Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
committerStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
commitf030154fe727e25a2afe1f78b3998c2d2dba95e4 (patch)
treecd92baf9e4fa8a136523b9eb570e9811846c9250 /src/ui/ui.cc
parent5636fad174f0bcff857c357c394c4cc8d424b302 (diff)
astyle cleanup, corrects not loading of material textures
Diffstat (limited to 'src/ui/ui.cc')
-rw-r--r--src/ui/ui.cc86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/ui/ui.cc b/src/ui/ui.cc
index f734a50..a6d54ab 100644
--- a/src/ui/ui.cc
+++ b/src/ui/ui.cc
@@ -41,7 +41,7 @@ UI *root()
void init()
{
con_print << "^BInitializing user interface..." << std::endl;
-
+
if (!global_ui) {
global_ui = new UI();
} else {
@@ -50,7 +50,7 @@ void init()
}
global_ui->load_menus();
- global_ui->load_settings();
+ global_ui->load_settings();
}
void shutdown()
@@ -71,19 +71,19 @@ UI::UI() : Window(0)
set_size(1024, 768);
set_border(false);
set_background(false);
-
+
// intialize console
ui_console = new Console(this);
// default palette
ui_palette = new Palette();
set_palette(ui_palette);
-
+
// default fonts
ui_font_small = new Font("gui", 12, 18);
ui_font_large = new Font("gui", 14, 24);
set_font(ui_font_small);
-
+
ui_mouse_focus = this;
ui_input_focus = this;
set_focus();
@@ -95,7 +95,7 @@ UI::UI() : Window(0)
UI::~UI()
{
delete ui_palette;
-
+
delete ui_font_small;
delete ui_font_large;
}
@@ -121,7 +121,7 @@ void UI::load_menus()
Button *button = 0;
Label *label = 0;
Menu *menu = 0;
-
+
while (ini.getline()) {
if (ini.got_section()) {
if (ini.got_section("menu")) {
@@ -131,10 +131,10 @@ void UI::load_menus()
} else if (menu) {
if (ini.got_section("button")) {
button = menu->add_button();
-
+
} else if (ini.got_section("label")) {
label = menu->add_label();
-
+
} else {
ini.unknown_section();
}
@@ -155,14 +155,14 @@ void UI::load_menus()
if (ini.got_key_string("text", strval)) {
aux::strip_quotes(strval);
button->set_text(strval);
-
+
} else if (ini.got_key_string("command", strval)) {
- for (size_t i =0; i <= strval.size(); i++) {
+ for (size_t i = 0; i <= strval.size(); i++) {
if (strval[i] == ',') strval[i] = ';';
}
aux::strip_quotes(strval);
button->set_command(strval);
-
+
} else if (ini.got_key_string("align", strval)) {
aux::to_label(strval);
if (strval.compare("left") == 0) {
@@ -195,7 +195,7 @@ void UI::load_menus()
ini.unkown_key();
}
}
-
+
}
}
@@ -211,7 +211,7 @@ void UI::load_menus()
menu->add_button("Connect", "connect");
menu->add_button("Quit", "quit");
}
-
+
// fallback game menu
if (!find_menu("game")) {
con_warn << "menu 'game' not found, using default" << std::endl;
@@ -236,16 +236,16 @@ void UI::load_settings()
{
ui_mouse_focus = this;
-
+
std::string filename("ui");
filesystem::IniFile ini;
ini.open(filename);
-
+
if (!ini.is_open()) {
con_error << "Could not open " << ini.name() << std::endl;
return;
}
-
+
std::string strval;
math::Color color;
@@ -253,16 +253,16 @@ void UI::load_settings()
float h = elementsize.height();
float m = elementmargin;
-
+
while (ini.getline()) {
-
+
if (ini.got_section()) {
if (ini.got_section("ui")) {
continue;
-
+
} else if (ini.got_section("colors")) {
continue;
-
+
} else if (ini.got_section("hud")) {
continue;
@@ -273,9 +273,9 @@ void UI::load_settings()
ini.unknown_section();
continue;
}
-
+
} else if (ini.got_key()) {
-
+
if (ini.in_section("ui")) {
if (ini.got_key_float("elementwidth", w)) {
elementsize.assign(w, h);
@@ -290,9 +290,9 @@ void UI::load_settings()
ini.unkown_key();
continue;
}
-
+
} else if (ini.in_section("colors")) {
-
+
if (ini.got_key_color("foreground", color)) {
ui_palette->set_foreground(color);
continue;
@@ -352,7 +352,7 @@ void UI::load_settings()
}
}
}
-
+
ini.close();
}
@@ -388,7 +388,7 @@ UI::Menus::iterator UI::find_menu(Window *menu)
if ((*it) == menu)
return it;
}
-
+
return it;
}
@@ -418,13 +418,13 @@ void UI::add_menu(Window *menu)
if (it == ui_menus.end()) {
ui_menus.push_back(menu);
}
-
+
}
void UI::show_menu(const char *label)
{
Window *menu = find_menu(label);
-
+
if (menu) {
if (ui_active_menu) {
ui_active_menu->hide();
@@ -438,7 +438,7 @@ void UI::show_menu(const char *label)
ui_active_menu = menu;
ui_active_menu->event_resize();
ui_active_menu->show();
-
+
set_pointer("pointer");
// raise console if it is visible
@@ -524,17 +524,17 @@ bool UI::input_key(const bool pressed, const int key, const unsigned int modifie
bool UI::on_keypress(const int key, const unsigned int modifier)
{
- switch( key ) {
-
- case SDLK_ESCAPE:
- if (active()) {
- hide_menu();
- audio::play("ui/menu");
- }
- return true;
- break;
- default:
- break;
+ switch (key) {
+
+ case SDLK_ESCAPE:
+ if (active()) {
+ hide_menu();
+ audio::play("ui/menu");
+ }
+ return true;
+ break;
+ default:
+ break;
}
return false;
@@ -570,7 +570,7 @@ void UI::draw_pointer()
paint::color(c);
math::Vector2f pos(mouse_cursor.x() - pointer_size * 0.5f, mouse_cursor.y() - pointer_size * 0.5f);
math::Vector2f s(pointer_size, pointer_size);
-
+
std::string texture("pointers/");
texture.append(mouse_pointer_bitmap);
@@ -578,7 +578,7 @@ void UI::draw_pointer()
gl::push();
gl::translate(mouse_cursor.x(), mouse_cursor.y(), 0);
- float angle = core::application()->time()* 0.75f - floorf(core::application()->time() * 0.75f);
+ float angle = core::application()->time() * 0.75f - floorf(core::application()->time() * 0.75f);
angle *= 360.0f;
gl::rotate(angle, math::Vector3f(0, 0, 1.0f));
gl::translate(-mouse_cursor.x(), -mouse_cursor.y(), 0);