Refactor more stuff

This commit is contained in:
mniip 2020-03-24 14:20:02 +03:00
parent 18cd57006b
commit a16a4936a5
5 changed files with 273 additions and 267 deletions

View File

@ -58,7 +58,7 @@ extern "C"
Client::Client():
messageOfTheDay("Fetching the message of the day..."),
messageOfTheDay("Fetching the message of the day..."_i18n),
versionCheckRequest(nullptr),
alternateVersionCheckRequest(nullptr),
usingAltUpdateServer(false),
@ -648,7 +648,7 @@ std::vector<std::pair<String, ByteString> > Client::GetServerNotifications()
RequestStatus Client::ParseServerReturn(ByteString &result, int status, bool json)
{
lastError = "";
lastError = ""_ascii;
// no server response, return "Malformed Response"
if (status == 200 && !result.size())
{
@ -658,7 +658,8 @@ RequestStatus Client::ParseServerReturn(ByteString &result, int status, bool jso
return RequestOkay;
if (status != 200)
{
lastError = String::Build("HTTP Error ", status, ": ", http::StatusText(status));
auto errMsg = i18nMulti("HTTP Error ", ": ");
lastError = String::Build(errMsg[0], status, errMsg[1], http::StatusText(status));
return RequestFailure;
}
@ -687,11 +688,12 @@ RequestStatus Client::ParseServerReturn(ByteString &result, int status, bool jso
// sometimes the server returns a 200 with the text "Error: 401"
if (!strncmp(result.c_str(), "Error: ", 7))
{
auto errMsg = i18nMulti("HTTP Error ", ": ");
status = ByteString(result.begin() + 7, result.end()).ToNumber<int>();
lastError = String::Build("HTTP Error ", status, ": ", http::StatusText(status));
lastError = String::Build(errMsg[0], status, errMsg[1], http::StatusText(status));
return RequestFailure;
}
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
return RequestFailure;
}
}
@ -732,7 +734,10 @@ bool Client::CheckUpdate(http::Request *updateRequest, bool checkSession)
{
//free(data);
if (usingAltUpdateServer && !checkSession)
this->messageOfTheDay = String::Build("HTTP Error ", status, " while checking for updates: ", http::StatusText(status));
{
auto errMsg = i18nMulti("HTTP Error ", " while checking for updates: ");
this->messageOfTheDay = String::Build(errMsg[0], status, errMsg[1], http::StatusText(status));
}
}
else if(data.size())
{
@ -952,7 +957,7 @@ User Client::GetAuthUser()
RequestStatus Client::UploadSave(SaveInfo & save)
{
lastError = "";
lastError = ""_ascii;
unsigned int gameDataLength;
char * gameData = NULL;
int dataStatus;
@ -962,7 +967,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
{
if (!save.GetGameSave())
{
lastError = "Empty game save";
lastError = "Empty game save"_i18n;
return RequestFailure;
}
@ -972,13 +977,13 @@ RequestStatus Client::UploadSave(SaveInfo & save)
if (!gameData)
{
lastError = "Cannot serialize game save";
lastError = "Cannot serialize game save"_i18n;
return RequestFailure;
}
#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG)
else if (save.gameSave->fromNewerVersion)
{
lastError = "Cannot upload save, incompatible with latest release version";
lastError = "Cannot upload save, incompatible with latest release version"_i18n;
return RequestFailure;
}
#endif
@ -992,7 +997,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
@ -1002,7 +1007,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
int saveID = ByteString(data.begin() + 3, data.end()).ToNumber<int>();
if (!saveID)
{
lastError = "Server did not return Save ID";
lastError = "Server did not return Save ID"_i18n;
ret = RequestFailure;
}
else
@ -1161,7 +1166,7 @@ std::vector<ByteString> Client::GetStamps(int start, int count)
RequestStatus Client::ExecVote(int saveID, int direction)
{
lastError = "";
lastError = ""_ascii;
int dataStatus;
ByteString data;
@ -1176,7 +1181,7 @@ RequestStatus Client::ExecVote(int saveID, int direction)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, false);
@ -1185,7 +1190,7 @@ RequestStatus Client::ExecVote(int saveID, int direction)
std::vector<unsigned char> Client::GetSaveData(int saveID, int saveDate)
{
lastError = "";
lastError = ""_ascii;
int dataStatus;
ByteString data;
ByteString urlStr;
@ -1207,7 +1212,7 @@ std::vector<unsigned char> Client::GetSaveData(int saveID, int saveDate)
LoginStatus Client::Login(ByteString username, ByteString password, User & user)
{
lastError = "";
lastError = ""_ascii;
char passwordHash[33];
char totalHash[33];
@ -1269,7 +1274,7 @@ LoginStatus Client::Login(ByteString username, ByteString password, User & user)
}
catch (std::exception &e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
return LoginError;
}
}
@ -1278,7 +1283,7 @@ LoginStatus Client::Login(ByteString username, ByteString password, User & user)
RequestStatus Client::DeleteSave(int saveID)
{
lastError = "";
lastError = ""_ascii;
ByteString data;
ByteString url = ByteString::Build(SCHEME, SERVER, "/Browse/Delete.json?ID=", saveID, "&Mode=Delete&Key=", authUser.SessionKey);
int dataStatus;
@ -1289,7 +1294,7 @@ RequestStatus Client::DeleteSave(int saveID)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1298,7 +1303,7 @@ RequestStatus Client::DeleteSave(int saveID)
RequestStatus Client::AddComment(int saveID, String comment)
{
lastError = "";
lastError = ""_ascii;
ByteString data;
int dataStatus;
ByteString url = ByteString::Build(SCHEME, SERVER, "/Browse/Comments.json?ID=", saveID);
@ -1311,7 +1316,7 @@ RequestStatus Client::AddComment(int saveID, String comment)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1320,7 +1325,7 @@ RequestStatus Client::AddComment(int saveID, String comment)
RequestStatus Client::FavouriteSave(int saveID, bool favourite)
{
lastError = "";
lastError = ""_ascii;
ByteStringBuilder urlStream;
ByteString data;
int dataStatus;
@ -1334,7 +1339,7 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1343,7 +1348,7 @@ RequestStatus Client::FavouriteSave(int saveID, bool favourite)
RequestStatus Client::ReportSave(int saveID, String message)
{
lastError = "";
lastError = ""_ascii;
ByteString data;
int dataStatus;
ByteString url = ByteString::Build(SCHEME, SERVER, "/Browse/Report.json?ID=", saveID, "&Key=", authUser.SessionKey);
@ -1356,7 +1361,7 @@ RequestStatus Client::ReportSave(int saveID, String message)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1365,7 +1370,7 @@ RequestStatus Client::ReportSave(int saveID, String message)
RequestStatus Client::UnpublishSave(int saveID)
{
lastError = "";
lastError = ""_ascii;
ByteString data;
int dataStatus;
ByteString url = ByteString::Build(SCHEME, SERVER, "/Browse/Delete.json?ID=", saveID, "&Mode=Unpublish&Key=", authUser.SessionKey);
@ -1376,7 +1381,7 @@ RequestStatus Client::UnpublishSave(int saveID)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1385,7 +1390,7 @@ RequestStatus Client::UnpublishSave(int saveID)
RequestStatus Client::PublishSave(int saveID)
{
lastError = "";
lastError = ""_ascii;
ByteString data;
int dataStatus;
ByteString url = ByteString::Build(SCHEME, SERVER, "/Browse/View.json?ID=", saveID, "&Key=", authUser.SessionKey);
@ -1398,7 +1403,7 @@ RequestStatus Client::PublishSave(int saveID)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return RequestFailure;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1407,7 +1412,7 @@ RequestStatus Client::PublishSave(int saveID)
SaveInfo * Client::GetSave(int saveID, int saveDate)
{
lastError = "";
lastError = ""_ascii;
ByteStringBuilder urlStream;
urlStream << SCHEME << SERVER << "/Browse/View.json?ID=" << saveID;
if(saveDate)
@ -1465,7 +1470,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
}
catch (std::exception & e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
return NULL;
}
}
@ -1496,7 +1501,7 @@ SaveFile * Client::LoadSaveFile(ByteString filename)
std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count, String query, int & resultCount)
{
lastError = "";
lastError = ""_ascii;
resultCount = 0;
std::vector<std::pair<ByteString, int> > * tagArray = new std::vector<std::pair<ByteString, int> >();
ByteStringBuilder urlStream;
@ -1530,7 +1535,7 @@ std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count,
}
catch (std::exception & e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
}
}
else
@ -1542,7 +1547,7 @@ std::vector<std::pair<ByteString, int> > * Client::GetTags(int start, int count,
std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, String query, ByteString sort, ByteString category, int & resultCount)
{
lastError = "";
lastError = ""_ascii;
resultCount = 0;
std::vector<SaveInfo*> * saveArray = new std::vector<SaveInfo*>();
ByteStringBuilder urlStream;
@ -1604,7 +1609,7 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, String query,
}
catch (std::exception &e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
}
}
return saveArray;
@ -1612,7 +1617,7 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, String query,
std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
{
lastError = "";
lastError = ""_ascii;
std::list<ByteString> * tags = NULL;
ByteString data;
int dataStatus;
@ -1624,7 +1629,7 @@ std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return NULL;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1643,7 +1648,7 @@ std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
}
catch (std::exception &e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
}
}
return tags;
@ -1651,7 +1656,7 @@ std::list<ByteString> * Client::RemoveTag(int saveID, ByteString tag)
std::list<ByteString> * Client::AddTag(int saveID, ByteString tag)
{
lastError = "";
lastError = ""_ascii;
std::list<ByteString> * tags = NULL;
ByteString data;
int dataStatus;
@ -1663,7 +1668,7 @@ std::list<ByteString> * Client::AddTag(int saveID, ByteString tag)
}
else
{
lastError = "Not authenticated";
lastError = "Not authenticated"_i18n;
return NULL;
}
RequestStatus ret = ParseServerReturn(data, dataStatus, true);
@ -1682,7 +1687,7 @@ std::list<ByteString> * Client::AddTag(int saveID, ByteString tag)
}
catch (std::exception & e)
{
lastError = "Could not read response: " + ByteString(e.what()).FromUtf8();
lastError = "Could not read response: "_i18n + ByteString(e.what()).FromUtf8();
}
}
return tags;

View File

@ -343,86 +343,86 @@ namespace http
{
switch (ret)
{
case 0: return "Status code 0 (bug?)";
case 100: return "Continue";
case 101: return "Switching Protocols";
case 102: return "Processing";
case 200: return "OK";
case 201: return "Created";
case 202: return "Accepted";
case 203: return "Non-Authoritative Information";
case 204: return "No Content";
case 205: return "Reset Content";
case 206: return "Partial Content";
case 207: return "Multi-Status";
case 300: return "Multiple Choices";
case 301: return "Moved Permanently";
case 302: return "Found";
case 303: return "See Other";
case 304: return "Not Modified";
case 305: return "Use Proxy";
case 306: return "Switch Proxy";
case 307: return "Temporary Redirect";
case 400: return "Bad Request";
case 401: return "Unauthorized";
case 402: return "Payment Required";
case 403: return "Forbidden";
case 404: return "Not Found";
case 405: return "Method Not Allowed";
case 406: return "Not Acceptable";
case 407: return "Proxy Authentication Required";
case 408: return "Request Timeout";
case 409: return "Conflict";
case 410: return "Gone";
case 411: return "Length Required";
case 412: return "Precondition Failed";
case 413: return "Request Entity Too Large";
case 414: return "Request URI Too Long";
case 415: return "Unsupported Media Type";
case 416: return "Requested Range Not Satisfiable";
case 417: return "Expectation Failed";
case 418: return "I'm a teapot";
case 422: return "Unprocessable Entity";
case 423: return "Locked";
case 424: return "Failed Dependency";
case 425: return "Unordered Collection";
case 426: return "Upgrade Required";
case 444: return "No Response";
case 450: return "Blocked by Windows Parental Controls";
case 499: return "Client Closed Request";
case 500: return "Internal Server Error";
case 501: return "Not Implemented";
case 502: return "Bad Gateway";
case 503: return "Service Unavailable";
case 504: return "Gateway Timeout";
case 505: return "HTTP Version Not Supported";
case 506: return "Variant Also Negotiates";
case 507: return "Insufficient Storage";
case 509: return "Bandwidth Limit Exceeded";
case 510: return "Not Extended";
case 600: return "Internal Client Error";
case 601: return "Unsupported Protocol";
case 602: return "Server Not Found";
case 603: return "Malformed Response";
case 604: return "Network Not Available";
case 605: return "Request Timed Out";
case 606: return "Malformed URL";
case 607: return "Connection Refused";
case 608: return "Proxy Server Not Found";
case 609: return "SSL: Invalid Certificate Status";
case 610: return "Cancelled by Shutdown";
case 611: return "Too Many Redirects";
case 612: return "SSL: Connect Error";
case 613: return "SSL: Crypto Engine Not Found";
case 614: return "SSL: Failed to Set Default Crypto Engine";
case 615: return "SSL: Local Certificate Issue";
case 616: return "SSL: Unable to Use Specified Cipher";
case 617: return "SSL: Failed to Initialise Crypto Engine";
case 618: return "SSL: Failed to Load CACERT File";
case 619: return "SSL: Failed to Load CRL File";
case 620: return "SSL: Issuer Check Failed";
case 621: return "SSL: Pinned Public Key Mismatch";
default: return "Unknown Status Code";
case 0: return "Status code 0 (bug?)"_i18n;
case 100: return "Continue"_i18n;
case 101: return "Switching Protocols"_i18n;
case 102: return "Processing"_i18n;
case 200: return "OK"_i18n;
case 201: return "Created"_i18n;
case 202: return "Accepted"_i18n;
case 203: return "Non-Authoritative Information"_i18n;
case 204: return "No Content"_i18n;
case 205: return "Reset Content"_i18n;
case 206: return "Partial Content"_i18n;
case 207: return "Multi-Status"_i18n;
case 300: return "Multiple Choices"_i18n;
case 301: return "Moved Permanently"_i18n;
case 302: return "Found"_i18n;
case 303: return "See Other"_i18n;
case 304: return "Not Modified"_i18n;
case 305: return "Use Proxy"_i18n;
case 306: return "Switch Proxy"_i18n;
case 307: return "Temporary Redirect"_i18n;
case 400: return "Bad Request"_i18n;
case 401: return "Unauthorized"_i18n;
case 402: return "Payment Required"_i18n;
case 403: return "Forbidden"_i18n;
case 404: return "Not Found"_i18n;
case 405: return "Method Not Allowed"_i18n;
case 406: return "Not Acceptable"_i18n;
case 407: return "Proxy Authentication Required"_i18n;
case 408: return "Request Timeout"_i18n;
case 409: return "Conflict"_i18n;
case 410: return "Gone"_i18n;
case 411: return "Length Required"_i18n;
case 412: return "Precondition Failed"_i18n;
case 413: return "Request Entity Too Large"_i18n;
case 414: return "Request URI Too Long"_i18n;
case 415: return "Unsupported Media Type"_i18n;
case 416: return "Requested Range Not Satisfiable"_i18n;
case 417: return "Expectation Failed"_i18n;
case 418: return "I'm a teapot"_i18n;
case 422: return "Unprocessable Entity"_i18n;
case 423: return "Locked"_i18n;
case 424: return "Failed Dependency"_i18n;
case 425: return "Unordered Collection"_i18n;
case 426: return "Upgrade Required"_i18n;
case 444: return "No Response"_i18n;
case 450: return "Blocked by Windows Parental Controls"_i18n;
case 499: return "Client Closed Request"_i18n;
case 500: return "Internal Server Error"_i18n;
case 501: return "Not Implemented"_i18n;
case 502: return "Bad Gateway"_i18n;
case 503: return "Service Unavailable"_i18n;
case 504: return "Gateway Timeout"_i18n;
case 505: return "HTTP Version Not Supported"_i18n;
case 506: return "Variant Also Negotiates"_i18n;
case 507: return "Insufficient Storage"_i18n;
case 509: return "Bandwidth Limit Exceeded"_i18n;
case 510: return "Not Extended"_i18n;
case 600: return "Internal Client Error"_i18n;
case 601: return "Unsupported Protocol"_i18n;
case 602: return "Server Not Found"_i18n;
case 603: return "Malformed Response"_i18n;
case 604: return "Network Not Available"_i18n;
case 605: return "Request Timed Out"_i18n;
case 606: return "Malformed URL"_i18n;
case 607: return "Connection Refused"_i18n;
case 608: return "Proxy Server Not Found"_i18n;
case 609: return "SSL: Invalid Certificate Status"_i18n;
case 610: return "Cancelled by Shutdown"_i18n;
case 611: return "Too Many Redirects"_i18n;
case 612: return "SSL: Connect Error"_i18n;
case 613: return "SSL: Crypto Engine Not Found"_i18n;
case 614: return "SSL: Failed to Set Default Crypto Engine"_i18n;
case 615: return "SSL: Local Certificate Issue"_i18n;
case 616: return "SSL: Unable to Use Specified Cipher"_i18n;
case 617: return "SSL: Failed to Initialise Crypto Engine"_i18n;
case 618: return "SSL: Failed to Load CACERT File"_i18n;
case 619: return "SSL: Failed to Load CRL File"_i18n;
case 620: return "SSL: Issuer Check Failed"_i18n;
case 621: return "SSL: Pinned Public Key Mismatch"_i18n;
default: return "Unknown Status Code"_i18n;
}
}
}

View File

@ -28,7 +28,7 @@ OptionsView::OptionsView():
c->Size.X = Size.X - c->Position.X - 12;
};
ui::Label * tempLabel = new ui::Label(ui::Point(4, 1), ui::Point(Size.X-8, 22), "Simulation Options");
ui::Label * tempLabel = new ui::Label(ui::Point(4, 1), ui::Point(Size.X-8, 22), "Simulation Options"_i18n);
tempLabel->SetTextColour(style::Colour::InformationTitle);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -55,48 +55,48 @@ OptionsView::OptionsView():
AddComponent(scrollPanel);
heatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Heat simulation \bgIntroduced in version 34", "");
heatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Heat simulation \bgIntroduced in version 34"_i18n, ""_ascii);
autowidth(heatSimulation);
heatSimulation->SetActionCallback({ [this] { c->SetHeatSimulation(heatSimulation->GetChecked()); } });
scrollPanel->AddChild(heatSimulation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd behaviour when disabled");
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd behaviour when disabled"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
ambientHeatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Ambient heat simulation \bgIntroduced in version 50", "");
ambientHeatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Ambient heat simulation \bgIntroduced in version 50"_i18n, ""_ascii);
autowidth(ambientHeatSimulation);
ambientHeatSimulation->SetActionCallback({ [this] { c->SetAmbientHeatSimulation(ambientHeatSimulation->GetChecked()); } });
scrollPanel->AddChild(ambientHeatSimulation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd / broken behaviour with many saves");
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd / broken behaviour with many saves"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
newtonianGravity = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Newtonian gravity \bgIntroduced in version 48", "");
newtonianGravity = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Newtonian gravity \bgIntroduced in version 48"_i18n, ""_ascii);
autowidth(newtonianGravity);
newtonianGravity->SetActionCallback({ [this] { c->SetNewtonianGravity(newtonianGravity->GetChecked()); } });
scrollPanel->AddChild(newtonianGravity);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance on older computers");
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance on older computers"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
waterEqualisation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Water equalisation \bgIntroduced in version 61", "");
waterEqualisation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Water equalisation \bgIntroduced in version 61"_i18n, ""_ascii);
autowidth(waterEqualisation);
waterEqualisation->SetActionCallback({ [this] { c->SetWaterEqualisation(waterEqualisation->GetChecked()); } });
scrollPanel->AddChild(waterEqualisation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance with a lot of water");
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance with a lot of water"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -105,14 +105,14 @@ OptionsView::OptionsView():
currentY+=19;
airMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(airMode);
airMode->AddOption(std::pair<String, int>("On", 0));
airMode->AddOption(std::pair<String, int>("Pressure off", 1));
airMode->AddOption(std::pair<String, int>("Velocity off", 2));
airMode->AddOption(std::pair<String, int>("Off", 3));
airMode->AddOption(std::pair<String, int>("No Update", 4));
airMode->AddOption({"On"_i18n, 0});
airMode->AddOption({"Pressure off"_i18n, 1});
airMode->AddOption({"Velocity off"_i18n, 2});
airMode->AddOption({"Off"_i18n, 3});
airMode->AddOption({"No Update"_i18n, 4});
airMode->SetActionCallback({ [this] { c->SetAirMode(airMode->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Air Simulation Mode");
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Air Simulation Mode"_i18n);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
@ -120,12 +120,12 @@ OptionsView::OptionsView():
currentY+=20;
gravityMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(gravityMode);
gravityMode->AddOption(std::pair<String, int>("Vertical", 0));
gravityMode->AddOption(std::pair<String, int>("Off", 1));
gravityMode->AddOption(std::pair<String, int>("Radial", 2));
gravityMode->AddOption({"Vertical"_i18n, 0});
gravityMode->AddOption({"Off"_i18n, 1});
gravityMode->AddOption({"Radial"_i18n, 2});
gravityMode->SetActionCallback({ [this] { c->SetGravityMode(gravityMode->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Gravity Simulation Mode");
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Gravity Simulation Mode"_i18n);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
@ -133,12 +133,12 @@ OptionsView::OptionsView():
currentY+=20;
edgeMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(edgeMode);
edgeMode->AddOption(std::pair<String, int>("Void", 0));
edgeMode->AddOption(std::pair<String, int>("Solid", 1));
edgeMode->AddOption(std::pair<String, int>("Loop", 2));
edgeMode->AddOption({"Void"_i18n, 0});
edgeMode->AddOption({"Solid"_i18n, 1});
edgeMode->AddOption({"Loop"_i18n, 2});
edgeMode->SetActionCallback({ [this] { c->SetEdgeMode(edgeMode->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Edge Mode");
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Edge Mode"_i18n);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
@ -157,26 +157,26 @@ OptionsView::OptionsView():
{
if (current_scale == ix_scale)
current_scale_valid = true;
scale->AddOption(std::pair<String, int>(String::Build(ix_scale), ix_scale));
scale->AddOption({String::Build(ix_scale), ix_scale});
ix_scale += 1;
}
while (ui::Engine::Ref().GetMaxWidth() >= ui::Engine::Ref().GetWidth() * ix_scale && ui::Engine::Ref().GetMaxHeight() >= ui::Engine::Ref().GetHeight() * ix_scale);
if (!current_scale_valid)
scale->AddOption(std::pair<String, int>("current", current_scale));
scale->AddOption({"current"_i18n, current_scale});
}
scale->SetActionCallback({ [this] { c->SetScale(scale->GetOption().second); } });
scrollPanel->AddChild(scale);
tempLabel = new ui::Label(ui::Point(scale->Position.X+scale->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Window scale factor for larger screens");
tempLabel = new ui::Label(ui::Point(scale->Position.X+scale->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Window scale factor for larger screens"_i18n);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable", "");
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable"_i18n, ""_ascii);
autowidth(resizable);
resizable->SetActionCallback({ [this] { c->SetResizable(resizable->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText())+20, currentY), ui::Point(1, 16), "\bg- Allow resizing and maximizing window");
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText())+20, currentY), ui::Point(1, 16), "\bg- Allow resizing and maximizing window"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -184,10 +184,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(resizable);
currentY+=20;
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen", "");
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen"_i18n, ""_ascii);
autowidth(fullscreen);
fullscreen->SetActionCallback({ [this] { c->SetFullscreen(fullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Fill the entire screen");
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Fill the entire screen"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -195,10 +195,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(fullscreen);
currentY+=20;
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution", "");
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution"_i18n, ""_ascii);
autowidth(altFullscreen);
altFullscreen->SetActionCallback({ [this] { c->SetAltFullscreen(altFullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Set optimial screen resolution");
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Set optimial screen resolution"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -206,10 +206,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(altFullscreen);
currentY+=20;
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling", "");
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling"_i18n, ""_ascii);
autowidth(forceIntegerScaling);
forceIntegerScaling->SetActionCallback({ [this] { c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(forceIntegerScaling->GetText())+20, currentY), ui::Point(1, 16), "\bg- Less blurry");
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(forceIntegerScaling->GetText())+20, currentY), ui::Point(1, 16), "\bg- Less blurry"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -217,10 +217,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(forceIntegerScaling);
currentY+=20;
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit", "");
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit"_i18n, ""_ascii);
autowidth(fastquit);
fastquit->SetActionCallback({ [this] { c->SetFastQuit(fastquit->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText())+20, currentY), ui::Point(1, 16), "\bg- Always exit completely when hitting close");
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText())+20, currentY), ui::Point(1, 16), "\bg- Always exit completely when hitting close"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -228,10 +228,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(fastquit);
currentY+=20;
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars", "");
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars"_i18n, ""_ascii);
autowidth(showAvatars);
showAvatars->SetActionCallback({ [this] { c->SetShowAvatars(showAvatars->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText())+20, currentY), ui::Point(1, 16), "\bg- Disable if you have a slow connection");
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText())+20, currentY), ui::Point(1, 16), "\bg- Disable if you have a slow connection"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -239,10 +239,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(showAvatars);
currentY+=20;
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories"_i18n, ""_ascii);
autowidth(mouseClickRequired);
mouseClickRequired->SetActionCallback({ [this] { c->SetMouseClickrequired(mouseClickRequired->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::textwidth(mouseClickRequired->GetText())+20, currentY), ui::Point(1, 16), "\bg- Switch between categories by clicking");
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::textwidth(mouseClickRequired->GetText())+20, currentY), ui::Point(1, 16), "\bg- Switch between categories by clicking"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -250,10 +250,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(mouseClickRequired);
currentY+=20;
includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure", "");
includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure"_i18n, ""_ascii);
autowidth(includePressure);
includePressure->SetActionCallback({ [this] { c->SetIncludePressure(includePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::textwidth(includePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc.");
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::textwidth(includePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc."_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -261,10 +261,10 @@ OptionsView::OptionsView():
scrollPanel->AddChild(includePressure);
currentY+=20;
perfectCirclePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle", "");
perfectCirclePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle"_i18n, ""_ascii);
autowidth(perfectCirclePressure);
perfectCirclePressure->SetActionCallback({ [this] { c->SetPerfectCircle(perfectCirclePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(perfectCirclePressure->Position.X+Graphics::textwidth(perfectCirclePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges");
tempLabel = new ui::Label(ui::Point(perfectCirclePressure->Position.X+Graphics::textwidth(perfectCirclePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@ -277,18 +277,18 @@ OptionsView::OptionsView():
decoSpace = new ui::DropDown(ui::Point(8, currentY), ui::Point(60, 16));
decoSpace->SetActionCallback({ [this] { c->SetDecoSpace(decoSpace->GetOption().second); } });
scrollPanel->AddChild(decoSpace);
decoSpace->AddOption(std::pair<String, int>("sRGB", 0));
decoSpace->AddOption(std::pair<String, int>("Linear", 1));
decoSpace->AddOption(std::pair<String, int>("Gamma 2.2", 2));
decoSpace->AddOption(std::pair<String, int>("Gamma 1.8", 3));
decoSpace->AddOption({"sRGB"_i18n, 0});
decoSpace->AddOption({"Linear"_i18n, 1});
decoSpace->AddOption({"Gamma 2.2"_i18n, 2});
decoSpace->AddOption({"Gamma 1.8"_i18n, 3});
tempLabel = new ui::Label(ui::Point(decoSpace->Position.X+decoSpace->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Colour space used by decoration tools");
tempLabel = new ui::Label(ui::Point(decoSpace->Position.X+decoSpace->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Colour space used by decoration tools"_i18n);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, currentY), ui::Point(90, 16), "Open Data Folder");
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, currentY), ui::Point(90, 16), "Open Data Folder"_i18n);
dataFolderButton->SetActionCallback({ [] {
//one of these should always be defined
#ifdef WIN
@ -306,13 +306,13 @@ OptionsView::OptionsView():
} });
scrollPanel->AddChild(dataFolderButton);
tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, currentY), ui::Point(1, 16), "\bg- Open the data and preferences folder");
tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, currentY), ui::Point(1, 16), "\bg- Open the data and preferences folder"_i18n);
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
ui::Button * tempButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
ui::Button * tempButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK"_i18n);
tempButton->SetActionCallback({ [this] { c->Exit(); } });
AddComponent(tempButton);
SetCancelButton(tempButton);

View File

@ -40,7 +40,7 @@ PreviewView::PreviewView():
userIsAuthor(false),
doOpen(false),
doError(false),
doErrorMessage(""),
doErrorMessage(""_ascii),
showAvatars(true),
prevPage(false),
commentBoxHeight(20),
@ -59,7 +59,7 @@ PreviewView::PreviewView():
{
showAvatars = Client::Ref().GetPrefBool("ShowAvatars", true);
favButton = new ui::Button(ui::Point(50, Size.Y-19), ui::Point(51, 19), "Fav");
favButton = new ui::Button(ui::Point(50, Size.Y-19), ui::Point(51, 19), "Fav"_i18n);
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
favButton->SetIcon(IconFavourite);
@ -67,26 +67,26 @@ PreviewView::PreviewView():
favButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false;
AddComponent(favButton);
reportButton = new ui::Button(ui::Point(100, Size.Y-19), ui::Point(51, 19), "Report");
reportButton = new ui::Button(ui::Point(100, Size.Y-19), ui::Point(51, 19), "Report"_i18n);
reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
reportButton->SetIcon(IconReport);
reportButton->SetActionCallback({ [this] {
new TextPrompt("Report Save", "Things to consider when reporting:\n\bw1)\bg When reporting stolen saves, please include the ID of the original save.\n\bw2)\bg Do not ask for saves to be removed from front page unless they break the rules.\n\bw3)\bg You may report saves for comments or tags too (including your own saves)", "", "[reason]", true, { [this](String const &resultText) {
new TextPrompt("Report Save"_i18n, "Things to consider when reporting:\n\bw1)\bg When reporting stolen saves, please include the ID of the original save.\n\bw2)\bg Do not ask for saves to be removed from front page unless they break the rules.\n\bw3)\bg You may report saves for comments or tags too (including your own saves)"_i18n, ""_ascii, "[reason]"_i18n, true, { [this](String const &resultText) {
c->Report(resultText);
} });
} });
reportButton->Enabled = Client::Ref().GetAuthUser().UserID?true:false;
AddComponent(reportButton);
openButton = new ui::Button(ui::Point(0, Size.Y-19), ui::Point(51, 19), "Open");
openButton = new ui::Button(ui::Point(0, Size.Y-19), ui::Point(51, 19), "Open"_i18n);
openButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
openButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
openButton->SetIcon(IconOpen);
openButton->SetActionCallback({ [this] { c->DoOpen(); } });
AddComponent(openButton);
browserOpenButton = new ui::Button(ui::Point((XRES/2)-107, Size.Y-19), ui::Point(108, 19), "Open in browser");
browserOpenButton = new ui::Button(ui::Point((XRES/2)-107, Size.Y-19), ui::Point(108, 19), "Open in browser"_i18n);
browserOpenButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
browserOpenButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
browserOpenButton->SetIcon(IconOpen);
@ -94,17 +94,17 @@ PreviewView::PreviewView():
AddComponent(browserOpenButton);
if(showAvatars)
saveNameLabel = new ui::Label(ui::Point(39, (YRES/2)+4), ui::Point(100, 16), "");
saveNameLabel = new ui::Label(ui::Point(39, (YRES/2)+4), ui::Point(100, 16), ""_ascii);
else
saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+4), ui::Point(100, 16), "");
saveNameLabel = new ui::Label(ui::Point(5, (YRES/2)+4), ui::Point(100, 16), ""_ascii);
saveNameLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
saveNameLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(saveNameLabel);
if(showAvatars)
saveDescriptionLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15+21), ui::Point((XRES/2)-10, Size.Y-((YRES/2)+4+15+17)-25), "");
saveDescriptionLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15+21), ui::Point((XRES/2)-10, Size.Y-((YRES/2)+4+15+17)-25), ""_ascii);
else
saveDescriptionLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15+19), ui::Point((XRES/2)-10, Size.Y-((YRES/2)+4+15+17)-23), "");
saveDescriptionLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15+19), ui::Point((XRES/2)-10, Size.Y-((YRES/2)+4+15+17)-23), ""_ascii);
saveDescriptionLabel->SetMultiline(true);
saveDescriptionLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
saveDescriptionLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
@ -112,9 +112,9 @@ PreviewView::PreviewView():
AddComponent(saveDescriptionLabel);
if(showAvatars)
authorDateLabel = new ui::Label(ui::Point(39, (YRES/2)+4+15), ui::Point(180, 16), "");
authorDateLabel = new ui::Label(ui::Point(39, (YRES/2)+4+15), ui::Point(180, 16), ""_ascii);
else
authorDateLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15), ui::Point(200, 16), "");
authorDateLabel = new ui::Label(ui::Point(5, (YRES/2)+4+15), ui::Point(200, 16), ""_ascii);
authorDateLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(authorDateLabel);
@ -131,12 +131,12 @@ PreviewView::PreviewView():
AddComponent(avatarButton);
}
viewsLabel = new ui::Label(ui::Point((XRES/2)-80, (YRES/2)+4+15), ui::Point(80, 16), "");
viewsLabel = new ui::Label(ui::Point((XRES/2)-80, (YRES/2)+4+15), ui::Point(80, 16), ""_ascii);
viewsLabel->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
viewsLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(viewsLabel);
pageInfo = new ui::Label(ui::Point((XRES/2) + 85, Size.Y+1), ui::Point(70, 16), "Page 1 of 1");
pageInfo = new ui::Label(ui::Point((XRES/2) + 85, Size.Y+1), ui::Point(70, 16), ""_ascii);
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(pageInfo);
@ -148,14 +148,14 @@ void PreviewView::AttachController(PreviewController * controller)
{
c = controller;
int textWidth = Graphics::textwidth("Click the box below to copy the save ID");
saveIDLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, Size.Y+5), ui::Point(textWidth+20, 16), "Click the box below to copy the save ID");
int textWidth = Graphics::textwidth("Click the box below to copy the save ID"_i18n);
saveIDLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, Size.Y+5), ui::Point(textWidth+20, 16), "Click the box below to copy the save ID"_i18n);
saveIDLabel->SetTextColour(ui::Colour(150, 150, 150));
saveIDLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(saveIDLabel);
textWidth = Graphics::textwidth(String::Build(c->SaveID()));
saveIDLabel2 = new ui::Label(ui::Point((Size.X-textWidth-20)/2-37, Size.Y+22), ui::Point(40, 16), "Save ID:");
saveIDLabel2 = new ui::Label(ui::Point((Size.X-textWidth-20)/2-37, Size.Y+22), ui::Point(40, 16), "Save ID:"_i18n);
AddComponent(saveIDLabel2);
saveIDButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, Size.Y+20), ui::Point(textWidth+10, 18), String::Build(c->SaveID()), saveIDLabel);
@ -223,20 +223,20 @@ void PreviewView::CheckComment()
if (!commentWarningLabel)
return;
String text = addCommentBox->GetText().ToLower();
if (!userIsAuthor && (text.Contains("stolen") || text.Contains("copied")))
if (!userIsAuthor && (text.Contains("stolen"_ascii) || text.Contains("copied"_ascii)))
{
if (!commentHelpText)
{
if (random_gen()%2)
commentWarningLabel->SetText("Stolen? Report the save instead");
commentWarningLabel->SetText("Stolen? Report the save instead"_i18n);
else
commentWarningLabel->SetText("Please report stolen saves");
commentWarningLabel->SetText("Please report stolen saves"_i18n);
commentHelpText = true;
}
}
else if (userIsAuthor && text.Contains("vote"))
else if (userIsAuthor && text.Contains("vote"_ascii))
{
commentWarningLabel->SetText("Do not ask for votes");
commentWarningLabel->SetText("Do not ask for votes"_i18n);
commentHelpText = true;
}
else if (CheckSwearing(text))
@ -244,9 +244,9 @@ void PreviewView::CheckComment()
if (!commentHelpText)
{
if (random_gen()%2)
commentWarningLabel->SetText("Please do not swear");
commentWarningLabel->SetText("Please do not swear"_i18n);
else
commentWarningLabel->SetText("Bad language may be deleted");
commentWarningLabel->SetText("Bad language may be deleted"_i18n);
commentHelpText = true;
}
}
@ -276,7 +276,7 @@ void PreviewView::DoDraw()
{
g->fillrect(Position.X+(Size.X/2)-101, Position.Y+(Size.Y/2)-26, 202, 52, 0, 0, 0, 210);
g->drawrect(Position.X+(Size.X/2)-100, Position.Y+(Size.Y/2)-25, 200, 50, 255, 255, 255, 180);
g->drawtext(Position.X+(Size.X/2)-(Graphics::textwidth("Loading save...")/2), Position.Y+(Size.Y/2)-5, "Loading save...", style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255);
g->drawtext(Position.X+(Size.X/2)-(Graphics::textwidth("Loading save..."_i18n)/2), Position.Y+(Size.Y/2)-5, "Loading save..."_i18n, style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255);
}
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
@ -375,7 +375,7 @@ void PreviewView::OnTick(float dt)
c->Update();
if (doError)
{
ErrorMessage::Blocking("Error loading save", doErrorMessage);
ErrorMessage::Blocking("Error loading save"_i18n, doErrorMessage);
c->Exit();
}
}
@ -432,37 +432,37 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
saveNameLabel->SetText(save->name);
String dateType;
if (save->updatedDate == save->createdDate)
dateType = "Created:";
dateType = "Created:"_i18n;
else
dateType = "Updated:";
dateType = "Updated:"_i18n;
if (showAvatars)
{
avatarButton->SetUsername(save->userName);
authorDateLabel->SetText("\bw" + save->userName.FromUtf8() + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate).FromAscii());
authorDateLabel->SetText("\bw"_ascii + save->userName.FromUtf8() + " \bg"_ascii + dateType + " \bw"_ascii + format::UnixtimeToDateMini(save->updatedDate).FromAscii());
}
else
{
authorDateLabel->SetText("\bgAuthor:\bw " + save->userName.FromUtf8() + " \bg" + dateType + " \bw" + format::UnixtimeToDateMini(save->updatedDate).FromAscii());
authorDateLabel->SetText("\bgAuthor:\bw "_i18n + save->userName.FromUtf8() + " \bg"_ascii + dateType + " \bw"_ascii + format::UnixtimeToDateMini(save->updatedDate).FromAscii());
}
if (Client::Ref().GetAuthUser().UserID && save->userName == Client::Ref().GetAuthUser().Username)
userIsAuthor = true;
else
userIsAuthor = false;
viewsLabel->SetText(String::Build("\bgViews:\bw ", save->Views));
viewsLabel->SetText(String::Build("\bgViews:\bw "_i18n, save->Views));
saveDescriptionLabel->SetText(save->Description);
if(save->Favourite)
{
favButton->Enabled = true;
favButton->SetText("Unfav");
favButton->SetText("Unfav"_i18n);
}
else if(Client::Ref().GetAuthUser().UserID)
{
favButton->Enabled = true;
favButton->SetText("Fav");
favButton->SetText("Fav"_i18n);
}
else
{
favButton->SetText("Fav");
favButton->SetText("Fav"_i18n);
favButton->Enabled = false;
}
@ -490,9 +490,9 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
{
votesUp = 0;
votesDown = 0;
saveNameLabel->SetText("");
authorDateLabel->SetText("");
saveDescriptionLabel->SetText("");
saveNameLabel->SetText(""_ascii);
authorDateLabel->SetText(""_ascii);
saveDescriptionLabel->SetText(""_ascii);
favButton->Enabled = false;
if (!sender->GetCanOpen())
openButton->Enabled = false;
@ -505,14 +505,14 @@ void PreviewView::submitComment()
{
String comment = addCommentBox->GetText();
submitCommentButton->Enabled = false;
addCommentBox->SetText("");
addCommentBox->SetPlaceholder("Submitting comment"); //This doesn't appear to ever show since no separate thread is created
addCommentBox->SetText(""_ascii);
addCommentBox->SetPlaceholder("Submitting comment"_i18n); //This doesn't appear to ever show since no separate thread is created
FocusComponent(NULL);
if (!c->SubmitComment(comment))
addCommentBox->SetText(comment);
addCommentBox->SetPlaceholder("Add comment");
addCommentBox->SetPlaceholder("Add comment"_i18n);
submitCommentButton->Enabled = true;
commentBoxAutoHeight();
@ -540,7 +540,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
commentBoxSizeX = Size.X-(XRES/2)-48;
commentBoxSizeY = 17;
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), "", "Add Comment");
addCommentBox = new ui::Textbox(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 17), ""_ascii, "Add Comment"_i18n);
addCommentBox->SetActionCallback({ [this] {
CheckComment();
commentBoxAutoHeight();
@ -548,12 +548,12 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
addCommentBox->SetMultiline(true);
AddComponent(addCommentBox);
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit");
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit"_i18n);
submitCommentButton->SetActionCallback({ [this] { submitComment(); } });
//submitCommentButton->Enabled = false;
AddComponent(submitCommentButton);
commentWarningLabel = new ui::Label(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 16), "If you see this it is a bug");
commentWarningLabel = new ui::Label(ui::Point((XRES/2)+4, Size.Y-19), ui::Point(Size.X-(XRES/2)-48, 16), "If you see this it is a bug"_i18n);
commentWarningLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
commentWarningLabel->SetTextColour(ui::Colour(255, 0, 0));
commentWarningLabel->Visible = false;
@ -561,7 +561,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
}
else
{
submitCommentButton = new ui::Button(ui::Point(XRES/2, Size.Y-19), ui::Point(Size.X-(XRES/2), 19), "Login to comment");
submitCommentButton = new ui::Button(ui::Point(XRES/2, Size.Y-19), ui::Point(Size.X-(XRES/2), 19), "Login to comment"_i18n);
submitCommentButton->SetActionCallback({ [this] { c->ShowLogin(); } });
AddComponent(submitCommentButton);
}
@ -575,7 +575,8 @@ void PreviewView::SaveLoadingError(String errorMessage)
void PreviewView::NotifyCommentsPageChanged(PreviewModel * sender)
{
pageInfo->SetText(String::Build("Page ", sender->GetCommentsPageNum(), " of ", sender->GetCommentsPageCount()));
auto pageOf = i18nMulti("Page ", " of ");
pageInfo->SetText(String::Build(pageOf[0], sender->GetCommentsPageNum(), pageOf[1], sender->GetCommentsPageCount()));
}
void PreviewView::NotifyCommentsChanged(PreviewModel * sender)

View File

@ -26,7 +26,7 @@ TPTScriptInterface::TPTScriptInterface(GameController * c, GameModel * m): Comma
int TPTScriptInterface::Command(String command)
{
lastError = "";
lastError = ""_ascii;
std::deque<String> words;
std::deque<AnyType> commandWords;
int retCode = -1;
@ -62,21 +62,21 @@ ValueType TPTScriptInterface::testType(String word)
size_t i = 0;
String::value_type const *rawWord = word.c_str();
//Function
if (word == "set")
if (word == "set"_ascii)
return TypeFunction;
else if (word == "create")
else if (word == "create"_ascii)
return TypeFunction;
else if (word == "delete")
else if (word == "delete"_ascii)
return TypeFunction;
else if (word == "kill")
else if (word == "kill"_ascii)
return TypeFunction;
else if (word == "load")
else if (word == "load"_ascii)
return TypeFunction;
else if (word == "reset")
else if (word == "reset"_ascii)
return TypeFunction;
else if (word == "bubble")
else if (word == "bubble"_ascii)
return TypeFunction;
else if (word == "quit")
else if (word == "quit"_ascii)
return TypeFunction;
//Basic type
@ -181,19 +181,19 @@ AnyType TPTScriptInterface::eval(std::deque<String> * words)
switch(wordType)
{
case TypeFunction:
if(word == "set")
if(word == "set"_ascii)
return tptS_set(words);
else if(word == "create")
else if(word == "create"_ascii)
return tptS_create(words);
else if(word == "delete" || word == "kill")
else if(word == "delete"_ascii || word == "kill"_ascii)
return tptS_delete(words);
else if(word == "load")
else if(word == "load"_ascii)
return tptS_load(words);
else if(word == "reset")
else if(word == "reset"_ascii)
return tptS_reset(words);
else if(word == "bubble")
else if(word == "bubble"_ascii)
return tptS_bubble(words);
else if(word == "quit")
else if(word == "quit"_ascii)
return tptS_quit(words);
break;
case TypeNumber:
@ -204,7 +204,7 @@ AnyType TPTScriptInterface::eval(std::deque<String> * words)
{
int x, y;
if(String::Split comma = word.SplitNumber(x))
if(comma.After().BeginsWith(","))
if(comma.After().BeginsWith(","_ascii))
if(comma.After().Substr(1).SplitNumber(y))
return PointType(x, y);
return PointType(0, 0);
@ -232,20 +232,20 @@ String TPTScriptInterface::FormatCommand(String command)
switch(cType)
{
case TypeFunction:
outputData += "\bt";
outputData += "\bt"_ascii;
break;
case TypeNumber:
case TypePoint:
outputData += "\bo";
outputData += "\bo"_ascii;
break;
case TypeString:
outputData += "\bg";
outputData += "\bg"_ascii;
break;
default:
outputData += "\bw";
outputData += "\bw"_ascii;
break;
}
outputData += words.front() + " ";
outputData += words.front() + " "_ascii;
words.pop_front();
}
return outputData;
@ -266,7 +266,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
FormatType propertyFormat;
int propertyOffset = GetPropertyOffset(property.Value().ToUtf8(), propertyFormat);
if (propertyOffset == -1)
throw GeneralException("Invalid property");
throw GeneralException("Invalid property"_i18n);
//Selector
int newValue = 0;
@ -281,7 +281,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
}
else if(value.GetType() == TypeString)
{
if (property.Value() == "temp")
if (property.Value() == "temp"_ascii)
{
String newString = ((StringType)value).Value();
if (newString.at(newString.length()-1) == 'C')
@ -289,7 +289,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
else if (newString.at(newString.length()-1) == 'F')
newValuef = (atof(newString.SubstrFromEnd(1).ToUtf8().c_str())-32.0f)*5/9+273.15f;
else
throw GeneralException("Invalid value for assignment");
throw GeneralException("Invalid value for assignment"_i18n);
}
else
{
@ -298,15 +298,15 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
{
// TODO: add element CAKE to invalidate this
if (!strcasecmp(((StringType)value).Value().ToUtf8().c_str(),"cake"))
throw GeneralException("Cake is a lie, not an element");
throw GeneralException("Invalid element");
throw GeneralException("Cake is a lie, not an element"_i18n);
throw GeneralException("Invalid element"_i18n);
}
}
}
else
throw GeneralException("Invalid value for assignment");
if (property.Value() == "type" && (newValue < 0 || newValue >= PT_NUM || !sim->elements[newValue].Enabled))
throw GeneralException("Invalid element");
throw GeneralException("Invalid value for assignment"_i18n);
if (property.Value() == "type"_ascii && (newValue < 0 || newValue >= PT_NUM || !sim->elements[newValue].Enabled))
throw GeneralException("Invalid element"_i18n);
if (selector.GetType() == TypePoint || selector.GetType() == TypeNumber)
{
@ -315,13 +315,13 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
{
ui::Point tempPoint = ((PointType)selector).Value();
if(tempPoint.X<0 || tempPoint.Y<0 || tempPoint.Y >= YRES || tempPoint.X >= XRES)
throw GeneralException("Invalid position");
throw GeneralException("Invalid position"_i18n);
}
else
partIndex = ((NumberType)selector).Value();
if(partIndex<0 || partIndex>NPART || sim->parts[partIndex].type==0)
throw GeneralException("Invalid particle");
throw GeneralException("Invalid particle"_i18n);
switch(propertyFormat)
{
@ -339,7 +339,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
}
returnValue = 1;
}
else if (selector.GetType() == TypeString && ((StringType)selector).Value() == "all")
else if (selector.GetType() == TypeString && ((StringType)selector).Value() == "all"_ascii)
{
switch(propertyFormat)
{
@ -386,9 +386,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
type = m->GetSimulation()->GetParticleType(((StringType)selector).Value().ToUtf8());
if (type<0 || type>=PT_NUM)
throw GeneralException("Invalid particle type");
throw GeneralException("Invalid particle type"_i18n);
if (type==0)
throw GeneralException("Cannot set properties of particles that do not exist");
throw GeneralException("Cannot set properties of particles that do not exist"_i18n);
switch(propertyFormat)
{
case FormatInt:
@ -426,7 +426,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<String> * words)
}
}
else
throw GeneralException("Invalid selector");
throw GeneralException("Invalid selector"_i18n);
return NumberType(returnValue);
}
@ -444,14 +444,14 @@ AnyType TPTScriptInterface::tptS_create(std::deque<String> * words)
else if(createType.GetType() == TypeString)
type = m->GetSimulation()->GetParticleType(((StringType)createType).Value().ToUtf8());
else
throw GeneralException("Invalid type");
throw GeneralException("Invalid type"_i18n);
if(type == -1)
throw GeneralException("Invalid particle type");
throw GeneralException("Invalid particle type"_i18n);
ui::Point tempPoint = position.Value();
if(tempPoint.X<0 || tempPoint.Y<0 || tempPoint.Y >= YRES || tempPoint.X >= XRES)
throw GeneralException("Invalid position");
throw GeneralException("Invalid position"_i18n);
int v = -1;
if (ID(type))
@ -475,18 +475,18 @@ AnyType TPTScriptInterface::tptS_delete(std::deque<String> * words)
{
ui::Point deletePoint = ((PointType)partRef).Value();
if(deletePoint.X<0 || deletePoint.Y<0 || deletePoint.Y >= YRES || deletePoint.X >= XRES)
throw GeneralException("Invalid position");
throw GeneralException("Invalid position"_i18n);
sim->delete_part(deletePoint.X, deletePoint.Y);
}
else if(partRef.GetType() == TypeNumber)
{
int partIndex = ((NumberType)partRef).Value();
if(partIndex < 0 || partIndex >= NPART)
throw GeneralException("Invalid particle index");
throw GeneralException("Invalid particle index"_i18n);
sim->kill_part(partIndex);
}
else
throw GeneralException("Invalid particle reference");
throw GeneralException("Invalid particle reference"_i18n);
return NumberType(0);
}
@ -502,7 +502,7 @@ AnyType TPTScriptInterface::tptS_load(std::deque<String> * words)
return NumberType(0);
}
else
throw GeneralException("Invalid save ID");
throw GeneralException("Invalid save ID"_i18n);
}
AnyType TPTScriptInterface::tptS_bubble(std::deque<String> * words)
@ -512,7 +512,7 @@ AnyType TPTScriptInterface::tptS_bubble(std::deque<String> * words)
ui::Point bubblePos = bubblePosA.Value();
if(bubblePos.X<0 || bubblePos.Y<0 || bubblePos.Y >= YRES || bubblePos.X >= XRES)
throw GeneralException("Invalid position");
throw GeneralException("Invalid position"_i18n);
Simulation * sim = m->GetSimulation();
@ -548,7 +548,7 @@ AnyType TPTScriptInterface::tptS_reset(std::deque<String> * words)
Simulation * sim = m->GetSimulation();
if (resetStr == "pressure")
if (resetStr == "pressure"_ascii)
{
for (int nx = 0; nx < XRES/CELL; nx++)
for (int ny = 0; ny < YRES/CELL; ny++)
@ -556,7 +556,7 @@ AnyType TPTScriptInterface::tptS_reset(std::deque<String> * words)
sim->air->pv[ny][nx] = 0;
}
}
else if (resetStr == "velocity")
else if (resetStr == "velocity"_ascii)
{
for (int nx = 0; nx < XRES/CELL; nx++)
for (int ny = 0; ny < YRES/CELL; ny++)
@ -565,11 +565,11 @@ AnyType TPTScriptInterface::tptS_reset(std::deque<String> * words)
sim->air->vy[ny][nx] = 0;
}
}
else if (resetStr == "sparks")
else if (resetStr == "sparks"_ascii)
{
c->ResetSpark();
}
else if (resetStr == "temp")
else if (resetStr == "temp"_ascii)
{
for (int i = 0; i < NPART; i++)
{
@ -581,7 +581,7 @@ AnyType TPTScriptInterface::tptS_reset(std::deque<String> * words)
}
else
{
throw GeneralException("Unknown reset command");
throw GeneralException("Unknown reset command"_i18n);
}
return NumberType(0);