diff --git a/Aquaria/AquariaCompileConfig.h b/Aquaria/AquariaCompileConfig.h new file mode 100644 index 0000000..3d763f7 --- /dev/null +++ b/Aquaria/AquariaCompileConfig.h @@ -0,0 +1,41 @@ +#ifndef __AQUARIA_COMPILE_CONFIG_H__ +#define __AQUARIA_COMPILE_CONFIG_H__ + +// The settings below are also configurable with CMake. +// Define BBGE_SKIP_CONFIG_HEADERS to use CMake-only configuration. +#ifndef BBGE_SKIP_CONFIG_HEADERS + + #define AQUARIA_FULL 1 + //#define AQUARIA_DEMO 1 + #define AQUARIA_BUILD_CONSOLE 1 + #define AQUARIA_BUILD_SCENEEDITOR 1 + + #define AQUARIA_CUSTOM_BUILD_ID "" + + // no console window in release mode (note for MSVC: use together with linker SubSystem setting) + #ifdef NDEBUG + # define AQUARIA_WIN32_NOCONSOLE + #endif + +#endif + + + +// Not CMake-configurable defines, change at your own risk + +// Should stay always defined; this tracks visited map areas +#define AQUARIA_BUILD_MAPVIS + +// Define this to save map visited data in a base64-encoded raw format. +// This can take much less space than the standard text format (as little +// as 10%), but WILL BE INCOMPATIBLE with previous builds of Aquaria -- +// the visited data will be lost if the file is loaded into such a build. +// (Current builds will load either format regardless of whether or not +// this is defined.) +//#define AQUARIA_SAVE_MAPVIS_RAW + +// Interesting, old test stuff +//#define AQ_TEST_QUADTRAIL + + +#endif //__AQUARIA_COMPILE_CONFIG_H__ diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 622e9db..4b8f28f 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __dsq__ #define __dsq__ +#include "AquariaCompileConfig.h" #include "../BBGE/Core.h" #include "../BBGE/Quad.h" #include "Element.h" @@ -362,6 +363,10 @@ enum FormUpgradeType FORMUPGRADE_MAX }; +// defined by windows includes +#undef INPUT_MOUSE +#undef INPUT_KEYBOARD + enum InputMode { INPUT_MOUSE = 0, diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 4fa55c3..2a3d2f4 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -7812,7 +7812,7 @@ void Game::setControlHint(const std::string &h, bool left, bool right, bool midd Vector p = controlHint_mouseLeft->position + Vector(-100,0); os.seekp(0); - os << "song/songslot-" << dsq->continuity.getSongSlotByType(songType); + os << "song/songslot-" << dsq->continuity.getSongSlotByType(songType) << '\0'; Quad *q = new Quad(os.str(), p); q->followCamera = 1; q->scale = Vector(0.7, 0.7); @@ -7827,7 +7827,7 @@ void Game::setControlHint(const std::string &h, bool left, bool right, bool midd int note = song->notes[i]; os.seekp(0); - os << "song/notebutton-" << note; + os << "song/notebutton-" << note << '\0'; Quad *q = new Quad(os.str(), p); q->color = dsq->getNoteColor(note)*0.5f + Vector(1, 1, 1)*0.5f; q->followCamera = 1; diff --git a/Aquaria/Main.cpp b/Aquaria/Main.cpp index e17dd9b..29fb0f3 100644 --- a/Aquaria/Main.cpp +++ b/Aquaria/Main.cpp @@ -18,54 +18,119 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +//#define SANITY_TEST -#include "DSQ.h" +#ifdef SANITY_TEST + #include "Core.h" + #include "Quad.h" + + class SanityTest : public Core + { + std::string dud; + public: + SanityTest() : Core(dud) + { + } + void init() + { + Core::init(); + + if (!createWindow(800,600,32,0, "Aquaria")) return; + debugLog("Init Input Library..."); + initInputLibrary(); + debugLog("OK"); + + debugLog("Init Sound Library..."); + initSoundLibrary(); + debugLog("OK"); + + debugLog("Init Graphics Library..."); + initGraphicsLibrary(0, 1); + core->enable2D(800); + //core->initFrameBuffer(); + debugLog("OK"); + + renderObjectLayers.resize(2); + + Quad *q = new Quad; + q->setTexture("gfx/Logo"); + q->position = Vector(400,300); + addRenderObject(q, 1); + + } + void onUpdate(float dt) + { + Core::onUpdate(dt); + if (core->getKeyState(KEY_ESCAPE)) + quit(); + } + }; + + int WINAPI WinMain( HINSTANCE hInstance, // Instance + HINSTANCE hPrevInstance, // Previous Instance + LPSTR lpCmdLine, // Command Line Parameters + int nCmdShow) // Window Show State + { + #ifdef _DEBUG + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + _CrtSetReportMode ( _CRT_ERROR, _CRTDBG_MODE_DEBUG); + #endif + + { + SanityTest core; + core.init(); + core.main(); + core.shutdown(); + + } + return (0); + } + +#else + + #include "DSQ.h" #ifdef BBGE_BUILD_WINDOWS #include #endif -static void MakeRan(void) -{ + + void enumerateTest() + { +#ifdef BBGE_BUILD_SDL + SDL_Rect **modes; + /* Get available fullscreen/hardware modes */ + modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); + #ifdef BBGE_BUILD_WINDOWS - std::ofstream out("ran"); - for (int i = 0; i < 32; i++) - out << rand()%1000; - out.close(); -#endif -} + /* Check is there are any modes available */ + if(modes == (SDL_Rect **)0){ + MessageBox(0, "No modes available!\n", "", MB_OK); + return; + } -static void StartAQConfig() -{ -#if defined(BBGE_BUILD_WINDOWS) -#if defined(AQUARIA_DEMO) || defined(AQUARIA_FULL) - if (!exists("ran", false)) - { - MakeRan(); - if(exists("aqconfig.exe", false)) - { - ShellExecute(NULL, "open", "aqconfig.exe", NULL, NULL, SW_SHOWNORMAL); - exit(0); - } - } + /* Check if or resolution is restricted */ + if(modes == (SDL_Rect **)-1){ + MessageBox(0, "All resolutions available.\n", "", MB_OK); + } + else{ + /* Print valid modes */ + printf("Available Modes\n"); + for(int i=0;modes[i];++i){ + std::ostringstream os; + os << "[" << modes[i]->w << "x" << modes[i]->h << "]"; + MessageBox(0, os.str().c_str(), "", MB_OK); + //printf(" %d x %d\n", modes[i]->w, modes[i]->h); + } + } #endif - remove("ran"); #endif -} - -static void CheckConfig(void) -{ -#ifdef BBGE_BUILD_WINDOWS - bool hasCfg = exists("usersettings.xml", false); - if(!hasCfg) - StartAQConfig(); -#endif -} + } -#if defined(BBGE_BUILD_WINDOWS) && !defined(BBGE_BUILD_SDL) +#if defined(BBGE_BUILD_WINDOWS) && defined(AQUARIA_WIN32_NOCONSOLE) int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters @@ -76,54 +141,12 @@ static void CheckConfig(void) _CrtSetReportMode ( _CRT_ERROR, _CRTDBG_MODE_DEBUG); #endif - DSQ core(GetCommandLine()); + std::string dsqParam = GetCommandLine(); #elif defined(BBGE_BUILD_SDL) - static inline void check_beta(void) - { - #if defined(BBGE_BUILD_UNIX) && defined(BETAEXPIRE) - bool bail = false; - - fprintf(stderr, "\n\n\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - - if ( time(NULL) > (BETAEXPIRE + 14 * 24 * 60 * 60) ) { - fprintf(stderr, - "Sorry, but this beta of the game has expired, and will no\n" - " longer run. This is to prevent tech support on out-of-date\n" - " and prerelease versions of the game. Please go to\n" - " http://www.bit-blot.com/ for information on getting a release\n" - " version that does not expire.\n"); - bail = true; - } else { - fprintf(stderr, " Warning: This is a beta version of AQUARIA.\n"); - } - - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "*********************************************************\n"); - fprintf(stderr, "\n\n\n"); - - fflush(stderr); - - if (bail) { - while (true) { - _exit(0); - } - } - #endif - } - extern "C" int main(int argc,char *argv[]) { - check_beta(); #ifdef BBGE_BUILD_WINDOWS #if defined(AQUARIA_DEMO) || defined(AQUARIA_FULL) @@ -143,15 +166,17 @@ static void CheckConfig(void) remove("ran"); #endif - std::string fileSystem = ""; + std::string dsqParam = ""; + #ifdef BBGE_BUILD_UNIX const char *envPath = getenv("AQUARIA_DATA_PATH"); if (envPath != NULL) - fileSystem = envPath; + dsqParam = envPath; #endif - DSQ core(fileSystem); -#endif +#endif + + DSQ core(dsqParam); { core.init(); //enumerateTest(); @@ -159,6 +184,14 @@ static void CheckConfig(void) core.shutdown(); } +#ifdef BBGE_BUILD_WINDOWS + std::ofstream out("ran"); + for (int i = 0; i < 1; i++) + out << rand()%1000; + out.close(); +#endif + return (0); } +#endif diff --git a/Aquaria/StatsAndAchievements.cpp b/Aquaria/StatsAndAchievements.cpp index 84a11f7..c0c72e1 100644 --- a/Aquaria/StatsAndAchievements.cpp +++ b/Aquaria/StatsAndAchievements.cpp @@ -23,10 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Avatar.h" #include "StatsAndAchievements.h" -#ifdef _MSC_VER -#define snprintf _snprintf -#endif - #ifndef ARRAYSIZE #define ARRAYSIZE(x) (sizeof (x) / sizeof ((x)[0])) #endif diff --git a/BBGE/BBGECompileConfig.h b/BBGE/BBGECompileConfig.h new file mode 100644 index 0000000..1f8048c --- /dev/null +++ b/BBGE/BBGECompileConfig.h @@ -0,0 +1,17 @@ +#ifndef __BBGE_COMPILE_CONFIG_H__ +#define __BBGE_COMPILE_CONFIG_H__ + +#ifndef BBGE_SKIP_CONFIG_HEADERS + +#define BBGE_BUILD_SDL 1 +#define BBGE_BUILD_FRAMEBUFFER 1 +#define BBGE_BUILD_SHADERS 1 +#define BBGE_BUILD_OPENGL 1 +#define BBGE_BUILD_OPENGL_DYNAMIC 1 +#define BBGE_BUILD_WIDESCREEN 1 +#define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1 +#define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1 + +#endif + +#endif diff --git a/BBGE/Base.h b/BBGE/Base.h index 5e334e3..e6a0516 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -25,6 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WIN32_LEAN_AND_MEAN #include + #ifdef _MSC_VER + #define strtof (float)strtod + #define snprintf _snprintf + #endif +#endif + +#include "BBGECompileConfig.h" + +#ifdef BBGE_BUILD_WINDOWS + //#include "iprof/prof.h" //#define BBGE_PROF(x) Prof(x) @@ -78,6 +88,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef BBGE_BUILD_SDL #include "SDL.h" + #undef main // SDL defines main to SDL_main. This is the only place where SDL.h is included, so this is ok. #endif diff --git a/BBGE/Vector.h b/BBGE/Vector.h index a36b832..1f4ca3a 100644 --- a/BBGE/Vector.h +++ b/BBGE/Vector.h @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma once #include +#include #include #include "Event.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index 9436f09..9eba0b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,16 +12,15 @@ IF(APPLE) SET(MACOSX TRUE) ENDIF(APPLE) -OPTION(AQUARIA_BETAEXPIRE "This build should expire in 30 days." FALSE) -IF(AQUARIA_BETAEXPIRE) - EXECUTE_PROCESS( - COMMAND date +%s - OUTPUT_VARIABLE BUILD_TIMESTAMP - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - ADD_DEFINITIONS(-DBETAEXPIRE=${BUILD_TIMESTAMP}) -ENDIF(AQUARIA_BETAEXPIRE) +# HACK: in case mingw is not correctly detected, fix this. +IF(${CMAKE_GENERATOR} MATCHES ".*[mM][iI][nN][gG][wW].*") # really ugly hack to match "mingw" case-insensitive + set(MINGW 1) + message(STATUS "!! Using MinGW hack !!") +ENDIF() + +IF(WIN32) + OPTION(AQUARIA_NO_CONSOLE "No console window?" FALSE) +ENDIF(WIN32) # No Steamworks SDK for Linux at the moment. Roll our own achievements. ADD_DEFINITIONS(-DBBGE_BUILD_ACHIEVEMENTS_INTERNAL=1) @@ -134,17 +133,15 @@ if (NOT SDL_FOUND) set(SDLDIR "${EXTLIBDIR}/SDL12") set(SDL_INCLUDE_DIR "${SDLDIR}/include") message(STATUS "Using internal copy of SDL") - set(SDL_LIBRARY "${SDLDIR}/lib/macosx/libSDL-1.2.0.dylib;${SDLDIR}/lib/macosx/libSDLmain.a") + set(SDL_LIBRARY "${SDLDIR}/lib/macosx/libSDL-1.2.0.dylib") elseif(WIN32) + set(SDLDIR "${EXTLIBDIR}/SDL12") + set(SDL_INCLUDE_DIR "${SDLDIR}/include" CACHE PATH "SDL include directory" FORCE) + message(STATUS "Using internal copy of SDL") if(MSVC) - set(SDLDIR "${EXTLIBDIR}/SDL12") - set(SDL_INCLUDE_DIR "${SDLDIR}/include" CACHE PATH "SDL include directory" FORCE) - message(STATUS "Using internal copy of SDL") - set(SDLMAIN_LIBRARY "${SDLDIR}/lib/win32/SDLmain.lib" CACHE INTERNAL "") - set(SDL_LIBRARY_TEMP "${SDLDIR}/lib/win32/SDL.lib" CACHE INTERNAL "") - set(SDL_LIBRARY ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL library can be found") + set(SDL_LIBRARY "${SDLDIR}/lib/win32/SDL.lib" CACHE PATH "Where the SDL library can be found") else(MSVC) - message(SEND_ERROR "We don't have a prebuilt SDL for this environment.") + set(SDL_LIBRARY "${SDLDIR}/lib/win32/libSDL.dll.a" CACHE PATH "Where the SDL library can be found") endif(MSVC) else(MACOSX) message(SEND_ERROR "We don't have a prebuilt SDL for this platform.") @@ -159,14 +156,10 @@ if(NOT AQUARIA_INTERNAL_OPENAL) endif(NOT AQUARIA_INTERNAL_OPENAL) if (NOT OPENAL_FOUND) if(WIN32) - if(MSVC) - set(OPENALDIR "${EXTLIBDIR}/AL") - set(OPENAL_INCLUDE_DIR "${OPENALDIR}/include" CACHE PATH "OpenAL include directory" FORCE) - message(STATUS "Using internal copy of OpenAL") - set(OPENAL_LIBRARY "${OPENALDIR}/lib/win32/OpenAL32.lib" CACHE FILEPATH "Where the OpenAL library can be found" FORCE) - else(MSVC) - message(SEND_ERROR "We don't have a prebuilt OpenAL for this environment.") - endif(MSVC) + set(OPENALDIR "${EXTLIBDIR}/AL") + set(OPENAL_INCLUDE_DIR "${OPENALDIR}/include" CACHE PATH "OpenAL include directory" FORCE) + message(STATUS "Using internal copy of OpenAL") + set(OPENAL_LIBRARY "${OPENALDIR}/lib/win32/OpenAL32.lib" CACHE FILEPATH "Where the OpenAL library can be found" FORCE) else(WIN32) message(SEND_ERROR "We don't have a prebuilt OpenAL for this platform.") endif(WIN32) @@ -185,8 +178,6 @@ INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) -# !!! FIXME: don't use fmod! -#INCLUDE_DIRECTORIES("${BBGEDIR}/fmodapi42604linux64/api/inc") # Custom build ID: e.g. "-custom", " (my very own build)" SET(AQUARIA_CUSTOM_BUILD_ID "" CACHE STRING @@ -196,9 +187,11 @@ if (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL "")) endif (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL "")) # Aquaria/BBGE specific defines... + ADD_DEFINITIONS(-DGL_GLEXT_LEGACY=1) ADD_DEFINITIONS(-DHAVE_PUTENV=1) ADD_DEFINITIONS(-DTIXML_USE_STL=1) +ADD_DEFINITIONS(-DBBGE_SKIP_CONFIG_HEADERS=1) # if this is not defined, it will use .h files to set the necessary defines ADD_DEFINITIONS(-DBBGE_BUILD_SDL=1) ADD_DEFINITIONS(-DBBGE_BUILD_FRAMEBUFFER=1) #ADD_DEFINITIONS(-DBBGE_BUILD_SHADERS=1) @@ -220,7 +213,10 @@ ENDIF(MACOSX) IF(WIN32) ADD_DEFINITIONS(-DBBGE_BUILD_WINDOWS=1) - SET(EXETYPE WIN32) + IF(AQUARIA_NO_CONSOLE) + SET(EXETYPE WIN32) + ADD_DEFINITIONS(-DAQUARIA_WIN32_NOCONSOLE=1) + ENDIF(AQUARIA_NO_CONSOLE) ENDIF(WIN32) @@ -422,6 +418,13 @@ SET(BBGE_SRCS_UNUSED ${BBGEDIR}/PointSprites.cpp ) +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR MINGW) +SET_SOURCE_FILES_PROPERTIES( + ${BBGEDIR}/FmodOpenALBridge.cpp + PROPERTIES COMPILE_FLAGS "-fpermissive" +) +ENDIF() + SET(FTGL_SRCS ${FTGLSRCDIR}/FTCharmap.cpp ${FTGLSRCDIR}/FTContour.cpp diff --git a/ExternalLibs/SDL12/include/SDL_config.h b/ExternalLibs/SDL12/include/SDL_config.h index b269243..db9ce8e 100644 --- a/ExternalLibs/SDL12/include/SDL_config.h +++ b/ExternalLibs/SDL12/include/SDL_config.h @@ -63,7 +63,7 @@ typedef size_t uintptr_t; /* Enable the dummy video driver (src/video/dummy/\*.c) */ #define SDL_VIDEO_DRIVER_DUMMY 1 -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(_WIN32) #define SDL_VIDEO_DRIVER_WINDIB 1 #endif