[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2605 - in trunk: data/worldmaps src src/worldmap
From: |
jave27 |
Subject: |
[Pingus-CVS] r2605 - in trunk: data/worldmaps src src/worldmap |
Date: |
Wed, 18 Jan 2006 20:55:16 +0100 |
Author: jave27
Date: 2006-01-18 20:55:09 +0100 (Wed, 18 Jan 2006)
New Revision: 2605
Modified:
trunk/data/worldmaps/tutorial.xml
trunk/data/worldmaps/volcano.xml
trunk/src/savegame_manager.cxx
trunk/src/worldmap/worldmap.cxx
trunk/src/worldmap/worldmap.hxx
Log:
Added a default starting level to the Worldmap XML file, and changed the code
to actually use it unless a node is specified in the variables.xml file.
Prior to this, a user was starting off in strange places in the volcano
worldmap.
Modified: trunk/data/worldmaps/tutorial.xml
===================================================================
--- trunk/data/worldmaps/tutorial.xml 2006-01-18 18:35:21 UTC (rev 2604)
+++ trunk/data/worldmaps/tutorial.xml 2006-01-18 19:55:09 UTC (rev 2605)
@@ -2,12 +2,14 @@
<pingus-worldmap>
<head>
<name>Tutorial Island</name>
+ <short-name>tutorial</short-name>
<description>Learn the basics</description>
<music>pingus-1.it</music>
<author>Ingo Ruhnke</author>
<email>address@hidden</email>
<width>1161</width>
<height>600</height>
+ <default-node>leveldot_1</default-node>
</head>
<intro_story>
Modified: trunk/data/worldmaps/volcano.xml
===================================================================
--- trunk/data/worldmaps/volcano.xml 2006-01-18 18:35:21 UTC (rev 2604)
+++ trunk/data/worldmaps/volcano.xml 2006-01-18 19:55:09 UTC (rev 2605)
@@ -1,12 +1,14 @@
<pingus-worldmap>
<head>
<name>Volcano Island</name>
+ <short-name>volcano</short-name>
<description>Be careful, it's hot!</description>
<music>gd-myla.it</music>
<author>Ingo Ruhnke</author>
<email>address@hidden</email>
<width>800</width>
<height>600</height>
+ <default-node>leveldot_1</default-node>
</head>
<intro_story>
Modified: trunk/src/savegame_manager.cxx
===================================================================
--- trunk/src/savegame_manager.cxx 2006-01-18 18:35:21 UTC (rev 2604)
+++ trunk/src/savegame_manager.cxx 2006-01-18 19:55:09 UTC (rev 2605)
@@ -85,11 +85,6 @@
{
std::cout << "SavegameManager: Couldn't find savegame file '" << filename
<< "', starting with a empty one." << std::endl;
- // FIXME: Unlock the first level
- Savegame savegame;
- savegame.status = Savegame::ACCESSIBLE;
- savegame.levelname = "tutorial/digger-tutorial2-grumbel";
- store(savegame);
}
}
Modified: trunk/src/worldmap/worldmap.cxx
===================================================================
--- trunk/src/worldmap/worldmap.cxx 2006-01-18 18:35:21 UTC (rev 2604)
+++ trunk/src/worldmap/worldmap.cxx 2006-01-18 19:55:09 UTC (rev 2605)
@@ -25,6 +25,7 @@
#include "../fonts.hxx"
#include "../path_manager.hxx"
#include "../stat_manager.hxx"
+#include "../savegame_manager.hxx"
#include "../system.hxx"
#include "../resource.hxx"
#include "../globals.hxx"
@@ -66,24 +67,7 @@
pingus = new Pingus(path_graph);
- std::string node;
- if (StatManager::instance()->get_string("current-tutorial-node", node))
- {
- NodeId id = path_graph->lookup_node(node);
- if (id == NoNode)
- {
- pingus->set_position(0);
- }
- else
- {
- pingus->set_position(id);
- }
- }
- else
- { // FIXME: This should not be hardcoded, but instead be noted in the
- // savegame or worldmap
- pingus->set_position(0);
- }
+ set_starting_node();
add_drawable(pingus);
@@ -157,9 +141,14 @@
reader.read_string("music", music);
reader.read_string("author", author);
reader.read_string("name", name);
+ reader.read_string("short-name", short_name);
reader.read_string("email", email);
reader.read_int("width", width);
reader.read_int("height", height);
+
+ std::string node_name;
+ reader.read_string("default-node", node_name);
+ default_node = path_graph->lookup_node(node_name);
}
void
@@ -321,7 +310,7 @@
}
else
{
- StatManager::instance()->set_string("current-tutorial-node",
dot->get_name());
+ StatManager::instance()->set_string(short_name +
"-current-node", dot->get_name());
}
}
else
@@ -420,6 +409,36 @@
}
}
+// Determine starting node
+void
+WorldMap::set_starting_node()
+{
+ // See if the user has played this map before. If not, use the
<default-node>
+ // tag from the XML file.
+ NodeId id;
+ std::string node_name;
+
+ if (StatManager::instance()->get_string(short_name + "-current-node",
node_name))
+ {
+ // Just in case that level doesn't exist, look it up.
+ id = path_graph->lookup_node(node_name);
+ if (id == NoNode)
+ id = default_node;
+ }
+ else
+ id = default_node;
+
+ pingus->set_position(id);
+
+ LevelDot* leveldot = dynamic_cast<LevelDot*>(path_graph->get_dot(id));
+ std::string resname = leveldot->get_plf().get_resname();
+ // Set an accessible flag for this level in the Savegame Manager.
+ if (!SavegameManager::instance()->get(resname))
+ {
+ Savegame savegame(resname, Savegame::ACCESSIBLE, 10000, 0);
+ SavegameManager::instance()->store(savegame);
+ }
+}
} // namespace WorldMapNS
} // namespace Pingus
Modified: trunk/src/worldmap/worldmap.hxx
===================================================================
--- trunk/src/worldmap/worldmap.hxx 2006-01-18 18:35:21 UTC (rev 2604)
+++ trunk/src/worldmap/worldmap.hxx 2006-01-18 19:55:09 UTC (rev 2605)
@@ -67,10 +67,13 @@
int height;
std::string name;
+ std::string short_name;
std::string author;
std::string email;
std::string music;
+ NodeId default_node;
+
Pingus* pingus;
GraphicContextState gc_state;
@@ -141,6 +144,10 @@
/** Unlock nodes according to the finished ones */
void update_locked_nodes();
+
+ /** Sets the starting level on the worldmap. Either take it from the
StatManager
+ or use the "default-node" option from the XML file */
+ void set_starting_node();
};
} // namespace WorldMapNS
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2605 - in trunk: data/worldmaps src src/worldmap,
jave27 <=