[Orxonox-commit 610] r3142 - in branches/pch/src: orxonox/overlays/console orxonox/overlays/hud util

rgrieder at orxonox.net rgrieder at orxonox.net
Wed Jun 10 22:49:05 CEST 2009


Author: rgrieder
Date: 2009-06-10 22:49:04 +0200 (Wed, 10 Jun 2009)
New Revision: 3142

Added:
   branches/pch/src/util/UTFStringConversions.h
Modified:
   branches/pch/src/orxonox/overlays/console/InGameConsole.cc
   branches/pch/src/orxonox/overlays/console/InGameConsole.h
   branches/pch/src/orxonox/overlays/hud/ChatOverlay.cc
   branches/pch/src/util/MultiTypeValue.h
Log:
Move std::string to Ogre::UTFString conversion to util.

Modified: branches/pch/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- branches/pch/src/orxonox/overlays/console/InGameConsole.cc	2009-06-10 20:48:29 UTC (rev 3141)
+++ branches/pch/src/orxonox/overlays/console/InGameConsole.cc	2009-06-10 20:49:04 UTC (rev 3142)
@@ -40,6 +40,7 @@
 #include "util/Math.h"
 #include "util/Convert.h"
 #include "util/Debug.h"
+#include "util/UTFStringConversions.h"
 #include "core/Clock.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -465,14 +466,14 @@
                 while (output.size() > this->maxCharsPerLine_)
                 {
                     ++linesUsed;
-                    this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output.substr(0, this->maxCharsPerLine_)));
+                    this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output.substr(0, this->maxCharsPerLine_)));
                     output.erase(0, this->maxCharsPerLine_);
                     output.insert(0, 1, ' ');
                     if (linesUsed > numLinesShifted_ || alwaysShift)
                         this->shiftLines();
                     this->colourLine(level, index);
                 }
-                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
                 this->displayedText_ = output;
                 this->numLinesShifted_ = linesUsed;
             }
@@ -490,7 +491,7 @@
                 else
                   this->inputWindowStart_ = 0;
                 this->displayedText_ = output;
-                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+                this->consoleOverlayTextAreas_[index]->setCaption(multi_cast<Ogre::UTFString>(output));
             }
         }
     }
@@ -605,22 +606,4 @@
     {
         InGameConsole::getInstance().deactivate();
     }
-
-    /**
-        @brief Converts a string into an Ogre::UTFString.
-        @param s The string to convert
-        @return The converted string
-    */
-    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text)
-    {
-        Ogre::UTFString utf;
-        Ogre::UTFString::code_point cp;
-        for (unsigned int i = 0; i < text.size(); ++i)
-        {
-          cp = text[i];
-          cp &= 0xFF;
-          utf.append(1, cp);
-        }
-        return utf;
-    }
 }

Modified: branches/pch/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- branches/pch/src/orxonox/overlays/console/InGameConsole.h	2009-06-10 20:48:29 UTC (rev 3141)
+++ branches/pch/src/orxonox/overlays/console/InGameConsole.h	2009-06-10 20:49:04 UTC (rev 3142)
@@ -60,8 +60,6 @@
         static void openConsole();
         static void closeConsole();
 
-        static Ogre::UTFString convert2UTF(const std::string& text);
-
     private: // functions
         InGameConsole(const InGameConsole& other);
 

Modified: branches/pch/src/orxonox/overlays/hud/ChatOverlay.cc
===================================================================
--- branches/pch/src/orxonox/overlays/hud/ChatOverlay.cc	2009-06-10 20:48:29 UTC (rev 3141)
+++ branches/pch/src/orxonox/overlays/hud/ChatOverlay.cc	2009-06-10 20:49:04 UTC (rev 3142)
@@ -30,6 +30,7 @@
 
 #include <OgreTextAreaOverlayElement.h>
 
+#include "util/UTFStringConversions.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/Executor.h"
@@ -38,7 +39,6 @@
 
 #include "PlayerManager.h"
 #include "objects/infos/PlayerInfo.h"
-#include "overlays/console/InGameConsole.h"
 #include "tools/Timer.h"
 
 #include "util/Convert.h"
@@ -85,7 +85,7 @@
             text = message;
         }
 
-        this->messages_.push_back(InGameConsole::convert2UTF(text));
+        this->messages_.push_back(multi_cast<Ogre::UTFString>(text));
         COUT(0) << "Chat: " << text << std::endl;
 
         new Timer<ChatOverlay>(this->displayTime_, false, this, createExecutor(createFunctor(&ChatOverlay::dropMessage)), true);

Modified: branches/pch/src/util/MultiTypeValue.h
===================================================================
--- branches/pch/src/util/MultiTypeValue.h	2009-06-10 20:48:29 UTC (rev 3141)
+++ branches/pch/src/util/MultiTypeValue.h	2009-06-10 20:49:04 UTC (rev 3142)
@@ -193,7 +193,8 @@
         saveAndIncrease( this->value_.y, mem );
         saveAndIncrease( this->value_.z, mem );
         saveAndIncrease( this->value_.w, mem );
-    }template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const
+    }
+    template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const
     {
         return 4*returnSize(this->value_.x);
     }

Added: branches/pch/src/util/UTFStringConversions.h
===================================================================
--- branches/pch/src/util/UTFStringConversions.h	                        (rev 0)
+++ branches/pch/src/util/UTFStringConversions.h	2009-06-10 20:49:04 UTC (rev 3142)
@@ -0,0 +1,61 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ */
+
+/**
+ at file
+ at brief
+    std::sring to Ogre::UTFString conversion functions
+*/
+
+#ifndef _UTFStringConversions_H__
+#define _UTFStringConversions_H__
+
+#include "UtilPrereqs.h"
+#include <OgreUTFString.h>
+
+namespace orxonox
+{
+    template <>
+    struct ConverterExplicit<std::string, Ogre::UTFString>
+    {
+        //! Converts an std::string into an Ogre::UTFString
+        inline static bool convert(Ogre::UTFString* output, const std::string& input)
+        {
+            Ogre::UTFString::code_point cp;
+            for (unsigned int i = 0; i < input.size(); ++i)
+            {
+              cp = input[i];
+              cp &= 0xFF;
+              output->append(1, cp);
+            }
+            return true;
+        }
+    };
+}
+
+#endif /* _UTFStringConversions_H__ */


Property changes on: branches/pch/src/util/UTFStringConversions.h
___________________________________________________________________
Added: svn:eol-style
   + native




More information about the Orxonox-commit mailing list