Przeglądaj źródła

installed data now has dialogs - text still needs dumping to xml file to be fully working

Paul 11 lat temu
rodzic
commit
4929d532f8

+ 10 - 4
QGearsMain/include/core/DialogsManager.h

@@ -60,6 +60,10 @@ struct MessageData
     UiWidget* cursor;
 
     MessageState state;
+    int x = 0;
+    int y = 0;
+    int w = 0;
+    int h = 0;
 
     std::vector< ScriptId > sync;
 
@@ -89,11 +93,13 @@ public:
     void Update();
     void Clear();
 
-    void ShowDialog( const char* d_name, const char* name, const int x, const int y );
-    void ShowText( const char* d_name, const char* text, const int x, const int y, const int width, const int height );
-    int Sync( const char* d_name );
+    void OpenDialog(const char* d_name, int x, int y, int w, int h); // aka dialog_open
+    void SetText( const char* d_name, const char* text ); // aka dialog_set_text
+    int Sync( const char* d_name ); // aka dialog_wait_for_close
+    void Hide(const char* d_name); // aka dialog_close
+
     void SetVariable( const char* d_name, const char* name, const char* value );
-    void Hide( const char* d_name );
+
     void SetClickable( const char* d_name, const bool clickable );
     void SetCursor( const char* d_name, const int first_row, const int last_row );
     int GetCursor( const char* d_name ) const;

+ 6 - 6
QGearsMain/include/core/ScriptManagerBinds.h

@@ -168,11 +168,11 @@ ScriptManager::InitBinds()
     luabind::module( m_LuaState )
     [
         luabind::class_< DialogsManager >( "Dialog" )
-            .def( "show_dialog", ( void( DialogsManager::* )( const char*, const char*, const int, const int ) ) &DialogsManager::ShowDialog )
-            .def( "show_text", ( void( DialogsManager::* )( const char*, const char*, const int, const int, const int, const int ) ) &DialogsManager::ShowText )
-            .def( "sync", ( int( DialogsManager::* )( const char* ) ) &DialogsManager::Sync, luabind::yield )
-            .def( "set_variable", ( void( DialogsManager::* )( const char*, const char*, const char* ) ) &DialogsManager::SetVariable )
-            .def( "hide", ( void( DialogsManager::* )( const char* ) ) &DialogsManager::Hide )
+            .def( "dialog_open", ( void( DialogsManager::* )( const char*, int, int, int, int ) ) &DialogsManager::OpenDialog )
+            .def( "dialog_set_text", ( void( DialogsManager::* )( const char*, const char* ) ) &DialogsManager::SetText )
+            .def( "dialog_wait_for_close", ( int( DialogsManager::* )( const char* ) ) &DialogsManager::Sync, luabind::yield )
+            .def( "dialog_close", (void(DialogsManager::*)(const char*)) &DialogsManager::Hide)
+            .def( "set_variable", ( void( DialogsManager::* )( const char*, const char*, const char* ) ) &DialogsManager::SetVariable )           
             .def( "set_clickable", ( void( DialogsManager::* )( const char*, const bool ) ) &DialogsManager::SetClickable )
             .def( "set_cursor", ( void( DialogsManager::* )( const char*, const int, const int ) ) &DialogsManager::SetCursor )
             .def( "get_cursor", ( int( DialogsManager::* )( const char* ) ) &DialogsManager::GetCursor )
@@ -246,7 +246,7 @@ ScriptManager::InitBinds()
     luabind::globals( m_LuaState )[ "entity_manager" ] = boost::ref( *( EntityManager::getSingletonPtr() ) );
     luabind::globals( m_LuaState )[ "background2d" ] = boost::ref( *( EntityManager::getSingletonPtr()->GetBackground2D() ) );
     luabind::globals( m_LuaState )[ "walkmesh" ] = boost::ref( *( EntityManager::getSingletonPtr()->GetWalkmesh() ) );
-    luabind::globals( m_LuaState )[ "message" ] = boost::ref( *( DialogsManager::getSingletonPtr() ) );
+    luabind::globals( m_LuaState )[ "dialog" ] = boost::ref( *( DialogsManager::getSingletonPtr() ) );
     luabind::globals( m_LuaState )[ "ui_manager" ] = boost::ref( *( UiManager::getSingletonPtr() ) );
     luabind::globals( m_LuaState )[ "world_map_module" ] = boost::ref( *( QGears::WorldMapModule::getSingletonPtr() ) );
     luabind::globals( m_LuaState )[ "timer" ] = boost::ref( *( Timer::getSingletonPtr() ) );

+ 47 - 40
QGearsMain/src/core/DialogsManager.cpp

@@ -268,54 +268,65 @@ DialogsManager::Clear()
 
 
 void
-DialogsManager::ShowDialog( const char* d_name, const char* name, const int x, const int y )
+DialogsManager::OpenDialog(const char* d_name, int x, int y, int w, int h)
 {
     int id = GetMessageId( d_name );
     if( id == -1 )
     {
-        LOG_TRIVIAL( "[SCRIPT] show_dialog: dialog \"" + Ogre::String( d_name ) + "\" doesn't exist." );
+        LOG_TRIVIAL( "[SCRIPT] dialog_open: dialog \"" + Ogre::String( d_name ) + "\" doesn't exist." );
         return;
     }
 
-    if( m_Messages[ id ]->state != MS_CLOSED )
+    MessageData* data = m_Messages[id];
+    if( data->state != MS_CLOSED )
     {
-        LOG_TRIVIAL( "[SCRIPT] show_dialog: dialog \"" + Ogre::String( d_name ) + " already shown. Close it first." );
+        LOG_TRIVIAL( "[SCRIPT] dialog_open: dialog \"" + Ogre::String( d_name ) + " already created. Close it first." );
         return;
     }
 
-    float width, height;
-    TiXmlNode* text = TextManager::getSingleton().GetDialog( name, width, height );
-    if( text != NULL )
-    {
-        m_Messages[ id ]->text_area->SetText( text );
-        ShowMessage( id, x, y, width, height );
-    }
-    else
-    {
-        LOG_TRIVIAL( "[SCRIPT] show_dialog: dialog text \"" + Ogre::String( name ) + "\" doesn't exist." );
-    }
+    data->x = x;
+    data->y = y;
+    data->w = w;
+    data->h = h;
+
+    LOG_TRIVIAL( "[SCRIPT] dialog_open: dialog(" +
+        std::to_string(x) + "," + std::to_string(y) + "," + 
+        std::to_string(w) + "," + std::to_string(h) + ")");
+    
 }
 
 
 
 void
-DialogsManager::ShowText( const char* d_name, const char* text, const int x, const int y, const int width, const int height )
+DialogsManager::SetText(const char* d_name, const char* text)
 {
-    int id = GetMessageId( d_name );
-    if( id == -1 )
+    int id = GetMessageId(d_name);
+    if (id == -1)
     {
-        LOG_TRIVIAL( "[SCRIPT] show_text: dialog \"" + Ogre::String( d_name ) + "\" doesn't exist." );
+        LOG_TRIVIAL("[SCRIPT] show_text: dialog \"" + Ogre::String(d_name) + "\" doesn't exist.");
         return;
     }
 
-    if( m_Messages[ id ]->state != MS_CLOSED )
+    MessageData* data = m_Messages[id];
+
+
+    // XML data can change dialog w/h VS whats in the lua script
+    float width = 0.0f;
+    float height = 0.0f;
+    TiXmlNode* xmlText = TextManager::getSingleton().GetDialog(text, width, height);
+    if (xmlText != NULL)
     {
-        LOG_TRIVIAL( "[SCRIPT] show_dialog: dialog \"" + Ogre::String( d_name ) + " already shown. Close it first." );
-        return;
+        m_Messages[id]->text_area->SetText(xmlText);
+        ShowMessage(id, data->x, data->y, 
+            width == 0.0f ? data->w : width, 
+            height == 0.0f ? data->h : height);
+    }
+    else
+    {
+        m_Messages[id]->text_area->SetText(std::string("[ERROR string not found:] ") + text);
+        ShowMessage(id, data->x, data->y, data->w, data->h);
     }
 
-    m_Messages[ id ]->text_area->SetText( text );
-    ShowMessage( id, x, y, width, height );
 }
 
 
@@ -336,22 +347,6 @@ DialogsManager::Sync( const char* d_name )
 }
 
 
