From e3bfdff511b78d7f1fe9d7d480d2f376d6fc66ae Mon Sep 17 00:00:00 2001 From: TheSillyDoggo Date: Tue, 10 Dec 2024 18:03:58 +1100 Subject: [PATCH] f --- resources/{langs => lang}/ja-JP.json | 5 ++++- resources/sprites/banner-mask.png | Bin 0 -> 4261 bytes src/Client/Client.cpp | 24 ++++++++++++++++++++++++ src/Client/Client.h | 7 +++---- src/Layers/TranslationCreditsLayer.cpp | 23 +++++++++++++---------- src/UI/TransLabelBMFont.cpp | 3 --- src/UI/TransLabelBMFont.hpp | 1 + src/Utils/TranslationManager.cpp | 14 ++++++++++++-- src/Utils/TranslationManager.hpp | 1 + 9 files changed, 58 insertions(+), 20 deletions(-) rename resources/{langs => lang}/ja-JP.json (85%) create mode 100644 resources/sprites/banner-mask.png diff --git a/resources/langs/ja-JP.json b/resources/lang/ja-JP.json similarity index 85% rename from resources/langs/ja-JP.json rename to resources/lang/ja-JP.json index c247ccc6..e6502220 100644 --- a/resources/langs/ja-JP.json +++ b/resources/lang/ja-JP.json @@ -12,5 +12,8 @@ "glow-col": 12, "death-effect-id": 3 } - ] + ], + "strings": { + "Noclip": "ノークリップ" + } } \ No newline at end of file diff --git a/resources/sprites/banner-mask.png b/resources/sprites/banner-mask.png new file mode 100644 index 0000000000000000000000000000000000000000..895ff540c6708ceeb6d63ff06a8acf05b1fc037d GIT binary patch literal 4261 zcmeHL`8(8W8~?VPC>6?*C4-a_Mp+JWOq{}G3)#Yq6oo8fH^z)NOWCr7m`1XMu@7VB zSOzVKLX1hsz7@vU1~bgetH0uXe>m6me6HuYo_l$&>vMnZ=Z8D~wuSMDW0J=J05}0P zxnT_e2d@7H|B?Nhp47Kx``b}}6URUR5IFrC2LLSY3;+n(LvI+|3B%FHu03|PM|ZAG zH2iH1^Nf|NdGjCbKT5j9Lgch8(nN4Xs9fXsySJpyq+-pbd~)MdNm-g zeUkJSdiH+gpq;9QhTEl7yUA4@^=*Vj!tP}5l>bh~#a}!Q5Nh6=`||Lz_`;8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{N!T37}76K!AzGbYxHo3kUr*tBQsPSY8A zF0YSnwrf658^tgxNCho8B`taT_DX4HMp{6x?VrZVDNZK_%;G0_j~8$#x`h}=qZNfm zG2#N-O_bsGB&mf$HP0P+=DPe^K)6x(!(jYtdE-Bkd&Fqw4tqId)YUa+#M(ijP1VEflHJ0 zNnBw5PCimC2}h6;)vz!_F|n1pcacceK=~rIsV1}69+s&jULwc_~j_d{@ek8-n6(;W$60kzqjDtNB{r; literal 0 HcmV?d00001 diff --git a/src/Client/Client.cpp b/src/Client/Client.cpp index fb3efdf6..ea5389cd 100644 --- a/src/Client/Client.cpp +++ b/src/Client/Client.cpp @@ -1,5 +1,6 @@ #include "Client.h" #include "../Utils/LaunchArgs.hpp" +#include "../Utils/TranslationManager.hpp" #include Client* Client::get() @@ -7,6 +8,13 @@ Client* Client::get() return instance; } +Client::Client() +{ + mod = Mod::get(); + + setLanguage(Mod::get()->getSavedValue("loaded-translation", "none")); +} + bool Client::handleKeybinds(enumKeyCodes key, bool isDown, bool isRepeatedKey) { if (!isDown || key == enumKeyCodes::KEY_Unknown) @@ -157,6 +165,22 @@ void Client::drawImGui() } } +void Client::setLanguage(std::string langFile) +{ + auto path = Mod::get()->getResourcesDir() / langFile; + + if (std::filesystem::exists(path)) + { + TranslationManager::get()->loadTranslationFromJson(file::readJson(path).unwrapOr("{ }")); + } + else + { + TranslationManager::get()->unloadTranslation(); + } + + Mod::get()->setSavedValue("loaded-translation", langFile); +} + void Client::sortWindows(bool instant) { float offset = ini->getKeyValueFloat("Offsets::WindowDistance", "15"); diff --git a/src/Client/Client.h b/src/Client/Client.h index 64089a97..d0cad8f9 100644 --- a/src/Client/Client.h +++ b/src/Client/Client.h @@ -48,10 +48,7 @@ class Client SimpleINI* ini = nullptr; ImVec2 widgetSize = ImVec2(215, 25); - Client() - { - mod = Mod::get(); - } + Client(); static Client* get(); @@ -69,6 +66,8 @@ class Client void setUIScale(float scale); + void setLanguage(std::string langFile); + //[[deprecated("GetModuleEnabled has been deprecated due to lag, please rember to cache the module :3")]] static bool GetModuleEnabled(std::string id) { diff --git a/src/Layers/TranslationCreditsLayer.cpp b/src/Layers/TranslationCreditsLayer.cpp index 1f3548b9..3c8085dd 100644 --- a/src/Layers/TranslationCreditsLayer.cpp +++ b/src/Layers/TranslationCreditsLayer.cpp @@ -17,18 +17,15 @@ void TranslationCreditsLayer::customSetup() langNode->setLayout(AxisLayout::create()->setGap(20)); - auto stencil = CCScale9Sprite::create("GJ_square01.png"); - stencil->setContentSize(size + ccp(0, -30)); - stencil->setAnchorPoint(ccp(0.5f, 0)); - - auto stencilTop = CCLayerColor::create(ccc4(255, 255, 255, 255), size.x, 30); - stencilTop->setAnchorPoint(ccp(0.5f, 1)); - stencilTop->ignoreAnchorPointForPosition(false); - stencil->addChildAtPosition(stencilTop, Anchor::Top); + auto stencil = CCScale9Sprite::create("banner-mask.png"_spr); + stencil->setContentSize(size + ccp(0, -32)); + stencil->setAnchorPoint(ccp(0.5f, 1)); + stencil->setScaleY(-1); auto clip = CCClippingNode::create(stencil); clip->setAlphaThreshold(0.03f); clip->setAnchorPoint(ccp(0.5f, 0)); + clip->setZOrder(3); auto clipOutline = CCScale9Sprite::create("GJ_square07.png"); clipOutline->setContentSize(size); @@ -48,9 +45,14 @@ void TranslationCreditsLayer::customSetup() clip->addChild(background, -2); clip->addChild(ground, -1); - baseLayer->addChildAtPosition(langNode, Anchor::Top, ccp(0, -16)); + baseLayer->addChildAtPosition(langNode, Anchor::Top, ccp(0, -18)); baseLayer->addChildAtPosition(clip, Anchor::Bottom); + auto clipLine = CCLayerColor::create(ccc4(255, 255, 255, 255), size.x, 30); + clipLine->setAnchorPoint(ccp(0.5f, 1)); + clipLine->ignoreAnchorPointForPosition(false); + baseLayer->addChildAtPosition(clipLine, Anchor::Bottom, ccp(0, stencil->getContentHeight() + 1.5f)); + auto gameNode = CCMenu::create(); gameNode->ignoreAnchorPointForPosition(false); gameNode->setContentSize(ccp(0, 0)); @@ -61,6 +63,7 @@ void TranslationCreditsLayer::customSetup() creditsMenu->setContentWidth(320); creditsMenu->setAnchorPoint(ccp(0.5f, 1)); creditsMenu->setLayout(AxisLayout::create()->setGrowCrossAxis(true)->setCrossAxisAlignment(AxisAlignment::Start)); + creditsMenu->setZOrder(6); for (auto contributor : language["contributors"].asArray().unwrap()) { @@ -106,7 +109,7 @@ void TranslationCreditsLayer::customSetup() creditsMenu->updateLayout(); clip->addChild(gameNode); - baseLayer->addChildAtPosition(creditsMenu, Anchor::Top, ccp(0, -42.5f)); + baseLayer->addChildAtPosition(creditsMenu, Anchor::Top, ccp(0, -45)); ok->setZOrder(420); } diff --git a/src/UI/TransLabelBMFont.cpp b/src/UI/TransLabelBMFont.cpp index c9f257bc..7916ac73 100644 --- a/src/UI/TransLabelBMFont.cpp +++ b/src/UI/TransLabelBMFont.cpp @@ -9,9 +9,6 @@ bool TransLabelBMFont::init(std::string text, std::string font) text = TranslationManager::get()->getTranslatedString(text); - if (text == "Noclip") - text = "ノークリップ"; - this->text = text; this->font = text; diff --git a/src/UI/TransLabelBMFont.hpp b/src/UI/TransLabelBMFont.hpp index bd4cda5c..fb4db359 100644 --- a/src/UI/TransLabelBMFont.hpp +++ b/src/UI/TransLabelBMFont.hpp @@ -4,6 +4,7 @@ using namespace geode::prelude; +// they call this my gender class TransLabelBMFont : public CCNode { private: diff --git a/src/Utils/TranslationManager.cpp b/src/Utils/TranslationManager.cpp index 235d1aae..9ce6cbd6 100644 --- a/src/Utils/TranslationManager.cpp +++ b/src/Utils/TranslationManager.cpp @@ -10,11 +10,21 @@ TranslationManager* TranslationManager::get() return instance; } -void TranslationManager::loadTranslationFromJson(matjson::Value object) +void TranslationManager::unloadTranslation() { translatedTexts = {}; +} + +void TranslationManager::loadTranslationFromJson(matjson::Value object) +{ + unloadTranslation(); + + if (!object.contains("strings")) + return; + + auto strings = object["strings"]; - for (auto value : object) + for (auto value : strings) { if (value.isString() && value.getKey().has_value()) { diff --git a/src/Utils/TranslationManager.hpp b/src/Utils/TranslationManager.hpp index 55ad78d6..10ae399c 100644 --- a/src/Utils/TranslationManager.hpp +++ b/src/Utils/TranslationManager.hpp @@ -12,6 +12,7 @@ class TranslationManager public: static TranslationManager* get(); + void unloadTranslation(); void loadTranslationFromJson(matjson::Value object); std::string getTranslatedString(std::string engText); }; \ No newline at end of file