[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,1.3,1.4 butt
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,1.3,1.4 button_factory.hxx,1.2,1.3 |
Date: |
11 Jul 2002 15:38:09 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv27004
Modified Files:
button_factory.cxx button_factory.hxx
Log Message:
added support for Double/TripleButton
Index: button_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/button_factory.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- button_factory.cxx 10 Jul 2002 14:06:20 -0000 1.3
+++ button_factory.cxx 11 Jul 2002 15:38:07 -0000 1.4
@@ -20,21 +20,29 @@
#include <stdlib.h>
#include "../xml_helper.hxx"
#include "../pingus_error.hxx"
+#include "button_factory.hxx"
+#include "double_button.hxx"
+#include "joystick_button.hxx"
#include "key_button.hxx"
#include "key_helper.hxx"
#include "mouse_button.hxx"
-#include "joystick_button.hxx"
#include "multiple_button.hxx"
-#include "button_factory.hxx"
+#include "triple_button.hxx"
namespace Input {
Button* ButtonFactory::create(xmlNodePtr cur)
{
+ if (!cur)
+ throw PingusError("ButtonFactory called without an element");
+
if (xmlIsBlankNode(cur))
cur = cur->next;
- if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "joystick-button"))
+ if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "double-button"))
+ return double_button(cur);
+
+ else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"joystick-button"))
return joystick_button(cur);
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "key-button"))
@@ -46,10 +54,32 @@
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"multiple-button"))
return multiple_button(cur);
+ else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"triple-button"))
+ return triple_button(cur);
+
else
throw PingusError(std::string("Unknown button type: ") + ((cur->name) ?
reinterpret_cast<const char*>(cur->name) : ""));
}
+ Button* ButtonFactory::double_button (xmlNodePtr cur)
+ {
+ Button *button1, *button2;
+
+ cur = cur->children;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+ button1 = create(cur);
+
+ cur = cur-> next;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+ button2 = create(cur);
+
+ return new DoubleButton(button1, button2);
+ }
+
Button* ButtonFactory::joystick_button (xmlNodePtr cur)
{
char * id_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("id")));
@@ -112,6 +142,31 @@
}
return new MultipleButton(buttons);
+ }
+
+ Button* ButtonFactory::triple_button (xmlNodePtr cur)
+ {
+ Button *button1, *button2, *button3;
+
+ cur = cur->children;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+ button1 = create(cur);
+
+ cur = cur-> next;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+ button2 = create(cur);
+
+ cur = cur-> next;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+ button3 = create(cur);
+
+ return new TripleButton(button1, button2, button3);
}
}
Index: button_factory.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/button_factory.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- button_factory.hxx 9 Jul 2002 17:00:10 -0000 1.2
+++ button_factory.hxx 11 Jul 2002 15:38:07 -0000 1.3
@@ -29,10 +29,12 @@
class ButtonFactory
{
private:
+ static inline Button* double_button (xmlNodePtr cur);
static inline Button* joystick_button (xmlNodePtr cur);
static inline Button* key_button (xmlNodePtr cur);
static inline Button* mouse_button (xmlNodePtr cur);
static inline Button* multiple_button (xmlNodePtr cur);
+ static inline Button* triple_button (xmlNodePtr cur);
public:
static Button* create (xmlNodePtr cur);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,1.3,1.4 button_factory.hxx,1.2,1.3,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input joystick_axis.cxx,1.3,1.4 joystick_button.cxx,1.1,1.2 mouse_button.cxx,1.1,1.2
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input scroller_factory.cxx,NONE,1.1 scroller_factory.hxx,NONE,1.1
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input joystick_axis.cxx,1.3,1.4 joystick_button.cxx,1.1,1.2 mouse_button.cxx,1.1,1.2
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input scroller_factory.cxx,NONE,1.1 scroller_factory.hxx,NONE,1.1
- Index(es):