i18n for everything else

This commit is contained in:
mniip 2020-03-24 22:56:12 +03:00
parent 7f4aae7e99
commit 8e67a6ff89
40 changed files with 133 additions and 126 deletions

View File

@ -15,7 +15,7 @@ SaveFile::SaveFile(ByteString filename):
gameSave(NULL), gameSave(NULL),
filename(filename), filename(filename),
displayName(filename.FromUtf8()), displayName(filename.FromUtf8()),
loadingError("") loadingError(""_ascii)
{ {
} }

View File

@ -38,7 +38,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
Version(0), Version(0),
userName(_userName), userName(_userName),
name(_name), name(_name),
Description(""), Description(""_ascii),
Published(false), Published(false),
tags(), tags(),
gameSave(NULL) gameSave(NULL)

View File

@ -293,7 +293,7 @@ inline wchar_t narrow_wchar(String::value_type ch)
char const numberChars[] = "-.+0123456789ABCDEFXabcdefx"; char const numberChars[] = "-.+0123456789ABCDEFXabcdefx";
ByteString numberByteString(numberChars); ByteString numberByteString(numberChars);
String numberString(numberChars); String numberString(numberByteString.FromAscii());
struct LocaleImpl struct LocaleImpl
{ {

View File

@ -32,10 +32,10 @@ void DebugLines::Draw()
g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120); g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120);
String info; String info;
info = String::Build(drawPoint2.X, " x ", drawPoint2.Y); info = String::Build(drawPoint2.X, " x "_ascii, drawPoint2.Y);
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info)-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info, 255, 255, 255, 200); g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info)-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info, 255, 255, 255, 200);
info = String::Build(drawPoint1.X, " x ", drawPoint1.Y); info = String::Build(drawPoint1.X, " x "_ascii, drawPoint1.Y);
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200); g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200);
info = String::Build(std::abs(drawPoint2.X-drawPoint1.X)); info = String::Build(std::abs(drawPoint2.X-drawPoint1.X));

View File

@ -18,7 +18,7 @@ void DebugParts::Draw()
Graphics * g = ui::Engine::Ref().g; Graphics * g = ui::Engine::Ref().g;
int x = 0, y = 0, lpx = 0, lpy = 0; int x = 0, y = 0, lpx = 0, lpy = 0;
String info = String::Build(sim->parts_lastActiveIndex, "/", NPART, " (", Format::Precision((float)sim->parts_lastActiveIndex/(NPART)*100.0f, 2), "%)"); String info = String::Build(sim->parts_lastActiveIndex, '/', NPART, " ("_ascii, Format::Precision((float)sim->parts_lastActiveIndex/(NPART)*100.0f, 2), "%)"_ascii);
for (int i = 0; i < NPART; i++) for (int i = 0; i < NPART; i++)
{ {
if (sim->parts[i].type) if (sim->parts[i].type)

View File

@ -74,7 +74,7 @@ void ElementPopulationDebug::Draw()
} }
} }
g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255); g->drawtext(xStart + bars + 5, yBottom-5, "0"_ascii, 255, 255, 255, 255);
g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255); g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255);
g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255); g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255);
} }

View File

