Kaynağa Gözat

All managers set to work on different modules (field, battle or world map).

Iñigo Valentin 3 yıl önce
ebeveyn
işleme
087389f108

+ 17 - 6
src/core/BattleManager.cpp

@@ -22,11 +22,14 @@
 #include "core/AudioManager.h"
 #include "core/AudioManager.h"
 #include "core/BattleManager.h"
 #include "core/BattleManager.h"
 #include "core/CameraManager.h"
 #include "core/CameraManager.h"
+#include "core/DialogsManager.h"
 #include "core/Enemy.h"
 #include "core/Enemy.h"
 #include "core/EntityManager.h"
 #include "core/EntityManager.h"
 #include "core/ConfigVar.h"
 #include "core/ConfigVar.h"
+#include "core/InputManager.h"
 #include "core/Logger.h"
 #include "core/Logger.h"
 #include "core/ScriptManager.h"
 #include "core/ScriptManager.h"
+#include "core/UiManager.h"
 #include "core/XmlFormationFile.h"
 #include "core/XmlFormationFile.h"
 
 
 /**
 /**
@@ -90,12 +93,16 @@ void BattleManager::StartBattle(const unsigned int id){
         LOG_ERROR("Started battle in BattleManager, but the manager was already in battle mode.");
         LOG_ERROR("Started battle in BattleManager, but the manager was already in battle mode.");
         return;
         return;
     }
     }
-    module_ = Module::BATTLE;
-    formation_id_ = id;
-    EntityManager::getSingleton().SetBattleModule();
-    CameraManager::getSingleton().SetBattleModule();
+    SetBattleModule();
+    SetFormationId(id);
     AudioManager::getSingleton().SetBattleModule();
     AudioManager::getSingleton().SetBattleModule();
+    CameraManager::getSingleton().SetBattleModule();
+    DialogsManager::getSingleton().SetBattleModule();
+    EntityManager::getSingleton().SetBattleModule();
+    InputManager::getSingleton().SetBattleModule();
     ScriptManager::getSingleton().SetBattleModule();
     ScriptManager::getSingleton().SetBattleModule();
+    UiManager::getSingleton().SetBattleModule();
+
     // Load the formation XML file (name is dddd.xml)
     // Load the formation XML file (name is dddd.xml)
     std::string filename = std::to_string(formation_id_);
     std::string filename = std::to_string(formation_id_);
     while (filename.length() < 4) filename = "0" + filename;
     while (filename.length() < 4) filename = "0" + filename;
@@ -129,11 +136,15 @@ void BattleManager::EndBattle(){
     }
     }
     SetPreviousModule();
     SetPreviousModule();
     ClearBattle();
     ClearBattle();
-    EntityManager::getSingleton().SetPreviousModule();
     CameraManager::getSingleton().EndBattleCamera();
     CameraManager::getSingleton().EndBattleCamera();
-    CameraManager::getSingleton().SetPreviousModule();
+
     AudioManager::getSingleton().SetPreviousModule();
     AudioManager::getSingleton().SetPreviousModule();
+    CameraManager::getSingleton().SetPreviousModule();
+    DialogsManager::getSingleton().SetPreviousModule();
+    EntityManager::getSingleton().SetPreviousModule();
+    InputManager::getSingleton().SetPreviousModule();
     ScriptManager::getSingleton().SetPreviousModule();
     ScriptManager::getSingleton().SetPreviousModule();
+    UiManager::getSingleton().SetPreviousModule();
 }
 }
 
 
 std::vector<Enemy> BattleManager::GetEnemies() const{return enemies_;}
 std::vector<Enemy> BattleManager::GetEnemies() const{return enemies_;}

+ 27 - 26
src/core/DialogsManager.cpp

@@ -104,22 +104,23 @@ void DialogsManager::ClearField(){
     for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);
     for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);
 }
 }
 
 
-void DialogsManager::ClearBattle(){}
+void DialogsManager::ClearBattle(){
+    for (unsigned int i = 0; i < battle_messages_.size(); ++ i) HideMessage(i);
+}
 
 
-void DialogsManager::ClearWorld(){}
+void DialogsManager::ClearWorld(){
+    for (unsigned int i = 0; i < messages_.size(); ++ i) HideMessage(i);
+}
 
 
 void DialogsManager::ScriptSetMapName(const char* text_id){
 void DialogsManager::ScriptSetMapName(const char* text_id){
     std::string text = TextHandler::getSingleton().GetDialogText(text_id);
     std::string text = TextHandler::getSingleton().GetDialogText(text_id);
     SetMapName(text);
     SetMapName(text);
 }
 }
 
 
-void DialogsManager::SetMapName(std::string name){
-    map_name_ = name;
-}
+void DialogsManager::SetMapName(std::string name){map_name_ = name;}
 
 
 std::string DialogsManager::GetMapName(){return map_name_;}
 std::string DialogsManager::GetMapName(){return map_name_;}
 
 
-
 void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
 void DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h){
     int id = GetMessageId(d_name);
     int id = GetMessageId(d_name);
     if (id == -1){
     if (id == -1){
@@ -383,25 +384,26 @@ void DialogsManager::UpdateField(){
                     }
                     }
                 }
                 }
                 break;
                 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();
-                }
+            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);
+                    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;
                 break;
             case MS_OPENED:
             case MS_OPENED:
                 {
                 {
@@ -437,13 +439,12 @@ void DialogsManager::UpdateField(){
                     }
                     }
                 }
                 }
                 break;
                 break;
-            case MS_HIDE_WINDOW:{
+            case MS_HIDE_WINDOW:
+                {
                     if (
                     if (
                       (messages_[i]->window == NULL)
                       (messages_[i]->window == NULL)
                       || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
                       || (messages_[i]->window->GetCurrentAnimationName() == Ogre::BLANKSTRING)
-                    ){
-                        HideMessage(i);
-                    }
+                    ) HideMessage(i);
                 }
                 }
             break;
             break;
         }
         }

+ 11 - 13
src/core/DialogsManager.h

@@ -158,8 +158,7 @@ struct MessageData{
     std::vector<ScriptId> sync;
     std::vector<ScriptId> sync;
 
 
     /**
     /**
-     * Indicates if the text is 'clickable', i.e., if it requieres a keypress
-     * to advance.
+     * Indicates if the text is 'clickable', i.e., if it requieres a keypress to advance.
      */
      */
     bool clickable;
     bool clickable;
 
 
