Skip to content

Commit

Permalink
Use same colors for Dialog as for Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Aug 25, 2014
1 parent 96a81e3 commit d3c7bde
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/gui/dialog.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/gui/menu.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand All @@ -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)
Expand All @@ -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;
}

Expand All @@ -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:
Expand All @@ -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)),
Expand Down
6 changes: 0 additions & 6 deletions src/gui/menu.hpp
Expand Up @@ -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 {
Expand Down
12 changes: 7 additions & 5 deletions src/supertux/colorscheme.cpp
Expand Up @@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "supertux/colorscheme.hpp"

#include "gui/menu.hpp"
#include "object/floating_text.hpp"
#include "object/level_time.hpp"
Expand All @@ -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);

Expand Down
38 changes: 38 additions & 0 deletions src/supertux/colorscheme.hpp
@@ -0,0 +1,38 @@
// SuperTux
// Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.

#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 */

0 comments on commit d3c7bde

Please sign in to comment.