[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input controller.cxx,1.16,1.17 contro
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input controller.cxx,1.16,1.17 controller.hxx,1.9,1.10 |
Date: |
19 Aug 2002 08:28:05 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv8790
Modified Files:
controller.cxx controller.hxx
Log Message:
merged button_states into buttons
Index: controller.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/controller.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- controller.cxx 17 Aug 2002 17:20:51 -0000 1.16
+++ controller.cxx 19 Aug 2002 08:28:03 -0000 1.17
@@ -76,22 +76,22 @@
scroller =
ScrollerFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"primary-button"))
- buttons[primary] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[primary].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"secondary-button"))
- buttons[secondary] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[secondary].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"pause-button"))
- buttons[pause] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[pause].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"fast-forward-button"))
- buttons[fast_forward] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[fast_forward].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"armageddon-button"))
- buttons[armageddon] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[armageddon].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"escape-button"))
- buttons[escape] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[escape].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"action-buttons"))
create_action_buttons(XMLhelper::skip_blank(cur->children));
@@ -130,44 +130,42 @@
if (!buttons.count(primary))
{
- buttons[primary] = new DummyButton;
+ buttons[primary].first = new DummyButton;
pwarn << "Controller: No primary button - inserting dummy" << std::endl;
}
if (!buttons.count(secondary))
{
- buttons[secondary] = new DummyButton;
+ buttons[secondary].first = new DummyButton;
pwarn << "Controller: No secondary button - inserting dummy" <<
std::endl;
}
if (!buttons.count(pause))
{
- buttons[pause] = new DummyButton;
+ buttons[pause].first = new DummyButton;
pwarn << "Controller: No pause button - inserting dummy" << std::endl;
}
if (!buttons.count(fast_forward))
{
- buttons[fast_forward] = new DummyButton;
+ buttons[fast_forward].first = new DummyButton;
pwarn << "Controller: No fast_forward button - inserting dummy" <<
std::endl;
}
if (!buttons.count(armageddon))
{
- buttons[armageddon] = new DummyButton;
+ buttons[armageddon].first = new DummyButton;
pwarn << "Controller: No armageddon button - inserting dummy" <<
std::endl;
}
if (!buttons.count(escape))
{
- buttons[escape] = new DummyButton;
+ buttons[escape].first = new DummyButton;
pwarn << "Controller: No escape button - inserting dummy" << std::endl;
}
- button_states.resize(buttons.size());
- std::map<ButtonName, Button*>::const_iterator it = buttons.begin();
- for (unsigned int i=0; i < buttons.size(); ++i, ++it)
- button_states[i] = it->second->is_pressed();
+ for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it =
buttons.begin(); it != buttons.end(); ++it)
+ it->second.second = it->second.first->is_pressed();
}
void
@@ -184,7 +182,7 @@
}
if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"action-button"))
- buttons[static_cast<ButtonName>(action_1 + count)] =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
+ buttons[static_cast<ButtonName>(action_1 + count)].first =
ButtonFactory::create(XMLhelper::skip_blank(cur->children));
else
PingusError::raise(std::string("Wrong Element in Controller Config
(action-buttons): ") + reinterpret_cast<const char*>(cur->name));
@@ -205,8 +203,8 @@
standard_pointer->update(delta);
action_axis ->update(delta);
- for (std::map<ButtonName, Button*>::iterator it = buttons.begin(); it !=
buttons.end(); ++it)
- it->second->update(delta);
+ for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it =
buttons.begin(); it != buttons.end(); ++it)
+ it->second.first->update(delta);
if (std_pointer_x != standard_pointer->get_x_pos() || std_pointer_y !=
standard_pointer->get_y_pos())
{
@@ -219,12 +217,11 @@
if (scroller->get_x_delta() || scroller->get_y_delta())
events.push_back(new ScrollEvent(scroller->get_x_delta(),
scroller->get_y_delta()));
- std::map<ButtonName, Button*>::const_iterator it = buttons.begin();
- for (unsigned int i=0; i < buttons.size(); ++i, ++it)
- if (it->second->is_pressed() != button_states[i])
+ for (std::map<ButtonName, std::pair<Button*, bool> >::iterator it =
buttons.begin(); it != buttons.end(); ++it)
+ if (it->second.first->is_pressed() != it->second.second)
{
- button_states[i] = it->second->is_pressed();
- if (button_states[i])
+ it->second.second = ! it->second.second;
+ if (it->second.second)
events.push_back(new ButtonEvent(it->first, pressed));
else
events.push_back(new ButtonEvent(it->first, released));
@@ -239,7 +236,7 @@
Controller::get_button (ButtonName name)
{
if (buttons.count(name))
- return buttons[name];
+ return buttons[name].first;
return 0;
}
Index: controller.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/controller.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- controller.hxx 17 Aug 2002 17:20:51 -0000 1.9
+++ controller.hxx 19 Aug 2002 08:28:03 -0000 1.10
@@ -42,13 +42,12 @@
Pointer* standard_pointer;
Scroller* scroller;
- std::map<ButtonName, Button*> buttons;
+ std::map<ButtonName, std::pair<Button*, bool> > buttons;
std::list<Event*> events;
float std_pointer_x;
float std_pointer_y;
- std::vector<bool> button_states;
public:
explicit Controller (const std::string& configfile);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input controller.cxx,1.16,1.17 controller.hxx,1.9,1.10,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.11,1.12 button_panel.cxx,1.10,1.11 credits.cxx,1.6,1.7 fade_out.cxx,1.2,1.3 force_vector.cxx,1.3,1.4 layer_manager.cxx,1.1,1.2 liquid.cxx,1.1,1.2 multiline_text.cxx,1.3,1.4 music_provider.cxx,1.1,1.2 pingus_main.cxx,1.11,1.12 screenshot.cxx,1.4,1.5 smallmap.cxx,1.10,1.11 sound_real.cxx,1.3,1.4 spot_map.cxx,1.6,1.7 system.cxx,1.4,1.5 theme.cxx,1.3,1.4 theme_selector.cxx,1.3,1.4 world.cxx,1.13,1.14
- Next by Date:
[Pingus-CVS] [Bug #1048] Game stays active after minimize or workspace change
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.11,1.12 button_panel.cxx,1.10,1.11 credits.cxx,1.6,1.7 fade_out.cxx,1.2,1.3 force_vector.cxx,1.3,1.4 layer_manager.cxx,1.1,1.2 liquid.cxx,1.1,1.2 multiline_text.cxx,1.3,1.4 music_provider.cxx,1.1,1.2 pingus_main.cxx,1.11,1.12 screenshot.cxx,1.4,1.5 smallmap.cxx,1.10,1.11 sound_real.cxx,1.3,1.4 spot_map.cxx,1.6,1.7 system.cxx,1.4,1.5 theme.cxx,1.3,1.4 theme_selector.cxx,1.3,1.4 world.cxx,1.13,1.14
- Next by thread:
[Pingus-CVS] [Bug #1048] Game stays active after minimize or workspace change
- Index(es):