pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src demo_recorder.cxx,1.15,1.16 story_scr


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src demo_recorder.cxx,1.15,1.16 story_screen.cxx,1.7,1.8 xml_helper.cxx,1.27,1.28xml_helper.hxx,1.19,1.20
Date: 4 Apr 2003 11:23:29 -0000

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv15621

Modified Files:
        demo_recorder.cxx story_screen.cxx xml_helper.cxx 
        xml_helper.hxx 
Log Message:
- convert UTF8 stuff to Iso-latin-1, should fix umlaut problems in xml files

Index: demo_recorder.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/demo_recorder.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- demo_recorder.cxx   30 Mar 2003 20:43:52 -0000      1.15
+++ demo_recorder.cxx   4 Apr 2003 11:23:27 -0000       1.16
@@ -29,15 +29,16 @@
   : record_demo (true)
 {
   std::string levelname = server->get_plf()->get_resname();
-  
+  std::string flat_levelname = levelname;
+
   // 'Flatten' the levelname so that we don't need directories
-  for (std::string::iterator i = levelname.begin(); i != levelname.end(); ++i)
+  for (std::string::iterator i = flat_levelname.begin(); i != 
flat_levelname.end(); ++i)
     if (*i == '/')
       *i = '_';
 
   if (!levelname.empty())
     {
-      std::string filename = System::get_statdir() + "demos/" + levelname + 
"-" + get_date() + ".xml";
+      std::string filename = System::get_statdir() + "demos/" + flat_levelname 
+ "-" + get_date() + ".xml";
       out.open(filename.c_str());
 
       if (!out)

Index: story_screen.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/story_screen.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- story_screen.cxx    28 Mar 2003 13:06:55 -0000      1.7
+++ story_screen.cxx    4 Apr 2003 11:23:27 -0000       1.8
@@ -110,10 +110,7 @@
   time_passed  = 0;
 
   pages.push_back(StoryPage(ResDescriptor("Story/story0", "story"), 
-                            "Page 1Dies ist ein Tet blabla, sehr lang blabla 
und mit umbruechen blabal\n"
-                            "Zeile zwei mehr text blabla umbrauchuauaneh 
usnthu snaotehu nostehusano\n"
-                            "authh nth pte thuat nth auntheun tahneuth oentuh 
oentuhontu hoantuhetuh\n"
-                            "aoeuth htnh30  003 0238p[ 8eu ntuhnt hnthneat'hur 
 rcg rg th th tnh "));
+                            "äÄÁÓöÖaoeuth htnh30  003 0238p[ 8eu ntuhnt 
hnthneat'hur  rcg rg th th tnh "));
 
   pages.push_back(StoryPage(ResDescriptor("Story/story1", "story"), 
                             "Page 2Dies ist ein Tet blabla, sehr lang blabla 
und mit umbruechen blabal\n"
@@ -137,16 +134,17 @@
 
   current_page = pages.back();
   page_surface = PingusResource::load_surface(current_page.image);
-  background   = PingusResource::load_surface("Story/background", "story");
+  background   = PingusResource::load_surface("menu/startscreenbg", "core");
 }
 
 void
 StoryScreenComponent::draw (GraphicContext& gc)
 {
   gc.draw(background, 0, 0);
-  gc.print_center(Fonts::pingus_large, 400, 20, "Chapter 1 - Enter the 
unknown...");
-  gc.draw(page_surface,  gc.get_width()/2 - page_surface.get_width()/2, 90);
-  gc.print_left(Fonts::pingus_small, 100, 315, display_text);
+  gc.print_center(Fonts::chalk_large, 400, 100, "Chapter 1 - Training Day - 
,bD(B");
+  gc.draw(page_surface,  gc.get_width()/2 - page_surface.get_width()/2,
+          160);
+  gc.print_left(Fonts::chalk_normal, 120, 335, display_text);
 }
 
 void
@@ -213,5 +211,9 @@
         }
     }
 }
+
+// Local Variables: ***
+// coding:iso-latin-1
+// End: ***
 
 /* EOF */

Index: xml_helper.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- xml_helper.cxx      25 Mar 2003 00:37:44 -0000      1.27
+++ xml_helper.cxx      4 Apr 2003 11:23:27 -0000       1.28
@@ -119,11 +119,11 @@
 bool
 XMLhelper::node_list_get_string (xmlDocPtr doc, xmlNodePtr cur, int inLine, 
std::string& value)
 {
-  char * retval = reinterpret_cast<char*>(xmlNodeListGetString(doc, cur, 
inLine));
+  xmlChar* retval = xmlNodeListGetString(doc, cur, inLine);
   if (!retval)
     return false;
     
-  value = retval;
+  value = xmlChar2string(retval);
   xmlFree(retval);
   return true;
 }
@@ -455,6 +455,31 @@
 #endif
 }
 
-/* EOF */
-
+std::string
+XMLhelper::xmlChar2string(const xmlChar* in)
+{
+  int in_len = xmlUTF8Strlen(in) + 1;
+  int out_len = in_len;
+  unsigned char* out = new unsigned char[out_len];
+  int ret = UTF8Toisolat1(out, &out_len, in,  &in_len);
+    
+  if (ret != 0)
+    {
+      std::cout << "Error: XMLhelper: Encoding failed: ret: " << ret 
+                << " in: " << in_len
+                << " out: " << out_len
+                << " str: " << reinterpret_cast<const char*>(in)
+                << std::endl;
+      delete[] out;
+      return reinterpret_cast<const char*>(in);
+    }
+  else
+    {
+      out[out_len-1] = '\0';
+      std::string ret_str = reinterpret_cast<char*>(out);
+      delete[] out;
+      return ret_str;
+    }
+}
 
+/* EOF */

Index: xml_helper.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_helper.hxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- xml_helper.hxx      25 Mar 2003 00:37:44 -0000      1.19
+++ xml_helper.hxx      4 Apr 2003 11:23:27 -0000       1.20
@@ -63,10 +63,13 @@
 public:
   static std::string encode_entities (const std::string& arg_str);
 
+  /** Convert a xmlChar into latin-1 and return it */
+  static std::string xmlChar2string(const xmlChar* str);
+
   /** @return if \a cur is a blank-node, goto the next, else return \a
       cur */
   static xmlNodePtr skip_blank (xmlNodePtr cur);
-  
+
   /** Compare a xmlChar* string with a char* one 
       @return true if both strings are equal */
   static bool equal_str (const xmlChar* comp, const char* orig);





reply via email to

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