Add quote reading to dataFile, add more to translatable strings

This commit is contained in:
J-D-K 2020-05-26 20:40:32 -04:00
parent c6e90bb85a
commit da120ade39
7 changed files with 139 additions and 87 deletions

View File

@ -38,7 +38,7 @@ INCLUDES := inc
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK
APP_VERSION := 05.25.2020
APP_VERSION := 05.26.2020
ROMFS := romfs
ICON := romfs/icon.jpg

View File

@ -37,13 +37,13 @@ namespace ui
//Holds theme set id
extern ColorSetId thmID;
//Both UI modes need access to this
//Both UI modes need access to thi
extern std::string folderMenuInfo;
//Strings since translation support
extern std::string userHelp, titleHelp, folderHelp, optHelp, \
confBlacklist, confOverwrite, confRestore, confDel, confCopy, \
confEraseNand, confEraseFolder, yt, nt, on, off;
confEraseNand, confEraseFolder, yt, nt, on, off, confirmHead;
//Strings for file mode menu
extern std::string advMenuStr[6];
@ -51,6 +51,10 @@ namespace ui
extern std::string exMenuStr[10];
//Strings for options menu
extern std::string optMenuStr[12];
//Strings for options explanations
extern std::string optMenuExp[12];
//Strings for the holding thing
extern std::string holdingText[3];
/*Colors
clearClr = color to clear buffer

View File

@ -1,86 +1,109 @@
#JKSV Switch translation guide
#Button strings [X] are replaced by JKSV at boot.
#string = set string to this.
#Translation author. Displayed in UI. NULL is ignored and not displayed.
author = NULL
author = "NULL"
#Help/Guide strings on bottom
#User Select
userHelp = [A] Select [Y] Dump All [X] UI Mode [-] Options [ZR] Extras
userHelp = "[A] Select [Y] Dump All [X] UI Mode [-] Options [ZR] Extras"
#Title Select
titleHelp = [A] Select [L][R] Change User [Y] Dump All [X] Favorite [-] BlackList [ZR] Erase [B] Back
titleHelp = "[A] Select [L][R] Change User [Y] Dump All [X] Favorite [-] BlackList [ZR] Erase [B] Back"
#Folder Select
folderHelp = [-] File Mode [L][R] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Erase [B] Back
folderHelp = "[-] File Mode [L]/[R]+[A] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Erase [B] Back"
#Options Menu
optHelp = [A] Toggle [B] Back
optHelp = "[A] Toggle [B] Back"
#Button prompts.
yt = Yes [A]
nt = No [B]
yt = "Yes [A]"
nt = "No [B]"
#On/Off for options. '>' is used to change color to green.
on = >On>
off = Off
on = ">On>"
off = "Off"
#Strings for messages/confirmation. '*' and '#' are used in strings to change color. %s is replaced with titles and names with sprintf.
#Text shown at the top of confirmation boxes
confirmHead = "Confirm"
#Strings for messages/confirmation. '*' and '#' are used in strings to change color. %s is replaced with titles and names.
#Confirm blacklist.
confirmBlacklist = Are you sure you want to add #%s# to your blacklist?
confirmBlacklist = "Are you sure you want to add #%s# to your blacklist?"
#Confirm overwriting folder
confirmOverwrite = Are you sure you want to overwrite #%s#?
confirmOverwrite = "Are you sure you want to overwrite #%s#?"
#Confirm restoring save
confirmRestore = Are you sure you want to restore #%s#?
confirmRestore = "Are you sure you want to restore #%s#?"
#Confirm deleting.
confirmDelete = Are you sure you want to delete #%s#? *This is permanent*!
confirmDelete = "Are you sure you want to delete #%s#? *This is permanent*!"
#Confirm file copy in file mode
confirmCopy = Are you sure you want to copy #%s# to #%s#?
confirmCopy = "Are you sure you want to copy #%s# to #%s#?"
#Warning for erasing save data from system in title menu
confirmEraseNand = *WARNING*: This *will* erase the save data for #%s# *from your system*. This is the same as deleting it from #Data Management#! Are you sure you want to continue?
confirmEraseNand = "*WARNING*: This *will* erase the save data for #%s# *from your system*. This is the same as deleting it from #Data Management#! Are you sure you want to continue?"
#Warning for deleting save data in folder menu
confirmEraseFolder = *WARNING*: This *will* delete the current save data for #%s# *from your system*! Are you sure you want to continue?
confirmEraseFolder = "*WARNING*: This *will* delete the current save data for #%s# *from your system*! Are you sure you want to continue?"
#Text displayed when holding is required. Should have a trailing space
holdingText = 0, "(Hold) "
holdingText = 1, "(Keep Holding) "
holdingText = 2, "(Almost There!) "
#Menu options are held in arrays of strings.
#The number is the option to set, string is what to set to.
#Only the string after the comma needs to be edited.
#Adv/file mode menu
#'Copy to ' NEEDS a trailing space
advMenu = 0, Copy to
advMenu = 1, Delete
advMenu = 2, Rename
advMenu = 3, Make Dir
advMenu = 4, Properties
advMenu = 5, Close
advMenu = 0, "Copy to "
advMenu = 1, "Delete"
advMenu = 2, "Rename"
advMenu = 3, "Make Dir"
advMenu = 4, "Properties"
advMenu = 5, "Close"
#Extras Menu
extMenu = 0, SD to SD Browser
extMenu = 1, BIS: PRODINFOF
extMenu = 2, BIS: SAFE
extMenu = 3, BIS: SYSTEM
extMenu = 4, BIS: USER
extMenu = 5, Remove Update
extMenu = 6, Terminate Process
extMenu = 7, Mount System Save
extMenu = 8, Rescan Titles
extMenu = 9, Process RomFS
extMenu = 0, "SD to SD Browser"
extMenu = 1, "BIS: PRODINFOF"
extMenu = 2, "BIS: SAFE"
extMenu = 3, "BIS: SYSTEM"
extMenu = 4, "BIS: USER"
extMenu = 5, "Remove Update"
extMenu = 6, "Terminate Process"
extMenu = 7, "Mount System Save"
extMenu = 8, "Rescan Titles"
extMenu = 9, "Mount Process RomFS"
#Options menu
#This is always last and all need a trailing space. It is the most likely to have things added to it.
optMenu = 0, Include Dev Sv:
optMenu = 1, AutoBackup:
optMenu = 2, Overclock:
optMenu = 3, Hold to Delete:
optMenu = 4, Hold to Restore:
optMenu = 5, Hold to Overwrite:
optMenu = 6, Force Mount:
optMenu = 7, Account Sys. Saves:
optMenu = 8, Write to Sys. Saves:
optMenu = 9, Text UI Mode:
optMenu = 10, Direct FS Cmd:
optMenu = 11, Skip User Select:
#All options need a trailing space. It is the most likely to have things added to it.
optMenu = 0, "Include Dev Sv: "
optMenu = 1, "AutoBackup: "
optMenu = 2, "Overclock: "
optMenu = 3, "Hold to Delete: "
optMenu = 4, "Hold to Restore: "
optMenu = 5, "Hold to Overwrite: "
optMenu = 6, "Force Mount: "
optMenu = 7, "Account Sys. Saves: "
optMenu = 8, "Write to Sys. Saves: "
optMenu = 9, "Text UI Mode: "
optMenu = 10, "Direct FS Cmd: "
optMenu = 11, "Skip User Select: "
#Explanations of what options do.
optMenuExp = 0, "Includes Device Save data in user accounts."
optMenuExp = 1, "Automatically creates a save backup before restoring a save."
optMenuExp = 2, "Applies a small CPU overclock to 1224Mhz at boot. This is the same speed developer units run at."
optMenuExp = 3, "Whether or not holding [A] is required when deleting folders and files."
optMenuExp = 4, "Whether or not holding [A] is required when restoring save data."
optMenuExp = 5, "Whether or not holding [A] is required when overwriting saves on SD."
optMenuExp = 6, "When enabled, JKSV will only load and show save data that can be opened. When disabled, everything found will be shown."
optMenuExp = 7, "When enabled, system save data tied to accounts will be shown."
optMenuExp = 8, "Controls whether system save data and partitions can have files and data written and deleted from them. *This can be extremely dangerous if you don't know what you're doing!*"
optMenuExp = 9, "Changes the UI to be text menu based like the original JKSM for 3DS."
optMenuExp = 10, "Directly uses the Switch's FS commands to copy files instead of stdio."
optMenuExp = 11, "Skips the user selection screen and jumps directly to the first user account found."

View File

@ -340,8 +340,12 @@ bool fs::dataFile::readNextLine(bool proc)
void fs::dataFile::procLine()
{
if((lPos = line.find_first_of('(')) != line.npos || (lPos = line.find_first_of('=')) != line.npos)
name.assign(line.begin(), line.begin() + lPos);
size_t pPos = line.find_first_of('('), ePos = line.find_first_of('=');
if(pPos != line.npos || ePos != line.npos)
{
lPos = ePos < pPos ? ePos : pPos;
name.assign(line.begin(), line.begin() + lPos);
}
else
name = "NULL";
util::stripChar(' ', name);
@ -350,11 +354,16 @@ void fs::dataFile::procLine()
std::string fs::dataFile::getNextValueStr()
{
std::string ret = "";
//Skip all spaces until we hit actual text
size_t pos1 = line.find_first_not_of(' ', lPos);
//Set lPos to end of string we want. This should just set lPos to the end of the line if it fails, which is ok
lPos = line.find_first_of(",;\n", pos1);
return std::string(line.substr(pos1, lPos++));
size_t pos1 = line.find_first_not_of(", ", lPos);
//If reading from quotes
if(line[pos1] == '"')
lPos = line.find_first_of('"', ++pos1);
else
lPos = line.find_first_of(",;\n", pos1);//Set lPos to end of string we want. This should just set lPos to the end of the line if it fails, which is ok
return line.substr(pos1, lPos++ - pos1);
}
int fs::dataFile::getNextValueInt()

View File

@ -10,7 +10,7 @@
#include "util.h"
#include "file.h"
#define VER_STRING "v. 05.25.2020"
#define VER_STRING "v. 05.26.2020"
//text mode
bool ui::textMode = false;
@ -52,7 +52,7 @@ static tex *top, *bot, *usrGuide, *ttlGuide, *fldrGuide, *optGuide;
std::string author = "NULL";
std::string ui::userHelp = "[A] Select [Y] Dump All [X] UI Mode [-] Options [ZR] Extras";
std::string ui::titleHelp = "[A] Select [L][R] Change User [Y] Dump All [X] Favorite [-] BlackList [ZR] Erase [B] Back";
std::string ui::folderHelp = "[-] File Mode [L][R] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Erase [B] Back";
std::string ui::folderHelp = "[-] File Mode [L]/[R]+[A] Auto [A] Backup [Y] Restore [X] Delete Folder [ZR] Erase [B] Back";
std::string ui::optHelp = "[A] Toggle [B] Back";
std::string ui::yt = "Yes [A]", ui::nt = "No [B]";
std::string ui::on = ">On>", ui::off = "Off";
@ -61,11 +61,28 @@ std::string ui::confOverwrite = "Are you sure you want to overwrite #%s#?";
std::string ui::confRestore = "Are you sure you want to restore #%s#?";
std::string ui::confDel = "Are you sure you want to delete #%s#? *This is permanent*!";
std::string ui::confCopy = "Are you sure you want to copy #%s# to #%s#?";
std::string ui::confirmHead = "Confirm";
std::string ui::confEraseNand = "*WARNING*: This *will* erase the save data for #%s# *from your system*. This is the same as deleting it from #Data Management#! Are you sure you want to continue?";
std::string ui::confEraseFolder = "*WARNING*: This *will* delete the current save data for #%s# *from your system*! Are you sure you want to continue?";
std::string ui::advMenuStr[6] = { "Copy to ", "Delete", "Rename", "Make Dir", "Properties", "Close" };
std::string ui::exMenuStr[10] = { "SD to SD Browser", "BIS: PRODINFOF", "BIS: SAFE", "BIS: SYSTEM", "BIS: USER", "Remove Update", "Terminate Process", "Mount System Save", "Rescan Titles", "Mount Process RomFS" };
std::string ui::optMenuStr[12] = { "Include Dev Sv: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Text UI Mode: ", "Direct FS Cmd: ", "Skip User Select: " };
std::string ui::optMenuExp[12] =
{
"Includes Device Save data in user accounts.",
"Automatically creates a save backup before restoring a save.",
"Applies a small CPU over clock to 1224Mhz at boot. This is the same speed developer units run at.",
"Whether or not holding [A] is required when deleting folders and files.",
"Whether or not holding [A] is required when restoring save data.",
"Whether or not holding [A] is required when overwriting saves on SD.",
"When enabled, JKSV will only load and show save data that can be opened. When disabled, everything found will be shown.",
"When enabled, system save data tied to accounts will be shown.",
"Controls whether system save data and partitions can have files and data written and deleted from them. *This can be extremely dangerous if you don't know what you're doing!*",
"Changes the UI to be text menu based like the original JKSM for 3DS.",
"Directly uses the Switch's FS commands to copy files instead of stdio.",
"Skips the user selection screen and jumps directly to the first user account found."
};
std::string ui::holdingText[3] = { "(Hold) ", "(Keep Holding) ", "(Almost there!) " };
//X position of help texts. Calculated to make editing quicker/easier
static unsigned userHelpX, titleHelpX, folderHelpX, optHelpX;
@ -73,8 +90,8 @@ static unsigned userHelpX, titleHelpX, folderHelpX, optHelpX;
static void loadTrans()
{
bool transFile = fs::fileExists(fs::getWorkDir() + "trans.txt");
if(!transFile && data::sysLang == SetLanguage_ENUS)
return;//Don't bother loading from file. It serves as a translation guide
//if(!transFile && data::sysLang == SetLanguage_ENUS)
//return;//Don't bother loading from file. It serves as a translation guide
std::string file;
if(transFile)
@ -127,6 +144,8 @@ static void loadTrans()
ui::confEraseNand = lang.getNextValueStr();
else if(varName == "confirmEraseFolder")
ui::confEraseFolder = lang.getNextValueStr();
else if(varName == "confirmHead")
ui::confirmHead = lang.getNextValueStr();
else if(varName == "advMenu")
{
int ind = lang.getNextValueInt();
@ -142,6 +161,18 @@ static void loadTrans()
int ind = lang.getNextValueInt();
ui::optMenuStr[ind] = lang.getNextValueStr();
}
else if(varName == "optMenuExp")
{
int ind = lang.getNextValueInt();
ui::optMenuExp[ind] = lang.getNextValueStr();
}
else if(varName == "holdingText")
{
int ind = lang.getNextValueInt();
ui::holdingText[ind] = lang.getNextValueStr();
}
else
ui::showMessage("*Translation File Error:*", "*%s* is not a known or valid string name.", varName.c_str());
}
}
@ -221,6 +252,10 @@ void ui::init()
bot = texCreate(1280, 72);
diaBox = texCreate(640, 420);
//Setup dialog box
drawTextbox(diaBox, 0, 0, 640, 420);
drawRect(diaBox, 0, 56, 640, 2, ui::thmID == ColorSetId_Light ? clrCreateU32(0xFF6D6D6D) : clrCreateU32(0xFFCCCCCC));
if(ui::textMode && data::skipUser)
{
ui::textTitlePrep(data::curUser);
@ -231,9 +266,8 @@ void ui::init()
else if(data::skipUser)
mstate = TTL_SEL;
loadTrans();
textUserPrep();
loadTrans();
//Replace the button [x] in strings that need it. Needs to be outside loadTrans so even defaults will get replaced
util::replaceButtonsInString(ui::userHelp);
@ -242,6 +276,9 @@ void ui::init()
util::replaceButtonsInString(ui::optHelp);
util::replaceButtonsInString(ui::yt);
util::replaceButtonsInString(ui::nt);
util::replaceButtonsInString(ui::optMenuExp[3]);
util::replaceButtonsInString(ui::optMenuExp[4]);
util::replaceButtonsInString(ui::optMenuExp[5]);
//Setup top and bottom gfx
texClearColor(top, clearClr);
@ -258,10 +295,6 @@ void ui::init()
//Not needed anymore
texDestroy(icn);
//Setup dialog box
drawTextbox(diaBox, 0, 0, 640, 420);
drawRect(diaBox, 0, 56, 640, 2, ui::thmID == ColorSetId_Light ? clrCreateU32(0xFF6D6D6D) : clrCreateU32(0xFFCCCCCC));
//Create graphics to hold guides
usrGuide = texCreate(textGetWidth(userHelp.c_str(), ui::shared, 18), 28);
ttlGuide = texCreate(textGetWidth(titleHelp.c_str(), ui::shared, 18), 28);

View File

@ -127,11 +127,11 @@ bool ui::confirm(bool hold, const char *fmt, ...)
}
if(holdCount <= 40)
yesText = "(Hold) ";
yesText = ui::holdingText[0];
else if(holdCount <= 80)
yesText = "(Keep Holding) ";
yesText = ui::holdingText[1];
else if(holdCount < 120)
yesText = "(Almost There!) ";
yesText = ui::holdingText[2];
yesText += loadGlyphArray[loadFrame];
yesX = 160 - (textGetWidth(yesText.c_str(), ui::shared, 20) / 2);
@ -166,7 +166,7 @@ bool ui::confirm(bool hold, const char *fmt, ...)
gfxBeginFrame();
texDraw(diaBox, frameBuffer, 320, 150);
drawText("Confirm", frameBuffer, ui::shared, 320 + headX, 168, 20, ui::txtDiag);
drawText(ui::confirmHead.c_str(), frameBuffer, ui::shared, 320 + headX, 168, 20, ui::txtDiag);
drawText(yesText.c_str(), frameBuffer, ui::shared, 320 + yesX, 530, 20, holdClr);
drawText(ui::nt.c_str(), frameBuffer, ui::shared, 860 - noX, 530, 20, ui::txtDiag);
drawTextWrap(tmp, frameBuffer, ui::shared, 352, 230, 16, ui::txtDiag, 576);

View File

@ -12,23 +12,6 @@
static ui::menu userMenu, titleMenu, exMenu, optMenu;
extern ui::menu folderMenu;
//Help text for options
static const std::string optHelpStrings[] =
{
"Includes all Device Save data in Account Saves.",
"Automatically create a backup before restoring a save. Just to be safe.",
"Apply a small overclock to 1224MHz at boot. This is to help the text UI mode run smoothly.",
"Whether or not holding \ue0e0 is required when deleting save folders and files.",
"Whether or not holding \ue0e0 is required when restoring saves to games.",
"Whether or not holding \ue0e0 is required when overwriting save folders.",
"When on, JKSV will only show save data that can be opened. When off, JKSV shows everything.",
"Includes system save data tied to accounts.",
"Controls whether or not system saves can be restored/overwritten. *THIS CAN BE EXTREMELY DANGEROUS*.",
"Changes the UI to a text menu based one like the 3DS version of JKSV.",
"Directly uses the Switch's FS commands to copy files instead of stdio.",
"Skips the user selection screen and jumps straight the first account's titles."
};
static inline void switchBool(bool& sw)
{
sw ? sw = false : sw = true;
@ -436,6 +419,6 @@ void ui::updateOptMenu(const uint64_t& down, const uint64_t& held)
ui::mstate = ui::textMode ? TXT_USR : USR_SEL;
optMenu.draw(ui::txtCont);
drawTextWrap(optHelpStrings[optMenu.getSelected()].c_str(), frameBuffer, ui::shared, 466, 98, 18, ui::txtCont, 730);
drawTextWrap(ui::optMenuExp[optMenu.getSelected()].c_str(), frameBuffer, ui::shared, 466, 98, 18, ui::txtCont, 730);
}