Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am2
-rw-r--r--src/client/audiosettingsmenu.cc5
-rw-r--r--src/client/graphicssettingsmenu.cc407
-rw-r--r--src/client/graphicssettingsmenu.h92
-rw-r--r--src/client/mainmenu.cc12
5 files changed, 512 insertions, 6 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 8e0124f..391892a 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -21,6 +21,7 @@ noinst_HEADERS = \
entitymenu.h \
galaxymapwidget.h \
gamewindow.h \
+ graphicssettingsmenu.h \
hud.h \
hudenginestatus.h \
hudplayerstatus.h \
@@ -61,6 +62,7 @@ libclient_la_SOURCES = \
entitymenu.cc \
galaxymapwidget.cc \
gamewindow.cc \
+ graphicssettingsmenu.cc \
hud.cc \
hudenginestatus.cc \
hudplayerstatus.cc \
diff --git a/src/client/audiosettingsmenu.cc b/src/client/audiosettingsmenu.cc
index 07a1009..b09586a 100644
--- a/src/client/audiosettingsmenu.cc
+++ b/src/client/audiosettingsmenu.cc
@@ -69,20 +69,19 @@ AudioSettingsMenu::AudioSettingsMenu(ui::Widget *parent, const char *label) : ui
_enginevolumeslider->set_border(true);
_enginevolumeslider->set_range(0.0f, 100.0f);
-
- // doppler effect
+ // options label
_optionslabel = new ui::Label(_frame);
_optionslabel->set_label("options");
_optionslabel->set_background(false);
_optionslabel->set_border(false);
_optionslabel->set_text("Options");
+ // doppler effect checkbox
_dopplercheckbox = new ui::Checkbox(_frame);
_dopplercheckbox->set_label("snd_doppler");
_dopplercheckbox->set_text("Enable doppler effect (requires sound restart)");
_dopplercheckbox->set_border(true);
-
// apply button
_applybutton = new ui::Button(_frame, "Apply");
_applybutton->set_label("apply");
diff --git a/src/client/graphicssettingsmenu.cc b/src/client/graphicssettingsmenu.cc
new file mode 100644
index 0000000..ab05635
--- /dev/null
+++ b/src/client/graphicssettingsmenu.cc
@@ -0,0 +1,407 @@
+/*
+ client/graphicssettingsmenu.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "client/graphicssettingsmenu.h"
+#include "core/cvar.h"
+#include "ui/button.h"
+#include "ui/checkbox.h"
+#include "ui/iconbutton.h"
+#include "ui/label.h"
+#include "ui/ui.h"
+#include "math/functions.h"
+
+#include <iostream>
+
+namespace client {
+
+GraphicsSettingsMenu::GraphicsSettingsMenu(ui::Widget *parent, const char *label) : ui::Window(parent)
+{
+ set_label(label);
+ set_border(true);
+ set_background(true);
+ set_font(ui::root()->font_small());
+
+ // window title
+ _titlelabel = new ui::Label(this);
+ _titlelabel->set_label("title");
+ _titlelabel->set_background(false);
+ _titlelabel->set_border(false);
+ _titlelabel->set_font(ui::root()->font_large());
+ _titlelabel->set_alignment(ui::AlignCenter);
+ _titlelabel->set_text("GRAPHICS SETTINGS");
+
+ // close button
+ _closebutton = new ui::IconButton(_titlelabel, "bitmaps/icons/window_close");
+
+ // content frame
+ _frame = new ui::Widget(this);
+ _frame->set_label("frame");
+ _frame->set_background(true);
+ _frame->set_border(true);
+ _frame->set_focus();
+
+ // options
+
+ _optionslabel = new ui::Label(_frame);
+ _optionslabel->set_label("options");
+ _optionslabel->set_background(false);
+ _optionslabel->set_border(false);
+ _optionslabel->set_text("Options");
+
+ _optionfullscreencheckbox = new ui::Checkbox(_frame);
+ _optionfullscreencheckbox->set_label("r_fullscreen");
+ _optionfullscreencheckbox->set_text("Fullscreen");
+ _optionfullscreencheckbox->set_border(true);
+
+ _optiongridcheckbox = new ui::Checkbox(_frame);
+ _optiongridcheckbox->set_label("r_grid");
+ _optiongridcheckbox->set_text("Draw space grid");
+ _optiongridcheckbox->set_border(true);
+
+ _optionskycheckbox = new ui::Checkbox(_frame);
+ _optionskycheckbox->set_label("r_sky");
+ _optionskycheckbox->set_text("Draw sky");
+ _optionskycheckbox->set_border(true);
+
+ _optionparticlescheckbox = new ui::Checkbox(_frame);
+ _optionparticlescheckbox->set_label("r_particles");
+ _optionparticlescheckbox->set_text("Draw particles");
+ _optionparticlescheckbox->set_border(true);
+
+ _optionindicatorscheckbox = new ui::Checkbox(_frame);
+ _optionindicatorscheckbox->set_label("r_indicators");
+ _optionindicatorscheckbox->set_text("Draw direction indicators");
+ _optionindicatorscheckbox->set_border(true);
+
+
+ _debuglabel = new ui::Label(_frame);
+ _debuglabel->set_label("debug");
+ _debuglabel->set_background(false);
+ _debuglabel->set_border(false);
+ _debuglabel->set_text("Debug");
+
+ _debugstatscheckbox = new ui::Checkbox(_frame);
+ _debugstatscheckbox->set_label("draw_stats");
+ _debugstatscheckbox->set_text("Draw FPS and statistics");
+ _debugstatscheckbox->set_border(true);
+
+ _debugwireframecheckbox = new ui::Checkbox(_frame);
+ _debugwireframecheckbox->set_label("r_wireframe");
+ _debugwireframecheckbox->set_text("Draw wireframe");
+ _debugwireframecheckbox->set_border(true);
+
+ _debugkeypresscheckbox = new ui::Checkbox(_frame);
+ _debugkeypresscheckbox->set_label("draw_keypressq");
+ _debugkeypresscheckbox->set_text("Draw keypress events");
+ _debugkeypresscheckbox->set_border(true);
+
+ _debugphysicscheckbox = new ui::Checkbox(_frame);
+ _debugphysicscheckbox->set_label("draw_physics");
+ _debugphysicscheckbox->set_text("Draw physics entities (singleplayer only)");
+ _debugphysicscheckbox->set_border(true);
+
+ // apply button
+ _applybutton = new ui::Button(_frame, "Apply");
+ _applybutton->set_label("apply");
+
+ // reset button
+ _resetbutton = new ui::Button(_frame, "Reset");
+ _resetbutton->set_label("reset");
+}
+
+GraphicsSettingsMenu::~GraphicsSettingsMenu()
+{
+}
+
+void GraphicsSettingsMenu::show()
+{
+ refresh();
+ ui::Window::show();
+}
+
+void GraphicsSettingsMenu::refresh()
+{
+ math::Color color;
+
+ // fullscreen
+ if (core::Cvar *cv_fullscreen = core::Cvar::find("r_fullscreen"))
+ {
+ _optionfullscreencheckbox->set_value(cv_fullscreen->value() > 0.0f);
+ _optionfullscreencheckbox->set_enabled(true);
+ }
+ else
+ {
+ _optionfullscreencheckbox->set_value(false);
+ _optionfullscreencheckbox->set_enabled(false);
+ }
+
+ // space grid
+ if (core::Cvar *cv_grid = core::Cvar::find("r_grid"))
+ {
+ _optiongridcheckbox->set_value(cv_grid->value() > 0.0f);
+ _optiongridcheckbox->set_enabled(true);
+ }
+ else
+ {
+ _optiongridcheckbox->set_value(false);
+ _optiongridcheckbox->set_enabled(false);
+ }
+
+ // sky
+ if (core::Cvar *cv_sky = core::Cvar::find("r_sky"))
+ {
+ _optionskycheckbox->set_value(cv_sky->value() > 0.0f);
+ _optionskycheckbox->set_enabled(true);
+ }
+ else
+ {
+ _optionskycheckbox->set_value(false);
+ _optionskycheckbox->set_enabled(false);
+ }
+
+ // particles
+ if (core::Cvar *cv_particles = core::Cvar::find("r_particles"))
+ {
+ _optionparticlescheckbox->set_value(cv_particles->value() > 0.0f);
+ _optionparticlescheckbox->set_enabled(true);
+ }
+ else
+ {
+ _optionparticlescheckbox->set_value(false);
+ _optionparticlescheckbox->set_enabled(false);
+ }
+
+ // indicators
+ if (core::Cvar *cv_indicators = core::Cvar::find("r_indicators"))
+ {
+ _optionindicatorscheckbox->set_value(cv_indicators->value() > 0.0f);
+ _optionindicatorscheckbox->set_enabled(true);
+ }
+ else
+ {
+ _optionindicatorscheckbox->set_value(false);
+ _optionindicatorscheckbox->set_enabled(false);
+ }
+
+ // stats
+ if (core::Cvar *cv_stats = core::Cvar::find("draw_stats"))
+ {
+ _debugstatscheckbox->set_value(cv_stats->value() > 0.0f);
+ _debugstatscheckbox->set_enabled(true);
+ }
+ else
+ {
+ _debugstatscheckbox->set_value(false);
+ _debugstatscheckbox->set_enabled(false);
+ }
+
+ // wireframe
+ if (core::Cvar *cv_wireframe = core::Cvar::find("r_wireframe"))
+ {
+ _debugwireframecheckbox->set_value(cv_wireframe->value() > 0.0f);
+ _debugwireframecheckbox->set_enabled(true);
+ }
+ else
+ {
+ _debugwireframecheckbox->set_value(false);
+ _debugwireframecheckbox->set_enabled(false);
+ }
+
+ // keypress
+ if (core::Cvar *cv_keypress = core::Cvar::find("draw_keypress"))
+ {
+ _debugkeypresscheckbox->set_value(cv_keypress->value() > 0.0f);
+ _debugkeypresscheckbox->set_enabled(true);
+ }
+ else
+ {
+ _debugkeypresscheckbox->set_value(false);
+ _debugkeypresscheckbox->set_enabled(false);
+ }
+
+ // physics
+ if (core::Cvar *cv_physics = core::Cvar::find("r_physics"))
+ {
+ _debugphysicscheckbox->set_value(cv_physics->value() > 0.0f);
+ _debugphysicscheckbox->set_enabled(true);
+ }
+ else
+ {
+ _debugphysicscheckbox->set_value(false);
+ _debugphysicscheckbox->set_enabled(false);
+ }
+
+}
+
+void GraphicsSettingsMenu::apply()
+{
+
+ // fullscreen
+ if (core::Cvar *cv_fullscreen = core::Cvar::find("r_fullscreen"))
+ {
+ cv_fullscreen->assign(_optionfullscreencheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // space grid
+ if (core::Cvar *cv_grid = core::Cvar::find("r_grid"))
+ {
+ cv_grid->assign(_optiongridcheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // sky
+ if (core::Cvar *cv_sky = core::Cvar::find("r_sky"))
+ {
+ cv_sky->assign(_optionskycheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // particles
+ if (core::Cvar *cv_particles = core::Cvar::find("r_particles"))
+ {
+ cv_particles->assign(_optionparticlescheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // indicators
+ if (core::Cvar *cv_indicators = core::Cvar::find("r_indicators"))
+ {
+ cv_indicators->assign(_optionindicatorscheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // stats
+ if (core::Cvar *cv_stats = core::Cvar::find("draw_stats"))
+ {
+ cv_stats->assign(_debugstatscheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // wireframe
+ if (core::Cvar *cv_wireframe = core::Cvar::find("r_wireframe"))
+ {
+ cv_wireframe->assign(_debugwireframecheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // keypress
+ if (core::Cvar *cv_keypress = core::Cvar::find("draw_keypress"))
+ {
+ cv_keypress->assign(_debugkeypresscheckbox->value() ? 1.0f : 0.0f);
+ }
+
+ // physics
+ if (core::Cvar *cv_physics = core::Cvar::find("r_physics"))
+ {
+ cv_physics->assign(_debugphysicscheckbox->value() ? 1.0f : 0.0f);
+ }
+}
+
+void GraphicsSettingsMenu::resize()
+{
+ const float padding = ui::UI::padding;
+ const float margin = ui::UI::margin;
+
+ // resize title label
+ _titlelabel->set_size(width() - padding * 2.0f, _titlelabel->font()->height());
+ _titlelabel->set_location(padding, padding);
+
+ // resize close button
+ _closebutton->set_size(_titlelabel->font()->height(), _titlelabel->font()->height());
+ _closebutton->set_location(_titlelabel->width() - _closebutton->width(), 0);
+
+ // resize content frame
+ _frame->set_location(_titlelabel->left(), _titlelabel->bottom() + padding);
+ _frame->set_size(_titlelabel->width(), height() - _titlelabel->bottom() - padding * 2.0f);
+
+ //---- inside _frame ----
+
+ const float h = _frame->font()->height() + margin;
+ const float w = _frame->width() - ui::UI::elementsize.width() - 3.0f * padding;
+
+ // OPTIONS
+ _optionslabel->set_location(padding, padding);
+ _optionslabel->set_size(ui::UI::elementsize.width(),h);
+
+ // fullscreen
+ _optionfullscreencheckbox->set_location(_optionslabel->right() + padding, _optionslabel->top());
+ _optionfullscreencheckbox->set_size(w, h);
+
+ // grid
+ _optiongridcheckbox->set_location(_optionslabel->right() + padding, _optionfullscreencheckbox->bottom() + margin);
+ _optiongridcheckbox->set_size(w, h);
+
+ // sky
+ _optionskycheckbox->set_location(_optionslabel->right() + padding, _optiongridcheckbox->bottom() + margin);
+ _optionskycheckbox->set_size(w, h);
+
+ // particles
+ _optionparticlescheckbox->set_location(_optionslabel->right() + padding, _optionskycheckbox->bottom() + margin);
+ _optionparticlescheckbox->set_size(w, h);
+
+ // indicators
+ _optionindicatorscheckbox->set_location(_optionslabel->right() + padding, _optionparticlescheckbox->bottom() + margin);
+ _optionindicatorscheckbox->set_size(w, h);
+
+ // DEBUG OPTIONS
+ _debuglabel->set_location(padding, _optionindicatorscheckbox->bottom() + padding);
+ _debuglabel->set_size(ui::UI::elementsize.width(), h);
+
+ // stats
+ _debugstatscheckbox->set_location(_debuglabel->right() + padding, _debuglabel->top());
+ _debugstatscheckbox->set_size(w, h);
+
+ // wireframe
+ _debugwireframecheckbox->set_location(_debuglabel->right() + padding, _debugstatscheckbox->bottom() + margin);
+ _debugwireframecheckbox->set_size(w,h);
+
+ // keypress
+ _debugkeypresscheckbox->set_location(_debuglabel->right() + padding, _debugwireframecheckbox->bottom() + margin);
+ _debugkeypresscheckbox->set_size(w,h);
+
+ // physics
+ _debugphysicscheckbox->set_location(_debuglabel->right() + padding, _debugkeypresscheckbox->bottom() + margin);
+ _debugphysicscheckbox->set_size(w,h);
+
+
+ // resize apply button
+ _applybutton->set_size(ui::UI::elementsize);
+ _applybutton->set_location(
+ (_frame->width() - 2.0f * ui::UI::elementsize.width() - padding) * 0.5f,
+ _frame->height() - _applybutton->height() - padding
+ );
+
+ // resize reset button
+ _resetbutton->set_size(ui::UI::elementsize);
+ _resetbutton->set_location(_applybutton->right() + padding, _applybutton->top());
+
+}
+
+bool GraphicsSettingsMenu::on_emit(ui::Widget *sender, const ui::Widget::Event event, void *data)
+{
+ if (sender == _closebutton)
+ {
+ if (event == ui::Widget::EventButtonClicked)
+ {
+ parent()->hide();
+ return true;
+ }
+ }
+ else if (sender == _applybutton)
+ {
+ if (event == ui::Widget::EventButtonClicked)
+ {
+ apply();
+ return true;
+ }
+ }
+ else if (sender == _resetbutton)
+ {
+ if (event == ui::Widget::EventButtonClicked)
+ {
+ refresh();
+ return true;
+ }
+ }
+
+ return Window::on_emit(sender, event, data);
+}
+
+} // namespace client
diff --git a/src/client/graphicssettingsmenu.h b/src/client/graphicssettingsmenu.h
new file mode 100644
index 0000000..b25215a
--- /dev/null
+++ b/src/client/graphicssettingsmenu.h
@@ -0,0 +1,92 @@
+/*
+ client/graphicssettingsmenu.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_GRAPHICSSETTINGSMENU_H__
+#define __INCLUDED_CLIENT_GRAPHICSSETTINGSMENU_H__
+
+#include "ui/window.h"
+
+namespace ui
+{
+ class Button;
+ class Checkbox;
+ class IconButton;
+ class Label;
+ class Slider;
+}
+
+namespace client
+{
+
+/**
+ * @brief the audio settings menu
+ * */
+class GraphicsSettingsMenu : public ui::Window
+{
+public:
+ /**
+ * @brief default constructor
+ * */
+ GraphicsSettingsMenu(ui::Widget *parent = 0, const char *label = 0);
+
+ /**
+ * @brief default destructor
+ * */
+ virtual ~GraphicsSettingsMenu();
+
+ /**
+ * @brief show window
+ * */
+ virtual void show();
+
+protected:
+ /**
+ * @brief emit event handler
+ * */
+ virtual bool on_emit(ui::Widget *sender, const ui::Widget::Event event, void *data);
+
+ /**
+ * @brief resize event handler
+ * */
+ virtual void resize();
+
+private:
+ /**
+ * @brief refresh widget content
+ * */
+ void refresh();
+
+ /**
+ * @brief apply changes
+ * */
+ void apply();
+
+ ui::Label *_titlelabel;
+ ui::IconButton *_closebutton;
+
+ ui::Widget *_frame;
+
+ ui::Label *_optionslabel;
+ ui::Checkbox *_optionfullscreencheckbox;
+ ui::Checkbox *_optiongridcheckbox;
+ ui::Checkbox *_optionskycheckbox;
+ ui::Checkbox *_optionparticlescheckbox;
+ ui::Checkbox *_optionindicatorscheckbox;
+
+ ui::Label *_debuglabel;
+ ui::Checkbox *_debugstatscheckbox;
+ ui::Checkbox *_debugwireframecheckbox;
+ ui::Checkbox *_debugkeypresscheckbox;
+ ui::Checkbox *_debugphysicscheckbox;
+
+ ui::Button *_applybutton;
+ ui::Button *_resetbutton;
+};
+
+}
+
+#endif // __INCLUDED_CLIENT_GRAPHICSSETTINGSMENU_H__
+
diff --git a/src/client/mainmenu.cc b/src/client/mainmenu.cc
index d9250bc..823ebfb 100644
--- a/src/client/mainmenu.cc
+++ b/src/client/mainmenu.cc
@@ -7,6 +7,7 @@
#include "client/audiosettingsmenu.h"
#include "client/buttonmenu.h"
#include "client/controlsettingsmenu.h"
+#include "client/graphicssettingsmenu.h"
#include "client/mainmenu.h"
#include "client/playersettingsmenu.h"
#include "client/savegamemenu.h"
@@ -195,13 +196,18 @@ void MainMenu::load()
mainmenu_joinmenu = (ui::Widget *) new ButtonMenu(this, "join");
static_cast<ButtonMenu *>(mainmenu_joinmenu)->set_compact();
+ // graphics settings menu
+ new GraphicsSettingsMenu(this, "graphics");
+
// audio settings menu
new AudioSettingsMenu(this, "audio");
- // control settings menu
- new ControlSettingsMenu(this, "controls");
// player settings menu
- new PlayerSettingsMenu(this, "player");
+ new PlayerSettingsMenu(this, "player");
+
+ // controls menu
+ new ControlSettingsMenu(this, "controls");
+
// load custom menus, this needs to be done before the
// non-buttonmenu child widgets are created