[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer ./ChangeLog src/Lib/2D/Palette.cpp sr...
From: |
Matthias Braun |
Subject: |
[netPanzer-CVS] netpanzer ./ChangeLog src/Lib/2D/Palette.cpp sr... |
Date: |
Mon, 24 Nov 2003 07:03:37 -0500 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Matthias Braun <address@hidden> 03/11/24 07:03:36
Modified files:
. : ChangeLog
src/Lib/2D : Palette.cpp Palette.hpp Surface.cpp Surface.hpp
src/Lib/Util : UtilInterface.cpp UtilInterface.hpp
src/NetPanzer/View: AbstractButton.hpp Button.cpp Button.hpp
CheckBox.cpp CheckBox.hpp Choice.cpp
Choice.hpp Component.hpp Icon.hpp
src/NetPanzer/Views/Game: GameInfoView.cpp GameInfoView.hpp
HelpScrollView.cpp HelpScrollView.hpp
LibView.cpp VehicleSelectionView.cpp
VehicleSelectionView.hpp
src/NetPanzer/Views/MainMenu: MenuTemplateView.cpp
MenuTemplateView.hpp
SpecialButtonView.cpp
src/NetPanzer/Views/MainMenu/Multi: HostOptionsView.cpp
HostOptionsView.hpp
Removed files:
src/Lib/Types : String.cpp String.hpp
src/NetPanzer/View: TextArea.cpp TextArea.hpp TextComponent.cpp
TextComponent.hpp TextField.cpp
TextField.hpp
Log message:
-eleminated the String class and replaced it with std::string
Patches:
Index: netpanzer/ChangeLog
diff -u netpanzer/ChangeLog:1.36 netpanzer/ChangeLog:1.37
--- netpanzer/ChangeLog:1.36 Sat Nov 22 10:43:09 2003
+++ netpanzer/ChangeLog Mon Nov 24 07:03:31 2003
@@ -1,3 +1,8 @@
+24-Nov-2003 by Matthias Braun
+-converted the SelectionList to std::vector, also removed limit of maximum
+ select units while doing this.
+-eleminated the String class and replaced it with std::string
+
22-Nov-2003 by Matthias Braun
-big reorganisation. Created several real libs in the lib directory and moved
some stuff inside NetPanzer directory.
Index: netpanzer/src/Lib/2D/Palette.cpp
diff -u netpanzer/src/Lib/2D/Palette.cpp:1.14
netpanzer/src/Lib/2D/Palette.cpp:1.15
--- netpanzer/src/Lib/2D/Palette.cpp:1.14 Sat Nov 22 10:43:13 2003
+++ netpanzer/src/Lib/2D/Palette.cpp Mon Nov 24 07:03:32 2003
@@ -27,7 +27,7 @@
float Palette::brightness = 1.0f;
// The name of the current loaded palette.
-String Palette::name;
+std::string Palette::name;
ColorTable Palette::colorTable2080;
ColorTable Palette::colorTable4060;
@@ -298,7 +298,7 @@
}
char tablePath[512];
- snprintf(tablePath, 512, "cache/colorfilters/%s", getName());
+ snprintf(tablePath, 512, "cache/colorfilters/%s", getName().c_str());
if(!FileSystem::exists(tablePath)) {
FileSystem::mkdir(tablePath);
}
@@ -341,10 +341,10 @@
// setName
//---------------------------------------------------------------------------
-void Palette::setName(String filename)
+void Palette::setName(const std::string& filename)
{
char strBuf[256];
- sprintf(strBuf, "%s", (const char*) UtilInterface::getFilename(filename));
+ snprintf(strBuf, 256, "%s", UtilInterface::getFilename(filename).c_str());
char *dotPtr = 0;
if ((dotPtr = strchr(strBuf, '.')) != 0) {
Index: netpanzer/src/Lib/2D/Palette.hpp
diff -u netpanzer/src/Lib/2D/Palette.hpp:1.6
netpanzer/src/Lib/2D/Palette.hpp:1.7
--- netpanzer/src/Lib/2D/Palette.hpp:1.6 Sat Nov 22 10:43:13 2003
+++ netpanzer/src/Lib/2D/Palette.hpp Mon Nov 24 07:03:33 2003
@@ -18,13 +18,13 @@
#ifndef __Palette_hpp__
#define __Palette_hpp__
+#include <string>
#include <stdio.h>
#include <stdint.h>
#include "Color.hpp"
#include "ColorTable.hpp"
#include "RGBColor.hpp"
-#include "Types/String.hpp"
const size_t PALETTE_LENGTH = 256;
@@ -35,15 +35,15 @@
static float brightness;
// The name of the current loaded palette.
- static String name;
+ static std::string name;
- static void setName(String filename);
+ static void setName(const std::string& filename);
public:
Palette();
static void setBrightness(float brightness);
- static const char *getName()
+ static const std::string& getName()
{
return name;
}
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.42
netpanzer/src/Lib/2D/Surface.cpp:1.43
--- netpanzer/src/Lib/2D/Surface.cpp:1.42 Sat Nov 22 10:43:14 2003
+++ netpanzer/src/Lib/2D/Surface.cpp Mon Nov 24 07:03:33 2003
@@ -18,10 +18,12 @@
#include <config.h>
#include <math.h>
+#include <ctype.h>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
+
#include "Util/Log.hpp"
#include "Util/FileSystem.hpp"
#include "Util/UtilInterface.hpp"
Index: netpanzer/src/Lib/2D/Surface.hpp
diff -u netpanzer/src/Lib/2D/Surface.hpp:1.19
netpanzer/src/Lib/2D/Surface.hpp:1.20
--- netpanzer/src/Lib/2D/Surface.hpp:1.19 Sat Nov 22 10:43:14 2003
+++ netpanzer/src/Lib/2D/Surface.hpp Mon Nov 24 07:03:33 2003
@@ -18,10 +18,12 @@
#ifndef __Surface_hpp__
#define __Surface_hpp__
+#include <string>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
+
#include "Types/iXY.hpp"
#include "Types/iRect.hpp"
#include "Util/NoCopy.hpp"
@@ -522,6 +524,8 @@
static int getFontHeight();
static int getTextLength(const char* text);
+ static int getTextLength(const std::string& text)
+ { return getTextLength(text.c_str()); }
}; // end Surface
#endif // __Surface_HPP__
Index: netpanzer/src/Lib/Util/UtilInterface.cpp
diff -u netpanzer/src/Lib/Util/UtilInterface.cpp:1.1
netpanzer/src/Lib/Util/UtilInterface.cpp:1.2
--- netpanzer/src/Lib/Util/UtilInterface.cpp:1.1 Sat Nov 22 10:43:20 2003
+++ netpanzer/src/Lib/Util/UtilInterface.cpp Mon Nov 24 07:03:34 2003
@@ -46,11 +46,11 @@
// getDirectory
//---------------------------------------------------------------------------
-String UtilInterface::getDirectory(String path)
+std::string UtilInterface::getDirectory(const std::string& path)
{
char strBuf[256];
- _splitpath(path, 0, strBuf, 0, 0);
+ _splitpath(path.c_str(), 0, strBuf, 0, 0);
return strBuf;
@@ -58,11 +58,11 @@
// getFilename
//---------------------------------------------------------------------------
-String UtilInterface::getFilename(String path)
+std::string UtilInterface::getFilename(const std::string& path)
{
char strBuf[256];
- _splitpath(path, 0, 0, strBuf, 0);
+ _splitpath(path.c_str(), 0, 0, strBuf, 0);
return strBuf;
@@ -70,11 +70,11 @@
// getExtension
//---------------------------------------------------------------------------
-String UtilInterface::getExtension(String path)
+std::string UtilInterface::getExtension(const std::string& path)
{
char strBuf[256];
- _splitpath(path, 0, 0, 0, strBuf);
+ _splitpath(path.c_str(), 0, 0, 0, strBuf);
return strBuf;
@@ -84,7 +84,7 @@
//---------------------------------------------------------------------------
// Purpose: Returns file size, in bytes, or 0 if file not found.
//---------------------------------------------------------------------------
-size_t UtilInterface::getFileSize(String filename)
+size_t UtilInterface::getFileSize(const std::string& filename)
{
ReadFile* file = FileSystem::openRead(filename);
size_t size = file->length();
@@ -97,7 +97,7 @@
//---------------------------------------------------------------------------
// Purpose: Returns the number of files in the specified directory.
//---------------------------------------------------------------------------
-int UtilInterface::getNumFilesInDirectory(String path)
+int UtilInterface::getNumFilesInDirectory(const std::string& path)
{
char** list = FileSystem::enumerateFiles(path);
int numfiles=0;
@@ -107,27 +107,6 @@
return numfiles;
} // end UtilInterface::getNumFilesInDirectory
-
-// deleteFile
-//---------------------------------------------------------------------------
-// Purpose: Deletes an individual file, or if wild cards are used, multiple
-// files can be saved.
-//---------------------------------------------------------------------------
-void UtilInterface::deleteFile(String path)
-{
- if (remove(path) < 0)
- printf("Couldn't remove file '%s'.\n", (const char*) path);
-} // end UtilInterface::deleteFile
-
-// checkFileError
-//---------------------------------------------------------------------------
-void UtilInterface::checkError(FILE *fp)
-{
- if (ferror(fp)) {
- throw Exception("ERROR: Possible corrupt file.");
- }
-
-} // end UtilInterface::checkError
// startRandomNumberGenerator
//---------------------------------------------------------------------------
Index: netpanzer/src/Lib/Util/UtilInterface.hpp
diff -u netpanzer/src/Lib/Util/UtilInterface.hpp:1.1
netpanzer/src/Lib/Util/UtilInterface.hpp:1.2
--- netpanzer/src/Lib/Util/UtilInterface.hpp:1.1 Sat Nov 22 10:43:20 2003
+++ netpanzer/src/Lib/Util/UtilInterface.hpp Mon Nov 24 07:03:34 2003
@@ -21,8 +21,6 @@
#include <SDL_net.h>
-#include "Types/String.hpp"
-
class Filename
{
public:
@@ -52,13 +50,11 @@
class UtilInterface
{
public:
- static String getDirectory(String path);
- static String getFilename(String path);
- static String getExtension(String path);
- static void deleteFile(String path);
- static size_t getFileSize(String filename);
- static int getNumFilesInDirectory(String path);
- static void checkError(FILE *fp);
+ static std::string getDirectory(const std::string& path);
+ static std::string getFilename(const std::string& path);
+ static std::string getExtension(const std::string& path);
+ static size_t getFileSize(const std::string& filename);
+ static int getNumFilesInDirectory(const std::string& path);
static void startRandomNumberGenerator();
// get servername/port from a string, doesn't always set the port
Index: netpanzer/src/NetPanzer/View/AbstractButton.hpp
diff -u netpanzer/src/NetPanzer/View/AbstractButton.hpp:1.1
netpanzer/src/NetPanzer/View/AbstractButton.hpp:1.2
--- netpanzer/src/NetPanzer/View/AbstractButton.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/AbstractButton.hpp Mon Nov 24 07:03:34 2003
@@ -20,7 +20,6 @@
#include "Button.hpp"
#include "Util/cTimeStamp.hpp"
-#include "Types/String.hpp"
#include "Icon.hpp"
#include "MouseEvent.hpp"
@@ -28,9 +27,9 @@
class AbstractButton : public Button
{
protected:
- String label;
- String actionCommand;
- String text;
+ std::string label;
+ std::string actionCommand;
+ std::string text;
Icon disableIcon;
Icon selectedIcon;
@@ -42,46 +41,42 @@
public:
AbstractButton()
{}
- AbstractButton(String s) : Button(s)
+ AbstractButton(const std::string& s) : Button(s)
{}
virtual ~AbstractButton()
{}
- void init(const String &text, Icon &icon)
+ void init(const std::string& text, Icon &icon)
{
AbstractButton::text = text;
AbstractButton::icon.copy(icon);
}
- void doClick()
- {}
- void doClick(TIMESTAMP time)
- {}
- const Surface& getDisableIcon()
+ const Surface& getDisableIcon() const
{
return (const Surface&) disableIcon;
}
- const Surface &getIcon()
+ const Surface &getIcon() const
{
return icon;
}
- const Surface &getPressedIcon()
+ const Surface &getPressedIcon() const
{
return pressedIcon;
}
- const Surface &getRolloverIcon()
+ const Surface &getRolloverIcon() const
{
return rolloverIcon;
}
- const Surface &getRolloverSelectedIcon()
+ const Surface &getRolloverSelectedIcon() const
{
return rolloverSelectedIcon;
}
- const Surface &getSelectedIcon()
+ const Surface &getSelectedIcon() const
{
return selectedIcon;
}
- const String &getText()
+ const std::string& getText() const
{
return text;
}
@@ -95,26 +90,10 @@
{
enabled = b;
}
- void setIcon(const Icon &icon)
- { }
- void setPressedIcon(const Icon &pressedIcon)
- { }
- void setRolloverEnabled(bool b)
- { }
- void setRolloverIcon(const Icon &rolloverIcon)
- { }
- void setSelected(bool b)
- {}
- void setSelectedIcon(Icon selectedIcon)
- {}
- void setText(String text)
- {}
virtual void actionPerformed(const mMouseEvent &me);
virtual void draw(Surface &dest)
{}
-
-}
-; // end AbstractButton
+}; // end AbstractButton
#endif // end __AbstractButton_hpp__
Index: netpanzer/src/NetPanzer/View/Button.cpp
diff -u netpanzer/src/NetPanzer/View/Button.cpp:1.1
netpanzer/src/NetPanzer/View/Button.cpp:1.2
--- netpanzer/src/NetPanzer/View/Button.cpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Button.cpp Mon Nov 24 07:03:34 2003
@@ -31,15 +31,15 @@
if (highlighted) {
dest.fillRect(bounds, componentBodyColor);
dest.drawButtonBorder(bounds, topLeftBorderColor,
bottomRightBorderColor);
- dest.bltStringCenteredInRect(bounds, (const char *) label, Color::red);
+ dest.bltStringCenteredInRect(bounds, label.c_str(), Color::red);
} else if (clicked) {
dest.fillRect(bounds, componentBodyColor);
dest.drawButtonBorder(bounds, bottomRightBorderColor,
topLeftBorderColor);
- dest.bltStringCenteredInRect(bounds, (const char *) label,
Color::yellow);
+ dest.bltStringCenteredInRect(bounds, label.c_str(), Color::yellow);
} else {
dest.fillRect(bounds, componentBodyColor);
dest.drawButtonBorder(bounds, topLeftBorderColor,
bottomRightBorderColor);
- dest.bltStringCenteredInRect(bounds, (const char *) label,
Color::white);
+ dest.bltStringCenteredInRect(bounds, label.c_str(), Color::white);
}
} // end Button::draw
Index: netpanzer/src/NetPanzer/View/Button.hpp
diff -u netpanzer/src/NetPanzer/View/Button.hpp:1.1
netpanzer/src/NetPanzer/View/Button.hpp:1.2
--- netpanzer/src/NetPanzer/View/Button.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Button.hpp Mon Nov 24 07:03:34 2003
@@ -26,8 +26,8 @@
class Button : public Component
{
protected:
- String label;
- String actionCommand;
+ std::string label;
+ std::string actionCommand;
bool highlighted;
bool clicked;
@@ -37,7 +37,7 @@
reset();
}
- Button(String s) : Component()
+ Button(const std::string& s) : Component()
{
reset();
@@ -60,25 +60,20 @@
return highlighted;
}
- void setActionCommand(String l)
+ void setActionCommand(const std::string& l)
{
label = l;
}
- void setLabel(String l)
+ void setLabel(const std::string& l)
{
label = l;
}
- String paramString()
- {
- return String();
- }
-
- String getLabel()
+ const std::string& getLabel() const
{
return label;
}
- String getActionCommand()
+ const std::string& getActionCommand() const
{
return actionCommand;
}
Index: netpanzer/src/NetPanzer/View/CheckBox.cpp
diff -u netpanzer/src/NetPanzer/View/CheckBox.cpp:1.1
netpanzer/src/NetPanzer/View/CheckBox.cpp:1.2
--- netpanzer/src/NetPanzer/View/CheckBox.cpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/CheckBox.cpp Mon Nov 24 07:03:34 2003
@@ -85,7 +85,7 @@
pos.x = min.x + size.x + 8;
pos.y = min.y + (size.y - Surface::getFontHeight()) / 2;
- dest.bltString(pos, (const char *) label, Color::white);
+ dest.bltString(pos, label.c_str(), Color::white);
} // end CheckBox::drawLabel
// actionPerformed
Index: netpanzer/src/NetPanzer/View/CheckBox.hpp
diff -u netpanzer/src/NetPanzer/View/CheckBox.hpp:1.1
netpanzer/src/NetPanzer/View/CheckBox.hpp:1.2
--- netpanzer/src/NetPanzer/View/CheckBox.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/CheckBox.hpp Mon Nov 24 07:03:34 2003
@@ -28,7 +28,7 @@
class CheckBox : public Component
{
protected:
- String label;
+ std::string label;
bool state;
StateChangedCallback* callback;
@@ -43,7 +43,7 @@
size = iXY(14, 14);
}
- CheckBox(const String &newlabel, bool newstate = false)
+ CheckBox(const std::string& newlabel, bool newstate = false)
: Component(), label(newlabel), state(newstate), callback(0)
{
size = iXY(14, 14);
@@ -52,7 +52,7 @@
virtual ~CheckBox()
{ }
- String getLabel() const
+ const std::string& getLabel() const
{
return label;
}
@@ -61,7 +61,7 @@
return state;
}
- void setLabel(String label)
+ void setLabel(const std::string& label)
{
CheckBox::label = label;
}
Index: netpanzer/src/NetPanzer/View/Choice.cpp
diff -u netpanzer/src/NetPanzer/View/Choice.cpp:1.1
netpanzer/src/NetPanzer/View/Choice.cpp:1.2
--- netpanzer/src/NetPanzer/View/Choice.cpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Choice.cpp Mon Nov 24 07:03:34 2003
@@ -35,11 +35,9 @@
}
//---------------------------------------------------------------------------
-void Choice::addItem(const String &item)
+void Choice::addItem(const std::string& item)
{
- choiceList.setNum(choiceList.getCount() + 1);
-
- choiceList[choiceList.getCount() - 1] = item;
+ choiceList.push_back(item);
int borderSpace = borderSize * 2;
@@ -48,10 +46,10 @@
}
//---------------------------------------------------------------------------
-void Choice::select(const String &item)
+void Choice::select(const std::string& item)
{
- for (int i = 0; i < choiceList.getCount(); i++) {
- if (strcmp((const char *) item, (const char *) choiceList[i]) == 0) {
+ for(size_t i = 0; i < choiceList.size(); i++) {
+ if(choiceList[i] == item) {
if(index == i)
return;
@@ -65,9 +63,9 @@
}
//---------------------------------------------------------------------------
-void Choice::select(int index)
+void Choice::select(size_t index)
{
- assert(index >= 0 && index < choiceList.getCount());
+ assert(index < choiceList.size());
if(index == Choice::index)
return;
@@ -88,7 +86,7 @@
isOpen = true;
// Set the size to accomodate all items.
- size.y = choiceList.getCount() * ChoiceItemHeight;
+ size.y = choiceList.size() * ChoiceItemHeight;
// Make sure the choice fits on the screen.
if (min.y + size.y >= parentDimensions.y) {
@@ -114,7 +112,7 @@
iRect r(min.x, min.y, min.x + size.x, min.y + ChoiceItemHeight);
- for (int i = 0; i < choiceList.getCount(); i++) {
+ for (size_t i = 0; i < choiceList.size(); i++) {
// Find the selected item.
if (r.contains(iXY(me.getX(), me.getY()))) {
mouseover = i;
@@ -181,7 +179,7 @@
pos.y = min.y - Surface::getFontHeight() - 4;
// Draw the name of the choice.
- dest.bltStringShadowed(min.x, pos.y + adjustedY, (const char *) name,
Color::white, Color::black);
+ dest.bltStringShadowed(min.x, pos.y + adjustedY, name.c_str(),
Color::white, Color::black);
getBounds(r);
@@ -193,22 +191,22 @@
s.fillRect(iRect(1, 1, s.getPixX() - 2, s.getPixY() - 2),
Color::terreVerte);
if (!isOpen) {
- s.bltStringShadowedCenter(choiceList[index], Color::white,
Color::black);
+ s.bltStringShadowedCenter(choiceList[index].c_str(), Color::white,
Color::black);
} else {
r = iRect(min.x, min.y, min.x + size.x, min.y + ChoiceItemHeight);
- int count = choiceList.getCount();
+ size_t count = choiceList.size();
- for (int i = 0; i < count; i++) {
+ for (size_t i = 0; i < count; i++) {
s.setTo(dest, r);
if (i == mouseover) {
// Higlight the selected item.
s.fill(Color::white);
- s.bltStringCenter(choiceList[i], Color::black);
+ s.bltStringCenter(choiceList[i].c_str(), Color::black);
} else {
- s.bltStringShadowedCenter(choiceList[i], Color::white,
Color::black);
+ s.bltStringShadowedCenter(choiceList[i].c_str(), Color::white,
Color::black);
}
r.translate(iXY(0, ChoiceItemHeight));
@@ -219,17 +217,14 @@
// add
//---------------------------------------------------------------------------
-void Choice::add(const String &item)
+void Choice::add(const std::string& item)
{
- choiceList.setNum(choiceList.getCount() + 1);
-
- choiceList[choiceList.getCount() - 1] = item;
+ choiceList.push_back(item);
int borderSpace = borderSize * 2;
size.x = std::max(Surface::getTextLength(item) + borderSpace, size.y);
size.x = std::max(minWidth, size.x);
-
} // end Choice::add
// setMinWidth
@@ -245,11 +240,7 @@
//---------------------------------------------------------------------------
void Choice::copyItems(const Choice &choice)
{
- choiceList.setNum(choice.choiceList.getCount());
-
- for (int i = 0; i < choice.choiceList.getCount(); i++) {
- choiceList[i] = choice.choiceList[i];
- }
+ choiceList = choice.choiceList;
- //index = choice.getSelectedIndex();
+ select(0);
} // end Choice::copyItems
Index: netpanzer/src/NetPanzer/View/Choice.hpp
diff -u netpanzer/src/NetPanzer/View/Choice.hpp:1.1
netpanzer/src/NetPanzer/View/Choice.hpp:1.2
--- netpanzer/src/NetPanzer/View/Choice.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Choice.hpp Mon Nov 24 07:03:34 2003
@@ -18,6 +18,9 @@
#ifndef __Choice_hpp__
#define __Choice_hpp__
+#include <vector>
+#include <string>
+
#include "Component.hpp"
#include "Util/cGrowList.hpp"
#include "MouseEvent.hpp"
@@ -28,12 +31,12 @@
class Choice : public Component
{
private:
- cGrowList <String> choiceList;
- int index;
- int minWidth;
- bool isOpen;
- int mouseover;
- int adjustedY; // The y translation value to keep the
choice on the screen.
+ std::vector<std::string> choiceList;
+ size_t index;
+ int minWidth;
+ bool isOpen;
+ size_t mouseover;
+ int adjustedY; // The y translation value to keep the
choice on the screen.
StateChangedCallback* callback;
enum { ChoiceItemHeight = 14 };
@@ -47,23 +50,19 @@
virtual ~Choice()
{}
- void add(const String &item);
- void addItem(const String &item);
+ void add(const std::string& item);
+ void addItem(const std::string& item);
void copyItems(const Choice &choice);
- int getItemCount() const
+ size_t getItemCount() const
{
- return choiceList.getCount();
+ return choiceList.size();
}
- int getSelectedIndex() const
+ size_t getSelectedIndex() const
{
return index;
}
- String paramString()
- {
- return String();
- }
- void select(const String &item);
- void select(int index);
+ void select(const std::string& item);
+ void select(size_t index);
void setMinWidth(int minWidth);
void setStateChangedCallback(StateChangedCallback* newcallback)
@@ -76,7 +75,6 @@
private:
void reset();
-}
-; // end Choice
+}; // end Choice
#endif // end __Choice_hpp__
Index: netpanzer/src/NetPanzer/View/Component.hpp
diff -u netpanzer/src/NetPanzer/View/Component.hpp:1.1
netpanzer/src/NetPanzer/View/Component.hpp:1.2
--- netpanzer/src/NetPanzer/View/Component.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Component.hpp Mon Nov 24 07:03:34 2003
@@ -18,13 +18,13 @@
#ifndef __Component_hpp__
#define __Component_hpp__
+#include <string>
#include <stdint.h>
#include "2D/Color.hpp"
#include "2D/Surface.hpp"
#include "Types/iXY.hpp"
#include "Types/iRect.hpp"
-#include "Types/String.hpp"
#include "Util/NoCopy.hpp"
class mMouseEvent;
@@ -38,7 +38,7 @@
iXY size;
iXY min;
Surface surface;
- String name;
+ std::string name;
bool enabled;
bool visible;
@@ -72,49 +72,49 @@
// Accessor functions.
bool contains(int x, int y) const;
- inline bool contains(iXY p) const
+ bool contains(iXY p) const
{
return contains(p.x, p.y);
}
- inline uint8_t getBackground() const
+ uint8_t getBackground() const
{
return background;
}
- inline void getBounds(iRect &r)
+ void getBounds(iRect &r)
{
r.min = min;
r.max = min + size;
}
- inline uint8_t getForeground() const
+ uint8_t getForeground() const
{
return foreground;
}
- inline Surface& getGraphics()
+ Surface& getGraphics()
{
return surface;
}
- inline String getName() const
+ const std::string& getName() const
{
return name;
}
- inline const iXY &getSize() const
+ const iXY &getSize() const
{
return size;
}
- inline int getSizeX() const
+ int getSizeX() const
{
return size.x;
}
- inline int getSizeY() const
+ int getSizeY() const
{
return size.y;
}
- inline bool isEnabled() const
+ bool isEnabled() const
{
return enabled;
}
//const bool &isValid() {}
- inline bool isVisible() const
+ bool isVisible() const
{
return visible;
}
@@ -130,17 +130,17 @@
void setEnabled(bool enabled);
void setForeground(PIX foreground);
void setLocation(int x, int y);
- inline void setLocation(const iXY &p)
+ void setLocation(const iXY &p)
{
setLocation(p.x, p.y);
}
- void setName(const String &name)
+ void setName(const std::string& name)
{
Component::name = name;
}
void setSize(int width, int height)
{}
- inline void setSize(const iXY &d)
+ void setSize(const iXY &d)
{
setSize(d.x, d.y);
}
@@ -152,3 +152,4 @@
}; // end Component
#endif // end __Component_hpp__
+
Index: netpanzer/src/NetPanzer/View/Icon.hpp
diff -u netpanzer/src/NetPanzer/View/Icon.hpp:1.1
netpanzer/src/NetPanzer/View/Icon.hpp:1.2
--- netpanzer/src/NetPanzer/View/Icon.hpp:1.1 Sat Nov 22 10:43:43 2003
+++ netpanzer/src/NetPanzer/View/Icon.hpp Mon Nov 24 07:03:34 2003
@@ -18,7 +18,8 @@
#ifndef __Icon_hpp__
#define __Icon_hpp__
-#include "Types/String.hpp"
+#include <string>
+
#include "2D/Surface.hpp"
//--------------------------------------------------------------------------
@@ -26,10 +27,10 @@
{
protected:
Surface image;
- String description;
+ std::string description;
public:
- Icon(const Surface &image, const String &description)
+ Icon(const Surface &image, const std::string& description)
{}
Icon(const Surface &image)
{}
@@ -38,7 +39,7 @@
virtual ~Icon()
{}
- const String &getDescription() const
+ const std::string& getDescription() const
{
return description;
}
@@ -57,7 +58,7 @@
return image;
}
- void setDescription(const String &decription)
+ void setDescription(const std::string& decription)
{
Icon::description = description;
}
Index: netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.16
netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.17
--- netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp:1.16 Sat Nov 22
10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameInfoView.cpp Mon Nov 24 07:03:34 2003
@@ -26,7 +26,6 @@
#include "UnitInterface.hpp"
#include "PlayerInterface.hpp"
#include "NetworkState.hpp"
-#include "Types/String.hpp"
#include "ScreenSurface.hpp"
static int getPlayerFrags()
@@ -37,28 +36,28 @@
return( (int) player_state->getTotal() );
}
-static String getPlayerTime()
+static const char* getPlayerTime()
{
- char time_string[256];
+ static char time_string[256];
int hrs = (GameManager::getGameTime() / 3600);
int min = (GameManager::getGameTime() / 60) % 60;
- sprintf(time_string, "%d:%d", hrs, min);
+ snprintf(time_string, 256, "%d:%d", hrs, min);
- return(time_string);
+ return time_string;
}
-static String getTimeLimit()
+static const char* getTimeLimit()
{
- char time_string[256];
+ static char time_string[256];
int hrs = (gameconfig->timelimit / 60);
int min = (gameconfig->timelimit % 60);
sprintf(time_string, "%d:%d", hrs, min);
- return(time_string);
+ return time_string;
}
@@ -134,11 +133,11 @@
*/
if( gameconfig->gametype == _gametype_timelimit ) {
- sprintf(timeBuf, "time %s/%s", (const char*) getPlayerTime(),
+ snprintf(timeBuf, 64, "time %s/%s", getPlayerTime(),
(const char*) getTimeLimit() );
checkGameInfoRect(timeBuf);
} else {
- sprintf(timeBuf, "time %s", (const char *) getPlayerTime() );
+ snprintf(timeBuf, 64, "time %s", getPlayerTime() );
checkGameInfoRect(timeBuf);
}
@@ -176,7 +175,7 @@
//---------------------------------------------------------------------------
// Purpose: Makes sure the rect is the size of the text inside.
//---------------------------------------------------------------------------
-void GameInfoView::checkGameInfoRect(String string)
+void GameInfoView::checkGameInfoRect(const std::string& string)
{
int length = Surface::getTextLength(string) + 2;
Index: netpanzer/src/NetPanzer/Views/Game/GameInfoView.hpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameInfoView.hpp:1.5
netpanzer/src/NetPanzer/Views/Game/GameInfoView.hpp:1.6
--- netpanzer/src/NetPanzer/Views/Game/GameInfoView.hpp:1.5 Sat Nov 22
10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameInfoView.hpp Mon Nov 24 07:03:34 2003
@@ -26,7 +26,7 @@
class GameInfoView : public GameTemplateView
{
private:
- void checkGameInfoRect(String string);
+ void checkGameInfoRect(const std::string& string);
iRect gameInfoRect;
Index: netpanzer/src/NetPanzer/Views/Game/HelpScrollView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/HelpScrollView.cpp:1.13
netpanzer/src/NetPanzer/Views/Game/HelpScrollView.cpp:1.14
--- netpanzer/src/NetPanzer/Views/Game/HelpScrollView.cpp:1.13 Wed Nov 12
15:46:03 2003
+++ netpanzer/src/NetPanzer/Views/Game/HelpScrollView.cpp Mon Nov 24
07:03:34 2003
@@ -172,7 +172,8 @@
//
int curIndex = 0;
for (int i = topViewableItem; i < topViewableItem + maxViewableItems; i++)
{
- dest.bltString(1, 6 + curIndex * (TEXT_GAP_SPACE +
Surface::getFontHeight()), text[i], color);
+ dest.bltString(1, 6 + curIndex * (TEXT_GAP_SPACE +
+ Surface::getFontHeight()), text[i].c_str(), color);
curIndex++;
}
//}
@@ -181,12 +182,9 @@
// insert
//--------------------------------------------------------------------------
-void HelpScrollView::insert(char *string)
+void HelpScrollView::insert(const char *string)
{
- text.setNum(text.getCount() + 1);
-
- text[text.getCount() - 1] = string;
-
+ text.push_back(std::string(string));
} // end HelpScrollView::insert
// actionPerformed
@@ -199,8 +197,8 @@
topViewableItem = 0;
}
} else if (me.getSource(downButton)) {
- if (++topViewableItem >= text.getCount() - maxViewableItems) {
- topViewableItem = text.getCount() - maxViewableItems;
+ if (++topViewableItem >= (long) text.size() - maxViewableItems) {
+ topViewableItem = (long) text.size() - maxViewableItems;
}
}
}
Index: netpanzer/src/NetPanzer/Views/Game/HelpScrollView.hpp
diff -u netpanzer/src/NetPanzer/Views/Game/HelpScrollView.hpp:1.6
netpanzer/src/NetPanzer/Views/Game/HelpScrollView.hpp:1.7
--- netpanzer/src/NetPanzer/Views/Game/HelpScrollView.hpp:1.6 Sat Nov 22
10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/HelpScrollView.hpp Mon Nov 24
07:03:34 2003
@@ -19,11 +19,12 @@
#ifndef __HelpScrollView_hpp__
#define __HelpScrollView_hpp__
+#include <vector>
+#include <string>
+
#include "SpecialButtonView.hpp"
#include "2D/Surface.hpp"
#include "ScrollBar.hpp"
-#include "Types/String.hpp"
-#include "Util/cGrowList.hpp"
#include "Button.hpp"
//---------------------------------------------------------------------------
@@ -37,10 +38,10 @@
void drawHelpText(Surface &dest, const int &x, const int &y);
ScrollBar *scrollBar;
- cGrowList <String> text;
+ std::vector<std::string> text;
enum { TEXT_GAP_SPACE = 2 };
- void insert(char *string);
+ void insert(const char *string);
Button upButton;
Button downButton;
Index: netpanzer/src/NetPanzer/Views/Game/LibView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/LibView.cpp:1.1
netpanzer/src/NetPanzer/Views/Game/LibView.cpp:1.2
--- netpanzer/src/NetPanzer/Views/Game/LibView.cpp:1.1 Sat Nov 22 10:48:48 2003
+++ netpanzer/src/NetPanzer/Views/Game/LibView.cpp Mon Nov 24 07:03:34 2003
@@ -296,12 +296,14 @@
pos.y += yOffset;
int windSpeed = gameconfig->windspeed;
- sprintf(strBuf, "Wind: %s (%d pix/sec)", (const char *)
HostOptionsView::windSpeedString, windSpeed);
+ sprintf(strBuf, "Wind: %s (%d pix/sec)",
+ HostOptionsView::windSpeedString.c_str(), windSpeed);
dest.bltString(iXY(pos.x, pos.y), strBuf, Color::yellow);
pos.y += yOffset;
int cloudCount = gameconfig->cloudcoverage;
- sprintf(strBuf, "Clouds: %s (%d allocated)", (const char *)
HostOptionsView::cloudCoverageString, cloudCount);
+ sprintf(strBuf, "Clouds: %s (%d allocated)",
+ HostOptionsView::cloudCoverageString.c_str(), cloudCount);
dest.bltString(iXY(pos.x, pos.y), strBuf, Color::yellow);
pos.y += yOffset;
Index: netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.cpp:1.22
netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.cpp:1.23
--- netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.cpp:1.22 Sat Nov
22 10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.cpp Mon Nov 24
07:03:34 2003
@@ -811,7 +811,7 @@
//---------------------------------------------------------------------------
// Purpose: Makes sure the rect is the size of the text inside.
//---------------------------------------------------------------------------
-void VehicleSelectionView::checkMiniProductionRect(String string)
+void VehicleSelectionView::checkMiniProductionRect(const std::string& string)
{
int length = Surface::getTextLength(string) + 54;
@@ -933,7 +933,7 @@
{
if (me.getID() == mMouseEvent::MOUSE_EVENT_CLICKED) {
if (me.getSource(buttonStaticDisplay)) {
- if (buttonStaticDisplay.getLabel() == String("On")) {
+ if (buttonStaticDisplay.getLabel() == "On") {
buttonStaticDisplay.setLabel("Off");
} else {
buttonStaticDisplay.setLabel("On");
@@ -943,7 +943,7 @@
}
if (me.getSource(buttonPower)) {
- if (buttonPower.getLabel() == String("On")) {
+ if (buttonPower.getLabel() == "On") {
buttonPower.setLabel("Off");
} else {
buttonPower.setLabel("On");
Index: netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.hpp
diff -u netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.hpp:1.5
netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.hpp:1.6
--- netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.hpp:1.5 Sat Nov
22 10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/VehicleSelectionView.hpp Mon Nov 24
07:03:35 2003
@@ -103,7 +103,7 @@
static Surface unitImages;
- static void checkMiniProductionRect(String string);
+ static void checkMiniProductionRect(const std::string& string);
public:
VehicleSelectionView();
Index: netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.24
netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.25
--- netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp:1.24 Sat Nov
22 10:43:46 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.cpp Mon Nov 24
07:03:35 2003
@@ -263,9 +263,9 @@
// doLoadBackgroundSurface
//---------------------------------------------------------------------------
-void MenuTemplateView::doLoadBackgroundSurface(String string)
+void MenuTemplateView::doLoadBackgroundSurface(const std::string& string)
{
- backgroundSurface.loadBMP(string);
+ backgroundSurface.loadBMP(string.c_str());
} // end MenuTemplateView::doLoadBackgroundSurface
// loadTitleSurface
@@ -277,24 +277,23 @@
// doLoadBackgroundSurface
//---------------------------------------------------------------------------
-void MenuTemplateView::doLoadTitleSurface(String string)
+void MenuTemplateView::doLoadTitleSurface(const std::string& string)
{
curTitleFlashTime = 0.0f;
titleFlashTimeHalf = 2.5;
- String pakString;
- pakString = "pics/backgrounds/menus/menu/pak/";
- pakString += UtilInterface::getFilename(string);
+ std::string pakString = "pics/backgrounds/menus/menu/pak/";
+ pakString += UtilInterface::getFilename(string.c_str());
pakString += ".pak";
- if (UtilInterface::getFileSize(pakString)) {
- titlePackedSurface.load((const char *) pakString);
+ if (UtilInterface::getFileSize(pakString.c_str())) {
+ titlePackedSurface.load(pakString.c_str());
} else {
Surface titleSurface;
try {
- titleSurface.loadBMP(string);
+ titleSurface.loadBMP(string.c_str());
} catch(Exception&) {
titleSurface.create(300, 50, 300, 1);
titleSurface.fill(128);
@@ -303,7 +302,7 @@
titlePackedSurface.pack(titleSurface);
- titlePackedSurface.save(pakString);
+ titlePackedSurface.save(pakString.c_str());
}
} // end MenuTemplateView::doLoadTitleSurface
Index: netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.hpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.hpp:1.6
netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.hpp:1.7
--- netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.hpp:1.6 Sat Nov
22 10:43:46 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/MenuTemplateView.hpp Mon Nov 24
07:03:35 2003
@@ -23,7 +23,6 @@
#include "2D/PackedSurface.hpp"
#include "Types/iRect.hpp"
#include "Types/iXY.hpp"
-#include "Types/String.hpp"
//--------------------------------------------------------------------------
class MenuTemplateView : public SpecialButtonView
@@ -34,8 +33,8 @@
virtual void loadBackgroundSurface();
virtual void loadTitleSurface();
- void doLoadBackgroundSurface(String string);
- void doLoadTitleSurface(String string);
+ void doLoadBackgroundSurface(const std::string& string);
+ void doLoadTitleSurface(const std::string& string);
float curTitleFlashTime; // Where am I at in the flash?
float titleFlashTimeHalf; // Time it takes for a half flash.
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.cpp:1.9
netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.cpp:1.10
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.cpp:1.9
Mon Oct 13 10:30:22 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.cpp Mon Nov
24 07:03:36 2003
@@ -27,8 +27,8 @@
int HostOptionsView::windSpeed = 1;
int HostOptionsView::gameType = 0;
-String HostOptionsView::cloudCoverageString;
-String HostOptionsView::windSpeedString;
+std::string HostOptionsView::cloudCoverageString;
+std::string HostOptionsView::windSpeedString;
static int getCurMaxPlayersCount()
{
Index: netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.hpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.hpp:1.4
netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.hpp:1.5
--- netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.hpp:1.4
Sat Nov 22 10:43:48 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Multi/HostOptionsView.hpp Mon Nov
24 07:03:36 2003
@@ -20,7 +20,6 @@
#include "RMouseHackView.hpp"
#include "2D/Surface.hpp"
-#include "Types/String.hpp"
#include "Choice.hpp"
#include "CheckBox.hpp"
@@ -77,8 +76,8 @@
windSpeed = speed;
}
- static String cloudCoverageString;
- static String windSpeedString;
+ static std::string cloudCoverageString;
+ static std::string windSpeedString;
}; // end HostOptionsView
#endif // end __HostOptionsView_hpp__
Index: netpanzer/src/NetPanzer/Views/MainMenu/SpecialButtonView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/SpecialButtonView.cpp:1.10
netpanzer/src/NetPanzer/Views/MainMenu/SpecialButtonView.cpp:1.11
--- netpanzer/src/NetPanzer/Views/MainMenu/SpecialButtonView.cpp:1.10 Sat Nov
22 10:43:46 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/SpecialButtonView.cpp Mon Nov
24 07:03:35 2003
@@ -31,7 +31,7 @@
{
char strBuf[256];
- String prefix;
+ std::string prefix;
// Check to see which type of button to load since we have multiple
palettes.
if (Desktop::getVisible("GameView")) {
@@ -40,7 +40,8 @@
prefix = "inMenus";
}
- sprintf(strBuf, "pics/backgrounds/menus/buttons/default/pak/%s%s.pak",
(const char *) prefix, fileString);
+ sprintf(strBuf, "pics/backgrounds/menus/buttons/default/pak/%s%s.pak",
+ prefix.c_str(), fileString);
if (UtilInterface::getFileSize(strBuf) > 0) {
PackedSurface tempPack;
@@ -53,7 +54,8 @@
Surface buttonSurface;
Surface tempSurface;
- sprintf(strBuf,
"pics/backgrounds/menus/buttons/default/%sbutover.bmp", (const char *) prefix);
+ sprintf(strBuf, "pics/backgrounds/menus/buttons/default/%sbutover.bmp",
+ prefix.c_str());
// Create.
tempSurface.loadBMP(strBuf);
@@ -69,7 +71,8 @@
buttonSurface.setFrame(2);
tempSurface.blt(buttonSurface);
- sprintf(strBuf, "pics/backgrounds/menus/buttons/default/%sbuton.bmp",
(const char *) prefix);
+ sprintf(strBuf, "pics/backgrounds/menus/buttons/default/%sbuton.bmp",
+ prefix.c_str());
tempSurface.loadBMP(strBuf);
@@ -81,7 +84,8 @@
tempSurface.blt(buttonSurface);
// Unhighlight.
- sprintf(strBuf, "pics/backgrounds/menus/buttons/default/%sbutoff.bmp",
(const char *) prefix);
+ sprintf(strBuf, "pics/backgrounds/menus/buttons/default/%sbutoff.bmp",
+ prefix.c_str());
tempSurface.loadBMP(strBuf);
@@ -107,7 +111,8 @@
PackedSurface tempPack;
tempPack.pack(buttonSurface);
- sprintf(strBuf, "pics/backgrounds/menus/buttons/default/pak/%s%s.pak",
(const char *) prefix, fileString);
+ sprintf(strBuf, "pics/backgrounds/menus/buttons/default/pak/%s%s.pak",
+ prefix.c_str(), fileString);
tempPack.save(strBuf);
addButtonPackedSurface(pos, tempPack, "", function);
@@ -134,3 +139,4 @@
void SpecialButtonView::doActivate()
{
} // end SpecialButtonView::doActivate
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer ./ChangeLog src/Lib/2D/Palette.cpp sr...,
Matthias Braun <=