fix region bug for language

This commit is contained in:
mrdude2478 2023-09-17 17:58:03 +01:00
parent f50baa532a
commit 785bae2b75
6 changed files with 46 additions and 23 deletions

View File

@ -44,7 +44,7 @@ DATA := data
INCLUDES := include include/ui include/data include/install include/nx include/nx/ipc include/util $(CURDIR)/include/Plutonium/Plutonium/include
APP_TITLE := TinWoo Installer
APP_AUTHOR := MrDude
APP_VERSION := 1.0.18
APP_VERSION := 1.0.19
ROMFS := romfs
APP_ICON := icon.jpg

View File

@ -5,7 +5,7 @@
namespace inst::config {
static const std::string appDir = "sdmc:/switch/tinwoo";
static const std::string configPath = appDir + "/config.json";
static const std::string appVersion = "1.0.18";
static const std::string appVersion = "1.0.19";
extern std::string gAuthKey;
extern std::string sigPatchesUrl;

View File

@ -357,7 +357,7 @@ namespace netInstStuff {
}
if (kDown & HidNpadButton_Minus) {
if (std::filesystem::remove("temp.html"));
std::remove("temp.html");
std::string url;
unsigned short maxlist = 50;
unsigned short nowlist = 0;
@ -398,6 +398,10 @@ namespace netInstStuff {
//If the above fails we probably have an html page - try to download it instead.
if (response.empty()) {
response = inst::curl::html_to_buffer(url);
if (response.empty()) {
inst::ui::mainApp->CreateShowDialog("inst.net.index_error"_lang, "inst.net.index_error_info"_lang, { "common.ok"_lang }, true, "romfs:/images/icons/fail.png");
break;
}
}
}

View File

@ -20,6 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <filesystem>
#include <sstream>
#include <switch.h>
#include "nx/nca_writer.h"
#include "util/error.hpp"
#include <zstd.h>
@ -29,6 +32,11 @@ SOFTWARE.
#include "util/title_util.hpp"
#include "install/nca.hpp"
//added for debugging messages on screen
#include "util/lang.hpp"
#include "ui/MainApplication.hpp"
//
void append(std::vector<u8>& buffer, const u8* ptr, u64 sz)
{
u64 offset = buffer.size();
@ -68,6 +76,10 @@ bool NcaBodyWriter::isOpen() const
//https://github.com/nicoboss/nsz/blob/master/nsz/BlockDecompressorReader.py
//https://switchbrew.org/wiki/NCA
namespace inst::ui {
extern MainApplication* mainApp;
}
class NczHeader
{
public:
@ -249,7 +261,7 @@ public:
{
const size_t readChunkSz = std::min(sz, buffInSize);
ZSTD_inBuffer input = { ptr, readChunkSz, 0 };
while (input.pos < input.size)
{
ZSTD_outBuffer output = { buffOut, buffOutSize, 0 };
@ -300,6 +312,21 @@ public:
}
auto header = (NczHeader*)m_buffer.data();
//debug code -- ignore....
/*
int x =0;
if (x == 0) {
char aByte = m_buffer.data()[0];
//aByte = 0x10+(aByte*0x40);
int one = sizeof(NczHeader);
std::ostringstream ss;
ss << "0x" << std::hex << one;
std::string result = ss.str();
inst::ui::mainApp->CreateShowDialog("Debug info", result, { "common.ok"_lang }, true, "romfs:/images/icons/information.png");
x++;
}
*/
if (m_buffer.size() + sz > header->size())
{
@ -491,4 +518,4 @@ void NcaWriter::flushHeader()
{
m_contentStorage->WritePlaceholder(*(NcmPlaceHolderId*)&m_ncaId, 0, m_buffer.data(), m_buffer.size());
}
}
}

View File

@ -103,7 +103,8 @@ namespace inst::ui {
return languageStrings[ourLangCode];
}
else {
return "options.language.system_language"_lang;
flag = "romfs:/images/flags/en.png";
return languageStrings[0];
}
}
@ -356,7 +357,6 @@ namespace inst::ui {
break;
case 13:
languageList = languageStrings;
languageList.push_back("options.language.system_language"_lang);
rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false, flag );
if (rc == -1) break;
switch (rc) {

View File

@ -11,18 +11,14 @@ namespace Language {
std::ifstream ifs;
std::string languagePath;
int langInt = inst::config::languageSetting;
if (langInt == 0) {
SetLanguage ourLang;
u64 lcode = 0;
setInitialize();
setGetSystemLanguage(&lcode);
setMakeLanguage(lcode, &ourLang);
setExit();
langInt = (int)ourLang;
}
switch (langInt) {
case 0:
languagePath = "romfs:/lang/en.json";
if (std::filesystem::exists(inst::config::appDir + "/lang/custom.json")) {
languagePath = (inst::config::appDir + "/lang/custom.json");
}
else {
languagePath = "romfs:/lang/en.json";
}
break;
case 1:
languagePath = "romfs:/lang/jp.json";
@ -46,12 +42,8 @@ namespace Language {
languagePath = "romfs:/lang/tw.json";
break;
default:
if (std::filesystem::exists(inst::config::appDir + "/lang/custom.json")) {
languagePath = (inst::config::appDir + "/lang/custom.json");
}
else {
languagePath = "romfs:/lang/en.json";
}
languagePath = "romfs:/lang/en.json";
break;
}
if (std::filesystem::exists(languagePath)) ifs = std::ifstream(languagePath);
else ifs = std::ifstream("romfs:/lang/en.json");