[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.17,1.18 button_pan
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src button_panel.cxx,1.17,1.18 button_panel.hxx,1.13,1.14 client.cxx,1.32,1.33 |
Date: |
29 Oct 2002 12:47:57 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv465
Modified Files:
button_panel.cxx button_panel.hxx client.cxx
Log Message:
added hotkey support
Index: button_panel.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- button_panel.cxx 14 Oct 2002 11:15:15 -0000 1.17
+++ button_panel.cxx 29 Oct 2002 12:47:55 -0000 1.18
@@ -56,7 +56,7 @@
0));
//FIXMEcontroller->get_owner ()));
}
- pressed_button = a_buttons.begin();
+ pressed_button = 0;
}
ButtonPanel::~ButtonPanel()
@@ -70,7 +70,7 @@
void
ButtonPanel::update(float delta)
{
- (*pressed_button)->update(delta);
+ a_buttons[pressed_button]->update(delta);
if (last_press + 350 < CL_System::get_time())
{
@@ -81,7 +81,7 @@
ActionName
ButtonPanel::get_action_name()
{
- return (*pressed_button)->get_action_name();
+ return a_buttons[pressed_button]->get_action_name();
}
void
@@ -94,15 +94,14 @@
else
alpha = 0.5;
- // draw the buttons
- for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
++button)
+ for(int i = 0; i < static_cast<int>(a_buttons.size()); ++i)
{
- if (button == pressed_button)
- (*button)->pressed = true;
+ if (i == pressed_button)
+ a_buttons[i]->pressed = true;
else
- (*button)->pressed = false;
+ a_buttons[i]->pressed = false;
- (*button)->draw(gc);
+ a_buttons[i]->draw(gc);
}
}
@@ -124,11 +123,15 @@
}
void
-ButtonPanel::set_button(int i)
+ButtonPanel::set_button(int n)
{
- if ((unsigned int)(i) < a_buttons.size())
+ if (n < 0 || n >= static_cast<int>(a_buttons.size()))
{
- pressed_button = a_buttons.begin() + i;
+ // FIXME: Play 'boing' sound here
+ }
+ else
+ {
+ pressed_button = n;
}
}
@@ -138,38 +141,8 @@
for(AButtonIter button = a_buttons.begin(); button != a_buttons.end();
button++)
{
if ((*button)->is_at(x, y))
- pressed_button = button;
- }
-
-
- /* if (armageddon->is_at(x, y))
- {
- last_press = CL_System::get_time();
-
- 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->is_mouse_over(x, y))
- {
- client->set_pause(!client->get_pause());
- return;
- }
- else if (forward->mouse_over(x, y))
- {
- client->set_fast_forward(!client->get_fast_forward());
- return;
+ pressed_button = button - a_buttons.begin();
}
- */
}
bool
@@ -194,19 +167,14 @@
void
ButtonPanel::next_action ()
{
- ++pressed_button;
- if (pressed_button == a_buttons.end ())
- pressed_button = a_buttons.begin ();
+ pressed_button = (pressed_button + 1) % a_buttons.size();
}
/// Select the previous action
void
ButtonPanel::previous_action ()
{
- if (pressed_button == a_buttons.begin ())
- pressed_button = a_buttons.end ();
-
- --pressed_button;
+ pressed_button = (pressed_button - 1 + a_buttons.size()) % a_buttons.size();
}
/* EOF */
Index: button_panel.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/button_panel.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- button_panel.hxx 4 Oct 2002 16:54:03 -0000 1.13
+++ button_panel.hxx 29 Oct 2002 12:47:55 -0000 1.14
@@ -35,7 +35,7 @@
std::vector<ActionButton*> a_buttons;
typedef std::vector<ActionButton*>::iterator AButtonIter;
- AButtonIter pressed_button;
+ int pressed_button;
TrueServer* server;
Client* client;
@@ -62,6 +62,8 @@
void draw(GraphicContext& gc);
void set_server(TrueServer*);
void set_client(Client*);
+
+ /// Set n'th action
void set_button(int);
/// Select the next action
@@ -69,7 +71,7 @@
/// Select the previous action
void previous_action ();
-
+
private:
ButtonPanel (const ButtonPanel&);
ButtonPanel& operator= (const ButtonPanel&);
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- client.cxx 28 Oct 2002 22:40:23 -0000 1.32
+++ client.cxx 29 Oct 2002 12:47:55 -0000 1.33
@@ -43,7 +43,7 @@
#include "input/event.hxx"
#include "input/axis_event.hxx"
#include "input/scroll_event.hxx"
-
+#include "input/button_event.hxx"
Client::Client (TrueServer * s)
: server (s),
@@ -124,8 +124,13 @@
switch ((*i)->get_type ())
{
case Input::ButtonEventType:
- // Ignore, is handled in GUIScreen
- //process_button_event (dynamic_cast<class Input::ButtonEvent*
const>(*i));
+ {
+ Input::ButtonEvent* ev = dynamic_cast<Input::ButtonEvent*
const>(*i);
+ if (ev->name >= Input::action_1 && ev->name <= Input::action_10)
+ {
+ button_panel->set_button(ev->name - Input::action_1);
+ }
+ }
break;
case Input::PointerEventType:
@@ -154,7 +159,8 @@
Client::process_scroll_event (Input::ScrollEvent* ev)
{
std::cout << "Client::process_scroll_event ()" << std::endl;
- playfield->scroll(static_cast<int>(ev->x_delta),
static_cast<int>(ev->y_delta));
+ playfield->scroll(static_cast<int>(ev->x_delta),
+ static_cast<int>(ev->y_delta));
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src button_panel.cxx,1.17,1.18 button_panel.hxx,1.13,1.14 client.cxx,1.32,1.33,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/data/images/worldmaps tutorial_layer0.jpg,NONE,1.1 tutorial_layer1.png,NONE,1.1 Makefile.am,1.2,1.3
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/data/worldmaps tutorial.xml,NONE,1.1
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/data/images/worldmaps tutorial_layer0.jpg,NONE,1.1 tutorial_layer1.png,NONE,1.1 Makefile.am,1.2,1.3
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/data/worldmaps tutorial.xml,NONE,1.1
- Index(es):