Added docs for xml converter. Added XmlToLua.h. Condition code in xml is now passed through the lua converter to handle renamed things.
This commit is contained in:
@@ -118,6 +118,7 @@ list(APPEND SMDATA_FILE_TYPES_HPP
|
||||
"IniFile.h"
|
||||
"MsdFile.h"
|
||||
"XmlFile.h"
|
||||
"XmlToLua.h"
|
||||
"XmlFileUtil.h"
|
||||
)
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Song.h"
|
||||
#include "ScreenSyncOverlay.h"
|
||||
#include "ThemeMetric.h"
|
||||
#include "XmlToLua.h"
|
||||
|
||||
static bool g_bIsDisplayed = false;
|
||||
static bool g_bIsSlow = false;
|
||||
@@ -1116,8 +1117,7 @@ class DebugLineClearErrors : public IDebugLine
|
||||
}
|
||||
};
|
||||
|
||||
void convert_xmls_in_dir(RString const& dirname);
|
||||
class DebugLineConvrtXML : public IDebugLine
|
||||
class DebugLineConvertXML : public IDebugLine
|
||||
{
|
||||
virtual RString GetDisplayTitle() { return CONVERT_XML.GetValue(); }
|
||||
virtual RString GetDisplayValue() { return RString(); }
|
||||
@@ -1319,7 +1319,7 @@ DECLARE_ONE( DebugLineReloadTheme );
|
||||
DECLARE_ONE( DebugLineReloadOverlayScreens );
|
||||
DECLARE_ONE( DebugLineToggleErrors );
|
||||
DECLARE_ONE( DebugLineClearErrors );
|
||||
DECLARE_ONE( DebugLineConvrtXML );
|
||||
DECLARE_ONE( DebugLineConvertXML );
|
||||
DECLARE_ONE( DebugLineWriteProfiles );
|
||||
DECLARE_ONE( DebugLineWritePreferences );
|
||||
DECLARE_ONE( DebugLineMenuTimer );
|
||||
|
||||
+13
-6
@@ -245,6 +245,15 @@ void init_parser_helpers()
|
||||
chunks_to_replace["IsPlayerEnabled(1)"]= "IsPlayerEnabled(PLAYER_2)";
|
||||
}
|
||||
|
||||
void convert_lua_chunk(RString& chunk_text)
|
||||
{
|
||||
for(map<RString, RString>::iterator chunk= chunks_to_replace.begin();
|
||||
chunk != chunks_to_replace.end(); ++chunk)
|
||||
{
|
||||
chunk_text.Replace(chunk->first, chunk->second);
|
||||
}
|
||||
}
|
||||
|
||||
// Conditions are mapped by condition string.
|
||||
// So condition_set_t::iterator->first is the lua to execute for the
|
||||
// condition, and condition_set_t::iterator->second is the name of the
|
||||
@@ -293,11 +302,7 @@ void actor_template_t::store_cmd(RString const& cmd_name, RString const& full_cm
|
||||
if(full_cmd.Left(1) == "%")
|
||||
{
|
||||
RString cmd_text= full_cmd.Right(full_cmd.size()-1);
|
||||
for(map<RString, RString>::iterator chunk= chunks_to_replace.begin();
|
||||
chunk != chunks_to_replace.end(); ++chunk)
|
||||
{
|
||||
cmd_text.Replace(chunk->first, chunk->second);
|
||||
}
|
||||
convert_lua_chunk(cmd_text);
|
||||
fields[cmd_name]= cmd_text;
|
||||
return;
|
||||
}
|
||||
@@ -739,7 +744,9 @@ void convert_xml_file(RString const& fname, RString const& dirname)
|
||||
for(condition_set_t::iterator cond= conditions.begin();
|
||||
cond != conditions.end(); ++cond)
|
||||
{
|
||||
file->Write("local " + cond->second + "_result= " + cond->first + "\n\n");
|
||||
RString cond_text= cond->first;
|
||||
convert_lua_chunk(cond_text);
|
||||
file->Write("local " + cond->second + "_result= " + cond_text + "\n\n");
|
||||
}
|
||||
if(!conditions.empty())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef XmlToLua_H
|
||||
#define XmlToLua_H
|
||||
void convert_xmls_in_dir(RString const& dirname);
|
||||
#endif
|
||||
Reference in New Issue
Block a user