netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src Lib/Xml/XmlConfig.cpp Lib/Xml/Xml...


From: Ivo Danihelka
Subject: [netPanzer-CVS] netpanzer/src Lib/Xml/XmlConfig.cpp Lib/Xml/Xml...
Date: Tue, 23 Sep 2003 11:38:27 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Ivo Danihelka <address@hidden>  03/09/23 11:38:27

Modified files:
        src/Lib/Xml    : XmlConfig.cpp XmlConfig.hpp 
        src/NetPanzer/Interfaces: GameConfig.cpp 
        src/NetPanzer/Views/MainMenu/Options: VisualsView.cpp 
                                              VisualsView.hpp 

Log message:
        GameConfig not reset color values

Patches:
Index: netpanzer/src/Lib/Xml/XmlConfig.cpp
diff -u netpanzer/src/Lib/Xml/XmlConfig.cpp:1.2 
netpanzer/src/Lib/Xml/XmlConfig.cpp:1.3
--- netpanzer/src/Lib/Xml/XmlConfig.cpp:1.2     Mon Sep 22 11:15:50 2003
+++ netpanzer/src/Lib/Xml/XmlConfig.cpp Tue Sep 23 11:38:26 2003
@@ -106,14 +106,34 @@
 }
 //-----------------------------------------------------------------
 /**
+ * Read number from attribute.
+ * @return long
+ * @return defaultValue default value
+ */
+long
+XmlConfig::readInt(const char *name, long defaultValue) const
+{
+    xmlChar *strXml = xmlGetProp(m_node, (const xmlChar*)name);
+    if (strXml == 0) {
+        return defaultValue;
+    }
+    xmlFree(strXml);
+    return readInt(name);
+}
+//-----------------------------------------------------------------
+/**
  * Read string from attribute.
  * @return string
+ * @return defaultValue default value or 0
  */
 std::string
-XmlConfig::readString(const char *name) const
+XmlConfig::readString(const char *name, const char *defaultValue) const
 {
     xmlChar *strXml = xmlGetProp(m_node, (const xmlChar*)name);
     if (strXml == 0) {
+        if (defaultValue) {
+            return std::string(defaultValue);
+        }
         throw Exception("xml config: '%s->%s' is empty",
             m_node->name, name);
     }
Index: netpanzer/src/Lib/Xml/XmlConfig.hpp
diff -u netpanzer/src/Lib/Xml/XmlConfig.hpp:1.1 
netpanzer/src/Lib/Xml/XmlConfig.hpp:1.2
--- netpanzer/src/Lib/Xml/XmlConfig.hpp:1.1     Sat Sep 20 18:40:15 2003
+++ netpanzer/src/Lib/Xml/XmlConfig.hpp Tue Sep 23 11:38:26 2003
@@ -39,7 +39,9 @@
 
         const XmlConfig getChild(const char *childName) const;
         long readInt(const char *name) const;
-        std::string readString(const char *name) const;
+        long readInt(const char *name, long defaultValue) const;
+        std::string readString(const char *name,
+                const char *defaultValue = 0) const;
 };
 
 #endif
Index: netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.9 
netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.10
--- netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp:1.9       Mon Sep 22 
11:15:49 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameConfig.cpp   Tue Sep 23 11:38:27 2003
@@ -167,18 +167,20 @@
     }
 
     XmlConfig game = config.getChild("game");
-    GameMode = game.readInt("mode");
-    GameType = game.readInt("type");
-    NumberPlayers = game.readInt("players");
-    NumberUnits = game.readInt("units");
-    NumberInitialUnits = game.readInt("init_units");
+    GameMode = game.readInt("mode", GameMode);
+    GameType = game.readInt("type", GameType);
+    NumberPlayers = game.readInt("players", NumberPlayers);
+    NumberUnits = game.readInt("units", NumberUnits);
+    NumberInitialUnits = game.readInt("init_units", NumberInitialUnits);
 
     XmlConfig visuals = config.getChild("visuals");
-    screen_resolution = visuals.readInt("resolution");
-    screen_fullscreen = visuals.readInt("fullscreen");
-    display_shadows_flag = visuals.readInt("shadows_flag");
-    display_unit_flags = visuals.readInt("unit_flags");
-    UnitColor = visuals.readInt("unit_color");
+    screen_resolution = visuals.readInt("resolution", screen_resolution);
+    screen_fullscreen = visuals.readInt("fullscreen", screen_fullscreen);
+    display_shadows_flag = visuals.readInt("shadows_flag",
+            display_shadows_flag);
+    display_unit_flags = visuals.readInt("unit_flags", display_unit_flags);
+    mini_map_unit_size = visuals.readInt("mini_map_unit_size",
+            mini_map_unit_size);
 }
 
 void GameConfig::saveConfig()
