[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src button_panel.cxx,1.5,1.6 button_panel
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src button_panel.cxx,1.5,1.6 button_panel.hxx,1.4,1.5 client.cxx,1.6,1.7 multiplayer_client_child.cxx,1.4,1.5 smallmap.cxx,1.6,1.7 smallmap.hxx,1.5,1.6 |
Date: |
29 Jul 2002 11:57:40 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv10519
Modified Files:
button_panel.cxx button_panel.hxx client.cxx
multiplayer_client_child.cxx smallmap.cxx smallmap.hxx
Log Message:
transformed button_panel and smallmap into GUI::Components
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- button_panel.cxx 28 Jun 2002 15:12:22 -0000 1.5
+++ button_panel.cxx 29 Jul 2002 11:57:38 -0000 1.6
@@ -160,48 +160,56 @@
}
void
-ButtonPanel::on_button_press(const CL_Key &key)
+ButtonPanel::on_button_press(int x, int y)
{
- if (key.id == CL_MOUSE_LEFTBUTTON)
+ for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
- for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
- {
- if ((*button)->mouse_over(controller->get_pos ()))
- pressed_button = button;
- }
+ if ((*button)->mouse_over(controller->get_pos ()))
+ pressed_button = button;
+ }
- if (armageddon->mouse_over(CL_Vector (key.x, key.y)))
- {
- last_press = CL_System::get_time();
+ if (armageddon->mouse_over(CL_Vector (x, y)))
+ {
+ last_press = CL_System::get_time();
- if (verbose) std::cout << "Armageddon: " << armageddon_pressed <<
std::endl;
- armageddon_pressed++;
+ if (verbose) std::cout << "Armageddon: " << armageddon_pressed <<
std::endl;
+ armageddon_pressed++;
- if (armageddon_pressed == 2)
- {
- arma_counter = 0;
- armageddon_pressed = 4;
- armageddon->pressed = true;
- server->get_world()->armageddon();
- }
- return;
- }
-
- if (pause->mouse_over(controller->get_pos ()))
- {
- client->set_pause(!client->get_pause());
- return;
- }
- else if (forward->mouse_over(controller->get_pos ()))
+ if (armageddon_pressed == 2)
{
- client->set_fast_forward(!client->get_fast_forward());
- return;
+ arma_counter = 0;
+ armageddon_pressed = 4;
+ armageddon->pressed = true;
+ server->get_world()->armageddon();
}
+ return;
+ }
+
+ if (pause->mouse_over(controller->get_pos ()))
+ {
+ client->set_pause(!client->get_pause());
+ return;
+ }
+ else if (forward->mouse_over(controller->get_pos ()))
+ {
+ client->set_fast_forward(!client->get_fast_forward());
+ return;
}
}
+bool
+ButtonPanel::is_at (int x, int y)
+{
+ for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
+ {
+ if ((*button)->mouse_over(CL_Vector (x, y)))
+ return true;
+ }
+ return false;
+}
+
void
-ButtonPanel::on_button_release(const CL_Key & /*key*/)
+ButtonPanel::on_button_release(int x, int y)
{
//forward->pressed = false;
Index: button_panel.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- button_panel.hxx 28 Jun 2002 15:12:22 -0000 1.4
+++ button_panel.hxx 29 Jul 2002 11:57:38 -0000 1.5
@@ -24,13 +24,14 @@
#include "gui_obj.hxx"
#include "action_button.hxx"
+#include "gui/component.hxx"
class CL_Key;
class Client;
class PLF;
class Controller;
-class ButtonPanel : public GuiObj
+class ButtonPanel : public GUI::Component
{
private:
friend class ClientEvent;
@@ -57,10 +58,12 @@
int x_pos, y_pos;
public:
ButtonPanel(PLF* plf, Controller*, int arg_x_pos, int arg_y_pos);
- ~ButtonPanel();
+ virtual ~ButtonPanel();
- void on_button_press(const CL_Key& key);
- void on_button_release(const CL_Key& key);
+ void on_button_press(int x, int y);
+ void on_button_release(int x, int y);
+
+ bool is_at (int x, int y);
ActionName get_action_name();
void update(float delta);
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- client.cxx 29 Jul 2002 10:44:12 -0000 1.6
+++ client.cxx 29 Jul 2002 11:57:38 -0000 1.7
@@ -160,10 +160,12 @@
obj.push_back(playfield);
obj.push_back(pcounter);
obj.push_back(time_display);
- obj.push_back(button_panel);
- obj.push_back(small_map);
obj.push_back(hurry_up);
+ gui_manager->add (small_map);
+ gui_manager->add (button_panel);
+
+
if (verbose) std::cout << "done " << timer.stop() << std::endl;
}
@@ -650,8 +652,8 @@
void
Client::on_mouse_button_press(const CL_Key& key)
{
- button_panel->on_button_press(key);
- small_map->on_button_press(key);
+ // button_panel->on_button_press(key);
+ //small_map->on_button_press(key);
switch(key.id)
{
@@ -671,8 +673,8 @@
void
Client::on_mouse_button_release(const CL_Key& key)
{
- button_panel->on_button_release(key);
- small_map->on_button_release(key);
+ //button_panel->on_button_release(key);
+ //small_map->on_button_release(key);
switch(key.id)
{
@@ -698,8 +700,8 @@
key.x = pos.x;
key.y = pos.y;
- button_panel->on_button_press(key);
- small_map->on_button_press(key);
+ //button_panel->on_button_press(key);
+ //small_map->on_button_press(key);
playfield->on_button_press(key);
}
@@ -712,8 +714,8 @@
key.x = pos.x;
key.y = pos.y;
- button_panel->on_button_release(key);
- small_map->on_button_release(key);
+ //button_panel->on_button_release(key);
+ //small_map->on_button_release(key);
}
Index: multiplayer_client_child.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/multiplayer_client_child.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- multiplayer_client_child.cxx 2 Jul 2002 21:46:36 -0000 1.4
+++ multiplayer_client_child.cxx 29 Jul 2002 11:57:38 -0000 1.5
@@ -44,7 +44,7 @@
//std::cout << "MultiplayerClientChild: Creating: " << server.get() <<
std::endl;
gui_objs.push_back (playfield);
- gui_objs.push_back (button_panel);
+ //gui_objs.push_back (button_panel);
gui_objs.push_back (counterbar);
controller->set_range (rect);
@@ -90,7 +90,7 @@
key.id = CL_MOUSE_LEFTBUTTON;
key.x = pos.x;
key.y = pos.y;
- button_panel->on_button_press(key);
+ //button_panel->on_button_press(key);
Pingu* pingu = playfield->get_pingu (controller->get_pos ());
if (pingu && pingu->get_owner () == controller->get_owner ())
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- smallmap.cxx 29 Jul 2002 10:44:12 -0000 1.6
+++ smallmap.cxx 29 Jul 2002 11:57:38 -0000 1.7
@@ -214,59 +214,40 @@
void
SmallMap::update(float /*delta*/)
{
- int cx, cy;
- ColMap* colmap = client->get_server()->get_world()->get_colmap();
-
- if (scroll_mode)
- {
- cx = (int(CL_Mouse::get_x()) - x_pos) * int(colmap->get_width()) / width;
- cy = (int(CL_Mouse::get_y()) - y_pos) * int(colmap->get_height()) /
height ;
-
- client->get_playfield()->set_viewpoint(cx, cy);
- }
-}
-
-bool
-SmallMap::mouse_over()
-{
- return (CL_Mouse::get_x() > x_pos && CL_Mouse::get_x() < x_pos + (int)width
- && CL_Mouse::get_y() > y_pos && CL_Mouse::get_y() < y_pos +
(int)height);
}
bool
-SmallMap::mouse_over(int x, int y)
+SmallMap::is_at (int x, int y)
{
- std::cout << "............." << x << " " << y << std::endl;
return (x > x_pos && x < x_pos + (int)width
&& y > y_pos && y < y_pos + (int)height);
}
-bool
-SmallMap::on_button_press(const CL_Key& key)
+void
+SmallMap::on_pointer_move(int x, int y)
{
- switch(key.id)
+ int cx, cy;
+ ColMap* colmap = client->get_server()->get_world()->get_colmap();
+
+ if (scroll_mode)
{
- case CL_MOUSE_LEFTBUTTON:
- if (mouse_over())
- {
- scroll_mode = true;
- return true;
- }
- break;
+ cx = (x - x_pos) * int(colmap->get_width()) / width;
+ cy = (y - y_pos) * int(colmap->get_height()) / height ;
+
+ client->get_playfield()->set_viewpoint(cx, cy);
}
- return false;
}
-bool
-SmallMap::on_button_release(const CL_Key& key)
+void
+SmallMap::on_button_press(int x, int y)
{
- switch(key.id)
- {
- case CL_MOUSE_LEFTBUTTON:
- scroll_mode = false;
- break;
- }
- return false;
+ scroll_mode = true;
+}
+
+void
+SmallMap::on_button_release(int x, int y)
+{
+ scroll_mode = false;
}
void
Index: smallmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- smallmap.hxx 29 Jul 2002 10:44:12 -0000 1.5
+++ smallmap.hxx 29 Jul 2002 11:57:38 -0000 1.6
@@ -21,13 +21,12 @@
#define HEADER_PINGUS_SMALLMAP_HXX
#include <ClanLib/Display/Display/surface.h>
-#include "gui_obj.hxx"
-
+#include "gui/component.hxx"
class CL_Key;
class Client;
-class SmallMap : public GuiObj
+class SmallMap : public GUI::Component
{
private:
Client* client;
@@ -46,10 +45,11 @@
bool has_focus;
public:
SmallMap();
- ~SmallMap();
+ virtual ~SmallMap();
- bool on_button_press(const CL_Key& key);
- bool on_button_release(const CL_Key& key);
+ void on_button_press(int x, int y);
+ void on_button_release(int x, int y);
+ void on_pointer_move(int x, int y);
void set_client(Client* c);
bool mouse_over();
@@ -58,7 +58,7 @@
void draw_pingus();
void update(float delta);
- bool mouse_over(int x, int y);
+ bool is_at (int x, int y);
// Events
void on_mouse_enter ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src button_panel.cxx,1.5,1.6 button_panel.hxx,1.4,1.5 client.cxx,1.6,1.7 multiplayer_client_child.cxx,1.4,1.5 smallmap.cxx,1.6,1.7 smallmap.hxx,1.5,1.6,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/gui component.hxx,1.2,1.3 root_gui_manager.cxx,1.1,1.2 root_gui_manager.hxx,1.1,1.2
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.3,1.4 action_button.hxx,1.3,1.4 button_panel.cxx,1.6,1.7 pingus_menu.cxx,1.3,1.4 pingus_menu.hxx,1.2,1.3 pingus_menu_manager.cxx,1.2,1.3 story.hxx,1.2,1.3 surface_button.cxx,1.2,1.3 surface_button.hxx,1.3,1.4
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/gui component.hxx,1.2,1.3 root_gui_manager.cxx,1.1,1.2 root_gui_manager.hxx,1.1,1.2
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.3,1.4 action_button.hxx,1.3,1.4 button_panel.cxx,1.6,1.7 pingus_menu.cxx,1.3,1.4 pingus_menu.hxx,1.2,1.3 pingus_menu_manager.cxx,1.2,1.3 story.hxx,1.2,1.3 surface_button.cxx,1.2,1.3 surface_button.hxx,1.3,1.4
- Index(es):