Use same colors for Dialog as for Menu
authorIngo Ruhnke <grumbel@gmail.com>
Mon, 25 Aug 2014 07:50:32 +0000 (09:50 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Mon, 25 Aug 2014 07:54:14 +0000 (09:54 +0200)
src/gui/dialog.cpp
src/gui/menu.cpp
src/gui/menu.hpp
src/supertux/colorscheme.cpp
src/supertux/colorscheme.hpp [new file with mode: 0644]

index cd56c40..260c7bf 100644 (file)
 
 #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);
   }
 }
 
index a329e25..e17764d 100644 (file)
@@ -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)),
index 5ecd3f8..8fc4ad5 100644 (file)
@@ -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 {
index 462cfe2..b32b111 100644 (file)
@@ -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"
@@ -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 (file)
index 0000000..8708436
--- /dev/null
@@ -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 */