Skip to content

Commit bb4d62f

Browse files
committed
ide: fix palette handling and disable custom font.
There are issues with the custom font because of this DearImGui issue: ocornut/imgui#2127 and unfortunately the proposed mitigation will not work out of the box, because we do not provide all the required characters in our font. The best solution would be to add our font characters to the already existing font atlas.
1 parent 238e80a commit bb4d62f

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

lol

src/ide/ide.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "ide/ide.h"
2121
#include "3rdparty/portable-file-dialogs/portable-file-dialogs.h"
2222

23+
#define CUSTOM_FONT 0
24+
2325
namespace z8
2426
{
2527

@@ -37,16 +39,16 @@ ide::ide(player *player)
3739
style.WindowRounding = style.ChildRounding = style.FrameRounding = style.ScrollbarRounding = style.TabRounding = 0.0f;
3840

3941
// Useless
40-
style.Colors[ImGuiCol_ChildBg] = (lol::vec4)z8::palette::get(5) / 255.f;
42+
style.Colors[ImGuiCol_ChildBg] = z8::palette::get(5);
4143

42-
style.Colors[ImGuiCol_Tab] = (lol::vec4)z8::palette::get(0) / 255.f;
43-
style.Colors[ImGuiCol_TabHovered] = (lol::vec4)z8::palette::get(8) / 255.f;
44-
style.Colors[ImGuiCol_TabActive] = (lol::vec4)z8::palette::get(8) / 255.f;
45-
style.Colors[ImGuiCol_TabUnfocused] = (lol::vec4)z8::palette::get(0) / 255.f;
46-
style.Colors[ImGuiCol_TabUnfocusedActive] = (lol::vec4)z8::palette::get(0) / 255.f;
44+
style.Colors[ImGuiCol_Tab] = z8::palette::get(0);
45+
style.Colors[ImGuiCol_TabHovered] = z8::palette::get(8);
46+
style.Colors[ImGuiCol_TabActive] = z8::palette::get(8);
47+
style.Colors[ImGuiCol_TabUnfocused] = z8::palette::get(0);
48+
style.Colors[ImGuiCol_TabUnfocusedActive] = z8::palette::get(0);
4749

48-
style.Colors[ImGuiCol_TitleBg] = (lol::vec4)z8::palette::get(5) / 255.f;
49-
style.Colors[ImGuiCol_TitleBgActive] = (lol::vec4)z8::palette::get(5) / 255.f;
50+
style.Colors[ImGuiCol_TitleBg] = z8::palette::get(5);
51+
style.Colors[ImGuiCol_TitleBgActive] = z8::palette::get(5);
5052

5153
m_player = player;
5254

@@ -63,6 +65,7 @@ ide::~ide()
6365
void ide::tick_game(float seconds)
6466
{
6567
WorldEntity::tick_game(seconds);
68+
#if CUSTOM_FONT
6669
if (!m_font)
6770
{
6871
auto atlas = IM_NEW(ImFontAtlas)();
@@ -112,11 +115,12 @@ void ide::tick_game(float seconds)
112115
m_font->ContainerAtlas->TexID = m_player->get_font_texture();
113116

114117
ImGui::PushFont(m_font);
118+
#endif
115119

116120
render_dock();
117121
// ImGui::ShowDemoWindow();
118122

119-
ImGui::PushStyleColor(ImGuiCol_ChildBg, (lol::vec4)z8::palette::get(5) / 255.f);
123+
ImGui::PushStyleColor(ImGuiCol_ChildBg, z8::palette::get(5));
120124
m_editor.render();
121125
ImGui::PopStyleColor(1);
122126

@@ -127,8 +131,8 @@ void ide::tick_game(float seconds)
127131
if (i % 4 > 0)
128132
ImGui::SameLine();
129133
ImGui::PushID(i);
130-
ImGui::PushStyleColor(ImGuiCol_Button, (lol::vec4)z8::palette::get(i) / 255.f);
131-
ImGui::PushStyleColor(ImGuiCol_Text, (lol::vec4)z8::palette::get(i < 6 ? 7 : 0) / 255.f);
134+
ImGui::PushStyleColor(ImGuiCol_Button, z8::palette::get(i));
135+
ImGui::PushStyleColor(ImGuiCol_Text, z8::palette::get(i < 6 ? 7 : 0));
132136
ImGui::Button(lol::format("%2d", i).c_str());
133137
ImGui::PopStyleColor(2);
134138
ImGui::PopID();
@@ -145,8 +149,8 @@ void ide::tick_game(float seconds)
145149

146150
ImGui::Begin("mUSIC", nullptr);
147151
{
148-
ImGui::TextColored((lol::vec4)z8::palette::get(10) / 255.f, "stuff");
149-
ImGui::TextColored((lol::vec4)z8::palette::get(5) / 255.f, "more stuff\nlol!!!");
152+
ImGui::TextColored(z8::palette::get(10), "stuff");
153+
ImGui::TextColored(z8::palette::get(5), "more stuff\nlol!!!");
150154
}
151155
ImGui::End();
152156

@@ -164,7 +168,9 @@ void ide::tick_game(float seconds)
164168
m_rom_edit.DrawContents(m_player->get_rom(), 0x5e00);
165169
ImGui::End();
166170

171+
#if CUSTOM_FONT
167172
ImGui::PopFont();
173+
#endif
168174
}
169175

170176
void ide::render_dock()

0 commit comments

Comments
 (0)