mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-07-28 01:51:49 +03:00
Untabify every single file
YOLO. This is a repeat of #642. As before, I just did rg -l '\t' | xargs -n 1 sed -i -e 's/\t/ /g' inside the desktop_version/ folder.
This commit is contained in:
+212
-212
@@ -20,332 +20,332 @@ option(OFFICIAL_BUILD "Compile an official build of the game" OFF)
|
|||||||
option(MAKEANDPLAY "Compile a version of the game without the main campaign (provided for convenience; consider modifying MakeAndPlay.h instead" OFF)
|
option(MAKEANDPLAY "Compile a version of the game without the main campaign (provided for convenience; consider modifying MakeAndPlay.h instead" OFF)
|
||||||
|
|
||||||
if(OFFICIAL_BUILD AND NOT MAKEANDPLAY)
|
if(OFFICIAL_BUILD AND NOT MAKEANDPLAY)
|
||||||
set(STEAM ON)
|
set(STEAM ON)
|
||||||
set(GOG ON)
|
set(GOG ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.1.3")
|
if(${CMAKE_VERSION} VERSION_LESS "3.1.3")
|
||||||
message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!")
|
message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_STANDARD 90)
|
set(CMAKE_C_STANDARD 90)
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 98)
|
set(CMAKE_CXX_STANDARD 98)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Architecture Flags
|
# Architecture Flags
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# Wow, Apple is a huge jerk these days huh?
|
# Wow, Apple is a huge jerk these days huh?
|
||||||
set(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
|
set(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
|
||||||
if(NOT CMAKE_OSX_SYSROOT)
|
if(NOT CMAKE_OSX_SYSROOT)
|
||||||
if(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
|
if(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
|
||||||
set(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
|
set(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
|
||||||
else()
|
else()
|
||||||
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
|
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
||||||
link_directories(/usr/local/lib)
|
link_directories(/usr/local/lib)
|
||||||
add_compile_options(-Werror=partial-availability)
|
add_compile_options(-Werror=partial-availability)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(VVVVVV)
|
project(VVVVVV)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
|
message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# RPATH
|
# RPATH
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(BIN_LIBROOT "osx")
|
set(BIN_LIBROOT "osx")
|
||||||
set(BIN_RPATH "@executable_path/osx")
|
set(BIN_RPATH "@executable_path/osx")
|
||||||
elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
set(BIN_LIBROOT "lib64")
|
set(BIN_LIBROOT "lib64")
|
||||||
set(BIN_RPATH "\$ORIGIN/lib64")
|
set(BIN_RPATH "\$ORIGIN/lib64")
|
||||||
else()
|
else()
|
||||||
set(BIN_LIBROOT "lib")
|
set(BIN_LIBROOT "lib")
|
||||||
set(BIN_RPATH "\$ORIGIN/lib")
|
set(BIN_RPATH "\$ORIGIN/lib")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Source Lists
|
# Source Lists
|
||||||
set(VVV_SRC
|
set(VVV_SRC
|
||||||
src/BinaryBlob.cpp
|
src/BinaryBlob.cpp
|
||||||
src/BlockV.cpp
|
src/BlockV.cpp
|
||||||
src/Ent.cpp
|
src/Ent.cpp
|
||||||
src/Entity.cpp
|
src/Entity.cpp
|
||||||
src/FileSystemUtils.cpp
|
src/FileSystemUtils.cpp
|
||||||
src/Finalclass.cpp
|
src/Finalclass.cpp
|
||||||
src/Game.cpp
|
src/Game.cpp
|
||||||
src/Graphics.cpp
|
src/Graphics.cpp
|
||||||
src/GraphicsResources.cpp
|
src/GraphicsResources.cpp
|
||||||
src/GraphicsUtil.cpp
|
src/GraphicsUtil.cpp
|
||||||
src/Input.cpp
|
src/Input.cpp
|
||||||
src/KeyPoll.cpp
|
src/KeyPoll.cpp
|
||||||
src/Labclass.cpp
|
src/Labclass.cpp
|
||||||
src/Logic.cpp
|
src/Logic.cpp
|
||||||
src/Map.cpp
|
src/Map.cpp
|
||||||
src/Music.cpp
|
src/Music.cpp
|
||||||
src/Otherlevel.cpp
|
src/Otherlevel.cpp
|
||||||
src/preloader.cpp
|
src/preloader.cpp
|
||||||
src/Render.cpp
|
src/Render.cpp
|
||||||
src/RenderFixed.cpp
|
src/RenderFixed.cpp
|
||||||
src/Screen.cpp
|
src/Screen.cpp
|
||||||
src/Script.cpp
|
src/Script.cpp
|
||||||
src/Scripts.cpp
|
src/Scripts.cpp
|
||||||
src/SoundSystem.cpp
|
src/SoundSystem.cpp
|
||||||
src/Spacestation2.cpp
|
src/Spacestation2.cpp
|
||||||
src/TerminalScripts.cpp
|
src/TerminalScripts.cpp
|
||||||
src/Textbox.cpp
|
src/Textbox.cpp
|
||||||
src/Tower.cpp
|
src/Tower.cpp
|
||||||
src/UtilityClass.cpp
|
src/UtilityClass.cpp
|
||||||
src/WarpClass.cpp
|
src/WarpClass.cpp
|
||||||
src/XMLUtils.cpp
|
src/XMLUtils.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/DeferCallbacks.c
|
src/DeferCallbacks.c
|
||||||
src/GlitchrunnerMode.c
|
src/GlitchrunnerMode.c
|
||||||
src/Network.c
|
src/Network.c
|
||||||
src/ThirdPartyDeps.c
|
src/ThirdPartyDeps.c
|
||||||
src/Vlogging.c
|
src/Vlogging.c
|
||||||
src/Xoshiro.c
|
src/Xoshiro.c
|
||||||
../third_party/physfs/extras/physfsrwops.c
|
../third_party/physfs/extras/physfsrwops.c
|
||||||
)
|
)
|
||||||
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
|
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
|
||||||
list(APPEND VVV_SRC src/CustomLevels.cpp)
|
list(APPEND VVV_SRC src/CustomLevels.cpp)
|
||||||
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
|
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
|
||||||
LIST(APPEND VVV_SRC src/Editor.cpp)
|
LIST(APPEND VVV_SRC src/Editor.cpp)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(STEAM)
|
if(STEAM)
|
||||||
list(APPEND VVV_SRC src/SteamNetwork.c)
|
list(APPEND VVV_SRC src/SteamNetwork.c)
|
||||||
endif()
|
endif()
|
||||||
if(GOG)
|
if(GOG)
|
||||||
list(APPEND VVV_SRC src/GOGNetwork.c)
|
list(APPEND VVV_SRC src/GOGNetwork.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Executable information
|
# Executable information
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_executable(VVVVVV WIN32 ${VVV_SRC} icon.rc)
|
add_executable(VVVVVV WIN32 ${VVV_SRC} icon.rc)
|
||||||
else()
|
else()
|
||||||
add_executable(VVVVVV ${VVV_SRC})
|
add_executable(VVVVVV ${VVV_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Include Directories
|
# Include Directories
|
||||||
if(BUNDLE_DEPENDENCIES)
|
if(BUNDLE_DEPENDENCIES)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
VVVVVV PRIVATE
|
VVVVVV PRIVATE
|
||||||
src
|
src
|
||||||
../third_party/tinyxml2
|
../third_party/tinyxml2
|
||||||
../third_party/physfs
|
../third_party/physfs
|
||||||
../third_party/physfs/extras
|
../third_party/physfs/extras
|
||||||
../third_party/lodepng
|
../third_party/lodepng
|
||||||
../third_party/utfcpp/source
|
../third_party/utfcpp/source
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
VVVVVV PRIVATE
|
VVVVVV PRIVATE
|
||||||
src
|
src
|
||||||
../third_party/lodepng
|
../third_party/lodepng
|
||||||
../third_party/physfs/extras
|
../third_party/physfs/extras
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MAKEANDPLAY)
|
if(MAKEANDPLAY)
|
||||||
target_compile_definitions(VVVVVV PRIVATE -DMAKEANDPLAY)
|
target_compile_definitions(VVVVVV PRIVATE -DMAKEANDPLAY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(STEAM)
|
if(STEAM)
|
||||||
target_compile_definitions(VVVVVV PRIVATE -DSTEAM_NETWORK)
|
target_compile_definitions(VVVVVV PRIVATE -DSTEAM_NETWORK)
|
||||||
endif()
|
endif()
|
||||||
if(GOG)
|
if(GOG)
|
||||||
target_compile_definitions(VVVVVV PRIVATE -DGOG_NETWORK)
|
target_compile_definitions(VVVVVV PRIVATE -DGOG_NETWORK)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(XML2_SRC
|
set(XML2_SRC
|
||||||
../third_party/tinyxml2/tinyxml2.cpp
|
../third_party/tinyxml2/tinyxml2.cpp
|
||||||
)
|
)
|
||||||
set(PFS_SRC
|
set(PFS_SRC
|
||||||
../third_party/physfs/physfs.c
|
../third_party/physfs/physfs.c
|
||||||
../third_party/physfs/physfs_archiver_dir.c
|
../third_party/physfs/physfs_archiver_dir.c
|
||||||
../third_party/physfs/physfs_archiver_unpacked.c
|
../third_party/physfs/physfs_archiver_unpacked.c
|
||||||
../third_party/physfs/physfs_archiver_zip.c
|
../third_party/physfs/physfs_archiver_zip.c
|
||||||
../third_party/physfs/physfs_byteorder.c
|
../third_party/physfs/physfs_byteorder.c
|
||||||
../third_party/physfs/physfs_unicode.c
|
../third_party/physfs/physfs_unicode.c
|
||||||
../third_party/physfs/physfs_platform_posix.c
|
../third_party/physfs/physfs_platform_posix.c
|
||||||
../third_party/physfs/physfs_platform_unix.c
|
../third_party/physfs/physfs_platform_unix.c
|
||||||
../third_party/physfs/physfs_platform_windows.c
|
../third_party/physfs/physfs_platform_windows.c
|
||||||
../third_party/physfs/physfs_platform_haiku.cpp
|
../third_party/physfs/physfs_platform_haiku.cpp
|
||||||
)
|
)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# Are you noticing a pattern with this Apple crap yet?
|
# Are you noticing a pattern with this Apple crap yet?
|
||||||
set(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m)
|
set(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m)
|
||||||
endif()
|
endif()
|
||||||
set(PNG_SRC ../third_party/lodepng/lodepng.c)
|
set(PNG_SRC ../third_party/lodepng/lodepng.c)
|
||||||
|
|
||||||
if(NOT OFFICIAL_BUILD)
|
if(NOT OFFICIAL_BUILD)
|
||||||
# Add interim commit hash and its date to the build
|
# Add interim commit hash and its date to the build
|
||||||
|
|
||||||
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
# find_package sets GIT_FOUND and GIT_EXECUTABLE
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
# These filenames have to be qualified, because when we run
|
# These filenames have to be qualified, because when we run
|
||||||
# the CMake script, its work dir gets set to the build folder
|
# the CMake script, its work dir gets set to the build folder
|
||||||
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in)
|
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in)
|
||||||
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out)
|
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
GenerateVersion ALL
|
GenerateVersion ALL
|
||||||
# This BYPRODUCTS line is required for this to be ran every time
|
# This BYPRODUCTS line is required for this to be ran every time
|
||||||
BYPRODUCTS ${VERSION_OUTPUT_FILE}
|
BYPRODUCTS ${VERSION_OUTPUT_FILE}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
# These args have to be passed through, otherwise the script can't see them
|
# These args have to be passed through, otherwise the script can't see them
|
||||||
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
|
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
|
||||||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||||
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
-DINPUT_FILE=${VERSION_INPUT_FILE}
|
||||||
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(VVVVVV GenerateVersion)
|
add_dependencies(VVVVVV GenerateVersion)
|
||||||
|
|
||||||
# This lets Version.h know that Version.h.out exists
|
# This lets Version.h know that Version.h.out exists
|
||||||
add_definitions(-DVERSION_H_OUT_EXISTS)
|
add_definitions(-DVERSION_H_OUT_EXISTS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build options
|
# Build options
|
||||||
if(ENABLE_WARNINGS)
|
if(ENABLE_WARNINGS)
|
||||||
# The weird syntax is due to CMake generator expressions.
|
# The weird syntax is due to CMake generator expressions.
|
||||||
# Saves quite a few lines and boilerplate at the price of readability.
|
# Saves quite a few lines and boilerplate at the price of readability.
|
||||||
target_compile_options(VVVVVV PRIVATE
|
target_compile_options(VVVVVV PRIVATE
|
||||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||||
-Wall -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>>
|
-Wall -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>>
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
$<$<CXX_COMPILER_ID:MSVC>:
|
||||||
/W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>)
|
/W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
|
if(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
|
||||||
add_definitions(-DNO_EDITOR)
|
add_definitions(-DNO_EDITOR)
|
||||||
elseif(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
|
elseif(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
|
||||||
add_definitions(-DNO_CUSTOM_LEVELS -DNO_EDITOR)
|
add_definitions(-DNO_CUSTOM_LEVELS -DNO_EDITOR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
|
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||||
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
|
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
|
||||||
else()
|
else()
|
||||||
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
|
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
|
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(SUPPORTS_IMPLICIT_FALLTHROUGH)
|
if(SUPPORTS_IMPLICIT_FALLTHROUGH)
|
||||||
target_compile_options(VVVVVV PRIVATE -Werror=implicit-fallthrough)
|
target_compile_options(VVVVVV PRIVATE -Werror=implicit-fallthrough)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Disable MSVC warnings about implicit conversion
|
# Disable MSVC warnings about implicit conversion
|
||||||
target_compile_options(VVVVVV PRIVATE /wd4244)
|
target_compile_options(VVVVVV PRIVATE /wd4244)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Disable exceptions
|
# Disable exceptions
|
||||||
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
||||||
|
|
||||||
# Disable RTTI
|
# Disable RTTI
|
||||||
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||||
else()
|
else()
|
||||||
# Disable exceptions
|
# Disable exceptions
|
||||||
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||||
|
|
||||||
# Disable RTTI
|
# Disable RTTI
|
||||||
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Unfortunately, it doesn't seem like distros package LodePNG
|
# Unfortunately, it doesn't seem like distros package LodePNG
|
||||||
add_library(lodepng-static STATIC ${PNG_SRC})
|
add_library(lodepng-static STATIC ${PNG_SRC})
|
||||||
|
|
||||||
target_compile_definitions(lodepng-static PRIVATE
|
target_compile_definitions(lodepng-static PRIVATE
|
||||||
-DLODEPNG_NO_COMPILE_ALLOCATORS
|
-DLODEPNG_NO_COMPILE_ALLOCATORS
|
||||||
-DLODEPNG_NO_COMPILE_DISK
|
-DLODEPNG_NO_COMPILE_DISK
|
||||||
-DLODEPNG_NO_COMPILE_ENCODER
|
-DLODEPNG_NO_COMPILE_ENCODER
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUNDLE_DEPENDENCIES)
|
if(BUNDLE_DEPENDENCIES)
|
||||||
add_library(tinyxml2-static STATIC ${XML2_SRC})
|
add_library(tinyxml2-static STATIC ${XML2_SRC})
|
||||||
add_library(physfs-static STATIC ${PFS_SRC})
|
add_library(physfs-static STATIC ${PFS_SRC})
|
||||||
target_compile_definitions(physfs-static PRIVATE
|
target_compile_definitions(physfs-static PRIVATE
|
||||||
-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1
|
-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1
|
||||||
)
|
)
|
||||||
|
|
||||||
# PhysFS needs some extensions...
|
# PhysFS needs some extensions...
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER "3.1.3"
|
if(${CMAKE_VERSION} VERSION_GREATER "3.1.3"
|
||||||
OR ${CMAKE_VERSION} VERSION_EQUAL "3.1.3")
|
OR ${CMAKE_VERSION} VERSION_EQUAL "3.1.3")
|
||||||
set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON)
|
set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static)
|
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static)
|
||||||
else()
|
else()
|
||||||
find_package(utf8cpp CONFIG)
|
find_package(utf8cpp CONFIG)
|
||||||
|
|
||||||
target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static)
|
target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# SDL2 Dependency (Detection pulled from FAudio)
|
# SDL2 Dependency (Detection pulled from FAudio)
|
||||||
if(DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
if(DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
||||||
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
||||||
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
||||||
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
|
||||||
elseif (EMSCRIPTEN)
|
elseif (EMSCRIPTEN)
|
||||||
message(STATUS "Using Emscripten SDL2")
|
message(STATUS "Using Emscripten SDL2")
|
||||||
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
|
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
|
||||||
target_link_libraries(VVVVVV -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
|
target_link_libraries(VVVVVV -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
|
||||||
else()
|
else()
|
||||||
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
||||||
find_package(SDL2 CONFIG)
|
find_package(SDL2 CONFIG)
|
||||||
if(TARGET SDL2::SDL2)
|
if(TARGET SDL2::SDL2)
|
||||||
message(STATUS "Using TARGET SDL2::SDL2")
|
message(STATUS "Using TARGET SDL2::SDL2")
|
||||||
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
|
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
|
||||||
elseif(TARGET SDL2)
|
elseif(TARGET SDL2)
|
||||||
message(STATUS "Using TARGET SDL2")
|
message(STATUS "Using TARGET SDL2")
|
||||||
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
|
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
|
||||||
else()
|
else()
|
||||||
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
|
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
|
||||||
find_path(SDL2_MIXER_INCLUDE_DIRS NAMES SDL_mixer.h PATH_SUFFIXES SDL2)
|
find_path(SDL2_MIXER_INCLUDE_DIRS NAMES SDL_mixer.h PATH_SUFFIXES SDL2)
|
||||||
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>" ${SDL2_MIXER_INCLUDE_DIRS})
|
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>" ${SDL2_MIXER_INCLUDE_DIRS})
|
||||||
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Yes, more Apple Crap
|
# Yes, more Apple Crap
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
find_library(FOUNDATION NAMES Foundation)
|
find_library(FOUNDATION NAMES Foundation)
|
||||||
find_library(IOKIT NAMES IOKit)
|
find_library(IOKIT NAMES IOKit)
|
||||||
target_link_libraries(VVVVVV objc ${IOKIT} ${FOUNDATION})
|
target_link_libraries(VVVVVV objc ${IOKIT} ${FOUNDATION})
|
||||||
endif()
|
endif()
|
||||||
# But hey, also some Haiku crap
|
# But hey, also some Haiku crap
|
||||||
if(HAIKU)
|
if(HAIKU)
|
||||||
find_library(BE_LIBRARY be)
|
find_library(BE_LIBRARY be)
|
||||||
find_library(ROOT_LIBRARY root)
|
find_library(ROOT_LIBRARY root)
|
||||||
target_link_libraries(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
|
target_link_libraries(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_compile_options(VVVVVV PUBLIC -sFORCE_FILESYSTEM=1)
|
target_compile_options(VVVVVV PUBLIC -sFORCE_FILESYSTEM=1)
|
||||||
# 256MB is enough for everybody
|
# 256MB is enough for everybody
|
||||||
target_link_libraries(VVVVVV -sFORCE_FILESYSTEM=1 -sTOTAL_MEMORY=256MB)
|
target_link_libraries(VVVVVV -sFORCE_FILESYSTEM=1 -sTOTAL_MEMORY=256MB)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -12,136 +12,136 @@
|
|||||||
|
|
||||||
binaryBlob::binaryBlob(void)
|
binaryBlob::binaryBlob(void)
|
||||||
{
|
{
|
||||||
numberofHeaders = 0;
|
numberofHeaders = 0;
|
||||||
SDL_zeroa(m_headers);
|
SDL_zeroa(m_headers);
|
||||||
SDL_zeroa(m_memblocks);
|
SDL_zeroa(m_memblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VVV_COMPILEMUSIC
|
#ifdef VVV_COMPILEMUSIC
|
||||||
void binaryBlob::AddFileToBinaryBlob(const char* _path)
|
void binaryBlob::AddFileToBinaryBlob(const char* _path)
|
||||||
{
|
{
|
||||||
long size;
|
long size;
|
||||||
char * memblock;
|
char * memblock;
|
||||||
|
|
||||||
FILE *file = fopen(_path, "rb");
|
FILE *file = fopen(_path, "rb");
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
size = ftell(file);
|
size = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
memblock = (char*) SDL_malloc(size);
|
memblock = (char*) SDL_malloc(size);
|
||||||
if (memblock == NULL)
|
if (memblock == NULL)
|
||||||
{
|
{
|
||||||
VVV_exit(1);
|
VVV_exit(1);
|
||||||
}
|
}
|
||||||
fread(memblock, 1, size, file);
|
fread(memblock, 1, size, file);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
vlog_info("The complete file size: %li", size);
|
vlog_info("The complete file size: %li", size);
|
||||||
|
|
||||||
m_memblocks[numberofHeaders] = memblock;
|
m_memblocks[numberofHeaders] = memblock;
|
||||||
for (int i = 0; _path[i]; i += 1)
|
for (int i = 0; _path[i]; i += 1)
|
||||||
{
|
{
|
||||||
m_headers[numberofHeaders].name[i] = _path[i];
|
m_headers[numberofHeaders].name[i] = _path[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_headers[numberofHeaders].valid = true;
|
m_headers[numberofHeaders].valid = true;
|
||||||
m_headers[numberofHeaders].size = size;
|
m_headers[numberofHeaders].size = size;
|
||||||
numberofHeaders += 1;
|
numberofHeaders += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vlog_info("Unable to open file");
|
vlog_info("Unable to open file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void binaryBlob::writeBinaryBlob(const char* _name)
|
void binaryBlob::writeBinaryBlob(const char* _name)
|
||||||
{
|
{
|
||||||
FILE *file = fopen(_name, "wb");
|
FILE *file = fopen(_name, "wb");
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
fwrite((char*) &m_headers, 1, sizeof(m_headers), file);
|
fwrite((char*) &m_headers, 1, sizeof(m_headers), file);
|
||||||
|
|
||||||
for (int i = 0; i < numberofHeaders; i += 1)
|
for (int i = 0; i < numberofHeaders; i += 1)
|
||||||
{
|
{
|
||||||
fwrite(m_memblocks[i], 1, m_headers[i].size, file);
|
fwrite(m_memblocks[i], 1, m_headers[i].size, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vlog_info("Unable to open new file for writing. Feels bad.");
|
vlog_info("Unable to open new file for writing. Feels bad.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool binaryBlob::unPackBinary(const char* name)
|
bool binaryBlob::unPackBinary(const char* name)
|
||||||
{
|
{
|
||||||
return FILESYSTEM_loadBinaryBlob(this, name);
|
return FILESYSTEM_loadBinaryBlob(this, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void binaryBlob::clear(void)
|
void binaryBlob::clear(void)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
||||||
{
|
{
|
||||||
SDL_free(m_memblocks[i]);
|
SDL_free(m_memblocks[i]);
|
||||||
}
|
}
|
||||||
SDL_zeroa(m_memblocks);
|
SDL_zeroa(m_memblocks);
|
||||||
SDL_zeroa(m_headers);
|
SDL_zeroa(m_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
int binaryBlob::getIndex(const char* _name)
|
int binaryBlob::getIndex(const char* _name)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
||||||
{
|
{
|
||||||
if (SDL_strcmp(_name, m_headers[i].name) == 0 && m_headers[i].valid)
|
if (SDL_strcmp(_name, m_headers[i].name) == 0 && m_headers[i].valid)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int binaryBlob::getSize(int _index)
|
int binaryBlob::getSize(int _index)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_ARR(_index, m_headers))
|
if (!INBOUNDS_ARR(_index, m_headers))
|
||||||
{
|
{
|
||||||
vlog_error("getSize() out-of-bounds!");
|
vlog_error("getSize() out-of-bounds!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_headers[_index].size;
|
return m_headers[_index].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* binaryBlob::getAddress(int _index)
|
char* binaryBlob::getAddress(int _index)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_ARR(_index, m_memblocks))
|
if (!INBOUNDS_ARR(_index, m_memblocks))
|
||||||
{
|
{
|
||||||
vlog_error("getAddress() out-of-bounds!");
|
vlog_error("getAddress() out-of-bounds!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return m_memblocks[_index];
|
return m_memblocks[_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binaryBlob::nextExtra(size_t* start)
|
bool binaryBlob::nextExtra(size_t* start)
|
||||||
{
|
{
|
||||||
size_t* idx;
|
size_t* idx;
|
||||||
|
|
||||||
if (start == NULL)
|
if (start == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (idx = start; *idx < SDL_arraysize(m_headers); *idx += 1)
|
for (idx = start; *idx < SDL_arraysize(m_headers); *idx += 1)
|
||||||
{
|
{
|
||||||
if (m_headers[*idx].valid
|
if (m_headers[*idx].valid
|
||||||
#define FOREACH_TRACK(_, track_name) && SDL_strcmp(m_headers[*idx].name, "data/" track_name) != 0
|
#define FOREACH_TRACK(_, track_name) && SDL_strcmp(m_headers[*idx].name, "data/" track_name) != 0
|
||||||
TRACK_NAMES(_)
|
TRACK_NAMES(_)
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,59 +7,59 @@
|
|||||||
// #define VVV_COMPILEMUSIC
|
// #define VVV_COMPILEMUSIC
|
||||||
|
|
||||||
#define TRACK_NAMES(blob) \
|
#define TRACK_NAMES(blob) \
|
||||||
FOREACH_TRACK(blob, "music/0levelcomplete.ogg") \
|
FOREACH_TRACK(blob, "music/0levelcomplete.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/1pushingonwards.ogg") \
|
FOREACH_TRACK(blob, "music/1pushingonwards.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/2positiveforce.ogg") \
|
FOREACH_TRACK(blob, "music/2positiveforce.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/3potentialforanything.ogg") \
|
FOREACH_TRACK(blob, "music/3potentialforanything.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/4passionforexploring.ogg") \
|
FOREACH_TRACK(blob, "music/4passionforexploring.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/5intermission.ogg") \
|
FOREACH_TRACK(blob, "music/5intermission.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/6presentingvvvvvv.ogg") \
|
FOREACH_TRACK(blob, "music/6presentingvvvvvv.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/7gamecomplete.ogg") \
|
FOREACH_TRACK(blob, "music/7gamecomplete.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/8predestinedfate.ogg") \
|
FOREACH_TRACK(blob, "music/8predestinedfate.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/9positiveforcereversed.ogg") \
|
FOREACH_TRACK(blob, "music/9positiveforcereversed.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/10popularpotpourri.ogg") \
|
FOREACH_TRACK(blob, "music/10popularpotpourri.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/11pipedream.ogg") \
|
FOREACH_TRACK(blob, "music/11pipedream.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/12pressurecooker.ogg") \
|
FOREACH_TRACK(blob, "music/12pressurecooker.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/13pacedenergy.ogg") \
|
FOREACH_TRACK(blob, "music/13pacedenergy.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/14piercingthesky.ogg") \
|
FOREACH_TRACK(blob, "music/14piercingthesky.ogg") \
|
||||||
FOREACH_TRACK(blob, "music/predestinedfatefinallevel.ogg")
|
FOREACH_TRACK(blob, "music/predestinedfatefinallevel.ogg")
|
||||||
|
|
||||||
struct resourceheader
|
struct resourceheader
|
||||||
{
|
{
|
||||||
char name[48];
|
char name[48];
|
||||||
int start_UNUSED;
|
int start_UNUSED;
|
||||||
int size;
|
int size;
|
||||||
bool valid;
|
bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
class binaryBlob
|
class binaryBlob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
binaryBlob(void);
|
binaryBlob(void);
|
||||||
|
|
||||||
#ifdef VVV_COMPILEMUSIC
|
#ifdef VVV_COMPILEMUSIC
|
||||||
void AddFileToBinaryBlob(const char* _path);
|
void AddFileToBinaryBlob(const char* _path);
|
||||||
|
|
||||||
void writeBinaryBlob(const char* _name);
|
void writeBinaryBlob(const char* _name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool unPackBinary(const char* _name);
|
bool unPackBinary(const char* _name);
|
||||||
|
|
||||||
int getIndex(const char* _name);
|
int getIndex(const char* _name);
|
||||||
|
|
||||||
int getSize(int _index);
|
int getSize(int _index);
|
||||||
|
|
||||||
bool nextExtra(size_t* start);
|
bool nextExtra(size_t* start);
|
||||||
|
|
||||||
char* getAddress(int _index);
|
char* getAddress(int _index);
|
||||||
|
|
||||||
void clear(void);
|
void clear(void);
|
||||||
|
|
||||||
static const int max_headers = 128;
|
static const int max_headers = 128;
|
||||||
|
|
||||||
int numberofHeaders;
|
int numberofHeaders;
|
||||||
resourceheader m_headers[max_headers];
|
resourceheader m_headers[max_headers];
|
||||||
char* m_memblocks[max_headers];
|
char* m_memblocks[max_headers];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,102 +2,102 @@
|
|||||||
|
|
||||||
blockclass::blockclass(void)
|
blockclass::blockclass(void)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockclass::clear(void)
|
void blockclass::clear(void)
|
||||||
{
|
{
|
||||||
type = 0;
|
type = 0;
|
||||||
trigger = 0;
|
trigger = 0;
|
||||||
|
|
||||||
xp = 0;
|
xp = 0;
|
||||||
yp = 0;
|
yp = 0;
|
||||||
wp = 0;
|
wp = 0;
|
||||||
hp = 0;
|
hp = 0;
|
||||||
rect.x = xp;
|
rect.x = xp;
|
||||||
rect.y = yp;
|
rect.y = yp;
|
||||||
rect.w = wp;
|
rect.w = wp;
|
||||||
rect.h = hp;
|
rect.h = hp;
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
g = 0;
|
g = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
|
|
||||||
/* std::strings get initialized automatically, but this is */
|
/* std::strings get initialized automatically, but this is */
|
||||||
/* in case this function gets called again after construction */
|
/* in case this function gets called again after construction */
|
||||||
script.clear();
|
script.clear();
|
||||||
prompt.clear();
|
prompt.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
|
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
|
||||||
{
|
{
|
||||||
rect.x = xi;
|
rect.x = xi;
|
||||||
rect.y = yi;
|
rect.y = yi;
|
||||||
rect.w = wi;
|
rect.w = wi;
|
||||||
rect.h = hi;
|
rect.h = hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockclass::setblockcolour( std::string col )
|
void blockclass::setblockcolour( std::string col )
|
||||||
{
|
{
|
||||||
if (col == "cyan")
|
if (col == "cyan")
|
||||||
{
|
{
|
||||||
r = 164;
|
r = 164;
|
||||||
g = 164;
|
g = 164;
|
||||||
b = 255;
|
b = 255;
|
||||||
}
|
}
|
||||||
else if (col == "red")
|
else if (col == "red")
|
||||||
{
|
{
|
||||||
r = 255;
|
r = 255;
|
||||||
g = 60;
|
g = 60;
|
||||||
b = 60;
|
b = 60;
|
||||||
}
|
}
|
||||||
else if (col == "green")
|
else if (col == "green")
|
||||||
{
|
{
|
||||||
r = 144;
|
r = 144;
|
||||||
g = 255;
|
g = 255;
|
||||||
b = 144;
|
b = 144;
|
||||||
}
|
}
|
||||||
else if (col == "yellow")
|
else if (col == "yellow")
|
||||||
{
|
{
|
||||||
r = 255;
|
r = 255;
|
||||||
g = 255;
|
g = 255;
|
||||||
b = 134;
|
b = 134;
|
||||||
}
|
}
|
||||||
else if (col == "blue")
|
else if (col == "blue")
|
||||||
{
|
{
|
||||||
r = 95;
|
r = 95;
|
||||||
g = 95;
|
g = 95;
|
||||||
b = 255;
|
b = 255;
|
||||||
}
|
}
|
||||||
else if (col == "purple")
|
else if (col == "purple")
|
||||||
{
|
{
|
||||||
r = 255;
|
r = 255;
|
||||||
g = 134;
|
g = 134;
|
||||||
b = 255;
|
b = 255;
|
||||||
}
|
}
|
||||||
else if (col == "white")
|
else if (col == "white")
|
||||||
{
|
{
|
||||||
r = 244;
|
r = 244;
|
||||||
g = 244;
|
g = 244;
|
||||||
b = 244;
|
b = 244;
|
||||||
}
|
}
|
||||||
else if (col == "gray")
|
else if (col == "gray")
|
||||||
{
|
{
|
||||||
r = 174;
|
r = 174;
|
||||||
g = 174;
|
g = 174;
|
||||||
b = 174;
|
b = 174;
|
||||||
}
|
}
|
||||||
else if (col == "orange")
|
else if (col == "orange")
|
||||||
{
|
{
|
||||||
r = 255;
|
r = 255;
|
||||||
g = 130;
|
g = 130;
|
||||||
b = 20;
|
b = 20;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//use a gray
|
//use a gray
|
||||||
r = 174;
|
r = 174;
|
||||||
g = 174;
|
g = 174;
|
||||||
b = 174;
|
b = 174;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+616
-616
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
||||||
|
|
||||||
class entclass
|
class entclass
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,62 +148,62 @@ void entityclass::generateswnwave( int t )
|
|||||||
game.swnstate = 9;
|
game.swnstate = 9;
|
||||||
game.swndelay = 8;
|
game.swndelay = 8;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 300) //less than 10 seconds
|
else if (game.swntimer <= 300) //less than 10 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 6;
|
game.swnstate = 6;
|
||||||
game.swndelay = 12;
|
game.swndelay = 12;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 360) //less than 12 seconds
|
else if (game.swntimer <= 360) //less than 12 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 5+game.swnstate2;
|
game.swnstate = 5+game.swnstate2;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 420) //less than 14 seconds
|
else if (game.swntimer <= 420) //less than 14 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 7+game.swnstate2;
|
game.swnstate = 7+game.swnstate2;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 480) //less than 16 seconds
|
else if (game.swntimer <= 480) //less than 16 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 5+game.swnstate2;
|
game.swnstate = 5+game.swnstate2;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 540) //less than 18 seconds
|
else if (game.swntimer <= 540) //less than 18 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 7+game.swnstate2;
|
game.swnstate = 7+game.swnstate2;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 600) //less than 20 seconds
|
else if (game.swntimer <= 600) //less than 20 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 5+game.swnstate2;
|
game.swnstate = 5+game.swnstate2;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 900) //less than 30 seconds
|
else if (game.swntimer <= 900) //less than 30 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 4;
|
game.swnstate = 4;
|
||||||
game.swndelay = 20;
|
game.swndelay = 20;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 1050) //less than 35 seconds
|
else if (game.swntimer <= 1050) //less than 35 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 3;
|
game.swnstate = 3;
|
||||||
game.swndelay = 10;
|
game.swndelay = 10;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 1200) //less than 40 seconds
|
else if (game.swntimer <= 1200) //less than 40 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 3;
|
game.swnstate = 3;
|
||||||
game.swndelay = 20;
|
game.swndelay = 20;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 1500) //less than 50 seconds
|
else if (game.swntimer <= 1500) //less than 50 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 2;
|
game.swnstate = 2;
|
||||||
game.swndelay = 10;
|
game.swndelay = 10;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 1650) //less than 55 seconds
|
else if (game.swntimer <= 1650) //less than 55 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 1;
|
game.swnstate = 1;
|
||||||
game.swndelay = 15;
|
game.swndelay = 15;
|
||||||
}
|
}
|
||||||
else if (game.swntimer <= 1800) //less than 60 seconds
|
else if (game.swntimer <= 1800) //less than 60 seconds
|
||||||
{
|
{
|
||||||
game.swnstate = 1;
|
game.swnstate = 1;
|
||||||
game.swndelay = 25;
|
game.swndelay = 25;
|
||||||
@@ -2778,8 +2778,8 @@ bool entityclass::updateentities( int i )
|
|||||||
if (entities[i].state == 1)
|
if (entities[i].state == 1)
|
||||||
{
|
{
|
||||||
//happy!
|
//happy!
|
||||||
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 6) entities[k].tile = 0;
|
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 6) entities[k].tile = 0;
|
||||||
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 7) entities[k].tile = 6;
|
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 7) entities[k].tile = 6;
|
||||||
//Stay close to the hero!
|
//Stay close to the hero!
|
||||||
int j = getplayer();
|
int j = getplayer();
|
||||||
if (INBOUNDS_VEC(j, entities) && entities[j].xp > entities[i].xp + 5)
|
if (INBOUNDS_VEC(j, entities) && entities[j].xp > entities[i].xp + 5)
|
||||||
@@ -3060,7 +3060,7 @@ bool entityclass::updateentities( int i )
|
|||||||
entities[i].para = 30;
|
entities[i].para = 30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entities[i].life == 1)
|
else if (entities[i].life == 1)
|
||||||
{
|
{
|
||||||
//Stand around for a bit
|
//Stand around for a bit
|
||||||
entities[i].para--;
|
entities[i].para--;
|
||||||
@@ -3096,7 +3096,7 @@ bool entityclass::updateentities( int i )
|
|||||||
entities[i].para = 30;
|
entities[i].para = 30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entities[i].life == 3)
|
else if (entities[i].life == 3)
|
||||||
{
|
{
|
||||||
//Stand around for a bit
|
//Stand around for a bit
|
||||||
entities[i].para--;
|
entities[i].para--;
|
||||||
@@ -3688,7 +3688,7 @@ void entityclass::animateentities( int _i )
|
|||||||
{
|
{
|
||||||
entities[_i].drawframe ++;
|
entities[_i].drawframe ++;
|
||||||
//if (game.gravitycontrol == 1) {
|
//if (game.gravitycontrol == 1) {
|
||||||
// entities[_i].drawframe += 6;
|
// entities[_i].drawframe += 6;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
||||||
GAMEMODE, TITLEMODE, CLICKTOSTART, FOCUSMODE, MAPMODE, TELEPORTERMODE, GAMECOMPLETE, GAMECOMPLETE2, EDITORMODE, PRELOADER
|
GAMEMODE, TITLEMODE, CLICKTOSTART, FOCUSMODE, MAPMODE, TELEPORTERMODE, GAMECOMPLETE, GAMECOMPLETE2, EDITORMODE, PRELOADER
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+2598
-2598
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
int32_t GOG_init(void)
|
int32_t GOG_init(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GOG_shutdown(void)
|
void GOG_shutdown(void)
|
||||||
@@ -25,7 +25,7 @@ void GOG_unlockAchievement(const char *name)
|
|||||||
|
|
||||||
int32_t GOG_getAchievementProgress(const char *name)
|
int32_t GOG_getAchievementProgress(const char *name)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GOG_setAchievementProgress(const char *name, int32_t stat)
|
void GOG_setAchievementProgress(const char *name, int32_t stat)
|
||||||
|
|||||||
@@ -1396,7 +1396,7 @@ void Game::updatestate(void)
|
|||||||
|
|
||||||
case 80:
|
case 80:
|
||||||
//Used to return to menu from the game
|
//Used to return to menu from the game
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 81:
|
case 81:
|
||||||
quittomenu();
|
quittomenu();
|
||||||
@@ -1457,7 +1457,7 @@ void Game::updatestate(void)
|
|||||||
break;
|
break;
|
||||||
case 83:
|
case 83:
|
||||||
frames--;
|
frames--;
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 84:
|
case 84:
|
||||||
quittomenu();
|
quittomenu();
|
||||||
@@ -1534,7 +1534,7 @@ void Game::updatestate(void)
|
|||||||
|
|
||||||
case 96:
|
case 96:
|
||||||
//Used to return to gravitron to game
|
//Used to return to gravitron to game
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 97:
|
case 97:
|
||||||
returntolab();
|
returntolab();
|
||||||
@@ -1941,7 +1941,7 @@ void Game::updatestate(void)
|
|||||||
#endif
|
#endif
|
||||||
case 1014:
|
case 1014:
|
||||||
frames--;
|
frames--;
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 1015:
|
case 1015:
|
||||||
#if !defined(NO_CUSTOM_LEVELS)
|
#if !defined(NO_CUSTOM_LEVELS)
|
||||||
@@ -2571,7 +2571,7 @@ void Game::updatestate(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3100:
|
case 3100:
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 3101:
|
case 3101:
|
||||||
quittomenu();
|
quittomenu();
|
||||||
@@ -2815,7 +2815,7 @@ void Game::updatestate(void)
|
|||||||
state++;
|
state++;
|
||||||
break;
|
break;
|
||||||
case 3521:
|
case 3521:
|
||||||
if(graphics.fademode == 1) state++;
|
if(graphics.fademode == 1) state++;
|
||||||
break;
|
break;
|
||||||
case 3522:
|
case 3522:
|
||||||
copyndmresults();
|
copyndmresults();
|
||||||
|
|||||||
+468
-468
File diff suppressed because it is too large
Load Diff
+228
-228
@@ -15,350 +15,350 @@
|
|||||||
class Graphics
|
class Graphics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init(void);
|
void init(void);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
|
|
||||||
void create_buffers(const SDL_PixelFormat* fmt);
|
void create_buffers(const SDL_PixelFormat* fmt);
|
||||||
void destroy_buffers(void);
|
void destroy_buffers(void);
|
||||||
|
|
||||||
GraphicsResources grphx;
|
GraphicsResources grphx;
|
||||||
|
|
||||||
int bfontlen(uint32_t ch);
|
int bfontlen(uint32_t ch);
|
||||||
int font_idx(uint32_t ch);
|
int font_idx(uint32_t ch);
|
||||||
|
|
||||||
bool Makebfont(void);
|
bool Makebfont(void);
|
||||||
|
|
||||||
void drawhuetile(int x, int y, int t);
|
void drawhuetile(int x, int y, int t);
|
||||||
void huetilesetcol(int t);
|
void huetilesetcol(int t);
|
||||||
Uint32 bigchunkygetcol(int t);
|
Uint32 bigchunkygetcol(int t);
|
||||||
|
|
||||||
void drawgravityline(int t);
|
void drawgravityline(int t);
|
||||||
|
|
||||||
bool MakeTileArray(void);
|
bool MakeTileArray(void);
|
||||||
|
|
||||||
bool MakeSpriteArray(void);
|
bool MakeSpriteArray(void);
|
||||||
|
|
||||||
bool maketelearray(void);
|
bool maketelearray(void);
|
||||||
|
|
||||||
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
|
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
|
||||||
|
|
||||||
void drawmenu(int cr, int cg, int cb, bool levelmenu = false);
|
void drawmenu(int cr, int cg, int cb, bool levelmenu = false);
|
||||||
|
|
||||||
void processfade(void);
|
void processfade(void);
|
||||||
void setfade(const int amount);
|
void setfade(const int amount);
|
||||||
|
|
||||||
void drawfade(void);
|
void drawfade(void);
|
||||||
|
|
||||||
void setwarprect(int a, int b, int c, int d);
|
void setwarprect(int a, int b, int c, int d);
|
||||||
|
|
||||||
void createtextboxreal(
|
void createtextboxreal(
|
||||||
const std::string& t,
|
const std::string& t,
|
||||||
int xp,
|
int xp,
|
||||||
int yp,
|
int yp,
|
||||||
int r,
|
int r,
|
||||||
int g,
|
int g,
|
||||||
int b,
|
int b,
|
||||||
bool flipme
|
bool flipme
|
||||||
);
|
);
|
||||||
void createtextbox(
|
void createtextbox(
|
||||||
const std::string& t,
|
const std::string& t,
|
||||||
int xp,
|
int xp,
|
||||||
int yp,
|
int yp,
|
||||||
int r,
|
int r,
|
||||||
int g,
|
int g,
|
||||||
int b
|
int b
|
||||||
);
|
);
|
||||||
void createtextboxflipme(
|
void createtextboxflipme(
|
||||||
const std::string& t,
|
const std::string& t,
|
||||||
int xp,
|
int xp,
|
||||||
int yp,
|
int yp,
|
||||||
int r,
|
int r,
|
||||||
int g,
|
int g,
|
||||||
int b
|
int b
|
||||||
);
|
);
|
||||||
|
|
||||||
void textboxcenterx(void);
|
void textboxcenterx(void);
|
||||||
|
|
||||||
int textboxwidth(void);
|
int textboxwidth(void);
|
||||||
|
|
||||||
void textboxmoveto(int xo);
|
void textboxmoveto(int xo);
|
||||||
|
|
||||||
void textboxcentery(void);
|
void textboxcentery(void);
|
||||||
|
|
||||||
void textboxadjust(void);
|
void textboxadjust(void);
|
||||||
|
|
||||||
void addline(const std::string& t);
|
void addline(const std::string& t);
|
||||||
|
|
||||||
void textboxtimer(int t);
|
void textboxtimer(int t);
|
||||||
|
|
||||||
void textboxremove(void);
|
void textboxremove(void);
|
||||||
|
|
||||||
void textboxremovefast(void);
|
void textboxremovefast(void);
|
||||||
|
|
||||||
void textboxactive(void);
|
void textboxactive(void);
|
||||||
|
|
||||||
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
|
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
|
||||||
|
|
||||||
void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b);
|
void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b);
|
||||||
|
|
||||||
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);
|
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);
|
||||||
|
|
||||||
int crewcolour(const int t);
|
int crewcolour(const int t);
|
||||||
|
|
||||||
void cutscenebars(void);
|
void cutscenebars(void);
|
||||||
void cutscenebarstimer(void);
|
void cutscenebarstimer(void);
|
||||||
void setbars(const int position);
|
void setbars(const int position);
|
||||||
|
|
||||||
void drawpartimage(int t, int xp, int yp, int wp, int hp);
|
void drawpartimage(int t, int xp, int yp, int wp, int hp);
|
||||||
|
|
||||||
void drawimage(int t, int xp, int yp, bool cent=false);
|
void drawimage(int t, int xp, int yp, bool cent=false);
|
||||||
|
|
||||||
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
|
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
|
||||||
|
|
||||||
void updatetextboxes(void);
|
void updatetextboxes(void);
|
||||||
void drawgui(void);
|
void drawgui(void);
|
||||||
|
|
||||||
void drawsprite(int x, int y, int t, int r, int g, int b);
|
void drawsprite(int x, int y, int t, int r, int g, int b);
|
||||||
void drawsprite(int x, int y, int t, Uint32 c);
|
void drawsprite(int x, int y, int t, Uint32 c);
|
||||||
|
|
||||||
void printcrewname(int x, int y, int t);
|
void printcrewname(int x, int y, int t);
|
||||||
|
|
||||||
void printcrewnamestatus(int x, int y, int t);
|
void printcrewnamestatus(int x, int y, int t);
|
||||||
|
|
||||||
void printcrewnamedark(int x, int y, int t);
|
void printcrewnamedark(int x, int y, int t);
|
||||||
|
|
||||||
void map_tab(int opt, const std::string& text, bool selected = false);
|
void map_tab(int opt, const std::string& text, bool selected = false);
|
||||||
|
|
||||||
void map_option(int opt, int num_opts, const std::string& text, bool selected = false);
|
void map_option(int opt, int num_opts, const std::string& text, bool selected = false);
|
||||||
|
|
||||||
void do_print(int x, int y, const std::string& text, int r, int g, int b, int a, int scale);
|
void do_print(int x, int y, const std::string& text, int r, int g, int b, int a, int scale);
|
||||||
|
|
||||||
void Print(int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false);
|
void Print(int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false);
|
||||||
|
|
||||||
void PrintAlpha(int _x, int _y, const std::string& _s, int r, int g, int b, int a, bool cen = false);
|
void PrintAlpha(int _x, int _y, const std::string& _s, int r, int g, int b, int a, bool cen = false);
|
||||||
|
|
||||||
bool next_wrap(size_t* start, size_t* len, const char* str, int maxwidth);
|
bool next_wrap(size_t* start, size_t* len, const char* str, int maxwidth);
|
||||||
|
|
||||||
bool next_wrap_s(char buffer[], size_t buffer_size, size_t* start, const char* str, int maxwidth);
|
bool next_wrap_s(char buffer[], size_t buffer_size, size_t* start, const char* str, int maxwidth);
|
||||||
|
|
||||||
void PrintWrap(int x, int y, const char* str, int r, int g, int b, bool cen, int linespacing, int maxwidth);
|
void PrintWrap(int x, int y, const char* str, int r, int g, int b, bool cen, int linespacing, int maxwidth);
|
||||||
|
|
||||||
void bprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false);
|
void bprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false);
|
||||||
|
|
||||||
void bprintalpha(int x, int y, const std::string& t, int r, int g, int b, int a, bool cen = false);
|
void bprintalpha(int x, int y, const std::string& t, int r, int g, int b, int a, bool cen = false);
|
||||||
|
|
||||||
int len(const std::string& t);
|
int len(const std::string& t);
|
||||||
void bigprint( int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false, int sc = 2 );
|
void bigprint( int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false, int sc = 2 );
|
||||||
void bigbprint(int x, int y, const std::string& s, int r, int g, int b, bool cen = false, int sc = 2);
|
void bigbprint(int x, int y, const std::string& s, int r, int g, int b, bool cen = false, int sc = 2);
|
||||||
void drawspritesetcol(int x, int y, int t, int c);
|
void drawspritesetcol(int x, int y, int t, int c);
|
||||||
|
|
||||||
|
|
||||||
void flashlight(void);
|
void flashlight(void);
|
||||||
void screenshake(void);
|
void screenshake(void);
|
||||||
void updatescreenshake(void);
|
void updatescreenshake(void);
|
||||||
|
|
||||||
int screenshake_x;
|
int screenshake_x;
|
||||||
int screenshake_y;
|
int screenshake_y;
|
||||||
|
|
||||||
void render(void);
|
void render(void);
|
||||||
void renderwithscreeneffects(void);
|
void renderwithscreeneffects(void);
|
||||||
void renderfixedpre(void);
|
void renderfixedpre(void);
|
||||||
void renderfixedpost(void);
|
void renderfixedpost(void);
|
||||||
|
|
||||||
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);
|
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);
|
||||||
|
|
||||||
void drawentities(void);
|
void drawentities(void);
|
||||||
|
|
||||||
void drawentity(const int i, const int yoff);
|
void drawentity(const int i, const int yoff);
|
||||||
|
|
||||||
void drawtrophytext(void);
|
void drawtrophytext(void);
|
||||||
|
|
||||||
void bigrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
void bigrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
||||||
void bigbrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
void bigbrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
||||||
|
|
||||||
|
|
||||||
void drawtele(int x, int y, int t, Uint32 c);
|
void drawtele(int x, int y, int t, Uint32 c);
|
||||||
|
|
||||||
Uint32 getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
Uint32 getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||||
|
|
||||||
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
|
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
|
||||||
|
|
||||||
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
|
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
|
||||||
|
|
||||||
Uint32 getRGB(Uint32 _col);
|
Uint32 getRGB(Uint32 _col);
|
||||||
|
|
||||||
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
|
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
|
||||||
|
|
||||||
|
|
||||||
Uint32 RGBf(int r, int g, int b);
|
Uint32 RGBf(int r, int g, int b);
|
||||||
|
|
||||||
void setcolreal(Uint32 t);
|
void setcolreal(Uint32 t);
|
||||||
|
|
||||||
void drawbackground(int t);
|
void drawbackground(int t);
|
||||||
void updatebackground(int t);
|
void updatebackground(int t);
|
||||||
#ifndef NO_CUSTOM_LEVELS
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
bool shouldrecoloroneway(const int tilenum, const bool mounted);
|
bool shouldrecoloroneway(const int tilenum, const bool mounted);
|
||||||
#endif
|
#endif
|
||||||
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
|
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
|
||||||
void drawtile2( int x, int y, int t );
|
void drawtile2( int x, int y, int t );
|
||||||
void drawtile( int x, int y, int t );
|
void drawtile( int x, int y, int t );
|
||||||
void drawtowertile( int x, int y, int t );
|
void drawtowertile( int x, int y, int t );
|
||||||
void drawtowertile3( int x, int y, int t, TowerBG& bg_obj );
|
void drawtowertile3( int x, int y, int t, TowerBG& bg_obj );
|
||||||
|
|
||||||
void drawmap(void);
|
void drawmap(void);
|
||||||
|
|
||||||
void drawforetile(int x, int y, int t);
|
void drawforetile(int x, int y, int t);
|
||||||
|
|
||||||
void drawforetile2(int x, int y, int t);
|
void drawforetile2(int x, int y, int t);
|
||||||
|
|
||||||
void drawforetile3(int x, int y, int t, int off);
|
void drawforetile3(int x, int y, int t, int off);
|
||||||
|
|
||||||
void drawrect(int x, int y, int w, int h, int r, int g, int b);
|
void drawrect(int x, int y, int w, int h, int r, int g, int b);
|
||||||
|
|
||||||
void drawtowermap(void);
|
void drawtowermap(void);
|
||||||
|
|
||||||
void drawtowerspikes(void);
|
void drawtowerspikes(void);
|
||||||
|
|
||||||
bool onscreen(int t);
|
bool onscreen(int t);
|
||||||
|
|
||||||
bool reloadresources(void);
|
bool reloadresources(void);
|
||||||
#ifndef NO_CUSTOM_LEVELS
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
bool tiles1_mounted;
|
bool tiles1_mounted;
|
||||||
bool tiles2_mounted;
|
bool tiles2_mounted;
|
||||||
bool minimap_mounted;
|
bool minimap_mounted;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void menuoffrender(void);
|
void menuoffrender(void);
|
||||||
|
|
||||||
void drawtowerbackground(const TowerBG& bg_obj);
|
void drawtowerbackground(const TowerBG& bg_obj);
|
||||||
void updatetowerbackground(TowerBG& bg_obj);
|
void updatetowerbackground(TowerBG& bg_obj);
|
||||||
|
|
||||||
void setcol(int t);
|
void setcol(int t);
|
||||||
void drawfinalmap(void);
|
void drawfinalmap(void);
|
||||||
|
|
||||||
colourTransform ct;
|
colourTransform ct;
|
||||||
|
|
||||||
int rcol;
|
int rcol;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int m;
|
int m;
|
||||||
|
|
||||||
std::vector <SDL_Surface*> images;
|
std::vector <SDL_Surface*> images;
|
||||||
|
|
||||||
std::vector <SDL_Surface*> tele;
|
std::vector <SDL_Surface*> tele;
|
||||||
std::vector <SDL_Surface*> tiles;
|
std::vector <SDL_Surface*> tiles;
|
||||||
std::vector <SDL_Surface*> tiles2;
|
std::vector <SDL_Surface*> tiles2;
|
||||||
std::vector <SDL_Surface*> tiles3;
|
std::vector <SDL_Surface*> tiles3;
|
||||||
std::vector <SDL_Surface*> entcolours;
|
std::vector <SDL_Surface*> entcolours;
|
||||||
std::vector <SDL_Surface*> sprites;
|
std::vector <SDL_Surface*> sprites;
|
||||||
std::vector <SDL_Surface*> flipsprites;
|
std::vector <SDL_Surface*> flipsprites;
|
||||||
std::vector <SDL_Surface*> bfont;
|
std::vector <SDL_Surface*> bfont;
|
||||||
std::vector <SDL_Surface*> flipbfont;
|
std::vector <SDL_Surface*> flipbfont;
|
||||||
|
|
||||||
bool flipmode;
|
bool flipmode;
|
||||||
bool setflipmode;
|
bool setflipmode;
|
||||||
bool notextoutline;
|
bool notextoutline;
|
||||||
//buffer objects. //TODO refactor buffer objects
|
//buffer objects. //TODO refactor buffer objects
|
||||||
SDL_Surface* backBuffer;
|
SDL_Surface* backBuffer;
|
||||||
Screen* screenbuffer;
|
Screen* screenbuffer;
|
||||||
SDL_Surface* menubuffer;
|
SDL_Surface* menubuffer;
|
||||||
SDL_Surface* foregroundBuffer;
|
SDL_Surface* foregroundBuffer;
|
||||||
SDL_Surface* tempBuffer;
|
SDL_Surface* tempBuffer;
|
||||||
SDL_Surface* warpbuffer;
|
SDL_Surface* warpbuffer;
|
||||||
SDL_Surface* warpbuffer_lerp;
|
SDL_Surface* warpbuffer_lerp;
|
||||||
|
|
||||||
TowerBG towerbg;
|
TowerBG towerbg;
|
||||||
TowerBG titlebg;
|
TowerBG titlebg;
|
||||||
|
|
||||||
SDL_Rect bfont_rect;
|
SDL_Rect bfont_rect;
|
||||||
SDL_Rect tiles_rect;
|
SDL_Rect tiles_rect;
|
||||||
SDL_Rect sprites_rect;
|
SDL_Rect sprites_rect;
|
||||||
SDL_Rect images_rect;
|
SDL_Rect images_rect;
|
||||||
SDL_Rect bg_rect;
|
SDL_Rect bg_rect;
|
||||||
SDL_Rect line_rect;
|
SDL_Rect line_rect;
|
||||||
SDL_Rect tele_rect;
|
SDL_Rect tele_rect;
|
||||||
SDL_Rect towerbuffer_rect;
|
SDL_Rect towerbuffer_rect;
|
||||||
|
|
||||||
SDL_Rect foot_rect;
|
SDL_Rect foot_rect;
|
||||||
SDL_Rect prect;
|
SDL_Rect prect;
|
||||||
SDL_Rect footerrect;
|
SDL_Rect footerrect;
|
||||||
SDL_Surface* footerbuffer;
|
SDL_Surface* footerbuffer;
|
||||||
|
|
||||||
int linestate, linedelay;
|
int linestate, linedelay;
|
||||||
int backoffset;
|
int backoffset;
|
||||||
bool backgrounddrawn, foregrounddrawn;
|
bool backgrounddrawn, foregrounddrawn;
|
||||||
|
|
||||||
int menuoffset;
|
int menuoffset;
|
||||||
int oldmenuoffset;
|
int oldmenuoffset;
|
||||||
bool resumegamemode;
|
bool resumegamemode;
|
||||||
|
|
||||||
SDL_Rect warprect;
|
SDL_Rect warprect;
|
||||||
|
|
||||||
int crewframe;
|
int crewframe;
|
||||||
int crewframedelay;
|
int crewframedelay;
|
||||||
|
|
||||||
int fademode;
|
int fademode;
|
||||||
int fadeamount;
|
int fadeamount;
|
||||||
int oldfadeamount;
|
int oldfadeamount;
|
||||||
int fadebars[15];
|
int fadebars[15];
|
||||||
int ingame_fademode;
|
int ingame_fademode;
|
||||||
|
|
||||||
bool trinketcolset;
|
bool trinketcolset;
|
||||||
int trinketr, trinketg, trinketb;
|
int trinketr, trinketg, trinketb;
|
||||||
|
|
||||||
std::vector <textboxclass> textbox;
|
std::vector <textboxclass> textbox;
|
||||||
|
|
||||||
bool showcutscenebars;
|
bool showcutscenebars;
|
||||||
int cutscenebarspos;
|
int cutscenebarspos;
|
||||||
int oldcutscenebarspos;
|
int oldcutscenebarspos;
|
||||||
|
|
||||||
static const int numstars = 50;
|
static const int numstars = 50;
|
||||||
SDL_Rect stars[numstars];
|
SDL_Rect stars[numstars];
|
||||||
int starsspeed[numstars];
|
int starsspeed[numstars];
|
||||||
|
|
||||||
static const int numbackboxes = 18;
|
static const int numbackboxes = 18;
|
||||||
int spcol, spcoldel;
|
int spcol, spcoldel;
|
||||||
SDL_Rect backboxes[numbackboxes];
|
SDL_Rect backboxes[numbackboxes];
|
||||||
int backboxvx[numbackboxes];
|
int backboxvx[numbackboxes];
|
||||||
int backboxvy[numbackboxes];
|
int backboxvy[numbackboxes];
|
||||||
float backboxint[numbackboxes];
|
float backboxint[numbackboxes];
|
||||||
|
|
||||||
int warpskip, warpfcol, warpbcol;
|
int warpskip, warpfcol, warpbcol;
|
||||||
|
|
||||||
bool translucentroomname;
|
bool translucentroomname;
|
||||||
|
|
||||||
std::map<int, int> font_positions;
|
std::map<int, int> font_positions;
|
||||||
|
|
||||||
SDL_Surface* ghostbuffer;
|
SDL_Surface* ghostbuffer;
|
||||||
|
|
||||||
float inline lerp(const float v0, const float v1)
|
float inline lerp(const float v0, const float v1)
|
||||||
{
|
{
|
||||||
return v0 + alpha * (v1 - v0);
|
return v0 + alpha * (v1 - v0);
|
||||||
}
|
}
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
||||||
Uint32 col_crewred;
|
Uint32 col_crewred;
|
||||||
Uint32 col_crewyellow;
|
Uint32 col_crewyellow;
|
||||||
Uint32 col_crewgreen;
|
Uint32 col_crewgreen;
|
||||||
Uint32 col_crewcyan;
|
Uint32 col_crewcyan;
|
||||||
Uint32 col_crewblue;
|
Uint32 col_crewblue;
|
||||||
Uint32 col_crewpurple; //actually pink
|
Uint32 col_crewpurple; //actually pink
|
||||||
Uint32 col_crewinactive;
|
Uint32 col_crewinactive;
|
||||||
Uint32 col_clock;
|
Uint32 col_clock;
|
||||||
Uint32 col_trinket;
|
Uint32 col_trinket;
|
||||||
int col_tr;
|
int col_tr;
|
||||||
int col_tg;
|
int col_tg;
|
||||||
int col_tb;
|
int col_tb;
|
||||||
void updatetitlecolours(void);
|
void updatetitlecolours(void);
|
||||||
|
|
||||||
bool kludgeswnlinewidth;
|
bool kludgeswnlinewidth;
|
||||||
|
|
||||||
Uint32 crewcolourreal(int t);
|
Uint32 crewcolourreal(int t);
|
||||||
|
|
||||||
char error[128];
|
char error[128];
|
||||||
char error_title[128]; /* for SDL_ShowSimpleMessageBox */
|
char error_title[128]; /* for SDL_ShowSimpleMessageBox */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef GRAPHICS_DEFINITION
|
#ifndef GRAPHICS_DEFINITION
|
||||||
|
|||||||
@@ -6,140 +6,140 @@
|
|||||||
// Used to load PNG data
|
// Used to load PNG data
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern unsigned lodepng_decode24(
|
extern unsigned lodepng_decode24(
|
||||||
unsigned char** out,
|
unsigned char** out,
|
||||||
unsigned* w,
|
unsigned* w,
|
||||||
unsigned* h,
|
unsigned* h,
|
||||||
const unsigned char* in,
|
const unsigned char* in,
|
||||||
size_t insize
|
size_t insize
|
||||||
);
|
);
|
||||||
extern unsigned lodepng_decode32(
|
extern unsigned lodepng_decode32(
|
||||||
unsigned char** out,
|
unsigned char** out,
|
||||||
unsigned* w,
|
unsigned* w,
|
||||||
unsigned* h,
|
unsigned* h,
|
||||||
const unsigned char* in,
|
const unsigned char* in,
|
||||||
size_t insize
|
size_t insize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool noAlpha = false)
|
static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool noAlpha = false)
|
||||||
{
|
{
|
||||||
//Temporary storage for the image that's loaded
|
//Temporary storage for the image that's loaded
|
||||||
SDL_Surface* loadedImage = NULL;
|
SDL_Surface* loadedImage = NULL;
|
||||||
//The optimized image that will be used
|
//The optimized image that will be used
|
||||||
SDL_Surface* optimizedImage = NULL;
|
SDL_Surface* optimizedImage = NULL;
|
||||||
|
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
|
|
||||||
unsigned char *fileIn;
|
unsigned char *fileIn;
|
||||||
size_t length;
|
size_t length;
|
||||||
FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false);
|
FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false);
|
||||||
if (fileIn == NULL)
|
if (fileIn == NULL)
|
||||||
{
|
{
|
||||||
SDL_assert(0 && "Image file missing!");
|
SDL_assert(0 && "Image file missing!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (noAlpha)
|
if (noAlpha)
|
||||||
{
|
{
|
||||||
lodepng_decode24(&data, &width, &height, fileIn, length);
|
lodepng_decode24(&data, &width, &height, fileIn, length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lodepng_decode32(&data, &width, &height, fileIn, length);
|
lodepng_decode32(&data, &width, &height, fileIn, length);
|
||||||
}
|
}
|
||||||
FILESYSTEM_freeMemory(&fileIn);
|
FILESYSTEM_freeMemory(&fileIn);
|
||||||
|
|
||||||
loadedImage = SDL_CreateRGBSurfaceFrom(
|
loadedImage = SDL_CreateRGBSurfaceFrom(
|
||||||
data,
|
data,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
noAlpha ? 24 : 32,
|
noAlpha ? 24 : 32,
|
||||||
width * (noAlpha ? 3 : 4),
|
width * (noAlpha ? 3 : 4),
|
||||||
0x000000FF,
|
0x000000FF,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
noAlpha ? 0x00000000 : 0xFF000000
|
noAlpha ? 0x00000000 : 0xFF000000
|
||||||
);
|
);
|
||||||
|
|
||||||
if (loadedImage != NULL)
|
if (loadedImage != NULL)
|
||||||
{
|
{
|
||||||
optimizedImage = SDL_ConvertSurfaceFormat(
|
optimizedImage = SDL_ConvertSurfaceFormat(
|
||||||
loadedImage,
|
loadedImage,
|
||||||
SDL_PIXELFORMAT_ABGR8888, // FIXME: Format? -flibit
|
SDL_PIXELFORMAT_ABGR8888, // FIXME: Format? -flibit
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
SDL_FreeSurface( loadedImage );
|
SDL_FreeSurface( loadedImage );
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
if (noBlend)
|
if (noBlend)
|
||||||
{
|
{
|
||||||
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
|
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
|
||||||
}
|
}
|
||||||
return optimizedImage;
|
return optimizedImage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
vlog_error("Image not found: %s", filename);
|
vlog_error("Image not found: %s", filename);
|
||||||
SDL_assert(0 && "Image not found! See stderr.");
|
SDL_assert(0 && "Image not found! See stderr.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsResources::init(void)
|
void GraphicsResources::init(void)
|
||||||
{
|
{
|
||||||
im_tiles = LoadImage("graphics/tiles.png");
|
im_tiles = LoadImage("graphics/tiles.png");
|
||||||
im_tiles2 = LoadImage("graphics/tiles2.png");
|
im_tiles2 = LoadImage("graphics/tiles2.png");
|
||||||
im_tiles3 = LoadImage("graphics/tiles3.png");
|
im_tiles3 = LoadImage("graphics/tiles3.png");
|
||||||
im_entcolours = LoadImage("graphics/entcolours.png");
|
im_entcolours = LoadImage("graphics/entcolours.png");
|
||||||
im_sprites = LoadImage("graphics/sprites.png");
|
im_sprites = LoadImage("graphics/sprites.png");
|
||||||
im_flipsprites = LoadImage("graphics/flipsprites.png");
|
im_flipsprites = LoadImage("graphics/flipsprites.png");
|
||||||
im_bfont = LoadImage("graphics/font.png");
|
im_bfont = LoadImage("graphics/font.png");
|
||||||
im_teleporter = LoadImage("graphics/teleporter.png");
|
im_teleporter = LoadImage("graphics/teleporter.png");
|
||||||
|
|
||||||
im_image0 = LoadImage("graphics/levelcomplete.png", false);
|
im_image0 = LoadImage("graphics/levelcomplete.png", false);
|
||||||
im_image1 = LoadImage("graphics/minimap.png", true, true);
|
im_image1 = LoadImage("graphics/minimap.png", true, true);
|
||||||
im_image2 = LoadImage("graphics/covered.png", true, true);
|
im_image2 = LoadImage("graphics/covered.png", true, true);
|
||||||
im_image3 = LoadImage("graphics/elephant.png");
|
im_image3 = LoadImage("graphics/elephant.png");
|
||||||
im_image4 = LoadImage("graphics/gamecomplete.png", false);
|
im_image4 = LoadImage("graphics/gamecomplete.png", false);
|
||||||
im_image5 = LoadImage("graphics/fliplevelcomplete.png", false);
|
im_image5 = LoadImage("graphics/fliplevelcomplete.png", false);
|
||||||
im_image6 = LoadImage("graphics/flipgamecomplete.png", false);
|
im_image6 = LoadImage("graphics/flipgamecomplete.png", false);
|
||||||
im_image7 = LoadImage("graphics/site.png", false);
|
im_image7 = LoadImage("graphics/site.png", false);
|
||||||
im_image8 = LoadImage("graphics/site2.png");
|
im_image8 = LoadImage("graphics/site2.png");
|
||||||
im_image9 = LoadImage("graphics/site3.png");
|
im_image9 = LoadImage("graphics/site3.png");
|
||||||
im_image10 = LoadImage("graphics/ending.png");
|
im_image10 = LoadImage("graphics/ending.png");
|
||||||
im_image11 = LoadImage("graphics/site4.png");
|
im_image11 = LoadImage("graphics/site4.png");
|
||||||
im_image12 = LoadImage("graphics/minimap.png");
|
im_image12 = LoadImage("graphics/minimap.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicsResources::destroy(void)
|
void GraphicsResources::destroy(void)
|
||||||
{
|
{
|
||||||
#define CLEAR(img) \
|
#define CLEAR(img) \
|
||||||
SDL_FreeSurface(img); \
|
SDL_FreeSurface(img); \
|
||||||
img = NULL;
|
img = NULL;
|
||||||
|
|
||||||
CLEAR(im_tiles);
|
CLEAR(im_tiles);
|
||||||
CLEAR(im_tiles2);
|
CLEAR(im_tiles2);
|
||||||
CLEAR(im_tiles3);
|
CLEAR(im_tiles3);
|
||||||
CLEAR(im_entcolours);
|
CLEAR(im_entcolours);
|
||||||
CLEAR(im_sprites);
|
CLEAR(im_sprites);
|
||||||
CLEAR(im_flipsprites);
|
CLEAR(im_flipsprites);
|
||||||
CLEAR(im_bfont);
|
CLEAR(im_bfont);
|
||||||
CLEAR(im_teleporter);
|
CLEAR(im_teleporter);
|
||||||
|
|
||||||
CLEAR(im_image0);
|
CLEAR(im_image0);
|
||||||
CLEAR(im_image1);
|
CLEAR(im_image1);
|
||||||
CLEAR(im_image2);
|
CLEAR(im_image2);
|
||||||
CLEAR(im_image3);
|
CLEAR(im_image3);
|
||||||
CLEAR(im_image4);
|
CLEAR(im_image4);
|
||||||
CLEAR(im_image5);
|
CLEAR(im_image5);
|
||||||
CLEAR(im_image6);
|
CLEAR(im_image6);
|
||||||
CLEAR(im_image7);
|
CLEAR(im_image7);
|
||||||
CLEAR(im_image8);
|
CLEAR(im_image8);
|
||||||
CLEAR(im_image9);
|
CLEAR(im_image9);
|
||||||
CLEAR(im_image10);
|
CLEAR(im_image10);
|
||||||
CLEAR(im_image11);
|
CLEAR(im_image11);
|
||||||
CLEAR(im_image12);
|
CLEAR(im_image12);
|
||||||
#undef CLEAR
|
#undef CLEAR
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1013,49 +1013,49 @@ static void menuactionpress(void)
|
|||||||
case Menu::unlockmenutrials:
|
case Menu::unlockmenutrials:
|
||||||
switch (game.currentmenuoption)
|
switch (game.currentmenuoption)
|
||||||
{
|
{
|
||||||
case 0: //unlock 1
|
case 0: //unlock 1
|
||||||
game.unlock[9] = true;
|
game.unlock[9] = true;
|
||||||
game.unlocknotify[9] = true;
|
game.unlocknotify[9] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 1: //unlock 2
|
case 1: //unlock 2
|
||||||
game.unlock[10] = true;
|
game.unlock[10] = true;
|
||||||
game.unlocknotify[10] = true;
|
game.unlocknotify[10] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 2: //unlock 3
|
case 2: //unlock 3
|
||||||
game.unlock[11] = true;
|
game.unlock[11] = true;
|
||||||
game.unlocknotify[11] = true;
|
game.unlocknotify[11] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 3: //unlock 4
|
case 3: //unlock 4
|
||||||
game.unlock[12] = true;
|
game.unlock[12] = true;
|
||||||
game.unlocknotify[12] = true;
|
game.unlocknotify[12] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 4: //unlock 5
|
case 4: //unlock 5
|
||||||
game.unlock[13] = true;
|
game.unlock[13] = true;
|
||||||
game.unlocknotify[13] = true;
|
game.unlocknotify[13] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 5: //unlock 6
|
case 5: //unlock 6
|
||||||
game.unlock[14] = true;
|
game.unlock[14] = true;
|
||||||
game.unlocknotify[14] = true;
|
game.unlocknotify[14] = true;
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.createmenu(Menu::unlockmenutrials, true);
|
game.createmenu(Menu::unlockmenutrials, true);
|
||||||
game.savestatsandsettings_menu();
|
game.savestatsandsettings_menu();
|
||||||
break;
|
break;
|
||||||
case 6: //back
|
case 6: //back
|
||||||
//back
|
//back
|
||||||
music.playef(11);
|
music.playef(11);
|
||||||
game.returnmenu();
|
game.returnmenu();
|
||||||
|
|||||||
+377
-377
@@ -13,464 +13,464 @@
|
|||||||
|
|
||||||
int inline KeyPoll::getThreshold(void)
|
int inline KeyPoll::getThreshold(void)
|
||||||
{
|
{
|
||||||
switch (sensitivity)
|
switch (sensitivity)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return 28000;
|
return 28000;
|
||||||
case 1:
|
case 1:
|
||||||
return 16000;
|
return 16000;
|
||||||
case 2:
|
case 2:
|
||||||
return 8000;
|
return 8000;
|
||||||
case 3:
|
case 3:
|
||||||
return 4000;
|
return 4000;
|
||||||
case 4:
|
case 4:
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 8000;
|
return 8000;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPoll::KeyPoll(void)
|
KeyPoll::KeyPoll(void)
|
||||||
{
|
{
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
// 0..5
|
// 0..5
|
||||||
sensitivity = 2;
|
sensitivity = 2;
|
||||||
|
|
||||||
keybuffer="";
|
keybuffer="";
|
||||||
leftbutton=0; rightbutton=0; middlebutton=0;
|
leftbutton=0; rightbutton=0; middlebutton=0;
|
||||||
mx=0; my=0;
|
mx=0; my=0;
|
||||||
resetWindow = 0;
|
resetWindow = 0;
|
||||||
pressedbackspace=false;
|
pressedbackspace=false;
|
||||||
|
|
||||||
linealreadyemptykludge = false;
|
linealreadyemptykludge = false;
|
||||||
|
|
||||||
isActive = true;
|
isActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPoll::enabletextentry(void)
|
void KeyPoll::enabletextentry(void)
|
||||||
{
|
{
|
||||||
keybuffer="";
|
keybuffer="";
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPoll::disabletextentry(void)
|
void KeyPoll::disabletextentry(void)
|
||||||
{
|
{
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::textentry(void)
|
bool KeyPoll::textentry(void)
|
||||||
{
|
{
|
||||||
return SDL_IsTextInputActive() == SDL_TRUE;
|
return SDL_IsTextInputActive() == SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPoll::toggleFullscreen(void)
|
void KeyPoll::toggleFullscreen(void)
|
||||||
{
|
{
|
||||||
if (graphics.screenbuffer != NULL)
|
if (graphics.screenbuffer != NULL)
|
||||||
{
|
{
|
||||||
graphics.screenbuffer->toggleFullScreen();
|
graphics.screenbuffer->toggleFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
keymap.clear(); /* we lost the input due to a new window. */
|
keymap.clear(); /* we lost the input due to a new window. */
|
||||||
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
|
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
|
||||||
{
|
{
|
||||||
game.press_left = false;
|
game.press_left = false;
|
||||||
game.press_right = false;
|
game.press_right = false;
|
||||||
game.press_action = true;
|
game.press_action = true;
|
||||||
game.press_map = false;
|
game.press_map = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int changemousestate(
|
static int changemousestate(
|
||||||
int timeout,
|
int timeout,
|
||||||
const bool show,
|
const bool show,
|
||||||
const bool hide
|
const bool hide
|
||||||
) {
|
) {
|
||||||
int prev;
|
int prev;
|
||||||
int new_;
|
int new_;
|
||||||
|
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
{
|
{
|
||||||
return --timeout;
|
return --timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we want to both show and hide at the same time, prioritize showing */
|
/* If we want to both show and hide at the same time, prioritize showing */
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
new_ = SDL_ENABLE;
|
new_ = SDL_ENABLE;
|
||||||
}
|
}
|
||||||
else if (hide)
|
else if (hide)
|
||||||
{
|
{
|
||||||
new_ = SDL_DISABLE;
|
new_ = SDL_DISABLE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = SDL_ShowCursor(SDL_QUERY);
|
prev = SDL_ShowCursor(SDL_QUERY);
|
||||||
|
|
||||||
if (prev == new_)
|
if (prev == new_)
|
||||||
{
|
{
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ShowCursor(new_);
|
SDL_ShowCursor(new_);
|
||||||
|
|
||||||
switch (new_)
|
switch (new_)
|
||||||
{
|
{
|
||||||
case SDL_DISABLE:
|
case SDL_DISABLE:
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
break;
|
break;
|
||||||
case SDL_ENABLE:
|
case SDL_ENABLE:
|
||||||
timeout = 30;
|
timeout = 30;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPoll::Poll(void)
|
void KeyPoll::Poll(void)
|
||||||
{
|
{
|
||||||
static int mousetoggletimeout = 0;
|
static int mousetoggletimeout = 0;
|
||||||
bool showmouse = false;
|
bool showmouse = false;
|
||||||
bool hidemouse = false;
|
bool hidemouse = false;
|
||||||
bool altpressed = false;
|
bool altpressed = false;
|
||||||
bool fullscreenkeybind = false;
|
bool fullscreenkeybind = false;
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
while (SDL_PollEvent(&evt))
|
while (SDL_PollEvent(&evt))
|
||||||
{
|
{
|
||||||
switch (evt.type)
|
switch (evt.type)
|
||||||
{
|
{
|
||||||
/* Keyboard Input */
|
/* Keyboard Input */
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
{
|
{
|
||||||
keymap[evt.key.keysym.sym] = true;
|
keymap[evt.key.keysym.sym] = true;
|
||||||
|
|
||||||
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
||||||
{
|
{
|
||||||
pressedbackspace = true;
|
pressedbackspace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */
|
#ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */
|
||||||
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
|
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
|
||||||
#else
|
#else
|
||||||
altpressed = keymap[SDLK_LALT] || keymap[SDLK_RALT];
|
altpressed = keymap[SDLK_LALT] || keymap[SDLK_RALT];
|
||||||
#endif
|
#endif
|
||||||
bool returnpressed = evt.key.keysym.sym == SDLK_RETURN;
|
bool returnpressed = evt.key.keysym.sym == SDLK_RETURN;
|
||||||
bool fpressed = evt.key.keysym.sym == SDLK_f;
|
bool fpressed = evt.key.keysym.sym == SDLK_f;
|
||||||
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
|
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
|
||||||
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
|
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
|
||||||
{
|
{
|
||||||
fullscreenkeybind = true;
|
fullscreenkeybind = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textentry())
|
if (textentry())
|
||||||
{
|
{
|
||||||
if (evt.key.keysym.sym == SDLK_BACKSPACE && !keybuffer.empty())
|
if (evt.key.keysym.sym == SDLK_BACKSPACE && !keybuffer.empty())
|
||||||
{
|
{
|
||||||
std::string::iterator iter = keybuffer.end();
|
std::string::iterator iter = keybuffer.end();
|
||||||
utf8::unchecked::prior(iter);
|
utf8::unchecked::prior(iter);
|
||||||
keybuffer = keybuffer.substr(0, iter - keybuffer.begin());
|
keybuffer = keybuffer.substr(0, iter - keybuffer.begin());
|
||||||
if (keybuffer.empty())
|
if (keybuffer.empty())
|
||||||
{
|
{
|
||||||
linealreadyemptykludge = true;
|
linealreadyemptykludge = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( evt.key.keysym.sym == SDLK_v &&
|
else if ( evt.key.keysym.sym == SDLK_v &&
|
||||||
keymap[SDLK_LCTRL] )
|
keymap[SDLK_LCTRL] )
|
||||||
{
|
{
|
||||||
char* text = SDL_GetClipboardText();
|
char* text = SDL_GetClipboardText();
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
keybuffer += text;
|
keybuffer += text;
|
||||||
SDL_free(text);
|
SDL_free(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
keymap[evt.key.keysym.sym] = false;
|
keymap[evt.key.keysym.sym] = false;
|
||||||
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
if (evt.key.keysym.sym == SDLK_BACKSPACE)
|
||||||
{
|
{
|
||||||
pressedbackspace = false;
|
pressedbackspace = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (!altpressed)
|
if (!altpressed)
|
||||||
{
|
{
|
||||||
keybuffer += evt.text.text;
|
keybuffer += evt.text.text;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Mouse Input */
|
/* Mouse Input */
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
mx = evt.motion.x;
|
mx = evt.motion.x;
|
||||||
my = evt.motion.y;
|
my = evt.motion.y;
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
switch (evt.button.button)
|
switch (evt.button.button)
|
||||||
{
|
{
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
leftbutton = 1;
|
leftbutton = 1;
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_RIGHT:
|
case SDL_BUTTON_RIGHT:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
rightbutton = 1;
|
rightbutton = 1;
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_MIDDLE:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
middlebutton = 1;
|
middlebutton = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
switch (evt.button.button)
|
switch (evt.button.button)
|
||||||
{
|
{
|
||||||
case SDL_BUTTON_LEFT:
|
case SDL_BUTTON_LEFT:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
leftbutton=0;
|
leftbutton=0;
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_RIGHT:
|
case SDL_BUTTON_RIGHT:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
rightbutton=0;
|
rightbutton=0;
|
||||||
break;
|
break;
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_MIDDLE:
|
||||||
mx = evt.button.x;
|
mx = evt.button.x;
|
||||||
my = evt.button.y;
|
my = evt.button.y;
|
||||||
middlebutton=0;
|
middlebutton=0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Controller Input */
|
/* Controller Input */
|
||||||
case SDL_CONTROLLERBUTTONDOWN:
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = true;
|
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = true;
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERBUTTONUP:
|
case SDL_CONTROLLERBUTTONUP:
|
||||||
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLERAXISMOTION:
|
case SDL_CONTROLLERAXISMOTION:
|
||||||
{
|
{
|
||||||
const int threshold = getThreshold();
|
const int threshold = getThreshold();
|
||||||
switch (evt.caxis.axis)
|
switch (evt.caxis.axis)
|
||||||
{
|
{
|
||||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||||
if ( evt.caxis.value > -threshold &&
|
if ( evt.caxis.value > -threshold &&
|
||||||
evt.caxis.value < threshold )
|
evt.caxis.value < threshold )
|
||||||
{
|
{
|
||||||
xVel = 0;
|
xVel = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xVel = (evt.caxis.value > 0) ? 1 : -1;
|
xVel = (evt.caxis.value > 0) ? 1 : -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||||
if ( evt.caxis.value > -threshold &&
|
if ( evt.caxis.value > -threshold &&
|
||||||
evt.caxis.value < threshold )
|
evt.caxis.value < threshold )
|
||||||
{
|
{
|
||||||
yVel = 0;
|
yVel = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yVel = (evt.caxis.value > 0) ? 1 : -1;
|
yVel = (evt.caxis.value > 0) ? 1 : -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
{
|
{
|
||||||
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
|
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
|
||||||
vlog_info(
|
vlog_info(
|
||||||
"Opened SDL_GameController ID #%i, %s",
|
"Opened SDL_GameController ID #%i, %s",
|
||||||
evt.cdevice.which,
|
evt.cdevice.which,
|
||||||
SDL_GameControllerName(toOpen)
|
SDL_GameControllerName(toOpen)
|
||||||
);
|
);
|
||||||
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(toOpen))] = toOpen;
|
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(toOpen))] = toOpen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEREMOVED:
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
{
|
{
|
||||||
SDL_GameController *toClose = controllers[evt.cdevice.which];
|
SDL_GameController *toClose = controllers[evt.cdevice.which];
|
||||||
controllers.erase(evt.cdevice.which);
|
controllers.erase(evt.cdevice.which);
|
||||||
vlog_info("Closing %s", SDL_GameControllerName(toClose));
|
vlog_info("Closing %s", SDL_GameControllerName(toClose));
|
||||||
SDL_GameControllerClose(toClose);
|
SDL_GameControllerClose(toClose);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Window Events */
|
/* Window Events */
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
switch (evt.window.event)
|
switch (evt.window.event)
|
||||||
{
|
{
|
||||||
/* Window Resize */
|
/* Window Resize */
|
||||||
case SDL_WINDOWEVENT_RESIZED:
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
if (SDL_GetWindowFlags(
|
if (SDL_GetWindowFlags(
|
||||||
SDL_GetWindowFromID(evt.window.windowID)
|
SDL_GetWindowFromID(evt.window.windowID)
|
||||||
) & SDL_WINDOW_INPUT_FOCUS)
|
) & SDL_WINDOW_INPUT_FOCUS)
|
||||||
{
|
{
|
||||||
resetWindow = true;
|
resetWindow = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Window Focus */
|
/* Window Focus */
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
if (!game.disablepause)
|
if (!game.disablepause)
|
||||||
{
|
{
|
||||||
isActive = true;
|
isActive = true;
|
||||||
if ((!game.disableaudiopause || !game.disabletemporaryaudiopause) && music.currentsong != -1)
|
if ((!game.disableaudiopause || !game.disabletemporaryaudiopause) && music.currentsong != -1)
|
||||||
{
|
{
|
||||||
music.resume();
|
music.resume();
|
||||||
music.resumeef();
|
music.resumeef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
|
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
|
||||||
{
|
{
|
||||||
if (wasFullscreen)
|
if (wasFullscreen)
|
||||||
{
|
{
|
||||||
graphics.screenbuffer->isWindowed = false;
|
graphics.screenbuffer->isWindowed = false;
|
||||||
SDL_SetWindowFullscreen(
|
SDL_SetWindowFullscreen(
|
||||||
SDL_GetWindowFromID(evt.window.windowID),
|
SDL_GetWindowFromID(evt.window.windowID),
|
||||||
SDL_WINDOW_FULLSCREEN_DESKTOP
|
SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_DisableScreenSaver();
|
SDL_DisableScreenSaver();
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
// For some reason, SDL_WINDOWEVENT_FOCUS_GAINED doesn't seem to get sent on Emscripten.
|
// For some reason, SDL_WINDOWEVENT_FOCUS_GAINED doesn't seem to get sent on Emscripten.
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
if (!game.disablepause)
|
if (!game.disablepause)
|
||||||
{
|
{
|
||||||
isActive = false;
|
isActive = false;
|
||||||
if (!game.disableaudiopause || !game.disabletemporaryaudiopause)
|
if (!game.disableaudiopause || !game.disabletemporaryaudiopause)
|
||||||
{
|
{
|
||||||
music.pause();
|
music.pause();
|
||||||
music.pauseef();
|
music.pauseef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
|
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
|
||||||
{
|
{
|
||||||
wasFullscreen = !graphics.screenbuffer->isWindowed;
|
wasFullscreen = !graphics.screenbuffer->isWindowed;
|
||||||
graphics.screenbuffer->isWindowed = true;
|
graphics.screenbuffer->isWindowed = true;
|
||||||
SDL_SetWindowFullscreen(
|
SDL_SetWindowFullscreen(
|
||||||
SDL_GetWindowFromID(evt.window.windowID),
|
SDL_GetWindowFromID(evt.window.windowID),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Mouse Focus */
|
/* Mouse Focus */
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
SDL_DisableScreenSaver();
|
SDL_DisableScreenSaver();
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_LEAVE:
|
case SDL_WINDOWEVENT_LEAVE:
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Quit Event */
|
/* Quit Event */
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
VVV_exit(0);
|
VVV_exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (evt.type)
|
switch (evt.type)
|
||||||
{
|
{
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (evt.key.repeat == 0)
|
if (evt.key.repeat == 0)
|
||||||
{
|
{
|
||||||
hidemouse = true;
|
hidemouse = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
case SDL_CONTROLLERBUTTONDOWN:
|
case SDL_CONTROLLERBUTTONDOWN:
|
||||||
case SDL_CONTROLLERAXISMOTION:
|
case SDL_CONTROLLERAXISMOTION:
|
||||||
hidemouse = true;
|
hidemouse = true;
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
showmouse = true;
|
showmouse = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mousetoggletimeout = changemousestate(
|
mousetoggletimeout = changemousestate(
|
||||||
mousetoggletimeout,
|
mousetoggletimeout,
|
||||||
showmouse,
|
showmouse,
|
||||||
hidemouse
|
hidemouse
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fullscreenkeybind)
|
if (fullscreenkeybind)
|
||||||
{
|
{
|
||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::isDown(SDL_Keycode key)
|
bool KeyPoll::isDown(SDL_Keycode key)
|
||||||
{
|
{
|
||||||
return keymap[key];
|
return keymap[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
|
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < buttons.size(); i += 1)
|
for (size_t i = 0; i < buttons.size(); i += 1)
|
||||||
{
|
{
|
||||||
if (buttonmap[buttons[i]])
|
if (buttonmap[buttons[i]])
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::isDown(SDL_GameControllerButton button)
|
bool KeyPoll::isDown(SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
return buttonmap[button];
|
return buttonmap[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::controllerButtonDown(void)
|
bool KeyPoll::controllerButtonDown(void)
|
||||||
{
|
{
|
||||||
for (
|
for (
|
||||||
SDL_GameControllerButton button = SDL_CONTROLLER_BUTTON_A;
|
SDL_GameControllerButton button = SDL_CONTROLLER_BUTTON_A;
|
||||||
button < SDL_CONTROLLER_BUTTON_DPAD_UP;
|
button < SDL_CONTROLLER_BUTTON_DPAD_UP;
|
||||||
button = (SDL_GameControllerButton) (button + 1)
|
button = (SDL_GameControllerButton) (button + 1)
|
||||||
) {
|
) {
|
||||||
if (isDown(button))
|
if (isDown(button))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::controllerWantsLeft(bool includeVert)
|
bool KeyPoll::controllerWantsLeft(bool includeVert)
|
||||||
{
|
{
|
||||||
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_LEFT] ||
|
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_LEFT] ||
|
||||||
xVel < 0 ||
|
xVel < 0 ||
|
||||||
( includeVert &&
|
( includeVert &&
|
||||||
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_UP] ||
|
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_UP] ||
|
||||||
yVel < 0 ) ) );
|
yVel < 0 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyPoll::controllerWantsRight(bool includeVert)
|
bool KeyPoll::controllerWantsRight(bool includeVert)
|
||||||
{
|
{
|
||||||
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_RIGHT] ||
|
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_RIGHT] ||
|
||||||
xVel > 0 ||
|
xVel > 0 ||
|
||||||
( includeVert &&
|
( includeVert &&
|
||||||
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_DOWN] ||
|
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_DOWN] ||
|
||||||
yVel > 0 ) ) );
|
yVel > 0 ) ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,72 +8,72 @@
|
|||||||
|
|
||||||
enum Kybrd
|
enum Kybrd
|
||||||
{
|
{
|
||||||
KEYBOARD_UP = SDLK_UP,
|
KEYBOARD_UP = SDLK_UP,
|
||||||
KEYBOARD_DOWN = SDLK_DOWN,
|
KEYBOARD_DOWN = SDLK_DOWN,
|
||||||
KEYBOARD_LEFT = SDLK_LEFT,
|
KEYBOARD_LEFT = SDLK_LEFT,
|
||||||
KEYBOARD_RIGHT = SDLK_RIGHT,
|
KEYBOARD_RIGHT = SDLK_RIGHT,
|
||||||
KEYBOARD_ENTER = SDLK_RETURN,
|
KEYBOARD_ENTER = SDLK_RETURN,
|
||||||
KEYBOARD_SPACE = SDLK_SPACE,
|
KEYBOARD_SPACE = SDLK_SPACE,
|
||||||
|
|
||||||
KEYBOARD_w = SDLK_w,
|
KEYBOARD_w = SDLK_w,
|
||||||
KEYBOARD_s = SDLK_s,
|
KEYBOARD_s = SDLK_s,
|
||||||
KEYBOARD_a = SDLK_a,
|
KEYBOARD_a = SDLK_a,
|
||||||
KEYBOARD_d = SDLK_d,
|
KEYBOARD_d = SDLK_d,
|
||||||
KEYBOARD_e = SDLK_e,
|
KEYBOARD_e = SDLK_e,
|
||||||
KEYBOARD_m = SDLK_m,
|
KEYBOARD_m = SDLK_m,
|
||||||
KEYBOARD_n = SDLK_n,
|
KEYBOARD_n = SDLK_n,
|
||||||
|
|
||||||
KEYBOARD_v = SDLK_v,
|
KEYBOARD_v = SDLK_v,
|
||||||
KEYBOARD_z = SDLK_z,
|
KEYBOARD_z = SDLK_z,
|
||||||
|
|
||||||
KEYBOARD_BACKSPACE = SDLK_BACKSPACE
|
KEYBOARD_BACKSPACE = SDLK_BACKSPACE
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyPoll
|
class KeyPoll
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::map<SDL_Keycode, bool> keymap;
|
std::map<SDL_Keycode, bool> keymap;
|
||||||
|
|
||||||
bool isActive;
|
bool isActive;
|
||||||
|
|
||||||
bool resetWindow;
|
bool resetWindow;
|
||||||
|
|
||||||
void toggleFullscreen(void);
|
void toggleFullscreen(void);
|
||||||
|
|
||||||
int sensitivity;
|
int sensitivity;
|
||||||
|
|
||||||
int inline getThreshold(void);
|
int inline getThreshold(void);
|
||||||
|
|
||||||
KeyPoll(void);
|
KeyPoll(void);
|
||||||
|
|
||||||
void enabletextentry(void);
|
void enabletextentry(void);
|
||||||
|
|
||||||
void disabletextentry(void);
|
void disabletextentry(void);
|
||||||
|
|
||||||
void Poll(void);
|
void Poll(void);
|
||||||
|
|
||||||
bool isDown(SDL_Keycode key);
|
bool isDown(SDL_Keycode key);
|
||||||
|
|
||||||
bool isDown(std::vector<SDL_GameControllerButton> buttons);
|
bool isDown(std::vector<SDL_GameControllerButton> buttons);
|
||||||
bool isDown(SDL_GameControllerButton button);
|
bool isDown(SDL_GameControllerButton button);
|
||||||
bool controllerButtonDown(void);
|
bool controllerButtonDown(void);
|
||||||
bool controllerWantsLeft(bool includeVert);
|
bool controllerWantsLeft(bool includeVert);
|
||||||
bool controllerWantsRight(bool includeVert);
|
bool controllerWantsRight(bool includeVert);
|
||||||
|
|
||||||
int leftbutton, rightbutton, middlebutton;
|
int leftbutton, rightbutton, middlebutton;
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
bool textentry(void);
|
bool textentry(void);
|
||||||
bool pressedbackspace;
|
bool pressedbackspace;
|
||||||
std::string keybuffer;
|
std::string keybuffer;
|
||||||
|
|
||||||
bool linealreadyemptykludge;
|
bool linealreadyemptykludge;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<SDL_JoystickID, SDL_GameController*> controllers;
|
std::map<SDL_JoystickID, SDL_GameController*> controllers;
|
||||||
std::map<SDL_GameControllerButton, bool> buttonmap;
|
std::map<SDL_GameControllerButton, bool> buttonmap;
|
||||||
int xVel, yVel;
|
int xVel, yVel;
|
||||||
Uint32 wasFullscreen;
|
Uint32 wasFullscreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef KEY_DEFINITION
|
#ifndef KEY_DEFINITION
|
||||||
|
|||||||
+2082
-2082
File diff suppressed because it is too large
Load Diff
@@ -543,7 +543,7 @@ void gamelogic(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//SWN Minigame Logic
|
//SWN Minigame Logic
|
||||||
if (game.swnmode) //which game?
|
if (game.swnmode) //which game?
|
||||||
{
|
{
|
||||||
if(game.swngame==0) //intermission, survive 60 seconds game
|
if(game.swngame==0) //intermission, survive 60 seconds game
|
||||||
{
|
{
|
||||||
@@ -994,7 +994,7 @@ void gamelogic(void)
|
|||||||
obj.customwarpmodevon = false;
|
obj.customwarpmodevon = false;
|
||||||
|
|
||||||
int i = obj.getplayer();
|
int i = obj.getplayer();
|
||||||
if (INBOUNDS_VEC(i, obj.entities) && ((game.door_down > -2 && obj.entities[i].yp >= 226-16) || (game.door_up > -2 && obj.entities[i].yp < -2+16) || (game.door_left > -2 && obj.entities[i].xp < -14+16) || (game.door_right > -2 && obj.entities[i].xp >= 308-16))){
|
if (INBOUNDS_VEC(i, obj.entities) && ((game.door_down > -2 && obj.entities[i].yp >= 226-16) || (game.door_up > -2 && obj.entities[i].yp < -2+16) || (game.door_left > -2 && obj.entities[i].xp < -14+16) || (game.door_right > -2 && obj.entities[i].xp >= 308-16))){
|
||||||
//Player is leaving room
|
//Player is leaving room
|
||||||
obj.customwarplinecheck(i);
|
obj.customwarplinecheck(i);
|
||||||
}
|
}
|
||||||
@@ -1503,7 +1503,7 @@ void gamelogic(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (game.roomy >= 52)
|
else if (game.roomy >= 52)
|
||||||
{
|
{
|
||||||
if (obj.flags[59])
|
if (obj.flags[59])
|
||||||
{
|
{
|
||||||
|
|||||||
+1759
-1759
File diff suppressed because it is too large
Load Diff
+370
-370
@@ -14,541 +14,541 @@
|
|||||||
|
|
||||||
musicclass::musicclass(void)
|
musicclass::musicclass(void)
|
||||||
{
|
{
|
||||||
safeToProcessMusic= false;
|
safeToProcessMusic= false;
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
musicVolume = 0;
|
musicVolume = 0;
|
||||||
|
|
||||||
user_music_volume = USER_VOLUME_MAX;
|
user_music_volume = USER_VOLUME_MAX;
|
||||||
user_sound_volume = USER_VOLUME_MAX;
|
user_sound_volume = USER_VOLUME_MAX;
|
||||||
|
|
||||||
currentsong = 0;
|
currentsong = 0;
|
||||||
nicechange = -1;
|
nicechange = -1;
|
||||||
nicefade = false;
|
nicefade = false;
|
||||||
quick_fade = true;
|
quick_fade = true;
|
||||||
|
|
||||||
usingmmmmmm = false;
|
usingmmmmmm = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::init(void)
|
void musicclass::init(void)
|
||||||
{
|
{
|
||||||
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
|
||||||
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
|
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
|
||||||
|
|
||||||
#ifdef VVV_COMPILEMUSIC
|
#ifdef VVV_COMPILEMUSIC
|
||||||
binaryBlob musicWriteBlob;
|
binaryBlob musicWriteBlob;
|
||||||
#define FOREACH_TRACK(blob, track_name) blob.AddFileToBinaryBlob("data/" track_name);
|
#define FOREACH_TRACK(blob, track_name) blob.AddFileToBinaryBlob("data/" track_name);
|
||||||
TRACK_NAMES(musicWriteBlob)
|
TRACK_NAMES(musicWriteBlob)
|
||||||
#undef FOREACH_TRACK
|
#undef FOREACH_TRACK
|
||||||
|
|
||||||
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
|
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
|
||||||
musicWriteBlob.clear();
|
musicWriteBlob.clear();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
num_mmmmmm_tracks = 0;
|
num_mmmmmm_tracks = 0;
|
||||||
num_pppppp_tracks = 0;
|
num_pppppp_tracks = 0;
|
||||||
|
|
||||||
if (!mmmmmm_blob.unPackBinary("mmmmmm.vvv"))
|
if (!mmmmmm_blob.unPackBinary("mmmmmm.vvv"))
|
||||||
{
|
{
|
||||||
if (pppppp_blob.unPackBinary("vvvvvvmusic.vvv"))
|
if (pppppp_blob.unPackBinary("vvvvvvmusic.vvv"))
|
||||||
{
|
{
|
||||||
vlog_info("Loading music from PPPPPP blob...");
|
vlog_info("Loading music from PPPPPP blob...");
|
||||||
|
|
||||||
mmmmmm = false;
|
mmmmmm = false;
|
||||||
usingmmmmmm=false;
|
usingmmmmmm=false;
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
SDL_RWops* rw;
|
SDL_RWops* rw;
|
||||||
|
|
||||||
#define FOREACH_TRACK(blob, track_name) \
|
#define FOREACH_TRACK(blob, track_name) \
|
||||||
index = blob.getIndex("data/" track_name); \
|
index = blob.getIndex("data/" track_name); \
|
||||||
rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \
|
rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \
|
||||||
musicTracks.push_back(MusicTrack( rw ));
|
musicTracks.push_back(MusicTrack( rw ));
|
||||||
|
|
||||||
TRACK_NAMES(pppppp_blob)
|
TRACK_NAMES(pppppp_blob)
|
||||||
|
|
||||||
#undef FOREACH_TRACK
|
#undef FOREACH_TRACK
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vlog_info("Loading music from loose files...");
|
vlog_info("Loading music from loose files...");
|
||||||
|
|
||||||
SDL_RWops* rw;
|
SDL_RWops* rw;
|
||||||
#define FOREACH_TRACK(_, track_name) \
|
#define FOREACH_TRACK(_, track_name) \
|
||||||
rw = PHYSFSRWOPS_openRead(track_name); \
|
rw = PHYSFSRWOPS_openRead(track_name); \
|
||||||
musicTracks.push_back(MusicTrack( rw ));
|
musicTracks.push_back(MusicTrack( rw ));
|
||||||
|
|
||||||
TRACK_NAMES(_)
|
TRACK_NAMES(_)
|
||||||
|
|
||||||
#undef FOREACH_TRACK
|
#undef FOREACH_TRACK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vlog_info("Loading PPPPPP and MMMMMM blobs...");
|
vlog_info("Loading PPPPPP and MMMMMM blobs...");
|
||||||
|
|
||||||
mmmmmm = true;
|
mmmmmm = true;
|
||||||
int index;
|
int index;
|
||||||
SDL_RWops *rw;
|
SDL_RWops *rw;
|
||||||
|
|
||||||
#define FOREACH_TRACK(blob, track_name) \
|
#define FOREACH_TRACK(blob, track_name) \
|
||||||
index = blob.getIndex("data/" track_name); \
|
index = blob.getIndex("data/" track_name); \
|
||||||
if (index >= 0 && index < blob.max_headers) \
|
if (index >= 0 && index < blob.max_headers) \
|
||||||
{ \
|
{ \
|
||||||
rw = SDL_RWFromConstMem(blob.getAddress(index), blob.getSize(index)); \
|
rw = SDL_RWFromConstMem(blob.getAddress(index), blob.getSize(index)); \
|
||||||
if (rw == NULL) \
|
if (rw == NULL) \
|
||||||
{ \
|
{ \
|
||||||
vlog_error("Unable to read music file header: %s", SDL_GetError()); \
|
vlog_error("Unable to read music file header: %s", SDL_GetError()); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
musicTracks.push_back(MusicTrack( rw )); \
|
musicTracks.push_back(MusicTrack( rw )); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACK_NAMES(mmmmmm_blob)
|
TRACK_NAMES(mmmmmm_blob)
|
||||||
|
|
||||||
num_mmmmmm_tracks += musicTracks.size();
|
num_mmmmmm_tracks += musicTracks.size();
|
||||||
|
|
||||||
size_t index_ = 0;
|
size_t index_ = 0;
|
||||||
while (mmmmmm_blob.nextExtra(&index_))
|
while (mmmmmm_blob.nextExtra(&index_))
|
||||||
{
|
{
|
||||||
rw = SDL_RWFromConstMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_));
|
rw = SDL_RWFromConstMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_));
|
||||||
musicTracks.push_back(MusicTrack( rw ));
|
musicTracks.push_back(MusicTrack( rw ));
|
||||||
|
|
||||||
num_mmmmmm_tracks++;
|
num_mmmmmm_tracks++;
|
||||||
index_++;
|
index_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ohCrap = pppppp_blob.unPackBinary("vvvvvvmusic.vvv");
|
bool ohCrap = pppppp_blob.unPackBinary("vvvvvvmusic.vvv");
|
||||||
SDL_assert(ohCrap && "Music not found!");
|
SDL_assert(ohCrap && "Music not found!");
|
||||||
|
|
||||||
TRACK_NAMES(pppppp_blob)
|
TRACK_NAMES(pppppp_blob)
|
||||||
|
|
||||||
#undef FOREACH_TRACK
|
#undef FOREACH_TRACK
|
||||||
}
|
}
|
||||||
|
|
||||||
num_pppppp_tracks += musicTracks.size() - num_mmmmmm_tracks;
|
num_pppppp_tracks += musicTracks.size() - num_mmmmmm_tracks;
|
||||||
|
|
||||||
SDL_RWops* rw;
|
SDL_RWops* rw;
|
||||||
size_t index_ = 0;
|
size_t index_ = 0;
|
||||||
while (pppppp_blob.nextExtra(&index_))
|
while (pppppp_blob.nextExtra(&index_))
|
||||||
{
|
{
|
||||||
rw = SDL_RWFromConstMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_));
|
rw = SDL_RWFromConstMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_));
|
||||||
musicTracks.push_back(MusicTrack( rw ));
|
musicTracks.push_back(MusicTrack( rw ));
|
||||||
|
|
||||||
num_pppppp_tracks++;
|
num_pppppp_tracks++;
|
||||||
index_++;
|
index_++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::destroy(void)
|
void musicclass::destroy(void)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < soundTracks.size(); ++i)
|
for (size_t i = 0; i < soundTracks.size(); ++i)
|
||||||
{
|
{
|
||||||
Mix_FreeChunk(soundTracks[i].sound);
|
Mix_FreeChunk(soundTracks[i].sound);
|
||||||
}
|
}
|
||||||
soundTracks.clear();
|
soundTracks.clear();
|
||||||
|
|
||||||
// Before we free all the music: stop playing music, else SDL2_mixer
|
// Before we free all the music: stop playing music, else SDL2_mixer
|
||||||
// will call SDL_Delay() if we are fading, resulting in no-draw frames
|
// will call SDL_Delay() if we are fading, resulting in no-draw frames
|
||||||
Mix_HaltMusic();
|
Mix_HaltMusic();
|
||||||
|
|
||||||
for (size_t i = 0; i < musicTracks.size(); ++i)
|
for (size_t i = 0; i < musicTracks.size(); ++i)
|
||||||
{
|
{
|
||||||
Mix_FreeMusic(musicTracks[i].m_music);
|
Mix_FreeMusic(musicTracks[i].m_music);
|
||||||
}
|
}
|
||||||
musicTracks.clear();
|
musicTracks.clear();
|
||||||
|
|
||||||
pppppp_blob.clear();
|
pppppp_blob.clear();
|
||||||
mmmmmm_blob.clear();
|
mmmmmm_blob.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::play(int t)
|
void musicclass::play(int t)
|
||||||
{
|
{
|
||||||
if (mmmmmm && usingmmmmmm)
|
if (mmmmmm && usingmmmmmm)
|
||||||
{
|
{
|
||||||
// Don't conjoin this if-statement with the above one...
|
// Don't conjoin this if-statement with the above one...
|
||||||
if (num_mmmmmm_tracks > 0)
|
if (num_mmmmmm_tracks > 0)
|
||||||
{
|
{
|
||||||
t %= num_mmmmmm_tracks;
|
t %= num_mmmmmm_tracks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (num_pppppp_tracks > 0)
|
else if (num_pppppp_tracks > 0)
|
||||||
{
|
{
|
||||||
t %= num_pppppp_tracks;
|
t %= num_pppppp_tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmmmmm && !usingmmmmmm)
|
if (mmmmmm && !usingmmmmmm)
|
||||||
{
|
{
|
||||||
t += num_mmmmmm_tracks;
|
t += num_mmmmmm_tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
safeToProcessMusic = true;
|
safeToProcessMusic = true;
|
||||||
|
|
||||||
if (currentsong == t && !m_doFadeOutVol)
|
if (currentsong == t && !m_doFadeOutVol)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentsong = t;
|
currentsong = t;
|
||||||
|
|
||||||
if (t == -1)
|
if (t == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!INBOUNDS_VEC(t, musicTracks))
|
if (!INBOUNDS_VEC(t, musicTracks))
|
||||||
{
|
{
|
||||||
vlog_error("play() out-of-bounds!");
|
vlog_error("play() out-of-bounds!");
|
||||||
currentsong = -1;
|
currentsong = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks)))
|
if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks)))
|
||||||
{
|
{
|
||||||
// Level Complete theme, no fade in or repeat
|
// Level Complete theme, no fade in or repeat
|
||||||
if (Mix_PlayMusic(musicTracks[t].m_music, 0) == -1)
|
if (Mix_PlayMusic(musicTracks[t].m_music, 0) == -1)
|
||||||
{
|
{
|
||||||
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
|
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
musicVolume = MIX_MAX_VOLUME;
|
musicVolume = MIX_MAX_VOLUME;
|
||||||
Mix_VolumeMusic(musicVolume);
|
Mix_VolumeMusic(musicVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_doFadeOutVol)
|
if (m_doFadeOutVol)
|
||||||
{
|
{
|
||||||
// We're already fading out
|
// We're already fading out
|
||||||
nicechange = t;
|
nicechange = t;
|
||||||
nicefade = true;
|
nicefade = true;
|
||||||
currentsong = -1;
|
currentsong = -1;
|
||||||
|
|
||||||
if (quick_fade)
|
if (quick_fade)
|
||||||
{
|
{
|
||||||
fadeMusicVolumeOut(500); // fade out quicker
|
fadeMusicVolumeOut(500); // fade out quicker
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
quick_fade = true;
|
quick_fade = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Mix_PlayMusic(musicTracks[t].m_music, -1) == -1)
|
else if (Mix_PlayMusic(musicTracks[t].m_music, -1) == -1)
|
||||||
{
|
{
|
||||||
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
|
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
fadeMusicVolumeIn(3000);
|
fadeMusicVolumeIn(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::resume()
|
void musicclass::resume()
|
||||||
{
|
{
|
||||||
Mix_ResumeMusic();
|
Mix_ResumeMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::resumefade(const int fadein_ms)
|
void musicclass::resumefade(const int fadein_ms)
|
||||||
{
|
{
|
||||||
resume();
|
resume();
|
||||||
fadeMusicVolumeIn(fadein_ms);
|
fadeMusicVolumeIn(fadein_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::fadein(void)
|
void musicclass::fadein(void)
|
||||||
{
|
{
|
||||||
resumefade(3000); // 3000 ms fadein
|
resumefade(3000); // 3000 ms fadein
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::pause(void)
|
void musicclass::pause(void)
|
||||||
{
|
{
|
||||||
Mix_PauseMusic();
|
Mix_PauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::haltdasmusik(void)
|
void musicclass::haltdasmusik(void)
|
||||||
{
|
{
|
||||||
/* Just pauses music. This is intended. */
|
/* Just pauses music. This is intended. */
|
||||||
pause();
|
pause();
|
||||||
currentsong = -1;
|
currentsong = -1;
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::silencedasmusik(void)
|
void musicclass::silencedasmusik(void)
|
||||||
{
|
{
|
||||||
musicVolume = 0;
|
musicVolume = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FadeState
|
struct FadeState
|
||||||
{
|
{
|
||||||
int start_volume;
|
int start_volume;
|
||||||
int end_volume;
|
int end_volume;
|
||||||
int duration_ms;
|
int duration_ms;
|
||||||
int step_ms;
|
int step_ms;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct FadeState fade;
|
static struct FadeState fade;
|
||||||
|
|
||||||
enum FadeCode
|
enum FadeCode
|
||||||
{
|
{
|
||||||
Fade_continue,
|
Fade_continue,
|
||||||
Fade_finished
|
Fade_finished
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum FadeCode processmusicfade(struct FadeState* state, int* volume)
|
static enum FadeCode processmusicfade(struct FadeState* state, int* volume)
|
||||||
{
|
{
|
||||||
int range;
|
int range;
|
||||||
int new_volume;
|
int new_volume;
|
||||||
|
|
||||||
if (state->duration_ms == 0 /* Fast path. */
|
if (state->duration_ms == 0 /* Fast path. */
|
||||||
|| state->start_volume == state->end_volume /* Fast path. */
|
|| state->start_volume == state->end_volume /* Fast path. */
|
||||||
|| state->step_ms >= state->duration_ms /* We're finished. */)
|
|| state->step_ms >= state->duration_ms /* We're finished. */)
|
||||||
{
|
{
|
||||||
*volume = state->end_volume;
|
*volume = state->end_volume;
|
||||||
state->step_ms = 0;
|
state->step_ms = 0;
|
||||||
return Fade_finished;
|
return Fade_finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
range = state->end_volume - state->start_volume;
|
range = state->end_volume - state->start_volume;
|
||||||
new_volume = range * state->step_ms / state->duration_ms;
|
new_volume = range * state->step_ms / state->duration_ms;
|
||||||
new_volume += state->start_volume;
|
new_volume += state->start_volume;
|
||||||
|
|
||||||
*volume = new_volume;
|
*volume = new_volume;
|
||||||
|
|
||||||
state->step_ms += game.get_timestep();
|
state->step_ms += game.get_timestep();
|
||||||
|
|
||||||
return Fade_continue;
|
return Fade_continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::fadeMusicVolumeIn(int ms)
|
void musicclass::fadeMusicVolumeIn(int ms)
|
||||||
{
|
{
|
||||||
m_doFadeInVol = true;
|
m_doFadeInVol = true;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
|
|
||||||
/* Ensure it starts at 0 */
|
/* Ensure it starts at 0 */
|
||||||
musicVolume = 0;
|
musicVolume = 0;
|
||||||
|
|
||||||
/* Fix 1-frame glitch */
|
/* Fix 1-frame glitch */
|
||||||
Mix_VolumeMusic(0);
|
Mix_VolumeMusic(0);
|
||||||
|
|
||||||
fade.step_ms = 0;
|
fade.step_ms = 0;
|
||||||
fade.duration_ms = ms;
|
fade.duration_ms = ms;
|
||||||
fade.start_volume = 0;
|
fade.start_volume = 0;
|
||||||
fade.end_volume = MIX_MAX_VOLUME;
|
fade.end_volume = MIX_MAX_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::fadeMusicVolumeOut(const int fadeout_ms)
|
void musicclass::fadeMusicVolumeOut(const int fadeout_ms)
|
||||||
{
|
{
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
m_doFadeOutVol = true;
|
m_doFadeOutVol = true;
|
||||||
|
|
||||||
fade.step_ms = 0;
|
fade.step_ms = 0;
|
||||||
/* Duration is proportional to current volume. */
|
/* Duration is proportional to current volume. */
|
||||||
fade.duration_ms = fadeout_ms * musicVolume / MIX_MAX_VOLUME;
|
fade.duration_ms = fadeout_ms * musicVolume / MIX_MAX_VOLUME;
|
||||||
fade.start_volume = musicVolume;
|
fade.start_volume = musicVolume;
|
||||||
fade.end_volume = 0;
|
fade.end_volume = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::fadeout(const bool quick_fade_ /*= true*/)
|
void musicclass::fadeout(const bool quick_fade_ /*= true*/)
|
||||||
{
|
{
|
||||||
fadeMusicVolumeOut(quick_fade_ ? 500 : 2000);
|
fadeMusicVolumeOut(quick_fade_ ? 500 : 2000);
|
||||||
quick_fade = quick_fade_;
|
quick_fade = quick_fade_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::processmusicfadein(void)
|
void musicclass::processmusicfadein(void)
|
||||||
{
|
{
|
||||||
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
|
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
|
||||||
if (fade_code == Fade_finished)
|
if (fade_code == Fade_finished)
|
||||||
{
|
{
|
||||||
m_doFadeInVol = false;
|
m_doFadeInVol = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::processmusicfadeout(void)
|
void musicclass::processmusicfadeout(void)
|
||||||
{
|
{
|
||||||
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
|
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
|
||||||
if (fade_code == Fade_finished)
|
if (fade_code == Fade_finished)
|
||||||
{
|
{
|
||||||
musicVolume = 0;
|
musicVolume = 0;
|
||||||
m_doFadeOutVol = false;
|
m_doFadeOutVol = false;
|
||||||
haltdasmusik();
|
haltdasmusik();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::processmusic(void)
|
void musicclass::processmusic(void)
|
||||||
{
|
{
|
||||||
if(!safeToProcessMusic)
|
if(!safeToProcessMusic)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_doFadeInVol)
|
if(m_doFadeInVol)
|
||||||
{
|
{
|
||||||
processmusicfadein();
|
processmusicfadein();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_doFadeOutVol)
|
if (m_doFadeOutVol)
|
||||||
{
|
{
|
||||||
processmusicfadeout();
|
processmusicfadeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This needs to come after processing fades */
|
/* This needs to come after processing fades */
|
||||||
if (nicefade && Mix_PausedMusic() == 1)
|
if (nicefade && Mix_PausedMusic() == 1)
|
||||||
{
|
{
|
||||||
play(nicechange);
|
play(nicechange);
|
||||||
nicechange = -1;
|
nicechange = -1;
|
||||||
nicefade = false;
|
nicefade = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void musicclass::niceplay(int t)
|
void musicclass::niceplay(int t)
|
||||||
{
|
{
|
||||||
/* important: do nothing if the correct song is playing! */
|
/* important: do nothing if the correct song is playing! */
|
||||||
if ((!mmmmmm && currentsong != t)
|
if ((!mmmmmm && currentsong != t)
|
||||||
|| (mmmmmm && usingmmmmmm && currentsong != t)
|
|| (mmmmmm && usingmmmmmm && currentsong != t)
|
||||||
|| (mmmmmm && !usingmmmmmm && currentsong != t + num_mmmmmm_tracks))
|
|| (mmmmmm && !usingmmmmmm && currentsong != t + num_mmmmmm_tracks))
|
||||||
{
|
{
|
||||||
if (currentsong != -1)
|
if (currentsong != -1)
|
||||||
{
|
{
|
||||||
fadeout(false);
|
fadeout(false);
|
||||||
}
|
}
|
||||||
nicefade = true;
|
nicefade = true;
|
||||||
}
|
}
|
||||||
nicechange = t;
|
nicechange = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int areamap[] = {
|
static const int areamap[] = {
|
||||||
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4,12,12,12,12,12,12,12,
|
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4,12,12,12,12,12,12,12,
|
||||||
4, 3, 3, 3, 3, 3, 3, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
|
4, 3, 3, 3, 3, 3, 3, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
|
||||||
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
|
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
|
||||||
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 1, 1, 1, 1,12,12,12,12,
|
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 1, 1, 1, 1,12,12,12,12,
|
||||||
4, 4, 3, 3, 3, 4, 4, 4, 4,-2,-2,-2, 1, 1, 1, 1, 4, 4, 4, 4,
|
4, 4, 3, 3, 3, 4, 4, 4, 4,-2,-2,-2, 1, 1, 1, 1, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1,11,11,-1, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1,11,11,-1, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1,11,11,11,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1,11,11,11,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1,11,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1,11,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 3,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 3,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4,-2,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
|
4, 4, 4, 4, 4, 4, 4, 4,-2,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
|
||||||
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
|
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
|
||||||
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4,
|
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4,-1,-3, 4, 4, 4, 4, 4, 1, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4,-1,-3, 4, 4, 4, 4, 4, 1, 4,
|
||||||
4, 4, 4, 4, 4, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
|
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_COMPILE_TIME_ASSERT(areamap, SDL_arraysize(areamap) == 20 * 20);
|
SDL_COMPILE_TIME_ASSERT(areamap, SDL_arraysize(areamap) == 20 * 20);
|
||||||
|
|
||||||
void musicclass::changemusicarea(int x, int y)
|
void musicclass::changemusicarea(int x, int y)
|
||||||
{
|
{
|
||||||
int room;
|
int room;
|
||||||
int track;
|
int track;
|
||||||
|
|
||||||
if (script.running)
|
if (script.running)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
room = musicroom(x, y);
|
room = musicroom(x, y);
|
||||||
|
|
||||||
if (!INBOUNDS_ARR(room, areamap))
|
if (!INBOUNDS_ARR(room, areamap))
|
||||||
{
|
{
|
||||||
SDL_assert(0 && "Music map index out-of-bounds!");
|
SDL_assert(0 && "Music map index out-of-bounds!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
track = areamap[room];
|
track = areamap[room];
|
||||||
|
|
||||||
switch (track)
|
switch (track)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
/* Don't change music. */
|
/* Don't change music. */
|
||||||
return;
|
return;
|
||||||
case -2:
|
case -2:
|
||||||
/* Special case: Tower music, changes with Flip Mode. */
|
/* Special case: Tower music, changes with Flip Mode. */
|
||||||
if (graphics.setflipmode)
|
if (graphics.setflipmode)
|
||||||
{
|
{
|
||||||
track = 9; /* ecroF evitisoP */
|
track = 9; /* ecroF evitisoP */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
track = 2; /* Positive Force */
|
track = 2; /* Positive Force */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
/* Special case: start of Space Station 2. */
|
/* Special case: start of Space Station 2. */
|
||||||
if (game.intimetrial)
|
if (game.intimetrial)
|
||||||
{
|
{
|
||||||
track = 1; /* Pushing Onwards */
|
track = 1; /* Pushing Onwards */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
track = 4; /* Passion for Exploring */
|
track = 4; /* Passion for Exploring */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
niceplay(track);
|
niceplay(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::playef(int t)
|
void musicclass::playef(int t)
|
||||||
{
|
{
|
||||||
if (!INBOUNDS_VEC(t, soundTracks))
|
if (!INBOUNDS_VEC(t, soundTracks))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int channel;
|
int channel;
|
||||||
|
|
||||||
channel = Mix_PlayChannel(-1, soundTracks[t].sound, 0);
|
channel = Mix_PlayChannel(-1, soundTracks[t].sound, 0);
|
||||||
if(channel == -1)
|
if(channel == -1)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to play WAV file: %s", Mix_GetError());
|
vlog_error("Unable to play WAV file: %s", Mix_GetError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::pauseef(void)
|
void musicclass::pauseef(void)
|
||||||
{
|
{
|
||||||
Mix_Pause(-1);
|
Mix_Pause(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::resumeef(void)
|
void musicclass::resumeef(void)
|
||||||
{
|
{
|
||||||
Mix_Resume(-1);
|
Mix_Resume(-1);
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-42
@@ -17,59 +17,59 @@
|
|||||||
class musicclass
|
class musicclass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
musicclass(void);
|
musicclass(void);
|
||||||
void init(void);
|
void init(void);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
|
|
||||||
void play(int t);
|
void play(int t);
|
||||||
void resume();
|
void resume();
|
||||||
void resumefade(const int fadein_ms);
|
void resumefade(const int fadein_ms);
|
||||||
void pause(void);
|
void pause(void);
|
||||||
void haltdasmusik(void);
|
void haltdasmusik(void);
|
||||||
void silencedasmusik(void);
|
void silencedasmusik(void);
|
||||||
void fadeMusicVolumeIn(int ms);
|
void fadeMusicVolumeIn(int ms);
|
||||||
void fadeMusicVolumeOut(const int fadeout_ms);
|
void fadeMusicVolumeOut(const int fadeout_ms);
|
||||||
void fadeout(const bool quick_fade_ = true);
|
void fadeout(const bool quick_fade_ = true);
|
||||||
void fadein(void);
|
void fadein(void);
|
||||||
void processmusicfadein(void);
|
void processmusicfadein(void);
|
||||||
void processmusicfadeout(void);
|
void processmusicfadeout(void);
|
||||||
void processmusic(void);
|
void processmusic(void);
|
||||||
void niceplay(int t);
|
void niceplay(int t);
|
||||||
|
|
||||||
void changemusicarea(int x, int y);
|
void changemusicarea(int x, int y);
|
||||||
|
|
||||||
int currentsong;
|
int currentsong;
|
||||||
|
|
||||||
void playef(int t);
|
void playef(int t);
|
||||||
void pauseef(void);
|
void pauseef(void);
|
||||||
void resumeef(void);
|
void resumeef(void);
|
||||||
|
|
||||||
std::vector<SoundTrack> soundTracks;
|
std::vector<SoundTrack> soundTracks;
|
||||||
std::vector<MusicTrack> musicTracks;
|
std::vector<MusicTrack> musicTracks;
|
||||||
SoundSystem soundSystem;
|
SoundSystem soundSystem;
|
||||||
bool safeToProcessMusic;
|
bool safeToProcessMusic;
|
||||||
|
|
||||||
int nicechange; // -1 if no song queued
|
int nicechange; // -1 if no song queued
|
||||||
bool nicefade;
|
bool nicefade;
|
||||||
|
|
||||||
bool m_doFadeInVol;
|
bool m_doFadeInVol;
|
||||||
bool m_doFadeOutVol;
|
bool m_doFadeOutVol;
|
||||||
int musicVolume;
|
int musicVolume;
|
||||||
|
|
||||||
/* 0..USER_VOLUME_MAX */
|
/* 0..USER_VOLUME_MAX */
|
||||||
int user_music_volume;
|
int user_music_volume;
|
||||||
int user_sound_volume;
|
int user_sound_volume;
|
||||||
|
|
||||||
bool quick_fade;
|
bool quick_fade;
|
||||||
|
|
||||||
// MMMMMM mod settings
|
// MMMMMM mod settings
|
||||||
bool mmmmmm;
|
bool mmmmmm;
|
||||||
bool usingmmmmmm;
|
bool usingmmmmmm;
|
||||||
|
|
||||||
binaryBlob pppppp_blob;
|
binaryBlob pppppp_blob;
|
||||||
binaryBlob mmmmmm_blob;
|
binaryBlob mmmmmm_blob;
|
||||||
int num_pppppp_tracks;
|
int num_pppppp_tracks;
|
||||||
int num_mmmmmm_tracks;
|
int num_mmmmmm_tracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef MUSIC_DEFINITION
|
#ifndef MUSIC_DEFINITION
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
#include "Unused.h"
|
#include "Unused.h"
|
||||||
|
|
||||||
#ifdef MAKEANDPLAY
|
#ifdef MAKEANDPLAY
|
||||||
#ifdef STEAM_NETWORK
|
#ifdef STEAM_NETWORK
|
||||||
#undef STEAM_NETWORK
|
#undef STEAM_NETWORK
|
||||||
#endif
|
#endif
|
||||||
#ifdef GOG_NETWORK
|
#ifdef GOG_NETWORK
|
||||||
#undef GOG_NETWORK
|
#undef GOG_NETWORK
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STEAM_NETWORK
|
#ifdef STEAM_NETWORK
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
|
|
||||||
#define NUM_BACKENDS (STEAM_NUM+GOG_NUM)
|
#define NUM_BACKENDS (STEAM_NUM+GOG_NUM)
|
||||||
#define DECLARE_BACKEND(name) \
|
#define DECLARE_BACKEND(name) \
|
||||||
int32_t name##_init(void); \
|
int32_t name##_init(void); \
|
||||||
void name##_shutdown(void); \
|
void name##_shutdown(void); \
|
||||||
void name##_update(void); \
|
void name##_update(void); \
|
||||||
void name##_unlockAchievement(const char *name); \
|
void name##_unlockAchievement(const char *name); \
|
||||||
int32_t name##_getAchievementProgress(const char *name); \
|
int32_t name##_getAchievementProgress(const char *name); \
|
||||||
void name##_setAchievementProgress(const char *name, int32_t stat);
|
void name##_setAchievementProgress(const char *name, int32_t stat);
|
||||||
#ifdef STEAM_NETWORK
|
#ifdef STEAM_NETWORK
|
||||||
DECLARE_BACKEND(STEAM)
|
DECLARE_BACKEND(STEAM)
|
||||||
#endif
|
#endif
|
||||||
@@ -41,13 +41,13 @@ DECLARE_BACKEND(GOG)
|
|||||||
|
|
||||||
typedef struct NetworkBackend
|
typedef struct NetworkBackend
|
||||||
{
|
{
|
||||||
int32_t IsInit;
|
int32_t IsInit;
|
||||||
int32_t (*Init)(void);
|
int32_t (*Init)(void);
|
||||||
void (*Shutdown)(void);
|
void (*Shutdown)(void);
|
||||||
void (*Update)(void);
|
void (*Update)(void);
|
||||||
void (*UnlockAchievement)(const char*);
|
void (*UnlockAchievement)(const char*);
|
||||||
int32_t (*GetAchievementProgress)(const char*);
|
int32_t (*GetAchievementProgress)(const char*);
|
||||||
void (*SetAchievementProgress)(const char*, int32_t);
|
void (*SetAchievementProgress)(const char*, int32_t);
|
||||||
} NetworkBackend;
|
} NetworkBackend;
|
||||||
|
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
@@ -56,103 +56,103 @@ static NetworkBackend backends[NUM_BACKENDS];
|
|||||||
|
|
||||||
int NETWORK_init(void)
|
int NETWORK_init(void)
|
||||||
{
|
{
|
||||||
int32_t i, any = 0;
|
int32_t i, any = 0;
|
||||||
#define ASSIGN_BACKEND(name, index) \
|
#define ASSIGN_BACKEND(name, index) \
|
||||||
backends[index].Init = name##_init; \
|
backends[index].Init = name##_init; \
|
||||||
backends[index].Shutdown = name##_shutdown; \
|
backends[index].Shutdown = name##_shutdown; \
|
||||||
backends[index].Update = name##_update; \
|
backends[index].Update = name##_update; \
|
||||||
backends[index].UnlockAchievement = name##_unlockAchievement; \
|
backends[index].UnlockAchievement = name##_unlockAchievement; \
|
||||||
backends[index].GetAchievementProgress = name##_getAchievementProgress; \
|
backends[index].GetAchievementProgress = name##_getAchievementProgress; \
|
||||||
backends[index].SetAchievementProgress = name##_setAchievementProgress;
|
backends[index].SetAchievementProgress = name##_setAchievementProgress;
|
||||||
#ifdef STEAM_NETWORK
|
#ifdef STEAM_NETWORK
|
||||||
ASSIGN_BACKEND(STEAM, 0)
|
ASSIGN_BACKEND(STEAM, 0)
|
||||||
#endif
|
#endif
|
||||||
#ifdef GOG_NETWORK
|
#ifdef GOG_NETWORK
|
||||||
ASSIGN_BACKEND(GOG, STEAM_NUM)
|
ASSIGN_BACKEND(GOG, STEAM_NUM)
|
||||||
#endif
|
#endif
|
||||||
#undef ASSIGN_BACKEND
|
#undef ASSIGN_BACKEND
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
{
|
{
|
||||||
backends[i].IsInit = backends[i].Init();
|
backends[i].IsInit = backends[i].Init();
|
||||||
any |= backends[i].IsInit;
|
any |= backends[i].IsInit;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(i);
|
UNUSED(i);
|
||||||
#endif
|
#endif
|
||||||
return any;
|
return any;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETWORK_shutdown(void)
|
void NETWORK_shutdown(void)
|
||||||
{
|
{
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
backends[i].Shutdown();
|
backends[i].Shutdown();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETWORK_update(void)
|
void NETWORK_update(void)
|
||||||
{
|
{
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
backends[i].Update();
|
backends[i].Update();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETWORK_unlockAchievement(const char *name)
|
void NETWORK_unlockAchievement(const char *name)
|
||||||
{
|
{
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
backends[i].UnlockAchievement(name);
|
backends[i].UnlockAchievement(name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(name);
|
UNUSED(name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t NETWORK_getAchievementProgress(const char *name)
|
int32_t NETWORK_getAchievementProgress(const char *name)
|
||||||
{
|
{
|
||||||
/* The highest stat gets priority, will eventually pass to the others */
|
/* The highest stat gets priority, will eventually pass to the others */
|
||||||
int32_t max = 0;
|
int32_t max = 0;
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i, stat;
|
int32_t i, stat;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
stat = backends[i].GetAchievementProgress(name);
|
stat = backends[i].GetAchievementProgress(name);
|
||||||
if (stat > max)
|
if (stat > max)
|
||||||
{
|
{
|
||||||
max = stat;
|
max = stat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(name);
|
UNUSED(name);
|
||||||
#endif
|
#endif
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETWORK_setAchievementProgress(const char *name, int32_t stat)
|
void NETWORK_setAchievementProgress(const char *name, int32_t stat)
|
||||||
{
|
{
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
backends[i].SetAchievementProgress(name, stat);
|
backends[i].SetAchievementProgress(name, stat);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(name);
|
UNUSED(name);
|
||||||
UNUSED(stat);
|
UNUSED(stat);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+9175
-9175
File diff suppressed because it is too large
Load Diff
@@ -1912,7 +1912,7 @@ void gamerender(void)
|
|||||||
graphics.bprint( 240, 190, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
graphics.bprint( 240, 190, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
||||||
graphics.bigbrprint( 300, 205, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
|
graphics.bigbrprint( 300, 205, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
|
||||||
}
|
}
|
||||||
else if (int(game.swndelay / 10) % 2 == 1)
|
else if (int(game.swndelay / 10) % 2 == 1)
|
||||||
{
|
{
|
||||||
graphics.bigbprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
|
graphics.bigbprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
|
||||||
graphics.bigbprint( -1, 200, "GO!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 3);
|
graphics.bigbprint( -1, 200, "GO!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 3);
|
||||||
@@ -2307,7 +2307,7 @@ void maprender(void)
|
|||||||
{
|
{
|
||||||
int temp = 1086;
|
int temp = 1086;
|
||||||
if (graphics.flipmode) temp += 3;
|
if (graphics.flipmode) temp += 3;
|
||||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2862,7 +2862,7 @@ void teleporterrender(void)
|
|||||||
{
|
{
|
||||||
temp = 1086;
|
temp = 1086;
|
||||||
if (graphics.flipmode) temp += 3;
|
if (graphics.flipmode) temp += 3;
|
||||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+313
-313
@@ -10,412 +10,412 @@
|
|||||||
// Used to create the window icon
|
// Used to create the window icon
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern unsigned lodepng_decode24(
|
extern unsigned lodepng_decode24(
|
||||||
unsigned char** out,
|
unsigned char** out,
|
||||||
unsigned* w,
|
unsigned* w,
|
||||||
unsigned* h,
|
unsigned* h,
|
||||||
const unsigned char* in,
|
const unsigned char* in,
|
||||||
size_t insize
|
size_t insize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenSettings::ScreenSettings(void)
|
ScreenSettings::ScreenSettings(void)
|
||||||
{
|
{
|
||||||
windowWidth = 320;
|
windowWidth = 320;
|
||||||
windowHeight = 240;
|
windowHeight = 240;
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
useVsync = true; // Now that uncapped is the default...
|
useVsync = true; // Now that uncapped is the default...
|
||||||
stretch = 0;
|
stretch = 0;
|
||||||
linearFilter = false;
|
linearFilter = false;
|
||||||
badSignal = false;
|
badSignal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::init(const ScreenSettings& settings)
|
void Screen::init(const ScreenSettings& settings)
|
||||||
{
|
{
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
m_renderer = NULL;
|
m_renderer = NULL;
|
||||||
m_screenTexture = NULL;
|
m_screenTexture = NULL;
|
||||||
m_screen = NULL;
|
m_screen = NULL;
|
||||||
isWindowed = !settings.fullscreen;
|
isWindowed = !settings.fullscreen;
|
||||||
stretchMode = settings.stretch;
|
stretchMode = settings.stretch;
|
||||||
isFiltered = settings.linearFilter;
|
isFiltered = settings.linearFilter;
|
||||||
vsync = settings.useVsync;
|
vsync = settings.useVsync;
|
||||||
filterSubrect.x = 1;
|
filterSubrect.x = 1;
|
||||||
filterSubrect.y = 1;
|
filterSubrect.y = 1;
|
||||||
filterSubrect.w = 318;
|
filterSubrect.w = 318;
|
||||||
filterSubrect.h = 238;
|
filterSubrect.h = 238;
|
||||||
|
|
||||||
SDL_SetHintWithPriority(
|
SDL_SetHintWithPriority(
|
||||||
SDL_HINT_RENDER_SCALE_QUALITY,
|
SDL_HINT_RENDER_SCALE_QUALITY,
|
||||||
isFiltered ? "linear" : "nearest",
|
isFiltered ? "linear" : "nearest",
|
||||||
SDL_HINT_OVERRIDE
|
SDL_HINT_OVERRIDE
|
||||||
);
|
);
|
||||||
SDL_SetHintWithPriority(
|
SDL_SetHintWithPriority(
|
||||||
SDL_HINT_RENDER_VSYNC,
|
SDL_HINT_RENDER_VSYNC,
|
||||||
vsync ? "1" : "0",
|
vsync ? "1" : "0",
|
||||||
SDL_HINT_OVERRIDE
|
SDL_HINT_OVERRIDE
|
||||||
);
|
);
|
||||||
|
|
||||||
// Uncomment this next line when you need to debug -flibit
|
// Uncomment this next line when you need to debug -flibit
|
||||||
// SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "software", SDL_HINT_OVERRIDE);
|
// SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "software", SDL_HINT_OVERRIDE);
|
||||||
// FIXME: m_renderer is also created in resetRendererWorkaround()!
|
// FIXME: m_renderer is also created in resetRendererWorkaround()!
|
||||||
SDL_CreateWindowAndRenderer(
|
SDL_CreateWindowAndRenderer(
|
||||||
640,
|
640,
|
||||||
480,
|
480,
|
||||||
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI,
|
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI,
|
||||||
&m_window,
|
&m_window,
|
||||||
&m_renderer
|
&m_renderer
|
||||||
);
|
);
|
||||||
SDL_SetWindowTitle(m_window, "VVVVVV");
|
SDL_SetWindowTitle(m_window, "VVVVVV");
|
||||||
|
|
||||||
LoadIcon();
|
LoadIcon();
|
||||||
|
|
||||||
// FIXME: This surface should be the actual backbuffer! -flibit
|
// FIXME: This surface should be the actual backbuffer! -flibit
|
||||||
m_screen = SDL_CreateRGBSurface(
|
m_screen = SDL_CreateRGBSurface(
|
||||||
0,
|
0,
|
||||||
320,
|
320,
|
||||||
240,
|
240,
|
||||||
32,
|
32,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x000000FF,
|
0x000000FF,
|
||||||
0xFF000000
|
0xFF000000
|
||||||
);
|
);
|
||||||
// ALSO FIXME: This SDL_CreateTexture() is duplicated twice in this file!
|
// ALSO FIXME: This SDL_CreateTexture() is duplicated twice in this file!
|
||||||
m_screenTexture = SDL_CreateTexture(
|
m_screenTexture = SDL_CreateTexture(
|
||||||
m_renderer,
|
m_renderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
320,
|
320,
|
||||||
240
|
240
|
||||||
);
|
);
|
||||||
|
|
||||||
badSignalEffect = settings.badSignal;
|
badSignalEffect = settings.badSignal;
|
||||||
|
|
||||||
ResizeScreen(settings.windowWidth, settings.windowHeight);
|
ResizeScreen(settings.windowWidth, settings.windowHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::destroy(void)
|
void Screen::destroy(void)
|
||||||
{
|
{
|
||||||
#define X(CLEANUP, POINTER) \
|
#define X(CLEANUP, POINTER) \
|
||||||
CLEANUP(POINTER); \
|
CLEANUP(POINTER); \
|
||||||
POINTER = NULL;
|
POINTER = NULL;
|
||||||
|
|
||||||
/* Order matters! */
|
/* Order matters! */
|
||||||
X(SDL_DestroyTexture, m_screenTexture);
|
X(SDL_DestroyTexture, m_screenTexture);
|
||||||
X(SDL_FreeSurface, m_screen);
|
X(SDL_FreeSurface, m_screen);
|
||||||
X(SDL_DestroyRenderer, m_renderer);
|
X(SDL_DestroyRenderer, m_renderer);
|
||||||
X(SDL_DestroyWindow, m_window);
|
X(SDL_DestroyWindow, m_window);
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::GetSettings(ScreenSettings* settings)
|
void Screen::GetSettings(ScreenSettings* settings)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
GetWindowSize(&width, &height);
|
GetWindowSize(&width, &height);
|
||||||
|
|
||||||
settings->windowWidth = width;
|
settings->windowWidth = width;
|
||||||
settings->windowHeight = height;
|
settings->windowHeight = height;
|
||||||
|
|
||||||
settings->fullscreen = !isWindowed;
|
settings->fullscreen = !isWindowed;
|
||||||
settings->useVsync = vsync;
|
settings->useVsync = vsync;
|
||||||
settings->stretch = stretchMode;
|
settings->stretch = stretchMode;
|
||||||
settings->linearFilter = isFiltered;
|
settings->linearFilter = isFiltered;
|
||||||
settings->badSignal = badSignalEffect;
|
settings->badSignal = badSignalEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::LoadIcon(void)
|
void Screen::LoadIcon(void)
|
||||||
{
|
{
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
unsigned char *fileIn;
|
unsigned char *fileIn;
|
||||||
size_t length;
|
size_t length;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
FILESYSTEM_loadAssetToMemory("VVVVVV.png", &fileIn, &length, false);
|
FILESYSTEM_loadAssetToMemory("VVVVVV.png", &fileIn, &length, false);
|
||||||
lodepng_decode24(&data, &width, &height, fileIn, length);
|
lodepng_decode24(&data, &width, &height, fileIn, length);
|
||||||
FILESYSTEM_freeMemory(&fileIn);
|
FILESYSTEM_freeMemory(&fileIn);
|
||||||
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
|
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
|
||||||
data,
|
data,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
24,
|
24,
|
||||||
width * 3,
|
width * 3,
|
||||||
0x000000FF,
|
0x000000FF,
|
||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x00FF0000,
|
0x00FF0000,
|
||||||
0x00000000
|
0x00000000
|
||||||
);
|
);
|
||||||
SDL_SetWindowIcon(m_window, icon);
|
SDL_SetWindowIcon(m_window, icon);
|
||||||
SDL_FreeSurface(icon);
|
SDL_FreeSurface(icon);
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::ResizeScreen(int x, int y)
|
void Screen::ResizeScreen(int x, int y)
|
||||||
{
|
{
|
||||||
static int resX = 320;
|
static int resX = 320;
|
||||||
static int resY = 240;
|
static int resY = 240;
|
||||||
if (x != -1 && y != -1)
|
if (x != -1 && y != -1)
|
||||||
{
|
{
|
||||||
// This is a user resize!
|
// This is a user resize!
|
||||||
resX = x;
|
resX = x;
|
||||||
resY = y;
|
resY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isWindowed)
|
if(!isWindowed)
|
||||||
{
|
{
|
||||||
int result = SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
int result = SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Error: could not set the game to fullscreen mode: %s", SDL_GetError());
|
vlog_error("Error: could not set the game to fullscreen mode: %s", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int result = SDL_SetWindowFullscreen(m_window, 0);
|
int result = SDL_SetWindowFullscreen(m_window, 0);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Error: could not set the game to windowed mode: %s", SDL_GetError());
|
vlog_error("Error: could not set the game to windowed mode: %s", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (x != -1 && y != -1)
|
if (x != -1 && y != -1)
|
||||||
{
|
{
|
||||||
SDL_SetWindowSize(m_window, resX, resY);
|
SDL_SetWindowSize(m_window, resX, resY);
|
||||||
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stretchMode == 1)
|
if (stretchMode == 1)
|
||||||
{
|
{
|
||||||
int winX, winY;
|
int winX, winY;
|
||||||
GetWindowSize(&winX, &winY);
|
GetWindowSize(&winX, &winY);
|
||||||
int result = SDL_RenderSetLogicalSize(m_renderer, winX, winY);
|
int result = SDL_RenderSetLogicalSize(m_renderer, winX, winY);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Error: could not set logical size: %s", SDL_GetError());
|
vlog_error("Error: could not set logical size: %s", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result = SDL_RenderSetIntegerScale(m_renderer, SDL_FALSE);
|
result = SDL_RenderSetIntegerScale(m_renderer, SDL_FALSE);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Error: could not set scale: %s", SDL_GetError());
|
vlog_error("Error: could not set scale: %s", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
|
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
|
||||||
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (stretchMode == 2));
|
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (stretchMode == 2));
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Error: could not set scale: %s", SDL_GetError());
|
vlog_error("Error: could not set scale: %s", SDL_GetError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_ShowWindow(m_window);
|
SDL_ShowWindow(m_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::ResizeToNearestMultiple(void)
|
void Screen::ResizeToNearestMultiple(void)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
GetWindowSize(&w, &h);
|
GetWindowSize(&w, &h);
|
||||||
|
|
||||||
// Check aspect ratio first
|
// Check aspect ratio first
|
||||||
bool using_width;
|
bool using_width;
|
||||||
int usethisdimension, usethisratio;
|
int usethisdimension, usethisratio;
|
||||||
|
|
||||||
if ((float) w / (float) h > 4.0 / 3.0)
|
if ((float) w / (float) h > 4.0 / 3.0)
|
||||||
{
|
{
|
||||||
// Width is bigger, so it's limited by height
|
// Width is bigger, so it's limited by height
|
||||||
usethisdimension = h;
|
usethisdimension = h;
|
||||||
usethisratio = 240;
|
usethisratio = 240;
|
||||||
using_width = false;
|
using_width = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
|
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
|
||||||
usethisdimension = w;
|
usethisdimension = w;
|
||||||
usethisratio = 320;
|
usethisratio = 320;
|
||||||
using_width = true;
|
using_width = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int floor = (usethisdimension / usethisratio) * usethisratio;
|
int floor = (usethisdimension / usethisratio) * usethisratio;
|
||||||
int ceiling = floor + usethisratio;
|
int ceiling = floor + usethisratio;
|
||||||
|
|
||||||
int final_dimension;
|
int final_dimension;
|
||||||
|
|
||||||
if (usethisdimension - floor < ceiling - usethisdimension)
|
if (usethisdimension - floor < ceiling - usethisdimension)
|
||||||
{
|
{
|
||||||
// Floor is nearest
|
// Floor is nearest
|
||||||
final_dimension = floor;
|
final_dimension = floor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ceiling is nearest. Or we're exactly on a multiple already
|
// Ceiling is nearest. Or we're exactly on a multiple already
|
||||||
final_dimension = ceiling;
|
final_dimension = ceiling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (final_dimension == 0)
|
if (final_dimension == 0)
|
||||||
{
|
{
|
||||||
// We're way too small!
|
// We're way too small!
|
||||||
ResizeScreen(320, 240);
|
ResizeScreen(320, 240);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (using_width)
|
if (using_width)
|
||||||
{
|
{
|
||||||
ResizeScreen(final_dimension, final_dimension / 4 * 3);
|
ResizeScreen(final_dimension, final_dimension / 4 * 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ResizeScreen(final_dimension * 4 / 3, final_dimension);
|
ResizeScreen(final_dimension * 4 / 3, final_dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::GetWindowSize(int* x, int* y)
|
void Screen::GetWindowSize(int* x, int* y)
|
||||||
{
|
{
|
||||||
SDL_GetRendererOutputSize(m_renderer, x, y);
|
SDL_GetRendererOutputSize(m_renderer, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
||||||
{
|
{
|
||||||
if((buffer == NULL) && (m_screen == NULL) )
|
if((buffer == NULL) && (m_screen == NULL) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(badSignalEffect)
|
if(badSignalEffect)
|
||||||
{
|
{
|
||||||
buffer = ApplyFilter(buffer);
|
buffer = ApplyFilter(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ClearSurface(m_screen);
|
ClearSurface(m_screen);
|
||||||
BlitSurfaceStandard(buffer,NULL,m_screen,rect);
|
BlitSurfaceStandard(buffer,NULL,m_screen,rect);
|
||||||
|
|
||||||
if(badSignalEffect)
|
if(badSignalEffect)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(buffer);
|
SDL_FreeSurface(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_PixelFormat* Screen::GetFormat(void)
|
const SDL_PixelFormat* Screen::GetFormat(void)
|
||||||
{
|
{
|
||||||
return m_screen->format;
|
return m_screen->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::FlipScreen(const bool flipmode)
|
void Screen::FlipScreen(const bool flipmode)
|
||||||
{
|
{
|
||||||
SDL_RendererFlip flip_flags;
|
SDL_RendererFlip flip_flags;
|
||||||
if (flipmode)
|
if (flipmode)
|
||||||
{
|
{
|
||||||
flip_flags = SDL_FLIP_VERTICAL;
|
flip_flags = SDL_FLIP_VERTICAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flip_flags = SDL_FLIP_NONE;
|
flip_flags = SDL_FLIP_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UpdateTexture(
|
SDL_UpdateTexture(
|
||||||
m_screenTexture,
|
m_screenTexture,
|
||||||
NULL,
|
NULL,
|
||||||
m_screen->pixels,
|
m_screen->pixels,
|
||||||
m_screen->pitch
|
m_screen->pitch
|
||||||
);
|
);
|
||||||
SDL_RenderCopyEx(
|
SDL_RenderCopyEx(
|
||||||
m_renderer,
|
m_renderer,
|
||||||
m_screenTexture,
|
m_screenTexture,
|
||||||
isFiltered ? &filterSubrect : NULL,
|
isFiltered ? &filterSubrect : NULL,
|
||||||
NULL,
|
NULL,
|
||||||
0.0,
|
0.0,
|
||||||
NULL,
|
NULL,
|
||||||
flip_flags
|
flip_flags
|
||||||
);
|
);
|
||||||
SDL_RenderPresent(m_renderer);
|
SDL_RenderPresent(m_renderer);
|
||||||
SDL_RenderClear(m_renderer);
|
SDL_RenderClear(m_renderer);
|
||||||
ClearSurface(m_screen);
|
ClearSurface(m_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::toggleFullScreen(void)
|
void Screen::toggleFullScreen(void)
|
||||||
{
|
{
|
||||||
isWindowed = !isWindowed;
|
isWindowed = !isWindowed;
|
||||||
ResizeScreen(-1, -1);
|
ResizeScreen(-1, -1);
|
||||||
|
|
||||||
if (game.currentmenuname == Menu::graphicoptions)
|
if (game.currentmenuname == Menu::graphicoptions)
|
||||||
{
|
{
|
||||||
/* Recreate menu to update "resize to nearest" */
|
/* Recreate menu to update "resize to nearest" */
|
||||||
game.createmenu(game.currentmenuname, true);
|
game.createmenu(game.currentmenuname, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::toggleStretchMode(void)
|
void Screen::toggleStretchMode(void)
|
||||||
{
|
{
|
||||||
stretchMode = (stretchMode + 1) % 3;
|
stretchMode = (stretchMode + 1) % 3;
|
||||||
ResizeScreen(-1, -1);
|
ResizeScreen(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::toggleLinearFilter(void)
|
void Screen::toggleLinearFilter(void)
|
||||||
{
|
{
|
||||||
isFiltered = !isFiltered;
|
isFiltered = !isFiltered;
|
||||||
SDL_SetHintWithPriority(
|
SDL_SetHintWithPriority(
|
||||||
SDL_HINT_RENDER_SCALE_QUALITY,
|
SDL_HINT_RENDER_SCALE_QUALITY,
|
||||||
isFiltered ? "linear" : "nearest",
|
isFiltered ? "linear" : "nearest",
|
||||||
SDL_HINT_OVERRIDE
|
SDL_HINT_OVERRIDE
|
||||||
);
|
);
|
||||||
SDL_DestroyTexture(m_screenTexture);
|
SDL_DestroyTexture(m_screenTexture);
|
||||||
m_screenTexture = SDL_CreateTexture(
|
m_screenTexture = SDL_CreateTexture(
|
||||||
m_renderer,
|
m_renderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
320,
|
320,
|
||||||
240
|
240
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::resetRendererWorkaround(void)
|
void Screen::resetRendererWorkaround(void)
|
||||||
{
|
{
|
||||||
SDL_SetHintWithPriority(
|
SDL_SetHintWithPriority(
|
||||||
SDL_HINT_RENDER_VSYNC,
|
SDL_HINT_RENDER_VSYNC,
|
||||||
vsync ? "1" : "0",
|
vsync ? "1" : "0",
|
||||||
SDL_HINT_OVERRIDE
|
SDL_HINT_OVERRIDE
|
||||||
);
|
);
|
||||||
|
|
||||||
/* FIXME: This exists because SDL_HINT_RENDER_VSYNC is not dynamic!
|
/* FIXME: This exists because SDL_HINT_RENDER_VSYNC is not dynamic!
|
||||||
* As a result, our only workaround is to tear down the renderer
|
* As a result, our only workaround is to tear down the renderer
|
||||||
* and recreate everything so that it can process the variable.
|
* and recreate everything so that it can process the variable.
|
||||||
* -flibit
|
* -flibit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (m_renderer == NULL)
|
if (m_renderer == NULL)
|
||||||
{
|
{
|
||||||
/* We haven't made it to init yet, don't worry about it */
|
/* We haven't made it to init yet, don't worry about it */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RendererInfo renderInfo;
|
SDL_RendererInfo renderInfo;
|
||||||
SDL_GetRendererInfo(m_renderer, &renderInfo);
|
SDL_GetRendererInfo(m_renderer, &renderInfo);
|
||||||
bool curVsync = (renderInfo.flags & SDL_RENDERER_PRESENTVSYNC) != 0;
|
bool curVsync = (renderInfo.flags & SDL_RENDERER_PRESENTVSYNC) != 0;
|
||||||
if (vsync == curVsync)
|
if (vsync == curVsync)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyTexture(m_screenTexture);
|
SDL_DestroyTexture(m_screenTexture);
|
||||||
SDL_DestroyRenderer(m_renderer);
|
SDL_DestroyRenderer(m_renderer);
|
||||||
|
|
||||||
m_renderer = SDL_CreateRenderer(m_window, -1, 0);
|
m_renderer = SDL_CreateRenderer(m_window, -1, 0);
|
||||||
m_screenTexture = SDL_CreateTexture(
|
m_screenTexture = SDL_CreateTexture(
|
||||||
m_renderer,
|
m_renderer,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
320,
|
320,
|
||||||
240
|
240
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Ugh, have to make sure to re-apply graphics options after doing the
|
/* Ugh, have to make sure to re-apply graphics options after doing the
|
||||||
* above, otherwise letterbox/integer won't be applied...
|
* above, otherwise letterbox/integer won't be applied...
|
||||||
*/
|
*/
|
||||||
ResizeScreen(-1, -1);
|
ResizeScreen(-1, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,39 +8,39 @@
|
|||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init(const ScreenSettings& settings);
|
void init(const ScreenSettings& settings);
|
||||||
void destroy(void);
|
void destroy(void);
|
||||||
|
|
||||||
void GetSettings(ScreenSettings* settings);
|
void GetSettings(ScreenSettings* settings);
|
||||||
|
|
||||||
void LoadIcon(void);
|
void LoadIcon(void);
|
||||||
|
|
||||||
void ResizeScreen(int x, int y);
|
void ResizeScreen(int x, int y);
|
||||||
void ResizeToNearestMultiple(void);
|
void ResizeToNearestMultiple(void);
|
||||||
void GetWindowSize(int* x, int* y);
|
void GetWindowSize(int* x, int* y);
|
||||||
|
|
||||||
void UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect);
|
void UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect);
|
||||||
void FlipScreen(bool flipmode);
|
void FlipScreen(bool flipmode);
|
||||||
|
|
||||||
const SDL_PixelFormat* GetFormat(void);
|
const SDL_PixelFormat* GetFormat(void);
|
||||||
|
|
||||||
void toggleFullScreen(void);
|
void toggleFullScreen(void);
|
||||||
void toggleStretchMode(void);
|
void toggleStretchMode(void);
|
||||||
void toggleLinearFilter(void);
|
void toggleLinearFilter(void);
|
||||||
void resetRendererWorkaround(void);
|
void resetRendererWorkaround(void);
|
||||||
|
|
||||||
bool isWindowed;
|
bool isWindowed;
|
||||||
bool isFiltered;
|
bool isFiltered;
|
||||||
bool badSignalEffect;
|
bool badSignalEffect;
|
||||||
int stretchMode;
|
int stretchMode;
|
||||||
bool vsync;
|
bool vsync;
|
||||||
|
|
||||||
SDL_Window *m_window;
|
SDL_Window *m_window;
|
||||||
SDL_Renderer *m_renderer;
|
SDL_Renderer *m_renderer;
|
||||||
SDL_Texture *m_screenTexture;
|
SDL_Texture *m_screenTexture;
|
||||||
SDL_Surface* m_screen;
|
SDL_Surface* m_screen;
|
||||||
|
|
||||||
SDL_Rect filterSubrect;
|
SDL_Rect filterSubrect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCREEN_H */
|
#endif /* SCREEN_H */
|
||||||
|
|||||||
@@ -3,15 +3,15 @@
|
|||||||
|
|
||||||
struct ScreenSettings
|
struct ScreenSettings
|
||||||
{
|
{
|
||||||
ScreenSettings(void);
|
ScreenSettings(void);
|
||||||
|
|
||||||
int windowWidth;
|
int windowWidth;
|
||||||
int windowHeight;
|
int windowHeight;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool useVsync;
|
bool useVsync;
|
||||||
int stretch;
|
int stretch;
|
||||||
bool linearFilter;
|
bool linearFilter;
|
||||||
bool badSignal;
|
bool badSignal;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCREENSETTINGS_H */
|
#endif /* SCREENSETTINGS_H */
|
||||||
|
|||||||
+3297
-3297
File diff suppressed because it is too large
Load Diff
@@ -7,60 +7,60 @@
|
|||||||
|
|
||||||
MusicTrack::MusicTrack(const char* fileName)
|
MusicTrack::MusicTrack(const char* fileName)
|
||||||
{
|
{
|
||||||
m_music = Mix_LoadMUS(fileName);
|
m_music = Mix_LoadMUS(fileName);
|
||||||
m_isValid = true;
|
m_isValid = true;
|
||||||
if(m_music == NULL)
|
if(m_music == NULL)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to load Ogg Music file: %s", Mix_GetError());
|
vlog_error("Unable to load Ogg Music file: %s", Mix_GetError());
|
||||||
m_isValid = false;
|
m_isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicTrack::MusicTrack(SDL_RWops *rw)
|
MusicTrack::MusicTrack(SDL_RWops *rw)
|
||||||
{
|
{
|
||||||
m_music = Mix_LoadMUS_RW(rw, 1);
|
m_music = Mix_LoadMUS_RW(rw, 1);
|
||||||
m_isValid = true;
|
m_isValid = true;
|
||||||
if(m_music == NULL)
|
if(m_music == NULL)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to load Magic Binary Music file: %s", Mix_GetError());
|
vlog_error("Unable to load Magic Binary Music file: %s", Mix_GetError());
|
||||||
m_isValid = false;
|
m_isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundTrack::SoundTrack(const char* fileName)
|
SoundTrack::SoundTrack(const char* fileName)
|
||||||
{
|
{
|
||||||
unsigned char *mem;
|
unsigned char *mem;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
sound = NULL;
|
sound = NULL;
|
||||||
|
|
||||||
FILESYSTEM_loadAssetToMemory(fileName, &mem, &length, false);
|
FILESYSTEM_loadAssetToMemory(fileName, &mem, &length, false);
|
||||||
if (mem == NULL)
|
if (mem == NULL)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to load WAV file %s", fileName);
|
vlog_error("Unable to load WAV file %s", fileName);
|
||||||
SDL_assert(0 && "WAV file missing!");
|
SDL_assert(0 && "WAV file missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length);
|
SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length);
|
||||||
sound = Mix_LoadWAV_RW(fileIn, 1);
|
sound = Mix_LoadWAV_RW(fileIn, 1);
|
||||||
FILESYSTEM_freeMemory(&mem);
|
FILESYSTEM_freeMemory(&mem);
|
||||||
|
|
||||||
if (sound == NULL)
|
if (sound == NULL)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to load WAV file: %s", Mix_GetError());
|
vlog_error("Unable to load WAV file: %s", Mix_GetError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundSystem::SoundSystem(void)
|
SoundSystem::SoundSystem(void)
|
||||||
{
|
{
|
||||||
int audio_rate = 44100;
|
int audio_rate = 44100;
|
||||||
Uint16 audio_format = AUDIO_S16SYS;
|
Uint16 audio_format = AUDIO_S16SYS;
|
||||||
int audio_channels = 2;
|
int audio_channels = 2;
|
||||||
int audio_buffers = 1024;
|
int audio_buffers = 1024;
|
||||||
|
|
||||||
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
|
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to initialize audio: %s", Mix_GetError());
|
vlog_error("Unable to initialize audio: %s", Mix_GetError());
|
||||||
SDL_assert(0 && "Unable to initialize audio!");
|
SDL_assert(0 && "Unable to initialize audio!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,23 @@
|
|||||||
class MusicTrack
|
class MusicTrack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MusicTrack(const char* fileName);
|
MusicTrack(const char* fileName);
|
||||||
MusicTrack(SDL_RWops *rw);
|
MusicTrack(SDL_RWops *rw);
|
||||||
Mix_Music *m_music;
|
Mix_Music *m_music;
|
||||||
bool m_isValid;
|
bool m_isValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SoundTrack
|
class SoundTrack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundTrack(const char* fileName);
|
SoundTrack(const char* fileName);
|
||||||
Mix_Chunk *sound;
|
Mix_Chunk *sound;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SoundSystem
|
class SoundSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundSystem(void);
|
SoundSystem(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SOUNDSYSTEM_H */
|
#endif /* SOUNDSYSTEM_H */
|
||||||
|
|||||||
+3616
-3616
File diff suppressed because it is too large
Load Diff
@@ -6,8 +6,8 @@
|
|||||||
class spacestation2class
|
class spacestation2class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const short* loadlevel(int rx, int ry);
|
const short* loadlevel(int rx, int ry);
|
||||||
std::string roomname;
|
std::string roomname;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPACESTATION2_H */
|
#endif /* SPACESTATION2_H */
|
||||||
|
|||||||
+124
-124
@@ -34,26 +34,26 @@ typedef intptr_t (*SteamInternal_CreateInterfaceFunc)(const char*);
|
|||||||
typedef int32_t (*SteamAPI_GetHSteamUserFunc)(void);
|
typedef int32_t (*SteamAPI_GetHSteamUserFunc)(void);
|
||||||
typedef int32_t (*SteamAPI_GetHSteamPipeFunc)(void);
|
typedef int32_t (*SteamAPI_GetHSteamPipeFunc)(void);
|
||||||
typedef intptr_t (*SteamAPI_ISteamClient_GetISteamUserStatsFunc)(
|
typedef intptr_t (*SteamAPI_ISteamClient_GetISteamUserStatsFunc)(
|
||||||
intptr_t,
|
intptr_t,
|
||||||
int32_t,
|
int32_t,
|
||||||
int32_t,
|
int32_t,
|
||||||
const char*
|
const char*
|
||||||
);
|
);
|
||||||
typedef uint8_t (*SteamAPI_ISteamUserStats_RequestCurrentStatsFunc)(intptr_t);
|
typedef uint8_t (*SteamAPI_ISteamUserStats_RequestCurrentStatsFunc)(intptr_t);
|
||||||
typedef uint8_t (*SteamAPI_ISteamUserStats_StoreStatsFunc)(intptr_t);
|
typedef uint8_t (*SteamAPI_ISteamUserStats_StoreStatsFunc)(intptr_t);
|
||||||
typedef uint8_t (*SteamAPI_ISteamUserStats_GetStatFunc)(
|
typedef uint8_t (*SteamAPI_ISteamUserStats_GetStatFunc)(
|
||||||
intptr_t,
|
intptr_t,
|
||||||
const char*,
|
const char*,
|
||||||
int32_t*
|
int32_t*
|
||||||
);
|
);
|
||||||
typedef uint8_t (*SteamAPI_ISteamUserStats_SetStatFunc)(
|
typedef uint8_t (*SteamAPI_ISteamUserStats_SetStatFunc)(
|
||||||
intptr_t,
|
intptr_t,
|
||||||
const char*,
|
const char*,
|
||||||
int32_t
|
int32_t
|
||||||
);
|
);
|
||||||
typedef uint8_t (*SteamAPI_ISteamUserStats_SetAchievementFunc)(
|
typedef uint8_t (*SteamAPI_ISteamUserStats_SetAchievementFunc)(
|
||||||
intptr_t,
|
intptr_t,
|
||||||
const char*
|
const char*
|
||||||
);
|
);
|
||||||
|
|
||||||
/* DLL, Entry Points */
|
/* DLL, Entry Points */
|
||||||
@@ -80,21 +80,21 @@ DEFINE_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
|
|||||||
|
|
||||||
static void ClearPointers(void)
|
static void ClearPointers(void)
|
||||||
{
|
{
|
||||||
SDL_UnloadObject(libHandle);
|
SDL_UnloadObject(libHandle);
|
||||||
libHandle = NULL;
|
libHandle = NULL;
|
||||||
steamUserStats = (intptr_t) NULL;
|
steamUserStats = (intptr_t) NULL;
|
||||||
SteamAPI_Init = NULL;
|
SteamAPI_Init = NULL;
|
||||||
SteamAPI_Shutdown = NULL;
|
SteamAPI_Shutdown = NULL;
|
||||||
SteamAPI_RunCallbacks = NULL;
|
SteamAPI_RunCallbacks = NULL;
|
||||||
SteamInternal_CreateInterface = NULL;
|
SteamInternal_CreateInterface = NULL;
|
||||||
SteamAPI_GetHSteamUser = NULL;
|
SteamAPI_GetHSteamUser = NULL;
|
||||||
SteamAPI_GetHSteamPipe = NULL;
|
SteamAPI_GetHSteamPipe = NULL;
|
||||||
SteamAPI_ISteamClient_GetISteamUserStats = NULL;
|
SteamAPI_ISteamClient_GetISteamUserStats = NULL;
|
||||||
SteamAPI_ISteamUserStats_RequestCurrentStats = NULL;
|
SteamAPI_ISteamUserStats_RequestCurrentStats = NULL;
|
||||||
SteamAPI_ISteamUserStats_StoreStats = NULL;
|
SteamAPI_ISteamUserStats_StoreStats = NULL;
|
||||||
SteamAPI_ISteamUserStats_GetStat = NULL;
|
SteamAPI_ISteamUserStats_GetStat = NULL;
|
||||||
SteamAPI_ISteamUserStats_SetStat = NULL;
|
SteamAPI_ISteamUserStats_SetStat = NULL;
|
||||||
SteamAPI_ISteamUserStats_SetAchievement = NULL;
|
SteamAPI_ISteamUserStats_SetAchievement = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NETWORK API Implementation */
|
/* NETWORK API Implementation */
|
||||||
@@ -102,127 +102,127 @@ static void ClearPointers(void)
|
|||||||
int32_t STEAM_init(void)
|
int32_t STEAM_init(void)
|
||||||
{
|
{
|
||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
intptr_t steamClient;
|
intptr_t steamClient;
|
||||||
int32_t steamUser, steamPipe;
|
int32_t steamUser, steamPipe;
|
||||||
|
|
||||||
libHandle = SDL_LoadObject(STEAM_LIBRARY);
|
libHandle = SDL_LoadObject(STEAM_LIBRARY);
|
||||||
if (!libHandle)
|
if (!libHandle)
|
||||||
{
|
{
|
||||||
vlog_info("%s not found!", STEAM_LIBRARY);
|
vlog_info("%s not found!", STEAM_LIBRARY);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOAD_FUNC(name) \
|
#define LOAD_FUNC(name) \
|
||||||
name = (name##Func) SDL_LoadFunction(libHandle, #name); \
|
name = (name##Func) SDL_LoadFunction(libHandle, #name); \
|
||||||
if (!name) \
|
if (!name) \
|
||||||
{ \
|
{ \
|
||||||
vlog_error("%s symbol %s not found!", STEAM_LIBRARY, #name); \
|
vlog_error("%s symbol %s not found!", STEAM_LIBRARY, #name); \
|
||||||
ClearPointers(); \
|
ClearPointers(); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
LOAD_FUNC(SteamAPI_Init)
|
LOAD_FUNC(SteamAPI_Init)
|
||||||
LOAD_FUNC(SteamAPI_Shutdown)
|
LOAD_FUNC(SteamAPI_Shutdown)
|
||||||
LOAD_FUNC(SteamAPI_RunCallbacks)
|
LOAD_FUNC(SteamAPI_RunCallbacks)
|
||||||
LOAD_FUNC(SteamInternal_CreateInterface)
|
LOAD_FUNC(SteamInternal_CreateInterface)
|
||||||
LOAD_FUNC(SteamAPI_GetHSteamUser)
|
LOAD_FUNC(SteamAPI_GetHSteamUser)
|
||||||
LOAD_FUNC(SteamAPI_GetHSteamPipe)
|
LOAD_FUNC(SteamAPI_GetHSteamPipe)
|
||||||
LOAD_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
|
LOAD_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
|
||||||
LOAD_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
|
LOAD_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
|
||||||
LOAD_FUNC(SteamAPI_ISteamUserStats_StoreStats)
|
LOAD_FUNC(SteamAPI_ISteamUserStats_StoreStats)
|
||||||
LOAD_FUNC(SteamAPI_ISteamUserStats_GetStat)
|
LOAD_FUNC(SteamAPI_ISteamUserStats_GetStat)
|
||||||
LOAD_FUNC(SteamAPI_ISteamUserStats_SetStat)
|
LOAD_FUNC(SteamAPI_ISteamUserStats_SetStat)
|
||||||
LOAD_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
|
LOAD_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
|
||||||
#undef LOAD_FUNC
|
#undef LOAD_FUNC
|
||||||
|
|
||||||
if (!SteamAPI_Init())
|
if (!SteamAPI_Init())
|
||||||
{
|
{
|
||||||
vlog_error("Steamworks not initialized!");
|
vlog_error("Steamworks not initialized!");
|
||||||
ClearPointers();
|
ClearPointers();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
steamClient = SteamInternal_CreateInterface(VVVVVV_STEAMCLIENT);
|
steamClient = SteamInternal_CreateInterface(VVVVVV_STEAMCLIENT);
|
||||||
steamUser = SteamAPI_GetHSteamUser();
|
steamUser = SteamAPI_GetHSteamUser();
|
||||||
steamPipe = SteamAPI_GetHSteamPipe();
|
steamPipe = SteamAPI_GetHSteamPipe();
|
||||||
if (!steamClient || !steamUser || !steamPipe)
|
if (!steamClient || !steamUser || !steamPipe)
|
||||||
{
|
{
|
||||||
SteamAPI_Shutdown();
|
SteamAPI_Shutdown();
|
||||||
vlog_error(VVVVVV_STEAMCLIENT " not created!");
|
vlog_error(VVVVVV_STEAMCLIENT " not created!");
|
||||||
ClearPointers();
|
ClearPointers();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
steamUserStats = SteamAPI_ISteamClient_GetISteamUserStats(
|
steamUserStats = SteamAPI_ISteamClient_GetISteamUserStats(
|
||||||
steamClient,
|
steamClient,
|
||||||
steamUser,
|
steamUser,
|
||||||
steamPipe,
|
steamPipe,
|
||||||
VVVVVV_STEAMUSERSTATS
|
VVVVVV_STEAMUSERSTATS
|
||||||
);
|
);
|
||||||
if (!steamUserStats)
|
if (!steamUserStats)
|
||||||
{
|
{
|
||||||
SteamAPI_Shutdown();
|
SteamAPI_Shutdown();
|
||||||
vlog_error(VVVVVV_STEAMUSERSTATS " not created!");
|
vlog_error(VVVVVV_STEAMUSERSTATS " not created!");
|
||||||
ClearPointers();
|
ClearPointers();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SteamAPI_ISteamUserStats_RequestCurrentStats(steamUserStats);
|
SteamAPI_ISteamUserStats_RequestCurrentStats(steamUserStats);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STEAM_shutdown(void)
|
void STEAM_shutdown(void)
|
||||||
{
|
{
|
||||||
if (libHandle)
|
if (libHandle)
|
||||||
{
|
{
|
||||||
SteamAPI_Shutdown();
|
SteamAPI_Shutdown();
|
||||||
ClearPointers();
|
ClearPointers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STEAM_update(void)
|
void STEAM_update(void)
|
||||||
{
|
{
|
||||||
if (libHandle)
|
if (libHandle)
|
||||||
{
|
{
|
||||||
SteamAPI_RunCallbacks();
|
SteamAPI_RunCallbacks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STEAM_unlockAchievement(const char *name)
|
void STEAM_unlockAchievement(const char *name)
|
||||||
{
|
{
|
||||||
if (libHandle)
|
if (libHandle)
|
||||||
{
|
{
|
||||||
SteamAPI_ISteamUserStats_SetAchievement(
|
SteamAPI_ISteamUserStats_SetAchievement(
|
||||||
steamUserStats,
|
steamUserStats,
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t STEAM_getAchievementProgress(const char *name)
|
int32_t STEAM_getAchievementProgress(const char *name)
|
||||||
{
|
{
|
||||||
int32_t result = -1;
|
int32_t result = -1;
|
||||||
if (libHandle)
|
if (libHandle)
|
||||||
{
|
{
|
||||||
SteamAPI_ISteamUserStats_GetStat(
|
SteamAPI_ISteamUserStats_GetStat(
|
||||||
steamUserStats,
|
steamUserStats,
|
||||||
name,
|
name,
|
||||||
&result
|
&result
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STEAM_setAchievementProgress(const char *name, int32_t stat)
|
void STEAM_setAchievementProgress(const char *name, int32_t stat)
|
||||||
{
|
{
|
||||||
if (libHandle)
|
if (libHandle)
|
||||||
{
|
{
|
||||||
SteamAPI_ISteamUserStats_SetStat(
|
SteamAPI_ISteamUserStats_SetStat(
|
||||||
steamUserStats,
|
steamUserStats,
|
||||||
name,
|
name,
|
||||||
stat
|
stat
|
||||||
);
|
);
|
||||||
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MAKEANDPLAY */
|
#endif /* MAKEANDPLAY */
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ void scriptclass::loadother(const char* t)
|
|||||||
|
|
||||||
|
|
||||||
static const char* lines[] = {
|
static const char* lines[] = {
|
||||||
//"delay(15)", "flash(5)", "shake(20)", "playef(9)",
|
//"delay(15)", "flash(5)", "shake(20)", "playef(9)",
|
||||||
|
|
||||||
"text(gray,0,114,3)",
|
"text(gray,0,114,3)",
|
||||||
" -= WARNING =- ",
|
" -= WARNING =- ",
|
||||||
|
|||||||
+1103
-1103
File diff suppressed because it is too large
Load Diff
@@ -5,16 +5,16 @@
|
|||||||
|
|
||||||
struct TowerBG
|
struct TowerBG
|
||||||
{
|
{
|
||||||
SDL_Surface* buffer;
|
SDL_Surface* buffer;
|
||||||
SDL_Surface* buffer_lerp;
|
SDL_Surface* buffer_lerp;
|
||||||
bool tdrawback;
|
bool tdrawback;
|
||||||
int bypos;
|
int bypos;
|
||||||
int bscroll;
|
int bscroll;
|
||||||
int colstate;
|
int colstate;
|
||||||
int scrolldir;
|
int scrolldir;
|
||||||
int r;
|
int r;
|
||||||
int g;
|
int g;
|
||||||
int b;
|
int b;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TOWERBG_H */
|
#endif /* TOWERBG_H */
|
||||||
|
|||||||
@@ -8,354 +8,354 @@
|
|||||||
|
|
||||||
static const char* GCChar(const SDL_GameControllerButton button)
|
static const char* GCChar(const SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case SDL_CONTROLLER_BUTTON_A:
|
case SDL_CONTROLLER_BUTTON_A:
|
||||||
return "A";
|
return "A";
|
||||||
case SDL_CONTROLLER_BUTTON_B:
|
case SDL_CONTROLLER_BUTTON_B:
|
||||||
return "B";
|
return "B";
|
||||||
case SDL_CONTROLLER_BUTTON_X:
|
case SDL_CONTROLLER_BUTTON_X:
|
||||||
return "X";
|
return "X";
|
||||||
case SDL_CONTROLLER_BUTTON_Y:
|
case SDL_CONTROLLER_BUTTON_Y:
|
||||||
return "Y";
|
return "Y";
|
||||||
case SDL_CONTROLLER_BUTTON_BACK:
|
case SDL_CONTROLLER_BUTTON_BACK:
|
||||||
return "BACK";
|
return "BACK";
|
||||||
case SDL_CONTROLLER_BUTTON_GUIDE:
|
case SDL_CONTROLLER_BUTTON_GUIDE:
|
||||||
return "GUIDE";
|
return "GUIDE";
|
||||||
case SDL_CONTROLLER_BUTTON_START:
|
case SDL_CONTROLLER_BUTTON_START:
|
||||||
return "START";
|
return "START";
|
||||||
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
||||||
return "L3";
|
return "L3";
|
||||||
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
|
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
|
||||||
return "R3";
|
return "R3";
|
||||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
||||||
return "LB";
|
return "LB";
|
||||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
||||||
return "RB";
|
return "RB";
|
||||||
default:
|
default:
|
||||||
SDL_assert(0 && "Unhandled button!");
|
SDL_assert(0 && "Unhandled button!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_toi(const std::string& str)
|
int ss_toi(const std::string& str)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
bool negative = false;
|
bool negative = false;
|
||||||
static const int radix = 10;
|
static const int radix = 10;
|
||||||
|
|
||||||
for (size_t i = 0; i < str.size(); ++i)
|
for (size_t i = 0; i < str.size(); ++i)
|
||||||
{
|
{
|
||||||
const char chr = str[i];
|
const char chr = str[i];
|
||||||
|
|
||||||
if (i == 0 && chr == '-')
|
if (i == 0 && chr == '-')
|
||||||
{
|
{
|
||||||
negative = true;
|
negative = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_isdigit(chr))
|
if (SDL_isdigit(chr))
|
||||||
{
|
{
|
||||||
retval *= radix;
|
retval *= radix;
|
||||||
retval += chr - '0';
|
retval += chr - '0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (negative)
|
if (negative)
|
||||||
{
|
{
|
||||||
return -retval;
|
return -retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool next_split(
|
bool next_split(
|
||||||
size_t* start,
|
size_t* start,
|
||||||
size_t* len,
|
size_t* len,
|
||||||
const char* str,
|
const char* str,
|
||||||
const char delim
|
const char delim
|
||||||
) {
|
) {
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
|
||||||
if (str[idx] == '\0')
|
if (str[idx] == '\0')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (str[idx] == delim)
|
if (str[idx] == delim)
|
||||||
{
|
{
|
||||||
*start += 1;
|
*start += 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (str[idx] == '\0')
|
else if (str[idx] == '\0')
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx += 1;
|
idx += 1;
|
||||||
*start += 1;
|
*start += 1;
|
||||||
*len += 1;
|
*len += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool next_split_s(
|
bool next_split_s(
|
||||||
char buffer[],
|
char buffer[],
|
||||||
const size_t buffer_size,
|
const size_t buffer_size,
|
||||||
size_t* start,
|
size_t* start,
|
||||||
const char* str,
|
const char* str,
|
||||||
const char delim
|
const char delim
|
||||||
) {
|
) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
const size_t prev_start = *start;
|
const size_t prev_start = *start;
|
||||||
|
|
||||||
const bool retval = next_split(start, &len, &str[*start], delim);
|
const bool retval = next_split(start, &len, &str[*start], delim);
|
||||||
|
|
||||||
if (retval)
|
if (retval)
|
||||||
{
|
{
|
||||||
/* Using SDL_strlcpy() here results in calling SDL_strlen() */
|
/* Using SDL_strlcpy() here results in calling SDL_strlen() */
|
||||||
/* on the whole string, which results in a visible freeze */
|
/* on the whole string, which results in a visible freeze */
|
||||||
/* if it's a very large string */
|
/* if it's a very large string */
|
||||||
const size_t length = VVV_min(buffer_size - 1, len);
|
const size_t length = VVV_min(buffer_size - 1, len);
|
||||||
SDL_memcpy(buffer, &str[prev_start], length);
|
SDL_memcpy(buffer, &str[prev_start], length);
|
||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
UtilityClass::UtilityClass(void) :
|
UtilityClass::UtilityClass(void) :
|
||||||
glow(0),
|
glow(0),
|
||||||
glowdir(0)
|
glowdir(0)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < SDL_arraysize(splitseconds); i++)
|
for (size_t i = 0; i < SDL_arraysize(splitseconds); i++)
|
||||||
{
|
{
|
||||||
splitseconds[i] = (i * 100) / 30;
|
splitseconds[i] = (i * 100) / 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
slowsine = 0;
|
slowsine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UtilityClass::String( int _v )
|
std::string UtilityClass::String( int _v )
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << _v;
|
os << _v;
|
||||||
return(os.str());
|
return(os.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int UtilityClass::Int(const char* str, int fallback /*= 0*/)
|
int UtilityClass::Int(const char* str, int fallback /*= 0*/)
|
||||||
{
|
{
|
||||||
if (!is_number(str))
|
if (!is_number(str))
|
||||||
{
|
{
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) SDL_strtol(str, NULL, 0);
|
return (int) SDL_strtol(str, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UtilityClass::GCString(const std::vector<SDL_GameControllerButton>& buttons)
|
std::string UtilityClass::GCString(const std::vector<SDL_GameControllerButton>& buttons)
|
||||||
{
|
{
|
||||||
std::string retval = "";
|
std::string retval = "";
|
||||||
for (size_t i = 0; i < buttons.size(); i += 1)
|
for (size_t i = 0; i < buttons.size(); i += 1)
|
||||||
{
|
{
|
||||||
retval += GCChar(buttons[i]);
|
retval += GCChar(buttons[i]);
|
||||||
if ((i + 1) < buttons.size())
|
if ((i + 1) < buttons.size())
|
||||||
{
|
{
|
||||||
retval += ",";
|
retval += ",";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UtilityClass::twodigits( int t )
|
std::string UtilityClass::twodigits( int t )
|
||||||
{
|
{
|
||||||
if (t < 10)
|
if (t < 10)
|
||||||
{
|
{
|
||||||
return "0" + String(t);
|
return "0" + String(t);
|
||||||
}
|
}
|
||||||
if (t >= 100)
|
if (t >= 100)
|
||||||
{
|
{
|
||||||
return "??";
|
return "??";
|
||||||
}
|
}
|
||||||
return String(t);
|
return String(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UtilityClass::timestring( int t )
|
std::string UtilityClass::timestring( int t )
|
||||||
{
|
{
|
||||||
//given a time t in frames, return a time in seconds
|
//given a time t in frames, return a time in seconds
|
||||||
std::string tempstring = "";
|
std::string tempstring = "";
|
||||||
int temp = (t - (t % 30)) / 30;
|
int temp = (t - (t % 30)) / 30;
|
||||||
if (temp < 60) //less than one minute
|
if (temp < 60) //less than one minute
|
||||||
{
|
{
|
||||||
t = t % 30;
|
t = t % 30;
|
||||||
tempstring = String(temp) + ":" + twodigits(splitseconds[t]);
|
tempstring = String(temp) + ":" + twodigits(splitseconds[t]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int temp2 = (temp - (temp % 60)) / 60;
|
int temp2 = (temp - (temp % 60)) / 60;
|
||||||
temp = temp % 60;
|
temp = temp % 60;
|
||||||
t = t % 30;
|
t = t % 30;
|
||||||
tempstring = String(temp2) + ":" + twodigits(temp) + ":" + twodigits(splitseconds[t]);
|
tempstring = String(temp2) + ":" + twodigits(temp) + ":" + twodigits(splitseconds[t]);
|
||||||
}
|
}
|
||||||
return tempstring;
|
return tempstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UtilityClass::number( int _t )
|
std::string UtilityClass::number( int _t )
|
||||||
{
|
{
|
||||||
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
|
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
|
||||||
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
|
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
|
||||||
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
|
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
|
||||||
|
|
||||||
if (_t < 0)
|
if (_t < 0)
|
||||||
{
|
{
|
||||||
return "???";
|
return "???";
|
||||||
}
|
}
|
||||||
else if (_t > 100)
|
else if (_t > 100)
|
||||||
{
|
{
|
||||||
return "Lots";
|
return "Lots";
|
||||||
}
|
}
|
||||||
else if (_t == 0)
|
else if (_t == 0)
|
||||||
{
|
{
|
||||||
return "Zero";
|
return "Zero";
|
||||||
}
|
}
|
||||||
else if (_t == 100)
|
else if (_t == 100)
|
||||||
{
|
{
|
||||||
return "One Hundred";
|
return "One Hundred";
|
||||||
}
|
}
|
||||||
else if (_t >= 1 && _t <= 9)
|
else if (_t >= 1 && _t <= 9)
|
||||||
{
|
{
|
||||||
return ones_place[_t-1];
|
return ones_place[_t-1];
|
||||||
}
|
}
|
||||||
else if (_t >= 11 && _t <= 19)
|
else if (_t >= 11 && _t <= 19)
|
||||||
{
|
{
|
||||||
return teens[_t-11];
|
return teens[_t-11];
|
||||||
}
|
}
|
||||||
else if (_t % 10 == 0)
|
else if (_t % 10 == 0)
|
||||||
{
|
{
|
||||||
return tens_place[(_t/10)-1];
|
return tens_place[(_t/10)-1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return tens_place[(_t/10)-1] + " " + ones_place[(_t%10)-1];
|
return tens_place[(_t/10)-1] + " " + ones_place[(_t%10)-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
|
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
|
||||||
{
|
{
|
||||||
return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
|
return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtilityClass::updateglow(void)
|
void UtilityClass::updateglow(void)
|
||||||
{
|
{
|
||||||
slowsine++;
|
slowsine++;
|
||||||
if (slowsine >= 64) slowsine = 0;
|
if (slowsine >= 64) slowsine = 0;
|
||||||
|
|
||||||
if (glowdir == 0) {
|
if (glowdir == 0) {
|
||||||
glow+=2;
|
glow+=2;
|
||||||
if (glow >= 62) glowdir = 1;
|
if (glow >= 62) glowdir = 1;
|
||||||
}else {
|
}else {
|
||||||
glow-=2;
|
glow-=2;
|
||||||
if (glow < 2) glowdir = 0;
|
if (glow < 2) glowdir = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_number(const char* str)
|
bool is_number(const char* str)
|
||||||
{
|
{
|
||||||
if (!SDL_isdigit(str[0]) && str[0] != '-')
|
if (!SDL_isdigit(str[0]) && str[0] != '-')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str[0] == '-' && str[1] == '\0')
|
if (str[0] == '-' && str[1] == '\0')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 1; str[i] != '\0'; ++i)
|
for (size_t i = 1; str[i] != '\0'; ++i)
|
||||||
{
|
{
|
||||||
if (!SDL_isdigit(str[i]))
|
if (!SDL_isdigit(str[i]))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool VVV_isxdigit(const unsigned char digit)
|
static bool VVV_isxdigit(const unsigned char digit)
|
||||||
{
|
{
|
||||||
return (digit >= 'a' && digit <= 'f')
|
return (digit >= 'a' && digit <= 'f')
|
||||||
|| (digit >= 'A' && digit <= 'F')
|
|| (digit >= 'A' && digit <= 'F')
|
||||||
|| SDL_isdigit(digit);
|
|| SDL_isdigit(digit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_positive_num(const char* str, const bool hex)
|
bool is_positive_num(const char* str, const bool hex)
|
||||||
{
|
{
|
||||||
if (str[0] == '\0')
|
if (str[0] == '\0')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; str[i] != '\0'; ++i)
|
for (size_t i = 0; str[i] != '\0'; ++i)
|
||||||
{
|
{
|
||||||
if (hex)
|
if (hex)
|
||||||
{
|
{
|
||||||
if (!VVV_isxdigit(str[i]))
|
if (!VVV_isxdigit(str[i]))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!SDL_isdigit(str[i]))
|
if (!SDL_isdigit(str[i]))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool endsWith(const char* str, const char* suffix)
|
bool endsWith(const char* str, const char* suffix)
|
||||||
{
|
{
|
||||||
const size_t str_size = SDL_strlen(str);
|
const size_t str_size = SDL_strlen(str);
|
||||||
const size_t suffix_size = SDL_strlen(suffix);
|
const size_t suffix_size = SDL_strlen(suffix);
|
||||||
|
|
||||||
if (str_size < suffix_size)
|
if (str_size < suffix_size)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
|
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VVV_fillstring(
|
void VVV_fillstring(
|
||||||
char* buffer,
|
char* buffer,
|
||||||
const size_t buffer_size,
|
const size_t buffer_size,
|
||||||
const char fillchar
|
const char fillchar
|
||||||
) {
|
) {
|
||||||
SDL_memset(buffer, fillchar, buffer_size - 1);
|
SDL_memset(buffer, fillchar, buffer_size - 1);
|
||||||
buffer[buffer_size - 1] = '\0';
|
buffer[buffer_size - 1] = '\0';
|
||||||
}
|
}
|
||||||
void _VVV_between(
|
void _VVV_between(
|
||||||
const char* original,
|
const char* original,
|
||||||
const size_t left_length,
|
const size_t left_length,
|
||||||
char* middle,
|
char* middle,
|
||||||
const size_t right_length,
|
const size_t right_length,
|
||||||
const size_t middle_size
|
const size_t middle_size
|
||||||
) {
|
) {
|
||||||
size_t middle_length = SDL_strlen(original);
|
size_t middle_length = SDL_strlen(original);
|
||||||
middle_length -= left_length + right_length;
|
middle_length -= left_length + right_length;
|
||||||
SDL_strlcpy(
|
SDL_strlcpy(
|
||||||
middle,
|
middle,
|
||||||
&original[left_length],
|
&original[left_length],
|
||||||
VVV_min(middle_length + 1, middle_size)
|
VVV_min(middle_length + 1, middle_size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+1121
-1121
File diff suppressed because it is too large
Load Diff
@@ -6,10 +6,10 @@
|
|||||||
class warpclass
|
class warpclass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const short* loadlevel(int rx, int ry);
|
const short* loadlevel(int rx, int ry);
|
||||||
std::string roomname;
|
std::string roomname;
|
||||||
int rcol;
|
int rcol;
|
||||||
bool warpx, warpy;
|
bool warpx, warpy;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WARPCLASS_H */
|
#endif /* WARPCLASS_H */
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
# Get interim commit and date of commit
|
# Get interim commit and date of commit
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||||
OUTPUT_VARIABLE INTERIM_COMMIT
|
OUTPUT_VARIABLE INTERIM_COMMIT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cs
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cs
|
||||||
OUTPUT_VARIABLE COMMIT_DATE
|
OUTPUT_VARIABLE COMMIT_DATE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE})")
|
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE})")
|
||||||
|
|||||||
Reference in New Issue
Block a user