@ -26,19 +26,23 @@ void ParticleDebug::Debug(int mode, int x, int y)
while (i < NPART && !sim->parts[i].type) while (i < NPART && !sim->parts[i].type)
i++; i++;
if (i == NPART) if (i == NPART)
logmessage = "End of particles reached, updated sim"; logmessage = "End of particles reached, updated sim"_i18n;
else else
logmessage = String::Build("Updated particle #", i); logmessage = String::Build("Updated particle #"_i18n, i);
} }
else if (mode == 1) else if (mode == 1)
{ {
if (x < 0 || x >= XRES || y < 0 || y >= YRES || !sim->pmap[y][x] || (i = ID(sim->pmap[y][x])) < debug_currentParticle) if (x < 0 || x >= XRES || y < 0 || y >= YRES || !sim->pmap[y][x] || (i = ID(sim->pmap[y][x])) < debug_currentParticle)
{ {
i = NPART; i = NPART;
logmessage = String::Build("Updated particles from #", debug_currentParticle, " to end, updated sim"); auto updated = i18nMulti("Updated particles from #", " to end, updated sim");
logmessage = String::Build(updated[0], debug_currentParticle, updated[1]);
} }
else else
logmessage = String::Build("Updated particles #", debug_currentParticle, " through #", i); {
auto updated = i18nMulti("Updated particles #", "through #");
logmessage = String::Build(updated[0], debug_currentParticle, updated[1], i);
}
} }
model->Log(logmessage, false); model->Log(logmessage, false);
@ -90,7 +94,8 @@ bool ParticleDebug::KeyPress(int key, int scan, bool shift, bool ctrl, bool alt,
{ {
sim->UpdateParticles(sim->debug_currentParticle, NPART); sim->UpdateParticles(sim->debug_currentParticle, NPART);
sim->AfterSim(); sim->AfterSim();
String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end, updated sim"); auto updated = i18nMulti("Updated particles from #", " to end, updated sim");
String logmessage = String::Build(updated[0], sim->debug_currentParticle, updated[1]);
model->Log(logmessage, false); model->Log(logmessage, false);
sim->debug_currentParticle = 0; sim->debug_currentParticle = 0;
} }

View File

@ -592,7 +592,7 @@ void Graphics::textnpos(String str, int n, int w, int *cx, int *cy)
while (*s&&n) while (*s&&n)
{ {
wordlen = 0; wordlen = 0;
while(*s && String(" .,!?\n").Contains(*s)) while(*s && String(" .,!?\n"_ascii).Contains(*s))
s++; s++;
charspace = textwidthx(s, w-x); charspace = textwidthx(s, w-x);
if (charspace<wordlen && wordlen && w-x<w/3) if (charspace<wordlen && wordlen && w-x<w/3)
@ -653,7 +653,7 @@ int Graphics::textwrapheight(String str, int width)
while (*s) while (*s)
{ {
wordlen = 0; wordlen = 0;
while(*s && String(" .,!?\n").Contains(*s)) while(*s && String(" .,!?\n"_ascii).Contains(*s))
s++; s++;
charspace = textwidthx(s, width-x); charspace = textwidthx(s, width-x);
if (charspace<wordlen && wordlen && width-x<width/3) if (charspace<wordlen && wordlen && width-x<width/3)
@ -734,6 +734,7 @@ void Graphics::textsize(String str, int & width, int & height)
void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert) void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert)
{ {
static String voteText = "Vote"_i18n;
y--; y--;
switch(icon) switch(icon)
{ {
@ -759,12 +760,12 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
if(invert) if(invert)
{ {
drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha); drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha);
drawtext(x+2, y+1, "Vote", 0, 100, 0, alpha); drawtext(x+2, y+1, voteText, 0, 100, 0, alpha);
} }
else else
{ {
drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha); drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha);
drawtext(x+2, y+1, "Vote", 0, 187, 18, alpha); drawtext(x+2, y+1, voteText, 0, 187, 18, alpha);
} }
break; break;
case IconVoteDown: case IconVoteDown:

View File

@ -39,34 +39,34 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, OnPicked on
UpdateTextboxes(r, g, b, alpha); UpdateTextboxes(r, g, b, alpha);
}; };
rValue = new ui::Textbox(ui::Point(5, Size.Y-23), ui::Point(30, 17), "255"); rValue = new ui::Textbox(ui::Point(5, Size.Y-23), ui::Point(30, 17), "255"_ascii);
rValue->SetActionCallback({ colourChange }); rValue->SetActionCallback({ colourChange });
rValue->SetLimit(3); rValue->SetLimit(3);
rValue->SetInputType(ui::Textbox::Number); rValue->SetInputType(ui::Textbox::Number);
AddComponent(rValue); AddComponent(rValue);
gValue = new ui::Textbox(ui::Point(40, Size.Y-23), ui::Point(30, 17), "255"); gValue = new ui::Textbox(ui::Point(40, Size.Y-23), ui::Point(30, 17), "255"_ascii);
gValue->SetActionCallback({ colourChange }); gValue->SetActionCallback({ colourChange });
gValue->SetLimit(3); gValue->SetLimit(3);
gValue->SetInputType(ui::Textbox::Number); gValue->SetInputType(ui::Textbox::Number);
AddComponent(gValue); AddComponent(gValue);
bValue = new ui::Textbox(ui::Point(75, Size.Y-23), ui::Point(30, 17), "255"); bValue = new ui::Textbox(ui::Point(75, Size.Y-23), ui::Point(30, 17), "255"_ascii);
bValue->SetActionCallback({ colourChange }); bValue->SetActionCallback({ colourChange });
bValue->SetLimit(3); bValue->SetLimit(3);
bValue->SetInputType(ui::Textbox::Number); bValue->SetInputType(ui::Textbox::Number);
AddComponent(bValue); AddComponent(bValue);
aValue = new ui::Textbox(ui::Point(110, Size.Y-23), ui::Point(30, 17), "255"); aValue = new ui::Textbox(ui::Point(110, Size.Y-23), ui::Point(30, 17), "255"_ascii);
aValue->SetActionCallback({ colourChange }); aValue->SetActionCallback({ colourChange });
aValue->SetLimit(3); aValue->SetLimit(3);
aValue->SetInputType(ui::Textbox::Number); aValue->SetInputType(ui::Textbox::Number);
AddComponent(aValue); AddComponent(aValue);
hexValue = new::ui::Label(ui::Point(150, Size.Y-23), ui::Point(53, 17), "0xFFFFFFFF"); hexValue = new::ui::Label(ui::Point(150, Size.Y-23), ui::Point(53, 17), "0xFFFFFFFF"_ascii);
AddComponent(hexValue); AddComponent(hexValue);
ui::Button * doneButton = new ui::Button(ui::Point(Size.X-45, Size.Y-23), ui::Point(40, 17), "Done"); ui::Button * doneButton = new ui::Button(ui::Point(Size.X-45, Size.Y-23), ui::Point(40, 17), "Done"_i18n);
doneButton->SetActionCallback({ [this] { doneButton->SetActionCallback({ [this] {
int Red, Green, Blue; int Red, Green, Blue;
Red = rValue->GetText().ToNumber<int>(true); Red = rValue->GetText().ToNumber<int>(true);

View File

@ -23,7 +23,7 @@ void ConsoleController::EvaluateCommand(String command)
{ {
if(command.length()) if(command.length())
{ {
if (command.BeginsWith("!load ")) if (command.BeginsWith("!load "_ascii))
CloseConsole(); CloseConsole();
int returnCode = commandInterface->Command(command); int returnCode = commandInterface->Command(command);
consoleModel->AddLastCommand(ConsoleCommand(command, returnCode, commandInterface->GetLastError())); consoleModel->AddLastCommand(ConsoleCommand(command, returnCode, commandInterface->GetLastError()));

View File

@ -10,7 +10,7 @@ ConsoleModel::ConsoleModel() {
{ {
if(previousCommands.size()<25) if(previousCommands.size()<25)
{ {
previousCommands.push_front(ConsoleCommand(*iter, 0, "")); previousCommands.push_front(ConsoleCommand(*iter, 0, ""_ascii));
currentCommandIndex = previousCommands.size(); currentCommandIndex = previousCommands.size();
} }
} }
@ -37,7 +37,7 @@ ConsoleCommand ConsoleModel::GetCurrentCommand()
{ {
if (currentCommandIndex >= previousCommands.size()) if (currentCommandIndex >= previousCommands.size())
{ {
return ConsoleCommand("", 0, ""); return ConsoleCommand(""_ascii, 0, ""_ascii);
} }
return previousCommands[currentCommandIndex]; return previousCommands[currentCommandIndex];
} }

View File

@ -19,7 +19,7 @@ ConsoleView::ConsoleView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, 150)), ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, 150)),
commandField(NULL) commandField(NULL)
{ {
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), ""); commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), ""_ascii);
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
commandField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; commandField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
commandField->SetActionCallback({ [this] { commandField->SetDisplayText(c->FormatCommand(commandField->GetText())); } }); commandField->SetActionCallback({ [this] { commandField->SetDisplayText(c->FormatCommand(commandField->GetText())); } });
@ -41,8 +41,8 @@ void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ct
case SDLK_RETURN: case SDLK_RETURN:
case SDLK_KP_ENTER: case SDLK_KP_ENTER:
c->EvaluateCommand(commandField->GetText()); c->EvaluateCommand(commandField->GetText());
commandField->SetText(""); commandField->SetText(""_ascii);
commandField->SetDisplayText(""); commandField->SetDisplayText(""_ascii);
break; break;
case SDLK_DOWN: case SDLK_DOWN:
c->NextCommand(); c->NextCommand();
@ -62,7 +62,7 @@ void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ct
void ConsoleView::DoTextInput(String text) void ConsoleView::DoTextInput(String text)
{ {
if (text == "~") if (text == "~"_ascii)
doClose = false; doClose = false;
if (!doClose) if (!doClose)
Window::DoTextInput(text); Window::DoTextInput(text);

View File

@ -38,7 +38,7 @@ ConfirmPrompt::ConfirmPrompt(String title, String message, ResultCallback callba
Size.Y += messagePanel->Size.Y+12; Size.Y += messagePanel->Size.Y+12;
Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2; Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X-75, 16), "Cancel"); ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X-75, 16), "Cancel"_i18n);
cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200); cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);

View File

@ -29,7 +29,7 @@ ErrorMessage::ErrorMessage(String title, String message, DismissCallback callbac
Size.Y += messageLabel->Size.Y+12; Size.Y += messageLabel->Size.Y+12;
Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2; Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss"); ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss"_i18n);
okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200); okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);

View File

@ -55,7 +55,7 @@ InformationMessage::InformationMessage(String title, String message, bool large)
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(titleLabel); AddComponent(titleLabel);
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss"); ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "Dismiss"_i18n);
okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200); okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);

