Prechádzať zdrojové kódy

Managers restructured.

They all extend a base Manager and have common features, such as different curse of actions depending on the active module. Changes in the audio manager so it can work in battle mode.
Iñigo Valentin 3 rokov pred
rodič
commit
36f9786f9b
49 zmenil súbory, kde vykonal 1793 pridanie a 1296 odobranie
  1. 2 2
      data/data/scripts/field.lua
  2. 5 4
      src/CMakeLists.txt
  3. 69 15
      src/core/AudioManager.cpp
  4. 181 67
      src/core/AudioManager.h
  5. 126 67
      src/core/BattleManager.cpp
  6. 57 37
      src/core/BattleManager.h
  7. 38 71
      src/core/CameraManager.cpp
  8. 42 11
      src/core/CameraManager.h
  9. 2 2
      src/core/CameraManagerCommands.h
  10. 5 7
      src/core/ConfigCmd.cpp
  11. 8 8
      src/core/ConfigCmd.h
  12. 14 13
      src/core/ConfigCmdHandler.cpp
  13. 10 11
      src/core/ConfigCmdHandler.h
  14. 77 115
      src/core/ConfigCmdHandlerCommands.h
  15. 3 3
      src/core/ConfigFile.cpp
  16. 12 13
      src/core/ConfigVar.h
  17. 6 6
      src/core/ConfigVarHandler.cpp
  18. 4 5
      src/core/ConfigVarHandler.h
  19. 15 15
      src/core/Console.cpp
  20. 138 123
      src/core/DialogsManager.cpp
  21. 39 10
      src/core/DialogsManager.h
  22. 3 104
      src/core/EntityManager.cpp
  23. 14 210
      src/core/EntityManager.h
  24. 22 8
      src/core/InputManager.cpp
  25. 80 17
      src/core/InputManager.h
  26. 6 5
      src/core/InputManagerCommands.h
  27. 115 0
      src/core/Manager.cpp
  28. 260 0
      src/core/Manager.h
  29. 92 92
      src/core/SavemapHandler.cpp
  30. 6 4
      src/core/SavemapHandler.h
  31. 16 0
      src/core/ScriptManager.cpp
  32. 43 29
      src/core/ScriptManager.h
  33. 146 142
      src/core/ScriptManagerBinds.h
  34. 3 3
      src/core/ScriptManagerCommands.h
  35. 20 19
      src/core/TextHandler.cpp
  36. 8 8
      src/core/TextHandler.h
  37. 5 7
      src/core/TextHandlerCommands.h
  38. 21 7
      src/core/UiManager.cpp
  39. 42 4
      src/core/UiManager.h
  40. 8 8
      src/core/UiTextArea.cpp
  41. 4 3
      src/core/XmlMapFile.cpp
  42. 2 2
      src/core/XmlScreenFile.cpp
  43. 5 4
      src/core/XmlTextFile.cpp
  44. 5 4
      src/core/XmlTextsFile.cpp
  45. 8 8
      src/main.cpp
  46. 2 1
      test/core/ConfigCmdHandler.cpp
  47. 2 1
      test/core/ConfigVarHandler.cpp
  48. 0 0
      test/core/SavemapHandler.cpp
  49. 2 1
      test/core/TextHandler.cpp

+ 2 - 2
data/data/scripts/field.lua

@@ -228,8 +228,8 @@ end
 --
 -- @param id ID of the track in the field.
 play_map_music = function(id)
-    local track_id = entity_manager:get_track_id(id)
-    if entity_manager:get_track_id(id) ~= -1 then
+    local track_id = audio_manager:get_track_id(id)
+    if track_id ~= -1 then
         audio_manager:play_music(tostring(track_id))
     else
         print("Requested non-existent music track ID " .. tostring(id))

+ 5 - 4
src/CMakeLists.txt

