From: Ingo Ruhnke Date: Mon, 25 Aug 2014 07:50:32 +0000 (+0200) Subject: Use same colors for Dialog as for Menu X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d3c7bde72a34de02571cac81d6a8cc6d0565d98e;p=supertux.git Use same colors for Dialog as for Menu --- diff --git a/src/gui/dialog.cpp b/src/gui/dialog.cpp index cd56c40a8..260c7bf0b 100644 --- a/src/gui/dialog.cpp +++ b/src/gui/dialog.cpp @@ -18,8 +18,10 @@ #include "control/controller.hpp" #include "gui/menu_manager.hpp" +#include "gui/menu.hpp" #include "gui/mousecursor.hpp" #include "supertux/resources.hpp" +#include "supertux/colorscheme.hpp" #include "video/drawing_context.hpp" #include "video/renderer.hpp" #include "video/video_system.hpp" @@ -209,7 +211,8 @@ Dialog::draw(DrawingContext& ctx) ctx.draw_text(Resources::normal_font, m_buttons[i].text, Vector(pos.x, pos.y - int(Resources::normal_font->get_height()/2)), - ALIGN_CENTER, LAYER_GUI); + ALIGN_CENTER, LAYER_GUI, + i == m_selected_button ? ColorScheme::Menu::active_color : ColorScheme::Menu::default_color); } } diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index a329e2533..e17764dc1 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -23,6 +23,7 @@ #include "gui/menu_item.hpp" #include "gui/menu_manager.hpp" #include "gui/mousecursor.hpp" +#include "supertux/colorscheme.hpp" #include "supertux/globals.hpp" #include "supertux/resources.hpp" #include "supertux/screen_manager.hpp" @@ -381,7 +382,7 @@ Menu::draw_item(DrawingContext& context, int index) MenuItem& pitem = *(items[index]); - Color text_color = default_color; + Color text_color = ColorScheme::Menu::default_color; float x_pos = pos.x; float y_pos = pos.y + 24*index - menu_height/2 + 12; int text_width = int(Resources::normal_font->get_text_width(pitem.text)); @@ -400,7 +401,7 @@ Menu::draw_item(DrawingContext& context, int index) if(index == active_item) { - text_color = active_color; + text_color = ColorScheme::Menu::active_color; } if(active_item == index) @@ -424,7 +425,7 @@ Menu::draw_item(DrawingContext& context, int index) { context.draw_text(Resources::normal_font, pitem.text, Vector(pos.x, y_pos - int(Resources::normal_font->get_height()/2)), - ALIGN_CENTER, LAYER_GUI, inactive_color); + ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::inactive_color); break; } @@ -446,7 +447,7 @@ Menu::draw_item(DrawingContext& context, int index) { context.draw_text(Resources::big_font, pitem.text, Vector(pos.x, y_pos - int(Resources::big_font->get_height()/2)), - ALIGN_CENTER, LAYER_GUI, label_color); + ALIGN_CENTER, LAYER_GUI, ColorScheme::Menu::label_color); break; } case MN_TEXTFIELD: @@ -459,17 +460,17 @@ Menu::draw_item(DrawingContext& context, int index) context.draw_text(Resources::normal_font, pitem.get_input_with_symbol(true), Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), - ALIGN_RIGHT, LAYER_GUI, field_color); + ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color); else context.draw_text(Resources::normal_font, pitem.get_input_with_symbol(false), Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), - ALIGN_RIGHT, LAYER_GUI, field_color); + ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color); } else context.draw_text(Resources::normal_font, pitem.input, Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), - ALIGN_RIGHT, LAYER_GUI, field_color); + ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color); context.draw_text(Resources::normal_font, pitem.text, Vector(left, y_pos - int(Resources::normal_font->get_height()/2)), diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index 5ecd3f877..8fc4ad501 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -30,12 +30,6 @@ class MenuItem; class Menu { - static Color default_color; - static Color active_color; - static Color inactive_color; - static Color label_color; - static Color field_color; - private: /* Action done on the menu */ enum MenuAction { diff --git a/src/supertux/colorscheme.cpp b/src/supertux/colorscheme.cpp index 462cfe2b9..b32b11174 100644 --- a/src/supertux/colorscheme.cpp +++ b/src/supertux/colorscheme.cpp @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include "supertux/colorscheme.hpp" + #include "gui/menu.hpp" #include "object/floating_text.hpp" #include "object/level_time.hpp" @@ -35,11 +37,11 @@ Color LevelIntro::stat_color(1.0,1.0,1.0); Color Statistics::header_color(1.0,1.0,1.0); Color Statistics::text_color(1.0,1.0,0.6); -Color Menu::default_color(1.0,1.0,1.0); -Color Menu::active_color(0.2,0.5,1.0); -Color Menu::inactive_color(0.5,0.5,0.5); -Color Menu::label_color(0.0,1.0,1.0); -Color Menu::field_color(1.0,1.0,0.6); +Color ColorScheme::Menu::default_color(1.0,1.0,1.0); +Color ColorScheme::Menu::active_color(0.2,0.5,1.0); +Color ColorScheme::Menu::inactive_color(0.5,0.5,0.5); +Color ColorScheme::Menu::label_color(0.0,1.0,1.0); +Color ColorScheme::Menu::field_color(1.0,1.0,0.6); Color PlayerStatus::text_color(1.0,1.0,0.6); diff --git a/src/supertux/colorscheme.hpp b/src/supertux/colorscheme.hpp new file mode 100644 index 000000000..870843660 --- /dev/null +++ b/src/supertux/colorscheme.hpp @@ -0,0 +1,38 @@ +// SuperTux +// Copyright (C) 2014 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_COLORSCHEME_HPP +#define HEADER_SUPERTUX_SUPERTUX_COLORSCHEME_HPP + +#include "video/color.hpp" + +class ColorScheme +{ +public: + class Menu + { + public: + static Color default_color; + static Color active_color; + static Color inactive_color; + static Color label_color; + static Color field_color; + }; +}; + +#endif + +/* EOF */