pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src xml_reader.cxx,NONE,1.1 xml_reader.hx


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src xml_reader.cxx,NONE,1.1 xml_reader.hxx,NONE,1.1 Makefile.am,1.129,1.130 game_delta.hxx,1.13,1.14 layer_manager.cxx,1.2,1.3 menu_background.cxx,1.4,1.5 screen_manager.cxx,1.28,1.29
Date: 18 Feb 2003 00:13:15 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv11209

Modified Files:
        Makefile.am game_delta.hxx layer_manager.cxx 
        menu_background.cxx screen_manager.cxx 
Added Files:
        xml_reader.cxx xml_reader.hxx 
Log Message:
- disabled unfinished GUI object inserter in editor
- added helper class for xml parsing


--- NEW FILE: xml_reader.cxx ---
//  $Id: xml_reader.cxx,v 1.1 2003/02/18 00:13:13 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 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 "xml_helper.hxx"
#include "xml_reader.hxx"

XMLReader::XMLReader(xmlDocPtr d, xmlNodePtr n)
  : doc(d), root_node(n), current_node(n)
{
  if (xmlIsBlankNode(current_node))
    current_node = current_node->next;
}

xmlNodePtr
XMLReader::find_node(const char* name)
{
  xmlNodePtr cur = current_node;
  while (cur)
    {
      if (XMLhelper::equal_str(cur->name, name))
        return cur;
      cur = next_node(cur);
    }
  return NULL;
}
  
bool
XMLReader::read_vector(const char* name, Vector& vec)
{
  xmlNodePtr cur = find_node(name);
  if (cur && XMLhelper::equal_str(cur->name, name))
    {
      vec = XMLhelper::parse_vector(doc, cur);
      return true;
    }
  return false;
}

bool
XMLReader::read_string(const char* name, std::string& str)
{
  xmlNodePtr cur = current_node;
  while (cur)
    {
      if (XMLhelper::equal_str(cur->name, name))
        {
          str = XMLhelper::parse_string(doc, cur);
          return true;
        }
      cur = next_node(cur);
    }
  return false;
}

bool
XMLReader::read_resdesc(const char* name, ResDescriptor& resdesc)
{
  xmlNodePtr cur = current_node;
  while (cur)
    {
      if (XMLhelper::equal_str(cur->name, name))
        {
          resdesc = XMLhelper::parse_surface(doc, cur);
          return true;
        }
      cur = next_node(cur);
    }
  
  return false;
}

xmlNodePtr
XMLReader::next_node(xmlNodePtr node)
{
  xmlNodePtr cur = node->next;
  
  if (xmlIsBlankNode(cur))
    cur = node->next;

  return cur;
}

/* EOF */

--- NEW FILE: xml_reader.hxx ---
//  $Id: xml_reader.hxx,v 1.1 2003/02/18 00:13:13 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 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_XML_READER_HXX
#define HEADER_PINGUS_XML_READER_HXX

#include <string>
#include "libxmlfwd.hxx"
#include "res_descriptor.hxx"
#include "vector.hxx"

/** */
class XMLReader
{
private:
  xmlDocPtr  doc;
  xmlNodePtr root_node;
  xmlNodePtr current_node;
public:
  XMLReader(xmlDocPtr d, xmlNodePtr n);
  
  bool read_vector (const char*, Vector&);
  bool read_string (const char*, std::string&);
  bool read_resdesc(const char*, ResDescriptor&);
private:
  xmlNodePtr next_node(xmlNodePtr n);
  xmlNodePtr find_node(const char*);
  
  XMLReader (const XMLReader&);
  XMLReader& operator= (const XMLReader&);
};

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- Makefile.am 17 Feb 2003 18:23:05 -0000      1.129
+++ Makefile.am 18 Feb 2003 00:13:13 -0000      1.130
@@ -316,6 +316,8 @@
 xml_plf.cxx \
 xml_plf.hxx \
 xml_pdf.hxx \
-xml_pdf.cxx
+xml_pdf.cxx \
+xml_reader.hxx \
+xml_reader.cxx
 
 ## EOF ##

Index: game_delta.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_delta.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- game_delta.hxx      29 Dec 2002 23:29:00 -0000      1.13
+++ game_delta.hxx      18 Feb 2003 00:13:13 -0000      1.14
@@ -29,7 +29,9 @@
 {
 private:
   /** time delta since the last update */
-  const DeltaManager& time_delta;
+  const float time_delta;
+
+  const unsigned int absolute_time;
     
   /** Reference to the event list from the controller, we must not
       delete the Event* */
@@ -37,16 +39,19 @@
     
 public:
   /** Construct a GameDelta with both time and events */
-  GameDelta (const DeltaManager& d,
+  GameDelta (float time_delta_arg,
+             unsigned int absolute_time_arg,
              const Input::EventLst& e)
-    : time_delta (d), events (e) {}
+    : time_delta (time_delta_arg),
+      absolute_time (absolute_time_arg),
+      events (e) {}
 
   /** Return the time that has passed in seconds since the last update() */
-  float get_time () const { return time_delta.get(); }
+  float get_time () const { return time_delta; }
 
   /** @return the time since the application startup in miliseconds
       (1/1000 second) */
-  unsigned int get_absolute_time () const { return time_delta.get_absolute(); }
+  unsigned int get_absolute_time () const { return absolute_time; }
 
   /** Return the events */
   const Input::EventLst& get_events () const { return events; }

Index: layer_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/layer_manager.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- layer_manager.cxx   17 Aug 2002 17:56:23 -0000      1.2
+++ layer_manager.cxx   18 Feb 2003 00:13:13 -0000      1.3
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <iostream>
 #include "layer_manager.hxx"
 
 LayerManager::LayerManager ()

Index: menu_background.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/menu_background.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- menu_background.cxx 6 Oct 2002 19:23:43 -0000       1.4
+++ menu_background.cxx 18 Feb 2003 00:13:13 -0000      1.5
@@ -43,7 +43,8 @@
 MenuBackground::update (float delta)
 {
 #ifndef WIN32
-   layer_manager.update (delta);
+  // FIXME: WIN32 shouldn't be an issue here
+  layer_manager.update (delta);
 #endif
 }
 

Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- screen_manager.cxx  29 Dec 2002 23:29:00 -0000      1.28
+++ screen_manager.cxx  18 Feb 2003 00:13:13 -0000      1.29
@@ -46,9 +46,9 @@
   // Main loop for the menu
   while (!screens.empty())
     {
-      delta_manager.set ();
-      
-      if (delta_manager.get() > 1.0)
+      float time_delta = delta_manager.getset ();
+
+      if (time_delta > 1.0)
        {
          std::cout << "ScreenManager: detected large delta (" << 
delta_manager.get()
                    << "), ignoring and doing frameskip" << std::endl;
@@ -59,10 +59,11 @@
       CL_System::keep_alive ();
 
       // Get new events from ClanLib
-      input_controller.update (delta_manager.get());
+      input_controller.update (time_delta);
 
       // Fill the delta with values
-      GameDelta delta (delta_manager, input_controller.get_events ());
+      GameDelta delta (time_delta, delta_manager.get_absolute(), 
+                       input_controller.get_events ());
 
       last_screen = get_current_screen();
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]