diff --git a/changelog.md b/changelog.md index b6efed7..62554f5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 1.7.7 + +- Added **Localization / Translations**!!! + # 1.7.6 - Fixed level creator appearing as blank in labels for official levels diff --git a/src/Client/Module.cpp b/src/Client/Module.cpp index bd22fa6..6d5418c 100644 --- a/src/Client/Module.cpp +++ b/src/Client/Module.cpp @@ -4,6 +4,7 @@ #include "Dropdown.h" #include "Client.h" #include "../UI/TransLabelBMFont.hpp" +#include "../UI/TransAlertLayer.hpp" void Module::drawImGui() { @@ -85,7 +86,7 @@ void Module::onInfoAndroid(CCObject* sender) if (!dat) return; - auto al = FLAlertLayer::create(dat->name.c_str(), dat->description.c_str(), "OK"); + auto al = TransAlertLayer::create(dat->name.c_str(), dat->description.c_str(), "OK"); al->show(); } diff --git a/src/Client/Types/ColourPickModule.cpp b/src/Client/Types/ColourPickModule.cpp index 21ccd94..50a6a27 100644 --- a/src/Client/Types/ColourPickModule.cpp +++ b/src/Client/Types/ColourPickModule.cpp @@ -1,8 +1,9 @@ #include "ColourPickModule.hpp" +#include "../../UI/TransLabelBMFont.hpp" void ColourModule::makeAndroid(CCNode* menu, CCPoint pos) { - auto label = CCLabelBMFont::create(name.c_str(), "bigFont.fnt"); + auto label = TransLabelBMFont::create(name.c_str(), "bigFont.fnt"); label->setAnchorPoint(ccp(0, 0.5f)); label->setScale(0.575f); label->setPosition(pos + ccp(-15, 0)); diff --git a/src/Client/Types/InputModule.cpp b/src/Client/Types/InputModule.cpp index 873a166..4940a99 100644 --- a/src/Client/Types/InputModule.cpp +++ b/src/Client/Types/InputModule.cpp @@ -1,5 +1,6 @@ #include "InputModule.hpp" #include +#include "../../UI/TransLabelBMFont.hpp" InputModule* mod; @@ -40,7 +41,7 @@ void InputModule::drawImGui() void InputModule::makeAndroid(CCNode* menu, CCPoint pos) { - auto label = CCLabelBMFont::create(name.c_str(), "bigFont.fnt"); + auto label = TransLabelBMFont::create(name.c_str(), "bigFont.fnt"); label->setAnchorPoint(ccp(0, 0.5f)); label->setScale(0.575f); label->setPosition(pos - ccp(10, 0)); diff --git a/src/Layers/LanguageSelectNode.cpp b/src/Layers/LanguageSelectNode.cpp index 0cd8fa7..7fbb834 100644 --- a/src/Layers/LanguageSelectNode.cpp +++ b/src/Layers/LanguageSelectNode.cpp @@ -36,15 +36,30 @@ bool LanguageSelectNode::init() if (!TranslationManager::get()->isLanguageLoaded()) goToPage(0); else - { - - } + goToPage(Mod::get()->getSavedValue("loaded-translation", "none")); this->addChild(colBG); this->addChildAtPosition(node, Anchor::Center); return true; } +void LanguageSelectNode::goToPage(std::string fileName) +{ + auto langs = Client::get()->getLanguages(); + + int i = 1; + + for (auto lang : langs) + { + if (lang.filename() == fileName) + return goToPage(i); + + i++; + } + + goToPage(0); +} + void LanguageSelectNode::goToPage(int page) { this->page = page; diff --git a/src/Layers/LanguageSelectNode.hpp b/src/Layers/LanguageSelectNode.hpp index fc1a9b6..4589f7b 100644 --- a/src/Layers/LanguageSelectNode.hpp +++ b/src/Layers/LanguageSelectNode.hpp @@ -16,6 +16,7 @@ class LanguageSelectNode : public CCLayer bool init(); void goToPage(int page); + void goToPage(std::string fileName); virtual void keyBackClicked(); void onSubmit(CCObject* sender); diff --git a/src/Layers/ModuleOptionsLayer.cpp b/src/Layers/ModuleOptionsLayer.cpp index d2e0ce2..079094c 100644 --- a/src/Layers/ModuleOptionsLayer.cpp +++ b/src/Layers/ModuleOptionsLayer.cpp @@ -1,4 +1,5 @@ #include "ModuleOptionsLayer.h" +#include "../UI/TransAlertLayer.hpp" ModuleOptionsLayer* ModuleOptionsLayer::create(Module* module) { @@ -49,6 +50,6 @@ void ModuleOptionsLayer::customSetup() void ModuleOptionsLayer::onInfoButton(CCObject*) { - auto al = FLAlertLayer::create(mod->name.c_str(), mod->description.c_str(), "OK"); + auto al = TransAlertLayer::create(mod->name.c_str(), mod->description.c_str(), "OK"); al->show(); } \ No newline at end of file diff --git a/src/Layers/SillyBaseLayer.cpp b/src/Layers/SillyBaseLayer.cpp index bce0819..dc3d5f6 100644 --- a/src/Layers/SillyBaseLayer.cpp +++ b/src/Layers/SillyBaseLayer.cpp @@ -29,7 +29,7 @@ bool SillyBaseLayer::setup() l->addChildAtPosition(bg, Anchor::Center); - title = CCLabelBMFont::create(_title.c_str(), "bigFont.fnt"); + title = TransLabelBMFont::create(_title.c_str(), "bigFont.fnt"); title->setPosition(l->getContentSize() / 2 + ccp(0, (l->getContentSize().height / 2) - 15)); title->setScale(0.6f); l->addChild(title); diff --git a/src/Layers/SillyBaseLayer.h b/src/Layers/SillyBaseLayer.h index ed8addf..898bf9a 100644 --- a/src/Layers/SillyBaseLayer.h +++ b/src/Layers/SillyBaseLayer.h @@ -5,6 +5,7 @@ #include "../Client/Client.h" #include "../UI/BlurLayer.hpp" #include "../UI/QOLModMenuBG.hpp" +#include "../UI/TransLabelBMFont.hpp" using namespace geode::prelude; @@ -16,7 +17,7 @@ class SillyBaseLayer : public geode::Popup<> CCPoint size = CCPointZero; BlurLayer* blur = nullptr; std::string _title; - CCLabelBMFont* title; + TransLabelBMFont* title; bool createWithOK; bool animate; bool noBlur; diff --git a/src/UI/TransAlertLayer.cpp b/src/UI/TransAlertLayer.cpp new file mode 100644 index 0000000..50b9558 --- /dev/null +++ b/src/UI/TransAlertLayer.cpp @@ -0,0 +1,70 @@ +#include "TransAlertLayer.hpp" +#include "TransLabelBMFont.hpp" +#include "../Utils/TranslationManager.hpp" + +bool TransAlertLayer::init(char const* title, const gd::string& desc, char const* btn) +{ + std::string desc2 = TranslationManager::get()->getTranslatedString(desc); + + if (!FLAlertLayer::init(nullptr, title, desc2, btn, nullptr, 300.0f, false, 320, 1.0f)) + return false; + + auto label = CCLabelBMFont::create("", "bigFont.fnt"); + + bool useTtf = false; + + for (auto letter : desc2) + { + if (!label->getConfiguration()->getCharacterSet()->contains(as(letter))) + { + useTtf = true; + break; + } + } + + auto titleL = TransLabelBMFont::create(std::string(title), "goldFont.fnt"); + titleL->setAnchorPoint(ccp(0.5f, 1)); + titleL->setPosition(m_mainLayer->getChildByType(0)->getPosition()); + titleL->setScale(m_mainLayer->getChildByType(0)->getScale()); + + m_mainLayer->getChildByType(0)->setVisible(false); + + m_mainLayer->addChild(titleL, 420); + + if (useTtf) + { + m_mainLayer->getChildByType