mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-09 06:54:01 -04:00
Modern Menu (#183)
* Add modern menu. Add and include LUS cvars .cmake file for macro usage in modern menu. * Un-ignore new .cmake * Copy new Resolution Editor stuff from 2ship (incomplete). Fix fullscreen checkbox. Finish changes for new UIWidgets. Cleanup ShipUtils. * Remove duplicate asm-differ entry from .gitmodules. * Re-implement Freecam options. * Cleanup freecam character follow buttons. Partially re-implement Multiplayer window as enhancement sidebar (needs text input widget to finish). Cleanup disables. --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "resource/importers/UnkActorSpawnDataFactory.h"
|
||||
#include "resource/importers/ArrayFactory.h"
|
||||
#include <Fast3D/Fast3dWindow.h>
|
||||
#include <Fonts.h>
|
||||
#include "window/gui/resource/Font.h"
|
||||
#include "window/gui/resource/FontFactory.h"
|
||||
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
#include <Fast3D/gfx_rendering_api.h>
|
||||
@@ -139,6 +142,14 @@ GameEngine::GameEngine() {
|
||||
loader->RegisterResourceFactory(std::make_shared<MK64::ResourceFactoryBinaryUnkActorSpawnDataV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "UnkSpawnData",
|
||||
static_cast<uint32_t>(MK64::ResourceType::UnkSpawnData), 0);
|
||||
|
||||
fontMono = CreateFontWithSize(16.0f, "fonts/Inconsolata-Regular.ttf");
|
||||
fontMonoLarger = CreateFontWithSize(20.0f, "fonts/Inconsolata-Regular.ttf");
|
||||
fontMonoLargest = CreateFontWithSize(24.0f, "fonts/Inconsolata-Regular.ttf");
|
||||
fontStandard = CreateFontWithSize(16.0f, "fonts/Montserrat-Regular.ttf");
|
||||
fontStandardLarger = CreateFontWithSize(20.0f, "fonts/Montserrat-Regular.ttf");
|
||||
fontStandardLargest = CreateFontWithSize(24.0f, "fonts/Montserrat-Regular.ttf");
|
||||
ImGui::GetIO().FontDefault = fontMono;
|
||||
}
|
||||
|
||||
void GameEngine::Create() {
|
||||
@@ -296,6 +307,37 @@ uint8_t GameEngine::GetBankIdByName(const std::string& name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ImFont* GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
auto mImGuiIo = &ImGui::GetIO();
|
||||
ImFont* font;
|
||||
if (fontPath == "") {
|
||||
ImFontConfig fontCfg = ImFontConfig();
|
||||
fontCfg.OversampleH = fontCfg.OversampleV = 1;
|
||||
fontCfg.PixelSnapH = true;
|
||||
fontCfg.SizePixels = size;
|
||||
font = mImGuiIo->Fonts->AddFontDefault(&fontCfg);
|
||||
} else {
|
||||
auto initData = std::make_shared<Ship::ResourceInitData>();
|
||||
initData->Format = RESOURCE_FORMAT_BINARY;
|
||||
initData->Type = static_cast<uint32_t>(RESOURCE_TYPE_FONT);
|
||||
initData->ResourceVersion = 0;
|
||||
initData->Path = fontPath;
|
||||
std::shared_ptr<Ship::Font> fontData = std::static_pointer_cast<Ship::Font>(
|
||||
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false, initData));
|
||||
font = mImGuiIo->Fonts->AddFontFromMemoryTTF(fontData->Data, fontData->DataSize, size);
|
||||
}
|
||||
// FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly
|
||||
float iconFontSize = size * 2.0f / 3.0f;
|
||||
static const ImWchar sIconsRanges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 };
|
||||
ImFontConfig iconsConfig;
|
||||
iconsConfig.MergeMode = true;
|
||||
iconsConfig.PixelSnapH = true;
|
||||
iconsConfig.GlyphMinAdvanceX = iconFontSize;
|
||||
mImGuiIo->Fonts->AddFontFromMemoryCompressedBase85TTF(fontawesome_compressed_data_base85, iconFontSize,
|
||||
&iconsConfig, sIconsRanges);
|
||||
return font;
|
||||
}
|
||||
|
||||
// End
|
||||
|
||||
extern "C" uint32_t GameEngine_GetSampleRate() {
|
||||
|
||||
Reference in New Issue
Block a user