@@ -198,7 +200,7 @@
     visuals.writeInt("fullscreen", screen_fullscreen);
     visuals.writeInt("shadows_flag", display_shadows_flag);
     visuals.writeInt("unit_flags", display_unit_flags);
-    visuals.writeInt("unit_color", UnitColor);
+    visuals.writeInt("mini_map_unit_size", mini_map_unit_size);
 
     xmlStore.save(configfile.c_str());
 }
Index: netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.cpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.cpp:1.7 
netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.cpp:1.8
--- netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.cpp:1.7  Thu Sep 
18 13:44:18 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.cpp      Tue Sep 
23 11:38:27 2003
@@ -64,6 +64,16 @@
     y += yOffset;
     y += yOffset;
 
+    choiceMiniMapUnitSize.setName("Mini Map Unit Size");
+    choiceMiniMapUnitSize.setStateChangedCallback(this);
+    choiceMiniMapUnitSize.addItem("Small");
+    choiceMiniMapUnitSize.addItem("Large");
+    choiceMiniMapUnitSize.setLocation(x, y);
+    choiceMiniMapUnitSize.setMinWidth(minWidth);
+    y += yOffset;
+    y += yOffset;
+
+
 #if 0
     choiceGameViewBackgroundColor.setName("Game View Background Color");
     choiceGameViewBackgroundColor.setStateChangedCallback(this);
@@ -87,15 +97,6 @@
 
     x = 300;
     y = 100;
-    choiceMiniMapUnitSize.setName("Mini Map Unit Size");
-    choiceMiniMapUnitSize.setStateChangedCallback(this);
-    choiceMiniMapUnitSize.addItemDefault("Small");
-    choiceMiniMapUnitSize.addItem("Large");
-    choiceMiniMapUnitSize.setLocation(x, y);
-    choiceMiniMapUnitSize.setMinWidth(minWidth);
-    y += yOffset;
-    y += yOffset;
-
     choiceUnitSelectionDrawMode.setName("Unit Selection Draw Mode");
     choiceUnitSelectionDrawMode.setStateChangedCallback(this);
     choiceUnitSelectionDrawMode.addItemDefault("Rectangle Edges");
@@ -243,7 +244,7 @@
     add(&choiceResolution);
     //add(&choiceGameViewBackgroundColor);
     //add(&choiceMiniMapObjectiveDrawMode);
-    //add(&choiceMiniMapUnitSize);
+    add(&choiceMiniMapUnitSize);
     //add(&choiceUnitSelectionDrawMode);
     //add(&choiceUnitInfoDrawLayer);
     //add(&choiceYourRadarUnit);
@@ -270,7 +271,7 @@
 void VisualsView::processEvents()
 {
     OptionsTemplateView::processEvents();
-
+#if 0
     
GameConfig::setPlayerRadarUnitColor(choiceYourRadarUnit.getSelectedIndex());
     
GameConfig::setAlliedRadarUnitColor(choiceAlliedRadarUnit.getSelectedIndex());
     
GameConfig::setPlayerOutpostRadarColor(choiceYourRadarObjective.getSelectedIndex());
@@ -280,6 +281,7 @@
     GameConfig::setConsoleTextColor(choiceConsoleText.getSelectedIndex());
 
     GameManager::setNetPanzerGameOptions();
+#endif
 
 } // end VisualsView::processEvents
 
Index: netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.hpp
diff -u netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.hpp:1.3 
netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.hpp:1.4
--- netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.hpp:1.3  Tue Sep 
16 16:16:13 2003
+++ netpanzer/src/NetPanzer/Views/MainMenu/Options/VisualsView.hpp      Tue Sep 
23 11:38:27 2003
@@ -56,6 +56,7 @@
 
     //Choice   choiceUnitInfoDrawLayer;
 
+#if 0
     // Color choices.
     Choice   choiceYourRadarUnit;
     Choice   choiceAlliedRadarUnit;
@@ -64,6 +65,7 @@
     Choice   choiceEnemyRadarObjective;
     Choice   choiceVehicleSelectionBox;
     Choice   choiceConsoleText;
+#endif
 
     virtual void loadTitleSurface();
 




reply via email to

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