-
-void
-DialogsManager::SetVariable( const char* d_name, const char* name, const char* value )
-{
-    int id = GetMessageId( d_name );
-    if( id == -1 )
-    {
-        LOG_TRIVIAL( "[SCRIPT] set_variable: dialog \"" + Ogre::String( d_name ) + "\" doesn't exist." );
-        return;
-    }
-
-    m_Messages[ id ]->text_area->SetVariable( name, value );
-}
-
-
-
 void
 DialogsManager::Hide( const char* d_name )
 {
@@ -372,6 +367,18 @@ DialogsManager::Hide( const char* d_name )
 }
 
 
+void
+DialogsManager::SetVariable(const char* d_name, const char* name, const char* value)
+{
+    int id = GetMessageId(d_name);
+    if (id == -1)
+    {
+        LOG_TRIVIAL("[SCRIPT] set_variable: dialog \"" + Ogre::String(d_name) + "\" doesn't exist.");
+        return;
+    }
+
+    m_Messages[id]->text_area->SetVariable(name, value);
+}
 
 void
 DialogsManager::SetClickable( const char* d_name, const bool clickable )

+ 1 - 1
QGearsMain/src/core/ScriptManager.cpp

@@ -197,7 +197,7 @@ ScriptManager::Update(const ScriptManager::Type type)
                             }
                             catch(luabind::error& /*e*/)
                             {
-                                LOG_ERROR(Ogre::String(lua_tostring(m_ScriptEntity[i].queue[0].state , -1)));
+                                LOG_ERROR("LUA error in " + m_ScriptEntity[i].name + " in function " + m_ScriptEntity[i].queue[0].function + " details: " + Ogre::String(lua_tostring(m_ScriptEntity[i].queue[0].state, -1)));
                             }
 
                             if(ret == 0)

+ 1 - 1
dependencies/SUDM

@@ -1 +1 @@
-Subproject commit a02716798dfc67e0976041e2e7e544da3610c366
+Subproject commit da92262c8e9cef817f884fce0044aa1d5dc7a8f2

+ 2 - 2
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -902,7 +902,7 @@ void FF7DataInstaller::CollectionFieldSpawnAndScaleFactors()
     {
         auto resourceName = (*mFLevelFileList)[mIteratorCounter];
         // Exclude things that are not fields
-        if (IsAFieldFile(resourceName) /*&& IsTestField(resourceName)*/)
+        if (IsAFieldFile(resourceName) && IsTestField(resourceName))
         {
             mConversionStep++;
 
@@ -955,7 +955,7 @@ void FF7DataInstaller::ConvertFieldsIteration()
         {
             mIteratorCounter++;
 
-            if (/*IsTestField(resourceName) &&*/
+            if (IsTestField(resourceName) &&
                 !WillCrash(resourceName))
             {
                 mfnWriteOutputLine("Converting field " + resourceName);