[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.5,1.6 action_butt
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.5,1.6 action_button.hxx,1.5,1.6 button_panel.cxx,1.8,1.9 button_panel.hxx,1.6,1.7 client.cxx,1.10,1.11 client.hxx,1.8,1.9 playfield.cxx,1.10,1.11 playfield.hxx,1.7,1.8 smallmap.cxx,1.8,1.9 smallmap.hxx,1.6,1.7 surface_button.hxx,1.5,1.6 |
Date: |
2 Aug 2002 22:55:22 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv16623
Modified Files:
action_button.cxx action_button.hxx button_panel.cxx
button_panel.hxx client.cxx client.hxx playfield.cxx
playfield.hxx smallmap.cxx smallmap.hxx surface_button.hxx
Log Message:
cleaned up the forward/pause/armageddon button mess a bit
on_button_press to on_primary_button_press rename
added on_secondary_press
Index: action_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- action_button.cxx 2 Aug 2002 11:25:46 -0000 1.5
+++ action_button.cxx 2 Aug 2002 22:55:19 -0000 1.6
@@ -26,22 +26,11 @@
#include "pingus_resource.hxx"
#include "action_button.hxx"
#include "server.hxx"
+#include "world.hxx"
#include "string_converter.hxx"
using namespace Pingus::Actions;
-Button::Button()
-{
-}
-
-Button::Button (int x, int y) : x_pos(x), y_pos(y)
-{
-}
-
-Button::~Button()
-{
-}
-
ActionButton::ActionButton() {}
ActionButton::~ActionButton() {}
@@ -74,7 +63,7 @@
font_h = PingusResource::load_font("Fonts/pingus_small", "fonts");
font_b = PingusResource::load_font("Fonts/pingus", "fonts");
- surface = PingusResource::load_surface("Pingus/" + action_to_string(name)
+ to_string(owner_id), "pingus");
+ surface = PingusResource::load_surface("Pingus/" + action_to_string(name) +
to_string(owner_id), "pingus");
if (is_multi_direct)
{
action_c.set_size(surface.get_num_frames()/2);
@@ -121,7 +110,7 @@
VerticalActionButton::~VerticalActionButton() {}
bool
-VerticalActionButton::mouse_over(int x, int y)
+VerticalActionButton::is_at(int x, int y)
{
if (x > x_pos && x < x_pos + 60
&& y > y_pos && y <= y_pos + 35)
@@ -186,8 +175,9 @@
action_c);
}
-ArmageddonButton::ArmageddonButton(int x, int y)
- : x_pos (x), y_pos (y),
+ArmageddonButton::ArmageddonButton(Server* s, int x, int y)
+ : server (s),
+ x_pos (x), y_pos (y),
background (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
{
@@ -226,10 +216,18 @@
}
}
-ForwardButton::ForwardButton(int x, int y) :
- Button (x, y),
- background (PingusResource::load_surface("buttons/hbuttonbgb",
"core")),
- backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
+void
+ArmageddonButton::on_primary_button_click (int x, int y)
+{
+ pressed = true; // FIXME: should check the server state instead
+ server->get_world()->armageddon();
+}
+
+ForwardButton::ForwardButton(Server* s, int x, int y)
+ : server (s),
+ x_pos (x), y_pos (y),
+ background (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
+ backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
{
surface = PingusResource::load_surface("buttons/fast_forward", "core");
}
@@ -248,7 +246,7 @@
}
bool
-ForwardButton::mouse_over(int x, int y)
+ForwardButton::is_at(int x, int y)
{
if (x > x_pos && x < x_pos + int(surface.get_width())
&& y > y_pos && y < y_pos + int(surface.get_height()))
@@ -259,10 +257,17 @@
}
}
-PauseButton::PauseButton(int x, int y) :
- Button (x, y),
- background (PingusResource::load_surface("buttons/hbuttonbgb",
"core")),
- backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
+void
+ForwardButton::on_primary_button_click (int x, int y)
+{
+ server->set_fast_forward(server->get_fast_forward());
+}
+
+PauseButton::PauseButton(Server* s, int x, int y)
+ : server (s),
+ x_pos(x), y_pos(y),
+ background (PingusResource::load_surface("buttons/hbuttonbgb", "core")),
+ backgroundhl(PingusResource::load_surface("buttons/hbuttonbg", "core"))
{
surface = PingusResource::load_surface("buttons/pause", "core");
}
@@ -281,7 +286,7 @@
}
bool
-PauseButton::mouse_over (int x, int y)
+PauseButton::is_at (int x, int y)
{
if (x > x_pos && x < x_pos + int(surface.get_width())
&& y > y_pos && y < y_pos + int(surface.get_height()))
@@ -290,6 +295,12 @@
} else {
return false;
}
+}
+
+void
+PauseButton::on_primary_button_click (int x, int y)
+{
+ server->set_pause(!server->get_pause ());
}
/* EOF */
Index: action_button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- action_button.hxx 2 Aug 2002 11:25:46 -0000 1.5
+++ action_button.hxx 2 Aug 2002 22:55:19 -0000 1.6
@@ -34,28 +34,11 @@
class CL_Vector;
// ----------------- snip --------------------
-class Button
-{
-protected:
- int x_pos;
- int y_pos;
-
- CL_Surface surface;
- bool pressed;
-public:
- Button();
- Button (int x, int y);
- virtual ~Button();
-
- virtual void draw() = 0;
- virtual bool mouse_over (int x, int y) = 0;
-};
-
-// ----------------- snip --------------------
///
class ArmageddonButton : public GUI::Component
{
private:
+ Server* server;
int x_pos;
int y_pos;
bool pressed;
@@ -64,59 +47,70 @@
CL_Surface backgroundhl;
AnimCounter counter;
- Server* server;
friend class ButtonPanel;
public:
- ArmageddonButton(int x, int y);
+ ArmageddonButton(Server*, int x, int y);
virtual ~ArmageddonButton();
void draw();
bool is_at(int x, int y);
+ void on_primary_button_click (int x, int y);
};
// ----------------- snip --------------------
///
-class ForwardButton : public Button
+class ForwardButton : public GUI::Component
{
private:
+ Server* server;
+ int x_pos;
+ int y_pos;
+ CL_Surface surface;
CL_Surface background;
CL_Surface backgroundhl;
- Server* server;
friend class ButtonPanel;
public:
- ForwardButton(int x, int y);
+ ForwardButton(Server*, int x, int y);
virtual ~ForwardButton();
void draw();
- bool mouse_over (int x, int y);
+ bool is_at (int x, int y);
+ void on_primary_button_click (int x, int y);
};
// ----------------- snip --------------------
///
-class PauseButton : public Button
+class PauseButton : public GUI::Component
{
private:
+ Server* server;
+ int x_pos;
+ int y_pos;
+ CL_Surface surface;
CL_Surface background;
CL_Surface backgroundhl;
- Server* server;
friend class ButtonPanel;
public:
- PauseButton(int x, int y);
+ PauseButton(Server*, int x, int y);
virtual ~PauseButton();
void draw();
- bool mouse_over (int x, int y);
+ bool is_at (int x, int y);
+ void on_primary_button_click (int x, int y);
};
// ----------------- snip --------------------
/** The button class manage a simple button for the button_panel. It
keeps his position, his surfaces and his font. */
-class ActionButton : public Button
+class ActionButton : public GUI::Component
{
protected:
+ CL_Surface surface;
+ int x_pos;
+ int y_pos;
CL_Font* font;
CL_Font* font_h;
// Added for printing action names next to the button.
@@ -148,7 +142,7 @@
/// Returns true if the button is pressed.
bool is_pressed();
- virtual bool mouse_over(int x, int y) = 0;
+ virtual bool is_at(int x, int y) = 0;
void set_action_holder(ActionHolder* h);
};
@@ -166,7 +160,7 @@
virtual ~VerticalActionButton();
void draw();
- bool mouse_over (int x, int y);
+ bool is_at (int x, int y);
};
// ----------------- snip --------------------
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- button_panel.cxx 2 Aug 2002 11:25:46 -0000 1.8
+++ button_panel.cxx 2 Aug 2002 22:55:19 -0000 1.9
@@ -58,15 +58,6 @@
buttons_data[i].name,
0));
//FIXMEcontroller->get_owner ()));
}
-
- armageddon = new ArmageddonButton(CL_Display::get_width() - 40,
CL_Display::get_height() - 62);
- forward = new ForwardButton (CL_Display::get_width() - 40 * 2,
CL_Display::get_height() - 62);
- pause = new PauseButton (CL_Display::get_width() - 40 * 3,
CL_Display::get_height() - 62);
-
- forward->pressed = false;
- pause->pressed = false;
-
-
pressed_button = a_buttons.begin();
}
@@ -77,10 +68,6 @@
{
delete *it;
}
-
- delete armageddon;
- delete forward;
- delete pause;
}
void
@@ -120,10 +107,6 @@
(*button)->draw();
}
-
- armageddon->draw();
- pause->draw();
- forward->draw();
}
void
@@ -135,10 +118,6 @@
{
(*button)->set_action_holder(server->get_action_holder());
}
-
- pause->server = server;
- armageddon->server = server;
- forward->server = server;
}
void
@@ -157,15 +136,16 @@
}
void
-ButtonPanel::on_button_press(int x, int y)
+ButtonPanel::on_primary_button_press(int x, int y)
{
for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
- if ((*button)->mouse_over(x, y))
+ if ((*button)->is_at(x, y))
pressed_button = button;
}
- if (armageddon->is_at(x, y))
+
+ /* if (armageddon->is_at(x, y))
{
last_press = CL_System::get_time();
@@ -182,7 +162,7 @@
return;
}
- if (pause->mouse_over(x, y))
+ if (pause->is_mouse_over(x, y))
{
client->set_pause(!client->get_pause());
return;
@@ -192,6 +172,7 @@
client->set_fast_forward(!client->get_fast_forward());
return;
}
+ */
}
bool
@@ -199,19 +180,15 @@
{
for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
- if ((*button)->mouse_over(x, y))
+ if ((*button)->is_at(x, y))
return true;
}
return false;
}
void
-ButtonPanel::on_button_release(int x, int y)
+ButtonPanel::on_primary_button_release(int x, int y)
{
-
- //forward->pressed = false;
- //pause->pressed = false;
-
}
/// Select the next action
Index: button_panel.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- button_panel.hxx 2 Aug 2002 11:25:46 -0000 1.6
+++ button_panel.hxx 2 Aug 2002 22:55:19 -0000 1.7
@@ -38,9 +38,6 @@
std::vector<ActionButton*> a_buttons;
typedef std::vector<ActionButton*>::iterator AButtonIter;
AButtonIter pressed_button;
- ArmageddonButton* armageddon;
- ForwardButton* forward;
- PauseButton* pause;
Server* server;
Client* client;
@@ -52,14 +49,13 @@
unsigned int last_press;
static CL_Surface button_cap;
-
int x_pos, y_pos;
public:
ButtonPanel(PLF* plf, int arg_x_pos, int arg_y_pos);
virtual ~ButtonPanel();
- void on_button_press(int x, int y);
- void on_button_release(int x, int y);
+ void on_primary_button_press(int x, int y);
+ void on_primary_button_release(int x, int y);
bool is_at (int x, int y);
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- client.cxx 2 Aug 2002 13:17:42 -0000 1.10
+++ client.cxx 2 Aug 2002 22:55:19 -0000 1.11
@@ -84,7 +84,7 @@
pcounter = new PingusCounter();
small_map = new SmallMap();
time_display = new TimeDisplay();
-
+
button_panel->set_client(this);
button_panel->set_server(server);
hurry_up->set_client(this);
@@ -99,6 +99,10 @@
gui_manager->add (small_map, true);
gui_manager->add (time_display, true);
+ gui_manager->add (new ArmageddonButton(server, CL_Display::get_width() - 40,
CL_Display::get_height() - 62), true);
+ gui_manager->add (new ForwardButton (server, CL_Display::get_width() - 40
* 2, CL_Display::get_height() - 62), true);
+ gui_manager->add (new PauseButton (server, CL_Display::get_width() - 40
* 3, CL_Display::get_height() - 62), true);
+
/*playfield->set_clip_rect(0, 0,
CL_Display::get_width(),
CL_Display::get_height());*/
@@ -331,35 +335,6 @@
}
#if 0
-void
-Client::register_event_handler()
-{
- if (verbose > 1) std::cout << "Client: register_event_handler()" <<
std::endl;
- enabled = true;
-}
-
-void
-Client::on_button_press(CL_InputDevice *device, const CL_Key &key)
-{
- if (!enabled)
- return;
-
- std::cout << "Got button press: " << enabled << std::endl;
-
- if (device == CL_Input::keyboards[0])
- {
- on_keyboard_button_press(key);
- }
- else if (device == CL_Input::pointers[0])
- {
- on_mouse_button_press(key);
- }
- else
- {
- if (verbose > 1) std::cout << "Unknown device pressed: device=" <<
device << "; key.id=" << key.id << std::endl;
- }
-}
-
void
Client::on_keyboard_button_press(const CL_Key& /*key*/)
{
Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- client.hxx 2 Aug 2002 13:17:42 -0000 1.8
+++ client.hxx 2 Aug 2002 22:55:19 -0000 1.9
@@ -105,8 +105,8 @@
ButtonPanel* get_button_panel () { return button_panel; }
- void on_button_press(int x, int y);
- void on_button_release(int x, int y);
+ void on_primary_button_press(int x, int y);
+ void on_primary_button_release(int x, int y);
void on_butmouse_button_press(const CL_Key &key);
void on_mouse_button_release(const CL_Key &key);
Index: playfield.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- playfield.cxx 2 Aug 2002 13:17:42 -0000 1.10
+++ playfield.cxx 2 Aug 2002 22:55:19 -0000 1.11
@@ -195,7 +195,7 @@
}
void
-Playfield::on_button_press(int x, int y)
+Playfield::on_primary_button_press(int x, int y)
{
if (current_pingu)
{
@@ -207,11 +207,31 @@
}
void
+Playfield::on_secondary_button_press (int x, int y)
+{
+ mouse_scrolling = true;
+ scroll_center_x = x;
+ scroll_center_y = y;
+}
+
+void
+Playfield::on_secondary_button_release (int x, int y)
+{
+ mouse_scrolling = false;
+}
+
+void
Playfield::on_pointer_move (int x, int y)
{
// FIXME: useless stuff, but currently the controller doesn't have a state
mouse_x = x;
mouse_y = y;
+
+ if (mouse_scrolling)
+ {
+ view[current_view]->shift_x_offset((scroll_center_x - mouse_x) / 5);
+ view[current_view]->shift_y_offset((scroll_center_y - mouse_y) / 5);
+ }
}
void
@@ -236,37 +256,6 @@
Playfield::set_client(Client* c)
{
client = c;
-}
-
-void
-Playfield::enable_scroll_mode()
-{
- if (verbose) std::cout << "Started scrolling..." << std::flush;
- mouse_scrolling = true;
-
-#if 0
- scroll_center_x = controller->get_x();
- scroll_center_y = controller->get_y();
-#endif
-}
-
-void
-Playfield::do_scrolling()
-{
-#if 0
- if (mouse_scrolling)
- {
- view[current_view]->shift_x_offset((scroll_center_x -
controller->get_x()) / 5);
- view[current_view]->shift_y_offset((scroll_center_y -
controller->get_y()) / 5);
- }
-#endif
-}
-
-void
-Playfield::disable_scroll_mode()
-{
- if (verbose) std::cout << "done" << std::endl;
- mouse_scrolling = false;
}
int
Index: playfield.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/playfield.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- playfield.hxx 2 Aug 2002 11:53:52 -0000 1.7
+++ playfield.hxx 2 Aug 2002 22:55:19 -0000 1.8
@@ -86,7 +86,9 @@
void set_world(World*);
Pingu* current_pingu_find(int x_pos, int y_pos);
- void on_button_press (int x, int y);
+ void on_primary_button_press (int x, int y);
+ void on_secondary_button_press (int x, int y);
+ void on_secondary_button_release (int x, int y);
void on_pointer_move (int x, int y);
void enable_scroll_mode();
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- smallmap.cxx 2 Aug 2002 11:53:52 -0000 1.8
+++ smallmap.cxx 2 Aug 2002 22:55:19 -0000 1.9
@@ -239,7 +239,7 @@
}
void
-SmallMap::on_button_press(int x, int y)
+SmallMap::on_primary_button_press(int x, int y)
{
scroll_mode = true;
@@ -252,19 +252,19 @@
}
void
-SmallMap::on_button_release(int x, int y)
+SmallMap::on_primary_button_release(int x, int y)
{
scroll_mode = false;
}
void
-SmallMap::on_mouse_enter ()
+SmallMap::on_pointer_enter ()
{
has_focus = true;
}
void
-SmallMap::on_mouse_leave ()
+SmallMap::on_pointer_leave ()
{
has_focus = false;
}
Index: smallmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- smallmap.hxx 29 Jul 2002 11:57:38 -0000 1.6
+++ smallmap.hxx 2 Aug 2002 22:55:19 -0000 1.7
@@ -47,8 +47,8 @@
SmallMap();
virtual ~SmallMap();
- void on_button_press(int x, int y);
- void on_button_release(int x, int y);
+ void on_primary_button_press(int x, int y);
+ void on_primary_button_release(int x, int y);
void on_pointer_move(int x, int y);
void set_client(Client* c);
@@ -61,8 +61,8 @@
bool is_at (int x, int y);
// Events
- void on_mouse_enter ();
- void on_mouse_leave ();
+ void on_pointer_enter ();
+ void on_pointer_leave ();
};
#endif
Index: surface_button.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/surface_button.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- surface_button.hxx 1 Aug 2002 21:40:01 -0000 1.5
+++ surface_button.hxx 2 Aug 2002 22:55:19 -0000 1.6
@@ -62,7 +62,7 @@
void on_pointer_press ();
void on_pointer_release ();
- void on_button_click (int x, int y) { on_click (); }
+ void on_primary_button_click (int x, int y) { on_click (); }
virtual void on_click () =0;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.5,1.6 action_button.hxx,1.5,1.6 button_panel.cxx,1.8,1.9 button_panel.hxx,1.6,1.7 client.cxx,1.10,1.11 client.hxx,1.8,1.9 playfield.cxx,1.10,1.11 playfield.hxx,1.7,1.8 smallmap.cxx,1.8,1.9 smallmap.hxx,1.6,1.7 surface_button.hxx,1.5,1.6,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/gui button.hxx,1.2,1.3 component.hxx,1.5,1.6 gui_manager.cxx,1.6,1.7 gui_manager.hxx,1.5,1.6 surface_button.cxx,1.1,1.2 surface_button.hxx,1.1,1.2
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap manager.cxx,1.6,1.7 manager.hxx,1.5,1.6 worldmap.cxx,1.5,1.6 worldmap.hxx,1.4,1.5
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/gui button.hxx,1.2,1.3 component.hxx,1.5,1.6 gui_manager.cxx,1.6,1.7 gui_manager.hxx,1.5,1.6 surface_button.cxx,1.1,1.2 surface_button.hxx,1.1,1.2
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldmap manager.cxx,1.6,1.7 manager.hxx,1.5,1.6 worldmap.cxx,1.5,1.6 worldmap.hxx,1.4,1.5
- Index(es):