Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-12-26 12:21:48 +0000
committerStijn Buys <ingar@osirion.org>2008-12-26 12:21:48 +0000
commitb875124824794a7762414db76ed9f953b8ba320f (patch)
tree86f27d64e4a9e91a93cb4b30752f27eeec6526ac /src/ui
parentbfa10f9990a8a045b03474d11af75984c12a856a (diff)
default player settings in player.ini,
palette text colors, cleanups
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/paint.cc5
-rw-r--r--src/ui/paint.h3
-rw-r--r--src/ui/palette.cc83
-rw-r--r--src/ui/palette.h155
-rw-r--r--src/ui/ui.cc57
-rw-r--r--src/ui/ui.h3
6 files changed, 229 insertions, 77 deletions
diff --git a/src/ui/paint.cc b/src/ui/paint.cc
index 86058cf..e6f2402 100644
--- a/src/ui/paint.cc
+++ b/src/ui/paint.cc
@@ -17,6 +17,11 @@ namespace ui
// contains the interface between the user interface and the render library
namespace paint {
+void assign_color(const char c, const math::Color &color)
+{
+ render::Text::assign_color(c, color);
+}
+
void color(float r, float g, float b, float a)
{
gl::color(r, g, b, a);
diff --git a/src/ui/paint.h b/src/ui/paint.h
index 95f1c62..840e18a 100644
--- a/src/ui/paint.h
+++ b/src/ui/paint.h
@@ -15,6 +15,9 @@ namespace ui
/// low-level widget paint functions
namespace paint {
+/// assign system colors
+void assign_color(const char c, const math::Color &color);
+
/// set paint color
void color(float r=0.0f, float g=0.0f, float b=0.0f, float a=1.0f);
diff --git a/src/ui/palette.cc b/src/ui/palette.cc
index 79388d8..f8d16c1 100644
--- a/src/ui/palette.cc
+++ b/src/ui/palette.cc
@@ -10,17 +10,18 @@
namespace ui
{
-Palette::Palette()
+Palette::Palette() :
+ palette_foreground(1.0f, 1.0f),
+ palette_background(0.5f, 0.75f),
+ palette_border(0.0f, 0.8f, 0.0f, 0.5f),
+ palette_text(0.75f),
+ palette_highlight(1.0f, 1.0f, 0.5f),
+ palette_pointer(0.0f, 0.75f, 0.0f),
+ palette_active(0.0f, 1.0f, 0.0f),
+ palette_debug(0.50f, 0.75f),
+ palette_mission(1.0f, 0.5f, 1.0f)
{
- palette_foreground.assign(1.0f, 1.0f);
- palette_highlight.assign(1.0f, 1.0f, 0.5f);
- palette_text.assign(0.75f);
- palette_background.assign(0.5f, 0.75f);
- palette_border.assign(0.0f, 0.8f, 0.0f, 0.5f);
- palette_pointer.assign(0.0f, 0.75f, 0.0f);
- palette_active.assign(0.0f, 1.0f, 0.0f);
- palette_debug.assign(1.0f, 0.0f, 1.0f, 0.75f);
}
Palette::~Palette()
@@ -36,12 +37,15 @@ const math::Color &Palette::color(Color palettecolor) const
case Background:
return background();
break;
- case Highlight:
- return highlight();
- break;
case Border:
return border();
break;
+ case Text:
+ return text();
+ break;
+ case Highlight:
+ return highlight();
+ break;
case Pointer:
return pointer();
break;
@@ -50,51 +54,28 @@ const math::Color &Palette::color(Color palettecolor) const
break;
case Debug:
return debug();
+ break;
+ case Mission:
+ return mission();
+ break;
+ case Bold:
+ return bold();
+ break;
+ case Fancy:
+ return fancy();
+ break;
+ case Warning:
+ return warning();
+ break;
+ case Error:
+ return error();
+ break;
default:
return foreground();
break;
}
}
-void Palette::set_foreground(math::Color const &color)
-{
- palette_foreground.assign(color);
-}
-
-void Palette::set_highlight(math::Color const &color)
-{
- palette_highlight.assign(color);
-}
-
-void Palette::set_text(math::Color const &color)
-{
- palette_text.assign(color);
-}
-
-void Palette::set_background(math::Color const &color)
-{
- palette_background.assign(color);
-}
-
-void Palette::set_border(math::Color const &color)
-{
- palette_border.assign(color);
-}
-
-void Palette::set_pointer(math::Color const &color)
-{
- palette_pointer.assign(color);
-}
-
-void Palette::set_active(math::Color const &color)
-{
- palette_active.assign(color);
-}
-
-void Palette::set_debug(math::Color const &color)
-{
- palette_debug.assign(color);
-}
}
diff --git a/src/ui/palette.h b/src/ui/palette.h
index 1ef49c7..1aabc59 100644
--- a/src/ui/palette.h
+++ b/src/ui/palette.h
@@ -12,77 +12,190 @@
namespace ui
{
+/// color palette used by the user interface
class Palette
{
public:
+ /// default constructor, creates a default palette
Palette();
+
+ /// default destructor
~Palette();
- enum Color { Foreground=0, Background=1, Highlight=2, Border=3, Pointer=4, Active=5, Debug=6 };
+ /// color index
+ enum Color { Foreground=0, Background=1, Border=2, Text=3, Highlight=4, Pointer=5, Active=6, Debug=7, Mission=8,
+ Bold=9, Fancy=10, Warning=11, Error=12 };
+
+ /* ---- mutators ------------------------------------------- */
/// set foreground color
- void set_foreground(math::Color const &color);
+ inline void set_foreground(const math::Color &color)
+ {
+ palette_foreground.assign(color);
+ }
+
+ /// set background color
+ inline void set_background(const math::Color &color)
+ {
+ palette_background.assign(color);
+ }
+
+ /// set border color
+ inline void set_border(const math::Color &color)
+ {
+ palette_border.assign(color);
+ }
+
+ /// set text color
+ inline void set_text(const math::Color &color)
+ {
+ palette_text.assign(color);
+ }
/// set highlight color
- void set_highlight(math::Color const &color);
-
- void set_text(math::Color const &color);
+ inline void set_highlight(const math::Color &color)
+ {
+ palette_highlight.assign(color);
+ }
- void set_background(math::Color const &color);
+ /// set pointer color
+ inline void set_pointer(const math::Color &color)
+ {
+ palette_pointer.assign(color);
+ }
- void set_border(math::Color const &color);
+ /// set active pointer color
+ inline void set_active(const math::Color &color)
+ {
+ palette_active.assign(color);
+ }
- void set_pointer(math::Color const &color);
+ /// set debug color
+ inline void set_debug(const math::Color &color)
+ {
+ palette_debug.assign(color);
+ }
- void set_active(math::Color const &color);
+ /// set mission color
+ inline void set_mission(const math::Color &color)
+ {
+ palette_mission.assign(color);
+ }
- void set_debug(math::Color const &olor);
+ /// set bold text color
+ inline void set_bold(const math::Color &color)
+ {
+ palette_bold.assign(color);
+ }
- inline const math::Color &foreground() const {
- return palette_foreground;
+ /// set fancy text color
+ inline void set_fancy(const math::Color &color)
+ {
+ palette_fancy.assign(color);
}
- inline const math::Color &highlight() const {
- return palette_highlight;
+ /// set warning text color
+ inline void set_warning(const math::Color &color)
+ {
+ palette_warning.assign(color);
}
- inline const math::Color &text() const {
- return palette_text;
+ /// set error text color
+ inline void set_error(const math::Color &color)
+ {
+ palette_error.assign(color);
+ }
+
+ /* ---- inspectors ----------------------------------------- */
+
+ /// foreground color
+ inline const math::Color &foreground() const {
+ return palette_foreground;
}
+ /// background color
inline const math::Color &background() const {
return palette_background;
}
+ /// border color
inline const math::Color &border() const {
return palette_border;
}
-
+
+ /// text color
+ inline const math::Color &text() const {
+ return palette_text;
+ }
+
+ /// highlight color
+ inline const math::Color &highlight() const {
+ return palette_highlight;
+ }
+
+ /// pointer color
inline const math::Color &pointer() const {
return palette_pointer;
}
+ /// active pointer color
inline const math::Color &active() const {
return palette_active;
}
+ /// debug color
inline const math::Color &debug() const {
return palette_debug;
}
+ /// mission color
+ inline const math::Color &mission() const {
+ return palette_mission;
+ }
+
+ /// bold text color
+ inline const math::Color &bold() const {
+ return palette_bold;
+ }
+
+ /// fancy text color
+ inline const math::Color &fancy() const {
+ return palette_fancy;
+ }
+
+ /// warning text color
+ inline const math::Color &warning() const {
+ return palette_warning;
+ }
+
+ /// error text color
+ inline const math::Color &error() const {
+ return palette_error;
+ }
+
+ // indexed color
const math::Color &color(Palette::Color palettecolor) const;
private:
-
+ // UI colors
math::Color palette_foreground;
- math::Color palette_highlight;
math::Color palette_background;
+ math::Color palette_border;
+ math::Color palette_text;
+ math::Color palette_highlight;
math::Color palette_pointer;
math::Color palette_active;
- math::Color palette_border;
math::Color palette_debug;
- math::Color palette_text;
+
+ // HUD colors
+ math::Color palette_mission;
+
+ // additional text colors
+ math::Color palette_bold;
+ math::Color palette_fancy;
+ math::Color palette_warning;
+ math::Color palette_error;
};
}
diff --git a/src/ui/ui.cc b/src/ui/ui.cc
index bc6f544..b06e29b 100644
--- a/src/ui/ui.cc
+++ b/src/ui/ui.cc
@@ -44,6 +44,7 @@ void func_ui_restart(std::string const &args)
{
if (global_ui) {
global_ui->load();
+ global_ui->apply_render_options();
}
}
@@ -291,6 +292,12 @@ void UI::load()
} else if (ini.got_section("colors")) {
continue;
+ } else if (ini.got_section("hud")) {
+ continue;
+
+ } else if (ini.got_section("text")) {
+ continue;
+
} else {
ini.unknown_section();
continue;
@@ -310,12 +317,16 @@ void UI::load()
continue;
} else if (ini.got_key_float("elementwidth", w)) {
elementsize.assign(w, h);
+ continue;
} else if (ini.got_key_float("elementheight", h)) {
elementsize.assign(w, h);
+ continue;
} else if (ini.got_key_float("elementmargin", m)) {
elementmargin = m;
+ continue;
} else {
ini.unkown_key();
+ continue;
}
} else if (ini.in_section("colors")) {
@@ -323,26 +334,51 @@ void UI::load()
if (ini.got_key_color("foreground", color)) {
ui_palette->set_foreground(color);
continue;
- } else if (ini.got_key_color("highlight", color)) {
- ui_palette->set_highlight(color);
- continue;
- } else if (ini.got_key_color("text", color)) {
- ui_palette->set_text(color);
} else if (ini.got_key_color("background", color)) {
ui_palette->set_background(color);
continue;
} else if (ini.got_key_color("border", color)) {
ui_palette->set_border(color);
continue;
+ } else if (ini.got_key_color("text", color)) {
+ ui_palette->set_text(color);
+ } else if (ini.got_key_color("highlight", color)) {
+ ui_palette->set_highlight(color);
+ continue;
} else if (ini.got_key_color("pointer", color)) {
ui_palette->set_pointer(color);
+ continue;
} else if (ini.got_key_color("active", color)) {
ui_palette->set_active(color);
+ continue;
} else if (ini.got_key_color("debug", color)) {
ui_palette->set_debug(color);
+ continue;
} else {
ini.unkown_key();
+ continue;
}
+
+ } else if (ini.in_section("hud")) {
+
+ if (ini.got_key_color("mission", color)) {
+ ui_palette->set_mission(color);
+ continue;
+ } else {
+ ini.unkown_key();
+ continue;
+ }
+
+ } else if (ini.in_section("text")) {
+ } else if (ini.got_key_color("bold", color)) {
+ ui_palette->set_bold(color);
+ } else if (ini.got_key_color("fancy", color)) {
+ ui_palette->set_fancy(color);
+ } else if (ini.got_key_color("warning", color)) {
+ ui_palette->set_warning(color);
+ } else if (ini.got_key_color("error", color)) {
+ ui_palette->set_error(color);
+ continue;
}
}
}
@@ -376,6 +412,17 @@ void UI::load()
menu->add_button("Join", "join; menu hide");
menu->add_button("Game menu", "menu game");
}
+}
+
+void UI::apply_render_options()
+{
+ // apply palette colors
+ paint::assign_color('N', palette()->text());
+ paint::assign_color('D', palette()->debug());
+ paint::assign_color('B', palette()->bold());
+ paint::assign_color('F', palette()->fancy());
+ paint::assign_color('W', palette()->warning());
+ paint::assign_color('E', palette()->error());
}
diff --git a/src/ui/ui.h b/src/ui/ui.h
index ae42ad6..95577cf 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -33,6 +33,9 @@ public:
/// reload menu files
void load();
+
+ /// apply UI options to the render engine
+ void apply_render_options();
/// make a window the active window
void show_menu(const char *label);