pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.10,1.11 start_scre


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.10,1.11 start_screen.hxx,1.2,1.3 xml_helper.cxx,1.28,1.29
Date: 9 Apr 2003 20:20:22 -0000

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

Modified Files:
        start_screen.cxx start_screen.hxx xml_helper.cxx 
Log Message:
- changed parsing of XML Level Descriptions to LaTeX style
- fixed bug where characters where chopped off of the description


Index: start_screen.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/start_screen.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- start_screen.cxx    6 Apr 2003 14:37:07 -0000       1.10
+++ start_screen.cxx    9 Apr 2003 20:20:20 -0000       1.11
@@ -40,10 +40,14 @@
   PLFHandle plf;
   CL_Surface background;
   std::string time_str;
+ 
 public:
   StartScreenComponent(PLFHandle plf);
-  virtual ~StartScreenComponent() {}
   void draw(GraphicContext& gc);
+  virtual ~StartScreenComponent() {}
+  
+private:
+  std::string format_description(int length);
 };
 
 class StartScreenOkButton : public GUI::SurfaceButton
@@ -130,7 +134,7 @@
   background.put_screen(0,0);
   
   gc.print_center(Fonts::chalk_large, gc.get_width()/2, 100, 
System::translate(plf->get_levelname()));
-  gc.print_left(Fonts::chalk_normal, 130, 160, 
System::translate(plf->get_description()));
+  gc.print_left(Fonts::chalk_normal, 130, 160, 
format_description(gc.get_width() - 260));
 
   gc.print_left (Fonts::chalk_normal, 300, 310, _("Number of Pingus: "));
   gc.print_right(Fonts::chalk_normal, 500, 310, to_string(plf->get_pingus()));
@@ -153,6 +157,47 @@
   if (maintainer_mode)
     gc.print_left(Fonts::chalk_small, 110, 430, _("Filename: ") + 
plf->get_resname());
 }
+
+std::string
+StartScreenComponent::format_description(int length)
+{
+  std::string description = System::translate(plf->get_description());
+
+  unsigned int pos = 0;
+  while ((pos = description.find('\t', pos)) != std::string::npos)
+    description.replace(pos, 1, 1, ' ');
+  
+  pos = 0;  
+  while ((pos = description.find('\n', pos)) != std::string::npos)
+    {
+      if (description[pos + 1] == '\n')          // double enter marks 
paragraph
+        description.replace(pos++, 2, 1, '\n');  // replace the two \n by one 
and move pos behind it
+      else
+        description.replace(pos, 1, 1, ' ');
+    }
+        
+  pos = 0;
+  while ((pos = description.find("  ", pos)) != std::string::npos)
+    description.replace(pos, 2, 1, ' ');
+
+  int start_pos      = 0;
+  int previous_space = 0;
+  pos = 0;
+  while ((pos = description.find(' ', pos + 1)) != std::string::npos)
+    {
+      if (Fonts::chalk_normal->get_text_width(description.substr(start_pos, 
pos - start_pos)) > length)
+        {
+         description[previous_space] = '\n';
+         start_pos = previous_space + 1;
+       }
+      else if 
(Fonts::chalk_normal->get_text_width(description.substr(start_pos, 
description.length())) <= length)
+        break;
+
+      previous_space = pos;
+    }
+  return description;
+}
+
 
 StartScreen::StartScreen(PLFHandle arg_plf)
   : plf(arg_plf)

Index: start_screen.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/start_screen.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- start_screen.hxx    30 Mar 2003 13:12:35 -0000      1.2
+++ start_screen.hxx    9 Apr 2003 20:20:20 -0000       1.3
@@ -38,7 +38,9 @@
   void on_pause_press();
   void on_fast_forward_press();
   void on_escape_press();
+  
 private:
+
   StartScreen (const StartScreen&);
   StartScreen& operator= (const StartScreen&);
 };

Index: xml_helper.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- xml_helper.cxx      4 Apr 2003 11:23:27 -0000       1.28
+++ xml_helper.cxx      9 Apr 2003 20:20:20 -0000       1.29
@@ -458,7 +458,7 @@
 std::string
 XMLhelper::xmlChar2string(const xmlChar* in)
 {
-  int in_len = xmlUTF8Strlen(in) + 1;
+  int in_len = xmlUTF8Strsize(in, 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);





reply via email to

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