View File

@ -13,21 +13,21 @@
SaveIDMessage::SaveIDMessage(int id): SaveIDMessage::SaveIDMessage(int id):
ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90)) ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90))
{ {
int textWidth = Graphics::textwidth("Save ID"); int textWidth = Graphics::textwidth("Save ID"_i18n);
ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(textWidth+20, 16), "Save ID"); ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(textWidth+20, 16), "Save ID"_i18n);
titleLabel->SetTextColour(style::Colour::InformationTitle); titleLabel->SetTextColour(style::Colour::InformationTitle);
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(titleLabel); AddComponent(titleLabel);
textWidth = Graphics::textwidth("Saved Successfully!"); textWidth = Graphics::textwidth("Saved Successfully!"_i18n);
ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(textWidth+20, 16), "Saved Successfully!"); ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(textWidth+20, 16), "Saved Successfully!"_i18n);
messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel); AddComponent(messageLabel);
textWidth = Graphics::textwidth("Click the box below to copy the save ID"); textWidth = Graphics::textwidth("Click the box below to copy the save ID"_i18n);
ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id"); ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id"_i18n);
copyTextLabel->SetTextColour(ui::Colour(150, 150, 150)); copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(copyTextLabel); AddComponent(copyTextLabel);
@ -36,7 +36,7 @@ SaveIDMessage::SaveIDMessage(int id):
ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), String::Build(id), copyTextLabel); ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), String::Build(id), copyTextLabel);
AddComponent(copyTextButton); AddComponent(copyTextButton);
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK"); ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK"_i18n);
okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
okayButton->SetActionCallback({ [this] { okayButton->SetActionCallback({ [this] {

View File

@ -47,7 +47,7 @@ TextPrompt::TextPrompt(String title, String message, String text, String placeho
AddComponent(textField); AddComponent(textField);
FocusComponent(textField); FocusComponent(textField);
ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel"); ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)+1, 16), "Cancel"_i18n);
cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200); cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
@ -60,7 +60,7 @@ TextPrompt::TextPrompt(String title, String message, String text, String placeho
AddComponent(cancelButton); AddComponent(cancelButton);
SetCancelButton(cancelButton); SetCancelButton(cancelButton);
ui::Button * okayButton = new ui::Button(ui::Point(Size.X/2, Size.Y-16), ui::Point(Size.X/2, 16), "Okay"); ui::Button * okayButton = new ui::Button(ui::Point(Size.X/2, Size.Y-16), ui::Point(Size.X/2, 16), "OK"_i18n);
okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight; okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
okayButton->Appearance.TextInactive = style::Colour::WarningTitle; okayButton->Appearance.TextInactive = style::Colour::WarningTitle;

View File

@ -20,7 +20,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
firstResult(NULL), firstResult(NULL),
gameController(gameController), gameController(gameController),
tools(tools), tools(tools),
toolTip(""), toolTip(""_ascii),
toolTipPresence(0), toolTipPresence(0),
shiftPressed(false), shiftPressed(false),
ctrlPressed(false), ctrlPressed(false),
@ -28,20 +28,20 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
isToolTipFadingIn(false), isToolTipFadingIn(false),
exit(false) exit(false)
{ {
ui::Label * title = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "Element Search"); ui::Label * title = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), "Element Search"_i18n);
title->SetTextColour(style::Colour::InformationTitle); title->SetTextColour(style::Colour::InformationTitle);
title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(title); AddComponent(title);
searchField = new ui::Textbox(ui::Point(8, 23), ui::Point(Size.X-16, 17), ""); searchField = new ui::Textbox(ui::Point(8, 23), ui::Point(Size.X-16, 17), ""_ascii);
searchField->SetActionCallback({ [this] { searchTools(searchField->GetText()); } }); searchField->SetActionCallback({ [this] { searchTools(searchField->GetText()); } });
searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(searchField); AddComponent(searchField);
FocusComponent(searchField); FocusComponent(searchField);
ui::Button * closeButton = new ui::Button(ui::Point(0, Size.Y-15), ui::Point((Size.X/2)+1, 15), "Close"); ui::Button * closeButton = new ui::Button(ui::Point(0, Size.Y-15), ui::Point((Size.X/2)+1, 15), "Close"_i18n);
closeButton->SetActionCallback({ [this] { exit = true; } }); closeButton->SetActionCallback({ [this] { exit = true; } });
ui::Button * okButton = new ui::Button(ui::Point(Size.X/2, Size.Y-15), ui::Point(Size.X/2, 15), "OK"); ui::Button * okButton = new ui::Button(ui::Point(Size.X/2, Size.Y-15), ui::Point(Size.X/2, 15), "OK"_i18n);
okButton->SetActionCallback({ [this] { okButton->SetActionCallback({ [this] {
if (GetFirstResult()) if (GetFirstResult())
SetActiveTool(0, GetFirstResult()); SetActiveTool(0, GetFirstResult());
@ -50,7 +50,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
AddComponent(okButton); AddComponent(okButton);
AddComponent(closeButton); AddComponent(closeButton);
searchTools(""); searchTools(""_ascii);
} }
void ElementSearchActivity::searchTools(String query) void ElementSearchActivity::searchTools(String query)
@ -143,7 +143,7 @@ void ElementSearchActivity::searchTools(String query)
ToolButton * tempButton; ToolButton * tempButton;
if(tempTexture) if(tempTexture)
tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), "", tool->GetIdentifier(), tool->GetDescription()); tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), ""_ascii, tool->GetIdentifier(), tool->GetDescription());
else else
tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), tool->GetName(), tool->GetIdentifier(), tool->GetDescription()); tempButton = new ToolButton(current+viewPosition, ui::Point(30, 18), tool->GetName(), tool->GetIdentifier(), tool->GetDescription());

View File

@ -313,17 +313,17 @@ FontEditor::FontEditor(ByteString _dataFile):
next->SetActionCallback({ [this] { NextChar(); } }); next->SetActionCallback({ [this] { NextChar(); } });
AddComponent(next); AddComponent(next);
ui::Button *shrink = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "><"); ui::Button *shrink = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "><"_ascii);
currentX += 18; currentX += 18;
shrink->SetActionCallback({ [this] { ShrinkChar(); } }); shrink->SetActionCallback({ [this] { ShrinkChar(); } });
AddComponent(shrink); AddComponent(shrink);
ui::Button *grow = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "<>"); ui::Button *grow = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "<>"_ascii);
currentX += 18; currentX += 18;
grow->SetActionCallback({ [this] { GrowChar(); } }); grow->SetActionCallback({ [this] { GrowChar(); } });
AddComponent(grow); AddComponent(grow);
ui::Button *add = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Add"); ui::Button *add = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Add"_ascii);
currentX += 37; currentX += 37;
add->SetActionCallback({ [this] { add->SetActionCallback({ [this] {
if (fontWidths.find(currentChar) == fontWidths.end()) if (fontWidths.find(currentChar) == fontWidths.end())
@ -335,7 +335,7 @@ FontEditor::FontEditor(ByteString _dataFile):
} }); } });
AddComponent(add); AddComponent(add);
ui::Button *remove = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Remove"); ui::Button *remove = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Remove"_ascii);
currentX += 37; currentX += 37;
remove->SetActionCallback({ [this] { remove->SetActionCallback({ [this] {
if (fontWidths.find(currentChar) != fontWidths.end()) if (fontWidths.find(currentChar) != fontWidths.end())
@ -347,7 +347,7 @@ FontEditor::FontEditor(ByteString _dataFile):
} }); } });
AddComponent(remove); AddComponent(remove);
ui::Button *showGrid = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Grid"); ui::Button *showGrid = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Grid"_ascii);
currentX += 33; currentX += 33;
showGrid->SetTogglable(true); showGrid->SetTogglable(true);
showGrid->SetToggleState(grid); showGrid->SetToggleState(grid);
@ -356,7 +356,7 @@ FontEditor::FontEditor(ByteString _dataFile):
} }); } });
AddComponent(showGrid); AddComponent(showGrid);
ui::Button *showRulers = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Rulers"); ui::Button *showRulers = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Rulers"_ascii);
currentX += 33; currentX += 33;
showRulers->SetTogglable(true); showRulers->SetTogglable(true);
showRulers->SetToggleState(rulers); showRulers->SetToggleState(rulers);
@ -382,12 +382,12 @@ FontEditor::FontEditor(ByteString _dataFile):
baseline += 18; baseline += 18;
currentX = 1; currentX = 1;
ui::Button *render = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Render"); ui::Button *render = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Render"_ascii);
currentX += 51; currentX += 51;
render->SetActionCallback({ [this] { Render(); } }); render->SetActionCallback({ [this] { Render(); } });
AddComponent(render); AddComponent(render);
savedButton = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Save"); savedButton = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Save"_ascii);
currentX += 51; currentX += 51;
savedButton->SetTogglable(true); savedButton->SetTogglable(true);
savedButton->SetToggleState(true); savedButton->SetToggleState(true);
@ -398,7 +398,7 @@ FontEditor::FontEditor(ByteString _dataFile):
ui::ScrollPanel *outputPanel = new ui::ScrollPanel(ui::Point(Size.X / 2, baseline), ui::Point(Size.X / 2, Size.Y - baseline)); ui::ScrollPanel *outputPanel = new ui::ScrollPanel(ui::Point(Size.X / 2, baseline), ui::Point(Size.X / 2, Size.Y - baseline));
AddComponent(outputPanel); AddComponent(outputPanel);
StretchLabel *outputPreview = new StretchLabel(ui::Point(0, 0), ui::Point(Size.X / 2, 0), ""); StretchLabel *outputPreview = new StretchLabel(ui::Point(0, 0), ui::Point(Size.X / 2, 0), ""_ascii);
outputPreview->SetMultiline(true); outputPreview->SetMultiline(true);
outputPreview->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; outputPreview->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
outputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop; outputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop;
@ -454,9 +454,9 @@ FontEditor::FontEditor(ByteString _dataFile):
if(p[0] < 0x20) if(p[0] < 0x20)
p[0] = 0x20; p[0] = 0x20;
if(p[0] == p[1]) if(p[0] == p[1])
input << p[0] << "\n"; input << p[0] << "\n"_ascii;
else else
input << p[0] << ":" << p[1] << "\n"; input << p[0] << ":"_ascii << p[1] << "\n"_ascii;
} }
inputPreview->SetText(input.Build()); inputPreview->SetText(input.Build());
textChangedCallback(); textChangedCallback();
@ -530,7 +530,7 @@ void FontEditor::OnDraw()
} }
else else
{ {
g->drawtext(8, 8, "No character", 255, 0, 0, 255); g->drawtext(8, 8, "No character"_ascii, 255, 0, 0, 255);
} }
} }

