From 5bbd1b159f1ecce8dd38e262f913bd3a619c3ae7 Mon Sep 17 00:00:00 2001 From: Kay Gonschior Date: Fri, 9 Oct 2015 14:49:18 +0200 Subject: [PATCH 1/7] progress --- Blueprint-Values.txt | 2 +- kgEngine-2.0/TileMapGame/GameController.cpp | 2 -- kgEngine-2.0/kgEngine-2.0/GameState.cpp | 16 +++++++++++ kgEngine-2.0/kgEngine-2.0/GameState.h | 27 +++++++++++++++++++ kgEngine-2.0/kgEngine-2.0/GameStateManager.h | 14 ++++++++++ kgEngine-2.0/kgEngine-2.0/InputManager.cpp | 2 ++ kgEngine-2.0/kgEngine-2.0/InputManager.h | 4 ++- .../kgEngine-2.0/kgEngine-2.0.vcxproj | 3 +++ .../kgEngine-2.0/kgEngine-2.0.vcxproj.filters | 9 +++++++ temp_todo.txt | 8 ------ 10 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 kgEngine-2.0/kgEngine-2.0/GameState.cpp create mode 100644 kgEngine-2.0/kgEngine-2.0/GameState.h create mode 100644 kgEngine-2.0/kgEngine-2.0/GameStateManager.h delete mode 100644 temp_todo.txt diff --git a/Blueprint-Values.txt b/Blueprint-Values.txt index f63eec49..9e0ce9ff 100644 --- a/Blueprint-Values.txt +++ b/Blueprint-Values.txt @@ -8,7 +8,7 @@ doubleWithUnit :66.6px list of any single value: vector :["Hello","How are you?","fine"] -vector :[true, false, 0, 1] +vector :[true, false, 0, 1] vector :[100,200,400,800] vector :[50px,100px,200px] vector :[33.3,66.6,100.5] diff --git a/kgEngine-2.0/TileMapGame/GameController.cpp b/kgEngine-2.0/TileMapGame/GameController.cpp index c325a91d..74069b69 100644 --- a/kgEngine-2.0/TileMapGame/GameController.cpp +++ b/kgEngine-2.0/TileMapGame/GameController.cpp @@ -32,8 +32,6 @@ namespace kg void GameController::sfmlEvent( Engine& engine, World& world, SaveManager& saveManager, const sf::Event& sfEvent ) { - if( sfEvent.type == Event::Closed ) - shutDown(); return; } diff --git a/kgEngine-2.0/kgEngine-2.0/GameState.cpp b/kgEngine-2.0/kgEngine-2.0/GameState.cpp new file mode 100644 index 00000000..c3f46154 --- /dev/null +++ b/kgEngine-2.0/kgEngine-2.0/GameState.cpp @@ -0,0 +1,16 @@ +#include "GameState.h" +using namespace std; +using namespace sf; +using namespace thor; + +namespace kg +{ + + void GameState::initReferences( Engine& engine, World& world, SaveManager& saveManager ) + { + r_engine = &engine; + r_world = &world; + r_saveManager = &saveManager; + } + +} diff --git a/kgEngine-2.0/kgEngine-2.0/GameState.h b/kgEngine-2.0/kgEngine-2.0/GameState.h new file mode 100644 index 00000000..189738d6 --- /dev/null +++ b/kgEngine-2.0/kgEngine-2.0/GameState.h @@ -0,0 +1,27 @@ +#pragma once +#include "stdafx.h" +#include "Plugin.h" +#include "Engine.h" +#include "World.h" +#include "SaveManager.h" + +namespace kg +{ + class DLL_EXPORT GameState : public PluginRTTI, public sf::NonCopyable + { + protected: + Engine* r_engine; + World* r_world; + SaveManager* r_saveManager; + + public: + + void initReferences( Engine& engine, World& world, SaveManager& saveManager ); + + virtual void initGui( tgui::Gui& gui ) = 0; + virtual void initInputCallbacks( InputManager& inputManager ) = 0; + + virtual void removeGui( tgui::Gui& gui ) = 0; + virtual void removeInputCallbacks( InputManager& inputManager ) = 0; + }; +} diff --git a/kgEngine-2.0/kgEngine-2.0/GameStateManager.h b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h new file mode 100644 index 00000000..ab9b82ea --- /dev/null +++ b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h @@ -0,0 +1,14 @@ +#pragma once +#include "GameState.h" + +namespace kg +{ + class DLL_EXPORT GameStateManager + { + std::vector> m_gameStateStack; + + public: + + + }; +} \ No newline at end of file diff --git a/kgEngine-2.0/kgEngine-2.0/InputManager.cpp b/kgEngine-2.0/kgEngine-2.0/InputManager.cpp index 7564a157..28028e56 100644 --- a/kgEngine-2.0/kgEngine-2.0/InputManager.cpp +++ b/kgEngine-2.0/kgEngine-2.0/InputManager.cpp @@ -12,6 +12,8 @@ namespace kg void InputManager::removeAction( const int& actionId ) { + for( auto& el : m_connectionsByActionId[actionId] ) + el.disconnect(); m_actionMap.removeAction( actionId ); } diff --git a/kgEngine-2.0/kgEngine-2.0/InputManager.h b/kgEngine-2.0/kgEngine-2.0/InputManager.h index 35a42438..204985e5 100644 --- a/kgEngine-2.0/kgEngine-2.0/InputManager.h +++ b/kgEngine-2.0/kgEngine-2.0/InputManager.h @@ -8,6 +8,7 @@ namespace kg thor::ActionMap m_actionMap; thor::ActionMap::CallbackSystem m_callbackSystem; + std::map> m_connectionsByActionId;//saved for disconnecting later public: // Has to be initialized manually in GraphicsSystem. @@ -40,7 +41,8 @@ namespace kg template void kg::InputManager::connect( const int& actionId, const T& callback ) { - m_callbackSystem.connect( actionId, callback ); + auto connection = m_callbackSystem.connect( actionId, callback ); + m_connectionsByActionId[actionId].push_back( connection ); } } diff --git a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj index 1f982cf7..174fda83 100644 --- a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj +++ b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj @@ -90,6 +90,7 @@ + @@ -116,6 +117,8 @@ + + diff --git a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters index 53b59e7e..2527a463 100644 --- a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters +++ b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters @@ -77,6 +77,9 @@ Quelldateien + + Quelldateien + @@ -178,5 +181,11 @@ Headerdateien\Engine + + Headerdateien + + + Headerdateien + \ No newline at end of file diff --git a/temp_todo.txt b/temp_todo.txt deleted file mode 100644 index a799a283..00000000 --- a/temp_todo.txt +++ /dev/null @@ -1,8 +0,0 @@ -XXX System::CreateSaveInformation -XXX Entity::CreateSaveInformation -XXX System::LoadFromSaveInfotmation -XXX Entity::LoadFromSaveInformation -XXX --- GESTRICHEN --- Save/Load AdditionalComponentValues -XXX Finish SaveSystem -XXX integrate Saving to existing Systems/Components -replace int with Id where possible \ No newline at end of file From 43e7f55732af8a94b497d3004fab56ac3c6d7cf4 Mon Sep 17 00:00:00 2001 From: Kay Gonschior Date: Fri, 9 Oct 2015 18:04:46 +0200 Subject: [PATCH 2/7] progress --- kgEngine-2.0/kgEngine-2.0/Core.cpp | 9 +++- kgEngine-2.0/kgEngine-2.0/Core.h | 4 ++ kgEngine-2.0/kgEngine-2.0/GameState.h | 6 +++ .../kgEngine-2.0/GameStateManager.cpp | 46 +++++++++++++++++++ kgEngine-2.0/kgEngine-2.0/GameStateManager.h | 15 +++++- kgEngine-2.0/kgEngine-2.0/PluginManager.h | 8 ++-- kgEngine-2.0/kgEngine-2.0/id_internal.h | 3 ++ .../kgEngine-2.0/kgEngine-2.0.vcxproj | 1 + .../kgEngine-2.0/kgEngine-2.0.vcxproj.filters | 3 ++ 9 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp diff --git a/kgEngine-2.0/kgEngine-2.0/Core.cpp b/kgEngine-2.0/kgEngine-2.0/Core.cpp index 6cbe6fca..5c292b70 100644 --- a/kgEngine-2.0/kgEngine-2.0/Core.cpp +++ b/kgEngine-2.0/kgEngine-2.0/Core.cpp @@ -7,6 +7,11 @@ using namespace sys; namespace kg { + + Core::Core() + :m_gameStateManager( m_engine, m_world, m_saveManager ) + { } + void Core::init() { loadPackages(); @@ -17,6 +22,7 @@ namespace kg //init systems m_world.initSystemsByImportance( m_engine, m_world, m_saveManager ); + m_gameStateManager.init(); } bool Core::shouldTerminate() const @@ -43,9 +49,10 @@ namespace kg m_engine.inputManager.forwardSfmlEvent( event ); } - if( !m_engine.isPaused )//if engine is not paused, update entities + if( !m_engine.isPaused )//if game is not paused, update entities m_world.updateEntities( m_engine, m_world, frameTime ); m_world.updateAllSystemsByImportance( m_engine, m_world, m_saveManager, frameTime ); + m_gameStateManager.onUpdate(); m_engine.inputManager.triggerCallbacks( m_engine.renderWindow ); m_world.removeEntitiesOnRemoveList(); } diff --git a/kgEngine-2.0/kgEngine-2.0/Core.h b/kgEngine-2.0/kgEngine-2.0/Core.h index 10a092d8..c642ae83 100644 --- a/kgEngine-2.0/kgEngine-2.0/Core.h +++ b/kgEngine-2.0/kgEngine-2.0/Core.h @@ -3,6 +3,7 @@ #include "World.h" #include "Engine.h" #include "SaveManager.h" +#include "GameStateManager.h" namespace kg { @@ -15,12 +16,15 @@ namespace kg Engine m_engine; SaveManager m_saveManager; World m_world; + GameStateManager m_gameStateManager; sf::Clock m_frameTimeClock; void loadPackages(); public: + Core(); + void init(); void update(); diff --git a/kgEngine-2.0/kgEngine-2.0/GameState.h b/kgEngine-2.0/kgEngine-2.0/GameState.h index 189738d6..44041754 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameState.h +++ b/kgEngine-2.0/kgEngine-2.0/GameState.h @@ -7,6 +7,8 @@ namespace kg { + class GameStateManager; + class DLL_EXPORT GameState : public PluginRTTI, public sf::NonCopyable { protected: @@ -18,9 +20,13 @@ namespace kg void initReferences( Engine& engine, World& world, SaveManager& saveManager ); + virtual void onInit() = 0; virtual void initGui( tgui::Gui& gui ) = 0; virtual void initInputCallbacks( InputManager& inputManager ) = 0; + virtual void onUpdate( GameStateManager& gameStateManager ) = 0; + + virtual void onRemove() = 0; virtual void removeGui( tgui::Gui& gui ) = 0; virtual void removeInputCallbacks( InputManager& inputManager ) = 0; }; diff --git a/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp b/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp new file mode 100644 index 00000000..c7c33f03 --- /dev/null +++ b/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp @@ -0,0 +1,46 @@ +#include "GameStateManager.h" +using namespace std; +using namespace sf; +using namespace thor; + +namespace kg +{ + + GameStateManager::GameStateManager( Engine& engine, World& world, SaveManager& saveManager ) + : engine(engine), + world(world), + saveManager(saveManager) + { + + } + + void GameStateManager::init() + { + auto defaultGameState = engine.pluginManager.createPlugin( 0 ); + + push( defaultGameState ); + } + + void GameStateManager::push( std::shared_ptr& gameState ) + { + gameState->initReferences( engine, world, saveManager ); + m_gameStateStack.push_back( gameState ); + } + + void GameStateManager::pop() + { + m_gameStateStack.pop_back(); + } + + const std::shared_ptr& GameStateManager::top() const + { + return m_gameStateStack.back(); + } + + void GameStateManager::onUpdate() + { + for( auto& el : m_gameStateStack ) + el->onUpdate(*this); + } + +} diff --git a/kgEngine-2.0/kgEngine-2.0/GameStateManager.h b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h index ab9b82ea..03849d99 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameStateManager.h +++ b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h @@ -5,10 +5,23 @@ namespace kg { class DLL_EXPORT GameStateManager { + Engine& engine; + World& world; + SaveManager& saveManager; + std::vector> m_gameStateStack; public: + GameStateManager( Engine& engine, World& world, SaveManager& saveManager ); + + void init(); + + void push( std::shared_ptr& gameState ); + + void pop(); + const std::shared_ptr& top()const; + void onUpdate(); }; -} \ No newline at end of file +} diff --git a/kgEngine-2.0/kgEngine-2.0/PluginManager.h b/kgEngine-2.0/kgEngine-2.0/PluginManager.h index 01dc0339..b887e790 100644 --- a/kgEngine-2.0/kgEngine-2.0/PluginManager.h +++ b/kgEngine-2.0/kgEngine-2.0/PluginManager.h @@ -92,7 +92,7 @@ namespace kg size_t genericPluginType = typeid(genericPluginType).hash_code(); try { - auto& plugin = m_pluginsByGenericTypeHash.at( genericPluginType ).first.at( id ); + auto plugin = static_pointer_cast< PluginFactoryInterface >(m_pluginsByGenericTypeHash.at( genericPluginType ).first.at( id )); if( plugin == nullptr ) throw PluginRequestException( id ); @@ -144,11 +144,11 @@ namespace kg size_t genericPluginType = typeid(genericPluginType).hash_code(); try { - auto& plugin = m_pluginsByGenericTypeHash.at( genericPluginType ).second.at( name ); + auto plugin = static_pointer_cast< PluginFactoryInterface >(m_pluginsByGenericTypeHash.at( genericPluginType ).second.at( name )); if( plugin == nullptr ) throw PluginRequestException( name ); - return plugin->create(); + return std::static_pointer_cast< BasePluginType >(plugin->create()); } catch( const std::exception& ) { @@ -200,7 +200,7 @@ namespace kg auto type_hash = typeid(BasePluginType).hash_code(); for( const auto& el : m_pluginsByGenericTypeHash[type_hash].first ) - retVal.push_back( static_pointer_cast>(el.second) ); + retVal.push_back( static_pointer_cast< PluginFactoryInterface >(el.second) ); return retVal; }; diff --git a/kgEngine-2.0/kgEngine-2.0/id_internal.h b/kgEngine-2.0/kgEngine-2.0/id_internal.h index c3f441a0..725898e0 100644 --- a/kgEngine-2.0/kgEngine-2.0/id_internal.h +++ b/kgEngine-2.0/kgEngine-2.0/id_internal.h @@ -10,5 +10,8 @@ namespace kg //UpdateImportance const double SAVE_UPDATE_IMPORTANCE = -1; + + //Default GameState + const int DEFAULT_GAMESTATE_ID = 0; } } \ No newline at end of file diff --git a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj index 174fda83..db9425ce 100644 --- a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj +++ b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj @@ -91,6 +91,7 @@ + diff --git a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters index 2527a463..eec2cb2f 100644 --- a/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters +++ b/kgEngine-2.0/kgEngine-2.0/kgEngine-2.0.vcxproj.filters @@ -80,6 +80,9 @@ Quelldateien + + Quelldateien + From 795dfc53134ca8fc067a86506380107e03ce0694 Mon Sep 17 00:00:00 2001 From: Kay Gonschior Date: Sat, 10 Oct 2015 14:54:13 +0200 Subject: [PATCH 3/7] finished GameState system --- kgEngine-2.0/TileMapGame/ChunkSystem.cpp | 6 + kgEngine-2.0/TileMapGame/ChunkSystem.h | 1 + kgEngine-2.0/TileMapGame/DefaultGameState.cpp | 72 +++++ kgEngine-2.0/TileMapGame/DefaultGameState.h | 39 +++ kgEngine-2.0/TileMapGame/GameController.cpp | 1 - .../TileMapGame/SingleplayerGameState.cpp | 257 ++++++++++++++++++ .../TileMapGame/SingleplayerGameState.h | 67 +++++ kgEngine-2.0/TileMapGame/TileMapGame.vcxproj | 4 + .../TileMapGame/TileMapGame.vcxproj.filters | 15 + kgEngine-2.0/TileMapGame/connect.cpp | 12 +- kgEngine-2.0/TileMapGame/id.h | 20 +- kgEngine-2.0/kgEngine-2.0/Core.cpp | 1 + kgEngine-2.0/kgEngine-2.0/GameState.cpp | 6 +- kgEngine-2.0/kgEngine-2.0/GameState.h | 14 +- .../kgEngine-2.0/GameStateManager.cpp | 32 ++- kgEngine-2.0/kgEngine-2.0/GameStateManager.h | 4 +- kgEngine-2.0/kgEngine-2.0/InputManager.cpp | 1 - kgEngine-2.0/kgEngine-2.0/PluginManager.h | 12 +- kgEngine-2.0/kgEngine-2.0/SaveManager.h | 2 +- 19 files changed, 540 insertions(+), 26 deletions(-) create mode 100644 kgEngine-2.0/TileMapGame/DefaultGameState.cpp create mode 100644 kgEngine-2.0/TileMapGame/DefaultGameState.h create mode 100644 kgEngine-2.0/TileMapGame/SingleplayerGameState.cpp create mode 100644 kgEngine-2.0/TileMapGame/SingleplayerGameState.h diff --git a/kgEngine-2.0/TileMapGame/ChunkSystem.cpp b/kgEngine-2.0/TileMapGame/ChunkSystem.cpp index 603bcaed..b9aa70c1 100644 --- a/kgEngine-2.0/TileMapGame/ChunkSystem.cpp +++ b/kgEngine-2.0/TileMapGame/ChunkSystem.cpp @@ -170,6 +170,12 @@ namespace kg // its a bug -.- } + void ChunkSystem::saveOpenSavegame( Engine& engine, World& world, SaveManager& saveManager ) + { + saveAllLoadedChunks( engine, world, saveManager ); + saveManager.saveSystems( world ); + } + bool ChunkSystem::ensureChunkLoaded( Engine& engine, World& world, SaveManager& saveManager, const sf::Vector2i& chunkPosition ) { if( !m_loadedChunks[chunkPosition.x][chunkPosition.y] ) diff --git a/kgEngine-2.0/TileMapGame/ChunkSystem.h b/kgEngine-2.0/TileMapGame/ChunkSystem.h index c8570209..b0f7118e 100644 --- a/kgEngine-2.0/TileMapGame/ChunkSystem.h +++ b/kgEngine-2.0/TileMapGame/ChunkSystem.h @@ -82,6 +82,7 @@ namespace kg /*std::list> getEntitiesInChunk( const sf::Vector2i& from, const sf::Vector2i& to )const;*/ + void saveOpenSavegame( Engine& engine, World& world, SaveManager& saveManager ); void saveAllLoadedChunks( Engine& engine, World& world, SaveManager& saveManager ); // returns the position in chunks for the position of an entity diff --git a/kgEngine-2.0/TileMapGame/DefaultGameState.cpp b/kgEngine-2.0/TileMapGame/DefaultGameState.cpp new file mode 100644 index 00000000..d5494eee --- /dev/null +++ b/kgEngine-2.0/TileMapGame/DefaultGameState.cpp @@ -0,0 +1,72 @@ +#include "DefaultGameState.h" +using namespace std; +using namespace sf; + +namespace kg +{ + + void DefaultGameState::onInit() + { + return; + } + + void DefaultGameState::registerGui( tgui::Gui& gui ) + { + return; + } + + void DefaultGameState::registerInputCallbacks( InputManager& inputManager ) + { + Action escapePress( Keyboard::Escape, Action::PressOnce ); + + Action eventClose( Event::Closed ); + + inputManager.setAction( id::Input::SHUT_DOWN, + escapePress || eventClose, + bind( &DefaultGameState::shutDown, this ) ); + } + + void DefaultGameState::onUpdate( GameStateManager& gameStateManager ) + { + if( !m_singleplayerGameStateLaunched ) + { + gameStateManager.push( std::make_shared() ); + m_singleplayerGameStateLaunched = true; + } + } + + void DefaultGameState::removeInputCallbacks( InputManager& inputManager ) + { + inputManager.removeAction( id::Input::SHUT_DOWN ); + } + + void DefaultGameState::removeGui( tgui::Gui& gui ) + { + return; + } + + void DefaultGameState::onDestroy() + { + throw exception( "DefaultGameState should never be destroyed" ); + } + + + const Plugin::Name& DefaultGameState::getPluginName() const + { + return PLUGIN_NAME; + } + + Plugin::Id DefaultGameState::getPluginId() const + { + return id::DEFAULT_GAMESTATE_ID; + } + + const std::string DefaultGameState::PLUGIN_NAME = "Default GameState"; + + void DefaultGameState::shutDown() + { + r_world->getSystem()->saveOpenSavegame( *r_engine, *r_world, *r_saveManager ); + r_engine->shouldTerminate = true; + } + +} diff --git a/kgEngine-2.0/TileMapGame/DefaultGameState.h b/kgEngine-2.0/TileMapGame/DefaultGameState.h new file mode 100644 index 00000000..8d071c41 --- /dev/null +++ b/kgEngine-2.0/TileMapGame/DefaultGameState.h @@ -0,0 +1,39 @@ +#pragma once +#include "stdafx.h" +#include "ChunkSystem.h" +#include "SingleplayerGameState.h" + +namespace kg +{ + class DefaultGameState : public GameState + { + bool m_singleplayerGameStateLaunched = false; + + public: + virtual void onInit() override; + + virtual void registerGui( tgui::Gui& gui ) override; + + virtual void registerInputCallbacks( InputManager& inputManager ) override; + + virtual void onUpdate( GameStateManager& gameStateManager ) override; + + virtual void removeInputCallbacks( InputManager& inputManager ) override; + + virtual void removeGui( tgui::Gui& gui ) override; + + virtual void onDestroy() override; + + + virtual const Plugin::Name& getPluginName() const override; + + virtual Plugin::Id getPluginId() const override; + + + static const std::string PLUGIN_NAME; + + //Input Callbacks + private: + void shutDown(); + }; +} diff --git a/kgEngine-2.0/TileMapGame/GameController.cpp b/kgEngine-2.0/TileMapGame/GameController.cpp index 74069b69..3e5bfaa2 100644 --- a/kgEngine-2.0/TileMapGame/GameController.cpp +++ b/kgEngine-2.0/TileMapGame/GameController.cpp @@ -2,7 +2,6 @@ using namespace std; using namespace sf; using namespace tgui; -using Action = thor::Action; namespace kg { diff --git a/kgEngine-2.0/TileMapGame/SingleplayerGameState.cpp b/kgEngine-2.0/TileMapGame/SingleplayerGameState.cpp new file mode 100644 index 00000000..a001ce69 --- /dev/null +++ b/kgEngine-2.0/TileMapGame/SingleplayerGameState.cpp @@ -0,0 +1,257 @@ +#include "SingleplayerGameState.h" +using namespace std; +using namespace sf; +using namespace tgui; + +namespace kg +{ + + std::shared_ptr SingleplayerGameState::m_getValidCamera() + { + if( m_camera.expired() ) + m_camera = r_graphicsSystem->getCamera( 0 ); + return m_camera.lock(); + } + + void SingleplayerGameState::movePlayer( sf::Vector2i distance ) + { + auto camera = m_getValidCamera(); + + camera->getComponent()->move( distance ); + } + + void SingleplayerGameState::m_onSavegameOpened( Engine& engine ) + { + m_cameraZoomFactor = 1; + } + + void SingleplayerGameState::onInit() + { + r_graphicsSystem = r_world->getSystem(); + + m_connectToSignal( r_saveManager->s_savegameOpened, &SingleplayerGameState::m_onSavegameOpened ); + + r_saveManager->openSavegame( *r_engine, *r_world, "MyFirstSavegameEver" ); + } + + void SingleplayerGameState::registerGui( tgui::Gui& gui ) + { + return; + } + + void SingleplayerGameState::registerInputCallbacks( InputManager& inputManager ) + { + // Keys + Action shift( Keyboard::LShift, Action::Hold ); + Action control( Keyboard::LControl, Action::Hold ); + + Action w( Keyboard::W, Action::Hold ); + Action a( Keyboard::A, Action::Hold ); + Action s( Keyboard::S, Action::Hold ); + Action d( Keyboard::D, Action::Hold ); + + Action add( Keyboard::Add, Action::Hold ); + Action subtract( Keyboard::Subtract, Action::Hold ); + + Action escapePress( Keyboard::Escape, Action::PressOnce ); + Action f5Press( Keyboard::F5, Action::PressOnce ); + + + // Events + Action eventClose( Event::Closed ); + + + // Set the actions and register callbacks + inputManager.setAction( id::Input::RELOAD_SAVE, f5Press, + bind( &SingleplayerGameState::reloadSave, this ) ); + + inputManager.setAction( id::Input::MOVE_UP, w && !shift && !control, + bind( &SingleplayerGameState::moveUp, this ) ); + inputManager.setAction( id::Input::MOVE_DOWN, s && !shift && !control, + bind( &SingleplayerGameState::moveDown, this ) ); + inputManager.setAction( id::Input::MOVE_LEFT, a && !shift && !control, + bind( &SingleplayerGameState::moveLeft, this ) ); + inputManager.setAction( id::Input::MOVE_RIGHT, d && !shift && !control, + bind( &SingleplayerGameState::moveRight, this ) ); + + inputManager.setAction( id::Input::MOVE_UP_FAST, w && shift && !control, + bind( &SingleplayerGameState::moveUpFast, this ) ); + inputManager.setAction( id::Input::MOVE_DOWN_FAST, s && shift && !control, + bind( &SingleplayerGameState::moveDownFast, this ) ); + inputManager.setAction( id::Input::MOVE_LEFT_FAST, a && shift && !control, + bind( &SingleplayerGameState::moveLeftFast, this ) ); + inputManager.setAction( id::Input::MOVE_RIGHT_FAST, d && shift && !control, + bind( &SingleplayerGameState::moveRightFast, this ) ); + + inputManager.setAction( id::Input::MOVE_UP_SLOW, w && !shift && control, + bind( &SingleplayerGameState::moveUpSlow, this ) ); + inputManager.setAction( id::Input::MOVE_DOWN_SLOW, s && !shift && control, + bind( &SingleplayerGameState::moveDownSlow, this ) ); + inputManager.setAction( id::Input::MOVE_LEFT_SLOW, a && !shift && control, + bind( &SingleplayerGameState::moveLeftSlow, this ) ); + inputManager.setAction( id::Input::MOVE_RIGHT_SLOW, d && !shift && control, + bind( &SingleplayerGameState::moveRightSlow, this ) ); + + inputManager.setAction( id::Input::ZOOM_IN, add, + bind( &SingleplayerGameState::zoomIn, this ) ); + inputManager.setAction( id::Input::ZOOM_OUT, subtract, + bind( &SingleplayerGameState::zoomOut, this ) ); + } + + void SingleplayerGameState::onUpdate( GameStateManager& gameStateManager ) + { + return; + } + + void SingleplayerGameState::removeInputCallbacks( InputManager& inputManager ) + { + inputManager.removeAction( id::Input::RELOAD_SAVE ); + + inputManager.removeAction( id::Input::MOVE_UP ); + inputManager.removeAction( id::Input::MOVE_DOWN ); + inputManager.removeAction( id::Input::MOVE_LEFT ); + inputManager.removeAction( id::Input::MOVE_RIGHT ); + + inputManager.removeAction( id::Input::MOVE_UP_FAST ); + inputManager.removeAction( id::Input::MOVE_DOWN_FAST ); + inputManager.removeAction( id::Input::MOVE_LEFT_FAST ); + inputManager.removeAction( id::Input::MOVE_RIGHT_FAST ); + + inputManager.removeAction( id::Input::MOVE_UP_SLOW ); + inputManager.removeAction( id::Input::MOVE_DOWN_SLOW ); + inputManager.removeAction( id::Input::MOVE_LEFT_SLOW ); + inputManager.removeAction( id::Input::MOVE_RIGHT_SLOW ); + + inputManager.removeAction( id::Input::ZOOM_IN ); + inputManager.removeAction( id::Input::ZOOM_OUT ); + } + + void SingleplayerGameState::removeGui( tgui::Gui& gui ) + { + return; + } + + void SingleplayerGameState::onDestroy() + { + return; + } + + + const Plugin::Name& SingleplayerGameState::getPluginName() const + { + return PLUGIN_NAME; + } + + Plugin::Id SingleplayerGameState::getPluginId() const + { + return id::GameStatePluginId::SINGLEPLAYER; + } + + void SingleplayerGameState::reloadSave() + { + r_world->getSystem()->saveOpenSavegame( *r_engine, *r_world, *r_saveManager ); + r_saveManager->openSavegame( *r_engine, *r_world, "MyFirstSavegameEver" ); + } + + void SingleplayerGameState::pause() + { + r_engine->isPaused = !r_engine->isPaused; + } + + void SingleplayerGameState::moveUp() + { + sf::Vector2i cameraMovement( 0, -10.0 / 16.0 * frameTime.asMilliseconds() ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveDown() + { + sf::Vector2i cameraMovement( 0, 10.0 / 16.0 * frameTime.asMilliseconds() ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveLeft() + { + sf::Vector2i cameraMovement( -10.0 / 16.0 * frameTime.asMilliseconds(), 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveRight() + { + sf::Vector2i cameraMovement( 10.0 / 16.0 * frameTime.asMilliseconds(), 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveUpFast() + { + sf::Vector2i cameraMovement( 0, -10.0 / 16.0 * frameTime.asMilliseconds() * 4 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveDownFast() + { + sf::Vector2i cameraMovement( 0, 10.0 / 16.0 * frameTime.asMilliseconds() * 4 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveLeftFast() + { + sf::Vector2i cameraMovement( -10.0 / 16.0 * frameTime.asMilliseconds() * 4, 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveRightFast() + { + sf::Vector2i cameraMovement( 10.0 / 16.0 * frameTime.asMilliseconds() * 4, 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveUpSlow() + { + sf::Vector2i cameraMovement( 0, -10.0 / 16.0 * frameTime.asMilliseconds() / 2 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveDownSlow() + { + sf::Vector2i cameraMovement( 0, 10.0 / 16.0 * frameTime.asMilliseconds() / 2 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveLeftSlow() + { + sf::Vector2i cameraMovement( -10.0 / 16.0 * frameTime.asMilliseconds() / 2, 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::moveRightSlow() + { + sf::Vector2i cameraMovement( 10.0 / 16.0 * frameTime.asMilliseconds() / 2, 0 ); + movePlayer( cameraMovement ); + } + + void SingleplayerGameState::zoomIn() + { + auto camera = m_getValidCamera(); + + m_cameraZoomFactor -= 0.01*frameTime.asMilliseconds(); + + if( m_cameraZoomFactor < 0 ) + m_cameraZoomFactor = 0; + camera->getComponent()->setZoomFactor( m_cameraZoomFactor ); + } + + void SingleplayerGameState::zoomOut() + { + auto camera = m_getValidCamera(); + + m_cameraZoomFactor += 0.01*frameTime.asMilliseconds(); + + if( m_cameraZoomFactor < 0 ) + m_cameraZoomFactor = 0; + camera->getComponent()->setZoomFactor( m_cameraZoomFactor ); + } + + const std::string SingleplayerGameState::PLUGIN_NAME = "Singleplayer GameState"; + +} diff --git a/kgEngine-2.0/TileMapGame/SingleplayerGameState.h b/kgEngine-2.0/TileMapGame/SingleplayerGameState.h new file mode 100644 index 00000000..fb0bd946 --- /dev/null +++ b/kgEngine-2.0/TileMapGame/SingleplayerGameState.h @@ -0,0 +1,67 @@ +#pragma once +#include "stdafx.h" +#include "ChunkSystem.h" +#include "GraphicsSystem.h" + +namespace kg +{ + class SingleplayerGameState : public GameState + { + GraphicsSystem* r_graphicsSystem; + + std::weak_ptr m_camera; + float m_cameraZoomFactor = 1; + std::shared_ptr m_getValidCamera(); + + void movePlayer( sf::Vector2i distance ); + + void m_onSavegameOpened( Engine& engine ); + + public: + virtual void onInit() override; + + virtual void registerGui( tgui::Gui& gui ) override; + + virtual void registerInputCallbacks( InputManager& inputManager ) override; + + virtual void onUpdate( GameStateManager& gameStateManager ) override; + + virtual void removeInputCallbacks( InputManager& inputManager ) override; + + virtual void removeGui( tgui::Gui& gui ) override; + + virtual void onDestroy() override; + + + virtual const Plugin::Name& getPluginName() const override; + + virtual Plugin::Id getPluginId() const override; + + + static const std::string PLUGIN_NAME; + + + //Input Callbacks + private: + void reloadSave(); + + void pause(); + + void moveUp(); + void moveDown(); + void moveLeft(); + void moveRight(); + void moveUpFast(); + void moveDownFast(); + void moveLeftFast(); + void moveRightFast(); + void moveUpSlow(); + void moveDownSlow(); + void moveLeftSlow(); + void moveRightSlow(); + + void zoomIn(); + void zoomOut(); + + }; +} diff --git a/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj b/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj index 336af4ca..e9594341 100644 --- a/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj +++ b/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj @@ -91,11 +91,13 @@ + + @@ -105,7 +107,9 @@ + + diff --git a/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj.filters b/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj.filters index 1721ff2e..722cdab3 100644 --- a/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj.filters +++ b/kgEngine-2.0/TileMapGame/TileMapGame.vcxproj.filters @@ -18,6 +18,9 @@ {7e7edd7b-5036-41fa-b73e-4272ad3170f9} + + {9de7af51-7d36-4f85-abf0-f97ad439180f} + @@ -53,6 +56,12 @@ Quelldateien + + Quelldateien + + + Quelldateien + @@ -94,5 +103,11 @@ Headerdateien\Components + + Headerdateien\GameStates + + + Headerdateien\GameStates + \ No newline at end of file diff --git a/kgEngine-2.0/TileMapGame/connect.cpp b/kgEngine-2.0/TileMapGame/connect.cpp index 6d20c702..9fa91091 100644 --- a/kgEngine-2.0/TileMapGame/connect.cpp +++ b/kgEngine-2.0/TileMapGame/connect.cpp @@ -8,6 +8,8 @@ #include "ChunkSystem.h" #include "GraphicsSystem.h" +#include "DefaultGameState.h" + using namespace std; using namespace kg; @@ -39,10 +41,10 @@ extern "C" //Camera not registered as a plugin. A camera entity is created in the GraphicsSystem //Systems - pluginManager.addPluginFactory( + /*pluginManager.addPluginFactory( std::make_shared>( ( int )id::SystemPluginId::GAME_CONTROLLER, - GameController::PLUGIN_NAME ) ); + GameController::PLUGIN_NAME ) );*/ pluginManager.addPluginFactory( std::make_shared>( ( int )id::SystemPluginId::CHUNK_SYSTEM, @@ -60,7 +62,13 @@ extern "C" ( int )id::SystemPluginId::ANIMATION_SYSTEM, AnimationSystem::PLUGIN_NAME ) ); + //GameStates + pluginManager.addPluginFactory( + std::make_shared>( + ( int )id::DEFAULT_GAMESTATE_ID, + DefaultGameState::PLUGIN_NAME ) ); + //AnimationHandlers pluginManager.addPluginFactory( std::make_shared>( ( int )id::SpecialPluginId::ANIMATION_HANDLER_EASY, diff --git a/kgEngine-2.0/TileMapGame/id.h b/kgEngine-2.0/TileMapGame/id.h index 84c97461..218e0198 100644 --- a/kgEngine-2.0/TileMapGame/id.h +++ b/kgEngine-2.0/TileMapGame/id.h @@ -36,12 +36,25 @@ namespace kg }; } - namespace SpecialPluginId + namespace GameStatePluginId { enum { FIRST_ELEMENT = ComponentPluginId::LAST_ELEMENT, + //Default is 0 (defined in 'id_internal.h') + SINGLEPLAYER, + + LAST_ELEMENT + }; + } + + namespace SpecialPluginId + { + enum + { + FIRST_ELEMENT = GameStatePluginId::LAST_ELEMENT, + ANIMATION_HANDLER_EASY, LAST_ELEMENT @@ -88,9 +101,11 @@ namespace kg { FIRST_ELEMENT, + //DefaultGameState SHUT_DOWN, - RELOAD_SAVE, + //SingleplayerGameState + RELOAD_SAVE, MOVE_UP, MOVE_DOWN, MOVE_LEFT, @@ -103,7 +118,6 @@ namespace kg MOVE_DOWN_SLOW, MOVE_LEFT_SLOW, MOVE_RIGHT_SLOW, - ZOOM_IN, ZOOM_OUT, diff --git a/kgEngine-2.0/kgEngine-2.0/Core.cpp b/kgEngine-2.0/kgEngine-2.0/Core.cpp index 5c292b70..9c8de4f4 100644 --- a/kgEngine-2.0/kgEngine-2.0/Core.cpp +++ b/kgEngine-2.0/kgEngine-2.0/Core.cpp @@ -40,6 +40,7 @@ namespace kg } if( m_engine.isPaused ) frameTime = sf::seconds( 0 ); + m_gameStateManager.forwardFrameTime( frameTime ); Event event; m_engine.inputManager.clearEvents(); diff --git a/kgEngine-2.0/kgEngine-2.0/GameState.cpp b/kgEngine-2.0/kgEngine-2.0/GameState.cpp index c3f46154..207d091d 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameState.cpp +++ b/kgEngine-2.0/kgEngine-2.0/GameState.cpp @@ -1,7 +1,6 @@ #include "GameState.h" using namespace std; using namespace sf; -using namespace thor; namespace kg { @@ -13,4 +12,9 @@ namespace kg r_saveManager = &saveManager; } + void GameState::updateFrameTime( const sf::Time& frameTime ) + { + this->frameTime = frameTime; + } + } diff --git a/kgEngine-2.0/kgEngine-2.0/GameState.h b/kgEngine-2.0/kgEngine-2.0/GameState.h index 44041754..1bdb6d3a 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameState.h +++ b/kgEngine-2.0/kgEngine-2.0/GameState.h @@ -8,26 +8,30 @@ namespace kg { class GameStateManager; + using Action = thor::Action; - class DLL_EXPORT GameState : public PluginRTTI, public sf::NonCopyable + class DLL_EXPORT GameState : public Plugin, public CallbackReciever, public sf::NonCopyable { protected: Engine* r_engine; World* r_world; SaveManager* r_saveManager; + sf::Time frameTime; + public: void initReferences( Engine& engine, World& world, SaveManager& saveManager ); + void updateFrameTime( const sf::Time& frameTime ); virtual void onInit() = 0; - virtual void initGui( tgui::Gui& gui ) = 0; - virtual void initInputCallbacks( InputManager& inputManager ) = 0; + virtual void registerGui( tgui::Gui& gui ) = 0; + virtual void registerInputCallbacks( InputManager& inputManager ) = 0; virtual void onUpdate( GameStateManager& gameStateManager ) = 0; - virtual void onRemove() = 0; - virtual void removeGui( tgui::Gui& gui ) = 0; virtual void removeInputCallbacks( InputManager& inputManager ) = 0; + virtual void removeGui( tgui::Gui& gui ) = 0; + virtual void onDestroy() = 0; }; } diff --git a/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp b/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp index c7c33f03..1f75206b 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp +++ b/kgEngine-2.0/kgEngine-2.0/GameStateManager.cpp @@ -1,7 +1,6 @@ #include "GameStateManager.h" using namespace std; using namespace sf; -using namespace thor; namespace kg { @@ -16,19 +15,36 @@ namespace kg void GameStateManager::init() { - auto defaultGameState = engine.pluginManager.createPlugin( 0 ); + auto defaultGameState = engine.pluginManager.createPlugin( id::DEFAULT_GAMESTATE_ID ); push( defaultGameState ); } - void GameStateManager::push( std::shared_ptr& gameState ) + void GameStateManager::forwardFrameTime( const sf::Time& frameTime ) + { + for( auto& el : m_gameStateStack ) + el->updateFrameTime( frameTime ); + } + + void GameStateManager::push( const std::shared_ptr& gameState ) { gameState->initReferences( engine, world, saveManager ); + + gameState->onInit(); + gameState->registerGui( engine.inputManager.gui ); + gameState->registerInputCallbacks( engine.inputManager ); + m_gameStateStack.push_back( gameState ); } void GameStateManager::pop() { + auto& gameState = m_gameStateStack.back(); + + gameState->removeInputCallbacks( engine.inputManager ); + gameState->removeGui( engine.inputManager.gui ); + gameState->onDestroy(); + m_gameStateStack.pop_back(); } @@ -39,8 +55,14 @@ namespace kg void GameStateManager::onUpdate() { + vector> temp; for( auto& el : m_gameStateStack ) - el->onUpdate(*this); - } + temp.push_back( el ); + for( auto& ptr : temp ) + { + if(auto sptr = ptr.lock()) + sptr->onUpdate( *this ); + } + } } diff --git a/kgEngine-2.0/kgEngine-2.0/GameStateManager.h b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h index 03849d99..7e7caffc 100644 --- a/kgEngine-2.0/kgEngine-2.0/GameStateManager.h +++ b/kgEngine-2.0/kgEngine-2.0/GameStateManager.h @@ -16,7 +16,9 @@ namespace kg void init(); - void push( std::shared_ptr& gameState ); + void forwardFrameTime( const sf::Time& frameTime ); + + void push( const std::shared_ptr& gameState ); void pop(); diff --git a/kgEngine-2.0/kgEngine-2.0/InputManager.cpp b/kgEngine-2.0/kgEngine-2.0/InputManager.cpp index 28028e56..08b0b950 100644 --- a/kgEngine-2.0/kgEngine-2.0/InputManager.cpp +++ b/kgEngine-2.0/kgEngine-2.0/InputManager.cpp @@ -1,7 +1,6 @@ #include "InputManager.h" using namespace std; using namespace sf; -using namespace thor; namespace kg { diff --git a/kgEngine-2.0/kgEngine-2.0/PluginManager.h b/kgEngine-2.0/kgEngine-2.0/PluginManager.h index b887e790..c8f74d4a 100644 --- a/kgEngine-2.0/kgEngine-2.0/PluginManager.h +++ b/kgEngine-2.0/kgEngine-2.0/PluginManager.h @@ -89,24 +89,27 @@ namespace kg template std::shared_ptr createPlugin( const Plugin::Id& id )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); + size_t genericPluginType = typeid(BasePluginType).hash_code(); +#ifndef _DEBUG try { +#endif auto plugin = static_pointer_cast< PluginFactoryInterface >(m_pluginsByGenericTypeHash.at( genericPluginType ).first.at( id )); if( plugin == nullptr ) throw PluginRequestException( id ); return std::static_pointer_cast< BasePluginType >(plugin->create()); +#ifndef _DEBUG } catch( const std::exception& ) { throw PluginRequestException( id ); } +#endif } template<> std::shared_ptr createPlugin( const Plugin::Id& id )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); try { auto& plugin = m_componentPluginFactorysById.at( id ); @@ -123,7 +126,6 @@ namespace kg template<> std::shared_ptr createPlugin( const Plugin::Id& id )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); try { auto& plugin = m_systemPluginFactorysById.at( id ); @@ -141,7 +143,7 @@ namespace kg template std::shared_ptr createPlugin( const Plugin::Name& name )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); + size_t genericPluginType = typeid(BasePluginType).hash_code(); try { auto plugin = static_pointer_cast< PluginFactoryInterface >(m_pluginsByGenericTypeHash.at( genericPluginType ).second.at( name )); @@ -158,7 +160,6 @@ namespace kg template<> std::shared_ptr createPlugin( const Plugin::Name& name )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); try { auto& plugin = m_componentPluginFactorysByName.at( name ); @@ -175,7 +176,6 @@ namespace kg template<> std::shared_ptr createPlugin( const Plugin::Name& name )const { - size_t genericPluginType = typeid(genericPluginType).hash_code(); try { auto& plugin = m_systemPluginFactorysByName.at( name ); diff --git a/kgEngine-2.0/kgEngine-2.0/SaveManager.h b/kgEngine-2.0/kgEngine-2.0/SaveManager.h index 48d9fc11..12e2cafa 100644 --- a/kgEngine-2.0/kgEngine-2.0/SaveManager.h +++ b/kgEngine-2.0/kgEngine-2.0/SaveManager.h @@ -10,7 +10,7 @@ namespace kg { class DLL_EXPORT SaveManager { - std::string m_openSavegameName = "ErrorSavegame"; + std::string m_openSavegameName = "dev_null"; public: using SystemSaveInformationMap = std::map < int, SystemSaveInformation > ; From da83eae988f02aa89b6842e9c9ef0cb35a3c84f9 Mon Sep 17 00:00:00 2001 From: Kay Gonschior Date: Sat, 10 Oct 2015 14:56:55 +0200 Subject: [PATCH 4/7] removed obsolete gameController --- kgEngine-2.0/TileMapGame/GameController.cpp | 268 ------------------ kgEngine-2.0/TileMapGame/GameController.h | 74 ----- kgEngine-2.0/TileMapGame/TileMapGame.vcxproj | 2 - .../TileMapGame/TileMapGame.vcxproj.filters | 6 - kgEngine-2.0/TileMapGame/connect.cpp | 5 - 5 files changed, 355 deletions(-) delete mode 100644 kgEngine-2.0/TileMapGame/GameController.cpp delete mode 100644 kgEngine-2.0/TileMapGame/GameController.h diff --git a/kgEngine-2.0/TileMapGame/GameController.cpp b/kgEngine-2.0/TileMapGame/GameController.cpp deleted file mode 100644 index 3e5bfaa2..00000000 --- a/kgEngine-2.0/TileMapGame/GameController.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include "GameController.h" -using namespace std; -using namespace sf; -using namespace tgui; - -namespace kg -{ - void GameController::m_onSavegameOpened( Engine& engine ) - { - m_cameraZoomFactor = 1; - } - - void GameController::init( Engine& engine, World& world, SaveManager& saveManager, std::shared_ptr& configFile ) - { - r_engine = &engine; - r_world = &world; - r_saveManager = &saveManager; - r_graphicsSystem = world.getSystem(); - - m_connectToSignal( saveManager.s_savegameOpened, &GameController::m_onSavegameOpened ); - registerInputCallbacks( engine.inputManager ); - - saveManager.openSavegame( engine, world, "MyFirstSavegameEver" ); - - auto button = make_shared