@@ -85,10 +85,10 @@ set(VGEARS_SOURCE_FILES
     core/BattleManager.cpp
     core/CameraManager.cpp
     core/ConfigCmd.cpp
-    core/ConfigCmdManager.cpp
+    core/ConfigCmdHandler.cpp
     core/ConfigFile.cpp
     core/ConfigVar.cpp
-    core/ConfigVarManager.cpp
+    core/ConfigVarHandler.cpp
     core/Console.cpp
     core/DebugDraw.cpp
     core/DialogsManager.cpp
@@ -102,6 +102,7 @@ set(VGEARS_SOURCE_FILES
     core/EntityTrigger.cpp
     core/GameFrameListener.cpp
     core/InputManager.cpp
+    core/Manager.cpp
     core/particles/Particle.cpp
     core/particles/ParticleEmitter.cpp
     core/particles/ParticleEmitterDictionary.cpp
@@ -121,9 +122,9 @@ set(VGEARS_SOURCE_FILES
     core/particles/renderer/ParticleEntityRenderer.cpp
     core/particles/renderer/ParticleEntityRendererDictionary.cpp
     core/Savemap.cpp
-    core/SavemapManager.cpp
+    core/SavemapHandler.cpp
     core/ScriptManager.cpp
-    core/TextManager.cpp
+    core/TextHandler.cpp
     core/Timer.cpp
     core/UiAnimation.cpp
     core/UiFont.cpp

+ 69 - 15
src/core/AudioManager.cpp

@@ -17,6 +17,7 @@
 #include <list>
 #include <boost/thread.hpp>
 #include "core/AudioManager.h"
+#include "core/Event.h"
 #include "core/XmlMusicsFile.h"
 #include "core/XmlSoundsFile.h"
 #include "core/Logger.h"
@@ -31,7 +32,7 @@ int AudioManager::channel_buffer_size_ = 96 * 1024;
 
 AudioManager::AudioManager():
   initialized_(false), thread_continue_(true), update_mutex_(), music_(&update_mutex_),
-  fx_(&update_mutex_)
+  battle_music_(&update_mutex_), fx_(&update_mutex_)
 {
     al_device_ = alcOpenDevice(nullptr);
     if (al_device_ != nullptr){
@@ -46,7 +47,7 @@ AudioManager::AudioManager():
             alListenerfv(AL_VELOCITY, velocity);
             alListenerfv(AL_ORIENTATION, orientation);
             initialized_ = true;
-            buffer_       = new char[channel_buffer_size_];
+            buffer_ = new char[channel_buffer_size_];
             update_thread_ = new boost::thread(boost::ref(*this));
             LOG_TRIVIAL("AudioManager initialised.");
         }
@@ -92,15 +93,28 @@ void AudioManager::operator()(){
     }
 }
 
-void AudioManager::Update(){
+void AudioManager::Input(const VGears::Event& event){}
+
+void AudioManager::UpdateDebug(){}
+
+void AudioManager::OnResize(){}
+
+void AudioManager::ClearField(){tracks_.clear();}
+
+void AudioManager::ClearBattle(){battle_track_ = -1;}
+
+void AudioManager::ClearWorld(){tracks_.clear();}
+
+void AudioManager::MusicPause(){
     boost::recursive_mutex::scoped_lock lock(update_mutex_);
-    music_.Update();
-    fx_.Update();
+    if (module_ == Module::BATTLE) battle_music_.Pause();
+    else music_.Pause();
 }
 
-void AudioManager::MusicPause(){
+void AudioManager::MusicResume(){
     boost::recursive_mutex::scoped_lock lock(update_mutex_);
-    music_.Pause();
+    if (module_ == Module::BATTLE) battle_music_.Resume();
+    else music_.Resume();
 }
 
 void AudioManager::ScriptPlayMusic(const char* name){
@@ -116,8 +130,16 @@ void AudioManager::MusicPlay(const Ogre::String& name){
             LOG_ERROR("No music found with name \"" + name + "\".");
             return;
         }
-        music_.SetLoop(music->loop);
-        music_.Play(music->file);
+        if (module_ == Module::BATTLE){
+            music_.Pause();
+            battle_music_.SetLoop(music->loop);
+            battle_music_.Play(music->file);
+        }
+        else{
+            battle_music_.Stop();
+            music_.SetLoop(music->loop);
+            music_.Play(music->file);
+        }
     }
 }
 
@@ -198,6 +220,33 @@ AudioManager::Sound* AudioManager::GetSound(const Ogre::String& name){
     return nullptr;
 }
 
+void AudioManager::AddTrack(const int id, const int track_id){
+    if (id >= 0 && id < 255) tracks_[id] = track_id;
+}
+
+int AudioManager::ScriptGetTrack(int id){
+    if (tracks_.count(id) == 0) return -1;
+    else return tracks_[id];
+}
+
+int AudioManager::ScriptGetBattleTrack(){return battle_track_;}
+
+void AudioManager::ScriptSetBattleTrack(int track){battle_track_ = track;}
+
+void AudioManager::UpdateField(){
+    boost::recursive_mutex::scoped_lock lock(update_mutex_);
+    music_.Update();
+    fx_.Update();
+}
+
+void AudioManager::UpdateBattle(){
+    boost::recursive_mutex::scoped_lock lock(update_mutex_);
+    battle_music_.Update();
+    fx_.Update();
+}
+
+void AudioManager::UpdateWorld(){UpdateField();}
+
 const char* AudioManager::ALError(){
     //ALenum error_code = alGetError();
     //if (error_code == AL_NO_ERROR)
@@ -218,9 +267,7 @@ const char* AudioManager::ALCError(const ALCdevice* device){
 AudioManager::Player::Player(boost::recursive_mutex* mutex):
   loop_(-1.0), vorbis_info_(nullptr), vorbis_section_(0),
   stream_finished_(false), update_mutex_(mutex)
-{
-    buffer_ = new char[1024 * 96];
-}
+{buffer_ = new char[1024 * 96];}
 
 AudioManager::Player::~Player(){Stop();}
 
@@ -229,12 +276,19 @@ void AudioManager::Player::Pause(){
     alSourcePause(source_);
 }
 
+void AudioManager::Player::Resume(){
+    if (!alIsSource(source_)){
+        LOG_WARNING("AudioManager::Player: Resume called but no track was paused.");
+        return;
+    }
+    alSourcePlay(source_);
+}
+
 void AudioManager::Player::Play(const Ogre::String &file){
     boost::recursive_mutex::scoped_lock lock(*update_mutex_);
 
 
     // If the same track is already playing, don't restart.
-
     if (file_ == file) return;
 
     // Open vorbis file.
@@ -275,6 +329,7 @@ void AudioManager::Player::Play(const Ogre::String &file){
 
 void AudioManager::Player::Stop(){
     boost::recursive_mutex::scoped_lock lock(*update_mutex_);
+    if (!alIsSource(source_)) return;
     // Stop source
     alSourceStop(source_);
     // Get source buffers
@@ -310,8 +365,7 @@ void AudioManager::Player::Update(){
             ALuint buffer_id;
             alSourceUnqueueBuffers(source_, 1, &buffer_id);
             alBufferData(
-              buffer_id, vorbis_info_->channels == 1 ?
-                AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
+              buffer_id, vorbis_info_->channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16,
               //static_cast<const ALvoid*>(AudioManager::getSingleton().buffer_),
               static_cast<const ALvoid*>(buffer_),
               static_cast<ALsizei>(buffer_size), static_cast<ALsizei>(vorbis_info_->rate)

+ 181 - 67
src/core/AudioManager.h

@@ -18,6 +18,7 @@
 #include <OgreSingleton.h>
 #include <boost/thread.hpp>
 #include <vorbis/vorbisfile.h>
+#include "Manager.h"
 
 // Include OpenAL
 #if defined(__WIN32__) || defined(_WIN32)
@@ -31,12 +32,55 @@
 /**
  * The audio manager.
  *
- * It handles all music and sounds in the application.
+ * It handles all music and sounds in the application. The manager has three players: one for
+ * battle music, another for music shared between fields and the world map, and a third one for
+ * sounds, that can be used anytime.
  */
-class AudioManager : public Ogre::Singleton<AudioManager>{
+class AudioManager : public Manager, public Ogre::Singleton<AudioManager>{
 
     public:
 
+        /**
+         * Music structure.
+         *
+         * Defines a music entry in musics.xml.
+         */
+        struct Music{
+
+            /**
+             * The name of the track.
+             */
+            Ogre::String name;
+
+            /**
+             * Track filename
+             */
+            Ogre::String file;
+
+            /**
+             * Music loop location for continuous playback.
+             */
+            float loop;
+        };
+
+        /**
+         * Music structure.
+         *
+         * Defines a sound entry in sound.xml.
+         */
+        struct Sound{
+
+            /**
+             * The name of the sound.
+             */
+            Ogre::String name;
+
+            /**
+             * Sound filename
+             */
+            Ogre::String file;
+        };
+
         /**
          * Constructor.
          */
@@ -53,17 +97,60 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
         void operator()();
 
         /**
-         * Updates the music player.
+         * Handles an input event.
+         *
+         * @param[in] event Event to handle.
+         */
+        void Input(const VGears::Event& event) override;
+
+        /**
+         * Updates the audio manager with debug information.
+         */
+        void UpdateDebug() override;
+
+        /**
+         * Handles resizing events
          */
-        void Update();
+        void OnResize() override;
+
+        /**
+         * Clears all field information in the audio manager.
+         *
+         * It clears the music tracks assigned for the fields.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle information in the audio manager.
+         *
+         * It clears the music track assigned for the battle.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map information in the audio manager.
+         *
+         * It clears the tracks assigned for the world map.
+         */
+        void ClearWorld() override;
 
         /**
          * Pauses currently playing music.
          *
-         * @todo How to resume it?
+         * If the manager is in battle mode, the battle music player will be paused. If not, the
+         * field or world map player will be paused. Playback can be resumed by calling
+         * {@see MusicResume}.
          */
         void MusicPause();
 
+        /**
+         * resumes currently paused music.
+         *
+         * If the manager is in battle mode, the battle music player will be resumed. If not, the
+         * field or world map player will be resumed.
+         */
+        void MusicResume();
+
         /**
          * Plays a music track.
          *
@@ -76,6 +163,11 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
         /**
          * Plays a music track.
          *
+         * If the manager is in battle mode, the field or world map player will be paused, and the
+         * battle player will play. If not, the battle music player will stop and the field or
+         * world map will start playing. If there is no music by the specified name, an error will
+         * be printed and nothing will be done.
+         *
          * @param[in] name Name of the track to play.
          */
         void MusicPlay(const Ogre::String& name);
@@ -123,54 +215,11 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
         /**
          * Stops the currently playing music.
          *
-         * Playback can't be resumed.
+         * Playback can't be resumed. If the battle mode is active, the battle music player will be
+         * the one stoped. If not, the field/world map player will be the one stopping.
          */
         void MusicStop();
 
-        /**
-         * Music structure.
-         *
-         * Defines a music entry in musics.xml.
-         */
-        struct Music{
-
-            /**
-             * The name of the track.
-             */
-            Ogre::String name;
-
-            /**
-             * Track filename
-             */
-            Ogre::String file;
-
-            /**
-             * Music loop location for continous playback.
-             *
-             * @todo How is a loop done with only one value? shouldn't it be
-             * start and end of loop?
-             */
-            float loop;
-        };
-
-        /**
-         * Music structure.
-         *
-         * Defines a sound entry in sound.xml.
-         */
-        struct Sound{
-
-            /**
-             * The name of the sound.
-             */
-            Ogre::String name;
-
-            /**
-             * Sound filename
-             */
-            Ogre::String file;
-        };
-
         /**
          * Adds a music track to the audio manager.
          *
@@ -201,30 +250,39 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
          */
         AudioManager::Sound* GetSound(const Ogre::String& name);
 
-    private:
+        /**
+         * Adds a music track ID to the list of music tracks of the field.
+         *
+         * @param[in] id ID of the track in the map.
+         * @param[in] track_id Music track ID.
+         */
+        void AddTrack(const int id, const int track_id);
 
         /**
-         * Initializes the audio manager.
+         * Retrieves the music ID for the specified track for a field or world map.
          *
-         * @todo Verify this comment.
+         * @param[in] id ID of the track in the field or world map.
+         * @return The music track ID, or -1 if it doesn't exist.
          */
-        const bool Init();
+        int ScriptGetTrack(int id);
 
         /**
-         * Handles errors
+         * Retrieves the music ID for the current or next battle.
          *
-         * @return nullptr
-         * @todo Implement and get error info.
+         * @return The music track ID for the current or upcoming battles.
          */
-        const char* ALError();
+        int ScriptGetBattleTrack();
 
         /**
-         * Handles errors
+         * Sets the music track for upcoming battles.
          *
-         * @return nullptr
-         * @todo Implement and get error info.
+         * Must be called before entering the battle mode.
+         *
+         * @param[in] id ID of the track for the upcoming battles.
          */
-        const char* ALCError( const ALCdevice* device );
+        void ScriptSetBattleTrack(int id);
+
+    private:
 
         /**
          * An audio player
@@ -256,6 +314,13 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
                  */
                 void Play(const Ogre::String& file);
 
+                /**
+                 * Resumes the playback of a paused player.
+                 *
+                 * If no track was paused, an error wilt be printed and nothing will be done.
+                 */
+                void Resume();
+
                 /**
                  * Stops the audio player.
                  */
@@ -338,10 +403,46 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
                 ALsizei FillBuffer();
         };
 
-    private:
+        /**
+         * Initializes the audio manager.
+         *
+         * @todo Verify this comment.
+         */
+        const bool Init();
+
+        /**
+         * Handles errors
+         *
+         * @return nullptr
+         * @todo Implement and get error info.
+         */
+        const char* ALError();
+
+        /**
+         * Handles errors
+         *
+         * @return nullptr
+         * @todo Implement and get error info.
+         */
+        const char* ALCError( const ALCdevice* device );
+
+        /**
+         * Updates the audio manager while on the field.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the audio manager while on a battle.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates the audio manager while on the world map.
+         */
+        void UpdateWorld() override;
 
         /**
-         * Indicatesif the audio manager has been initialized.
+         * Indicates if the audio manager has been initialized.
          */
         bool initialized_;
 
@@ -378,14 +479,17 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
         bool thread_continue_;
 
         /**
-         * Music player.
+         * Music player for either fields or world map.
          */
         AudioManager::Player music_;
 
+        /**
+         * Music player for battles.
+         */
+        AudioManager::Player battle_music_;
+
         /**
          * Sound effect player.
-         *
-         * TODO: Unused? remove.
          */
         AudioManager::Player fx_;
 
@@ -394,6 +498,16 @@ class AudioManager : public Ogre::Singleton<AudioManager>{
          */
         std::list<AudioManager::Music> music_list_;
 
+        /**
+         * IDs of the music tracks of the current content (field or world map).
+         */
+        std::unordered_map<unsigned int, unsigned int> tracks_;
+
+        /**
+         * ID of the track for the current battle.
+         */
+        int battle_track_;
+
         /**
          * List of music.
          */

+ 126 - 67
src/core/BattleManager.cpp

@@ -19,12 +19,14 @@
 #include <OgreEntity.h>
 #include <OgreRoot.h>
 #include <OgreViewport.h>
+#include "core/AudioManager.h"
 #include "core/BattleManager.h"
 #include "core/CameraManager.h"
 #include "core/Enemy.h"
 #include "core/EntityManager.h"
 #include "core/ConfigVar.h"
 #include "core/Logger.h"
+#include "core/ScriptManager.h"
 #include "core/XmlFormationFile.h"
 
 /**
@@ -37,7 +39,7 @@ ConfigVar cv_debug_battle_axis("debug_battle_axis", "Draw debug battle axis", "f
 
 const float BattleManager::MODEL_SCALE = 0.0015f;
 
-BattleManager::BattleManager(): paused_(false){
+BattleManager::BattleManager(){
     LOG_TRIVIAL("BattleManager created.");
     scene_node_ = Ogre::Root::getSingleton().getSceneManager("Scene")
       ->getRootSceneNode()->createChildSceneNode("BattleManager");
@@ -51,9 +53,49 @@ BattleManager::~BattleManager(){
     LOG_TRIVIAL("BattleManager destroyed.");
 }
 
+void BattleManager::Input(const VGears::Event& event){}
+
+void BattleManager::UpdateDebug(){}
+
+void BattleManager::OnResize(){}
+
+void BattleManager::ClearField(){
+    LOG_TRIVIAL("Called empty method BattleManager::ClearField()");
+}
+
+void BattleManager::ClearBattle(){
+    formation_id_ = -1;
+    next_formation_id_ = -1;
+    // TODO location_ = null;
+    camera_.clear();
+    initial_camera_ = 0;
+    layout_ = LAYOUT::NORMAL;
+    escape_difficulty_ = 0.0f;
+    arena_battle_ = false;
+    show_victory_pose_ = true;
+    show_spoils_ = true;
+    preemptive_ = true;
+    money_ = 0;
+    spoil_.clear();
+    enemies_.clear();
+    // TODO party_.clear();
+}
+
+void BattleManager::ClearWorld(){
+    LOG_TRIVIAL("Called empty method BattleManager::ClearWorld()");
+}
+
 void BattleManager::StartBattle(const unsigned int id){
+    if (module_ == Module::BATTLE){
+        LOG_ERROR("Started battle in BattleManager, but the manager was already in battle mode.");
+        return;
+    }
+    module_ = Module::BATTLE;
     formation_id_ = id;
     EntityManager::getSingleton().SetBattleModule();
+    CameraManager::getSingleton().SetBattleModule();
+    AudioManager::getSingleton().SetBattleModule();
+    ScriptManager::getSingleton().SetBattleModule();
     // Load the formation XML file (name is dddd.xml)
     std::string filename = std::to_string(formation_id_);
     while (filename.length() < 4) filename = "0" + filename;
@@ -81,9 +123,17 @@ void BattleManager::StartBattle(const unsigned int id){
 }
 
 void BattleManager::EndBattle(){
-    formation_id_ = -1;
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Ended battle in BattleManager, but the manager was not in battle mode.");
+        return;
+    }
+    SetPreviousModule();
+    ClearBattle();
     EntityManager::getSingleton().SetPreviousModule();
     CameraManager::getSingleton().EndBattleCamera();
+    CameraManager::getSingleton().SetPreviousModule();
+    AudioManager::getSingleton().SetPreviousModule();
+    ScriptManager::getSingleton().SetPreviousModule();
 }
 
 std::vector<Enemy> BattleManager::GetEnemies() const{return enemies_;}
@@ -92,6 +142,12 @@ void BattleManager::AddEnemy(
   const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible,
   const bool targeteable, const bool active, const std::string cover
 ){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR(
+          "Tried to add an enemy to the BattleManager, but the manager was not in battle mode."
+        );
+        return;
+    }
     Enemy* enemy = new Enemy(id, pos, front, visible, targeteable, active, cover);
     enemies_.push_back(*enemy);
     EntityManager::getSingleton().AddBattleEntity(
@@ -99,19 +155,17 @@ void BattleManager::AddEnemy(
       "models/battle/enemy/" + enemy->GetModel() + ".mesh", enemy->GetPos(), Ogre::Degree(0),
       Ogre::Vector3(MODEL_SCALE, MODEL_SCALE, MODEL_SCALE), id, visible
     );
-
-    /*EntityManager::getSingleton().AddBattleEntity(
-      enemy->GetName() + "_" + std::to_string(enemies_.size() - 1),
-      "models/battle/enemy/" + enemy->GetModel() + ".mesh",
-      Ogre::Vector3(
-        28.554688 + 5 * (enemies_.size() - 1), 214.312500 + 10 * (enemies_.size() - 1), 2.421875
-      ), Ogre::Degree(0), Ogre::Vector3(0.0015, 0.0015, 0.0015), id, visible
-    );*/
 }
 
 void BattleManager::AddCamera(
   const unsigned int id, const Ogre::Vector3 pos, const Ogre::Vector3 dir
 ){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR(
+          "Tried to add a camera to the BattleManager, but the manager was not in battle mode."
+        );
+        return;
+    }
     BattleCamera camera;
     camera.id = id;
     camera.location = pos;
@@ -119,87 +173,87 @@ void BattleManager::AddCamera(
     camera_.push_back(camera);
 }
 
-void BattleManager::Input(const VGears::Event& event){
-    // TODO: Change to battle input commands.
-    //background_2d_.InputDebug(event);
-    if (paused_ == true) return;
-    //if (event.type == VGears::ET_KEY_PRESS && event.event == "interact"){
-        // TODO
-    //}
-}
-
-void BattleManager::Update(){
-    UpdateDebug();
-    if (paused_ == true) return;
-
-    // TODO: Update all entity scripts
-    // for (unsigned int i = 0; i < party_.size(); ++ i) party_[i]->Update();
-    // for (unsigned int i = 0; i < enemy_.size(); ++ i) enemy_[i]->Update();
-    // TODO: Environment model update
-}
-
-void BattleManager::UpdateDebug(){
-    // TODO: Update all entity scripts
-    // for (unsigned int i = 0; i < party_.size(); ++ i) party_[i]->UpdateDebug();
-    // for (unsigned int i = 0; i < enemy_.size(); ++ i) enemy_[i]->UpdateDebug();
-    // TODO: Environment model update
-}
-
-void BattleManager::Clear(){
-    paused_ = false;
-    formation_id_ = -1;
-    next_formation_id_ = -1;
-    // TODO location_ = null;
-    // TODO camera_.clear();
-    initial_camera_ = 0;
-    layout_ = LAYOUT::NORMAL;
-    escape_difficulty_ = 0.0f;
-    arena_battle_ = false;
-    show_victory_pose_ = true;
-    show_spoils_ = true;
-    preemptive_ = true;
-    money_ = 0;
-    spoil_.clear();
-    // TODO enemy_.clear();
-    // TODO party_.clear();
-    scene_node_->removeAndDestroyAllChildren();
-}
-
-void BattleManager::ScriptSetPaused(const bool paused){paused_ = paused;}
-
 void BattleManager::SetLayout(const LAYOUT layout){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set a layout the BattleManager, but it's not in battle mode.");
+        return;
+    }
     if (layout == LAYOUT::UNKNOWN_0 || layout == LAYOUT::UNKNOWN_1) layout_ = LAYOUT::NORMAL;
     else layout_ = layout;
 }
 
 void BattleManager::SetFormationId(const int id){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set formation int the BattleManager, but it's not in battle mode.");
+        return;
+    }
     if (id < 0) formation_id_ = -1;
     else formation_id_ = id;
 }
 
 void BattleManager::SetNextFormationId(const int id){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set next formation in the BattleManager, but it's not in battle mode.");
+        return;
+    }
     if (id < 0) next_formation_id_ = -1;
     else next_formation_id_ = id;
 }
 
 void BattleManager::SetEscapeability(const float difficulty){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set escapability in the BattleManager, but it's not in battle mode.");
+        return;
+    }
     if (difficulty < 0.0f || difficulty > 1.0f) escape_difficulty_ = -1.0f;
     else escape_difficulty_ = difficulty;
 }
 
-void BattleManager::SetSkipVictoryPose(const bool skip){show_victory_pose_ = !skip;}
+void BattleManager::SetSkipVictoryPose(const bool skip){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set pose mode in the BattleManager, but it's not in battle mode.");
+        return;
+    }
+    show_victory_pose_ = !skip;
+}
 
-void BattleManager::SetSkipSpoils(const bool skip){show_spoils_ = !skip;}
+void BattleManager::SetSkipSpoils(const bool skip){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set spoils mode in the BattleManager, but it's not in battle mode.");
+        return;
+    }
+    show_spoils_ = !skip;
+}
 
 void BattleManager::SetLocation(const int id, const Ogre::String name){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set a location in the BattleManager, but it's not in battle mode.");
+        return;
+    }
     // TODO
 }
 
-void BattleManager::SetArenaBattle(const bool arena){arena_battle_ = arena;}
+void BattleManager::SetArenaBattle(const bool arena){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set arena info in the BattleManager, but it's not in battle mode.");
+        return;
+    }
+    arena_battle_ = arena;
+}
 
-void BattleManager::SetInitialCamera(const unsigned int id){initial_camera_ = id;}
+void BattleManager::SetInitialCamera(const unsigned int id){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to set the camera in the BattleManager, but it's not in battle mode.");
+        return;
+    }
+    initial_camera_ = id;
+}
 
 void BattleManager::LoadParty(){
+    if (module_ != Module::BATTLE){
+        LOG_ERROR("Tried to load party in the BattleManager, but it's not in battle mode.");
+        return;
+    }
     std::vector<int> positions {0, 1, 2};
     Ogre::Vector3 position = Ogre::Vector3(0, 5, 0);
     // Randomize party member positions.
@@ -219,10 +273,15 @@ void BattleManager::LoadParty(){
     }
 
     EntityManager::getSingleton().AddBattleEntity(
-          "center",
-          "models/fields/entities/avfe.mesh", position, Ogre::Degree(0),
-          //Ogre::Vector3(MODEL_SCALE, MODEL_SCALE, MODEL_SCALE), 100 + i, true
-          Ogre::Vector3(0.01, 0.01, 0.01), 999, true
-        );
+      "center", "models/fields/entities/avfe.mesh", position, Ogre::Degree(0),
+      //Ogre::Vector3(MODEL_SCALE, MODEL_SCALE, MODEL_SCALE), 100 + i, true
+      Ogre::Vector3(0.01, 0.01, 0.01), 999, true
+    );
 
 }
+
+void BattleManager::UpdateField(){}
+
+void BattleManager::UpdateBattle(){}
+
+void BattleManager::UpdateWorld(){}

+ 57 - 37
src/core/BattleManager.h

@@ -18,11 +18,12 @@
 #include <OgreSingleton.h>
 #include "Enemy.h"
 #include "Event.h"
+#include "Manager.h"
 
 /**
  * The battle manager.
  */
-class BattleManager : public Ogre::Singleton<BattleManager>{
+class BattleManager : public Manager, public Ogre::Singleton<BattleManager>{
 
     public:
 
@@ -156,6 +157,42 @@ class BattleManager : public Ogre::Singleton<BattleManager>{
          */
         virtual ~BattleManager();
 
+        /**
+         * Handles an input event.
+         *
+         * @param[in] event Event to handle.
+         */
+        void Input(const VGears::Event& event) override;
+
+        /**
+         * Updates the battle in the manager with debug information.
+         *
+         * It's automatically called from {@see Update}.
+         */
+        void UpdateDebug() override;
+
+        /**
+         * Handles resizing events
+         */
+        void OnResize() override;
+
+        /**
+         * Clears all field information in the battle manager.
+         *
+         * Does nothing.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle information in the battle manager.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map information in the battle manager.
+         */
+        void ClearWorld() override;
+
         /**
          * Starts a battle.
          *
@@ -191,42 +228,11 @@ class BattleManager : public Ogre::Singleton<BattleManager>{
           const bool targeteable, const bool active, const std::string cover
         );
 
-        /**
-         * Handles an input event.
-         *
-         * @param[in] event Event to handle.
-         */
-        void Input(const VGears::Event& event);
-
         /**
          * Loads enemy info from the enemy XML enemy file.
          */
         void Load();
 
-        /**
-         * Updates the entities in the manager.
-         */
-        void Update();
-
-        /**
-         * Updates the entities in the manager with debug information.
-         *
-         * It's automatically called from {@see Update}.
-         */
-        void UpdateDebug();
-
-        /**
-         * Clears the entity manager.
-         */
-        void Clear();
-
-        /**
-         * Pauses or resumes the battle.
-         *
-         * @param[in] paused True to pause, false to resume.
-         */
-        void ScriptSetPaused(const bool paused);
-
         /**
          * Sets the battle layout.
          *
@@ -314,6 +320,25 @@ class BattleManager : public Ogre::Singleton<BattleManager>{
          */
         void LoadParty();
 
+        /**
+         * Updates the manager while in the field.
+         *
+         * It does nothing
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the manager during a battle.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates manager while in the world map.
+         *
+         * It does nothing
+         */
+        void UpdateWorld() override;
+
         /**
          * Scale factor for all battle models.
          */
@@ -324,11 +349,6 @@ class BattleManager : public Ogre::Singleton<BattleManager>{
          */
         Ogre::SceneNode* scene_node_;
 
-        /**
-         * Indicates if the script execution is paused.
-         */
-        bool paused_;
-
         /**
          * The current battle formation ID.
          */

+ 38 - 71
src/core/CameraManager.cpp

@@ -33,7 +33,6 @@ ConfigVar cv_cam_speed("camera_speed", "Camera speed", "0.02");
 template<>CameraManager* Ogre::Singleton<CameraManager>::msSingleton = nullptr;
 
 CameraManager::CameraManager():
-  battle_(false),
   camera_free_(false),
   camera_free_rotate_(false),
   d2_position_(Ogre::Vector3::ZERO),
@@ -71,73 +70,45 @@ CameraManager::CameraManager():
 
 CameraManager::~CameraManager(){LOG_TRIVIAL("CameraManager finished.");}
 
-void CameraManager::Input(
-  const VGears::Event& event, Ogre::Real time_since_last_frame
-){
+void CameraManager::Input(const VGears::Event& event){}
+
+void CameraManager::Input(const VGears::Event& event, Ogre::Real time_since_last_frame){
     if (camera_free_ == true){
         float speed = cv_cam_speed.GetF() * time_since_last_frame;
         if(
           InputManager::getSingleton().IsButtonPressed(OIS::KC_RSHIFT)
           || InputManager::getSingleton().IsButtonPressed(OIS::KC_LSHIFT)
-        ){
-            speed *= 4;
-        }
+        ) speed *= 4;
 
         Ogre::SceneNode* rootScene =
-          Ogre::Root::getSingleton().getSceneManager("Scene")
-            ->getRootSceneNode();
+          Ogre::Root::getSingleton().getSceneManager("Scene") ->getRootSceneNode();
 
         if (event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_W){
             //camera_->moveRelative(Ogre::Vector3(0, 0, -speed));
-            rootScene->translate(
-              Ogre::Vector3(0, 0, -speed), Ogre::Node::TS_LOCAL
-            );
+            rootScene->translate(Ogre::Vector3(0, 0, -speed), Ogre::Node::TS_LOCAL);
         }
-        else if (
-          event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_A
-        ){
+        else if (event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_A){
             //camera_->moveRelative(Ogre::Vector3(-speed, 0, 0));
-            rootScene->translate(
-              Ogre::Vector3(-speed, 0, 0), Ogre::Node::TS_LOCAL
-            );
+            rootScene->translate(Ogre::Vector3(-speed, 0, 0), Ogre::Node::TS_LOCAL);
         }
-        else if (
-          event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_S
-        ){
+        else if (event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_S){
             //camera_->moveRelative(Ogre::Vector3(0, 0, speed));
-            rootScene->translate(
-              Ogre::Vector3(0, 0, speed), Ogre::Node::TS_LOCAL
-            );
+            rootScene->translate(Ogre::Vector3(0, 0, speed), Ogre::Node::TS_LOCAL);
         }
-        else if (
-          event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_D
-        ){
+        else if (event.type == VGears::ET_KEY_IMPULSE && event.param1 == OIS::KC_D){
             //camera_->moveRelative(Ogre::Vector3(speed, 0, 0));
-            rootScene->translate(
-              Ogre::Vector3(speed, 0, 0), Ogre::Node::TS_LOCAL
-            );
+            rootScene->translate(Ogre::Vector3(speed, 0, 0), Ogre::Node::TS_LOCAL);
         }
-        else if (
-          event.type == VGears::ET_MOUSE_PRESS && event.param1 == OIS::MB_Right
-        ){
+        else if (event.type == VGears::ET_MOUSE_PRESS && event.param1 == OIS::MB_Right)
             camera_free_rotate_ = true;
-        }
-        else if (
-          event.type == VGears::ET_MOUSE_RELEASE
-          && event.param1 == OIS::MB_Right
-        ){
+        else if (event.type == VGears::ET_MOUSE_RELEASE && event.param1 == OIS::MB_Right)
             camera_free_rotate_ = false;
-        }
-        else if (
-          event.type == VGears::ET_MOUSE_MOVE && camera_free_rotate_ == true
-        ){
+        else if (event.type == VGears::ET_MOUSE_MOVE && camera_free_rotate_ == true){
             //camera_->rotate(
-            //  Ogre::Vector3::UNIT_Z,
-            //  Ogre::Radian(Ogre::Degree(-event.param1 * 0.13f))
+            //  Ogre::Vector3::UNIT_Z, Ogre::Radian(Ogre::Degree(-event.param1 * 0.13f))
             //);
             rootScene->rotate(
-              Ogre::Vector3::UNIT_Z,
-              Ogre::Radian(Ogre::Degree(-event.param1 * 0.13f))
+              Ogre::Vector3::UNIT_Z, Ogre::Radian(Ogre::Degree(-event.param1 * 0.13f))
             );
             //camera_->pitch(Ogre::Degree(-event.param2 * 0.13f));
             rootScene->pitch(Ogre::Degree(-event.param2 * 0.13f));
@@ -145,15 +116,20 @@ void CameraManager::Input(
     }
 }
 
-void CameraManager::Update(){}
-
 void CameraManager::OnResize(){
     camera_->setAspectRatio(
-      Ogre::Real(viewport_->getActualWidth())
-      / Ogre::Real(viewport_->getActualHeight())
+      Ogre::Real(viewport_->getActualWidth()) / Ogre::Real(viewport_->getActualHeight())
     );
 }
 
+void CameraManager::UpdateDebug(){}
+
+void CameraManager::ClearField(){}
+
+void CameraManager::ClearBattle(){}
+
+void CameraManager::ClearWorld(){}
+
 void CameraManager::SetCameraFree(const bool enable){
     camera_free_ = enable;
     if (camera_free_ == true){
@@ -183,8 +159,7 @@ void CameraManager::SetCameraFree(const bool enable){
 
 
 void CameraManager::Set2DCamera(
-  const Ogre::Vector3 position,
-  const Ogre::Quaternion orientation, const Ogre::Radian fov
+  const Ogre::Vector3 position, const Ogre::Quaternion orientation, const Ogre::Radian fov
 ){
     d2_position_ = position;
     d2_orientation_ = orientation;
@@ -193,9 +168,7 @@ void CameraManager::Set2DCamera(
     CameraManager::getSingleton().GetCurrentCamera()->setPosition(d2_position_);
     //Ogre::Root::getSingleton().getSceneManager("Scene")
     //  ->getRootSceneNode()->setPosition(d2_position_);
-    CameraManager::getSingleton().GetCurrentCamera()->setOrientation(
-      d2_orientation_
-    );
+    CameraManager::getSingleton().GetCurrentCamera()->setOrientation(d2_orientation_);
     //Ogre::Root::getSingleton().getSceneManager("Scene")
     //  ->getRootSceneNode()->setOrientation(d2_orientation_);
     CameraManager::getSingleton().GetCurrentCamera()->setFOVy(d2_fov_);
@@ -205,17 +178,15 @@ void CameraManager::Set2DCamera(
 void CameraManager::StartBattleCamera(
   const Ogre::Vector3 position, const Ogre::Vector3 orientation
 ){
-    if (battle_){
+    if (module_ != Module::BATTLE){
         LOG_ERROR("Tried to start battle camera but the CameraManager is already in battle mode");
         return;
     }
-    battle_ = true;
     std::cout << "CAMERA BATTLE START: " << camera_->getPosition().x << ", " << camera_->getPosition().y << ", " << camera_->getPosition().z << ", "
         << camera_->getOrientation().w << ", "<< camera_->getOrientation().x << ", " << camera_->getOrientation().y << ", "
         << camera_->getOrientation().z << std::endl;
     position_backup_ = Ogre::Vector3(
-      camera_->getPosition().x, camera_->getPosition().y,
-      camera_->getPosition().z
+      camera_->getPosition().x, camera_->getPosition().y, camera_->getPosition().z
     );
     orientation_backup_ = Ogre::Quaternion(
       camera_->getOrientation().w, camera_->getOrientation().x,
@@ -223,7 +194,6 @@ void CameraManager::StartBattleCamera(
     );
     camera_->setPosition(position);
     //CameraManager::getSingleton().GetCurrentCamera()->setFixedYawAxis(true, Ogre::Vector3::UNIT_Y);
-    camera_->lookAt(Ogre::Vector3(orientation.x, orientation.y, camera_->getPosition().z));
     camera_->lookAt(orientation);
 
 
@@ -233,11 +203,6 @@ void CameraManager::StartBattleCamera(
 }
 
 void CameraManager::EndBattleCamera(){
-    if (!battle_){
-        LOG_ERROR("Tried to end battle camera but the CameraManager is not in battle mode");
-        return;
-    }
-    battle_ = false;
         std::cout << "CAMERA BATTLE END: " << camera_->getPosition().x << ", " << camera_->getPosition().y << ", " << camera_->getPosition().z << ", "
             << camera_->getOrientation().w << ", "<< camera_->getOrientation().x << ", " << camera_->getOrientation().y << ", "
             << camera_->getOrientation().z << std::endl;
@@ -267,16 +232,12 @@ void CameraManager::Set2DScroll(const Ogre::Vector2& position){
     bottom = frustrumRect.bottom;
     float move_x = ((right - left) / width) * position.x;
     float move_y = ((bottom - top) / height) * -position.y;
-    camera_->setFrustumExtents(
-      left - move_x, right - move_x, top + move_y, bottom + move_y
-    );
+    camera_->setFrustumExtents(left - move_x, right - move_x, top + move_y, bottom + move_y);
 }
 
 const Ogre::Vector2& CameraManager::Get2DScroll() const{return d2_scroll_;}
 
-const Ogre::Vector3 CameraManager::ProjectPointToScreen(
-  const Ogre::Vector3& point
-){
+const Ogre::Vector3 CameraManager::ProjectPointToScreen(const Ogre::Vector3& point){
     Ogre::Vector3 view = camera_->getViewMatrix() * point;
     float z = view.z;
     view = camera_->getProjectionMatrix() * view;
@@ -317,3 +278,9 @@ void CameraManager::ScriptSetCamera(
     camera_->lookAt(Ogre::Vector3(d_x, d_y, camera_->getPosition().z));
     camera_->lookAt(Ogre::Vector3(d_x, d_y, d_z));
 }
+
+void CameraManager::UpdateField(){}
+
+void CameraManager::UpdateBattle(){}
+
+void CameraManager::UpdateWorld(){}

+ 42 - 11
src/core/CameraManager.h

@@ -18,11 +18,12 @@
 #include <OgreCamera.h>
 #include <OgreSingleton.h>
 #include "Event.h"
+#include "Manager.h"
 
 /**
  * The camera manager.
  */
-class CameraManager : public Ogre::Singleton<CameraManager>{
+class CameraManager : public Manager, public Ogre::Singleton<CameraManager>{
 
     public:
 
@@ -45,25 +46,45 @@ class CameraManager : public Ogre::Singleton<CameraManager>{
          * Handles the scene manager camera actions based on events.
          *
          * @param[in] event Event that triggers the camera action.
-         * @param[in] time_since_last_frame For speed calculation.
          */
-        void Input(
-          const VGears::Event& event , Ogre::Real time_since_last_frame
-        );
+        void Input(const VGears::Event& event) override;
 
         /**
-         * Triggered when updated.
+         * Handles camera actions.
          *
-         * Unused.
+         * Handles the scene manager camera actions based on events.
+         *
+         * @param[in] event Event that triggers the camera action.
+         * @param[in] time_since_last_frame For speed calculation.
          */
-        void Update();
+        void Input(const VGears::Event& event , Ogre::Real time_since_last_frame);
 
         /**
          * Trigered when the viewport is resized.
          *
          * Resets the aspect ratio.
          */
-        void OnResize();
+        void OnResize() override;
+
+        /**
+         * Updates debug information.
+         */
+        void UpdateDebug() override;
+
+        /**
+         * Clears all field information in the camera manager.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle information in the camera manager.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map information in the camera manager.
+         */
+        void ClearWorld() override;
 
         /**
          * Enables or disables the free camera.
@@ -184,9 +205,19 @@ class CameraManager : public Ogre::Singleton<CameraManager>{
         void InitCommands();
 
         /**
-         * Indicates if the camera is in battle mode.
+         * Updates while the camera is in the field.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates while the camera is in battle.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates while the camera is in the world map.
          */
-        bool battle_;
+        void UpdateWorld() override;
 
         /**
          * The camera.

+ 2 - 2
src/core/CameraManagerCommands.h

@@ -17,7 +17,7 @@
 
 #include <OgreStringConverter.h>
 #include "CameraManager.h"
-#include "ConfigCmdManager.h"
+#include "ConfigCmdHandler.h"
 #include "Console.h"
 
 void CommandCameraFree(const Ogre::StringVector& params){
@@ -36,7 +36,7 @@ void CommandCameraFreeCompletition( Ogre::StringVector& complete_params ){
 }
 
 void CameraManager::InitCommands(){
-    ConfigCmdManager::getSingleton().AddCommand(
+    ConfigCmdHandler::getSingleton().AddCommand(
       "camera_free", "Enable or disable free camera", "",
       CommandCameraFree, CommandCameraFreeCompletition
     );

+ 5 - 7
src/core/ConfigCmd.cpp

@@ -17,23 +17,21 @@
 
 ConfigCmd::ConfigCmd(
   const Ogre::String& name, const Ogre::String& description,
-  const Ogre::String& params_description, ConfigCmdHandler handler,
+  const Ogre::String& params_description, ConfigCmdParams params,
   ConfigCmdCompletion completion):
     name_(name),
     description_(description),
     params_description_(params_description),
-    handler_(handler),
+    params_(params),
     completion_(completion)
 {}
 
 const Ogre::String& ConfigCmd::GetName() const{return name_;}
 
-const Ogre::String& ConfigCmd::GetDescription() const{ return description_;}
+const Ogre::String& ConfigCmd::GetDescription() const{return description_;}
 
-const Ogre::String& ConfigCmd::GetParamsDescription() const{
-    return params_description_;
-}
+const Ogre::String& ConfigCmd::GetParamsDescription() const{return params_description_;}
 
-ConfigCmdHandler ConfigCmd::GetHandler() const{return handler_;}
+ConfigCmdParams ConfigCmd::GetHandler() const{return params_;}
 
 ConfigCmdCompletion ConfigCmd::GetCompletion() const{return completion_;}

+ 8 - 8
src/core/ConfigCmd.h

@@ -18,9 +18,9 @@
 #include <OgreString.h>
 #include <OgreStringVector.h>
 
-class ConfigCmdManager;
+class ConfigCmdHandler;
 
-typedef void (*ConfigCmdHandler)(const Ogre::StringVector& params);
+typedef void (*ConfigCmdParams)(const Ogre::StringVector& params);
 
 typedef void (*ConfigCmdCompletion)(Ogre::StringVector& complete_params);
 
@@ -30,7 +30,7 @@ typedef void (*ConfigCmdCompletion)(Ogre::StringVector& complete_params);
  */
 class ConfigCmd{
 
-    friend class ConfigCmdManager;
+    friend class ConfigCmdHandler;
 
     public:
 
@@ -42,12 +42,12 @@ class ConfigCmd{
          * @param[in] name Command name.
          * @param[in] description Command description.
          * @param[in] params_description Command parameters description.
-         * @param[in] handler Command handler.
+         * @param[in] params Command parameter handler.
          * @param[in] completion Command completion.
          */
         ConfigCmd(
           const Ogre::String& name, const Ogre::String& description,
-          const Ogre::String& params_description, ConfigCmdHandler handler,
+          const Ogre::String& params_description, ConfigCmdParams params,
           ConfigCmdCompletion completion
         );
 
@@ -77,7 +77,7 @@ class ConfigCmd{
          *
          * @return The command parameter description.
          */
-        ConfigCmdHandler GetHandler() const;
+        ConfigCmdParams GetHandler() const;
 
         /**
          * Checks the command completion
@@ -118,9 +118,9 @@ class ConfigCmd{
         Ogre::String params_description_;
 
         /**
-         * The command handler.
+         * The command parameter handler.
          */
-        ConfigCmdHandler handler_;
+        ConfigCmdParams params_;
 
         /**
          * The command completion.

+ 14 - 13
src/core/ConfigCmdManager.cpp → src/core/ConfigCmdHandler.cpp

@@ -13,44 +13,45 @@
  * GNU General Public License for more details.
  */
 
+#include "ConfigCmdHandler.h"
+
 #include "core/Assert.h"
-#include "core/ConfigCmdManager.h"
-#include "core/ConfigCmdManagerCommands.h"
+#include "ConfigCmdHandlerCommands.h"
 
 /**
  * Configuration manager singleton.
  */
-template<>ConfigCmdManager *Ogre::Singleton<ConfigCmdManager>::msSingleton = nullptr;
+template<>ConfigCmdHandler *Ogre::Singleton<ConfigCmdHandler>::msSingleton = nullptr;
 
-ConfigCmdManager::ConfigCmdManager(){InitCmd();}
+ConfigCmdHandler::ConfigCmdHandler(){InitCmd();}
 
-ConfigCmdManager::~ConfigCmdManager(){}
+ConfigCmdHandler::~ConfigCmdHandler(){}
 
-void ConfigCmdManager::AddCommand(
+void ConfigCmdHandler::AddCommand(
   const Ogre::String& name, const Ogre::String& description, const Ogre::String& params_description,
-  ConfigCmdHandler handler, ConfigCmdCompletion completion
+  ConfigCmdParams params, ConfigCmdCompletion completion
 ){
     VGEARS_ASSERT(name != "", "Command name shouldn't be empty.");
-    VGEARS_ASSERT(handler, "Null command handler.");
+    VGEARS_ASSERT(params, "Null command parameter list.");
     // Check if command already added
     for (unsigned int i = 0; i < commands_.size(); ++ i)
         VGEARS_ASSERT(commands_[i]->GetName() != name, "Command already exist.");
     commands_.emplace_back(std::make_unique<ConfigCmd>(
-      name, description, params_description, handler, completion
+      name, description, params_description, params, completion
     ));
 }
 
-void ConfigCmdManager::ExecuteString(const Ogre::String& cmd_string){}
+void ConfigCmdHandler::ExecuteString(const Ogre::String& cmd_string){}
 
-ConfigCmd* ConfigCmdManager::Find(const Ogre::String& name) const{
+ConfigCmd* ConfigCmdHandler::Find(const Ogre::String& name) const{
     for (unsigned int i = 0; i < commands_.size(); ++ i)
         if (commands_[i]->GetName() == name) return commands_[i].get();
     return nullptr;
 }
 
-int ConfigCmdManager::GetConfigCmdNumber(){return commands_.size();}
+int ConfigCmdHandler::GetConfigCmdNumber(){return commands_.size();}
 
-ConfigCmd* ConfigCmdManager::GetConfigCmd(unsigned int i) const{
+ConfigCmd* ConfigCmdHandler::GetConfigCmd(unsigned int i) const{
     if (i < commands_.size()) return commands_[i].get();
     return nullptr;
 }

+ 10 - 11
src/core/ConfigCmdManager.h → src/core/ConfigCmdHandler.h

@@ -21,21 +21,21 @@
 #include "ConfigCmd.h"
 
 /**
- * A manager for configuration commands.
+ * A handler for configuration commands.
  */
-class ConfigCmdManager : public Ogre::Singleton<ConfigCmdManager>{
+class ConfigCmdHandler : public Ogre::Singleton<ConfigCmdHandler>{
 
     public:
 
         /**
          * Constructor.
          */
-        ConfigCmdManager();
+        ConfigCmdHandler();
 
         /**
          * Destructor.
          */
-        ~ConfigCmdManager();
+        ~ConfigCmdHandler();
 
         /**
          * Adds a command to the manager.
@@ -43,12 +43,12 @@ class ConfigCmdManager : public Ogre::Singleton<ConfigCmdManager>{
          * @param[in] name Command name.
          * @param[in] description Command description.
          * @param[in] params_description Command parameters description.
-         * @param[in] handler Command handler.
-         * @param[in] completion Command completion.
+         * @param[in] params Command parameter list.
+         * @param[in] completion Command completion list.
          */
         void AddCommand(
           const Ogre::String& name, const Ogre::String& description,
-          const Ogre::String& params_description, ConfigCmdHandler handler,
+          const Ogre::String& params_description, ConfigCmdParams params,
           ConfigCmdCompletion completion
         );
 
@@ -77,8 +77,7 @@ class ConfigCmdManager : public Ogre::Singleton<ConfigCmdManager>{
         /**
          * Retrieves a command by index.
          *
-         * A command index is the position at which it was added to the
-         * manager.
+         * A command index is the position at which it was added to the manager.
          */
         ConfigCmd* GetConfigCmd(unsigned int i) const;
 
@@ -89,14 +88,14 @@ class ConfigCmdManager : public Ogre::Singleton<ConfigCmdManager>{
          *
          * @param[in] rhs Manager to not copy.
          */
-        ConfigCmdManager(const ConfigCmdManager& rhs) = delete;
+        ConfigCmdHandler(const ConfigCmdHandler& rhs) = delete;
 
         /**
          * Forbidden copy constructor.
          *
          * @param[in] rhs Manager to not copy.
          */
-        ConfigCmdManager operator =(const ConfigCmdManager& rhs) = delete;
+        ConfigCmdHandler operator =(const ConfigCmdHandler& rhs) = delete;
 
         /**
          * Initializes the command.

+ 77 - 115
src/core/ConfigCmdManagerCommands.h → src/core/ConfigCmdHandlerCommands.h

@@ -19,14 +19,14 @@
 #include <OgreRoot.h>
 #include <OgreStringConverter.h>
 #include "Console.h"
-#include "ConfigCmdManager.h"
-#include "ConfigVarManager.h"
 #include "EntityManager.h"
 #include "Logger.h"
 #include "XmlMapFile.h"
 #include "XmlMapsFile.h"
 #include "VGearsGameState.h"
 #include "common/VGearsApplication.h"
+#include "ConfigCmdHandler.h"
+#include "ConfigVarHandler.h"
 
 /**
  * Command to quit the application.
@@ -40,8 +40,8 @@ void CmdQuit(const Ogre::StringVector& params){
 /**
  * Command to print to console.
  *
- * @param[in] params Command parameters. All of them will be concatenated and
- * printed. If none are supplied, a command usage text will be printed instead.
+ * @param[in] params Command parameters. All of them will be concatenated and printed. If none are
+ * supplied, a command usage text will be printed instead.
  */
 void CmdEcho(const Ogre::StringVector& params){
     if (params.size() < 1){
@@ -61,23 +61,21 @@ void CmdEcho(const Ogre::StringVector& params){
 /**
  * Searches variables in the variable list and prints them.
  *
- * @param[in] params Command parameters. The first one is the command name. If
- * no more are passed, all variables will be printed. If another parameter is
- * passed, the variables with that name (if any) will be printed. If more than
- * two parameter are passed, a command usage string will be printed instead.
+ * @param[in] params Command parameters. The first one is the command name. If no more are passed,
+ * all variables will be printed. If another parameter is passed, the variables with that name (if
+ * any) will be printed. If more than two parameter are passed, a command usage string will be
+ * printed instead.
  */
 void CmdConfigVarList(const Ogre::StringVector& params){
     if (params.size() > 2){
-        Console::getSingleton().AddTextToOutput(
-          "Usage: /config_var_list [search string]"
-       );
+        Console::getSingleton().AddTextToOutput("Usage: /config_var_list [search string]");
         return;
     }
 
     int number = 0;
-    int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
+    int num_vars = ConfigVarHandler::getSingleton().GetConfigVarNumber();
     for (int i = 0; i < num_vars; ++ i){
-        ConfigVar* var = ConfigVarManager::getSingleton().GetConfigVar(i);
+        ConfigVar* var = ConfigVarHandler::getSingleton().GetConfigVar(i);
         Ogre::String name = var->GetName();
 
         if (params.size() > 1){
@@ -86,14 +84,12 @@ void CmdConfigVarList(const Ogre::StringVector& params){
                 Console::getSingleton().AddTextToOutput(
                   var->GetName() + " = \"" + var->GetS() + "\""
                );
-                ++number;
+                ++ number;
             }
         }
         else{
-            Console::getSingleton().AddTextToOutput(
-              var->GetName() + " = \"" + var->GetS() + "\""
-           );
-            ++number;
+            Console::getSingleton().AddTextToOutput(var->GetName() + " = \"" + var->GetS() + "\"");
+            ++ number;
         }
     }
     Console::getSingleton().AddTextToOutput(
@@ -104,33 +100,31 @@ void CmdConfigVarList(const Ogre::StringVector& params){
 /**
  * Searches the command list and prints the comands.
  *
- * @param[in] params Command parameters. The first one is the command name. If
- * no more is passed, all commands will be printed. If another parameter is
- * passed, the command with that name (if any) will be printed. If more than
- * two parameter are passed, a command usage string will be printed instead.
+ * @param[in] params Command parameters. The first one is the command name. If no more is passed,
+ * all commands will be printed. If another parameter is passed, the command with that name (if
+ * any) will be printed. If more than two parameter are passed, a command usage string will be
+ * printed instead.
  */
 void CmdConfigCmdList(const Ogre::StringVector& params){
     if (params.size() > 2){
-        Console::getSingleton().AddTextToOutput(
-          "Usage: /config_cmd_list [search string]"
-       );
+        Console::getSingleton().AddTextToOutput("Usage: /config_cmd_list [search string]");
         return;
     }
     int number = 0;
-    int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+    int num_cmds = ConfigCmdHandler::getSingleton().GetConfigCmdNumber();
     for (int i = 0; i < num_cmds; ++ i){
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().GetConfigCmd(i);
+        ConfigCmd* cmd = ConfigCmdHandler::getSingleton().GetConfigCmd(i);
         Ogre::String name = cmd->GetName();
         if (params.size() > 1){
             int found = name.find(params[1]);
             if (found == 0){
                 Console::getSingleton().AddTextToOutput(cmd->GetName());
-                ++number;
+                ++ number;
             }
         }
         else{
             Console::getSingleton().AddTextToOutput(cmd->GetName());
-            ++number;
+            ++ number;
         }
     }
     Console::getSingleton().AddTextToOutput(
@@ -141,24 +135,20 @@ void CmdConfigCmdList(const Ogre::StringVector& params){
 /**
  * Sets the value of a configuration value.
  *
- * @param[in] params Command parameters. The first one is the command name. The
- * second one is a variable name. The third one is optional and is a value for
- * the variable. If a value is supplied, the variable will be given that value.
- * If not, the variable will be reset to it's default value. If there is no
- * variable by that name, nothing will be done. In any case, a feddback will be
- * printed to console. If less than two or more than three parameters are
- * passed, a usage text wil be printed and nothing will be done.
+ * @param[in] params Command parameters. The first one is the command name. The second one is a
+ * variable name. The third one is optional and is a value for the variable. If a value is supplied,
+ * the variable will be given that value. If not, the variable will be reset to it's default value.
+ * If there is no variable by that name, nothing will be done. In any case, a feedback will be
+ * printed to console. If less than two or more than three parameters are passed, a usage text will
+ * be printed and nothing will be done.
  */
-void CmdSetConfigVar(const Ogre::StringVector& params)
-{
+void CmdSetConfigVar(const Ogre::StringVector& params){
     if (params.size() < 2 || params.size() > 3){
-        Console::getSingleton().AddTextToOutput(
-          "Usage: /set <config variable> [value]"
-       );
+        Console::getSingleton().AddTextToOutput("Usage: /set <config variable> [value]");
         return;
     }
     Ogre::String name = params[1];
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(name);
+    ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
     if (cvar == NULL){
         LOG_ERROR("Config variable \"" + name + "\" not found.");
         return;
@@ -166,28 +156,23 @@ void CmdSetConfigVar(const Ogre::StringVector& params)
     if (params.size() == 3){
         cvar->SetS(params[2]);
         Console* console = Console::getSingletonPtr();
-        if (console != NULL)
-            LOG_TRIVIAL(params[1] + " changed to \"" + params[2] + "\".");
+        if (console != NULL) LOG_TRIVIAL(params[1] + " changed to \"" + params[2] + "\".");
     }
     else{
         // Reset to default
         cvar->SetS(cvar->GetDefaultValue());
-        LOG_TRIVIAL(
-          params[1] + " changed to default \""
-          + cvar->GetDefaultValue() + "\"."
-       );
+        LOG_TRIVIAL(params[1] + " changed to default \"" + cvar->GetDefaultValue() + "\".");
     }
 }
 
 /**
  * Changes the value of a configuration value conditionally.
  *
- * @param[in] params Command parameters. The first one is the command name. The
- * next ones are possible values for the variables. If the value of the
- * variable is the current one, the next one will be assigned. Once the value
- * is changed once, no more steps will be taken and the function will return.
- * If the last provided value is the current value of the variable, it will not
- * be changed.
+ * @param[in] params Command parameters. The first one is the command name. The next ones are
+ * possible values for the variables. If the value of the variable is the current one, the next one
+ * will be assigned. Once the value is changed once, no more steps will be taken and the function
+ * will return. If the last provided value is the current value of the variable, it will not be
+ * changed.
  */
 void CmdToggleConfigVar(const Ogre::StringVector& params){
     if (params.size() < 4){
@@ -196,7 +181,7 @@ void CmdToggleConfigVar(const Ogre::StringVector& params){
         return;
     }
     Ogre::String name = params[1];
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(name);
+    ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
     if (cvar == NULL){
         LOG_ERROR("Config variable \"" + name + "\" not found.");
         return;
@@ -219,14 +204,13 @@ void CmdToggleConfigVar(const Ogre::StringVector& params){
 /**
  * Increments the value of a configuration variable.
  *
- * @param[in] params Command parameters. Exactly five must be provided. The
- * first one is the command name. The second one is the variable to increment.
- * The third one is the minimum value the variable will take. The fourth one is
- * the maximum value the variable will take. The fifth value is the increment
- * to apply to the variable. The variable in the second parameter will be
- * incremented by the value in the fith one, but it will be capped between the
- * third and fourth one. If there are more or less than five parameters, a
- * usage text will be printed and nothing will be done.
+ * @param[in] params Command parameters. Exactly five must be provided. The first one is the command
+ * name. The second one is the variable to increment. The third one is the minimum value the
+ * variable will take. The fourth one is the maximum value the variable will take. The fifth value
+ * is the increment to apply to the variable. The variable in the second parameter will be
+ * incremented by the value in the fith one, but it will be capped between the third and fourth one.
+ * If there are more or less than five parameters, a usage text will be printed and nothing will be
+ * done.
  */
 void CmdIncrementConfigVar(const Ogre::StringVector& params){
     if (params.size() != 5){
@@ -236,7 +220,7 @@ void CmdIncrementConfigVar(const Ogre::StringVector& params){
         return;
     }
     Ogre::String name = params[1];
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(name);
+    ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(name);
     if (cvar == NULL){
         LOG_ERROR("Config variable \"" + name + "\" not found.");
         return;
@@ -254,17 +238,15 @@ void CmdIncrementConfigVar(const Ogre::StringVector& params){
 /**
  * Configures the log level.
  *
- * @param[in] params Command parameters. Exactly two must be provided. The
- * first one is the command name. The second one is the log level. Accepted
- * values are 1 (only errors), 2 (errors and warnings) and 3 (all). If there
- * are more or less than five parameters, a usage text will be printed and
- * nothing will be done.
+ * @param[in] params Command parameters. Exactly two must be provided. The first one is the command
+ * name. The second one is the log level. Accepted values are 1 (only errors), 2 (errors and
+ * warnings) and 3 (all). If there are more or less than five parameters, a usage text will be
+ * printed and nothing will be done.
  */
 void CmdSetLogLevel(const Ogre::StringVector& params){
     if (params.size() != 2){
         Console::getSingleton().AddTextToOutput(
-          "Usage: /log_level "
-          "<level: 1 - only errors, 2 - errors and warnings, 3 - all>"
+          "Usage: /log_level <level: 1 - only errors, 2 - errors and warnings, 3 - all>"
         );
         return;
     }
@@ -286,9 +268,7 @@ void CmdSetLogLevel(const Ogre::StringVector& params){
                 );
                 break;
             case 3:
-                Console::getSingleton().AddTextToOutput(
-                  "Logger level changed to \"all\".\n"
-                );
+                Console::getSingleton().AddTextToOutput("Logger level changed to \"all\".\n");
                 break;
         }
     }
@@ -303,10 +283,9 @@ void CmdSetLogLevel(const Ogre::StringVector& params){
 /**
  * Changes the game map.
  *
- * @param[in] params Command parameters. Exactly two must be provided. The
- * first one is the command name. The second one is the map ID. If there
- * are more or less than five parameters, a usage text will be printed and
- * nothing will be done.
+ * @param[in] params Command parameters. Exactly two must be provided. The first one is the command
+ * name. The second one is the map ID. If there are more or less than five parameters, a usage text
+ * will be printed and nothing will be done.
  */
 void CmdMap(const Ogre::StringVector& params){
     if (params.size() != 2){
@@ -333,11 +312,10 @@ void CmdMapCompletion(Ogre::StringVector& complete_params){
 /**
  * Sets the resolution and full screen mode.
  *
- * @param[in] params Command parameters. Three or four must be provided. The
- * first one is the command name. The second one is the resolution width. The
- * third one is the resolution height. The fourth one is optional and can be
- * used to toggle the full screen. "true", "yes" or 1 will set the game in full
- * screen mode. Anything else will set it to windowed mode.
+ * @param[in] params Command parameters. Three or four must be provided. The first one is the
+ * command name. The second one is the resolution width. The third one is the resolution height. The
+ * fourth one is optional and can be used to toggle the full screen. "true", "yes" or 1 will set the
+ * game in full screen mode. Anything else will set it to windowed mode.
  */
 void CmdResolution(const Ogre::StringVector& params){
     if (params.size() < 3){
@@ -349,15 +327,13 @@ void CmdResolution(const Ogre::StringVector& params){
     Ogre::RenderWindow* window = VGears::Application::getSingleton().getRenderWindow();
     if (params.size() >= 4){
         window->setFullscreen(
-          Ogre::StringConverter::parseBool(params[3]),
-          Ogre::StringConverter::parseInt(params[1]),
+          Ogre::StringConverter::parseBool(params[3]), Ogre::StringConverter::parseInt(params[1]),
           Ogre::StringConverter::parseInt(params[2])
         );
     }
     else{
         window->resize(
-          Ogre::StringConverter::parseInt(params[1]),
-          Ogre::StringConverter::parseInt(params[2])
+          Ogre::StringConverter::parseInt(params[1]), Ogre::StringConverter::parseInt(params[2])
         );
         window->getViewport(0)->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
     }
@@ -366,10 +342,9 @@ void CmdResolution(const Ogre::StringVector& params){
 /**
  * Loads a list of resolution modes.
  *
- * A resolution mode is represented by a string with the format "[w] [h] [f]",
- * where [w] is the resolution width, in pixels, [h] is the resolution height,
- * in pixels and [f] is the full screen state (0 for windowed mode, 1 for full
- * screen)
+ * A resolution mode is represented by a string with the format "[w] [h] [f]", where [w] is the
+ * resolution width, in pixels, [h] is the resolution height, in pixels and [f] is the full screen
+ * state (0 for windowed mode, 1 for full screen)
  *
  * @param[in] complete_params The resolution modes will be loaded here.
  */
@@ -392,10 +367,8 @@ void CmdResolutionCompletition(Ogre::StringVector& complete_params){
  * @param[in] params Command parameters. Unused.
  */
 void CmdScreenshot(const Ogre::StringVector& params){
-    Ogre::RenderWindow* window
-      = VGears::Application::getSingleton().getRenderWindow();
-    Ogre::String ret
-      = window->writeContentsToTimestampedFile("screenshot_", ".tga");
+    Ogre::RenderWindow* window = VGears::Application::getSingleton().getRenderWindow();
+    Ogre::String ret = window->writeContentsToTimestampedFile("screenshot_", ".tga");
     Console::getSingleton().AddTextToOutput("Screenshot " + ret + " saved.");
 }
 
@@ -452,40 +425,29 @@ void CmdViewerCompletion(Ogre::StringVector& complete_params){
 /**
  * Initializes all available commands.
  */
-void ConfigCmdManager::InitCmd(){
+void ConfigCmdHandler::InitCmd(){
     AddCommand("quit", "Stops application and quit", "", CmdQuit, NULL);
     AddCommand("echo", "Print command parameters", "", CmdEcho, NULL);
     AddCommand(
-      "config_var_list", "List of registered config variables",
-      "[<filter substring>]", CmdConfigVarList, NULL
+      "config_var_list", "List of registered config variables", "[<filter substring>]",
+      CmdConfigVarList, NULL
     );
     AddCommand(
       "config_cmd_list", "List of registered config commands",
       "[<filter substring>]", CmdConfigCmdList, NULL
     );
+    AddCommand("set", "Set cvar value", "<cvar name> [value]", CmdSetConfigVar, NULL);
     AddCommand(
-      "set", "Set cvar value", "<cvar name> [value]", CmdSetConfigVar, NULL
-    );
-    AddCommand(
-      "toggle", "Toggle cvar value",
-      "<cvar name> [value1] [value2] ...", CmdToggleConfigVar, NULL
+      "toggle", "Toggle cvar value", "<cvar name> [value1] [value2] ...", CmdToggleConfigVar, NULL
     );
     AddCommand(
-      "increment",
-      "Increment cvar value", "<cvar name> [value min] [value max] [step]",
+      "increment", "Increment cvar value", "<cvar name> [value min] [value max] [step]",
       CmdIncrementConfigVar, NULL
     );
-    AddCommand(
-      "set_log_level", "Set log messages level", "", CmdSetLogLevel, NULL
-    );
+    AddCommand("set_log_level", "Set log messages level", "", CmdSetLogLevel, NULL);
     AddCommand("map", "Run game module", "", CmdMap, CmdMapCompletion);
-    AddCommand(
-      "resolution", "Change resolution", "",
-      CmdResolution, CmdResolutionCompletition
-    );
-    AddCommand(
-      "screenshot", "Capture current screen content", "", CmdScreenshot, NULL
-    );
+    AddCommand("resolution", "Change resolution", "", CmdResolution, CmdResolutionCompletition);
+    AddCommand("screenshot", "Capture current screen content", "", CmdScreenshot, NULL);
     //AddCommand(
     //  "viewer", "Run viewer module", "", CmdViewer, CmdViewerCompletion
     //);

+ 3 - 3
src/core/ConfigFile.cpp

@@ -13,10 +13,10 @@
  * GNU General Public License for more details.
  */
 
-#include "core/ConfigCmdManager.h"
 #include "core/ConfigFile.h"
 #include "core/Logger.h"
 #include "core/Utilites.h"
+#include "ConfigCmdHandler.h"
 
 void ConfigFile::Execute(const Ogre::String& name){
     // Open the configuration file
@@ -36,7 +36,7 @@ void ConfigFile::Execute(const Ogre::String& name){
                 if (params.size() > 0){
                     // handle command
                     ConfigCmd* cmd
-                      = ConfigCmdManager::getSingleton().Find(params[0]);
+                      = ConfigCmdHandler::getSingleton().Find(params[0]);
                     if (cmd != nullptr) cmd->GetHandler()(params);
                     else
                         LOG_ERROR("Can't find command \"" + params[0] + "\".");
@@ -53,7 +53,7 @@ void ConfigFile::Execute(const Ogre::String& name){
 
             if (params.size() > 0){
                 ConfigCmd* cmd
-                  = ConfigCmdManager::getSingleton().Find(params[0]);
+                  = ConfigCmdHandler::getSingleton().Find(params[0]);
 
                 if(cmd != nullptr) cmd->GetHandler()(params);
                 else LOG_ERROR("Can't find command \"" + params[0] + "\".");

+ 12 - 13
src/core/ConfigVar.h

@@ -17,13 +17,13 @@
 
 #include <OgreString.h>
 
-class ConfigVarManager;
+class ConfigVarHandler;
 
 /**
  * A configuration variable
  */
 class ConfigVar{
-    friend class ConfigVarManager;
+    friend class ConfigVarHandler;
 
     public:
 
@@ -31,8 +31,7 @@ class ConfigVar{
          * Constructor.
          *
          * @param[in] name The variable name.
-         * @param[in] description A human-friendly description for the
-         * variable.
+         * @param[in] description A human-friendly description for the variable.
          * @param[in] default_value The default value for the variable.
          */
         ConfigVar(
@@ -137,46 +136,46 @@ class ConfigVar{
         /**
          * The variable name.
          */
-        Ogre::String    name_;
+        Ogre::String name_;
 
         /**
          * The variable description.
          */
-        Ogre::String    description_;
+        Ogre::String description_;
 
         /**
          * The variable default value.
          */
-        Ogre::String    default_value_;
+        Ogre::String default_value_;
 
         /**
          * Variable value, integer format.
          */
-        int             value_i_;
+        int value_i_;
 
         /**
          * Variable value, float format.
          */
-        float           value_f_;
+        float value_f_;
 
         /**
          * Variable value, integer format.
          */
-        bool            value_b_;
+        bool value_b_;
 
         /**
          * Variable value, string format.
          */
-        Ogre::String    value_s_;
+        Ogre::String value_s_;
 
         /**
          * @todo Understand and document.
          */
-        ConfigVar*          previous_;
+        ConfigVar* previous_;
 
         /**
          * @todo Understand and document.
          */
-        static ConfigVar*   static_config_var_list_;
+        static ConfigVar* static_config_var_list_;
 };
 

+ 6 - 6
src/core/ConfigVarManager.cpp → src/core/ConfigVarHandler.cpp

@@ -13,14 +13,14 @@
  * GNU General Public License for more details.
  */
 
-#include "core/ConfigVarManager.h"
+#include "ConfigVarHandler.h"
 
 /**
  * Configuration variable manager singleton.
  */
-template<>ConfigVarManager *Ogre::Singleton<ConfigVarManager>::msSingleton = nullptr;
+template<>ConfigVarHandler *Ogre::Singleton<ConfigVarHandler>::msSingleton = nullptr;
 
-ConfigVarManager::ConfigVarManager(){
+ConfigVarHandler::ConfigVarHandler(){
     // TODO: Properly cast this.
     if (reinterpret_cast<std::uintptr_t>(&ConfigVar::static_config_var_list_) != 0xffffffff){
         for (ConfigVar* cvar = ConfigVar::static_config_var_list_; cvar; cvar = cvar->previous_)
@@ -30,14 +30,14 @@ ConfigVarManager::ConfigVarManager(){
     }
 }
 
-ConfigVar* ConfigVarManager::Find(const Ogre::String& name) const{
+ConfigVar* ConfigVarHandler::Find(const Ogre::String& name) const{
     for (size_t i = 0; i < config_vars_.size(); ++ i)
         if (config_vars_[i]->GetName() == name) return config_vars_[i];
     return nullptr;
 }
 
-unsigned int ConfigVarManager::GetConfigVarNumber() const{return config_vars_.size();}
+unsigned int ConfigVarHandler::GetConfigVarNumber() const{return config_vars_.size();}
 
-ConfigVar* ConfigVarManager::GetConfigVar(const unsigned int i) const{
+ConfigVar* ConfigVarHandler::GetConfigVar(const unsigned int i) const{
     if (i < config_vars_.size()) return config_vars_[i]; return nullptr;
 }

+ 4 - 5
src/core/ConfigVarManager.h → src/core/ConfigVarHandler.h

@@ -20,23 +20,22 @@
 #include "ConfigVar.h"
 
 /**
- * Configuration variable manager.
+ * Configuration variable hanlder.
  */
-class ConfigVarManager : public Ogre::Singleton<ConfigVarManager>{
+class ConfigVarHandler : public Ogre::Singleton<ConfigVarHandler>{
 
     public:
 
         /**
          * Constructor.
          */
-        ConfigVarManager();
+        ConfigVarHandler();
 
         /**
          * Finds a variable by name.
          *
          * @param[in] name Name of the variable to retrieve.
-         * @return The variable by the specified name, nullptr if there is no
-         * one by that name.
+         * @return The variable by the specified name, nullptr if there is no one by that name.
          */
         ConfigVar* Find(const Ogre::String& name) const;
 

+ 15 - 15
src/core/Console.cpp

@@ -16,14 +16,14 @@
 #include <OgreFontManager.h>
 #include <OgreRenderWindow.h>
 #include "common/VGearsApplication.h"
-#include "core/ConfigCmdManager.h"
-#include "core/ConfigVarManager.h"
 #include "core/Console.h"
 #include "core/DebugDraw.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/Timer.h"
 #include "core/Utilites.h"
+#include "ConfigCmdHandler.h"
+#include "ConfigVarHandler.h"
 
 /**
  * Console singleton
@@ -447,7 +447,7 @@ void Console::ExecuteCommand(const Ogre::String& command){
     bool handled = false;
     Ogre::StringVector params = StringTokenise(command);
     // Is it cvar?
-    ConfigVar* cvar = ConfigVarManager::getSingleton().Find(params[0]);
+    ConfigVar* cvar = ConfigVarHandler::getSingleton().Find(params[0]);
     if (cvar != nullptr){
         handled = true;
         if (params.size() > 1){
@@ -463,7 +463,7 @@ void Console::ExecuteCommand(const Ogre::String& command){
     }
     if (handled == false){
         // Handle command
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+        ConfigCmd* cmd = ConfigCmdHandler::getSingleton().Find(params[0]);
         if (cmd != nullptr){
             cmd->GetHandler()(params);
             return;
@@ -484,17 +484,17 @@ void Console::CompleteInput(){
         Ogre::StringVector params = StringTokenise(input_line_);
         if (params.size() == 0){
             // Add cvars.
-            int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
+            int num_vars = ConfigVarHandler::getSingleton().GetConfigVarNumber();
             for (int i = 0; i < num_vars; ++ i){
                 auto_completition_.push_back(
-                  ConfigVarManager::getSingleton().GetConfigVar(i)->GetName()
+                  ConfigVarHandler::getSingleton().GetConfigVar(i)->GetName()
                 );
             }
             // Add commands.
-            int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+            int num_cmds = ConfigCmdHandler::getSingleton().GetConfigCmdNumber();
             for (int i = 0; i < num_cmds; ++i){
                 auto_completition_.push_back(
-                  ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName()
+                  ConfigCmdHandler::getSingleton().GetConfigCmd(i)->GetName()
                 );
             }
             add_slash = true;
@@ -502,9 +502,9 @@ void Console::CompleteInput(){
         else if (params.size() == 1){
             input_line_ = params[0];
             // Add Cvars.
-            int num_vars = ConfigVarManager::getSingleton().GetConfigVarNumber();
+            int num_vars = ConfigVarHandler::getSingleton().GetConfigVarNumber();
             for (int i = 0; i < num_vars; ++ i){
-                Ogre::String name = ConfigVarManager::getSingleton().GetConfigVar(i)->GetName();
+                Ogre::String name = ConfigVarHandler::getSingleton().GetConfigVar(i)->GetName();
                 unsigned int pos = name.find(input_line_);
                 if (pos == 0){
                     add_slash = true;
@@ -515,9 +515,9 @@ void Console::CompleteInput(){
                 }
             }
             // Add commands.
-            int num_cmds = ConfigCmdManager::getSingleton().GetConfigCmdNumber();
+            int num_cmds = ConfigCmdHandler::getSingleton().GetConfigCmdNumber();
             for (int i = 0; i < num_cmds; ++ i){
-                Ogre::String name = ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetName();
+                Ogre::String name = ConfigCmdHandler::getSingleton().GetConfigCmd(i)->GetName();
                 int pos = name.find(input_line_);
                 if (pos == 0){
                     add_slash = true;
@@ -526,10 +526,10 @@ void Console::CompleteInput(){
                         auto_completition_.push_back(part);
                     }
                     else if (
-                      ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion() != nullptr
+                      ConfigCmdHandler::getSingleton().GetConfigCmd(i)->GetCompletion() != nullptr
                     ){
                         input_line_ += " ";
-                        ConfigCmdManager::getSingleton().GetConfigCmd(i)->GetCompletion()(
+                        ConfigCmdHandler::getSingleton().GetConfigCmd(i)->GetCompletion()(
                           auto_completition_
                         );
                     }
@@ -540,7 +540,7 @@ void Console::CompleteInput(){
             Ogre::String all_params = params[1];
             for (size_t i = 2; i < params.size(); ++ i) all_params += " " + params[i];
             // Add commands arguments
-            ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params[0]);
+            ConfigCmd* cmd = ConfigCmdHandler::getSingleton().Find(params[0]);
             if (cmd != nullptr){
                 add_slash = true;
                 if (cmd->GetCompletion() != nullptr){

+ 138 - 123
src/core/DialogsManager.cpp

@@ -17,7 +17,7 @@
 #include "core/ConfigVar.h"
 #include "core/DebugDraw.h"
 #include "core/Logger.h"
-#include "core/TextManager.h"
+#include "TextHandler.h"
 
 /**
  * Dialog manager singleton.
@@ -96,8 +96,20 @@ void DialogsManager::Input(const VGears::Event& input){
         down_pressed_ = true;
 }
 
+void DialogsManager::UpdateDebug(){}
+
+void DialogsManager::OnResize(){}
+
+void DialogsManager::ClearField(){
+    for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);
+}
+
+void DialogsManager::ClearBattle(){}
+
+void DialogsManager::ClearWorld(){}
+
 void DialogsManager::ScriptSetMapName(const char* text_id){
-    std::string text = TextManager::getSingleton().GetDialogText(text_id);
+    std::string text = TextHandler::getSingleton().GetDialogText(text_id);
     SetMapName(text);
 }
 
@@ -107,126 +119,6 @@ void DialogsManager::SetMapName(std::string name){
 
 std::string DialogsManager::GetMapName(){return map_name_;}
 
-void DialogsManager::Update(){
-    for (unsigned int i = 0; i < messages_.size(); ++ i){
-        switch(messages_[i]->state){
-            case MS_SHOW_WINDOW:
-                {
-                    if (
-                      (messages_[i]->window == NULL)
-                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
-                    ){
-                        messages_[i]->text_area->PlayAnimation("Show", UiAnimation::ONCE, 0, -1);
-                        messages_[i]->text_area->SetVisible(true);
-                        messages_[i]->state = MS_SHOW_TEXT;
-                    }
-                }
-                break;
-            case MS_SHOW_TEXT:{
-                if (AutoCloseCheck(i) == true) break;
-                if (messages_[i]->clickable == true){
-                    if (next_pressed_ == true) messages_[i]->text_area->InputPressed();
-                    if (next_repeated_ == true) messages_[i]->text_area->InputRepeated();
-                }
-
-                if (messages_[i]->text_area->GetTextState() == TS_DONE){
-                    messages_[i]->state = MS_OPENED;
-                    if (messages_[i]->cursor != NULL && messages_[i]->show_cursor == true){
-                        messages_[i]->cursor->SetY(
-                          messages_[i]->cursor_percent_y,
-                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
-                            * messages_[i]->text_area->GetFont()->GetHeight()
-                        );
-                        messages_[i]->cursor->SetVisible(true);
-                    }
-                }
-            }
-                break;
-            case MS_OPENED:
-                {
-                    if (messages_[i]->clickable == true && next_pressed_ == true){
-                        if (messages_[i]->closeable == true){
-                            messages_[i]->auto_close = true;
-                            if ((messages_[i]->cursor != NULL) && (messages_[i]->show_cursor == true)){
-                                messages_[i]->show_cursor = false;
-                                messages_[i]->cursor_row_selected = messages_[i]->cursor_row_current;
-                                messages_[i]->cursor->SetVisible(false);
-                            }
-                        }
-                    }
-                    if (AutoCloseCheck(i) == true) break;
-                    if (
-                      (messages_[i]->cursor != NULL)
-                      && (messages_[i]->show_cursor == true)
-                      && (messages_[i]->clickable == true)
-                    ){
-                        if (up_pressed_ == true) messages_[i]->cursor_row_current -= 1;
-                        else if (down_pressed_ == true) messages_[i]->cursor_row_current += 1;
-                        messages_[i]->cursor_row_current =
-                          (messages_[i]->cursor_row_current < messages_[i]->cursor_row_first)
-                            ? messages_[i]->cursor_row_last : messages_[i]->cursor_row_current;
-                        messages_[i]->cursor_row_current =
-                          (messages_[i]->cursor_row_current > messages_[i]->cursor_row_last)
-                            ? messages_[i]->cursor_row_first : messages_[i]->cursor_row_current;
-                        messages_[i]->cursor->SetY(
-                          messages_[i]->cursor_percent_y,
-                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
-                            * messages_[i]->text_area->GetFont()->GetHeight()
-                        );
-                    }
-                }
-                break;
-            case MS_HIDE_WINDOW:{
-                    if (
-                      (messages_[i]->window == NULL)
-                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
-                    ){
-                        HideMessage(i);
-                    }
-                }
-            break;
-        }
-    }
-
-    if (cv_debug_message.GetB() == true){
-        DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
-        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
-        DEBUG_DRAW.SetScreenSpace(true);
-        int y = 34;
-        for (unsigned int i = 0; i < messages_.size(); ++ i){
-            Ogre::String caption;
-            caption += "Message " + Ogre::StringConverter::toString(i) + ": "
-              + message_state_string[messages_[i]->state];
-
-            if (messages_[i]->state == MS_SHOW_TEXT){
-                caption += " ("
-                  + Ogre::StringConverter::toString(int(messages_[i]->text_area->GetTextLimit()))
-                  + "/" + Ogre::StringConverter::toString(messages_[i]->text_area->GetTextSize());
-
-                switch(messages_[i]->text_area->GetTextState()){
-                    case TS_PAUSE_OK: caption += " pause ok"; break;
-                    case TS_PAUSE_TIME:
-                        caption += " pause time " + Ogre::StringConverter::toString(
-                          int(messages_[i]->text_area->GetPauseTime())
-                        );
-                        break;
-                    case TS_OVERFLOW: caption += " overflow"; break;
-                    case TS_NEXT_PAGE: caption += " next page"; break;
-                    case TS_SCROLL_TEXT: caption += " scroll"; break;
-                }
-                caption += ")";
-            }
-            DEBUG_DRAW.Text(10, y, caption);
-            y += 16;
-        }
-    }
-    next_pressed_ = false;
-    next_repeated_ = false;
-    up_pressed_ = false;
-    down_pressed_ = false;
-}
-
-void DialogsManager::Clear(){for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);}
 
 void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
     int id = GetMessageId(d_name);
@@ -261,7 +153,7 @@ void DialogsManager::SetText(const char* d_name, const char* text){
     // XML data can change dialog w/h VS what is in the lua script
     float width = 0.0f;
     float height = 0.0f;
-    TiXmlNode* xmlText = TextManager::getSingleton().GetDialog(text, width, height);
+    TiXmlNode* xmlText = TextHandler::getSingleton().GetDialog(text, width, height);
     if (xmlText != NULL){
         ShowMessage(
           id, data->x, data->y,
@@ -475,3 +367,126 @@ bool DialogsManager::AutoCloseCheck(const unsigned int id){
     }
     return false;
 }
+
+void DialogsManager::UpdateField(){
+    for (unsigned int i = 0; i < messages_.size(); ++ i){
+        switch(messages_[i]->state){
+            case MS_SHOW_WINDOW:
+                {
+                    if (
+                      (messages_[i]->window == NULL)
+                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
+                    ){
+                        messages_[i]->text_area->PlayAnimation("Show", UiAnimation::ONCE, 0, -1);
+                        messages_[i]->text_area->SetVisible(true);
+                        messages_[i]->state = MS_SHOW_TEXT;
+                    }
+                }
+                break;
+            case MS_SHOW_TEXT:{
+                if (AutoCloseCheck(i) == true) break;
+                if (messages_[i]->clickable == true){
+                    if (next_pressed_ == true) messages_[i]->text_area->InputPressed();
+                    if (next_repeated_ == true) messages_[i]->text_area->InputRepeated();
+                }
+
+                if (messages_[i]->text_area->GetTextState() == TS_DONE){
+                    messages_[i]->state = MS_OPENED;
+                    if (messages_[i]->cursor != NULL && messages_[i]->show_cursor == true){
+                        messages_[i]->cursor->SetY(
+                          messages_[i]->cursor_percent_y,
+                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
+                            * messages_[i]->text_area->GetFont()->GetHeight()
+                        );
+                        messages_[i]->cursor->SetVisible(true);
+                    }
+                }
+            }
+                break;
+            case MS_OPENED:
+                {
+                    if (messages_[i]->clickable == true && next_pressed_ == true){
+                        if (messages_[i]->closeable == true){
+                            messages_[i]->auto_close = true;
+                            if ((messages_[i]->cursor != NULL) && (messages_[i]->show_cursor == true)){
+                                messages_[i]->show_cursor = false;
+                                messages_[i]->cursor_row_selected = messages_[i]->cursor_row_current;
+                                messages_[i]->cursor->SetVisible(false);
+                            }
+                        }
+                    }
+                    if (AutoCloseCheck(i) == true) break;
+                    if (
+                      (messages_[i]->cursor != NULL)
+                      && (messages_[i]->show_cursor == true)
+                      && (messages_[i]->clickable == true)
+                    ){
+                        if (up_pressed_ == true) messages_[i]->cursor_row_current -= 1;
+                        else if (down_pressed_ == true) messages_[i]->cursor_row_current += 1;
+                        messages_[i]->cursor_row_current =
+                          (messages_[i]->cursor_row_current < messages_[i]->cursor_row_first)
+                            ? messages_[i]->cursor_row_last : messages_[i]->cursor_row_current;
+                        messages_[i]->cursor_row_current =
+                          (messages_[i]->cursor_row_current > messages_[i]->cursor_row_last)
+                            ? messages_[i]->cursor_row_first : messages_[i]->cursor_row_current;
+                        messages_[i]->cursor->SetY(
+                          messages_[i]->cursor_percent_y,
+                          messages_[i]->cursor_y + messages_[i]->cursor_row_current
+                            * messages_[i]->text_area->GetFont()->GetHeight()
+                        );
+                    }
+                }
+                break;
+            case MS_HIDE_WINDOW:{
+                    if (
+                      (messages_[i]->window == NULL)
+                      || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
+                    ){
+                        HideMessage(i);
+                    }
+                }
+            break;
+        }
+    }
+
+    if (cv_debug_message.GetB() == true){
+        DEBUG_DRAW.SetColour(Ogre::ColourValue::White);
+        DEBUG_DRAW.SetTextAlignment(DEBUG_DRAW.LEFT);
+        DEBUG_DRAW.SetScreenSpace(true);
+        int y = 34;
+        for (unsigned int i = 0; i < messages_.size(); ++ i){
+            Ogre::String caption;
+            caption += "Message " + Ogre::StringConverter::toString(i) + ": "
+              + message_state_string[messages_[i]->state];
+
+            if (messages_[i]->state == MS_SHOW_TEXT){
+                caption += " ("
+                  + Ogre::StringConverter::toString(int(messages_[i]->text_area->GetTextLimit()))
+                  + "/" + Ogre::StringConverter::toString(messages_[i]->text_area->GetTextSize());
+
+                switch(messages_[i]->text_area->GetTextState()){
+                    case TS_PAUSE_OK: caption += " pause ok"; break;
+                    case TS_PAUSE_TIME:
+                        caption += " pause time " + Ogre::StringConverter::toString(
+                          int(messages_[i]->text_area->GetPauseTime())
+                        );
+                        break;
+                    case TS_OVERFLOW: caption += " overflow"; break;
+                    case TS_NEXT_PAGE: caption += " next page"; break;
+                    case TS_SCROLL_TEXT: caption += " scroll"; break;
+                }
+                caption += ")";
+            }
+            DEBUG_DRAW.Text(10, y, caption);
+            y += 16;
+        }
+    }
+    next_pressed_ = false;
+    next_repeated_ = false;
+    up_pressed_ = false;
+    down_pressed_ = false;
+}
+
+void DialogsManager::UpdateBattle(){}
+
+void DialogsManager::UpdateWorld(){}

+ 39 - 10
src/core/DialogsManager.h

@@ -16,8 +16,10 @@
 #pragma once
 
 #include <OgreSingleton.h>
+#include "Manager.h"
 #include "UiManager.h"
 #include "UiTextArea.h"
+#include "InputManager.h"
 
 
 /**
@@ -235,7 +237,7 @@ struct MessageData{
 /**
  * The dialog manager.
  */
-class DialogsManager : public Ogre::Singleton<DialogsManager>{
+class DialogsManager : public Manager, public Ogre::Singleton<DialogsManager>{
 
     public:
 
@@ -259,17 +261,32 @@ class DialogsManager : public Ogre::Singleton<DialogsManager>{
          *
          * @param[in] event Event to process.
          */
-        void Input(const VGears::Event& event);
+        void Input(const VGears::Event& event) override;
 
         /**
-         * Updates all the messages in the manager.
+         * Updates the messagemanager with debug information.
          */
-        void Update();
+        void UpdateDebug();
 
         /**
-         * Hides every dialog in the manager.
+         * Handles resizing events
          */
-        void Clear();
+        void OnResize() override;
+
+        /**
+         * Clears all field messages.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle messages.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map maeeages.
+         */
+        void ClearWorld() override;
 
         /**
          * Opens a dialog.
@@ -407,6 +424,21 @@ class DialogsManager : public Ogre::Singleton<DialogsManager>{
 
     private:
 
+        /**
+         * Updates the dialogs while in a field.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the dialogs during a battle.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates the dialogs while on the world map.
+         */
+        void UpdateWorld() override;
+
         /**
          * Shows a message in a dialog.
          *
@@ -417,10 +449,7 @@ class DialogsManager : public Ogre::Singleton<DialogsManager>{
          * @param[in] height Height of the text, in pixels.
          * @todo Is this a window-limit-aware version of SetText?
          */
-        void ShowMessage(
-          const int id, const int x, const int y,
-          const int width, const int height
-        );
+        void ShowMessage(const int id, const int x, const int y, const int width, const int height);
 
         /**
          * Closes and hides a message.

+ 3 - 104
src/core/EntityManager.cpp

@@ -95,8 +95,6 @@ Ogre::Degree EntityManager::GetDirectionToPoint(
 }
 
 EntityManager::EntityManager():
-  module_(MODULE::FIELD),
-  paused_(false),
   player_entity_(nullptr),
   player_move_(Ogre::Vector3::ZERO),
   player_move_rotation_(0),
@@ -129,52 +127,6 @@ EntityManager::~EntityManager(){
     LOG_TRIVIAL("EntityManager destroyed.");
 }
 
-EntityManager::MODULE EntityManager::GetModule(){return module_;}
-
-bool EntityManager::IsModule(EntityManager::MODULE module){return (module_ == module);}
-
-bool EntityManager::IsFieldModule(){return (module_ == MODULE::FIELD);}
-
-bool EntityManager::IsBattleModule(){return (module_ == MODULE::BATTLE);}
-
-bool EntityManager::IsWorldModule(){return (module_ == MODULE::WORLD);}
-
-void EntityManager::SetModule(EntityManager::MODULE module){
-    if (module == MODULE::FIELD){
-        ClearBattle();
-        ClearWorld();
-    }
-    else if (module == MODULE::WORLD){
-        ClearBattle();
-        ClearField();
-    }
-    else if (module == MODULE::BATTLE){
-        prev_module_ = module_;
-    }
-    module_ = module;
-}
-
-void EntityManager::SetFieldModule(){SetModule(MODULE::FIELD);}
-
-void EntityManager::SetBattleModule(){SetModule(MODULE::BATTLE);}
-
-void EntityManager::SetWorldModule(){SetModule(MODULE::WORLD);}
-
-void EntityManager::SetPreviousModule(){
-    if (module_ != MODULE::BATTLE)
-        LOG_WARNING(
-          "Called EntityManager::SetPreviousModule without battle module active. Doing nothing"
-          + "Current module is " + std::to_string(module_)
-        );
-    else if(module_ = prev_module_)
-        LOG_WARNING(
-          "Called EntityManager::SetPreviousModule but there is no previous module. Doing nothing"
-          + "Current module is " + std::to_string(module_)
-        );
-    else module_ = prev_module_;
-    return;
-}
-
 void EntityManager::Input(const VGears::Event& event){
     background_2d_.InputDebug(event);
     if (paused_ == true) return;
@@ -215,26 +167,6 @@ void EntityManager::Input(const VGears::Event& event){
     }
 }
 
-void EntityManager::Update(){
-    UpdateDebug();
-    if (paused_ == true) return;
-    Update(module_);
-}
-
-void EntityManager::Update(MODULE module){
-    switch (module){
-        case MODULE::FIELD:
-            UpdateField();
-            break;
-        case MODULE::BATTLE:
-            UpdateBattle();
-            break;
-        case MODULE::WORLD:
-            UpdateWorld();
-            break;
-    }
-}
-
 void EntityManager::UpdateField(){
     // Update all entity scripts
     ScriptManager::getSingleton().Update(ScriptManager::ENTITY);
@@ -368,7 +300,7 @@ void EntityManager::UpdateWorld(){
 void EntityManager::UpdateDebug(){
     grid_->setVisible(cv_debug_grid.GetB());
     axis_->setVisible(cv_debug_axis.GetB());
-    if (module_ == MODULE::BATTLE)
+    if (module_ == Module::BATTLE)
         for (unsigned int i = 0; i < battle_entity_.size(); ++ i) battle_entity_[i]->UpdateDebug();
     else{
         for (unsigned int i = 0; i < entity_.size(); ++ i) entity_[i]->UpdateDebug();
@@ -381,22 +313,6 @@ void EntityManager::UpdateDebug(){
 
 void EntityManager::OnResize(){background_2d_.OnResize();}
 
-void EntityManager::Clear(){Clear(module_);}
-
-void EntityManager::Clear(MODULE module){
-    switch (module){
-        case MODULE::FIELD:
-            ClearField();
-            break;
-        case MODULE::BATTLE:
-            ClearBattle();
-            break;
-        case MODULE::WORLD:
-            ClearWorld();
-            break;
-    }
-}
-
 void EntityManager::ClearField(){
     walkmesh_.Clear();
     background_2d_.Clear();
@@ -438,14 +354,6 @@ void EntityManager::ClearWorld(){
     // TODO implement
 }
 
-void EntityManager::ClearAll(){
-    ClearField();
-    ClearBattle();
-    ClearWorld();
-}
-
-void EntityManager::ScriptSetPaused(const bool paused){paused_ = paused;}
-
 Walkmesh* EntityManager::GetWalkmesh(){return &walkmesh_;}
 
 Background2D* EntityManager::GetBackground2D(){return &background_2d_;}
@@ -465,7 +373,7 @@ void EntityManager::AddEntity(
   const Ogre::Degree& rotation, const Ogre::Vector3& scale,
   const Ogre::Quaternion& root_orientation, int index
 ){
-    if (module_ != MODULE::FIELD){
+    if (module_ != Module::FIELD){
         LOG_ERROR("Tried to add field Entity but the EntityManager is not in field mode.");
         return;
     }
@@ -484,7 +392,7 @@ void EntityManager::AddBattleEntity(
   const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position,
   const Ogre::Degree& rotation, const Ogre::Vector3& scale, const int index, const int visible
 ){
-    if (module_ != MODULE::BATTLE){
+    if (module_ != Module::BATTLE){
         LOG_ERROR("Tried to add battle Entity but the EntityManager is not in battle mode.");
         return;
     }
@@ -627,15 +535,6 @@ void EntityManager::SetEntityToCharacter(const char* entity_name, unsigned int c
         if (entity_[i]->GetName() == entity_name) entity_[i]->SetCharacter(char_id);
 }
 
-void EntityManager::AddTrack(const int id, const int track_id){
-    if (id >= 0 && id < 255) tracks_[id] = track_id;
-}
-
-int EntityManager::GetTrack(const int id){
-    if (tracks_.count(id) == 0) return -1;
-    else return tracks_[id];
-}
-
 bool EntityManager::SetEntityOnWalkmesh(Entity* entity){
     Ogre::Vector3 position3 = entity->GetPosition();
     Ogre::Vector2 position2;

+ 14 - 210
src/core/EntityManager.h

@@ -21,42 +21,16 @@
 #include "EntityPoint.h"
 #include "EntityTrigger.h"
 #include "Event.h"
+#include "Manager.h"
 #include "Walkmesh.h"
 
 /**
  * The entity manager.
  */
-class EntityManager : public Ogre::Singleton<EntityManager>{
+class EntityManager : public Manager, public Ogre::Singleton<EntityManager>{
 
     public:
 
-        /**
-         * The modules the entity manager can handle.
-         */
-        enum MODULE{
-
-            /**
-             * Field module.
-             *
-             * Used in field maps. It has background, walkmesh, entities...
-             */
-            FIELD = 0,
-
-            /**
-             * Battle module.
-             *
-             * Used in battles. During battles there is no walkmesh.
-             */
-            BATTLE = 1,
-
-            /**
-             * World map module.
-             *
-             * Used in the world map. It has background, walkmesh, entities...
-             */
-            WORLD = 2
-        };
-
         /**
          * Constructor.
          */
@@ -67,171 +41,45 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          */
         virtual ~EntityManager();
 
-        /**
-         * Retrieves the currently selected module.
-         *
-         * @return The currently selected module.
-         */
-        MODULE GetModule();
-
-        /**
-         * Checks the currently selected module.
-         *
-         * @param[in] module The module to check.
-         * @return True if the currently selected module matches the module to check, false
-         * otherwise.
-         */
-        bool IsModule(MODULE module);
-
-        /**
-         * Checks if the currently selected module is the field module.
-         *
-         * @return True if the currently selected module is the field module, false otherwise.
-         */
-        bool IsFieldModule();
-
-        /**
-         * Checks if the currently selected module is the battle module.
-         *
-         * @return True if the currently selected module is the battle module, false otherwise.
-         */
-        bool IsBattleModule();
-
-        /**
-         * Checks if the currently selected module is the world module.
-         *
-         * @return True if the currently selected module is the world module, false otherwise.
-         */
-        bool IsWorldModule();
-
-        /**
-         * Sets the current module for the entity manager.
-         *
-         * Operation availability and entity visibility will depend on the loaded module. Check
-         * {@see SetFieldModule()}, {@see SetBattleModule()} and {@see SetWorldModule()} for
-         * information about what changing modules implies.
-         */
-        void SetModule(MODULE module);
-
-        /**
-         * Sets the current module to the field mode.
-         *
-         * While the field module is active. All field entities are present and updated each frame,
-         * and the walkmesh is active. Setting the field module will clear all the information
-         * stored in the battle and world modules.
-         */
-        void SetFieldModule();
-
-        /**
-         * Sets the current module to the battle mode.
-         *
-         * While the battle module is active. Battle entities are present and updated each frame.
-         * Setting the field module will not clear the information stored in the field and world
-         * modules.
-         */
-        void SetBattleModule();
-
-        /**
-         * Sets the current module to the world map mode.
-         *
-         * While the world module is active. All world entities are present and updated each frame,
-         * and the walkmesh is active. Setting the world module will clear all the information
-         * stored in the battle and field modeules.
-         */
-        void SetWorldModule();
-
-        /**
-         * Sets the module that was loaded before a battle.
-         *
-         * Calling this will call either {@see SetFieldModule()} or {@see SetWorldModule},
-         * depending on which module was loaded before. Calling this while not in the battle module
-         * will do nothing.
-         */
-        void SetPreviousModule();
-
         /**
          * Handles an input event.
          *
          * @param[in] event Event to handle.
          */
-        void Input(const VGears::Event& event);
-
-        /**
-         * Updates the entities in the manager.
-         *
-         * It only updates the entities of the currenly selected module.
-         */
-        void Update();
+        void Input(const VGears::Event& event) override;
 
         /**
          * Updates the entities in the manager with debug information.
          *
          * It's automatically called from {@see Update}.
          */
-        void UpdateDebug();
+        void UpdateDebug() override;
 
         /**
          * Handles resizing events
          */
-        void OnResize();
-
-        /**
-         * Clears the entity manager.
-         *
-         * Clears the entity manager for the currently loaded module. Check {@see ClearField()},
-         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
-         * depending on the currently loaded module.
-         */
-        void Clear();
+        void OnResize() override;
 
         /**
-         * Clears the entity manager.
-         *
-         * Clears the entity manager for the selected module. Check {@see ClearField()},
-         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
-         * depending on the currently loaded module.
-         *
-         * @param[in] module The module to clear.
-         */
-        void Clear(MODULE module);
-
-        /**
-         * Clear all field information in the entity manager.
+         * Clears all field information in the entity manager.
          *
          * It clears the background, the walkmesh, any pending actions and all the field entities.
          */
-        void ClearField();
+        void ClearField() override;
 
         /**
-         * Clear all battle information in the entity manager.
+         * Clears all battle information in the entity manager.
          *
          * It clears any pending actions and all the battle entities.
          */
-        void ClearBattle();
+        void ClearBattle() override;
 
         /**
-         * Clear all world map information in the entity manager.
+         * Clears all world map information in the entity manager.
          *
          * It clears the background, the walkmesh, any pending actions and all the world entities.
          */
-        void ClearWorld();
-
-        /**
-         * Clears the entity manager.
-         *
-         * Clears the entity manager for every module. Check {@see ClearField()},
-         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
-         * depending on the currently loaded module.
-         */
-        void ClearAll();
-
-        /**
-         * Pauses or resumes an entity scripts.
-         *
-         * @param[in] paused True to pause, false to resume.
-         * @todo Verify the description.
-         */
-        void ScriptSetPaused(const bool paused);
+        void ClearWorld() override;
 
         /**
          * Retrieves the walkmesh.
@@ -500,23 +348,6 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          */
         void SetEntityToCharacter(const char* entity_name, unsigned int char_id);
 
-        /**
-         * Adds a music track ID to the list of music tracks of the field.
-         *
-         * @param[in] id ID of the track in the map.
-         * @param[in] track_id Music track ID.
-         */
-        void AddTrack(const int id, const int track_id);
-
-        /**
-         * Adds a music track ID from the list of music tracks of the field.
-         *
-         * @param[in] id ID of the track in the map.
-         * @return The music track ID, or -1 if it doesn't exist.
-         */
-        int GetTrack(const int id);
-
-
     private:
 
         /**
@@ -578,24 +409,17 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
         /**
          * Updates the field entities in the manager.
          */
-        void UpdateField();
+        void UpdateField() override;
 
         /**
          * Updates the battle entities in the manager.
          */
-        void UpdateBattle();
+        void UpdateBattle() override;
 
         /**
          * Updates the world map entities in the manager.
          */
-        void UpdateWorld();
-
-        /**
-         * Updates the entities of one module in the manager.
-         *
-         * @param[in] module The module whose entities to update.
-         */
-        void Update(MODULE module);
+        void UpdateWorld() override;
 
         /**
          * Attaches an entity to the walkmesh.
@@ -703,21 +527,6 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          */
         void SetNextScrollStep();
 
-        /**
-         * The currently selected module.
-         */
-        MODULE module_;
-
-        /**
-         * The previous module.
-         */
-        MODULE prev_module_;
-
-        /**
-         * Indicates if the script execution is paused.
-         */
-        bool paused_;
-
         /**
          * The map walkmesh.
          */
@@ -813,9 +622,4 @@ class EntityManager : public Ogre::Singleton<EntityManager>{
          * The encounter rate of the map.
          */
         float encounter_rate_;
-
-        /**
-         * IDs of the music tracks of the field.
-         */
-        std::unordered_map<int, int> tracks_;
 };

+ 22 - 8
src/core/InputManager.cpp

@@ -13,28 +13,38 @@
  * GNU General Public License for more details.
  */
 
-#include "core/ConfigCmdManager.h"
 #include "core/Console.h"
 #include "core/InputManager.h"
 #include "core/InputManagerCommands.h"
 #include "core/Logger.h"
 #include "core/Timer.h"
+#include "core/Manager.h"
+#include "ConfigCmdHandler.h"
 
 /**
  * Input manager singleton.
  */
 template<>InputManager *Ogre::Singleton<InputManager>::msSingleton = nullptr;
 
-InputManager::InputManager():
-  repeat_first_wait_(true),
-  repeat_timer_(0)
-{
+InputManager::InputManager():repeat_first_wait_(true), repeat_timer_(0){
     InitCmd();
     Reset();
+    Update();
 }
 
 InputManager::~InputManager(){}
 
+void InputManager::Input(const VGears::Event& event){}
+
+void InputManager::UpdateDebug(){}
+
+void InputManager::OnResize(){}
+
+void InputManager::ClearField(){}
+
+void InputManager::ClearBattle(){}
+
+void InputManager::ClearWorld(){}
 
 void InputManager::Reset(){
     for (int button = 0; button < 256; ++ button) button_state_[button] = false;
@@ -183,15 +193,13 @@ void InputManager::AddGameEvents(const int button, const VGears::EventType type)
         if (
           std::find(
             bind_game_events_[i].buttons.begin(), bind_game_events_[i].buttons.end(), button
-          )
-          != bind_game_events_[i].buttons.end()
+          ) != bind_game_events_[i].buttons.end()
         ){
             unsigned int j = 0;
             for (; j < bind_game_events_[i].buttons.size(); ++ j){
                 if (bind_game_events_[i].buttons[j] != button)
                     if (IsButtonPressed(bind_game_events_[i].buttons[j]) == false) break;
             }
-
             if (j >= bind_game_events_[i].buttons.size()) binds_indexes.push_back(i);
         }
     }
@@ -215,3 +223,9 @@ void InputManager::AddGameEvents(const int button, const VGears::EventType type)
         event_queue_.push_back(event);
     }
 }
+
+void InputManager::UpdateField(){Update();}
+
+void InputManager::UpdateBattle(){Update();}
+
+void InputManager::UpdateWorld(){Update();}

+ 80 - 17
src/core/InputManager.h

@@ -21,6 +21,7 @@
 #include <OgreStringVector.h>
 #include <OIS/OIS.h>
 #include "Event.h"
+#include "Manager.h"
 
 typedef std::vector<VGears::Event> InputEventArray;
 
@@ -33,7 +34,7 @@ class ConfigCmd;
  *
  * It handles input events and creates {@see Event}s.
  */
-class InputManager : public Ogre::Singleton<InputManager>{
+class InputManager : public Manager, public Ogre::Singleton<InputManager>{
 
     public:
 
@@ -47,16 +48,59 @@ class InputManager : public Ogre::Singleton<InputManager>{
          */
         virtual ~InputManager();
 
+        /**
+         * Makes the input manager itself handles an input event.
+         *
+         * @param[in] event Event to handle.
+         */
+        void Input(const VGears::Event& event) override;
+
+        /**
+         * Update keyboard and mouse buttons, movements and scroll status.
+         */
+        void Update();
+
+        /**
+         * Updates the input manager with debug information.
+         */
+        void UpdateDebug() override;
+
+        /**
+         * Handles resizing events
+         */
+        void OnResize() override;
+
+        /**
+         * Clears all field information in the input manager.
+         *
+         * It does nothing.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle information in the input manager.
+         *
+         * It does nothing.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map information in the input manager.
+         *
+         * It does nothing.
+         */
+        void ClearWorld() override;
+
         /**
          * Triggered when a keyboard button is pressed or released.
          *
          * Creates an {@see Event}.
          *
          * @param[in] button Pressed button ID.
-         * @param[in] text @todo The key code? It gets assigned to parameter 1
-         * of the generated event.
-         * @param[in] down True if the button has been pressed, false if it has
-         * been released. It gets assigned to parameter 2 of the event.
+         * @param[in] text @todo The key code? It gets assigned to parameter 1 of the generated
+         * event.
+         * @param[in] down True if the button has been pressed, false if it has been released. It
+         * gets assigned to parameter 2 of the event.
          */
         void ButtonPressed(int button, char text, bool down);
 
@@ -66,8 +110,8 @@ class InputManager : public Ogre::Singleton<InputManager>{
          * Creates an {@see Event}.
          *
          * @param[in] button Pressed button ID.
-         * @param[in] down True if the button has been pressed, false if it has
-         * been released. It gets assigned to parameter 1 of the event.
+         * @param[in] down True if the button has been pressed, false if it has been released. It
+         * gets assigned to parameter 1 of the event.
          */
         void MousePressed(int button, bool down);
 
@@ -76,10 +120,8 @@ class InputManager : public Ogre::Singleton<InputManager>{
          *
          * Creates an {@see Event}.
          *
-         * @param[in] x New mouse's X coordinate. It gets assigned to parameter
-         * 1 of the event.
-         * @param[in] y New mouse's Y coordinate. It gets assigned to parameter
-         * 2 of the event.
+         * @param[in] x New mouse's X coordinate. It gets assigned to parameter 1 of the event.
+         * @param[in] y New mouse's Y coordinate. It gets assigned to parameter 2 of the event.
          */
         void MouseMoved(int x, int y);
 
@@ -88,9 +130,8 @@ class InputManager : public Ogre::Singleton<InputManager>{
          *
          * Creates an {@see Event}.
          *
-         * @param[in] value Number of lines scrolled. Positive for scroll down,
-         * negative for scroll up. It gets assigned to parameter 1 of the
-         * event.
+         * @param[in] value Number of lines scrolled. Positive for scroll down, negative for scroll
+         * up. It gets assigned to parameter 1 of the event.
          */
         void MouseScrolled(int value);
 
@@ -103,10 +144,11 @@ class InputManager : public Ogre::Singleton<InputManager>{
         void Reset();
 
         /**
-         * Update keyboard and mouse buttons, movements and scroll status.
+         * Checks if a button is being pressed.
+         *
+         * @param[in] button Button code.
+         * @return true if the button is being pressed, false otherwise.
          */
-        void Update();
-
         bool IsButtonPressed(int button) const;
 
         /**
@@ -162,6 +204,27 @@ class InputManager : public Ogre::Singleton<InputManager>{
 
     private:
 
+        /**
+         * Updates the input manager while on the fields.
+         *
+         * It just calls the generic {@see Update()}.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the input manager while on a battle.
+         *
+         * It just calls the generic {@see Update()}.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates the input manager while on the world map.
+         *
+         * It just calls the generic {@see Update()}.
+         */
+        void UpdateWorld() override;
+
         /**
          * The state of eahc button.
          */

+ 6 - 5
src/core/InputManagerCommands.h

@@ -14,9 +14,10 @@
  */
 
 #include <OgreStringConverter.h>
+
+#include "ConfigCmdHandler.h"
+#include "ConfigVarHandler.h"
 #include "Console.h"
-#include "ConfigCmdManager.h"
-#include "ConfigVarManager.h"
 #include "Logger.h"
 #include "Utilites.h"
 
@@ -72,7 +73,7 @@ void CmdBind(const Ogre::StringVector& params){
         Ogre::StringVector params_cmd = StringTokenise(params[2]);
 
         // Handle command
-        ConfigCmd* cmd = ConfigCmdManager::getSingleton().Find(params_cmd[0]);
+        ConfigCmd* cmd = ConfigCmdHandler::getSingleton().Find(params_cmd[0]);
         if (cmd != NULL){
             InputManager::getSingleton().BindCommand(
               cmd, params_cmd, key_codes
@@ -118,10 +119,10 @@ void CmdBindGameEvent(const Ogre::StringVector& params){
 
 // TODO: Move this to InpuManager.cpp?
 void InputManager::InitCmd(){
-    ConfigCmdManager::getSingleton().AddCommand(
+    ConfigCmdHandler::getSingleton().AddCommand(
       "bind", "Bind command to keys", "", CmdBind, NULL
     );
-    ConfigCmdManager::getSingleton().AddCommand(
+    ConfigCmdHandler::getSingleton().AddCommand(
       "bind_game_event", "Bind game event to keys", "", CmdBindGameEvent, NULL
     );
 }

+ 115 - 0
src/core/Manager.cpp

@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#include <iostream>
+#include <OgreRoot.h>
+#include "Manager.h"
+#include "Logger.h"
+
+
+Manager::Manager(): module_(Module::FIELD), prev_module_(Module::FIELD), paused_(false){}
+
+Manager::~Manager(){}
+
+Manager::Module Manager::GetModule(){return module_;}
+
+bool Manager::IsModule(Manager::Module module){return (module_ == module);}
+
+bool Manager::IsFieldModule(){return (module_ == Module::FIELD);}
+
+bool Manager::IsBattleModule(){return (module_ == Module::BATTLE);}
+
+bool Manager::IsWorldModule(){return (module_ == Module::WORLD);}
+
+void Manager::SetModule(Manager::Module module){
+    if (module == Module::FIELD){
+        ClearBattle();
+        ClearWorld();
+    }
+    else if (module == Module::WORLD){
+        ClearBattle();
+        ClearField();
+    }
+    else if (module == Module::BATTLE){
+        prev_module_ = module_;
+    }
+    module_ = module;
+}
+
+void Manager::SetFieldModule(){SetModule(Module::FIELD);}
+
+void Manager::SetBattleModule(){SetModule(Module::BATTLE);}
+
+void Manager::SetWorldModule(){SetModule(Module::WORLD);}
+
+void Manager::SetPreviousModule(){
+    if (module_ != Module::BATTLE)
+        LOG_WARNING(
+          "Called Manager::SetPreviousModule without battle module active. Doing nothing"
+          + "Current module is " + std::to_string(module_)
+        );
+    else if(module_ = prev_module_)
+        LOG_WARNING(
+          "Called Manager::SetPreviousModule but there is no previous module. Doing nothing"
+          + "Current module is " + std::to_string(module_)
+        );
+    else module_ = prev_module_;
+    return;
+}
+
+void Manager::Update(){
+    UpdateDebug();
+    if (paused_ == true) return;
+    Update(module_);
+}
+
+
+void Manager::Update(Module module){
+    switch (module){
+        case Module::FIELD:
+            UpdateField();
+            break;
+        case Module::BATTLE:
+            UpdateBattle();
+            break;
+        case Module::WORLD:
+            UpdateWorld();
+            break;
+    }
+}
+
+void Manager::Clear(){Clear(module_);}
+
+void Manager::Clear(Module module){
+    switch (module){
+        case Module::FIELD:
+            ClearField();
+            break;
+        case Module::BATTLE:
+            ClearBattle();
+            break;
+        case Module::WORLD:
+            ClearWorld();
+            break;
+    }
+}
+
+void Manager::ClearAll(){
+    ClearField();
+    ClearBattle();
+    ClearWorld();
+}
+
+void Manager::ScriptSetPaused(const bool paused){paused_ = paused;}

+ 260 - 0
src/core/Manager.h

@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#pragma once
+#include "Event.h"
+
+/**
+ * A base manager.
+ *
+ * Contain functionalities shared by all managers that contains.
+ */
+class Manager{
+
+    public:
+
+        /**
+         * The modules the entity manager can handle.
+         */
+        enum Module{
+
+            /**
+             * Field module.
+             *
+             * Used in field maps. It has background, walkmesh, entities...
+             */
+            FIELD = 0,
+
+            /**
+             * Battle module.
+             *
+             * Used in battles. During battles there is no walkmesh.
+             */
+            BATTLE = 1,
+
+            /**
+             * World map module.
+             *
+             * Used in the world map. It has background, walkmesh, entities...
+             */
+            WORLD = 2
+        };
+
+        /**
+         * Constructor.
+         */
+        Manager();
+
+        /**
+         * Destructor.
+         */
+        virtual ~Manager();
+
+        /**
+         * Retrieves the currently selected module.
+         *
+         * @return The currently selected module.
+         */
+        Module GetModule();
+
+        /**
+         * Checks the currently selected module.
+         *
+         * @param[in] module The module to check.
+         * @return True if the currently selected module matches the module to check, false
+         * otherwise.
+         */
+        bool IsModule(Module module);
+
+        /**
+         * Checks if the currently selected module is the field module.
+         *
+         * @return True if the currently selected module is the field module, false otherwise.
+         */
+        bool IsFieldModule();
+
+        /**
+         * Checks if the currently selected module is the battle module.
+         *
+         * @return True if the currently selected module is the battle module, false otherwise.
+         */
+        bool IsBattleModule();
+
+        /**
+         * Checks if the currently selected module is the world module.
+         *
+         * @return True if the currently selected module is the world module, false otherwise.
+         */
+        bool IsWorldModule();
+
+        /**
+         * Sets the current module for the entity manager.
+         *
+         * Operation availability and entity visibility will depend on the loaded module. Check
+         * {@see SetFieldModule()}, {@see SetBattleModule()} and {@see SetWorldModule()} for
+         * information about what changing modules implies.
+         */
+        void SetModule(Module module);
+
+        /**
+         * Sets the current module to the field mode.
+         *
+         * Setting the field module will clear all the information stored in the battle and world
+         * modules.
+         */
+        void SetFieldModule();
+
+        /**
+         * Sets the current module to the battle mode.
+         *
+         * Setting the field module will not clear the information stored in the field and world
+         * modules.
+         */
+        void SetBattleModule();
+
+        /**
+         * Sets the current module to the world map mode.
+         *
+         * Setting the world module will clear all the information stored in the battle and field
+         * modules.
+         */
+        void SetWorldModule();
+
+        /**
+         * Sets the module that was loaded before a battle.
+         *
+         * Calling this will call either {@see SetFieldModule()} or {@see SetWorldModule},
+         * depending on which module was loaded before. Calling this while not in the battle module
+         * will do nothing.
+         */
+        void SetPreviousModule();
+
+        /**
+         * Handles an input event.
+         *
+         * @param[in] event Event to handle.
+         */
+        virtual void Input(const VGears::Event& event) = 0;
+
+        /**
+         * Called every frame, performs an update on the things controlled by the manager.
+         *
+         * It's functionality may be dependent on the current module.
+         */
+        void Update();
+
+        /**
+         * Called every frame, performs an update on the things controlled by the manager.
+         *
+         * It must update debug contents. It's functionality may depend on the current module.
+         */
+        virtual void UpdateDebug() = 0;
+
+        /**
+         * Handles resizing events
+         */
+        virtual void OnResize() = 0;
+
+        /**
+         * Clears the manager.
+         *
+         * Clears the manager for the currently loaded module. Check {@see ClearField()},
+         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
+         * depending on the currently loaded module.
+         */
+        void Clear();
+
+        /**
+         * Clears the manager.
+         *
+         * Clears the manager for the selected module. Check {@see ClearField()},
+         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
+         * depending on the currently loaded module.
+         *
+         * @param[in] module The module to clear.
+         */
+        void Clear(Module module);
+
+        /**
+         * Clear all field information in the manager.
+         */
+        virtual void ClearField() = 0;
+
+        /**
+         * Clear all battle information in the manager.
+         */
+        virtual void ClearBattle() = 0;
+
+        /**
+         * Clear all world map information in the manager.
+         */
+        virtual void ClearWorld() = 0;
+
+        /**
+         * Clears the manager.
+         *
+         * Clears the entity manager for every module. Check {@see ClearField()},
+         * {@see ClearBattle()}, {@see ClearWorld()} for information about what this does
+         * depending on the currently loaded module.
+         */
+        void ClearAll();
+
+        /**
+         * Handles game pausing.
+         *
+         * @param[in] paused True to pause, false to resume.
+         */
+        void ScriptSetPaused(const bool paused);
+
+    protected:
+
+        /**
+         * Updates the field entities in the manager.
+         */
+        virtual void UpdateField() = 0;
+
+        /**
+         * Updates the battle entities in the manager.
+         */
+        virtual void UpdateBattle() = 0;
+
+        /**
+         * Updates the world map entities in the manager.
+         */
+        virtual void UpdateWorld() = 0;
+
+        /**
+         * Updates the entities of one module in the manager.
+         *
+         * @param[in] module The module whose entities to update.
+         */
+        void Update(Module module);
+
+        /**
+         * The currently selected module.
+         */
+        Module module_;
+
+        /**
+         * The previous module.
+         */
+        Module prev_module_;
+
+        /**
+         * Indicates if the game is paused.
+         */
+        bool paused_;
+
+};

+ 92 - 92
src/core/SavemapManager.cpp → src/core/SavemapHandler.cpp

@@ -16,48 +16,46 @@
 #include <iostream>
 #include <string>
 #include <vector>
-#include "core/SavemapManager.h"
+#include "core/SavemapHandler.h"
 #include "core/Logger.h"
 
 /**
- * Savemap manager singleton.
+ * Savemap handler singleton.
  */
-template<>SavemapManager *Ogre::Singleton<SavemapManager>::msSingleton = nullptr;
+template<>SavemapHandler *Ogre::Singleton<SavemapHandler>::msSingleton = nullptr;
 
-int SavemapManager::MAX_SAVE_SLOTS(15);
+int SavemapHandler::MAX_SAVE_SLOTS(15);
 
-std::string SavemapManager::SAVE_PATH("save/");
+std::string SavemapHandler::SAVE_PATH("save/");
 
-SavemapManager::SavemapManager(): current_savemap_(nullptr), savemaps_read_(false){}
+SavemapHandler::SavemapHandler(): current_savemap_(nullptr), savemaps_read_(false){}
 
-SavemapManager::~SavemapManager(){
+SavemapHandler::~SavemapHandler(){
     //TODO
-    LOG_TRIVIAL("SavemapManager destroyed.");
+    LOG_TRIVIAL("SavemapHandler destroyed.");
 }
 
-Savemap SavemapManager::GetCurrentSavemap(){return *current_savemap_;}
+Savemap SavemapHandler::GetCurrentSavemap(){return *current_savemap_;}
 
-Savemap* SavemapManager::GetSavemap(unsigned int slot){
+Savemap* SavemapHandler::GetSavemap(unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return nullptr;
     if (!savemaps_read_) ReadSavemaps();
     return saved_savemaps_[slot];
 }
 
-std::vector<Savemap*> SavemapManager::GetSavemaps(){
+std::vector<Savemap*> SavemapHandler::GetSavemaps(){
     if (!savemaps_read_) ReadSavemaps();
     return saved_savemaps_;
 }
 
-bool SavemapManager::Save(unsigned int slot, const bool force){
+bool SavemapHandler::Save(unsigned int slot, const bool force){
     if (current_savemap_ == nullptr) return false;
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (!savemaps_read_) ReadSavemaps();
     if (
-        force == false && saved_savemaps_[slot]->IsEmpty() == false
+      force == false && saved_savemaps_[slot]->IsEmpty() == false
       && current_savemap_->GetControlKey() != saved_savemaps_[slot]->GetControlKey()
-    ){
-        return false;
-    }
+    ) return false;
     else{
         saved_savemaps_[slot] = current_savemap_;
         saved_savemaps_[slot]->Write(slot, SAVE_PATH + std::to_string(slot) + ".xml");
@@ -65,15 +63,13 @@ bool SavemapManager::Save(unsigned int slot, const bool force){
     }
 }
 
-bool SavemapManager::Save(Savemap savemap, unsigned int slot, bool force){
+bool SavemapHandler::Save(Savemap savemap, unsigned int slot, bool force){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (!savemaps_read_) ReadSavemaps();
     if (
       force == false && saved_savemaps_[slot]->IsEmpty() == false
       && savemap.GetControlKey() != saved_savemaps_[slot]->GetControlKey()
-    ){
-        return false;
-    }
+    ) return false;
     else{
         *current_savemap_ = savemap;
         saved_savemaps_[slot] = current_savemap_;
@@ -82,13 +78,13 @@ bool SavemapManager::Save(Savemap savemap, unsigned int slot, bool force){
     }
 }
 
-void SavemapManager::Release(){
+void SavemapHandler::Release(){
     current_savemap_ = nullptr;
     saved_savemaps_.clear();
     savemaps_read_ = false;
 }
 
-void SavemapManager::ReadSavemaps(){
+void SavemapHandler::ReadSavemaps(){
     saved_savemaps_.clear();
     for (int i = 0; i < MAX_SAVE_SLOTS; i ++){
         Savemap* savemap = new Savemap();
@@ -98,17 +94,17 @@ void SavemapManager::ReadSavemaps(){
     savemaps_read_ = true;
 }
 
-void SavemapManager::SetData(const unsigned int bank, const unsigned int address, const int value){
+void SavemapHandler::SetData(const unsigned int bank, const unsigned int address, const int value){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetData(bank, address, value);
 }
 
-void SavemapManager::SetControlKey(const char* control){
+void SavemapHandler::SetControlKey(const char* control){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetControlKey(std::string(control));
 }
 
-void SavemapManager::SetWindowColours(
+void SavemapHandler::SetWindowColours(
   const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
   const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
   const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
@@ -120,62 +116,62 @@ void SavemapManager::SetWindowColours(
     );
 }
 
-void SavemapManager::SetMoney(const unsigned int money){
+void SavemapHandler::SetMoney(const unsigned int money){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetMoney(money);
 }
 
-void SavemapManager::SetGameTime(const unsigned int seconds){
+void SavemapHandler::SetGameTime(const unsigned int seconds){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetGameTime(seconds);
 }
-void SavemapManager::SetCountdownTime(const unsigned int seconds){
+void SavemapHandler::SetCountdownTime(const unsigned int seconds){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetCountdownTime(seconds);
 }
 
-void SavemapManager::SetKeyItem(const unsigned int item, const bool owned){
+void SavemapHandler::SetKeyItem(const unsigned int item, const bool owned){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetKeyItem(item, owned);
 }
 
-void SavemapManager::SetParty(const int member_1, const int member_2, const int member_3){
+void SavemapHandler::SetParty(const int member_1, const int member_2, const int member_3){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetParty(member_1, member_2, member_3);
 }
 
-void SavemapManager::SetItem(
+void SavemapHandler::SetItem(
   const unsigned int slot, const unsigned int id, const unsigned int quantity
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetItem(slot, id, quantity);
 }
 
-void SavemapManager::SetMateria(const unsigned int slot, const int id, const unsigned int ap){
+void SavemapHandler::SetMateria(const unsigned int slot, const int id, const unsigned int ap){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetMateria(slot, id, ap);
 }
 
-void SavemapManager::SetESkillMateria(
+void SavemapHandler::SetESkillMateria(
   const unsigned slot, const unsigned int skill, const bool learned
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetESkillMateria(slot, skill, learned);
 }
 
-void SavemapManager::SetMateriaStash(const unsigned int slot, const int id, const unsigned int ap){
+void SavemapHandler::SetMateriaStash(const unsigned int slot, const int id, const unsigned int ap){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetMateriaStash(slot, id, ap);
 }
 
-void SavemapManager::SetESkillMateriaStash(
+void SavemapHandler::SetESkillMateriaStash(
   const unsigned slot, const unsigned int skill, const bool learned
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetESkillMateriaStash(slot, skill, learned);
 }
 
-void SavemapManager::SetLocation(
+void SavemapHandler::SetLocation(
   const float x, const float y, const float z,
   const unsigned int triangle, const int angle, const char* field, const char* name
 ){
@@ -183,12 +179,12 @@ void SavemapManager::SetLocation(
     current_savemap_->SetLocation(x, y, z, triangle, angle, std::string(field), std::string(name));
 }
 
-void SavemapManager::SetSetting(const unsigned int key, const unsigned int value){
+void SavemapHandler::SetSetting(const unsigned int key, const unsigned int value){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetSetting(key, value);
 }
 
-void SavemapManager::SetCharacterInfo(
+void SavemapHandler::SetCharacterInfo(
   const unsigned int id, const int char_id, const char* name,
   const bool enabled, const bool locked,
   const unsigned int level, const unsigned int kills,
@@ -203,14 +199,14 @@ void SavemapManager::SetCharacterInfo(
     );
 }
 
-void SavemapManager::SetCharacterStat(
+void SavemapHandler::SetCharacterStat(
   const unsigned int id, const unsigned int stat, const unsigned int base, const unsigned int extra
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetCharacterStat(id, stat, base, extra);
 }
 
-void SavemapManager::SetCharacterLimitLearned(
+void SavemapHandler::SetCharacterLimitLearned(
   const unsigned int id, const unsigned int level,
   const unsigned int technique, const bool learned, const unsigned int uses
 ){
@@ -218,7 +214,7 @@ void SavemapManager::SetCharacterLimitLearned(
     current_savemap_->SetCharacterLimitLearned(id, level, technique, learned, uses);
 }
 
-void SavemapManager::SetCharacterMateria(
+void SavemapHandler::SetCharacterMateria(
   const unsigned int id, const bool weapon, const unsigned int slot,
   const int materia, const unsigned int ap
 ){
@@ -226,7 +222,7 @@ void SavemapManager::SetCharacterMateria(
     current_savemap_->SetCharacterMateria(id, weapon, slot, materia, ap);
 }
 
-void SavemapManager::SetCharacterESkillMateria(
+void SavemapHandler::SetCharacterESkillMateria(
   const unsigned int id, const bool weapon, const unsigned int slot,
   const unsigned int skill, const bool learned
 ){
@@ -234,26 +230,26 @@ void SavemapManager::SetCharacterESkillMateria(
     current_savemap_->SetCharacterESkillMateria(id, weapon, slot, skill, learned);
 }
 
-void SavemapManager::SetCharacterStatus(
+void SavemapHandler::SetCharacterStatus(
   const unsigned int id, const unsigned int status, const bool inflicted
 ){
     if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
     current_savemap_->SetCharacterStatus(id, status, inflicted);
 }
 
-bool SavemapManager::IsSlotEmpty(const unsigned int slot){
+bool SavemapHandler::IsSlotEmpty(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return true;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsEmpty();
 }
 
-std::string SavemapManager::GetSlotControlKey(const unsigned int slot){
+std::string SavemapHandler::GetSlotControlKey(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return std::string("");
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetControlKey();
 }
 
-unsigned int SavemapManager::GetSlotWindowCornerColourComponent(
+unsigned int SavemapHandler::GetSlotWindowCornerColourComponent(
   const unsigned int slot, const unsigned int corner, const unsigned int comp
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -261,193 +257,197 @@ unsigned int SavemapManager::GetSlotWindowCornerColourComponent(
     return saved_savemaps_[slot]->GetWindowCornerColourComponent(corner, comp);
 }
 
-unsigned int SavemapManager::GetSlotMoney(const unsigned int slot){
+unsigned int SavemapHandler::GetSlotMoney(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetMoney();
 }
 
-unsigned int SavemapManager::GetSlotGameTime(const unsigned int slot){
+unsigned int SavemapHandler::GetSlotGameTime(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetGameTime();
 }
 
-unsigned int SavemapManager::GetSlotCountdownTime(const unsigned int slot){
+unsigned int SavemapHandler::GetSlotCountdownTime(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCountdownTime();
 }
 
-int SavemapManager::GetSlotPartyMember(const unsigned int slot, const unsigned int pos){
+int SavemapHandler::GetSlotPartyMember(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return -1;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetPartyMember(pos);
 }
 
-unsigned int SavemapManager::GetSlotItemAtPosId(const unsigned int slot, const unsigned int pos){
+unsigned int SavemapHandler::GetSlotItemAtPosId(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetItemAtPosId(pos);
 }
 
-unsigned int SavemapManager::GetSlotItemAtPosQty(const unsigned int slot, const unsigned int pos){
+unsigned int SavemapHandler::GetSlotItemAtPosQty(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetItemAtPosQty(pos);
 }
 
-bool SavemapManager::GetSlotKeyItem(const unsigned int slot, const unsigned int id){
+bool SavemapHandler::GetSlotKeyItem(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetKeyItem(id);
 }
 
-int SavemapManager::GetSlotMateriaAtPosId(const unsigned int slot, const unsigned int pos){
+int SavemapHandler::GetSlotMateriaAtPosId(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return -1;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetMateriaAtPosId(pos);
 }
 
-unsigned int SavemapManager::GetSlotMateriaAtPosAp(const unsigned int slot, const unsigned int pos){
+unsigned int SavemapHandler::GetSlotMateriaAtPosAp(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetMateriaAtPosAp(pos);
 }
 
-bool SavemapManager::IsSlotMateriaAtPosESkill(const unsigned int slot, const unsigned int pos){
+bool SavemapHandler::IsSlotMateriaAtPosESkill(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsMateriaAtPosESkill(pos);
 }
 
-bool SavemapManager::IsSlotMateriaAtPosESkillLearned(const unsigned int slot, const unsigned int pos, const unsigned int skill){
+bool SavemapHandler::IsSlotMateriaAtPosESkillLearned(
+  const unsigned int slot, const unsigned int pos, const unsigned int skill
+){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsMateriaAtPosESkillLearned(pos, skill);
 }
 
-int SavemapManager::GetSlotStashAtPosId(const unsigned int slot, const unsigned int pos){
+int SavemapHandler::GetSlotStashAtPosId(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return -1;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetStashAtPosId(pos);
 }
 
-unsigned int SavemapManager::GetSlotStashAtPosAp(const unsigned int slot, const unsigned int pos){
+unsigned int SavemapHandler::GetSlotStashAtPosAp(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetStashAtPosAp(pos);
 }
 
-bool SavemapManager::IsSlotStashAtPosESkill(const unsigned int slot, const unsigned int pos){
+bool SavemapHandler::IsSlotStashAtPosESkill(const unsigned int slot, const unsigned int pos){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsStashAtPosESkill(pos);
 }
 
-bool SavemapManager::IsSlotStashAtPosESkillLearned(const unsigned int slot, const unsigned int pos, const unsigned int skill){
+bool SavemapHandler::IsSlotStashAtPosESkillLearned(
+  const unsigned int slot, const unsigned int pos, const unsigned int skill
+){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsStashAtPosESkillLearned(pos, skill);
 }
 
-float SavemapManager::GetSlotLocationX(const unsigned int slot){
+float SavemapHandler::GetSlotLocationX(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0.0f;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationX();
 }
 
-float SavemapManager::GetSlotLocationY(const unsigned int slot){
+float SavemapHandler::GetSlotLocationY(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0.0f;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationY();
 }
 
-float SavemapManager::GetSlotLocationZ(const unsigned int slot){
+float SavemapHandler::GetSlotLocationZ(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return -1.0f;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationZ();
 }
 
-unsigned int SavemapManager::GetSlotLocationTriangle(const unsigned int slot){
+unsigned int SavemapHandler::GetSlotLocationTriangle(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationTriangle();
 }
 
-int SavemapManager::GetSlotLocationAngle(const unsigned int slot){
+int SavemapHandler::GetSlotLocationAngle(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationAngle();
 }
 
-std::string SavemapManager::GetSlotLocationField(const unsigned int slot){
+std::string SavemapHandler::GetSlotLocationField(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return "";
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationField();
 }
 
-std::string SavemapManager::GetSlotLocationName(const unsigned int slot){
+std::string SavemapHandler::GetSlotLocationName(const unsigned int slot){
     if (slot >= MAX_SAVE_SLOTS) return "";
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetLocationName();
 }
 
-int SavemapManager::GetSlotSetting(const unsigned int slot, const unsigned int key){
+int SavemapHandler::GetSlotSetting(const unsigned int slot, const unsigned int key){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetSetting(key);
 }
 
-int SavemapManager::GetSlotCharacterCharId(const unsigned int slot, const unsigned int id){
+int SavemapHandler::GetSlotCharacterCharId(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterCharId(id);
 }
 
-std::string SavemapManager::GetSlotCharacterName(const unsigned int slot, const unsigned int id){
+std::string SavemapHandler::GetSlotCharacterName(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return "";
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterName(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterLevel(const unsigned int slot, const unsigned int id){
+unsigned int SavemapHandler::GetSlotCharacterLevel(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return 1;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterLevel(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterKills(const unsigned int slot, const unsigned int id){
+unsigned int SavemapHandler::GetSlotCharacterKills(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterKills(id);
 }
 
-bool SavemapManager::IsSlotCharacterEnabled(const unsigned int slot, const unsigned int id){
+bool SavemapHandler::IsSlotCharacterEnabled(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsCharacterEnabled(id);
 }
 
-bool SavemapManager::IsSlotCharacterLocked(const unsigned int slot, const unsigned int id){
+bool SavemapHandler::IsSlotCharacterLocked(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsCharacterLocked(id);
 }
 
-bool SavemapManager::IsSlotCharacterBackRow(const unsigned int slot, const unsigned int id){
+bool SavemapHandler::IsSlotCharacterBackRow(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return false;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->IsCharacterBackRow(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterExp(const unsigned int slot, const unsigned int id){
+unsigned int SavemapHandler::GetSlotCharacterExp(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return 0;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterExp(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterExpToNext(
+unsigned int SavemapHandler::GetSlotCharacterExpToNext(
   const unsigned int slot, const unsigned int id
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -455,7 +455,7 @@ unsigned int SavemapManager::GetSlotCharacterExpToNext(
     return saved_savemaps_[slot]->GetCharacterExpToNext(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterLimitLevel(
+unsigned int SavemapHandler::GetSlotCharacterLimitLevel(
   const unsigned int slot, const unsigned int id
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -463,7 +463,7 @@ unsigned int SavemapManager::GetSlotCharacterLimitLevel(
     return saved_savemaps_[slot]->GetCharacterLimitLevel(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterLimitBar(
+unsigned int SavemapHandler::GetSlotCharacterLimitBar(
   const unsigned int slot, const unsigned int id
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -471,7 +471,7 @@ unsigned int SavemapManager::GetSlotCharacterLimitBar(
     return saved_savemaps_[slot]->GetCharacterLimitBar(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterWeaponId(
+unsigned int SavemapHandler::GetSlotCharacterWeaponId(
   const unsigned int slot, const unsigned int id
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -479,7 +479,7 @@ unsigned int SavemapManager::GetSlotCharacterWeaponId(
     return saved_savemaps_[slot]->GetCharacterWeaponId(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterArmorId(
+unsigned int SavemapHandler::GetSlotCharacterArmorId(
   const unsigned int slot, const unsigned int id
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -487,13 +487,13 @@ unsigned int SavemapManager::GetSlotCharacterArmorId(
     return saved_savemaps_[slot]->GetCharacterArmorId(id);
 }
 
-int SavemapManager::GetSlotCharacterAccessoryId(const unsigned int slot, const unsigned int id){
+int SavemapHandler::GetSlotCharacterAccessoryId(const unsigned int slot, const unsigned int id){
     if (slot >= MAX_SAVE_SLOTS) return -1;
     if (savemaps_read_ == false) ReadSavemaps();
     return saved_savemaps_[slot]->GetCharacterAccessoryId(id);
 }
 
-unsigned int SavemapManager::GetSlotCharacterStatBase(
+unsigned int SavemapHandler::GetSlotCharacterStatBase(
   const unsigned int slot, const unsigned int id, const unsigned int stat
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -501,7 +501,7 @@ unsigned int SavemapManager::GetSlotCharacterStatBase(
     return saved_savemaps_[slot]->GetCharacterStatBase(id, stat);
 }
 
-unsigned int SavemapManager::GetSlotCharacterStatExtra(
+unsigned int SavemapHandler::GetSlotCharacterStatExtra(
   const unsigned int slot, const unsigned int id, const unsigned int stat
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -509,7 +509,7 @@ unsigned int SavemapManager::GetSlotCharacterStatExtra(
     return saved_savemaps_[slot]->GetCharacterStatExtra(id, stat);
 }
 
-unsigned int SavemapManager::GetSlotCharacterLimitUses(
+unsigned int SavemapHandler::GetSlotCharacterLimitUses(
   const unsigned int slot, const unsigned int id, const unsigned int level
 ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -517,7 +517,7 @@ unsigned int SavemapManager::GetSlotCharacterLimitUses(
     return saved_savemaps_[slot]->GetCharacterLimitUses(id, level);
 }
 
-bool SavemapManager::IsSlotCharacterLimitLearned(
+bool SavemapHandler::IsSlotCharacterLimitLearned(
   const unsigned int slot, const unsigned int id, const unsigned int level, const unsigned int tech
 ){
     if (slot >= MAX_SAVE_SLOTS) return false;
@@ -525,7 +525,7 @@ bool SavemapManager::IsSlotCharacterLimitLearned(
     return saved_savemaps_[slot]->IsCharacterLimitLearned(id, level, tech);
 }
 
-int SavemapManager::GetSlotCharacterMateriaId(
+int SavemapHandler::GetSlotCharacterMateriaId(
   const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
 ){
     if (slot >= MAX_SAVE_SLOTS) return -1;
@@ -533,7 +533,7 @@ int SavemapManager::GetSlotCharacterMateriaId(
     return saved_savemaps_[slot]->GetCharacterMateriaId(id, weapon, pos);
 }
 
-unsigned int SavemapManager::GetSlotCharacterMateriaAp(
+unsigned int SavemapHandler::GetSlotCharacterMateriaAp(
   const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  ){
     if (slot >= MAX_SAVE_SLOTS) return 0;
@@ -541,7 +541,7 @@ unsigned int SavemapManager::GetSlotCharacterMateriaAp(
     return saved_savemaps_[slot]->GetCharacterMateriaAp(id, weapon, pos);
 }
 
-bool SavemapManager::IsSlotCharacterMateriaESkill(
+bool SavemapHandler::IsSlotCharacterMateriaESkill(
   const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
 ){
     if (slot >= MAX_SAVE_SLOTS) return false;
@@ -549,7 +549,7 @@ bool SavemapManager::IsSlotCharacterMateriaESkill(
     return saved_savemaps_[slot]->IsCharacterMateriaESkill(id, weapon, pos);
 }
 
-bool SavemapManager::IsSlotCharacterMateriaESkillLearned(
+bool SavemapHandler::IsSlotCharacterMateriaESkillLearned(
   const unsigned int slot, const unsigned int id, const bool weapon,
   const unsigned int pos, const unsigned int skill
 ){
@@ -558,7 +558,7 @@ bool SavemapManager::IsSlotCharacterMateriaESkillLearned(
     return saved_savemaps_[slot]->IsCharacterMateriaESkillLearned(id, weapon, pos, skill);
 }
 
-int SavemapManager::GetSlotData(
+int SavemapHandler::GetSlotData(
   const unsigned int slot, const unsigned int bank, const unsigned int address
 ){
     if (slot >= MAX_SAVE_SLOTS) return false;

+ 6 - 4
src/core/SavemapManager.h → src/core/SavemapHandler.h

@@ -20,8 +20,10 @@
 #include <OgreColourValue.h>
 #include "core/Savemap.h"
 
-
-class SavemapManager : public Ogre::Singleton<SavemapManager>{
+/**
+ * A handler for savemaps.
+ */
+class SavemapHandler : public Ogre::Singleton<SavemapHandler>{
 
     public:
 
@@ -33,12 +35,12 @@ class SavemapManager : public Ogre::Singleton<SavemapManager>{
         /**
          * Constructor.
          */
-        SavemapManager();
+        SavemapHandler();
 
         /**
          * Destructor.
          */
-        virtual ~SavemapManager();
+        virtual ~SavemapHandler();
 
         /**
          * Retrieves the current savemap.

+ 16 - 0
src/core/ScriptManager.cpp

@@ -315,6 +315,16 @@ void ScriptManager::Update(const ScriptManager::Type type){
     }
 }
 
+void ScriptManager::UpdateDebug(){}
+
+void ScriptManager::OnResize(){}
+
+void ScriptManager::ClearField(){}
+
+void ScriptManager::ClearBattle(){}
+
+void ScriptManager::ClearWorld(){}
+
 void ScriptManager::RunString(const Ogre::String& lua){
     int pre_eval_index = lua_gettop(lua_state_);
     if (luaL_dostring(lua_state_, lua.c_str()) == 1)
@@ -624,3 +634,9 @@ void ScriptManager::AddValueToStack(const float value){
     QueueScript* script = GetScriptByScriptId(current_script_id_);
     if (script != nullptr) lua_pushnumber(script->state, value);
 }
+
+void ScriptManager::UpdateField(){}
+
+void ScriptManager::UpdateBattle(){}
+
+void ScriptManager::UpdateWorld(){}

+ 43 - 29
src/core/ScriptManager.h

@@ -19,6 +19,7 @@
 #include <OgreString.h>
 #include "Event.h"
 #include "LuaIncludes.h"
+#include "Manager.h"
 
 class Entity;
 
@@ -127,7 +128,7 @@ struct QueueScript{
 
 
 
-class ScriptManager : public Ogre::Singleton<ScriptManager>{
+class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
 
     public:
 
@@ -165,33 +166,6 @@ class ScriptManager : public Ogre::Singleton<ScriptManager>{
             FIELD
         };
 
-        /**
-         * The modules the script manager can handle.
-         */
-        enum MODULE{
-
-            /**
-             * Field module.
-             *
-             * Used in field maps. It has background, walkmesh, entities...
-             */
-            FIELD = 0,
-
-            /**
-             * Battle module.
-             *
-             * Used in battles. During battles there is no walkmesh.
-             */
-            BATTLE = 1,
-
-            /**
-             * World map module.
-             *
-             * Used in the world map. It has background, walkmesh, entities...
-             */
-            WORLD = 2
-        };
-
         /**
          * Constructor.
          */
@@ -207,7 +181,7 @@ class ScriptManager : public Ogre::Singleton<ScriptManager>{
          *
          * @param[in] event The event to handle.
          */
-        void Input(const VGears::Event& event);
+        void Input(const VGears::Event& event) override;
 
         /**
          * Updates the state of all scripts of a given type.
@@ -216,6 +190,31 @@ class ScriptManager : public Ogre::Singleton<ScriptManager>{
          */
         void Update(const Type type);
 
+        /**
+         * Updates the script in the manager with debug information.
+         */
+        void UpdateDebug() override;
+
+        /**
+         * Handles resizing events
+         */
+        void OnResize() override;
+
+        /**
+         * Clears all field information in the script manager.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle information in the script manager.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map information in the script manager.
+         */
+        void ClearWorld() override;
+
         /**
          * Runs a lua command string.
          *
@@ -422,6 +421,21 @@ class ScriptManager : public Ogre::Singleton<ScriptManager>{
 
     private:
 
+        /**
+         * Updates the script while in a field.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the scripts during a battle.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates the scripts while on the world map.
+         */
+        void UpdateWorld() override;
+
         /**
          * Lua state.
          */

+ 146 - 142
src/core/ScriptManagerBinds.h

@@ -23,14 +23,14 @@
 #include "EntityManager.h"
 #include "BattleManager.h"
 #include "AudioManager.h"
-#include "SavemapManager.h"
+#include "SavemapHandler.h"
 #include "Timer.h"
 #include "UiManager.h"
 #include "UiWidget.h"
 #include "XmlMapFile.h"
 #include "XmlMapsFile.h"
 #include "DialogsManager.h"
-#include "TextManager.h"
+#include "TextHandler.h"
 
 
 /*
@@ -267,7 +267,6 @@ void ScriptManager::InitBinds(){
             "set_entity_to_character",
             (void(EntityManager::*)(const char*, unsigned int)) &EntityManager::SetEntityToCharacter
           )
-          .def("get_track_id", (int(EntityManager::*)(int)) &EntityManager::GetTrack)
     ];
 
     // Commands for the battle manager.
@@ -293,6 +292,11 @@ void ScriptManager::InitBinds(){
             (void(AudioManager::*)(const char*, const char*, const char*, const char*))
             &AudioManager::ScriptPlaySounds
           )
+          .def("get_track_id", (int(AudioManager::*)(int)) &AudioManager::ScriptGetTrack)
+          .def("get_battle_track_id", (int(AudioManager::*)()) &AudioManager::ScriptGetBattleTrack)
+          .def(
+            "set_battle_track_id", (void(AudioManager::*)(int)) &AudioManager::ScriptSetBattleTrack
+          )
     ];
 
     // Commands for the audio manager.
@@ -305,384 +309,384 @@ void ScriptManager::InitBinds(){
            )
     ];
 
-    // Commands for the savemap manager.
+    // Commands for the savemap handelr.
     luabind::module(lua_state_)[
-        luabind::class_<SavemapManager>("SavemapManager")
+        luabind::class_<SavemapHandler>("SavemapHandler")
           .def(
-            "release", (void(SavemapManager::*)()) &SavemapManager::Release
+            "release", (void(SavemapHandler::*)()) &SavemapHandler::Release
           )
           .def(
             "get_current_savemap",
-            (Savemap*(SavemapManager::*)()) &SavemapManager::GetCurrentSavemap
+            (Savemap*(SavemapHandler::*)()) &SavemapHandler::GetCurrentSavemap
           )
           .def(
             "get_savemap",
-            (Savemap*(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSavemap
+            (Savemap*(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSavemap
           )
           .def(
             "set_data",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const int))
-              &SavemapManager::SetData
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const int))
+              &SavemapHandler::SetData
           )
           .def(
-            "set_control_key", (void(SavemapManager::*)(const char*)) &SavemapManager::SetControlKey
+            "set_control_key", (void(SavemapHandler::*)(const char*)) &SavemapHandler::SetControlKey
           )
           .def(
             "set_window_colours",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int,
               const unsigned int, const unsigned int, const unsigned int,
               const unsigned int, const unsigned int, const unsigned int,
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::SetWindowColours
+            )) &SavemapHandler::SetWindowColours
           )
-          .def("set_money", (void(SavemapManager::*)(const unsigned int)) &SavemapManager::SetMoney)
+          .def("set_money", (void(SavemapHandler::*)(const unsigned int)) &SavemapHandler::SetMoney)
           .def(
             "set_game_time",
-            (void(SavemapManager::*)(const unsigned int)) &SavemapManager::SetGameTime
+            (void(SavemapHandler::*)(const unsigned int)) &SavemapHandler::SetGameTime
           )
           .def(
             "set_countdown_time",
-            (void(SavemapManager::*)(const unsigned int)) &SavemapManager::SetCountdownTime
+            (void(SavemapHandler::*)(const unsigned int)) &SavemapHandler::SetCountdownTime
           )
           .def(
             "set_key_item",
-            (void(SavemapManager::*)(const unsigned int, const bool)) &SavemapManager::SetKeyItem
+            (void(SavemapHandler::*)(const unsigned int, const bool)) &SavemapHandler::SetKeyItem
           )
           .def(
             "set_party",
-            (void(SavemapManager::*)(const int, const int, const int)) &SavemapManager::SetParty
+            (void(SavemapHandler::*)(const int, const int, const int)) &SavemapHandler::SetParty
           )
           .def(
             "set_item",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const unsigned int))
-              &SavemapManager::SetItem
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const unsigned int))
+              &SavemapHandler::SetItem
           )
           .def(
             "set_materia",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const unsigned int))
-              &SavemapManager::SetMateria
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const unsigned int))
+              &SavemapHandler::SetMateria
           )
           .def(
             "set_e_skill_materia",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const bool))
-              &SavemapManager::SetESkillMateria
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const bool))
+              &SavemapHandler::SetESkillMateria
           )
           .def(
             "set_materia_stash",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const unsigned int))
-              &SavemapManager::SetMateriaStash
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const unsigned int))
+              &SavemapHandler::SetMateriaStash
           )
           .def(
             "set_e_skill_materia_stash",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const bool))
-              &SavemapManager::SetESkillMateriaStash
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const bool))
+              &SavemapHandler::SetESkillMateriaStash
           )
           .def(
             "set_location",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const float, const float, const float, const unsigned int, const int,
               const char*, const char*
-            )) &SavemapManager::SetLocation
+            )) &SavemapHandler::SetLocation
           )
           .def(
             "set_setting",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::SetSetting
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::SetSetting
           )
           .def(
             "set_character_info",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const int, const char*, const bool, const bool, const unsigned int,
               const unsigned int, const bool, const unsigned int, const unsigned int,
               const unsigned int, const unsigned int, const unsigned int, const unsigned int,
               const int
-            )) &SavemapManager::SetCharacterInfo
+            )) &SavemapHandler::SetCharacterInfo
           )
           .def(
             "set_character_stat",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::SetCharacterStat
+            )) &SavemapHandler::SetCharacterStat
           )
           .def(
             "set_character_limit_learned",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int,
               const bool, const unsigned int
-            )) &SavemapManager::SetCharacterLimitLearned
+            )) &SavemapHandler::SetCharacterLimitLearned
           )
           .def(
             "set_character_materia",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const bool, const unsigned int,
               const unsigned int, const unsigned int
-            )) &SavemapManager::SetCharacterMateria
+            )) &SavemapHandler::SetCharacterMateria
           )
           .def(
             "set_character_e_skill_materia",
-            (void(SavemapManager::*)(
+            (void(SavemapHandler::*)(
               const unsigned int, const bool, const unsigned int, const unsigned int, const bool
-            )) &SavemapManager::SetCharacterESkillMateria
+            )) &SavemapHandler::SetCharacterESkillMateria
           )
           .def(
             "set_character_status",
-            (void(SavemapManager::*)(const unsigned int, const unsigned int, const bool))
-              &SavemapManager::SetCharacterStatus
+            (void(SavemapHandler::*)(const unsigned int, const unsigned int, const bool))
+              &SavemapHandler::SetCharacterStatus
           )
           .def(
-            "save", (bool(SavemapManager::*)(const unsigned int, const bool)) &SavemapManager::Save
+            "save", (bool(SavemapHandler::*)(const unsigned int, const bool)) &SavemapHandler::Save
           )
           .def(
             "is_slot_empty",
-            (bool(SavemapManager::*)(const unsigned int)) &SavemapManager::IsSlotEmpty
+            (bool(SavemapHandler::*)(const unsigned int)) &SavemapHandler::IsSlotEmpty
           )
           .def(
             "get_slot_control_key",
-            (std::string(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotControlKey
+            (std::string(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotControlKey
           )
           .def(
             "get_slot_control_key",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::GetSlotWindowCornerColourComponent
+            )) &SavemapHandler::GetSlotWindowCornerColourComponent
           )
           .def(
             "get_slot_money",
-            (unsigned int(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotMoney
+            (unsigned int(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotMoney
           )
           .def(
             "get_slot_game_time",
-            (unsigned int(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotGameTime
+            (unsigned int(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotGameTime
           )
           .def(
             "get_slot_countdown_time",
-            (unsigned int(SavemapManager::*)(const unsigned int))
-              &SavemapManager::GetSlotCountdownTime
+            (unsigned int(SavemapHandler::*)(const unsigned int))
+              &SavemapHandler::GetSlotCountdownTime
           )
           .def(
             "get_slot_party_member",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotPartyMember
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotPartyMember
           )
           .def(
             "get_slot_item_at_pos_id",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotItemAtPosId
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotItemAtPosId
           )
           .def(
             "get_slot_item_at_pos_qty",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotItemAtPosQty
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotItemAtPosQty
           )
           .def(
             "get_slot_key_item",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotKeyItem
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotKeyItem
           )
           .def(
             "get_slot_materia_at_pos_id",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotMateriaAtPosId
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotMateriaAtPosId
           )
           .def(
             "get_slot_materia_at_pos_ap",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotMateriaAtPosAp
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotMateriaAtPosAp
           )
           .def(
             "is_slot_materia_at_pos_e_skill",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::IsSlotMateriaAtPosESkill
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::IsSlotMateriaAtPosESkill
           )
           .def(
             "is_slot_materia_at_pos_e_skill_learned",
-            (bool(SavemapManager::*)(
+            (bool(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::IsSlotMateriaAtPosESkillLearned
+            )) &SavemapHandler::IsSlotMateriaAtPosESkillLearned
           )
           .def(
             "get_slot_stash_at_pos_id",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotStashAtPosId
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotStashAtPosId
           )
           .def(
             "get_slot_stash_at_pos_ap",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotStashAtPosAp
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotStashAtPosAp
           )
           .def(
             "is_slot_stash_at_pos_e_skill",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::IsSlotStashAtPosESkill
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::IsSlotStashAtPosESkill
           )
           .def(
             "is_slot_stash_at_pos_e_skill_learned",
-            (bool(SavemapManager::*)(
+            (bool(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::IsSlotStashAtPosESkillLearned
+            )) &SavemapHandler::IsSlotStashAtPosESkillLearned
           )
           .def(
             "get_slot_location_x",
-            (float(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotLocationX
+            (float(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotLocationX
           )
           .def(
             "get_slot_location_y",
-            (float(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotLocationY
+            (float(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotLocationY
           )
           .def(
             "get_slot_location_z",
-            (float(SavemapManager::*)(const unsigned int)) &SavemapManager::GetSlotLocationZ
+            (float(SavemapHandler::*)(const unsigned int)) &SavemapHandler::GetSlotLocationZ
           )
           .def(
             "get_slot_location_triangle",
-            (unsigned int(SavemapManager::*)(const unsigned int))
-              &SavemapManager::GetSlotLocationTriangle
+            (unsigned int(SavemapHandler::*)(const unsigned int))
+              &SavemapHandler::GetSlotLocationTriangle
           )
           .def(
             "get_slot_location_angle",
-            (unsigned int(SavemapManager::*)(const unsigned int))
-              &SavemapManager::GetSlotLocationAngle
+            (unsigned int(SavemapHandler::*)(const unsigned int))
+              &SavemapHandler::GetSlotLocationAngle
           )
           .def(
             "get_slot_location_field",
-            (std::string(SavemapManager::*)(const unsigned int))
-              &SavemapManager::GetSlotLocationField
+            (std::string(SavemapHandler::*)(const unsigned int))
+              &SavemapHandler::GetSlotLocationField
           )
           .def(
             "get_slot_location_name",
-            (std::string(SavemapManager::*)(const unsigned int))
-              &SavemapManager::GetSlotLocationName
+            (std::string(SavemapHandler::*)(const unsigned int))
+              &SavemapHandler::GetSlotLocationName
           )
           .def(
             "get_slot_setting",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotSetting
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotSetting
           )
           .def(
             "get_slot_character_char_id",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterCharId
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterCharId
           )
           .def(
             "get_slot_character_name",
-            (std::string(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterName
+            (std::string(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterName
           )
           .def(
             "get_slot_character_level",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterLevel
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterLevel
           )
           .def(
             "get_slot_character_kills",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterKills
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterKills
           )
           .def(
             "is_slot_character_enabled",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::IsSlotCharacterEnabled
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::IsSlotCharacterEnabled
           )
           .def(
             "is_slot_character_locked",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::IsSlotCharacterLocked
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::IsSlotCharacterLocked
           )
           .def(
             "is_slot_character_back_row",
-            (bool(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::IsSlotCharacterBackRow
+            (bool(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::IsSlotCharacterBackRow
           )
           .def(
             "get_slot_character_exp",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterExp
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterExp
           )
           .def(
             "get_slot_character_exp_to_next",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterExpToNext
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterExpToNext
           )
           .def(
             "get_slot_character_limit_level",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterLimitLevel
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterLimitLevel
           )
           .def(
             "get_slot_character_limit_bar",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterLimitBar
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterLimitBar
           )
           .def(
             "get_slot_character_weapon_id",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterWeaponId
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterWeaponId
           )
           .def(
             "get_slot_character_armor_id",
-            (unsigned int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterArmorId
+            (unsigned int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterArmorId
           )
           .def(
             "get_slot_character_accessory_id",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotCharacterAccessoryId
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotCharacterAccessoryId
           )
           .def(
             "get_slot_character_stat_base",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::GetSlotCharacterStatBase
+            )) &SavemapHandler::GetSlotCharacterStatBase
           )
           .def(
             "get_slot_character_stat_extra",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::GetSlotCharacterStatExtra
+            )) &SavemapHandler::GetSlotCharacterStatExtra
           )
           .def(
             "get_slot_character_limit_uses",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::GetSlotCharacterLimitUses
+            )) &SavemapHandler::GetSlotCharacterLimitUses
           )
           .def(
             "is_slot_character_limit_learned",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const unsigned int, const unsigned int
-            )) &SavemapManager::IsSlotCharacterLimitLearned
+            )) &SavemapHandler::IsSlotCharacterLimitLearned
           )
           .def(
             "get_slot_character_materia_id",
-            (int(SavemapManager::*)(
+            (int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const bool, const unsigned int
-            )) &SavemapManager::GetSlotCharacterMateriaId
+            )) &SavemapHandler::GetSlotCharacterMateriaId
           )
           .def(
             "get_slot_character_materia_ap",
-            (unsigned int(SavemapManager::*)(
+            (unsigned int(SavemapHandler::*)(
               const unsigned int, const unsigned int, const bool, const unsigned int
-            )) &SavemapManager::GetSlotCharacterMateriaAp
+            )) &SavemapHandler::GetSlotCharacterMateriaAp
           )
           .def(
             "get_slot_character_materia_e_skill",
-            (bool(SavemapManager::*)(
+            (bool(SavemapHandler::*)(
               const unsigned int, const unsigned int, const bool,
               const unsigned int, const unsigned int
-            )) &SavemapManager::IsSlotCharacterMateriaESkill
+            )) &SavemapHandler::IsSlotCharacterMateriaESkill
           )
           .def(
             "get_slot_character_materia_e_skill_learned",
-            (bool(SavemapManager::*)(
+            (bool(SavemapHandler::*)(
               const unsigned int, const unsigned int, const bool,
               const unsigned int, const unsigned int
-            )) &SavemapManager::IsSlotCharacterMateriaESkillLearned
+            )) &SavemapHandler::IsSlotCharacterMateriaESkillLearned
           )
           .def(
             "get_slot_data",
-            (int(SavemapManager::*)(const unsigned int, const unsigned int, const unsigned int))
-              &SavemapManager::GetSlotData
+            (int(SavemapHandler::*)(const unsigned int, const unsigned int, const unsigned int))
+              &SavemapHandler::GetSlotData
           )
     ];
 
@@ -737,14 +741,14 @@ void ScriptManager::InitBinds(){
           .def("is_locked", (bool(Walkmesh ::*)(unsigned int)) &Walkmesh ::IsLocked)
     ];
 
-    // Text manager commands
+    // Text handler commands
     luabind::module(lua_state_)[
-        luabind::class_<TextManager>("TextManager")
+        luabind::class_<TextHandler>("TextHandler")
           .def(
             "set_character_name",
-            (void(TextManager ::*)(unsigned int, const char*)) &TextManager::SetCharacterName
+            (void(TextHandler ::*)(unsigned int, const char*)) &TextHandler::SetCharacterName
           )
-          .def("set_party", (void(TextManager ::*)(int, int, int)) &TextManager::SetParty)
+          .def("set_party", (void(TextHandler ::*)(int, int, int)) &TextHandler::SetParty)
     ];
 
     // Dialog commands
@@ -910,12 +914,12 @@ void ScriptManager::InitBinds(){
       = boost::ref(*(BattleManager::getSingletonPtr()));
     luabind::globals(lua_state_)["audio_manager"] = boost::ref(*(AudioManager::getSingletonPtr()));
     luabind::globals(lua_state_)["savemap_manager"]
-      = boost::ref(*(SavemapManager::getSingletonPtr()));
+      = boost::ref(*(SavemapHandler::getSingletonPtr()));
     luabind::globals(lua_state_)["background2d"]
       = boost::ref(*(EntityManager::getSingletonPtr()->GetBackground2D()));
     luabind::globals(lua_state_)["walkmesh"]
       = boost::ref(*(EntityManager::getSingletonPtr()->GetWalkmesh()));
-    luabind::globals(lua_state_)["text_manager"] = boost::ref(*(TextManager::getSingletonPtr()));
+    luabind::globals(lua_state_)["text_manager"] = boost::ref(*(TextHandler::getSingletonPtr()));
     luabind::globals(lua_state_)["dialog"] = boost::ref(*(DialogsManager::getSingletonPtr()));
     luabind::globals(lua_state_)["ui_manager"] = boost::ref(*(UiManager::getSingletonPtr()));
     luabind::globals(lua_state_)["world_map_module"]

+ 3 - 3
src/core/ScriptManagerCommands.h

@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  */
 
-#include "ConfigCmdManager.h"
+#include "ConfigCmdHandler.h"
 #include "Console.h"
 
 /**
@@ -53,10 +53,10 @@ void CmdScriptRunFile(const Ogre::StringVector& params){
 }
 
 void ScriptManager::InitCmd(){
-    ConfigCmdManager::getSingleton().AddCommand(
+    ConfigCmdHandler::getSingleton().AddCommand(
       "script_run_string", "Run script string", "", CmdScriptRunString, NULL
     );
-    ConfigCmdManager::getSingleton().AddCommand(
+    ConfigCmdHandler::getSingleton().AddCommand(
       "script_run_file", "Run script file", "", CmdScriptRunFile, NULL
     );
 }

+ 20 - 19
src/core/TextManager.cpp → src/core/TextHandler.cpp

@@ -13,47 +13,48 @@
  * GNU General Public License for more details.
  */
 
+#include "TextHandler.h"
+
 #include <iostream>
-#include "core/TextManager.h"
-#include "core/TextManagerCommands.h"
+#include "core/TextHandlerCommands.h"
 #include "core/XmlTextsFile.h"
 #include "core/XmlTextFile.h"
 
 /**
- * Text manager singleton.
+ * Text handler singleton.
  */
-template<>TextManager* Ogre::Singleton< TextManager >::msSingleton = NULL;
+template<>TextHandler* Ogre::Singleton<TextHandler>::msSingleton = NULL;
 
-TextManager::TextManager(): language_(""){
+TextHandler::TextHandler(): language_(""){
     for (int i = 0; i < 3; i ++) current_party_[i] = -1;
     for (int i = 0; i < 11; i ++) character_names_[i] = std::string("CHAR_") + std::to_string(i);
     InitCmd();
 }
 
-TextManager::~TextManager(){UnloadTexts();}
+TextHandler::~TextHandler(){UnloadTexts();}
 
-void TextManager::LoadFieldText(const std::string file_name){
+void TextHandler::LoadFieldText(const std::string file_name){
     XmlTextFile texts("./data/" + file_name);
     texts.LoadTexts();
 }
 
-void TextManager::SetLanguage(const Ogre::String& language){
+void TextHandler::SetLanguage(const Ogre::String& language){
     language_ = language;
     UnloadTexts();
     XmlTextsFile texts("./data/texts.xml");
     texts.LoadTexts();
 }
 
-const Ogre::String& TextManager::GetLanguage(){return language_;}
+const Ogre::String& TextHandler::GetLanguage(){return language_;}
 
-void TextManager::AddText(const Ogre::String& name, TiXmlNode* node){
+void TextHandler::AddText(const Ogre::String& name, TiXmlNode* node){
     Text text;
     text.name = name;
     text.node = node;
     texts_.push_back(text);
 }
 
-void TextManager::AddDialog(
+void TextHandler::AddDialog(
   const Ogre::String& name, TiXmlNode* node, const float width, const float height
 ){
     Dialog dialog;
@@ -64,14 +65,14 @@ void TextManager::AddDialog(
     dialogs_.push_back(dialog);
 }
 
-TiXmlNode* TextManager::GetText(const Ogre::String& name) const{
+TiXmlNode* TextHandler::GetText(const Ogre::String& name) const{
     for (unsigned int i = 0; i < texts_.size(); ++ i)
         if (texts_[i].name == name) return texts_[i].node;
     LOG_WARNING("Can't find text '" + name + "'.");
     return NULL;
 }
 
-TiXmlNode* TextManager::GetDialog(const Ogre::String& name, float &width, float& height) const{
+TiXmlNode* TextHandler::GetDialog(const Ogre::String& name, float &width, float& height) const{
     for (unsigned int i = 0; i < dialogs_.size(); ++ i){
         if (dialogs_[i].name == name){
             width = dialogs_[i].width;
@@ -82,7 +83,7 @@ TiXmlNode* TextManager::GetDialog(const Ogre::String& name, float &width, float&
     return NULL;
 }
 
-std::string TextManager::GetDialogText(const std::string name){
+std::string TextHandler::GetDialogText(const std::string name){
     std::string text = "";
     for (unsigned int i = 0; i < dialogs_.size(); ++ i){
         if (dialogs_[i].name == name){
@@ -92,19 +93,19 @@ std::string TextManager::GetDialogText(const std::string name){
     }
     return text;
 }
-void TextManager::UnloadTexts(){
+void TextHandler::UnloadTexts(){
     for (unsigned int i = 0; i < texts_.size(); ++ i) delete texts_[i].node;
     texts_.clear();
     for (unsigned int i = 0; i < dialogs_.size(); ++ i) delete dialogs_[i].node;
     dialogs_.clear();
 }
 
-std::string TextManager::GetCharacterName(int id){
+std::string TextHandler::GetCharacterName(int id){
     if (id >= 0 && id < 11) return character_names_[id];
     else return std::string("UNKNOWN_CHAR_" + id);
 }
 
-std::string TextManager::GetPartyCharacterName(int position){
+std::string TextHandler::GetPartyCharacterName(int position){
     if (position >= 1 && position <= 3){
         if (current_party_[position - 1] < 0) return "";
         else return GetCharacterName(current_party_[position - 1]);
@@ -112,12 +113,12 @@ std::string TextManager::GetPartyCharacterName(int position){
     else return std::string("UNKNOWN_PARTY_POS_" + position);
 }
 
-void TextManager::SetCharacterName(int id, char* name){
+void TextHandler::SetCharacterName(int id, char* name){
     if (id >= 0 && id < 11) character_names_[id] = std::string(name);
     else LOG_WARNING("Not setting character name for character ID " + std::to_string(id) + ".");
 }
 
-void TextManager::SetParty(int char_1, int char_2, int char_3){
+void TextHandler::SetParty(int char_1, int char_2, int char_3){
     current_party_[0] = char_1;
     current_party_[2] = char_2;
     current_party_[3] = char_3;

+ 8 - 8
src/core/TextManager.h → src/core/TextHandler.h

@@ -20,24 +20,24 @@
 #include <tinyxml.h>
 
 /**
- * The text manager.
+ * The text handler.
  */
-class TextManager : public Ogre::Singleton<TextManager>{
+class TextHandler : public Ogre::Singleton<TextHandler>{
 
     public:
 
         /**
          * Constructor.
          */
-        TextManager();
+        TextHandler();
 
         /**
          * Destructor.
          */
-        virtual ~TextManager();
+        virtual ~TextHandler();
 
         /**
-         * Initializes the commands for the text manager.
+         * Initializes the commands for the text handler.
          */
         void InitCmd();
 
@@ -112,7 +112,7 @@ class TextManager : public Ogre::Singleton<TextManager>{
         std::string GetDialogText(const std::string name);
 
         /**
-         * Deletes all texts in the manager.
+         * Deletes all texts in the handler.
          */
         void UnloadTexts();
 
@@ -176,7 +176,7 @@ class TextManager : public Ogre::Singleton<TextManager>{
         };
 
         /**
-         * The list of texts in the manager.
+         * The list of texts in the handler.
          */
         std::vector<Text> texts_;
 
@@ -207,7 +207,7 @@ class TextManager : public Ogre::Singleton<TextManager>{
         };
 
         /**
-         * The list of dialogs in the manager.
+         * The list of dialogs in the handler.
          */
         std::vector<Dialog> dialogs_;
 

+ 5 - 7
src/core/TextManagerCommands.h → src/core/TextHandlerCommands.h

@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  */
 
-#include "ConfigCmdManager.h"
+#include "ConfigCmdHandler.h"
 #include "Console.h"
 #include "Logger.h"
 #include "XmlTextsFile.h"
@@ -28,12 +28,10 @@
  */
 void CmdSetLanguage(const Ogre::StringVector& params){
     if (params.size() < 2){
-        Console::getSingleton().AddTextToOutput(
-          "Usage: /set_language <language>"
-        );
+        Console::getSingleton().AddTextToOutput("Usage: /set_language <language>");
         return;
     }
-    TextManager::getSingleton().SetLanguage(params[1]);
+    TextHandler::getSingleton().SetLanguage(params[1]);
     LOG_TRIVIAL("Set game language to \"" + params[1] + "\".");
 }
 
@@ -49,8 +47,8 @@ void CmdSetLanguageCompletition(Ogre::StringVector& complete_params){
     texts.GetAvailableLanguages(complete_params);
 }
 
-void TextManager::InitCmd(){
-    ConfigCmdManager::getSingleton().AddCommand(
+void TextHandler::InitCmd(){
+    ConfigCmdHandler::getSingleton().AddCommand(
       "set_language", "Change language of texts and dialogs", "",
       CmdSetLanguage, CmdSetLanguageCompletition
     );

+ 21 - 7
src/core/UiManager.cpp

@@ -27,7 +27,7 @@
 #include "core/XmlPrototypesFile.h"
 #include "core/XmlScreensFile.h"
 #include "core/XmlTextsFile.h"
-#include "core/TextManager.h"
+#include "TextHandler.h"
 
 /**
  * UI manager singleton.
@@ -51,11 +51,15 @@ void UiManager::Initialise(){
     screens.LoadScreens();
 }
 
-void UiManager::Update(){
-    // Update all ui scripts
-    ScriptManager::getSingleton().Update(ScriptManager::UI);
-    for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->Update();
-}
+void UiManager::Input(const VGears::Event& event){}
+
+void UiManager::UpdateDebug(){}
+
+void UiManager::ClearField(){}
+
+void UiManager::ClearBattle(){}
+
+void UiManager::ClearWorld(){}
 
 void UiManager::OnResize(){
     for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->OnResize();
@@ -75,7 +79,7 @@ std::string toLower(std::string s) {
 }
 
 UiFont* UiManager::GetFont(const Ogre::String& name){
-    Ogre::String language = TextManager::getSingleton().GetLanguage();
+    Ogre::String language = TextHandler::getSingleton().GetLanguage();
 
     for (unsigned int i = 0; i < fonts_.size(); ++ i){
         if (fonts_[ i ]->GetName() == name){
@@ -127,3 +131,13 @@ void UiManager::renderQueueStarted(
         for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->Render();
     }
 }
+
+void UiManager::UpdateField(){
+    // Update all ui scripts
+    ScriptManager::getSingleton().Update(ScriptManager::UI);
+    for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->Update();
+}
+
+void UiManager::UpdateBattle(){}
+
+void UiManager::UpdateWorld(){}

+ 42 - 4
src/core/UiManager.h

@@ -19,14 +19,15 @@
 #include <OgreSingleton.h>
 #include <OgreUTFString.h>
 #include <tinyxml.h>
+#include "Manager.h"
 #include "UiFont.h"
 #include "UiWidget.h"
 
 /**
  * The UI manager.
  */
-class UiManager
-  : public Ogre::RenderQueueListener, public Ogre::Singleton<UiManager>
+class UiManager :
+  public Manager, public Ogre::RenderQueueListener, public Ogre::Singleton<UiManager>
 {
 
     public:
@@ -50,15 +51,37 @@ class UiManager
         void Initialise();
 
         /**
-         * Updates the UI elements in the manager.
+         * Handles an input event.
+         *
+         * @param[in] event Event to handle.
+         */
+        void Input(const VGears::Event& event) override;
+
+        /**
+         * Updates the elements in the manager with debug information.
          */
-        void Update();
+        void UpdateDebug() override;
 
         /**
          * Handles resizing events.
          */
         void OnResize();
 
+        /**
+         * Clears all field UI elements in the manager.
+         */
+        void ClearField() override;
+
+        /**
+         * Clears all battle UI elements in the manager.
+         */
+        void ClearBattle() override;
+
+        /**
+         * Clears all world map UI elements in the manager.
+         */
+        void ClearWorld() override;
+
         /**
          * Adds a font to the manager.
          *
@@ -130,6 +153,21 @@ class UiManager
 
     private:
 
+        /**
+         * Updates the field UI elements in the manager.
+         */
+        void UpdateField() override;
+
+        /**
+         * Updates the battle UI elements in the manager.
+         */
+        void UpdateBattle() override;
+
+        /**
+         * Updates the world map UI elements in the manager.
+         */
+        void UpdateWorld() override;
+
         /**
          * List of fonts in the manager.
          */

+ 8 - 8
src/core/UiTextArea.cpp

@@ -26,10 +26,10 @@
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/UiTextArea.h"
-#include "core/TextManager.h"
 #include "core/Timer.h"
 #include "core/UiSprite.h"
 #include "core/Utilites.h"
+#include "TextHandler.h"
 
 UiTextArea::UiTextArea(const Ogre::String& name): UiWidget(name){
     Initialise();
@@ -250,7 +250,7 @@ void UiTextArea::SetText(TiXmlNode* text){
     if (font_ != NULL){
         Ogre::String language = font_->GetLanguage();
         if (language != "")
-            if (TextManager::getSingleton().GetLanguage() != language) SetFont(font_->GetName());
+            if (TextHandler::getSingleton().GetLanguage() != language) SetFont(font_->GetName());
     }
 
     TextClear();
@@ -660,7 +660,7 @@ void UiTextArea::PrepareTextFromNode(TiXmlNode* node, const Ogre::ColourValue& c
                     }
                     else if (name == "character"){
                         const std::string* id = node->ToElement()->Attribute(Ogre::String("id"));
-                        const std::string char_name = TextManager::getSingleton().GetCharacterName(
+                        const std::string char_name = TextHandler::getSingleton().GetCharacterName(
                           std::stoi(*id)
                         );
                         for (unsigned int i = 0; i < char_name.length(); ++ i){
@@ -673,7 +673,7 @@ void UiTextArea::PrepareTextFromNode(TiXmlNode* node, const Ogre::ColourValue& c
                     else if (name == "party"){
                         const std::string* pos = node->ToElement()->Attribute(Ogre::String("pos"));
                         const std::string char_name
-                          = TextManager::getSingleton().GetPartyCharacterName(std::stoi(*pos));
+                          = TextHandler::getSingleton().GetPartyCharacterName(std::stoi(*pos));
                         for (unsigned int i = 0; i < char_name.length(); ++ i){
                             TextChar text_char;
                             text_char.char_code = char_name.at(i);
@@ -686,7 +686,7 @@ void UiTextArea::PrepareTextFromNode(TiXmlNode* node, const Ogre::ColourValue& c
                           Ogre::String("name")
                         );
                         if (text_name != NULL){
-                            TiXmlNode* text = TextManager::getSingleton().GetText(*text_name);
+                            TiXmlNode* text = TextHandler::getSingleton().GetText(*text_name);
                             if (text != NULL) PrepareTextFromNode(text, colour_child);
                         }
                     }
@@ -826,7 +826,7 @@ void UiTextArea::SetTextFromNode(TiXmlNode* node, const Ogre::ColourValue& colou
                 }
                 else if (name == "character"){
                     const std::string* id = node->ToElement()->Attribute(Ogre::String("id"));
-                    const std::string char_name = TextManager::getSingleton().GetCharacterName(
+                    const std::string char_name = TextHandler::getSingleton().GetCharacterName(
                       std::stoi(*id)
                     );
                     for (unsigned int i = 0; i < char_name.length(); ++ i){
@@ -839,7 +839,7 @@ void UiTextArea::SetTextFromNode(TiXmlNode* node, const Ogre::ColourValue& colou
                 else if (name == "party"){
                     const std::string* pos = node->ToElement()->Attribute(Ogre::String("pos"));
                     const std::string char_name
-                      = TextManager::getSingleton().GetPartyCharacterName(std::stoi(*pos));
+                      = TextHandler::getSingleton().GetPartyCharacterName(std::stoi(*pos));
                     for (unsigned int i = 0; i < char_name.length(); ++ i){
                         TextChar text_char;
                         text_char.char_code = char_name.at(i);
@@ -852,7 +852,7 @@ void UiTextArea::SetTextFromNode(TiXmlNode* node, const Ogre::ColourValue& colou
                       Ogre::String("name")
                     );
                     if (text_name != NULL){
-                        TiXmlNode* text = TextManager::getSingleton().GetText(*text_name);
+                        TiXmlNode* text = TextHandler::getSingleton().GetText(*text_name);
                         if (text != NULL) SetTextFromNode(text, colour_child);
                     }
                 }

+ 4 - 3
src/core/XmlMapFile.cpp

@@ -13,14 +13,15 @@
  * GNU General Public License for more details.
  */
 
+#include "core/AudioManager.h"
 #include "core/EntityManager.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
-#include "core/TextManager.h"
 #include "core/XmlBackground2DFile.h"
 #include "core/XmlMapFile.h"
 #include "map/VGearsBackground2DFileManager.h"
 #include "map/VGearsWalkmeshFileManager.h"
+#include "TextHandler.h"
 
 XmlMapFile::XmlMapFile(const Ogre::String& file): XmlFile(file){}
 
@@ -60,7 +61,7 @@ void XmlMapFile::LoadMap(){
             }
         }
         else if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "texts"){
-            TextManager::getSingleton().LoadFieldText(GetString(node, "file_name"));
+            TextHandler::getSingleton().LoadFieldText(GetString(node, "file_name"));
         }
         else if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "entity_model"){
             Ogre::String name = GetString(node, "name");
@@ -121,7 +122,7 @@ void XmlMapFile::LoadMap(){
             for (TiXmlNode* track = node->FirstChild(); track; track = track->NextSibling()){
                 int id = GetInt(track, "id");
                 int track_id = GetInt(track, "track_id");
-                EntityManager::getSingleton().AddTrack(id, track_id);
+                AudioManager::getSingleton().AddTrack(id, track_id);
             }
         }
         node = node->NextSibling();

+ 2 - 2
src/core/XmlScreenFile.cpp

@@ -19,9 +19,9 @@
 #include "core/UiSprite.h"
 #include "core/UiTextArea.h"
 #include "core/UiWidget.h"
-#include "core/TextManager.h"
 #include "core/XmlScreenFile.h"
 #include "core/Utilites.h"
+#include "TextHandler.h"
 
 XmlScreenFile::XmlScreenFile(const Ogre::String& file): XmlFile(file){}
 
@@ -90,7 +90,7 @@ void XmlScreenFile::LoadScreenRecursive(
                     if (node->ValueStr() == "text_area"){
                         Ogre::String text = GetString(node, "text_name", "");
                         if (text != ""){
-                            TiXmlNode* utf = TextManager::getSingleton().GetText(text);
+                            TiXmlNode* utf = TextHandler::getSingleton().GetText(text);
                             if (utf != nullptr) static_cast<UiTextArea*>(widget2)->SetText(utf);
                         }
                         Ogre::String font = GetString(node, "font", "");

+ 5 - 4
src/core/XmlTextFile.cpp

@@ -16,7 +16,8 @@
 #include "core/Logger.h"
 #include "core/UiManager.h"
 #include "core/XmlTextFile.h"
-#include "core/TextManager.h"
+
+#include "TextHandler.h"
 
 XmlTextFile::XmlTextFile(const Ogre::String& file): XmlFile(file){}
 
@@ -26,7 +27,7 @@ void XmlTextFile::LoadTexts(){
     TiXmlNode* node = file_.RootElement();
     if(node == nullptr || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "Text Manager: " + file_.ValueStr() + " is not a valid text file! No <texts> in root."
+          "Text File: " + file_.ValueStr() + " is not a valid text file! No <texts> in root."
         );
         return;
     }
@@ -34,13 +35,13 @@ void XmlTextFile::LoadTexts(){
     while (node != nullptr){
         if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "text"){
             Ogre::String name = GetString(node, "name");
-            TextManager::getSingleton().AddText(name, node->Clone());
+            TextHandler::getSingleton().AddText(name, node->Clone());
         }
         else if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "dialog"){
             Ogre::String name = GetString(node, "name");
             float width = GetFloat(node, "width", 0.0f);
             float height = GetFloat(node, "height", 0.0f);
-            TextManager::getSingleton().AddDialog(name, node->Clone(), width, height);
+            TextHandler::getSingleton().AddDialog(name, node->Clone(), width, height);
         }
         node = node->NextSibling();
     }

+ 5 - 4
src/core/XmlTextsFile.cpp

@@ -16,7 +16,8 @@
 #include "core/Logger.h"
 #include "core/XmlTextFile.h"
 #include "core/XmlTextsFile.h"
-#include "core/TextManager.h"
+
+#include "TextHandler.h"
 
 XmlTextsFile::XmlTextsFile(const Ogre::String& file): XmlFile(file){}
 
@@ -26,7 +27,7 @@ void XmlTextsFile::GetAvailableLanguages(Ogre::StringVector& languages){
     TiXmlNode* node = file_.RootElement();
     if (node == NULL || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "UI Text Manager: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
+          "Texts File: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
         );
         return;
     }
@@ -42,11 +43,11 @@ void XmlTextsFile::LoadTexts(){
     TiXmlNode* node = file_.RootElement();
     if (node == NULL || node->ValueStr() != "texts"){
         LOG_ERROR(
-          "Text Manager: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
+          "Texts File: " + file_.ValueStr() + " is not a valid texts file! No <texts> in root."
         );
         return;
     }
-    Ogre::String language = TextManager::getSingleton().GetLanguage();
+    Ogre::String language = TextHandler::getSingleton().GetLanguage();
     node = node->FirstChild();
     while (node != nullptr){
         if (node->Type() == TiXmlNode::TINYXML_ELEMENT && node->ValueStr() == "language"){

+ 8 - 8
src/main.cpp

@@ -25,22 +25,22 @@
 #include "core/AudioManager.h"
 #include "core/BattleManager.h"
 #include "core/CameraManager.h"
-#include "core/ConfigCmdManager.h"
+#include "core/ConfigCmdHandler.h"
 #include "core/ConfigFile.h"
-#include "core/ConfigVarManager.h"
+#include "core/ConfigVarHandler.h"
 #include "core/Console.h"
 #include "core/DebugDraw.h"
 #include "core/EntityManager.h"
 #include "core/GameFrameListener.h"
 #include "core/InputManager.h"
 #include "core/Logger.h"
-#include "core/SavemapManager.h"
+#include "core/SavemapHandler.h"
 #include "core/ScriptManager.h"
 #include "core/Timer.h"
 #include "core/UiManager.h"
 #include "core/particles/ParticleSystemManager.h"
-#include "core/TextManager.h"
 #include "core/DialogsManager.h"
+#include "core/TextHandler.h"
 #include "data/VGearsLZSFLevelFileManager.h"
 #include "data/VGearsLGPArchiveFactory.h"
 #include "data/worldmap/WorldmapFileManager.h"
@@ -95,8 +95,8 @@ int main(int argc, char *argv[]){
         Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
 
         // Initialize it before console because it may use it
-        auto config_var_manager = std::make_unique<ConfigVarManager>();
-        auto config_cmd_manager = std::make_unique<ConfigCmdManager>();
+        auto config_var_manager = std::make_unique<ConfigVarHandler>();
+        auto config_cmd_manager = std::make_unique<ConfigCmdHandler>();
         auto debug_draw = std::make_unique<DebugDraw>();
 
         // Initialize before GameFrameListener, but after ConfigCmdManager
@@ -104,12 +104,12 @@ int main(int argc, char *argv[]){
 
         auto audio_manager = std::make_unique<AudioManager>();
 
-        auto savemap_manager = std::make_unique<SavemapManager>();
+        auto savemap_manager = std::make_unique<SavemapHandler>();
 
         // Create this earlier than DisplayFrameListener cause it can fire
         // events there
         auto camera_manager = std::make_unique<CameraManager>();
-        auto text_manager = std::make_unique<TextManager>();
+        auto text_manager = std::make_unique<TextHandler>();
         auto ui_manager = std::make_unique<UiManager>();
         auto dialogs_manager = std::make_unique<DialogsManager>();
         auto entity_manager = std::make_unique<EntityManager>();

+ 2 - 1
test/core/ConfigCmdManager.cpp → test/core/ConfigCmdHandler.cpp

@@ -13,8 +13,9 @@
  * GNU General Public License for more details.
  */
 
+#include "../../src/core/ConfigCmdHandler.h"
+
 #include <boost/test/unit_test.hpp>
-#include "core/ConfigCmdManager.h"
 
 #pragma message("Unimplemented test file: " __FILE__)
 

+ 2 - 1
test/core/ConfigVarManager.cpp → test/core/ConfigVarHandler.cpp

@@ -13,8 +13,9 @@
  * GNU General Public License for more details.
  */
 
+#include "../../src/core/ConfigVarHandler.h"
+
 #include <boost/test/unit_test.hpp>
-#include "core/ConfigVarManager.h"
 
 #pragma message("Unimplemented test file: " __FILE__)
 

+ 0 - 0
test/core/SavemapManager.cpp → test/core/SavemapHandler.cpp


+ 2 - 1
test/core/TextManager.cpp → test/core/TextHandler.cpp

@@ -13,8 +13,9 @@
  * GNU General Public License for more details.
  */
 
+#include "../../src/core/TextHandler.h"
+
 #include <boost/test/unit_test.hpp>
-#include "core/TextManager.h"
 
 #pragma message("Unimplemented test file: " __FILE__)