View File

@ -29,7 +29,7 @@ void Button::TextPosition(String ButtonText)
{ {
int position = Graphics::textwidthx(buttonDisplayText, Size.X - (Appearance.icon? 38 : 22)); int position = Graphics::textwidthx(buttonDisplayText, Size.X - (Appearance.icon? 38 : 22));
buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position); buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position);
buttonDisplayText += "..."; buttonDisplayText += "..."_ascii;
} }
} }

View File

@ -25,7 +25,7 @@ namespace ui
ui::Button::OnMouseClick(x, y, button); ui::Button::OnMouseClick(x, y, button);
ClipboardPush(ButtonText.ToUtf8()); ClipboardPush(ButtonText.ToUtf8());
copyTextLabel->SetText("Copied!"); copyTextLabel->SetText("Copied!"_i18n);
Appearance.TextInactive = ui::Colour(180, 230, 180); Appearance.TextInactive = ui::Colour(180, 230, 180);
Appearance.TextHover = ui::Colour(180, 230, 180); Appearance.TextHover = ui::Colour(180, 230, 180);

View File

@ -77,7 +77,7 @@ void Engine::Exit()
void Engine::ConfirmExit() void Engine::ConfirmExit()
{ {
new ConfirmPrompt("You are about to quit", "Are you sure you want to exit the game?", { [] { new ConfirmPrompt("You are about to quit"_i18n, "Are you sure you want to exit the game?"_i18n, { [] {
ui::Engine::Ref().Exit(); ui::Engine::Ref().Exit();
} }); } });
} }

View File

