Commit 5b8ff03c authored by Gerhard Stein's avatar Gerhard Stein

Until GameLaunche it seems to be working. Some fixes need to be done and a lot of

integration is still ahead.
parent b046909f
......@@ -115,9 +115,7 @@ int main(int argc, char *argv[])
////////////////////////////////
// Set GameLauncher as Engine //
////////////////////////////////
//gApp.setEngine(new CGameLauncher(false));
// TODO: Still need to check this dependency
assert(0);
gApp.setEngine(new CGameLauncher(false));
//////////////////////////////
// Run the Commander Genius //
......
......@@ -246,18 +246,14 @@ include_directories (${CommanderGenius_SOURCE_DIR}/src/engine/dbfusion/include)
add_subdirectory(engine)
add_subdirectory(sdl)
add_subdirectory(fileio)
#add_subdirectory(core)
#add_subdirectory(dialog)
#add_subdirectory(engine)
#add_subdirectory(graphics)
#add_subdirectory(hardware)
add_subdirectory(dialog)
add_subdirectory(graphics)
# Get all the o-files from the different targets and link'em
get_property(cg_obj_libs GLOBAL PROPERTY CG_OBJ_LIBS)
# Add executable Commander Genius
add_executable (CGeniusExe CGenius.cpp ${cg_obj_libs})
add_executable (CGeniusExe CGenius.cpp fileio.cpp misc.cpp ${cg_obj_libs})
# Link GsKit
......
include_directories(${SDL_INCLUDE_DIR})
FILE(GLOB SRCS *.cpp *.h)
add_library(dialog OBJECT ${SRCS})
set_property(GLOBAL APPEND PROPERTY CG_OBJ_LIBS $<TARGET_OBJECTS:dialog>)
......@@ -12,9 +12,8 @@
#include <vector>
#include <string>
#include <memory>
#include "core/LogicDrawSplitter.h"
class CTextViewer : public GameState
class CTextViewer
{
public:
CTextViewer(int x, int y, int w, int h);
......
......@@ -543,7 +543,7 @@ void CGameLauncher::ponderPatchDialog()
if( episode > 0 ) // The game has to have a valid episode!
{
// Get the EXE-Data of the game and load it into the memory.
if(!gpKeenFiles->exeFile.readData(episode, DataDirectory))
if(!gKeenFiles.exeFile.readData(episode, DataDirectory))
{
letchooseagain();
}
......
......@@ -4,6 +4,7 @@ include_directories(${SDL_INCLUDE_DIR})
add_subdirectory(core)
add_subdirectory(keen)
add_library(engine OBJECT CGameLauncher.cpp CGameLauncher.h)
add_library(engine OBJECT CGameLauncher.cpp CGameLauncher.h
playgame/CPlayGame.cpp playgame/CPlayGame.h)
set_property(GLOBAL APPEND PROPERTY CG_OBJ_LIBS $<TARGET_OBJECTS:engine>)
......@@ -9,11 +9,12 @@
#include "ActionFormat.h"
#include "common/CBehaviorEngine.h"
#include "engine/core/CBehaviorEngine.h"
#include "fileio/KeenFiles.h"
void ActionFormatType::setActionFormat( const size_t sprite_offset )
{
byte *ptr = g_pBehaviorEngine->m_ExeFile.getDSegPtr();
byte *ptr = gKeenFiles.exeFile.getDSegPtr();
ptr += sprite_offset;
memcpy( this, ptr, 15*sizeof(int16_t) );
......@@ -34,7 +35,7 @@ void ActionFormatType::setNextActionFormat()
bool ActionFormatType::getActionFormat( const size_t sprite_offset )
{
byte *ptr = g_pBehaviorEngine->m_ExeFile.getDSegPtr();
byte *ptr = gKeenFiles.exeFile.getDSegPtr();
ptr += sprite_offset;
return (memcmp( this, ptr, 15*sizeof(int16_t) ) == 0);
}
......@@ -14,7 +14,7 @@
* belong to this class
*/
#include "common/CBehaviorEngine.h"
#include "CBehaviorEngine.h"
#include <base/GsLogging.h>
void CBehaviorEngine::setMessage(const std::string &name, const std::string &message)
......@@ -75,9 +75,6 @@ bool CBehaviorEngine::readTeleporterTable(byte *p_exedata)
std::vector<CTileProperties> &CBehaviorEngine::getTileProperties(size_t tmnum)
{ return m_TileProperties[tmnum]; }
CPhysicsSettings &CBehaviorEngine::getPhysicsSettings()
{ return m_PhysicsSettings; }
// returns a pointer to the string with name 'name'
std::string CBehaviorEngine::getString(const std::string& name)
{
......
......@@ -13,7 +13,7 @@
#include <base/GsLogging.h>
#include <base/video/CVideoDriver.h>
#include <base/CInput.h>
#include "engine/spritedefines.h"
#include "engine/core/spritedefines.h"
int CCamera::mCamlead = 0;
bool CCamera::mCamLeadChange = false;
......@@ -66,7 +66,7 @@ void CCamera::attachObject(CSpriteObject *p_attacher)
mp_AttachedObject = p_attacher;
}
void CCamera::setPosition(const VectorD2<int>& newpos)
void CCamera::setPosition(const Vector2D<int>& newpos)
{
int cam_x = newpos.x-((gVideoDriver.getGameResolution().w/2)<<STC);
......
......@@ -29,11 +29,6 @@ class CSpriteObject;
struct EventRestartLevel : CEvent {};
/*struct EventSendBitmapDialogMsg : EventSendDialog
{
const GsBitmap &BitmapRef;
......@@ -74,52 +69,6 @@ struct TextEventMatchOption
std::shared_ptr<CEvent> event;
};
/**
* \description This event triggers a MessageBox where you can select multiple items
*
* \param Message This Text will be shown when the Box is triggered
* \param OptionStrings The Text to the option which can be selected
* Depending on the size of the
*/
struct EventSendSelectionDialogMsg : CEvent {
const std::string Message;
std::list<TextEventMatchOption> Options;
EventSendSelectionDialogMsg(const std::string& lMsg) :
Message(lMsg){}
void addOption(const std::string& ltext, CEvent *levent)
{
TextEventMatchOption NewOption;
NewOption.text = ltext;
NewOption.event.reset( levent );
Options.push_back(NewOption);
}
};
/**
* \description This event will erase all the enemies, etc, except the player
*/
struct EventEraseAllEnemies : CEvent {};
/**
* \description This event will erase all the enemies, etc, except the player
*/
struct EventEraseAllMeeps : CEvent {};
struct EventSpawnFoot : CEvent {
const int x,y;
const int foeID;
EventSpawnFoot( const int lx, const int ly, const int lfoe ) :
x(lx), y(ly), foeID(lfoe) {}
};
......
......@@ -6,8 +6,8 @@
*/
#include "CHUD.h"
#include "engine/CCamera.h"
#include "common/CBehaviorEngine.h"
#include "engine/core/CCamera.h"
#include "engine/core/CBehaviorEngine.h"
#include <base/video/CVideoDriver.h>
#include "sdl/extensions.h"
#include "graphics/GsGraphics.h"
......
include_directories(${SDL_INCLUDE_DIR})
add_library(engine_core OBJECT CSettings.cpp CSettings.h
CResourceLoader.cpp CResourceLoader.h
GameEngine.cpp GameEngine.h)
FILE(GLOB_RECURSE srcs *.cpp *.h)
add_library(engine_core OBJECT ${srcs})
set_property(GLOBAL APPEND PROPERTY CG_OBJ_LIBS $<TARGET_OBJECTS:engine_core>)
......@@ -6,7 +6,7 @@
*/
#include "CMap.h"
#include "common/CBehaviorEngine.h"
#include "engine/core/CBehaviorEngine.h"
#include <base/utils/FindFile.h>
#include <base/GsLogging.h>
#include <base/video/CVideoDriver.h>
......
......@@ -12,7 +12,7 @@
#include "CMessages.h"
//#include "StringUtils.h"
#include <base/GsLogging.h>
#include "common/CBehaviorEngine.h"
#include "engine/core/CBehaviorEngine.h"
CMessages::CMessages(unsigned char *p_exebuf, char episode, int version) :
mp_exe(p_exebuf),
......
......@@ -9,7 +9,7 @@
*/
#include "CSpriteObject.h"
#include "engine/spritedefines.h"
#include "engine/core/spritedefines.h"
#include <base/GsTimer.h>
/*
......@@ -752,7 +752,7 @@ void CSpriteObject::processMoveBitDown()
}
void CSpriteObject::processMove(const VectorD2<int>& dir)
void CSpriteObject::processMove(const Vector2D<int>& dir)
{
processMove(dir.x, dir.y);
}
......
......@@ -7,17 +7,19 @@
*/
#include "CPassive.h"
#include "common/CBehaviorEngine.h"
#include "engine/core/CBehaviorEngine.h"
#include <base/video/CVideoDriver.h>
#include <widgets/GsMenuController.h>
#include "fileio/KeenFiles.h"
CPassive::CPassive()
{
CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
CExeFile &ExeFile = gKeenFiles.exeFile;
m_modeg = false;
m_mode = INTRO;
m_Episode = ExeFile.getEpisode();
m_DataDirectory = ExeFile.getDataDirectory();
m_DataDirectory = gKeenFiles.gameDir;
}
......
......@@ -14,9 +14,9 @@
#ifndef CPASSIVE_H_
#define CPASSIVE_H_
#include "common/CMap.h"
#include "common/CSpriteObject.h"
#include "core/mode/CGameMode.h"
#include "engine/core/CMap.h"
#include "engine/core/CSpriteObject.h"
#include "engine/core/mode/CGameMode.h"
#include "fileio/CSaveGameController.h"
#include <string>
#include <vector>
......
......@@ -60,11 +60,11 @@ void CPlanes::setOffsets(unsigned long p1, unsigned long p2, unsigned long p3,
* This functions read one plane of graphics to a designated pointer which is derived by
* a SDL-Surface normally
*/
void CPlanes::readPlane(size_t p, Uint8 *pixels, Uint16 width, Uint16 height)
void CPlanes::readPlane(uint32_t p, uint8_t *pixels, uint16_t width, uint16_t height)
{
for(Uint16 y=0 ; y<height ; y++)
for(uint16_t y=0 ; y<height ; y++)
{
for(Uint16 x=0 ; x<width ; x++)
for(uint16_t x=0 ; x<width ; x++)
{
pixels[y*width + x] |= (getbit(p) << p);
}
......@@ -76,15 +76,15 @@ void CPlanes::readPlane(size_t p, Uint8 *pixels, Uint16 width, Uint16 height)
* a SDL-Surface normally. This function is used for tilemaps, which need to be read
* differently from the gamedata of Keen
*/
void CPlanes::readPlaneofTiles(size_t p, Uint8 *pixels, Uint16 columns,
Uint16 tilesize, Uint16 numtiles)
void CPlanes::readPlaneofTiles(uint32_t p, uint8_t *pixels, uint16_t columns,
uint16_t tilesize, uint16_t numtiles)
{
Uint8 *u_offset;
for(size_t t=0;t<numtiles;t++)
uint8_t *u_offset;
for(uint32_t t=0;t<numtiles;t++)
{
for(size_t y=0;y<tilesize;y++)
for(uint32_t y=0;y<tilesize;y++)
{
for(size_t x=0;x<tilesize;x++)
for(uint32_t x=0;x<tilesize;x++)
{
u_offset = pixels +
tilesize*tilesize*columns*(t/columns) +
......
......@@ -17,9 +17,9 @@ public:
unsigned char getbit(unsigned char plane);
void setOffsets(unsigned long p1, unsigned long p2, unsigned long p3,
unsigned long p4, unsigned long p5 = 0);
void readPlane(size_t p, Uint8 *pixels, Uint16 width, Uint16 height);
void readPlaneofTiles(size_t p, Uint8 *pixels, Uint16 columns,
Uint16 tilesize, Uint16 numtiles);
void readPlane(uint32_t p, uint8_t *pixels, uint16_t width, uint16_t height);
void readPlaneofTiles(uint32_t p, uint8_t *pixels, uint16_t columns,
uint16_t tilesize, uint16_t numtiles);
private:
unsigned long getbit_bytepos[5];
......
......@@ -5,7 +5,7 @@
* Author: gerstrong
*/
#include "engine/spritedefines.h"
#include "engine/core/spritedefines.h"
#include "CSpriteObject.h"
#include <base/GsLogging.h>
#include <base/video/CVideoDriver.h>
......@@ -148,18 +148,18 @@ void CSpriteObject::performCliffStop(const int &speed)
// Used in some setup mode, like putting the player to
// the current map position
void CSpriteObject::moveToForce(const VectorD2<int> &dir)
void CSpriteObject::moveToForce(const Vector2D<int> &dir)
{
m_Pos = dir;
}
void CSpriteObject::moveToForce(const int new_x, const int new_y)
{
moveToForce(VectorD2<int>(new_x, new_y));
moveToForce(Vector2D<int>(new_x, new_y));
}
// For the vector functions
void CSpriteObject::moveDir(const VectorD2<int> &dir)
void CSpriteObject::moveDir(const Vector2D<int> &dir)
{
moveXDir(dir.x);
moveYDir(dir.y);
......@@ -177,9 +177,9 @@ void CSpriteObject::moveToVertical(const int& new_y)
moveYDir(pos_y);
}
void CSpriteObject::moveTo(const VectorD2<Uint32> &new_loc)
void CSpriteObject::moveTo(const Vector2D<Uint32> &new_loc)
{
VectorD2<int> amount = new_loc - m_Pos;
Vector2D<int> amount = new_loc - m_Pos;
moveXDir(amount.x);
moveYDir(amount.y);
......@@ -187,7 +187,7 @@ void CSpriteObject::moveTo(const VectorD2<Uint32> &new_loc)
void CSpriteObject::moveTo(const int new_x, const int new_y)
{
moveTo(VectorD2<Uint32>(new_x, new_y));
moveTo(Vector2D<Uint32>(new_x, new_y));
}
void CSpriteObject::moveXDir(const int amount, const bool force)
......
......@@ -28,6 +28,9 @@
// Enumerations are here
#include "objenums.h"
const int COLISION_RES = (1<<STC);
// The bouncing box used by the object which is used to determine the collisions
......@@ -320,4 +323,17 @@ protected:
int mSprVar; // Sprite variant, which is used by the Spritemap
};
/**
* \description This event will spawn a new object
*
* \param pObject Pointer to the allocated memory of the Object. Caution: This allocation
*/
struct EventSpawnObject : CEvent {
const CSpriteObject *pObject;
EventSpawnObject( const CSpriteObject* pObject ) :
pObject( pObject ) {}
};
#endif // __CSpriteObject_H_
......@@ -10,7 +10,8 @@
#ifndef CGAMEMODE_H_
#define CGAMEMODE_H_
//#include "engine/CEvent.h"
#include <base/GsEvent.h>
//#include "core/LogicDrawSplitter.h"
#include <string>
......
......@@ -7,7 +7,7 @@
#include "CGamePlayMode.h"
#include "graphics/effects/CColorMerge.h"
#include "sdl/music/CMusicPlayer.h"
#include "sdl/audio/music/CMusicPlayer.h"
#include <base/GsTimer.h>
#include <base/video/CVideoDriver.h>
#include <base/GsApp.h>
......
......@@ -24,7 +24,7 @@ void KeenEngine::switchToGamePlayMode()
if(numPlayers <= 0)
numPlayers = 1;
std::string DataDirectory = g_pBehaviorEngine->m_ExeFile.getDataDirectory();
std::string DataDirectory = gKeenFiles.gameDir;
gEventManager.add( new GMSwitchToPlayGameMode( episode, numPlayers, DataDirectory ) );
}
......@@ -34,7 +34,7 @@ void KeenEngine::start()
{
int version;
CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
CExeFile &ExeFile = gKeenFiles.exeFile;
version = ExeFile.getEXEVersion();
......@@ -47,7 +47,7 @@ void KeenEngine::start()
return;
}
gpKeenFiles->setupFilenames(mEp);
gKeenFiles.setupFilenames(mEp);
g_pBehaviorEngine->setEpisode(mEp);
......
......@@ -16,7 +16,7 @@
#include "graphics/effects/CPixelate.h"
#include "sdl/extensions.h"
#include "menu/MainMenu.h"
#include "sdl/music/CMusic.h"
#include "sdl/audio/music/CMusic.h"
namespace galaxy
......
......@@ -8,7 +8,7 @@
#ifndef CPASSIVE_GALAXY_H_
#define CPASSIVE_GALAXY_H_
#include "../../CPassive.h"
#include "engine/core/CPassive.h"
#include <string>
namespace galaxy
......
......@@ -16,20 +16,27 @@
#include "graphics/GsGraphics.h"
#include "common/dialog/CMessageBoxBitmapGalaxy.h"
#include "common/dialog/CMessageBoxSelection.h"
#include "sdl/sound/CSound.h"
#include "sdl/music/CMusic.h"
#include "sdl/audio/Audio.h"
#include "sdl/audio/music/CMusic.h"
#include "graphics/effects/CColorMerge.h"
#include "graphics/effects/CDimDark.h"
#include "ep4/ai/CInchWorm.h"
#include "common/ai/CPlayerLevel.h"
#include "common/ai/CPlayerWM.h"
#include <fileio/KeenFiles.h>
namespace galaxy
{
CPlayGameGalaxy::CPlayGameGalaxy(const int startlevel) :
CPlayGame(g_pBehaviorEngine->m_ExeFile, startlevel),
m_WorldMap(g_pBehaviorEngine->m_ExeFile, mInventoryVec, m_Cheatmode),
m_LevelPlay(g_pBehaviorEngine->m_ExeFile, mInventoryVec, m_Cheatmode),
CPlayGame(gKeenFiles.exeFile, startlevel),
m_WorldMap(gKeenFiles.exeFile, mInventoryVec, m_Cheatmode),
m_LevelPlay(gKeenFiles.exeFile, mInventoryVec, m_Cheatmode),
m_SavedGame(*gpSaveGameController)
{
const int numPlayers = g_pBehaviorEngine->mPlayers;
......@@ -248,6 +255,34 @@ bool CPlayGameGalaxy::init()
}
/**
* \description This event triggers a MessageBox where you can select multiple items
*
* \param Message This Text will be shown when the Box is triggered
* \param OptionStrings The Text to the option which can be selected
* Depending on the size of the
*/
struct EventSendSelectionDialogMsg : CEvent {
const std::string Message;
std::list<TextEventMatchOption> Options;
EventSendSelectionDialogMsg(const std::string& lMsg) :
Message(lMsg){}
void addOption(const std::string& ltext, CEvent *levent)
{
TextEventMatchOption NewOption;
NewOption.text = ltext;
NewOption.event.reset( levent );
Options.push_back(NewOption);
}
};
struct EventRestartLevel : CEvent {};
void CPlayGameGalaxy::looseManagement( const int playerID,
const bool playerGameOver,
......
......@@ -11,7 +11,7 @@
#include "engine/playgame/CPlayGame.h"
#include "common/CInventory.h"
#include "common/dialog/CMessageBoxGalaxy.h"
#include "common/CMap.h"
#include "engine/core/CMap.h"
#include "common/CWorldMap.h"
#include "CLevelPlay.h"
#include <memory>
......
......@@ -4,14 +4,14 @@
#include <base/utils/StringUtils.h>
#include <widgets/GsMenuController.h>
#include "CResourceLoader.h"
#include "engine/core/CResourceLoader.h"
#include "GalaxyEngine.h"
#include "engine/core/CBehaviorEngine.h"
#include "common/CGameLauncher.h"
#include "engine/CGameLauncher.h"
#include "fileio/CPatcher.h"
#include "fileio/CSaveGameController.h"
#include "engine/CMessages.h"
#include "sdl/sound/CSound.h"
#include "engine/core/CMessages.h"
#include "sdl/audio/Audio.h"
#include "CPassive.h"
#include "CPlayGameGalaxy.h"
......@@ -21,6 +21,7 @@
#include "menu/ControlSettings.h"
#include "res/CAudioGalaxy.h"
#include <base/video/CVideoDriver.h>
#include "fileio/KeenFiles.h"
namespace galaxy
{
......@@ -28,7 +29,7 @@ namespace galaxy
bool setupAudio()
{
const CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
const CExeFile &ExeFile = gKeenFiles.exeFile;
const unsigned int ep = ExeFile.getEpisode();
CAudioGalaxy *audio = new CAudioGalaxy(ExeFile, g_pSound->getAudioSpec());
......@@ -46,7 +47,8 @@ bool loadLevelMusic(const int level)
{
Uint16 track;
CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
CExeFile &ExeFile = gKeenFiles.exeFile;
const int Idx = ExeFile.getEpisode()-4;
byte* musictable_start = ExeFile.getRawData()+GalaxySongAssignments[Idx];
......@@ -97,7 +99,7 @@ bool GalaxyEngine::loadResources( const Uint8 flags )
int handle()
{
CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
CExeFile &ExeFile = gKeenFiles.exeFile;
int version = ExeFile.getEXEVersion();
unsigned char *p_exedata = ExeFile.getRawData();
const int Episode = ExeFile.getEpisode();
......
......@@ -3,6 +3,7 @@
#include "engine/keen/KeenEngine.h"
#include "res/CEGAGraphicsGalaxy.h"
#include <base/GsEvent.h>
/**
* The Galaxy engine derived from KeenEngine has the task to manage the whole Keen 4-6
......
......@@ -13,18 +13,6 @@
#include <boost/property_tree/ptree.hpp>
/**
* \description This event will spawn a new object
*
* \param pObject Pointer to the allocated memory of the Object. Caution: This allocation
*/
struct EventSpawnObject : CEvent {
const CSpriteObject *pObject;
EventSpawnObject( const CSpriteObject* pObject ) :
pObject( pObject ) {}
};
class CGalaxySpriteObject: public CSpriteObject
{
......
......@@ -9,6 +9,7 @@
#include "graphics/GsGraphics.h"
#include "engine/core/CBehaviorEngine.h"
#include <base/utils/StringUtils.h>
#include "fileio/KeenFiles.h"
CStatusScreenGalaxyEp4::CStatusScreenGalaxyEp4(const stItemGalaxy& Item) :
CStatusScreenGalaxy(Item)
......@@ -58,7 +59,7 @@ void CStatusScreenGalaxyEp4::GenerateStatus()
SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifeAt), 8), TempRect.x, TempRect.y+2, mpStatusSurface.get());