Add RTL level property and print flag

Again, the RTL property controls whether textboxes will be
right-aligned, and that kind of stuff. It can't be font-bound, since
Space Station supports Hebrew characters and we want to be able to
support, say, a Hebrew translation or Hebrew levels in the future
without having to make a dedicated (or duplicated) font for it.
Therefore it's a property of both the language pack as well as custom
levels - like custom levels already had a <font> tag, they now also
have an <rtl> tag that sets this property.

Right now, we'll have to hardcode it so the menu option for the Arabic
font sets the <rtl> property to 1, and all the other options set it to
0. But it's future-proof in that we can later decide to split the
option for Space Station into an LTR option and an RTL option (so both
"english/..." and "עברית" would select Space Station, but one sets the
RTL property to 0 and the other sets it to 1).
This commit is contained in:
Dav999
2024-01-03 20:09:23 +01:00
committed by Misa Elizabeth Kai
parent 37c4f76988
commit 29e2b19698
11 changed files with 83 additions and 20 deletions

View File

@@ -227,6 +227,7 @@ TAG_FINDER(find_desc2, "Desc2")
TAG_FINDER(find_desc3, "Desc3")
TAG_FINDER(find_website, "website")
TAG_FINDER(find_font, "font")
TAG_FINDER(find_rtl, "rtl")
/* For CliPlaytestArgs */
TAG_FINDER(find_playtest, "Playtest")
@@ -315,6 +316,7 @@ bool customlevelclass::getLevelMetaDataAndPlaytestArgs(const std::string& _path,
{
_data.level_main_font_idx = font::get_font_idx_8x8();
}
_data.rtl = help.Int(find_rtl(buf).c_str());
if (pt_args != NULL)
@@ -1037,6 +1039,7 @@ bool customlevelclass::load(std::string _path)
version = 0;
level_font_name = "font";
rtl = false;
for (pElem = hDoc
.FirstChildElement()
@@ -1104,6 +1107,11 @@ bool customlevelclass::load(std::string _path)
{
level_font_name = pText_;
}
if(SDL_strcmp(pKey_, "rtl") == 0)
{
rtl = help.Int(pText_);
}
}
}
@@ -1524,6 +1532,20 @@ bool customlevelclass::save(const std::string& _path)
}
}
if (rtl)
{
xml::update_tag(msg, "rtl", rtl);
}
else
{
// Also get rid of this one...
tinyxml2::XMLElement* element;
while ((element = msg->FirstChildElement("rtl")) != NULL)
{
doc.DeleteNode(element);
}
}
xml::update_tag(data, "mapwidth", mapwidth);
xml::update_tag(data, "mapheight", mapheight);