mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:50:05 +00:00
About dialog
This commit is contained in:
parent
aaeea156f3
commit
5c793e07d8
10 changed files with 294 additions and 7 deletions
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -15,12 +17,19 @@ namespace manager
|
|||
{
|
||||
namespace ResourceManager
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::manager::resource_manager";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
static void LoadFonts();
|
||||
static void LoadTextures();
|
||||
|
||||
static const std::unordered_map<types::Font, std::string> fontNames_ {
|
||||
{types::Font::din1451alt, ":/res/fonts/din1451alt.ttf"},
|
||||
{types::Font::din1451alt_g, ":/res/fonts/din1451alt_g.ttf"}};
|
||||
|
||||
static std::unordered_map<types::Font, int> fontIds_ {};
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
config::CountyDatabase::Initialize();
|
||||
|
|
@ -31,10 +40,26 @@ void Initialize()
|
|||
|
||||
void Shutdown() {}
|
||||
|
||||
int FontId(types::Font font)
|
||||
{
|
||||
auto it = fontIds_.find(font);
|
||||
if (it != fontIds_.cend())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void LoadFonts()
|
||||
{
|
||||
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
||||
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
|
||||
for (auto& fontName : fontNames_)
|
||||
{
|
||||
int fontId = QFontDatabase::addApplicationFont(
|
||||
QString::fromStdString(fontName.second));
|
||||
fontIds_.emplace(fontName.first, fontId);
|
||||
|
||||
util::Font::Create(fontName.second);
|
||||
}
|
||||
|
||||
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
|
||||
fontAtlas->AddFontDefault();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/types/font_types.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -8,8 +10,12 @@ namespace manager
|
|||
{
|
||||
namespace ResourceManager
|
||||
{
|
||||
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
int FontId(types::Font font);
|
||||
|
||||
} // namespace ResourceManager
|
||||
} // namespace manager
|
||||
} // namespace qt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue