Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/base/shipmodel.cc2
-rw-r--r--src/ui/slider.cc54
-rw-r--r--src/ui/slider.h4
3 files changed, 55 insertions, 5 deletions
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index 8710aad..e52aab2 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -141,7 +141,7 @@ void ShipModel::generate_info()
add_text(str.str());
str.str("");
- str << "cargo hold: ^B" << 0.1f * maxcargo() << " ^Nmetric tonnes";
+ str << "cargo hold: ^B" << maxcargo() << " ^Ncubic meters";
add_text(str.str());
str.str("");
diff --git a/src/ui/slider.cc b/src/ui/slider.cc
index 5de82b2..b5a38f1 100644
--- a/src/ui/slider.cc
+++ b/src/ui/slider.cc
@@ -16,9 +16,15 @@ Slider::Slider(Widget *parent, const float minimum, const float maximum) : Widge
slider_maximum = maximum;
slider_value = slider_minimum;
- slider_minbutton = new ui::Button(this, "<");
+ slider_minbutton = new ui::Button(this, "<<");
slider_minbutton->set_border(false);
+ slider_decbutton = new ui::Button(this, "<");
+ slider_decbutton->set_border(false);
+
+ slider_incbutton = new ui::Button(this, ">");
+ slider_incbutton->set_border(false);
+
slider_maxbutton = new ui::Button(this, ">>");
slider_maxbutton->set_border(false);
@@ -75,16 +81,50 @@ bool Slider::on_emit(Widget *sender, const Event event, void *data)
slider_value = slider_minimum;
emit(EventSliderChanged, this);
return true;
+ } else if (sender == slider_decbutton) {
+ if (slider_value > slider_minimum) {
+ slider_value--;
+ emit(EventSliderChanged, this);
+ }
+ return true;
+ } else if (sender == slider_incbutton) {
+ if (slider_value < slider_maximum) {
+ slider_value++;
+ emit(EventSliderChanged, this);
+ }
+ return true;
} else if (sender == slider_maxbutton) {
slider_value = slider_maximum;
emit(EventSliderChanged, this);
return true;
}
}
-
return false;
}
+bool Slider::on_keypress(const int key, const unsigned int modifier)
+{
+ switch (key) {
+
+ case 512 + SDL_BUTTON_WHEELUP:
+ if (slider_value < slider_maximum) {
+ slider_value++;
+ emit(EventSliderChanged, this);
+ }
+ return true;
+ break;
+
+ case 512 + SDL_BUTTON_WHEELDOWN:
+ if (slider_value > slider_minimum) {
+ slider_value--;
+ emit(EventSliderChanged, this);
+ }
+ return true;
+ break;
+ }
+
+ return false;
+}
void Slider::resize()
{
@@ -92,17 +132,23 @@ void Slider::resize()
slider_minbutton->set_size(height(), height());
slider_minbutton->set_location(0, 0);
+ slider_decbutton->set_size(height(), height());
+ slider_decbutton->set_location(slider_minbutton->right(), 0);
+
slider_maxbutton->set_size(height(), height());
slider_maxbutton->set_location(width() - slider_maxbutton->width(), 0);
+
+ slider_incbutton->set_size(height(), height());
+ slider_incbutton->set_location(slider_maxbutton->left() - slider_incbutton->width() , 0);
}
void Slider::draw()
{
if (slider_maximum > slider_minimum) {
const float range = (slider_value - slider_minimum) / (slider_maximum - slider_minimum);
- const float x = (width() - 3.0f * height()) * range;
+ const float x = (width() - 5.0f * height()) * range;
Paint::set_color(palette()->foreground());
- Paint::draw_rectangle(math::Vector2f(global_location().x() + height() + x, global_location().y()), math::Vector2f(height(), height()));
+ Paint::draw_rectangle(math::Vector2f(global_location().x() + 2.0f * height() + x + 1, global_location().y() +1 ), math::Vector2f(height() - 2, height() - 2));
}
Widget::draw();
diff --git a/src/ui/slider.h b/src/ui/slider.h
index 8bcb427..46dfd50 100644
--- a/src/ui/slider.h
+++ b/src/ui/slider.h
@@ -82,6 +82,8 @@ protected:
virtual void draw();
virtual bool on_emit(Widget *sender, const Event event, void *data=0);
+
+ virtual bool on_keypress(const int key, const unsigned int modifier);
private:
/// validate slider value
@@ -92,6 +94,8 @@ private:
float slider_value;
Button *slider_minbutton;
+ Button *slider_decbutton;
+ Button *slider_incbutton;
Button *slider_maxbutton;
};