[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3639 - in trunk/pingus: data/data data/images/core/demo sr
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3639 - in trunk/pingus: data/data data/images/core/demo src src/gui |
Date: |
Thu, 3 Jul 2008 05:46:31 +0200 |
Author: grumbel
Date: 2008-07-03 05:46:29 +0200 (Thu, 03 Jul 2008)
New Revision: 3639
Added:
trunk/pingus/data/images/core/demo/highlight.png
Modified:
trunk/pingus/data/data/core.res
trunk/pingus/src/demo_session.cpp
trunk/pingus/src/demo_session.hpp
trunk/pingus/src/gui/component.hpp
trunk/pingus/src/gui/gui_manager.cpp
Log:
Added indication when pause or fastforward is active
Modified: trunk/pingus/data/data/core.res
===================================================================
--- trunk/pingus/data/data/core.res 2008-07-03 03:45:57 UTC (rev 3638)
+++ trunk/pingus/data/data/core.res 2008-07-03 03:46:29 UTC (rev 3639)
@@ -19,6 +19,10 @@
(section (name "core")
(section (name "demo")
(sprite
+ (name "highlight")
+ (image-file "../images/core/demo/highlight.png"))
+
+ (sprite
(name "fastforward")
(image-file "../images/core/demo/fastforward.png"))
(sprite
Added: trunk/pingus/data/images/core/demo/highlight.png
===================================================================
(Binary files differ)
Property changes on: trunk/pingus/data/images/core/demo/highlight.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: trunk/pingus/src/demo_session.cpp
===================================================================
--- trunk/pingus/src/demo_session.cpp 2008-07-03 03:45:57 UTC (rev 3638)
+++ trunk/pingus/src/demo_session.cpp 2008-07-03 03:46:29 UTC (rev 3639)
@@ -31,18 +31,42 @@
#include "components/smallmap.hpp"
#include "screen/screen_manager.hpp"
#include "display/display.hpp"
+#include "resource.hpp"
#include "demo_session.hpp"
+static bool false_func() { return false; }
+
class BButton : public GUI::SurfaceButton
{
private:
+ Sprite highlight;
boost::function<void(void)> callback;
+ boost::function<bool(void)> highlight_func;
+
public:
- BButton(int x, int y, const std::string& name, boost::function<void (void)>
callback_)
+ BButton(int x, int y, const std::string& name,
+ boost::function<void (void)> callback_,
+ boost::function<bool(void)> highlight_func_ = &false_func)
: SurfaceButton(x, y, name, name + "-pressed", name + "-hover"),
- callback(callback_)
+ highlight(Resource::load_sprite("core/demo/highlight")),
+ callback(callback_),
+ highlight_func(highlight_func_)
{}
+ virtual void draw (DrawingContext& gc)
+ {
+
+ if (highlight_func())
+ {
+ gc.draw(button_pressed_surface, Vector2i(x_pos, y_pos));
+ gc.draw(highlight, Vector2i(x_pos, y_pos));
+ }
+ else
+ {
+ SurfaceButton::draw(gc);
+ }
+ }
+
void on_click() {
callback();
}
@@ -83,9 +107,11 @@
gui_manager->add(small_map, true);
gui_manager->add(new BButton(32+50, 32, "core/demo/fastforward",
-
boost::bind(&DemoSession::on_fast_forward_press, this)), true);
+
boost::bind(&DemoSession::on_fast_forward_press, this),
+ boost::bind(&DemoSession::is_fast_forward,
this)), true);
gui_manager->add(new BButton(32, 32, "core/demo/pause",
- boost::bind(&DemoSession::on_pause_press,
this)), true);
+ boost::bind(&DemoSession::on_pause_press, this),
+ boost::bind(&DemoSession::is_pause, this)),
true);
gui_manager->add(new BButton(Display::get_width() - 32 - 48, 32,
"core/demo/reload",
boost::bind(&DemoSession::restart, this)),
true);
}
@@ -185,11 +211,11 @@
}
void
-DemoSession::process_scroll_event(const Input::ScrollEvent& ev)
+DemoSession::on_scroller_move(float x, float y)
{
// FIXME: Rounding considered evil?
- playfield->scroll(static_cast<int>(-ev.x_delta),
- static_cast<int>(-ev.y_delta));
+ playfield->scroll(static_cast<int>(-x),
+ static_cast<int>(-y));
}
void
Modified: trunk/pingus/src/demo_session.hpp
===================================================================
--- trunk/pingus/src/demo_session.hpp 2008-07-03 03:45:57 UTC (rev 3638)
+++ trunk/pingus/src/demo_session.hpp 2008-07-03 03:46:29 UTC (rev 3639)
@@ -67,7 +67,10 @@
void restart();
- void process_scroll_event(const Input::ScrollEvent& ev);
+ void on_scroller_move(float x, float y);
+
+ bool is_pause() { return pause; }
+ bool is_fast_forward() { return fast_forward; }
private:
DemoSession (const DemoSession&);
DemoSession& operator= (const DemoSession&);
Modified: trunk/pingus/src/gui/component.hpp
===================================================================
--- trunk/pingus/src/gui/component.hpp 2008-07-03 03:45:57 UTC (rev 3638)
+++ trunk/pingus/src/gui/component.hpp 2008-07-03 03:46:29 UTC (rev 3639)
@@ -82,6 +82,8 @@
coordinates */
virtual void on_pointer_move (int x, int y) { UNUSED_ARG(x); UNUSED_ARG(y); }
+ virtual void on_scroller_move (float x, float y) { UNUSED_ARG(x);
UNUSED_ARG(y); }
+
/** Emitted whenever a keyboard character is pressed. Only certain
components should implement this */
virtual void on_key_pressed(const unsigned short c) { UNUSED_ARG(c); }
Modified: trunk/pingus/src/gui/gui_manager.cpp
===================================================================
--- trunk/pingus/src/gui/gui_manager.cpp 2008-07-03 03:45:57 UTC (rev
3638)
+++ trunk/pingus/src/gui/gui_manager.cpp 2008-07-03 03:46:29 UTC (rev
3639)
@@ -87,6 +87,7 @@
break;
case Input::SCROLLER_EVENT_TYPE:
+ on_scroller_move(event.scroll.x_delta, event.scroll.y_delta);
break;
default:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3639 - in trunk/pingus: data/data data/images/core/demo src src/gui,
grumbel at BerliOS <=