Skip to content

Commit 7357f40

Browse files
authored
Merge pull request #2046 from weluvgoatz/textbox-fix
Followup to custom menus
2 parents 9180996 + eca6a3b commit 7357f40

22 files changed

+129
-84
lines changed

src/editor/button_widget.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ ButtonWidget::draw(DrawingContext& context)
4343
}
4444

4545
if (m_grab) {
46-
context.color().draw_filled_rect(m_rect, Color(std::min(g_config->editorcolor.red + 0.4f, 1.f), std::min(g_config->editorcolor.green + 0.4f, 1.f),
47-
std::min(g_config->editorcolor.blue + 0.4f, 1.f), std::min(g_config->editorcolor.alpha + 0.1f, 1.f)), 4.0f,
46+
context.color().draw_filled_rect(m_rect, g_config->editorgrabcolor, 4.0f,
4847
LAYER_GUI-5);
4948
} else if (m_hover) {
50-
context.color().draw_filled_rect(m_rect, Color(std::min(g_config->editorcolor.red + 0.4f, 1.f), std::min(g_config->editorcolor.green + 0.4f, 1.f),
51-
std::min(g_config->editorcolor.blue + 0.4f, 1.f), std::max(g_config->editorcolor.alpha - 0.2f, 0.f)), 4.0f,
49+
context.color().draw_filled_rect(m_rect, g_config->editorhovercolor, 4.0f,
5250
LAYER_GUI-5);
5351
}
5452
}

src/editor/layers_widget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ EditorLayersWidget::draw(DrawingContext& context)
6565

6666
context.color().draw_filled_rect(Rectf(Vector(0, static_cast<float>(m_Ypos)),
6767
Vector(static_cast<float>(m_Width), static_cast<float>(SCREEN_HEIGHT))),
68-
Color(g_config->editorcolor),
68+
g_config->editorcolor,
6969
0.0f,
7070
LAYER_GUI-10);
7171

@@ -98,8 +98,7 @@ EditorLayersWidget::draw(DrawingContext& context)
9898

9999
if (draw_rect)
100100
{
101-
context.color().draw_filled_rect(target_rect, Color(std::min(g_config->editorcolor.red + 0.4f, 1.f), std::min(g_config->editorcolor.green + 0.4f, 1.f),
102-
std::min(g_config->editorcolor.blue + 0.4f, 1.f), std::max(g_config->editorcolor.alpha - 0.2f, 0.f)), 0.0f,
101+
context.color().draw_filled_rect(target_rect, g_config->editorhovercolor, 0.0f,
103102
LAYER_GUI-5);
104103
}
105104

src/editor/tip.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "supertux/colorscheme.hpp"
2020
#include "supertux/game_object.hpp"
21+
#include "supertux/gameconfig.hpp"
22+
#include "supertux/globals.hpp"
2123
#include "supertux/resources.hpp"
2224
#include "util/log.hpp"
2325
#include "video/drawing_context.hpp"
@@ -66,7 +68,7 @@ Tip::draw(DrawingContext& context, const Vector& pos)
6668
auto position = pos;
6769
position.y += 35;
6870
context.color().draw_text(Resources::normal_font, m_header, position,
69-
ALIGN_LEFT, LAYER_GUI-11, ColorScheme::Menu::label_color);
71+
ALIGN_LEFT, LAYER_GUI-11, g_config->labeltextcolor);
7072

7173
for (const auto& str : m_strings) {
7274
position.y += 22;

src/editor/toolbox_widget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ EditorToolboxWidget::draw(DrawingContext& context)
7373
context.color().draw_filled_rect(Rectf(Vector(static_cast<float>(m_Xpos), 0),
7474
Vector(static_cast<float>(context.get_width()),
7575
static_cast<float>(context.get_height()))),
76-
Color(g_config->editorcolor),
76+
g_config->editorcolor,
7777
0.0f, LAYER_GUI-10);
7878
if (m_dragging) {
7979
context.color().draw_filled_rect(selection_draw_rect(), Color(0.2f, 0.4f, 1.0f, 0.6f),
@@ -83,8 +83,7 @@ EditorToolboxWidget::draw(DrawingContext& context)
8383
if (m_hovered_item != HoveredItem::NONE)
8484
{
8585
context.color().draw_filled_rect(get_item_rect(m_hovered_item),
86-
Color(std::min(g_config->editorcolor.red + 0.4f, 1.f), std::min(g_config->editorcolor.green + 0.4f, 1.f),
87-
std::min(g_config->editorcolor.blue + 0.4f, 1.f), std::max(g_config->editorcolor.alpha - 0.2f, 0.f)),
86+
g_config->editorhovercolor,
8887
0.0f, LAYER_GUI - 5);
8988
}
9089

src/gui/dialog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ Dialog::draw(DrawingContext& context)
199199
// draw background rect
200200
context.color().draw_filled_rect(bg_rect.grown(12.0f),
201201
Color(g_config->menubackcolor.red, g_config->menubackcolor.green,
202-
g_config->menubackcolor.blue, (g_config->menubackcolor.alpha - (m_passive ? 0.5f : 0.0f))),
202+
g_config->menubackcolor.blue, (std::max(0.f, g_config->menubackcolor.alpha - (m_passive ? 0.5f : 0.0f)))),
203203
g_config->menuroundness + 4.f,
204204
LAYER_GUI-10);
205205

206206
context.color().draw_filled_rect(bg_rect.grown(8.0f),
207207
Color(g_config->menufrontcolor.red, g_config->menufrontcolor.green,
208-
g_config->menufrontcolor.blue, (g_config->menufrontcolor.alpha - (m_passive ? 0.3f : 0.0f))),
208+
g_config->menufrontcolor.blue, (std::max(0.f, g_config->menufrontcolor.alpha - (m_passive ? 0.3f : 0.0f)))),
209209
g_config->menuroundness,
210210
LAYER_GUI-10);
211211

@@ -220,7 +220,7 @@ Dialog::draw(DrawingContext& context)
220220
// draw HL line
221221
context.color().draw_filled_rect(Rectf(Vector(bg_rect.get_left(), bg_rect.get_bottom() - 35),
222222
Sizef(bg_rect.get_width(), 4)),
223-
Color(g_config->hlcolor), LAYER_GUI);
223+
g_config->hlcolor, LAYER_GUI);
224224
context.color().draw_filled_rect(Rectf(Vector(bg_rect.get_left(), bg_rect.get_bottom() - 35),
225225
Sizef(bg_rect.get_width(), 2)),
226226
Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);
@@ -252,7 +252,7 @@ Dialog::draw(DrawingContext& context)
252252
context.color().draw_text(Resources::normal_font, m_buttons[i].text,
253253
Vector(pos.x, pos.y - static_cast<float>(int(Resources::normal_font->get_height() / 2))),
254254
ALIGN_CENTER, LAYER_GUI,
255-
i == m_selected_button ? ColorScheme::Menu::active_color : ColorScheme::Menu::default_color);
255+
i == m_selected_button ? g_config->activetextcolor : ColorScheme::Menu::default_color);
256256
}
257257
}
258258

