Adding basic language support unfinished

This commit is contained in:
2022-12-15 21:11:37 -08:00
parent 2f48f61e9a
commit 5b48fb3901
22 changed files with 364 additions and 4 deletions

View File

@ -0,0 +1,11 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
LanguageManager.cpp
)

View File

@ -0,0 +1,19 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "LanguageManager.hpp"
#include "game/DawnGame.hpp"
using namespace Dawn;
LanguageManager::LanguageManager(DawnGame *game) {
this->game = game;
auto lang = this->game->assetManager.get<LanguageAsset>("language_en");
while(!lang->loaded) {
lang->updateAsync();
}
std::cout << lang->getValue("test2");
}

View File

@ -0,0 +1,29 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "event/Event.hpp"
#include "asset/AssetManager.hpp"
namespace Dawn {
class DawnGame;
struct LocalizedString {
std::string data;
};
class LanguageManager {
private:
DawnGame *game;
LanguageAsset *asset;
public:
Event<> eventLanguageChanged;
LanguageManager(DawnGame *game);
struct LocalizedString getString(std::string key);
};
}