Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F118185
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
15 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d36a6c8..209f6bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,135 +1,154 @@
Project (meandmyshadow)
CMake_Minimum_Required (VERSION 2.6)
Set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#Option if the game should be compiled with hardware acceleration.
Option (HARDWARE_ACCELERATION "Use openGL as rendering backend" ON)
Option (DEBUG_MODE "Compile the game with debug mode enabled" OFF)
#Use openGL only when compiling with HARDWARE_ACCELERATION.
#Otherwise we try to find XLib.
if (HARDWARE_ACCELERATION)
Find_Package (OpenGL REQUIRED)
else (HARDWARE_ACCELERATION)
- INCLUDE (FindX11)
+ Include (FindX11)
endif (HARDWARE_ACCELERATION)
#Find the required libraries.
Find_Package (SDL REQUIRED)
Find_Package (SDL_gfx REQUIRED)
Find_Package (SDL_image REQUIRED)
Find_Package (SDL_ttf REQUIRED)
Find_Package (SDL_mixer REQUIRED)
Find_Package (OpenSSL REQUIRED)
Find_Package (CURL REQUIRED)
Find_Package (LibArchive REQUIRED)
Find_Package (Lua51 REQUIRED)
if (HARDWARE_ACCELERATION AND NOT OPENGL_FOUND)
- message (FATAL_ERROR "OpenGL not found !")
+ message (FATAL_ERROR "OpenGL library could not be found!")
elseif (NOT HARDWARE_ACCELERATION AND NOT X11_FOUND)
- message (FATAL_ERROR "X11 not found !")
+ message (FATAL_ERROR "X11 library could not be found!")
endif (HARDWARE_ACCELERATION AND NOT OPENGL_FOUND)
if (NOT SDL_FOUND)
- message (FATAL_ERROR "SDL not found !")
+ message (FATAL_ERROR "SDL library could not be found!")
endif (NOT SDL_FOUND)
if (NOT SDLGFX_FOUND)
- message (FATAL_ERROR "SDL_gfx not found !")
+ message (FATAL_ERROR "SDL_gfx library could not be found!")
endif (NOT SDLGFX_FOUND)
if (NOT SDLIMAGE_FOUND)
- message (FATAL_ERROR "SDL_gfx not found !")
+ message (FATAL_ERROR "SDL_gfx library could not be found!")
endif (NOT SDLIMAGE_FOUND)
if (NOT SDLTTF_FOUND)
- message (FATAL_ERROR "SDL_ttf not found !")
+ message (FATAL_ERROR "SDL_ttf library could not be found!")
endif (NOT SDLTTF_FOUND)
if (NOT SDLMIXER_FOUND)
- message (FATAL_ERROR "SDL_mixer not found !")
+ message (FATAL_ERROR "SDL_mixer library could not be found!")
endif (NOT SDLMIXER_FOUND)
if (NOT OPENSSL_FOUND)
- message (FATAL_ERROR "OpenSSL not found !")
+ message (FATAL_ERROR "OpenSSL library could not be found!")
endif (NOT OPENSSL_FOUND)
if (NOT CURL_FOUND)
- message(FATAL_ERROR "CURL not found !")
+ message(FATAL_ERROR "CURL library could not be found!")
endif (NOT CURL_FOUND)
if (NOT LibArchive_FOUND)
- message (FATAL_ERROR "LIBARCHIVE not found !")
+ message (FATAL_ERROR "LibArchive library could not be found!")
endif (NOT LibArchive_FOUND)
if (NOT LUA51_FOUND)
- message (FATAL_ERROR "Lua not found !")
+ message (FATAL_ERROR "Lua library could not be found!")
endif (NOT LUA51_FOUND)
+#Although Lua is found it could be the wrong version.
+#Try to find the header file and extract the Lua version, if we don't find the header file carry on.
+if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
+ #Open the file and extract the version define lines.
+ file (STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_VERSION_M(AJ|IN)OR[ \t]")
+ #Extract only the numbers from the files.
+ string (REGEX MATCHALL "[0-9]" LUA_VERSION_STRING "${lua_version_str}")
+ string (COMPARE EQUAL "${LUA_VERSION_STRING}" "5;2" LUA_VERSION_MATCH)
+
+ if (NOT LUA_VERSION_MATCH)
+ message (FATAL_ERROR "Incorrect Lua version ${LUA_VERSION_STRING}, expected 5.2!")
+ endif (NOT LUA_VERSION_MATCH)
+
+ #Finally unset the unneeded variables.
+ unset (lua_version_str)
+ unset (LUA_VERSION_STRING)
+ unset (LUA_VERSION_MATCH)
+endif()
+
#Parse the configure file.
Configure_File (
"${PROJECT_SOURCE_DIR}/src/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
#Add the include directories of the (found) libraries.
Include_Directories(
${PROJECT_BINARY_DIR}
${X11_X11_INCLUDE_PATH}
${OPENGL_gl_INCLUDE_DIR}
${SDL_INCLUDE_DIR}
${SDLGFX_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${SDLMIXER_INCLUDE_DIR}
${OPENSSL_CRYPTO_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${LibArchive_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
)
#Set the output path and the source path.
Set (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
Set (SRC_DIR ${PROJECT_SOURCE_DIR}/src)
#List the source files.
File (GLOB SOURCES ${SRC_DIR}/*.cpp)
File (GLOB TINYGETTEXT ${SRC_DIR}/libs/tinygettext/*.cpp)
-File (GLOB FINDLOCALE ${SRC_DIR}/libs/findlocale/*.c)
+File (GLOB FINDLOCALE ${SRC_DIR}/libs/findlocale/*.cpp)
Add_Executable (meandmyshadow ${SOURCES} ${TINYGETTEXT} ${FINDLOCALE})
Target_Link_Libraries (
meandmyshadow
${OPENGL_gl_LIBRARY}
${X11_X11_LIB}
${SDL_LIBRARY}
${SDLGFX_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY}
${SDLMIXER_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${CURL_LIBRARY}
${LibArchive_LIBRARY}
${LUA_LIBRARIES}
)
#Path options
Set (BINDIR "bin" CACHE STRING "Where to install binaries")
Set (DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "Sets the root of data directories to a non-default location")
Set (ICONDIR "${DATAROOTDIR}/icons" CACHE STRING "Sets the icon directory for desktop entry to a non-default location.")
Set (DESKTOPDIR "${DATAROOTDIR}/applications" CACHE STRING "Sets the desktop file directory for desktop entry to a non-default location.")
#Install locations
Install (DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${DATAROOTDIR}/meandmyshadow/)
Install (FILES AUTHORS DESTINATION ${DATAROOTDIR}/meandmyshadow/)
Install (TARGETS meandmyshadow RUNTIME DESTINATION ${BINDIR})
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
Install (FILES meandmyshadow.desktop DESTINATION ${DESKTOPDIR})
Install (FILES icons/16x16/meandmyshadow.png DESTINATION ${ICONDIR}/hicolor/16x16/apps/)
Install (FILES icons/32x32/meandmyshadow.png DESTINATION ${ICONDIR}/hicolor/32x32/apps/)
Install (FILES icons/48x48/meandmyshadow.png DESTINATION ${ICONDIR}/hicolor/48x48/apps/)
Install (FILES icons/64x64/meandmyshadow.png DESTINATION ${ICONDIR}/hicolor/64x64/apps/)
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
diff --git a/src/Game.h b/src/Game.h
index 0e7d55d..88168e6 100644
--- a/src/Game.h
+++ b/src/Game.h
@@ -1,288 +1,283 @@
/*
* Copyright (C) 2011-2013 Me and My Shadow
*
* This file is part of Me and My Shadow.
*
* Me and My Shadow is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Me and My Shadow is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Me and My Shadow. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAME_H
#define GAME_H
#include <SDL/SDL.h>
#ifdef __APPLE__
#include <SDL_mixer/SDL_mixer.h>
#include <SDL_ttf/SDL_ttf.h>
#else
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_ttf.h>
#endif
#include <vector>
#include <map>
#include <string>
#include "GameState.h"
#include "GUIObject.h"
#include "GameObjects.h"
#include "Scenery.h"
#include "Player.h"
#include "Shadow.h"
//This structure contains variables that make a GameObjectEvent.
struct typeGameObjectEvent{
//The type of event.
int eventType;
//The type of object that should react to the event.
int objectType;
//Flags, 0x1 means use the id.
int flags;
//Blocks with this id should react to the event.
std::string id;
//Optional pointer to the block the event should be called on.
GameObject* target;
};
class ThemeManager;
class ThemeBackground;
class TreeStorageNode;
//The different level events.
enum LevelEventType{
//Event called when the level is created, this happens after all the blocks are created and their onCreate is called.
LevelEvent_OnCreate=1,
//Event called when the game is saved.
LevelEvent_OnSave,
//Event called when the game is loaded.
LevelEvent_OnLoad,
//Event called when the game is reset.
LevelEvent_OnReset,
};
class Game : public GameState,public GUIEventCallback{
private:
//Boolean if the game should reset.
bool isReset;
//contains currently played level.
TreeStorageNode* currentLevelNode;
protected:
//Array containing "tooltips" for certain block types.
//It will be shown in the topleft corner of the screen.
SDL_Surface* bmTips[TYPE_MAX];
//SDL_Surface containing the action images (record, play, etc..)
SDL_Surface* action;
//SDL_Surface containing the medal image.
SDL_Surface* medals;
//ThemeBlockInstance containing the collectable image.
ThemeBlockInstance collectable;
//The name of the current level.
std::string levelName;
//The path + file of the current level.
std::string levelFile;
//Editor data containing information like name, size, etc...
std::map<std::string,std::string> editorData;
//Vector used to queue the gameObjectEvents.
std::vector<typeGameObjectEvent> eventQueue;
//The themeManager.
ThemeManager* customTheme;
//The themeBackground.
ThemeBackground* background;
//Load a level from node.
//After calling this function the ownership of
//node will transfer to Game class. So don't delete
//the node after calling this function!
virtual void loadLevelFromNode(TreeStorageNode* obj, const std::string& fileName);
public:
//Array used to convert GameObject type->string.
static const char* blockName[TYPE_MAX];
//Map used to convert GameObject string->type.
static std::map<std::string,int> blockNameMap;
//Map used to convert GameObjectEventType type->string.
static std::map<int,std::string> gameObjectEventTypeMap;
//Map used to convert GameObjectEventType string->type.
static std::map<std::string,int> gameObjectEventNameMap;
//Map used to convert LevelEventType type->string.
static std::map<int,std::string> levelEventTypeMap;
//Map used to convert LevelEventType string->type.
static std::map<std::string,int> levelEventNameMap;
//Boolean that is set to true when a game is won.
bool won;
//Boolean that is set to true when we should save game on next logic update.
bool saveStateNextTime;
//Boolean that is set to true when we should load game on next logic update.
bool loadStateNextTime;
//Boolean if the replaying currently done is for the interlevel screen.
bool interlevel;
//X position of second medal in interlevel popup
int medalX;
//Integer containing the current tip index.
int gameTipIndex;
//Integer containing the number of ticks passed since the start of the level.
int time;
//Integer containing the stored value of time.
int timeSaved;
//Integer containing the number of recordings it took to finish.
int recordings;
//Integer containing the stored value of recordings.
int recordingsSaved;
//Integer keeping track of currently obtained collectables
int currentCollectables;
//Integer keeping track of total colletables in the level
int totalCollectables;
//Integer containing the stored value of current collectables
int currentCollectablesSaved;
//Time of recent swap, for achievements. (in game-ticks)
int recentSwap,recentSwapSaved;
//Store time of recent save/load for achievements (in millisecond)
Uint32 recentLoad,recentSave;
//Enumeration with the different camera modes.
enum CameraMode{
CAMERA_PLAYER,
CAMERA_SHADOW,
CAMERA_CUSTOM
};
//The current camera mode.
CameraMode cameraMode;
//Rectangle containing the target for the camera.
SDL_Rect cameraTarget;
//The saved cameraMode.
CameraMode cameraModeSaved;
SDL_Rect cameraTargetSaved;
//Level scripts.
std::map<int,std::string> scripts;
//Vector containing all the levelObjects in the current game.
std::vector<Block*> levelObjects;
//The background layers for the scenery.
std::map<std::string,std::vector<Scenery*> > backgroundLayers;
//The player...
Player player;
//... and his shadow.
Shadow shadow;
//warning: weak reference only, may point to invalid location
Block* objLastCheckPoint;
//Constructor.
Game();
//If this is not empty then when next Game class is created
//it will play this record file.
static std::string recordFile;
//Destructor.
//It will call destroy();
~Game();
//Method used to clean up the GameState.
void destroy();
//Inherited from GameState.
void handleEvents();
void logic();
void render();
void resize();
//This method will load a level.
//fileName: The fileName of the level.
virtual void loadLevel(std::string fileName);
//Method used to broadcast a GameObjectEvent.
//eventType: The type of event.
//objectType: The type of object that should react to the event.
//id: The id of the blocks that should react.
//target: Pointer to the object
void broadcastObjectEvent(int eventType,int objectType=-1,const char* id=NULL,GameObject* target=NULL);
//Method that will check if a script for a given levelEvent is present.
//If that's the case the script will be executed.
//eventType: The level event type to execute.
void inline executeScript(int eventType);
- //FIXME: We get a link error here :/
-#if defined(ANDROID)
+
//Returns if the player and shadow can save the current state.
bool canSaveState();
-#else
- //Returns if the player and shadow can save the current state.
- bool inline canSaveState();
-#endif
//Method used to store the current state.
//This is used for checkpoints.
//Returns: True if it succeeds without problems.
bool saveState();
//Method used to load the stored state.
//This is used for checkpoints.
//Returns: True if it succeeds without problems.
bool loadState();
//Method that will reset the GameState to it's initial state.
//save: Boolean if the saved state should also be delted.
void reset(bool save);
//Save current game record to the file.
//fileName: The filename of the destination file.
void saveRecord(const char* fileName);
//Load game record (and its level) from file and play it.
//fileName: The filename of the recording file.
void loadRecord(const char* fileName);
//Method called by the player (or shadow) when he finished.
void replayPlay();
//Method that gets called when the recording has ended.
void recordingEnded();
//get current level's auto-save record path,
//using current level's MD5, file name and other information.
void getCurrentLevelAutoSaveRecordPath(std::string &bestTimeFilePath,std::string &bestRecordingFilePath,bool createPath);
//Method that will prepare the gamestate for the next level and start it.
//If it's the last level it will show the congratulations text and return to the level select screen.
void gotoNextLevel();
//Get the name of the current level.
const std::string& getLevelName(){
return levelName;
}
//GUI event handling is done here.
void GUIEventCallback_OnEvent(std::string name,GUIObject* obj,int eventType);
};
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, May 15, 9:41 PM (2 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
63979
Default Alt Text
(15 KB)
Attached To
Mode
R79 meandmyshadow
Attached
Detach File
Event Timeline