src/gui/item_back.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "gui/menu_manager.hpp"
2020
#include "supertux/colorscheme.hpp"
21+
#include "supertux/gameconfig.hpp"
22+
#include "supertux/globals.hpp"
2123
#include "supertux/resources.hpp"
2224
#include "video/drawing_context.hpp"
2325
#include "video/surface.hpp"
@@ -34,7 +36,7 @@ ItemBack::draw(DrawingContext& context, const Vector& pos, int menu_width, bool
3436
context.color().draw_text(Resources::normal_font, get_text(),
3537
Vector( pos.x + static_cast<float>(menu_width) / 2.0f,
3638
pos.y - static_cast<float>(int(Resources::normal_font->get_height()/2))),
37-
ALIGN_CENTER, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
39+
ALIGN_CENTER, LAYER_GUI, active ? g_config->activetextcolor : get_color());
3840
context.color().draw_surface(Resources::back,
3941
Vector(pos.x + static_cast<float>(menu_width) / 2.0f + text_width / 2.0f + 16.0f,
4042
pos.y - 8.0f),

src/gui/item_controlfield.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "gui/item_controlfield.hpp"
1818

1919
#include "supertux/colorscheme.hpp"
20+
#include "supertux/gameconfig.hpp"
21+
#include "supertux/globals.hpp"
2022
#include "supertux/resources.hpp"
2123
#include "video/drawing_context.hpp"
2224

@@ -36,7 +38,7 @@ ItemControlField::draw(DrawingContext& context, const Vector& pos, int menu_widt
3638
context.color().draw_text(Resources::normal_font, get_text(),
3739
Vector(pos.x + 16.0f,
3840
pos.y - static_cast<float>(int(Resources::normal_font->get_height()/2))),
39-
ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
41+
ALIGN_LEFT, LAYER_GUI, active ? g_config->activetextcolor : get_color());
4042
}
4143

4244
int

src/gui/item_floatfield.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "gui/item_floatfield.hpp"
1818

1919
#include "supertux/colorscheme.hpp"
20+
#include "supertux/gameconfig.hpp"
2021
#include "supertux/globals.hpp"
2122
#include "supertux/resources.hpp"
2223
#include "video/drawing_context.hpp"
@@ -56,7 +57,7 @@ ItemFloatField::draw(DrawingContext& context, const Vector& pos, int menu_width,
5657
context.color().draw_text(Resources::normal_font, get_text(),
5758
Vector(pos.x + 16.0f,
5859
pos.y - Resources::normal_font->get_height() / 2.0f),
59-
ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
60+
ALIGN_LEFT, LAYER_GUI, active ? g_config->activetextcolor : get_color());
6061
}
6162

6263
int

src/gui/item_intfield.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "gui/item_intfield.hpp"
1818

1919
#include "supertux/colorscheme.hpp"
20+
#include "supertux/gameconfig.hpp"
2021
#include "supertux/globals.hpp"
2122
#include "supertux/resources.hpp"
2223
#include "video/drawing_context.hpp"
@@ -43,7 +44,7 @@ ItemIntField::draw(DrawingContext& context, const Vector& pos, int menu_width, b
4344
context.color().draw_text(Resources::normal_font, get_text(),
4445
Vector(pos.x + 16.0f,
4546
pos.y - Resources::normal_font->get_height() / 2.0f),
46-
ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color());
47+
ALIGN_LEFT, LAYER_GUI, active ? g_config->activetextcolor : get_color());
4748
}
4849

4950
int

src/gui/item_label.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "gui/item_label.hpp"
1818

1919
#include "supertux/colorscheme.hpp"
20+
#include "supertux/gameconfig.hpp"
21+
#include "supertux/globals.hpp"
2022
#include "supertux/resources.hpp"
2123
#include "video/drawing_context.hpp"
2224

@@ -35,7 +37,7 @@ ItemLabel::draw(DrawingContext& context, const Vector& pos, int menu_width, bool
3537

3638
Color
3739
ItemLabel::get_color() const {
38-
return ColorScheme::Menu::label_color;
40+
return g_config->labeltextcolor;
3941
}
4042

4143
int

0 commit comments

Comments
 (0)