mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Make fallback map static to simplify constructors
This commit is contained in:
parent
886c77bced
commit
a302ec9c65
50 changed files with 279 additions and 332 deletions
|
@ -1,11 +1,13 @@
|
|||
#include "tags.hpp"
|
||||
|
||||
#include <components/fallback/fallback.hpp>
|
||||
|
||||
#include <MyGUI_Colour.h>
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map<std::string,std::string>& fallbackSettings)
|
||||
bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out)
|
||||
{
|
||||
std::string fontcolour = "fontcolour=";
|
||||
size_t fontcolourLength = fontcolour.length();
|
||||
|
@ -16,14 +18,14 @@ bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map<s
|
|||
if (tag.compare(0, fontcolourLength, fontcolour) == 0)
|
||||
{
|
||||
std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength);
|
||||
std::map<std::string, std::string>::const_iterator it = fallbackSettings.find(fallbackName);
|
||||
if (it == fallbackSettings.end())
|
||||
std::string str = Fallback::Map::getString(fallbackName);
|
||||
if (str.empty())
|
||||
throw std::runtime_error("Unknown fallback name: " + fallbackName);
|
||||
std::string str = it->second;
|
||||
|
||||
std::string ret[3];
|
||||
unsigned int j=0;
|
||||
for(unsigned int i=0;i<str.length();++i){
|
||||
for(unsigned int i=0;i<str.length();++i)
|
||||
{
|
||||
if(str[i]==',') j++;
|
||||
else if (str[i] != ' ') ret[j]+=str[i];
|
||||
}
|
||||
|
@ -34,14 +36,14 @@ bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map<s
|
|||
else if (tag.compare(0, fontcolourhtmlLength, fontcolourhtml) == 0)
|
||||
{
|
||||
std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourhtmlLength);
|
||||
std::map<std::string, std::string>::const_iterator it = fallbackSettings.find(fallbackName);
|
||||
if (it == fallbackSettings.end())
|
||||
std::string str = Fallback::Map::getString(fallbackName);
|
||||
if (str.empty())
|
||||
throw std::runtime_error("Unknown fallback name: " + fallbackName);
|
||||
std::string str = it->second;
|
||||
|
||||
std::string ret[3];
|
||||
unsigned int j=0;
|
||||
for(unsigned int i=0;i<str.length();++i){
|
||||
for(unsigned int i=0;i<str.length();++i)
|
||||
{
|
||||
if(str[i]==',') j++;
|
||||
else if (str[i] != ' ') ret[j]+=str[i];
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Gui
|
|||
{
|
||||
|
||||
/// Try to replace a tag. Returns true on success and writes the result to \a out.
|
||||
bool replaceTag (const MyGUI::UString& tag, MyGUI::UString& out, const std::map<std::string,std::string>& fallbackSettings);
|
||||
bool replaceTag (const MyGUI::UString& tag, MyGUI::UString& out);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue