[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input inverted_scroller.cxx,NONE,1.1
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input inverted_scroller.cxx,NONE,1.1 inverted_scroller.hxx,NONE,1.1 multiple_scroller.cxx,NONE,1.1 multiple_scroller.hxx,NONE,1.1 joystick_scroller.cxx,1.1,1.2 scroller_factory.cxx,1.1,1.2 scroller_factory.hxx,1.1,1.2 |
Date: |
12 Jul 2002 12:36:16 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv23267
Modified Files:
joystick_scroller.cxx scroller_factory.cxx
scroller_factory.hxx
Added Files:
inverted_scroller.cxx inverted_scroller.hxx
multiple_scroller.cxx multiple_scroller.hxx
Log Message:
two new scrollers
--- NEW FILE: inverted_scroller.cxx ---
// $Id: inverted_scroller.cxx,v 1.1 2002/07/12 12:36:14 torangan Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "inverted_scroller.hxx"
namespace Input {
InvertedScroller::InvertedScroller (Scroller* scroller_, bool invert_x_, bool
invert_y_) : scroller(scroller_), invert_x(invert_x_), invert_y(invert_y_)
{
}
InvertedScroller::~InvertedScroller ()
{
delete scroller;
}
float
InvertedScroller::get_x_delta ()
{
return x_pos;
}
float
InvertedScroller::get_y_delta ()
{
return y_pos;
}
void
InvertedScroller::get_delta (float& x, float& y)
{
x = x_pos;
y = y_pos;
}
void
InvertedScroller::update (float delta)
{
scroller->update(delta);
(invert_x) ? x_pos = -(scroller->get_x_delta()) : x_pos =
scroller->get_x_delta();
(invert_y) ? y_pos = -(scroller->get_y_delta()) : x_pos =
scroller->get_y_delta();
}
}
/* EOF */
--- NEW FILE: inverted_scroller.hxx ---
// $Id: inverted_scroller.hxx,v 1.1 2002/07/12 12:36:14 torangan Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PINGUS_INPUT_INVERTED_SCROLLER_HXX
#define HEADER_PINGUS_INPUT_INVERTED_SCROLLER_HXX
#include "scroller.hxx"
namespace Input {
class InvertedScroller : public Scroller {
private:
Scroller* scroller;
bool invert_x;
bool invert_y;
float x_pos;
float y_pos;
public:
InvertedScroller (Scroller* scroller_, bool invert_x_, bool invert_y_);
~InvertedScroller ();
float get_x_delta ();
float get_y_delta ();
void get_delta (float& x, float& y);
void update (float delta);
};
}
#endif
/* EOF */
--- NEW FILE: multiple_scroller.cxx ---
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "multiple_scroller.hxx"
namespace Input {
MultipleScroller::MultipleScroller (const std::vector<Scroller*>& scrollers_)
: scrollers(scrollers_)
{
}
MultipleScroller::~MultipleScroller ()
{
for (std::vector<Scroller*>::const_iterator it = scrollers.begin(); it !=
scrollers.end(); it++)
delete *it;
}
float
MultipleScroller::get_x_delta ()
{
return x_pos;
}
float
MultipleScroller::get_y_delta ()
{
return y_pos;
}
void
MultipleScroller::get_delta (float& x, float& y)
{
x = x_pos;
y = y_pos;
}
void
MultipleScroller::update (float delta)
{
bool found_delta = false;
for (std::vector<Scroller*>::const_iterator it = scrollers.begin(); it !=
scrollers.end(); it++)
{
(*it)->update(delta);
if (!found_delta && ((*it)->get_x_delta() || (*it)->get_y_delta()))
{
x_pos = (*it)->get_x_delta();
y_pos = (*it)->get_y_delta();
found_delta = true;
}
}
}
}
/* EOF */
--- NEW FILE: multiple_scroller.hxx ---
// $Id: multiple_scroller.hxx,v 1.1 2002/07/12 12:36:14 torangan Exp $
//
// Pingus - A free Lemmings clone
// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_PINGUS_INPUT_MULTIPLE_SCROLLER_HXX
#define HEADER_PINGUS_INPUT_MULTIPLE_SCROLLER_HXX
#include <vector>
#include "scroller.hxx"
namespace Input {
class MultipleScroller : public Scroller {
private:
std::vector<Scroller*> scrollers;
float x_pos;
float y_pos;
public:
MultipleScroller (const std::vector<Scroller*>& scrollers_);
~MultipleScroller ();
float get_x_delta ();
float get_y_delta ();
void get_delta (float& x, float& y);
void update (float delta);
};
}
#endif
/* EOF */
Index: joystick_scroller.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/joystick_scroller.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- joystick_scroller.cxx 11 Jul 2002 14:51:10 -0000 1.1
+++ joystick_scroller.cxx 12 Jul 2002 12:36:14 -0000 1.2
@@ -62,4 +62,3 @@
}
/* EOF */
-
Index: scroller_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/scroller_factory.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- scroller_factory.cxx 11 Jul 2002 16:09:08 -0000 1.1
+++ scroller_factory.cxx 12 Jul 2002 12:36:14 -0000 1.2
@@ -25,8 +25,10 @@
#include "axis_scroller.hxx"
#include "button.hxx"
#include "button_factory.hxx"
+#include "inverted_scroller.hxx"
#include "joystick_scroller.hxx"
#include "mouse_scroller.hxx"
+#include "multiple_scroller.hxx"
#include "pointer.hxx"
#include "pointer_factory.hxx"
#include "pointer_scroller.hxx"
@@ -46,12 +48,18 @@
if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "axis-scroller"))
return axis_scroller(cur);
+ else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"inverted-scroller"))
+ return inverted_scroller(cur);
+
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"joystick-scroller"))
return joystick_scroller(cur);
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"mouse-scroller"))
return mouse_scroller(cur);
+ else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"multiple-scroller"))
+ return multiple_scroller(cur);
+
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"pointer-scroller"))
return pointer_scroller(cur);
@@ -86,6 +94,34 @@
return new AxisScroller(axis1, axis2, speed);
}
+
+ Scroller*
+ ScrollerFactory::inverted_scroller (xmlNodePtr cur)
+ {
+ char * invert_x_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("invert-x")));
+ if (!invert_x_str)
+ throw PingusError("InvertedScroller without invert X parameter");
+
+ char * invert_y_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("invert-y")));
+ if (!invert_y_str)
+ throw PingusError("InvertedScroller without invert Y parameter");
+
+ bool invert_x = strtol(invert_x_str, reinterpret_cast<char**>(NULL), 10);
+ bool invert_y = strtol(invert_x_str, reinterpret_cast<char**>(NULL), 10);
+
+ free(invert_x_str);
+ free(invert_y_str);
+
+ Scroller* scroller;
+ cur = cur->children;
+
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+
+ scroller = create(cur);
+
+ return new InvertedScroller(scroller, invert_x, invert_y);
+ }
Scroller*
ScrollerFactory::joystick_scroller (xmlNodePtr cur)
@@ -111,6 +147,25 @@
ScrollerFactory::mouse_scroller (xmlNodePtr)
{
return new MouseScroller;
+ }
+
+ Scroller*
+ ScrollerFactory::multiple_scroller (xmlNodePtr cur)
+ {
+ std::vector<Scroller*> scrollers;
+
+ cur = cur->children;
+
+ while (cur)
+ {
+ if (xmlIsBlankNode(cur))
+ cur = cur->next;
+
+ scrollers.push_back(create(cur));
+ cur = cur->next;
+ }
+
+ return new MultipleScroller(scrollers);
}
Scroller*
Index: scroller_factory.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/scroller_factory.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- scroller_factory.hxx 11 Jul 2002 16:09:08 -0000 1.1
+++ scroller_factory.hxx 12 Jul 2002 12:36:14 -0000 1.2
@@ -30,8 +30,10 @@
{
private:
static inline Scroller* axis_scroller (xmlNodePtr cur);
+ static inline Scroller* inverted_scroller (xmlNodePtr cur);
static inline Scroller* joystick_scroller (xmlNodePtr cur);
static inline Scroller* mouse_scroller (xmlNodePtr cur);
+ static inline Scroller* multiple_scroller (xmlNodePtr cur);
static inline Scroller* pointer_scroller (xmlNodePtr cur);
public:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input inverted_scroller.cxx,NONE,1.1 inverted_scroller.hxx,NONE,1.1 multiple_scroller.cxx,NONE,1.1 multiple_scroller.hxx,NONE,1.1 joystick_scroller.cxx,1.1,1.2 scroller_factory.cxx,1.1,1.2 scroller_factory.hxx,1.1,1.2,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input scroller_factory.cxx,NONE,1.1 scroller_factory.hxx,NONE,1.1
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input dummy_scroller.hxx,NONE,1.1 Makefile.am,1.16,1.17
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input scroller_factory.cxx,NONE,1.1 scroller_factory.hxx,NONE,1.1
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input dummy_scroller.hxx,NONE,1.1 Makefile.am,1.16,1.17
- Index(es):