[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/input axis_factory.cxx,NONE,1.1 axis_
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/input axis_factory.cxx,NONE,1.1 axis_factory.hxx,NONE,1.1 |
Date: |
9 Jul 2002 16:03:35 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/input
In directory dark:/tmp/cvs-serv9026
Added Files:
axis_factory.cxx axis_factory.hxx
Log Message:
creates an axis object
--- NEW FILE: axis_factory.cxx ---
// $Id: axis_factory.cxx,v 1.1 2002/07/09 16:03:32 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 <stdlib.h>
#include "../xml_helper.hxx"
#include "../pingus_error.hxx"
#include "button_axis.hxx"
#include "inverted_axis.hxx"
#include "joystick_axis.hxx"
#include "mouse_axis.hxx"
#include "axis_factory.hxx"
#include "button_factory.hxx"
#include "button.hxx"
namespace Input {
Axis* AxisFactory::create(xmlNodePtr cur)
{
if (xmlIsBlankNode(cur))
cur = cur->next;
if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "button-axis"))
return button_axis(cur);
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"inverted-axis"))
return inverted_axis(cur);
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name),
"joystick-axis"))
return joystick_axis(cur);
else if ( ! strcmp(reinterpret_cast<const char*>(cur->name), "mouse-axis"))
return mouse_axis(cur);
else
throw PingusError("Unknown axis type: " +
std::string(reinterpret_cast<const char*>(cur->name)));
}
Axis* AxisFactory::button_axis (xmlNodePtr cur)
{
char * angle_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("id")));
float angle = atof(angle_str);
free(angle_str);
cur = cur->children;
Button* button1 = ButtonFactory::create(cur);
cur = cur->next;
Button* button2 = ButtonFactory::create(cur);
return new ButtonAxis(angle, button1, button2);
}
Axis* AxisFactory::inverted_axis (xmlNodePtr cur)
{
return new InvertedAxis(create(cur->children));
}
Axis* AxisFactory::joystick_axis (xmlNodePtr cur)
{
char * angle_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("angle")));
char * id_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("id")));
char * axis_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("axis")));
float angle = atof(angle_str);
int id = atoi(id_str);
int axis = atoi(axis_str);
free(angle_str);
free(id_str);
free(axis_str);
return new JoystickAxis(id, axis, angle);
}
Axis* AxisFactory::mouse_axis (xmlNodePtr cur)
{
char * angle_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("angle")));
char * axis_str = reinterpret_cast<char *>(xmlGetProp(cur,
reinterpret_cast<const xmlChar*>("axis")));
float angle = atof(angle_str);
int axis = atoi(axis_str);
free(angle_str);
free(axis_str);
return new MouseAxis(axis, angle);
}
}
/* EOF */
--- NEW FILE: axis_factory.hxx ---
// $Id: axis_factory.hxx,v 1.1 2002/07/09 16:03:32 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_POINTER_FACTORY_HXX
#define HEADER_PINGUS_INPUT_POINTER_FACTORY_HXX
#include "../libxmlfwd.hxx"
class Axis;
namespace Input {
class AxisFactory
{
private:
static inline Axis* button_axis (xmlNodePtr cur);
static inline Axis* inverted_axis (xmlNodePtr cur);
static inline Axis* joystick_axis (xmlNodePtr cur);
static inline Axis* mouse_axis (xmlNodePtr cur);
public:
static Axis* create (xmlNodePtr cur);
};
}
#endif
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/input axis_factory.cxx,NONE,1.1 axis_factory.hxx,NONE,1.1,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,NONE,1.1 button_factory.hxx,NONE,1.1
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/doc controller.xml,1.1,1.2
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input button_factory.cxx,NONE,1.1 button_factory.hxx,NONE,1.1
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/doc controller.xml,1.1,1.2
- Index(es):