@@ -365,19 +364,15 @@ class DialogsManager : public Manager, public Ogre::Singleton<DialogsManager>{
          * @param[in] name Name of the variable.
          * @param[in] name Name of the variable.
          * @param[in] value Value for the variable.
          * @param[in] value Value for the variable.
          */
          */
-        void SetVariable(
-          const char* d_name, const char* name, const char* value
-        );
+        void SetVariable(const char* d_name, const char* name, const char* value);
 
 
         /**
         /**
          * Makes the dialog clickable or not.
          * Makes the dialog clickable or not.
          *
          *
-         * A clickable dialog presents a choice for the user that must be
-         * selected with a cursor.
+         * A clickable dialog presents a choice for the user that must be selected with a cursor.
          *
          *
          * @param[in] d_name Name of the dialog.
          * @param[in] d_name Name of the dialog.
-         * @param[in] clickable True to make the dialog clickable, false to
-         * make it unclickable
+         * @param[in] clickable True to make the dialog clickable, false to make it unclickable
          */
          */
         void SetClickable(const char* d_name, const bool clickable);
         void SetClickable(const char* d_name, const bool clickable);
 
 
@@ -388,9 +383,7 @@ class DialogsManager : public Manager, public Ogre::Singleton<DialogsManager>{
          * @param[in] first_row First selectable line.
          * @param[in] first_row First selectable line.
          * @param[in] last_row Last selectable line.
          * @param[in] last_row Last selectable line.
          */
          */
-        void SetCursor(
-          const char* d_name, const int first_row, const int last_row
-        );
+        void SetCursor(const char* d_name, const int first_row, const int last_row);
 
 
         /**
         /**
          * Gets the cursor position in a dialog.
          * Gets the cursor position in a dialog.
@@ -480,10 +473,15 @@ class DialogsManager : public Manager, public Ogre::Singleton<DialogsManager>{
         UiWidget* limit_area_;
         UiWidget* limit_area_;
 
 
         /**
         /**
-         * The list of messages.
+         * The list of messages for the field or the world map.
          */
          */
         std::vector<MessageData*> messages_;
         std::vector<MessageData*> messages_;
 
 
+        /**
+         * The list of battle messages.
+         */
+        std::vector<MessageData*> battle_messages_;
+
         /**
         /**
          * Indicates if the 'next' button has been pressed.
          * Indicates if the 'next' button has been pressed.
          */
          */

+ 2 - 1
src/core/EntityManager.cpp

@@ -286,6 +286,7 @@ void EntityManager::UpdateField(){
 }
 }
 
 
 void EntityManager::UpdateBattle(){
 void EntityManager::UpdateBattle(){
+    ScriptManager::getSingleton().Update(ScriptManager::BATTLE);
     for (unsigned int i = 0; i < battle_entity_.size(); ++ i){
     for (unsigned int i = 0; i < battle_entity_.size(); ++ i){
         battle_entity_[i]->Update();
         battle_entity_[i]->Update();
         battle_entity_[i]->PlayAnimationContinue(battle_entity_[i]->GetDefaultAnimationName());
         battle_entity_[i]->PlayAnimationContinue(battle_entity_[i]->GetDefaultAnimationName());
@@ -404,7 +405,7 @@ void EntityManager::AddBattleEntity(
     entity->SetIndex(index);
     entity->SetIndex(index);
     entity->SetVisible(visible);
     entity->SetVisible(visible);
     battle_entity_.push_back(entity);
     battle_entity_.push_back(entity);
-    ScriptManager::getSingleton().AddEntity(ScriptManager::ENTITY, entity->GetName(), entity);
+    ScriptManager::getSingleton().AddEntity(ScriptManager::BATTLE, entity->GetName(), entity);
 }
 }
 
 
 void EntityManager::ScriptAddEntity(
 void EntityManager::ScriptAddEntity(

+ 3 - 6
src/core/InputManager.h

@@ -173,8 +173,7 @@ class InputManager : public Manager, public Ogre::Singleton<InputManager>{
          * @param[in] buttons Buttons to bind to the command.
          * @param[in] buttons Buttons to bind to the command.
          */
          */
         void BindCommand(
         void BindCommand(
-          ConfigCmd* cmd, const Ogre::StringVector& params,
-          const ButtonList& buttons
+          ConfigCmd* cmd, const Ogre::StringVector& params, const ButtonList& buttons
         );
         );
 
 
         /**
         /**
@@ -183,9 +182,7 @@ class InputManager : public Manager, public Ogre::Singleton<InputManager>{
          * @param[in] event The game event to bind.
          * @param[in] event The game event to bind.
          * @param[in] buttons Buttons to bind to the event.
          * @param[in] buttons Buttons to bind to the event.
          */
          */
-        void BindGameEvent(
-          const Ogre::String& event, const ButtonList& buttons
-        );
+        void BindGameEvent(const Ogre::String& event, const ButtonList& buttons);
 
 
         /**
         /**
          * Activates all bindings for a button.
          * Activates all bindings for a button.
@@ -238,7 +235,7 @@ class InputManager : public Manager, public Ogre::Singleton<InputManager>{
         char button_text_[256];
         char button_text_[256];
 
 
         /**
         /**
-         * Indicates if a key holded down is waiting to repeat events.
+         * Indicates if a key held down is waiting to repeat events.
          *
          *
          * @todo Verify this.
          * @todo Verify this.
          */
          */

+ 8 - 8
src/core/Manager.cpp

@@ -23,17 +23,17 @@ Manager::Manager(): module_(Module::FIELD), prev_module_(Module::FIELD), paused_
 
 
 Manager::~Manager(){}
 Manager::~Manager(){}
 
 
-Manager::Module Manager::GetModule(){return module_;}
+Manager::Module Manager::GetModule() const{return module_;}
 
 
-bool Manager::IsModule(Manager::Module module){return (module_ == module);}
+bool Manager::IsModule(Module module) const{return (module_ == module);}
 
 
-bool Manager::IsFieldModule(){return (module_ == Module::FIELD);}
+bool Manager::IsFieldModule() const{return (module_ == Module::FIELD);}
 
 
-bool Manager::IsBattleModule(){return (module_ == Module::BATTLE);}
+bool Manager::IsBattleModule() const{return (module_ == Module::BATTLE);}
 
 
-bool Manager::IsWorldModule(){return (module_ == Module::WORLD);}
+bool Manager::IsWorldModule() const{return (module_ == Module::WORLD);}
 
 
-void Manager::SetModule(Manager::Module module){
+void Manager::SetModule(const Module module){
     if (module == Module::FIELD){
     if (module == Module::FIELD){
         ClearBattle();
         ClearBattle();
         ClearWorld();
         ClearWorld();
@@ -76,7 +76,7 @@ void Manager::Update(){
 }
 }
 
 
 
 
-void Manager::Update(Module module){
+void Manager::Update(const Module module){
     switch (module){
     switch (module){
         case Module::FIELD:
         case Module::FIELD:
             UpdateField();
             UpdateField();
@@ -92,7 +92,7 @@ void Manager::Update(Module module){
 
 
 void Manager::Clear(){Clear(module_);}
 void Manager::Clear(){Clear(module_);}
 
 
-void Manager::Clear(Module module){
+void Manager::Clear(const Module module){
     switch (module){
     switch (module){
         case Module::FIELD:
         case Module::FIELD:
             ClearField();
             ClearField();

+ 7 - 7
src/core/Manager.h

@@ -67,7 +67,7 @@ class Manager{
          *
          *
          * @return The currently selected module.
          * @return The currently selected module.
          */
          */
-        Module GetModule();
+        Module GetModule() const;
 
 
         /**
         /**
          * Checks the currently selected module.
          * Checks the currently selected module.
@@ -76,28 +76,28 @@ class Manager{
          * @return True if the currently selected module matches the module to check, false
          * @return True if the currently selected module matches the module to check, false
          * otherwise.
          * otherwise.
          */
          */
-        bool IsModule(Module module);
+        bool IsModule(const Module module) const;
 
 
         /**
         /**
          * Checks if the currently selected module is the field module.
          * Checks if the currently selected module is the field module.
          *
          *
          * @return True if the currently selected module is the field module, false otherwise.
          * @return True if the currently selected module is the field module, false otherwise.
          */
          */
-        bool IsFieldModule();
+        bool IsFieldModule() const;
 
 
         /**
         /**
          * Checks if the currently selected module is the battle module.
          * Checks if the currently selected module is the battle module.
          *
          *
          * @return True if the currently selected module is the battle module, false otherwise.
          * @return True if the currently selected module is the battle module, false otherwise.
          */
          */
-        bool IsBattleModule();
+        bool IsBattleModule() const;
 
 
         /**
         /**
          * Checks if the currently selected module is the world module.
          * Checks if the currently selected module is the world module.
          *
          *
          * @return True if the currently selected module is the world module, false otherwise.
          * @return True if the currently selected module is the world module, false otherwise.
          */
          */
-        bool IsWorldModule();
+        bool IsWorldModule() const;
 
 
         /**
         /**
          * Sets the current module for the entity manager.
          * Sets the current module for the entity manager.
@@ -106,7 +106,7 @@ class Manager{
          * {@see SetFieldModule()}, {@see SetBattleModule()} and {@see SetWorldModule()} for
          * {@see SetFieldModule()}, {@see SetBattleModule()} and {@see SetWorldModule()} for
          * information about what changing modules implies.
          * information about what changing modules implies.
          */
          */
-        void SetModule(Module module);
+        void SetModule(const Module module);
 
 
         /**
         /**
          * Sets the current module to the field mode.
          * Sets the current module to the field mode.
@@ -185,7 +185,7 @@ class Manager{
          *
          *
          * @param[in] module The module to clear.
          * @param[in] module The module to clear.
          */
          */
-        void Clear(Module module);
+        void Clear(const Module module);
 
 
         /**
         /**
          * Clear all field information in the manager.
          * Clear all field information in the manager.

+ 6 - 5
src/core/ScriptManager.cpp

@@ -33,7 +33,7 @@ ConfigVar cv_debug_script(
  */
  */
 template<>ScriptManager *Ogre::Singleton<ScriptManager>::msSingleton = nullptr;
 template<>ScriptManager *Ogre::Singleton<ScriptManager>::msSingleton = nullptr;
 
 
-Ogre::String script_entity_type[] = {"SYSTEM", "ENTITY", "UI"};
+Ogre::String script_entity_type[] = {"SYSTEM", "ENTITY", "UI", "BATTLE"};
 
 
 /**
 /**
  * Compares the priority of two scripts.
  * Compares the priority of two scripts.
@@ -91,14 +91,14 @@ void ScriptManager::Input(const VGears::Event& event){
         || event.param1 == OIS::KC_Y || event.param1 == OIS::KC_Z || event.param1 == OIS::KC_X
         || event.param1 == OIS::KC_Y || event.param1 == OIS::KC_Z || event.param1 == OIS::KC_X
       )
       )
     ){
     ){
+
         for (unsigned int i = 0; i < script_entity_.size(); ++ i){
         for (unsigned int i = 0; i < script_entity_.size(); ++ i){
             Ogre::String argument2 = "";
             Ogre::String argument2 = "";
             if (event.type == VGears::ET_KEY_PRESS) argument2 = "Press";
             if (event.type == VGears::ET_KEY_PRESS) argument2 = "Press";
-            else if (event.type == VGears::ET_KEY_REPEAT_WAIT)
-                argument2 = "Repeat";
+            else if (event.type == VGears::ET_KEY_REPEAT_WAIT) argument2 = "Repeat";
             ScriptRequest(
             ScriptRequest(
-              &script_entity_[i], "on_button", 100, KeyToString((OIS::KeyCode)((int)event.param1)),
-              argument2, false, false
+              &script_entity_[i], "on_button", 100,
+              KeyToString((OIS::KeyCode) ((int) event.param1)), argument2, false, false
             );
             );
         }
         }
     }
     }
@@ -438,6 +438,7 @@ luabind::object ScriptManager::GetTableByEntityName(
         case ScriptManager::SYSTEM: table = table[system_table_name_]; break;
         case ScriptManager::SYSTEM: table = table[system_table_name_]; break;
         case ScriptManager::ENTITY: table = table[entity_table_name_]; break;
         case ScriptManager::ENTITY: table = table[entity_table_name_]; break;
         case ScriptManager::UI: table = table[ui_table_name_]; break;
         case ScriptManager::UI: table = table[ui_table_name_]; break;
+        case ScriptManager::BATTLE: table = table[battle_table_name_]; break;
     }
     }
 
 
     if (luabind::type(table) != LUA_TTABLE) return luabind::object();
     if (luabind::type(table) != LUA_TTABLE) return luabind::object();

+ 47 - 49
src/core/ScriptManager.h

@@ -145,9 +145,9 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
             SYSTEM,
             SYSTEM,
 
 
             /**
             /**
-             * A field entity script.
+             * A field or world map entity script.
              *
              *
-             * The script belongs to any of the enities on a map.
+             * The script belongs to any of the entities on a map.
              */
              */
             ENTITY,
             ENTITY,
 
 
@@ -159,11 +159,11 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
             UI,
             UI,
 
 
             /**
             /**
-             * A field script.
+             * A battle entity script.
              *
              *
-             * The script ios triggered by the map itself
+             * The script belongs to any of the entities on the battle.
              */
              */
-            FIELD
+            BATTLE
         };
         };
 
 
         /**
         /**
@@ -229,8 +229,7 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
          *
          *
          * No errors are handled, and nothing is returned
          * No errors are handled, and nothing is returned
          *
          *
-         * @param[in] file Path to the lua file to run (relative to the
-         * data directory).
+         * @param[in] file Path to the lua file to run (relative to the data directory).
          */
          */
         void RunFile(const Ogre::String& file);
         void RunFile(const Ogre::String& file);
 
 
@@ -249,48 +248,55 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
         /**
         /**
          * Adds an entity to the manager.
          * Adds an entity to the manager.
          *
          *
+         * Usage depends on the currently active module. The entity will be added to the list of
+         * entities of the module.
+         *
          * @param[in] type Type of entity to add.
          * @param[in] type Type of entity to add.
          * @param[in] entity_name The entity name.
          * @param[in] entity_name The entity name.
          * @param[in] entity The entity to add.
          * @param[in] entity The entity to add.
          */
          */
-        void AddEntity(
-          const Type type, const Ogre::String& entity_name, Entity* entity
-        );
+        void AddEntity(const Type type, const Ogre::String& entity_name, Entity* entity);
 
 
         /**
         /**
          * Deletes an entity from the manager.
          * Deletes an entity from the manager.
          *
          *
-         * If there is no entity with name ENTITY_NAME and type TYPE, nothing
-         * will be done.
+         * Usage depends on the currently active module. The entity will be removed from the list of
+         * entities of the module. If there is no entity with name ENTITY_NAME and type TYPE,
+         * nothing will be done.
          *
          *
          * @param[in] type Type of the entity to remove.
          * @param[in] type Type of the entity to remove.
-         * @param[in] entity_name NAme of the entity to remove.
+         * @param[in] entity_name Name of the entity to remove.
          */
          */
         void RemoveEntity(const Type type, const Ogre::String& entity_name);
         void RemoveEntity(const Type type, const Ogre::String& entity_name);
 
 
         /**
         /**
          * Adds an script to an entity.
          * Adds an script to an entity.
          *
          *
+         * Usage depends on the currently active module. The script will be added to the list of
+         * scripts of the module.
+         *
          * @param[in] entity_name Name of the entity to add a script to.
          * @param[in] entity_name Name of the entity to add a script to.
          * @param[in] function_name Name of the script to add.
          * @param[in] function_name Name of the script to add.
-         * @param[in] priority Script priority. Lower numbers have higher
-         * priority.
+         * @param[in] priority Script priority. Lower numbers have higher priority.
          */
          */
         void AddEntityScript(
         void AddEntityScript(
-          const Ogre::String& entity_name, const Ogre::String& function_name,
-          int priority
+          const Ogre::String& entity_name, const Ogre::String& function_name, int priority
         );
         );
 
 
         /**
         /**
          * Removes the top script of an entity.
          * Removes the top script of an entity.
          *
          *
-         * @param[in] entity Enthity whose first script to remove.
+         * The entity must be in one of the currently active modules for it's script to be removed.
+         *
+         * @param[in] entity Entity whose first script to remove.
          */
          */
         void RemoveEntityTopScript(ScriptEntity& entity);
         void RemoveEntityTopScript(ScriptEntity& entity);
 
 
         /**
         /**
          * Retrieves a table.
          * Retrieves a table.
          *
          *
+         * The retrieved table depends on the currently active module.
+         *
          * @param[in] type Type of script.
          * @param[in] type Type of script.
          * @param[in] name Script name.
          * @param[in] name Script name.
          * @param[in] state Initial script state.
          * @param[in] state Initial script state.
@@ -298,30 +304,28 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
          * @todo Understand and document.
          * @todo Understand and document.
          */
          */
         luabind::object GetTableByEntityName(
         luabind::object GetTableByEntityName(
-          const ScriptManager::Type type, const Ogre::String& name,
-          lua_State* state
+          const ScriptManager::Type type, const Ogre::String& name, lua_State* state
         ) const;
         ) const;
 
 
         /**
         /**
          * Retrieves a script from it's ID.
          * Retrieves a script from it's ID.
          *
          *
          * @param[in] script Script ID.
          * @param[in] script Script ID.
-         * @return The script with the corresponding ID, or nullptr if there is
-         * none
+         * @return The script with the corresponding ID, or nullptr if there is none.
          */
          */
         QueueScript* GetScriptByScriptId(const ScriptId& script) const;
         QueueScript* GetScriptByScriptId(const ScriptId& script) const;
 
 
         /**
         /**
          * Retrieves a script entity by it's name and type.
          * Retrieves a script entity by it's name and type.
          *
          *
+         * Usage depends on the currently active module. The entity will be searched among the
+         * entities of the currently active module.
+         *
          * @param[in] type Entity type.
          * @param[in] type Entity type.
          * @param[in] entity_name The entity name.
          * @param[in] entity_name The entity name.
-         * @return The entity by that type and name, or nullptr if there is
-         * no one that matches.
+         * @return The entity by that type and name, or nullptr if there is no one that matches.
          */
          */
-        ScriptEntity* GetScriptEntityByName(
-          const Type type, const Ogre::String& entity_name
-        ) const;
+        ScriptEntity* GetScriptEntityByName(const Type type, const Ogre::String& entity_name) const;
 
 
         /**
         /**
          * Retrieves the current script ID.
          * Retrieves the current script ID.
@@ -352,8 +356,7 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
          *
          *
          * @param[in] type Script type.
          * @param[in] type Script type.
          * @param[in] entity Entity the scripts belong to.
          * @param[in] entity Entity the scripts belong to.
-         * @param[in] function Name of the function of the selected entity to
-         * execute.
+         * @param[in] function Name of the function of the selected entity to execute.
          * @param[in] priority Execution priority.
          * @param[in] priority Execution priority.
          */
          */
         void ScriptRequest(
         void ScriptRequest(
@@ -365,45 +368,39 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
          *
          *
          * @param[in] type Script type.
          * @param[in] type Script type.
          * @param[in] entity Entity the scripts belong to.
          * @param[in] entity Entity the scripts belong to.
-         * @param[in] function Name of the function of the selected entity to
-         * execute.
+         * @param[in] function Name of the function of the selected entity to execute.
          * @param[in] priority Execution priority.
          * @param[in] priority Execution priority.
          * @return -1 on success, 1 if the entity or the script don't exist.
          * @return -1 on success, 1 if the entity or the script don't exist.
          */
          */
         int ScriptRequestStartSync(
         int ScriptRequestStartSync(
-          const Type type, const char* entity,
-          const char* function, const int priority);
+          const Type type, const char* entity, const char* function, const int priority
+        );
 
 
         /**
         /**
          * Request a synchronous script execution to end.
          * Request a synchronous script execution to end.
          *
          *
          * @param[in] type Script type.
          * @param[in] type Script type.
          * @param[in] entity Entity the scripts belong to.
          * @param[in] entity Entity the scripts belong to.
-         * @param[in] function Name of the function of the selected entity to
-         * execute.
+         * @param[in] function Name of the function of the selected entity to execute.
          * @param[in] priority Execution priority.
          * @param[in] priority Execution priority.
          * @return -1 if the execution stops or if the script was not running,
          * @return -1 if the execution stops or if the script was not running,
          * 1 if the entity or the script don't exist.
          * 1 if the entity or the script don't exist.
          */
          */
         int ScriptRequestEndSync(
         int ScriptRequestEndSync(
-          const Type type, const char* entity,
-          const char* function, const int priority
+          const Type type, const char* entity, const char* function, const int priority
         );
         );
 
 
         /**
         /**
          * Request a script execution.
          * Request a script execution.
          *
          *
          * @param[in] script_entity Entity the scripts belong to.
          * @param[in] script_entity Entity the scripts belong to.
-         * @param[in] function Name of the function of the selected entity to
-         * execute.
+         * @param[in] function Name of the function of the selected entity to execute.
          * @param[in] priority Execution priority.
          * @param[in] priority Execution priority.
          * @param[in] argument1 First argument for the script.
          * @param[in] argument1 First argument for the script.
          * @param[in] argument2 Second argument for the script.
          * @param[in] argument2 Second argument for the script.
-         * @param[in] start_sync If true, the script will be started
-         * synchronously.
+         * @param[in] start_sync If true, the script will be started synchronously.
          * @param[in] end_sync @todo Understand and document.
          * @param[in] end_sync @todo Understand and document.
-         * @return True on success, false on error (i.e. if the entity or the
-         * script don't exist)
+         * @return True on success, false on error (i.e. if the entity or the script don't exist)
          */
          */
         bool ScriptRequest(
         bool ScriptRequest(
           ScriptEntity* script_entity, const Ogre::String& function,
           ScriptEntity* script_entity, const Ogre::String& function,
@@ -451,13 +448,18 @@ class ScriptManager : public Manager, public Ogre::Singleton<ScriptManager>{
          */
          */
         Ogre::String entity_table_name_;
         Ogre::String entity_table_name_;
 
 
+        /**
+         * The battle entity script table name.
+         */
+        Ogre::String battle_table_name_;
+
         /**
         /**
          * The UI script table name.
          * The UI script table name.
          */
          */
         Ogre::String ui_table_name_;
         Ogre::String ui_table_name_;
 
 
         /**
         /**
-         * The list of script entities.
+         * The list of map entity scripts.
          */
          */
         std::vector<ScriptEntity> script_entity_;
         std::vector<ScriptEntity> script_entity_;
 
 
@@ -474,11 +476,7 @@ struct ScriptEntity{
      *
      *
      *By default, the type is {@see ScriptManager::SYSTEM}.
      *By default, the type is {@see ScriptManager::SYSTEM}.
      */
      */
-    ScriptEntity():
-      name(""),
-      type(ScriptManager::SYSTEM),
-      resort(false)
-    {}
+    ScriptEntity(): name(""), type(ScriptManager::SYSTEM), resort(false){}
 
 
     /**
     /**
      * The script name.
      * The script name.

+ 2 - 2
src/core/UiManager.cpp

@@ -138,6 +138,6 @@ void UiManager::UpdateField(){
     for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->Update();
     for (unsigned int i = 0; i < widgets_.size(); ++ i) widgets_[i]->Update();
 }
 }
 
 
-void UiManager::UpdateBattle(){}
+void UiManager::UpdateBattle(){UpdateField();}
 
 
-void UiManager::UpdateWorld(){}
+void UiManager::UpdateWorld(){UpdateField();}