@ -23,7 +23,7 @@ Label::Label(Point position, Point size, String labelText):
SetText(labelText); SetText(labelText);
menu = new ContextMenu(this); menu = new ContextMenu(this);
menu->AddItem(ContextMenuItem("Copy", 0, true)); menu->AddItem(ContextMenuItem("Copy"_i18n, 0, true));
} }
Label::~Label() Label::~Label()
@ -206,8 +206,8 @@ void Label::updateSelection()
{ {
auto indexL = displayTextWrapper.Clear2Index(selectionIndexL.clear_index); auto indexL = displayTextWrapper.Clear2Index(selectionIndexL.clear_index);
auto indexH = displayTextWrapper.Clear2Index(selectionIndexH.clear_index); auto indexH = displayTextWrapper.Clear2Index(selectionIndexH.clear_index);
displayTextWithSelection.Insert(indexL.wrapped_index , "\x01"); displayTextWithSelection.Insert(indexL.wrapped_index , "\x01"_ascii);
displayTextWithSelection.Insert(indexH.wrapped_index + 1, "\x01"); displayTextWithSelection.Insert(indexH.wrapped_index + 1, "\x01"_ascii);
} }
} }

View File

@ -12,7 +12,7 @@ ProgressBar::ProgressBar(Point position, Point size, int startProgress, String s
Component(position, size), Component(position, size),
progress(0), progress(0),
intermediatePos(0.0f), intermediatePos(0.0f),
progressStatus("") progressStatus(""_ascii)
{ {
SetStatus(startStatus); SetStatus(startStatus);
SetProgress(startProgress); SetProgress(startProgress);

View File

@ -236,8 +236,8 @@ void Window::DoDraw()
Graphics * g = ui::Engine::Ref().g; Graphics * g = ui::Engine::Ref().g;
String tempString, tempString2; String tempString, tempString2;
tempString = String::Build("Position: L ", focusedComponent_->Position.X, ", R ", Size.X-(focusedComponent_->Position.X+focusedComponent_->Size.X), ", T: ", focusedComponent_->Position.Y, ", B: ", Size.Y-(focusedComponent_->Position.Y+focusedComponent_->Size.Y)); tempString = String::Build("Position: L "_ascii, focusedComponent_->Position.X, ", R "_ascii, Size.X-(focusedComponent_->Position.X+focusedComponent_->Size.X), ", T: "_ascii, focusedComponent_->Position.Y, ", B: "_ascii, Size.Y-(focusedComponent_->Position.Y+focusedComponent_->Size.Y));
tempString2 = String::Build("Size: ", focusedComponent_->Size.X, ", ", focusedComponent_->Size.Y); tempString2 = String::Build("Size: "_ascii, focusedComponent_->Size.X, ", "_ascii, focusedComponent_->Size.Y);
if (Graphics::textwidth(tempString)+xPos > WINDOWW) if (Graphics::textwidth(tempString)+xPos > WINDOWW)
xPos = WINDOWW-(Graphics::textwidth(tempString)+5); xPos = WINDOWW-(Graphics::textwidth(tempString)+5);

View File

@ -22,19 +22,20 @@ LocalBrowserView::LocalBrowserView():
lastChanged(0), lastChanged(0),
pageCount(0) pageCount(0)
{ {
nextButton = new ui::Button(ui::Point(WINDOWW-52, WINDOWH-18), ui::Point(50, 16), String("Next ") + 0xE015); nextButton = new ui::Button(ui::Point(WINDOWW-52, WINDOWH-18), ui::Point(50, 16), "Next "_i18n + 0xE015);
previousButton = new ui::Button(ui::Point(2, WINDOWH-18), ui::Point(50, 16), 0xE016 + String(" Prev")); previousButton = new ui::Button(ui::Point(2, WINDOWH-18), ui::Point(50, 16), 0xE016 + " Prev"_i18n);
undeleteButton = new ui::Button(ui::Point(WINDOWW-122, WINDOWH-18), ui::Point(60, 16), "Rescan"); undeleteButton = new ui::Button(ui::Point(WINDOWW-122, WINDOWH-18), ui::Point(60, 16), "Rescan"_i18n);
AddComponent(nextButton); AddComponent(nextButton);
AddComponent(previousButton); AddComponent(previousButton);
AddComponent(undeleteButton); AddComponent(undeleteButton);
pageTextbox = new ui::Textbox(ui::Point(283, WINDOWH-18), ui::Point(41, 16), ""); pageTextbox = new ui::Textbox(ui::Point(283, WINDOWH-18), ui::Point(41, 16), ""_ascii);
pageTextbox->SetActionCallback({ [this] { textChanged(); } }); pageTextbox->SetActionCallback({ [this] { textChanged(); } });
pageTextbox->SetInputType(ui::Textbox::Number); pageTextbox->SetInputType(ui::Textbox::Number);
pageLabel = new ui::Label(ui::Point(0, WINDOWH-18), ui::Point(30, 16), "Page"); //page [TEXTBOX] of y auto pageOf = i18nMulti("Page", "of "); //page [TEXTBOX] of y
pageLabel = new ui::Label(ui::Point(0, WINDOWH-18), ui::Point(30, 16), pageOf[0]);
pageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignRight; pageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
pageCountLabel = new ui::Label(ui::Point(WINDOWW/2+6, WINDOWH-18), ui::Point(50, 16), ""); pageCountLabel = new ui::Label(ui::Point(WINDOWW/2+6, WINDOWH-18), ui::Point(50, 16), ""_ascii);
pageCountLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; pageCountLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(pageLabel); AddComponent(pageLabel);
AddComponent(pageCountLabel); AddComponent(pageCountLabel);
@ -50,7 +51,7 @@ LocalBrowserView::LocalBrowserView():
undeleteButton->SetActionCallback({ [this] { c->RescanStamps(); } }); undeleteButton->SetActionCallback({ [this] { c->RescanStamps(); } });
removeSelected = new ui::Button(ui::Point(((WINDOWW-100)/2), WINDOWH-18), ui::Point(100, 16), "Delete"); removeSelected = new ui::Button(ui::Point(((WINDOWW-100)/2), WINDOWH-18), ui::Point(100, 16), "Delete"_i18n);
removeSelected->Visible = false; removeSelected->Visible = false;
removeSelected->SetActionCallback({ [this] { c->RemoveSelected(); } }); removeSelected->SetActionCallback({ [this] { c->RemoveSelected(); } });
AddComponent(removeSelected); AddComponent(removeSelected);
@ -59,10 +60,8 @@ LocalBrowserView::LocalBrowserView():
void LocalBrowserView::textChanged() void LocalBrowserView::textChanged()
{ {
int num = pageTextbox->GetText().ToNumber<int>(true); int num = pageTextbox->GetText().ToNumber<int>(true);
if (num < 0) //0 is allowed so that you can backspace the 1 if(num < 0 || num > pageCount) //0 is allowed so that you can backspace the 1
pageTextbox->SetText("1"); pageTextbox->SetText(String::Build(num < 0 ? 1 : pageCount));
else if (num > pageCount)
pageTextbox->SetText(String::Build(pageCount));
changed = true; changed = true;
lastChanged = GetTicks()+600; lastChanged = GetTicks()+600;
} }
@ -86,7 +85,8 @@ void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender)
} }
else else
{ {
String pageInfo = String::Build("of ", pageCount); auto pageOf = i18nMulti("Page", "of ");
String pageInfo = String::Build(pageOf[1], pageCount);
pageCountLabel->SetText(pageInfo); pageCountLabel->SetText(pageInfo);
int width = Graphics::textwidth(pageInfo); int width = Graphics::textwidth(pageInfo);

View File

@ -3,6 +3,7 @@
#include "LoginView.h" #include "LoginView.h"
#include "client/Client.h" #include "client/Client.h"
#include "Config.h"
LoginModel::LoginModel(): LoginModel::LoginModel():
currentUser(0, "") currentUser(0, "")
@ -14,19 +15,19 @@ void LoginModel::Login(ByteString username, ByteString password)
{ {
if (username.Contains("@")) if (username.Contains("@"))
{ {
statusText = "Use your Powder Toy account to log in, not your email. If you don't have a Powder Toy account, you can create one at https://powdertoy.co.uk/Register.html"; statusText = "Use your Powder Toy account to log in, not your email. If you don't have a Powder Toy account, you can create one at "_i18n + ByteString(SCHEME SERVER "/Register.html").FromAscii();
loginStatus = false; loginStatus = false;
notifyStatusChanged(); notifyStatusChanged();
return; return;
} }
statusText = "Logging in..."; statusText = "Logging in..."_i18n;
loginStatus = false; loginStatus = false;
notifyStatusChanged(); notifyStatusChanged();
LoginStatus status = Client::Ref().Login(username, password, currentUser); LoginStatus status = Client::Ref().Login(username, password, currentUser);
switch(status) switch(status)
{ {
case LoginOkay: case LoginOkay:
statusText = "Logged in"; statusText = "Logged in"_i18n;
loginStatus = true; loginStatus = true;
break; break;
case LoginError: case LoginError:

View File

@ -16,12 +16,12 @@
LoginView::LoginView(): LoginView::LoginView():
ui::Window(ui::Point(-1, -1), ui::Point(200, 87)), ui::Window(ui::Point(-1, -1), ui::Point(200, 87)),
loginButton(new ui::Button(ui::Point(200-100, 87-17), ui::Point(100, 17), "Sign in")), loginButton(new ui::Button(ui::Point(200-100, 87-17), ui::Point(100, 17), "Sign in"_i18n)),
cancelButton(new ui::Button(ui::Point(0, 87-17), ui::Point(101, 17), "Sign Out")), cancelButton(new ui::Button(ui::Point(0, 87-17), ui::Point(101, 17), "Sign Out"_i18n)),
titleLabel(new ui::Label(ui::Point(4, 5), ui::Point(200-16, 16), "Server login")), titleLabel(new ui::Label(ui::Point(4, 5), ui::Point(200-16, 16), "Server login"_i18n)),
infoLabel(new ui::Label(ui::Point(8, 67), ui::Point(200-16, 16), "")), infoLabel(new ui::Label(ui::Point(8, 67), ui::Point(200-16, 16), ""_ascii)),
usernameField(new ui::Textbox(ui::Point(8, 25), ui::Point(200-16, 17), Client::Ref().GetAuthUser().Username.FromUtf8(), "[username]")), usernameField(new ui::Textbox(ui::Point(8, 25), ui::Point(200-16, 17), Client::Ref().GetAuthUser().Username.FromUtf8(), "[username]"_i18n)),
passwordField(new ui::Textbox(ui::Point(8, 46), ui::Point(200-16, 17), "", "[password]")), passwordField(new ui::Textbox(ui::Point(8, 46), ui::Point(200-16, 17), ""_ascii, "[password]"_i18n)),
targetSize(0, 0) targetSize(0, 0)
{ {
targetSize = Size; targetSize = Size;

View File

@ -58,7 +58,7 @@ bool PreviewController::SubmitComment(String comment)
{ {
if(comment.length() < 4) if(comment.length() < 4)
{ {
new ErrorMessage("Error", "Comment is too short"); new ErrorMessage("Error"_i18n, "Comment is too short"_i18n);
return false; return false;
} }
else else
@ -66,7 +66,7 @@ bool PreviewController::SubmitComment(String comment)
RequestStatus status = Client::Ref().AddComment(saveId, comment); RequestStatus status = Client::Ref().AddComment(saveId, comment);
if(status != RequestOkay) if(status != RequestOkay)
{ {
new ErrorMessage("Error submitting comment", Client::Ref().GetLastError()); new ErrorMessage("Error submitting comment"_i18n, Client::Ref().GetLastError());
return false; return false;
} }
else else
@ -109,10 +109,10 @@ void PreviewController::Report(String message)
if(Client::Ref().ReportSave(saveId, message) == RequestOkay) if(Client::Ref().ReportSave(saveId, message) == RequestOkay)
{ {
Exit(); Exit();
new InformationMessage("Information", "Report submitted", false); new InformationMessage("Information"_i18n, "Report submitted"_i18n, false);
} }
else else
new ErrorMessage("Error", "Unable to file report: " + Client::Ref().GetLastError()); new ErrorMessage("Error"_i18n, "Unable to file report: "_i18n + Client::Ref().GetLastError());
} }
void PreviewController::FavouriteSave() void PreviewController::FavouriteSave()
@ -128,7 +128,7 @@ void PreviewController::FavouriteSave()
} }
catch (PreviewModelException & e) catch (PreviewModelException & e)
{ {
new ErrorMessage("Error", ByteString(e.what()).FromUtf8()); new ErrorMessage("Error"_i18n, ByteString(e.what()).FromUtf8());
} }
} }
} }

View File

@ -39,9 +39,9 @@ void PreviewModel::SetFavourite(bool favourite)
if (Client::Ref().FavouriteSave(saveInfo->id, favourite) == RequestOkay) if (Client::Ref().FavouriteSave(saveInfo->id, favourite) == RequestOkay)
saveInfo->Favourite = favourite; saveInfo->Favourite = favourite;
else if (favourite) else if (favourite)
throw PreviewModelException("Error, could not fav. the save: " + Client::Ref().GetLastError()); throw PreviewModelException("Error, could not fav. the save: "_i18n + Client::Ref().GetLastError());
else else
throw PreviewModelException("Error, could not unfav. the save: " + Client::Ref().GetLastError()); throw PreviewModelException("Error, could not unfav. the save: "_i18n + Client::Ref().GetLastError());
notifySaveChanged(); notifySaveChanged();
} }
} }
@ -175,12 +175,12 @@ void PreviewModel::OnSaveReady()
{ {
GameSave *gameSave = new GameSave(*saveData); GameSave *gameSave = new GameSave(*saveData);
if (gameSave->fromNewerVersion) if (gameSave->fromNewerVersion)
new ErrorMessage("This save is from a newer version", "Please update TPT in game or at https://powdertoy.co.uk"); new ErrorMessage("This save is from a newer version"_i18n, "Please update TPT in game or at "_i18n + ByteString(SCHEME SERVER).FromAscii());
saveInfo->SetGameSave(gameSave); saveInfo->SetGameSave(gameSave);
} }
catch(ParseException &e) catch(ParseException &e)
{ {
new ErrorMessage("Error", ByteString(e.what()).FromUtf8()); new ErrorMessage("Error"_i18n, ByteString(e.what()).FromUtf8());
canOpen = false; canOpen = false;
} }
notifySaveChanged(); notifySaveChanged();
@ -331,7 +331,7 @@ void PreviewModel::Update()
else else
{ {
for (size_t i = 0; i < observers.size(); i++) for (size_t i = 0; i < observers.size(); i++)
observers[i]->SaveLoadingError("Could not parse save info"); observers[i]->SaveLoadingError("Could not parse save info"_i18n);
} }
} }
else else

