mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-06 11:07:18 -04:00
Add Dusk logo to imgui prelaunch
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 340 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@@ -29,13 +29,22 @@ bool AssetExists(const std::string& path) {
|
||||
SDL_PathInfo pathInfo{};
|
||||
return SDL_GetPathInfo(path.c_str(), &pathInfo) && pathInfo.type == SDL_PATHTYPE_FILE;
|
||||
}
|
||||
|
||||
ImTextureID AddTexture(const char* assetName) {
|
||||
auto image = GetImage(GetAssetPath(assetName));
|
||||
if (image.data == nullptr || image.width == 0 || image.height == 0) {
|
||||
return 0;
|
||||
}
|
||||
return aurora_imgui_add_texture(image.width, image.height, image.data.get());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ImFont* ImGuiEngine::fontNormal;
|
||||
ImFont* ImGuiEngine::fontLarge;
|
||||
ImFont* ImGuiEngine::fontExtraLarge;
|
||||
ImFont* ImGuiEngine::fontMono;
|
||||
ImTextureID ImGuiEngine::duskIcon = 0;
|
||||
ImTextureID ImGuiEngine::orgIcon = 0;
|
||||
ImTextureID ImGuiEngine::duskLogo = 0;
|
||||
|
||||
inline ImFont* CreateFont(float size, const std::string& fontPath, std::string_view fontName) {
|
||||
bool fontFileExists = !fontPath.empty() && AssetExists(fontPath);
|
||||
@@ -187,13 +196,11 @@ Image GetImage(const std::string& path) {
|
||||
}
|
||||
|
||||
void ImGuiEngine_AddTextures() {
|
||||
if (ImGuiEngine::duskIcon == 0) {
|
||||
auto icon = GetImage(GetAssetPath("icon.png"));
|
||||
if (icon.data == nullptr || icon.width == 0 || icon.height == 0) {
|
||||
ImGuiEngine::duskIcon = 0;
|
||||
return;
|
||||
}
|
||||
ImGuiEngine::duskIcon = aurora_imgui_add_texture(icon.width, icon.height, icon.data.get());
|
||||
if (ImGuiEngine::orgIcon == 0) {
|
||||
ImGuiEngine::orgIcon = AddTexture("org-icon.png");
|
||||
}
|
||||
if (ImGuiEngine::duskLogo == 0) {
|
||||
ImGuiEngine::duskLogo = AddTexture("logo.png");
|
||||
}
|
||||
}
|
||||
} // namespace dusk
|
||||
|
||||
@@ -11,7 +11,8 @@ public:
|
||||
static ImFont* fontLarge;
|
||||
static ImFont* fontExtraLarge;
|
||||
static ImFont* fontMono;
|
||||
static ImTextureID duskIcon;
|
||||
static ImTextureID orgIcon;
|
||||
static ImTextureID duskLogo;
|
||||
};
|
||||
|
||||
void ImGuiEngine_Initialize(float scale);
|
||||
@@ -23,5 +24,5 @@ struct Image {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
Image GetImage(std::string_view path);
|
||||
Image GetImage(const std::string& path);
|
||||
} // namespace dusk
|
||||
|
||||
@@ -80,12 +80,20 @@ void ImGuiPreLaunchWindow::draw() {
|
||||
|
||||
float iconSize = 150.f;
|
||||
ImGui::SameLine(windowSize.x / 2 - iconSize + (iconSize / 2));
|
||||
if (ImGuiEngine::duskIcon != 0)
|
||||
ImGui::Image(ImGuiEngine::duskIcon, ImVec2{iconSize, iconSize});
|
||||
if (ImGuiEngine::orgIcon != 0) {
|
||||
ImGui::Image(ImGuiEngine::orgIcon, ImVec2{iconSize, iconSize});
|
||||
}
|
||||
ImGuiTextCenter("Twilit Realm presents");
|
||||
ImGui::PushFont(ImGuiEngine::fontExtraLarge);
|
||||
ImGuiTextCenter("Dusk");
|
||||
ImGui::PopFont();
|
||||
if (ImGuiEngine::duskLogo) {
|
||||
ImGui::NewLine();
|
||||
float width = iconSize * 2.5f;
|
||||
ImGui::SameLine(windowSize.x / 2 - width + (width / 2));
|
||||
ImGui::Image(ImGuiEngine::duskLogo, ImVec2{width, iconSize});
|
||||
} else {
|
||||
ImGui::PushFont(ImGuiEngine::fontExtraLarge);
|
||||
ImGuiTextCenter("Dusk");
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
(this->*drawTable[m_CurMenu])();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user