View File

@ -22,7 +22,7 @@ CommandInterface::CommandInterface(GameController * c, GameModel * m) {
int CommandInterface::Command(String command) int CommandInterface::Command(String command)
{ {
lastError = "No interpreter"; lastError = "No interpreter"_i18n;
return -1; return -1;
} }

View File

@ -280,7 +280,7 @@ void luacon_hook(lua_State * l, lua_Debug * ar)
{ {
if(ar->event == LUA_HOOKCOUNT && Platform::GetTime()-ui::Engine::Ref().LastTick() > 3000) if(ar->event == LUA_HOOKCOUNT && Platform::GetTime()-ui::Engine::Ref().LastTick() > 3000)
{ {
if(ConfirmPrompt::Blocking("Script not responding", "The Lua script may have stopped responding. There might be an infinite loop. Press \"Stop\" to stop it", "Stop")) if(ConfirmPrompt::Blocking("Script not responding"_i18n, "The Lua script may have stopped responding. There might be an infinite loop. Press \"Stop\" to stop it"_i18n, "Stop"_i18n))
luaL_error(l, "Error: Script not responding"); luaL_error(l, "Error: Script not responding");
ui::Engine::Ref().LastTick(Platform::GetTime()); ui::Engine::Ref().LastTick(Platform::GetTime());
} }
@ -459,7 +459,7 @@ int luatpt_graphics_func(lua_State *l)
int luatpt_error(lua_State* l) int luatpt_error(lua_State* l)
{ {
String errorMessage = ByteString(luaL_optstring(l, 1, "Error text")).FromUtf8(); String errorMessage = ByteString(luaL_optstring(l, 1, "Error text")).FromUtf8();
ErrorMessage::Blocking("Error", errorMessage); ErrorMessage::Blocking("Error"_i18n, errorMessage);
return 0; return 0;
} }
@ -560,12 +560,12 @@ int luatpt_setconsole(lua_State* l)
int luatpt_log(lua_State* l) int luatpt_log(lua_State* l)
{ {
int args = lua_gettop(l); int args = lua_gettop(l);
String text = ""; String text = ""_ascii;
for(int i = 1; i <= args; i++) for(int i = 1; i <= args; i++)
{ {
luaL_tostring(l, -1); luaL_tostring(l, -1);
if(text.length()) if(text.length())
text=ByteString(luaL_optstring(l, -1, "")).FromUtf8() + ", " + text; text=ByteString(luaL_optstring(l, -1, "")).FromUtf8() + ", "_ascii + text;
else else
text=ByteString(luaL_optstring(l, -1, "")).FromUtf8(); text=ByteString(luaL_optstring(l, -1, "")).FromUtf8();
lua_pop(l, 2); lua_pop(l, 2);
@ -573,7 +573,7 @@ int luatpt_log(lua_State* l)
if((*luacon_currentCommand)) if((*luacon_currentCommand))
{ {
if(luacon_lastError->length()) if(luacon_lastError->length())
*luacon_lastError += "; "; *luacon_lastError += "; "_ascii;
*luacon_lastError += text; *luacon_lastError += text;
} }
else else
@ -1386,7 +1386,7 @@ int luatpt_getscript(lua_State* l)
int confirmPrompt = luaL_optint(l, 4, 1); int confirmPrompt = luaL_optint(l, 4, 1);
ByteString url = ByteString::Build(SCHEME "starcatcher.us/scripts/main.lua?get=", scriptID); ByteString url = ByteString::Build(SCHEME "starcatcher.us/scripts/main.lua?get=", scriptID);
if (confirmPrompt && !ConfirmPrompt::Blocking("Do you want to install script?", url.FromUtf8(), "Install")) if (confirmPrompt && !ConfirmPrompt::Blocking("Do you want to install script?"_i18n, url.FromUtf8(), "Install"_i18n))
return 0; return 0;
int ret; int ret;
@ -1410,7 +1410,7 @@ int luatpt_getscript(lua_State* l)
{ {
fclose(outputfile); fclose(outputfile);
outputfile = NULL; outputfile = NULL;
if (!confirmPrompt || ConfirmPrompt::Blocking("File already exists, overwrite?", ByteString(filename).FromUtf8(), "Overwrite")) if (!confirmPrompt || ConfirmPrompt::Blocking("File already exists, overwrite?"_i18n, ByteString(filename).FromUtf8(), "Overwrite"_i18n))
{ {
outputfile = fopen(filename, "wb"); outputfile = fopen(filename, "wb");
} }

View File

@ -29,7 +29,7 @@ LuaCheckbox::LuaCheckbox(lua_State * l) :
int sizeY = luaL_optinteger(l, 4, 10); int sizeY = luaL_optinteger(l, 4, 10);
String text = ByteString(luaL_optstring(l, 5, "")).FromUtf8(); String text = ByteString(luaL_optstring(l, 5, "")).FromUtf8();
checkbox = new ui::Checkbox(ui::Point(posX, posY), ui::Point(sizeX, sizeY), text, ""); checkbox = new ui::Checkbox(ui::Point(posX, posY), ui::Point(sizeX, sizeY), text, ""_ascii);
component = checkbox; component = checkbox;
checkbox->SetActionCallback({ [this] { triggerAction(); } }); checkbox->SetActionCallback({ [this] { triggerAction(); } });
} }

View File

@ -205,7 +205,7 @@ bool LuaEvents::HandleEvent(LuaScriptInterface *luacon_ci, Event *event, ByteStr
int callret = lua_pcall(l, numArgs, 1, 0); int callret = lua_pcall(l, numArgs, 1, 0);
if (callret) if (callret)
{ {
if (luacon_geterror(luacon_ci) == "Error: Script not responding") if (luacon_geterror(luacon_ci) == "Error: Script not responding"_i18n) // probably not a good idea
{ {
ui::Engine::Ref().LastTick(Platform::GetTime()); ui::Engine::Ref().LastTick(Platform::GetTime());
for (int j = i; j <= len - 1; j++) for (int j = i; j <= len - 1; j++)

View File

@ -54,7 +54,7 @@ AnyType::operator StringType()
else if (type == TypePoint && value.pt) else if (type == TypePoint && value.pt)
{ {
ui::Point thisPoint = *(value.pt); ui::Point thisPoint = *(value.pt);
return StringType(String::Build(thisPoint.X, ",", thisPoint.Y)); return StringType(String::Build(thisPoint.X, ',', thisPoint.Y));
} }
else else
throw InvalidConversionException(type, TypeString); throw InvalidConversionException(type, TypeString);
@ -71,7 +71,7 @@ AnyType::operator PointType()
{ {
int x, y; int x, y;
if(String::Split comma = (*value.str).SplitNumber(x)) if(String::Split comma = (*value.str).SplitNumber(x))
if(comma.After().BeginsWith(",")) if(comma.After().BeginsWith(","_ascii))
if(String::Split end = comma.After().Substr(1).SplitNumber(y)) if(String::Split end = comma.After().Substr(1).SplitNumber(y))
if(!end.After().size()) if(!end.After().size())
return PointType(x, y); return PointType(x, y);

View File

@ -3,7 +3,7 @@
Element::Element(): Element::Element():
Identifier("DEFAULT_INVALID"), Identifier("DEFAULT_INVALID"),
Name(""), Name(""_ascii),
Colour(PIXPACK(0xFF00FF)), Colour(PIXPACK(0xFF00FF)),
MenuVisible(0), MenuVisible(0),
MenuSection(0), MenuSection(0),
@ -29,7 +29,7 @@ Element::Element():
Weight(50), Weight(50),
HeatConduct(128), HeatConduct(128),
Description("No description"), Description("No description"_i18n),
Properties(TYPE_SOLID), Properties(TYPE_SOLID),

View File

@ -11,8 +11,8 @@
SimTool::SimTool(): SimTool::SimTool():
Identifier("DEFAULT_TOOL_INVALID"), Identifier("DEFAULT_TOOL_INVALID"),
Name(""), Name(""_ascii),
Colour(PIXPACK(0xFFFFFF)), Colour(PIXPACK(0xFFFFFF)),
Description("NULL Tool, does NOTHING") Description("NULL Tool, does NOTHING"_i18n)
{ {
} }

View File

@ -5219,7 +5219,7 @@ String Simulation::ElementResolve(int type, int ctype)
{ {
return elements[type].Name; return elements[type].Name;
} }
return "Empty"; return "Empty"_i18n;
} }
String Simulation::BasicParticleInfo(Particle const &sample_part) String Simulation::BasicParticleInfo(Particle const &sample_part)
@ -5230,17 +5230,17 @@ String Simulation::BasicParticleInfo(Particle const &sample_part)
int pavg1int = (int)sample_part.pavg[1]; int pavg1int = (int)sample_part.pavg[1];
if (type == PT_LAVA && ctype && IsValidElement(ctype)) if (type == PT_LAVA && ctype && IsValidElement(ctype))
{ {
sampleInfo << "Molten " << ElementResolve(ctype, -1); sampleInfo << "Molten "_i18n << ElementResolve(ctype, -1);
} }
else if ((type == PT_PIPE || type == PT_PPIP) && ctype && IsValidElement(ctype)) else if ((type == PT_PIPE || type == PT_PPIP) && ctype && IsValidElement(ctype))
{ {
if (ctype == PT_LAVA && pavg1int && IsValidElement(pavg1int)) if (ctype == PT_LAVA && pavg1int && IsValidElement(pavg1int))
{ {
sampleInfo << ElementResolve(type, -1) << " with molten " << ElementResolve(pavg1int, -1); sampleInfo << ElementResolve(type, -1) << " with molten "_i18n << ElementResolve(pavg1int, -1);
} }
else else
{ {
sampleInfo << ElementResolve(type, -1) << " with " << ElementResolve(ctype, pavg1int); sampleInfo << ElementResolve(type, -1) << " with "_i18n << ElementResolve(ctype, pavg1int);
} }
} }
else else

View File

@ -104,7 +104,7 @@ void Task::before()
bool Task::doWork() bool Task::doWork()
{ {
notifyStatus("Fake progress"); notifyStatus("Fake progress"_ascii);
for(int i = 0; i < 100; i++) for(int i = 0; i < 100; i++)
{ {
notifyProgress(i); notifyProgress(i);

View File

@ -18,7 +18,7 @@ TaskWindow::TaskWindow(String title_, Task * task_, bool closeOnDone):
progress(0), progress(0),
done(false), done(false),
closeOnDone(closeOnDone), closeOnDone(closeOnDone),
progressStatus("0%") progressStatus("0%"_ascii)
{ {
ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title); ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 15), title);
@ -27,7 +27,7 @@ TaskWindow::TaskWindow(String title_, Task * task_, bool closeOnDone):
tempLabel->SetTextColour(style::Colour::WarningTitle); tempLabel->SetTextColour(style::Colour::WarningTitle);
AddComponent(tempLabel); AddComponent(tempLabel);
statusLabel = new ui::Label(ui::Point(4, 23), ui::Point(Size.X-8, 15), ""); statusLabel = new ui::Label(ui::Point(4, 23), ui::Point(Size.X-8, 15), ""_ascii);
statusLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; statusLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
statusLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; statusLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(statusLabel); AddComponent(statusLabel);
@ -45,7 +45,7 @@ void TaskWindow::NotifyStatus(Task * task)
void TaskWindow::NotifyError(Task * task) void TaskWindow::NotifyError(Task * task)
{ {
new ErrorMessage("Error", task->GetError()); new ErrorMessage("Error"_i18n, task->GetError());
done = true; done = true;
} }
@ -68,9 +68,9 @@ void TaskWindow::NotifyProgress(Task * task)
{ {
progress = task->GetProgress(); progress = task->GetProgress();
if(progress>-1) if(progress>-1)
progressStatus = String::Build(progress, "%"); progressStatus = String::Build(progress, '%');
else else
progressStatus = "Please wait..."; progressStatus = "Please wait..."_i18n;
} }
void TaskWindow::OnTick(float dt) void TaskWindow::OnTick(float dt)