[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2612 - in trunk: . data data/metamap data/worldmaps src sr
From: |
jave27 |
Subject: |
[Pingus-CVS] r2612 - in trunk: . data data/metamap data/worldmaps src src/gui src/worldmap src/worldobjs |
Date: |
Thu, 19 Jan 2006 20:43:35 +0100 |
Author: jave27
Date: 2006-01-19 20:42:45 +0100 (Thu, 19 Jan 2006)
New Revision: 2612
Added:
trunk/data/metamap/
trunk/data/metamap/Makefile.am
trunk/data/metamap/metamap.xml
trunk/src/worldmap/metamap.cxx
trunk/src/worldmap/metamap.hxx
trunk/src/worldmap/world_dot.cxx
trunk/src/worldmap/world_dot.hxx
Modified:
trunk/Pingus.vcproj
trunk/data/worldmaps/tutorial.xml
trunk/data/worldmaps/volcano.xml
trunk/src/SConscript
trunk/src/file_dialog.hxx
trunk/src/file_dialog_item.cxx
trunk/src/file_dialog_item.hxx
trunk/src/game_session.cxx
trunk/src/gui/combobox.cxx
trunk/src/pingus_main.cxx
trunk/src/pingus_menu.cxx
trunk/src/savegame.hxx
trunk/src/story_screen.cxx
trunk/src/worldmap/Makefile.am
trunk/src/worldmap/dot_factory.cxx
trunk/src/worldmap/level_dot.cxx
trunk/src/worldmap/manager.cxx
trunk/src/worldmap/manager.hxx
trunk/src/worldmap/path_graph.cxx
trunk/src/worldmap/path_graph.hxx
trunk/src/worldmap/pingus.cxx
trunk/src/worldmap/worldmap.cxx
trunk/src/worldmap/worldmap.hxx
trunk/src/worldobjs/fake_exit.cxx
trunk/src/worldobjs/smasher.cxx
trunk/src/worldobjs/woodthing.cxx
trunk/src/xml_pingus_level.cxx
Log:
Added a metamap to connect the worldmaps.
Rearranged a lot of stuff.. The level name that's stored in the StatManager is
now the actual levelname from the .pingus file (unless blank), so the old
savegames.xml file won't be effective anymore.
Also added some things to the variables.xml file.
More general cleanup, too. Big commit...
Modified: trunk/Pingus.vcproj
===================================================================
--- trunk/Pingus.vcproj 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/Pingus.vcproj 2006-01-19 19:42:45 UTC (rev 2612)
@@ -762,6 +762,12 @@
RelativePath=".\src\worldmap\manager.hxx">
</File>
<File
+
RelativePath=".\src\worldmap\metamap.cxx">
+ </File>
+ <File
+
RelativePath=".\src\worldmap\metamap.hxx">
+ </File>
+ <File
RelativePath=".\src\worldmap\path.cxx">
</File>
<File
@@ -801,6 +807,12 @@
RelativePath=".\src\worldmap\surface_drawable.hxx">
</File>
<File
+
RelativePath=".\src\worldmap\world_dot.cxx">
+ </File>
+ <File
+
RelativePath=".\src\worldmap\world_dot.hxx">
+ </File>
+ <File
RelativePath=".\src\worldmap\worldmap.cxx">
</File>
<File
Added: trunk/data/metamap/Makefile.am
===================================================================
--- trunk/data/metamap/Makefile.am 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/data/metamap/Makefile.am 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,27 @@
+# $Id: Makefile.am,v 1.19 2006/1/19 20:52:23 Jave27 Exp $
+#
+# Pingus - A free Lemmings clone
+# Copyright (C) 2006 Ingo Ruhnke <address@hidden>
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Override automake so that "make install" puts these in proper place:
+pkgdatadir = $(datadir)/games/@PACKAGE@/metamap
+
+nobase_pkgdata_DATA = metamap.xml
+
+EXTRA_DIST = $(nobase_pkgdata_DATA)
+
+# EOF #
Property changes on: trunk/data/metamap/Makefile.am
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/data/metamap/metamap.xml
===================================================================
--- trunk/data/metamap/metamap.xml 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/data/metamap/metamap.xml 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<pingus-metamap>
+ <head>
+ <!-- FIXME: The following items should be added eventually.
+ The ultimate goal of this metamap is to have a "Globe view"
+ where you can choose which Island/Worldmap you want to play,
+ and watch your pingus sail around the globe.
+ For now, this just determines the order of worldmaps.
+ ----------------------------------------------------------
+ <name>The Globe</name>
+ <music>pingus-1.it</music>
+ <width>1161</width>
+ <height>600</height>
+ -->
+ <default-node>tutorial</default-node>
+ <final-node>volcano</final-node>
+ </head>
+
+ <graph>
+ <nodes>
+ <worlddot>
+ <dot>
+ <name>tutorial</name>
+ <!-- FIXME: This currently has no
meaning since it doesn't get drawn -->
+ <position>
+ <x>50</x>
+ <y>50</y>
+ <z>10</z>
+ </position>
+ </dot>
+ <levelname>tutorial.xml</levelname>
+ </worlddot>
+
+ <worlddot>
+ <dot>
+ <name>volcano</name>
+ <position>
+ <x>180</x>
+ <y>345</y>
+ <z>10</z>
+ </position>
+ </dot>
+ <levelname>volcano.xml</levelname>
+ </worlddot>
+ </nodes>
+
+ <edges>
+ <edge>
+ <name>edge_1</name>
+ <source>tutorial</source>
+ <destination>volcano</destination>
+ <positions>
+ <position>
+ <x>10</x>
+ <y>10</y>
+ <z>10</z>
+ </position>
+ </positions>
+ </edge>
+ </edges>
+ </graph>
+
+</pingus-metamap>
\ No newline at end of file
Property changes on: trunk/data/metamap/metamap.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/data/worldmaps/tutorial.xml
===================================================================
--- trunk/data/worldmaps/tutorial.xml 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/data/worldmaps/tutorial.xml 2006-01-19 19:42:45 UTC (rev 2612)
@@ -10,6 +10,7 @@
<width>1161</width>
<height>600</height>
<default-node>leveldot_1</default-node>
+ <final-node>leveldot_19</final-node>
</head>
<intro_story>
Modified: trunk/data/worldmaps/volcano.xml
===================================================================
--- trunk/data/worldmaps/volcano.xml 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/data/worldmaps/volcano.xml 2006-01-19 19:42:45 UTC (rev 2612)
@@ -9,6 +9,7 @@
<width>800</width>
<height>600</height>
<default-node>leveldot_1</default-node>
+ <final-node>leveldot_19</final-node>
</head>
<intro_story>
Modified: trunk/src/SConscript
===================================================================
--- trunk/src/SConscript 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/SConscript 2006-01-19 19:42:45 UTC (rev 2612)
@@ -225,12 +225,14 @@
'worldmap/graph.cxx',
'worldmap/level_dot.cxx',
'worldmap/manager.cxx',
+'worldmap/metamap.cxx',
'worldmap/path.cxx',
'worldmap/path_drawable.cxx',
'worldmap/path_graph.cxx',
'worldmap/pingus.cxx',
'worldmap/sprite_drawable.cxx',
'worldmap/surface_drawable.cxx',
+'worldmap/world_dot.cxx',
'worldmap/worldmap.cxx',
'worldmap/worldmap_story.cxx',
'worldobj.cxx',
Modified: trunk/src/file_dialog.hxx
===================================================================
--- trunk/src/file_dialog.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/file_dialog.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -35,7 +35,10 @@
struct FileItem {
std::string name;
+ std::string short_name;
std::string friendly_name;
+ bool is_accessible;
+ bool is_finished;
bool is_directory;
};
Modified: trunk/src/file_dialog_item.cxx
===================================================================
--- trunk/src/file_dialog_item.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/file_dialog_item.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -33,14 +33,22 @@
#include "fonts.hxx"
#include "resource.hxx"
#include "gettext.h"
+#include "stat_manager.hxx"
+#include "savegame_manager.hxx"
+#include "savegame.hxx"
+#include "worldmap/manager.hxx"
+#include "worldmap/metamap.hxx"
namespace Pingus {
// Only Constructor
FileDialogItem::FileDialogItem(FileDialog* f, Vector p)
- : mouse_over(false), is_hidden(true), file_dialog(f),
- pos(p),
sprite(Resource::load_sprite("core/misc/404sprite"))
+ : mouse_over(false),
+ is_hidden(true),
+ file_dialog(f),
+ pos(p),
+ sprite(Resource::load_sprite("core/misc/404sprite"))
{
}
@@ -52,7 +60,10 @@
is_hidden = false;
// Load sprite based on file (folder icon, level screenshot,
or generic)
if (file_item.is_directory)
+ {
+ file_item.is_directory = true;
sprite = Resource::load_sprite("core/menu/folder");
+ }
else
{
// FIXME: Load thumbnail specific to this level
@@ -82,15 +93,41 @@
// It's a level file
reader.read_string("levelname", file_item.friendly_name);
reader.read_string("difficulty", file_info);
+ file_item.is_accessible
= true;
file_item.friendly_name
= _(file_item.friendly_name);
file_info =
_("Difficulty: ") + file_info;
+ Savegame* sg =
SavegameManager::instance()->get(file_item.friendly_name);
+ if (sg)
+ {
+ status =
_("Finished!");
+
file_item.is_finished = (sg->status == Savegame::FINISHED);
+ }
+ else
+ {
+ status = _("Not
finished");
+
file_item.is_finished = false;
+ }
}
else
{
// It's a Worldmap
- // FIXME: Add more
types eventually
reader.read_string("name", file_item.friendly_name);
+
reader.read_string("short-name", file_item.short_name);
reader.read_string("description", file_info);
+
+ // Get player's status
for this worldmap
+ if
(!StatManager::instance()->get_bool(
+
file_item.short_name + "-accessible", file_item.is_accessible))
+ {
+ status = _("Not
Accessible");
+
file_item.is_accessible = false;
+ }
+ else if
(!StatManager::instance()->get_bool(
+
file_item.short_name + "-finished", file_item.is_finished))
+ {
+ status = _("Not
Finished");
+
file_item.is_finished = false;
+ }
file_item.friendly_name
= _(file_item.friendly_name);
file_info =
_(file_info);
@@ -133,9 +170,21 @@
pos.y + sprite.get_height(),
CL_Color(255,255,255,150));
else // It's a file
{
- gc.draw_fillrect(pos.x+50, pos.y,
pos.x+300, pos.y+50, CL_Color::azure);
+ // Determine which color to draw the
background rectangle.
+ CL_Color color;
+ if (file_item.is_accessible)
+ if (file_item.is_finished)
+ color = CL_Color::azure;
+ else
+ color = CL_Color::aqua;
+ else
+ color = CL_Color::red;
+ gc.draw_fillrect(pos.x+50, pos.y,
pos.x+270, pos.y+75, color);
+
+ // Draw level or worldmap information.
gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y, file_item.friendly_name);
gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y+25, file_info);
+ gc.print_left(Fonts::pingus_small,
pos.x+50, pos.y+50, status);
}
}
}
@@ -144,7 +193,8 @@
void
FileDialogItem::on_primary_button_click (int x, int y)
{
- file_dialog->set_selected_file(file_item);
+ if (file_item.is_accessible)
+ file_dialog->set_selected_file(file_item);
}
void
Modified: trunk/src/file_dialog_item.hxx
===================================================================
--- trunk/src/file_dialog_item.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/file_dialog_item.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -37,6 +37,7 @@
/** Extra info about this file - differs based on file type
(difficulty, etc.) */
std::string file_info;
+ std::string status;
FileDialog* file_dialog;
Vector pos;
Modified: trunk/src/game_session.cxx
===================================================================
--- trunk/src/game_session.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/game_session.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -117,7 +117,7 @@
{ // Write the savegame
Savegame savegame;
- savegame.levelname = result.plf.get_resname();
+ savegame.levelname = result.plf.get_levelname();
savegame.needed_time = result.used_time;
savegame.saved_pingus = result.saved;
Modified: trunk/src/gui/combobox.cxx
===================================================================
--- trunk/src/gui/combobox.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/gui/combobox.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -83,6 +83,7 @@
}
item_list.clear();
current_item = 0;
+ drop_down = false;
}
// Returns whether or not the combobox is at this location
Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/pingus_main.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -924,6 +924,7 @@
Sound::PingusSound::init();
PinguActionFactory::init();
Credits::init();
+ WorldMapNS::WorldMapManager::instance();
fps_counter.init();
console.init();
Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/pingus_menu.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -172,18 +172,17 @@
PingusMenu::do_start(const std::string &filename)
{ // Start the story or worldmap mode
Sound::PingusSound::play_sound ("letsgo");
-
- bool story_seen = false;
- StatManager::instance()->get_bool(StatManager::get_resname(filename) +
"-story-seen", story_seen);
-
WorldMapNS::WorldMapManager::instance()->load(filename);
+ bool story_seen = false;
+
StatManager::instance()->get_bool(WorldMapNS::WorldMapManager::instance()->
+ get_worldmap()->get_shortname() + "-story-seen", story_seen);
+
if (!story_seen)
ScreenManager::instance()->push_screen(new StoryScreen(
WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
else
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
- //}
}
void PingusMenu::do_contrib(const std::string &levelfile)
Modified: trunk/src/savegame.hxx
===================================================================
--- trunk/src/savegame.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/savegame.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -50,6 +50,7 @@
int saved_pingus;
Savegame();
+ ~Savegame() { }
Savegame(FileReader node);
Savegame(std::string arg_levelname, S_Status arg_status, int arg_time, int
arg_saved_pingus);
Modified: trunk/src/story_screen.cxx
===================================================================
--- trunk/src/story_screen.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/story_screen.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -90,7 +90,6 @@
void on_click()
{
story_comp->next_text();
- //ScreenManager::instance()->replace_screen (PingusMenuManager::instance
(), false);
}
};
@@ -109,7 +108,6 @@
StoryScreenComponent::StoryScreenComponent (WorldMapNS::WorldMapStory
*arg_story)
: story(arg_story)
{
- // FIXME: Need to Re-enable credits
/*if (&arg_story == &Story::credits)
show_credits = true;
else */
@@ -197,10 +195,12 @@
else
{
//Out of story pages
- StatManager::instance()->set_bool(
-
StatManager::get_resname(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_filename())
+
StatManager::instance()->set_bool(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_shortname()
+ "-story-seen", true);
-
+
+ //See if credits have been seen
+ /*if
StatManager::instance()->get_bool(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_shortname()
+ + ") */
if (show_credits)
ScreenManager::instance()->replace_screen(Credits::instance(),
false);
else
Modified: trunk/src/worldmap/Makefile.am
===================================================================
--- trunk/src/worldmap/Makefile.am 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/Makefile.am 2006-01-19 19:42:45 UTC (rev 2612)
@@ -34,6 +34,8 @@
level_dot.hxx \
manager.cxx \
manager.hxx \
+metamap.cxx \
+metamap.hxx \
path.cxx \
path.hxx \
path_drawable.cxx \
@@ -47,6 +49,8 @@
sprite_drawable.hxx \
surface_drawable.cxx \
surface_drawable.hxx \
+world_dot.cxx \
+world_dot.hxx \
worldmap.cxx \
worldmap.hxx \
worldmap_story.cxx \
Modified: trunk/src/worldmap/dot_factory.cxx
===================================================================
--- trunk/src/worldmap/dot_factory.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/dot_factory.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -19,6 +19,7 @@
#include "../pingus_error.hxx"
#include "level_dot.hxx"
+#include "world_dot.hxx"
#include "dot_factory.hxx"
namespace Pingus {
@@ -27,20 +28,20 @@
Dot*
DotFactory::create(FileReader reader)
{
- if (reader.get_name() == "leveldot")
- {
-
- }
- else if (reader.get_name() == "tubedot")
- {
-
- }
- else
- {
- //PingusError::raise("DotFactory: unknown tag: ");
- }
-
- return new LevelDot(reader);
+ if (reader.get_name() == "leveldot")
+ {
+ return new LevelDot(reader);
+ }
+ else if (reader.get_name() == "worlddot")
+ {
+ return new WorldDot(reader);
+ }
+ //else if (reader.get_name() == "tubedot")
+ else
+ {
+ PingusError::raise("DotFactory: unknown tag: ");
+ }
+ return 0;
}
} // namespace WorldMapNS
Modified: trunk/src/worldmap/level_dot.cxx
===================================================================
--- trunk/src/worldmap/level_dot.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/level_dot.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -47,8 +47,10 @@
highlight_green_dot_sur(Resource::load_sprite("core/worldmap/dot_green_hl")),
highlight_red_dot_sur(Resource::load_sprite("core/worldmap/dot_red_hl"))
{
- reader.read_string("levelname", levelname);
- plf = PLFResMgr::load_plf(levelname);
+ std::string resname;
+ reader.read_string("levelname", resname);
+ plf = PLFResMgr::load_plf(resname);
+ levelname = plf.get_levelname();
}
void
@@ -137,8 +139,8 @@
pos_correction = realpos + length - static_cast<int>(gc.get_width());
gc.print_center(Fonts::pingus_small,
- static_cast<int>(pos.x) - pos_correction,
- static_cast<int>(pos.y - 40),
+ pos.x - (float)pos_correction,
+ pos.y - 40,
_(get_plf().get_levelname()),
10000);
}
@@ -152,8 +154,8 @@
pos_correction = realpos + length - static_cast<int>(gc.get_width());
gc.print_center(Fonts::pingus_small,
- static_cast<int>(pos.x) - pos_correction,
- static_cast<int>(pos.y - 30),
+ pos.x - (float)pos_correction,
+ pos.y - 30,
_("locked"),
10000);
}
@@ -161,7 +163,7 @@
if (maintainer_mode)
{
gc.print_center(Fonts::pingus_small,
- int(pos.x), int(pos.y - 56),
+ pos.x, pos.y - 56,
get_plf().get_resname(),
10000);
}
Modified: trunk/src/worldmap/manager.cxx
===================================================================
--- trunk/src/worldmap/manager.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/manager.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -29,6 +29,7 @@
#include "worldmap.hxx"
#include "worldmap_story.hxx"
#include "pingus.hxx"
+#include "metamap.hxx"
#include "manager.hxx"
#include "../story_screen.hxx"
@@ -211,12 +212,12 @@
}
WorldMapManager::WorldMapManager ()
- : worldmap(0),
- new_worldmap(0)
+ : is_init(false),
+ exit_worldmap(false),
+ worldmap(0),
+ new_worldmap(0),
+ metamap(new
MetaMap(path_manager.complete("metamap/metamap.xml")))
{
- is_init = false;
- exit_worldmap = false;
-
// FIXME: a bit ugly because of the proteced member, but should work
// FIXME: well enough. GUIScreen could also use multi-inheritage,
// FIXME: but that could lead to member function name conflicts
@@ -226,13 +227,6 @@
gui_manager->add(new WorldMapManagerEnterButton());
gui_manager->add(new WorldMapManagerStoryButton());
-
- bool credits_unlocked = false;
- StatManager::instance()->get_bool("credits-unlocked", credits_unlocked);
- if (credits_unlocked)
- {
- gui_manager->add(new WorldMapManagerCreditsButton());
- }
}
void
@@ -242,27 +236,36 @@
delete worldmap;
worldmap = new WorldMap (filename);
+
+ bool credits_unlocked = false;
+ StatManager::instance()->get_bool(worldmap->get_shortname() +
"-credits-unlocked",
+ credits_unlocked);
+ if (credits_unlocked)
+ {
+ gui_manager->add(new WorldMapManagerCreditsButton());
+ }
}
void
WorldMapManager::on_startup ()
{
- exit_worldmap = false;
- Sound::PingusSound::stop_music();
+ exit_worldmap = false;
+ Sound::PingusSound::stop_music();
- if (!worldmap)
- {
- load(path_manager.complete("worldmaps/tutorial.xml"));
- }
+ if (!worldmap)
+ {
+ load(path_manager.complete("worldmaps/" +
metamap->get_default_worldmap()));
+ }
- if (worldmap)
- worldmap->on_startup ();
+ if (worldmap)
+ worldmap->on_startup ();
}
WorldMapManager::~WorldMapManager ()
{
delete worldmap;
delete new_worldmap;
+ delete metamap;
}
void
Modified: trunk/src/worldmap/manager.hxx
===================================================================
--- trunk/src/worldmap/manager.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/manager.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -33,7 +33,7 @@
namespace WorldMapNS {
typedef int NodeId;
-
+class MetaMap;
class WorldMap;
/** The WorldMapManager manages the worldmaps and the translation
@@ -75,6 +75,8 @@
WorldMap* worldmap;
WorldMap* new_worldmap;
+ MetaMap* metamap;
+
WorldMapManager ();
public:
~WorldMapManager ();
@@ -97,6 +99,7 @@
/** @}*/
WorldMap* get_worldmap() { return worldmap; }
+ MetaMap* get_metamap() { return metamap; }
/** Change the current map to the given map
Added: trunk/src/worldmap/metamap.cxx
===================================================================
--- trunk/src/worldmap/metamap.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/metamap.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,117 @@
+// $Id: metamap.cxx,v 1.32 2006/1/19 00:30:04 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2006 Ingo Ruhnke <address@hidden>
+//
+// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <ClanLib/core.h>
+#include "dot.hxx"
+#include "metamap.hxx"
+#include "path_graph.hxx"
+#include "../pingus_error.hxx"
+#include "../debug.hxx"
+#include "../globals.hxx"
+#include "../stat_manager.hxx"
+#include "../xml_file_reader.hxx"
+
+namespace Pingus {
+namespace WorldMapNS {
+
+// Constructor
+MetaMap::MetaMap(const std::string &filename_arg) :
+ filename(filename_arg)
+{
+ CL_InputSourceProvider_File provider(".");
+ CL_DomDocument doc(provider.open_source(filename), true);
+ CL_DomElement root = doc.get_document_element();
+
+ XMLFileReader xml(root);
+ parse_file(xml);
+
+ pout(PINGUS_DEBUG_WORLDMAP) << "Metamap Info: " <<
+ " Default Node: " << default_node <<
+ " Final Node: " << final_node <<
+ " Default World Name: " <<
path_graph->get_dot(default_node)->get_name() << std::endl;
+}
+
+// Parse the XML file
+void
+MetaMap::parse_file(FileReader &reader)
+{
+ if (reader.get_name() == "pingus-metamap")
+ {
+ parse_graph(reader.read_section("graph"));
+ parse_properties(reader.read_section("head"));
+ // FIXME: Implement this stuff eventually.
+ // parse_objects(reader.read_section("objects"));
+ // intro_story = new
WorldMapStory(reader.read_section("intro_story"));
+ // end_story = new
WorldMapStory(reader.read_section("end_story"));
+ }
+ else
+ PingusError::raise("MetaMap: " + filename + ": not a MetaMap
file");
+
+ if (!path_graph)
+ PingusError::raise("MetaMap: " + filename + " missing Graph");
+}
+
+// Parse the nodes and edges
+void
+MetaMap::parse_graph(FileReader &reader)
+{
+ path_graph = new PathGraph(this, reader);
+}
+
+// Parse the properties of this file
+void
+MetaMap::parse_properties(FileReader &reader)
+{
+ // Get beginning and ending nodes.
+ std::string node_name;
+ reader.read_string("default-node", node_name);
+ default_node = path_graph->lookup_node(node_name);
+
+ unlock_default(node_name);
+
+ reader.read_string("final-node", node_name);
+ final_node = path_graph->lookup_node(node_name);
+}
+
+void
+MetaMap::unlock_default(const std::string &default_node_name)
+{
+ bool is_opened = false;
+ StatManager::instance()->get_bool(default_node_name + "-accessible",
is_opened);
+ if (!is_opened)
+ {
+ StatManager::instance()->set_bool(default_node_name +
"-accessible", true);
+ }
+}
+
+std::string
+MetaMap::get_default_worldmap()
+{
+ return (path_graph->get_dot(default_node)->get_name());
+}
+
+MetaMap::~MetaMap()
+{
+ delete path_graph;
+}
+
+} // WorldMap namespace
+} // Pingus namespace
+
+/* EOF */
Property changes on: trunk/src/worldmap/metamap.cxx
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/src/worldmap/metamap.hxx
===================================================================
--- trunk/src/worldmap/metamap.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/metamap.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,95 @@
+// $Id: metamap.hxx,v 1.32 2006/1/19 00:30:04 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2006 Ingo Ruhnke <address@hidden>
+//
+// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_PINGUS_METAMAP_HXX
+#define HEADER_PINGUS_METAMAP_HXX
+
+#include <string>
+
+namespace Pingus {
+
+ class FileReader;
+
+namespace WorldMapNS {
+
+ class Drawable;
+ class PathGraph;
+ typedef int EdgeId;
+ typedef int NodeId;
+
+/** This class is used to connect the WorldMaps (or "islands").
+ FIXME: Eventually, this should draw a picture of the globe so you
+ FIXME: can watch your pingus sail around and pick which island/area
they want
+ FIXME: to go to */
+class MetaMap {
+private:
+ // here, a NodeId represents a WorldMap.
+ NodeId default_node;
+ NodeId final_node;
+
+ /** The graph that represents the path between Nodes */
+ PathGraph* path_graph;
+
+ /** Filename of this Metamap */
+ std::string filename;
+
+public:
+ MetaMap(const std::string &filename_arg);
+ ~MetaMap();
+
+ /** Returns whether or not the given worldmap is accessible. Use the
<short-name>
+ tag in the WorldMap XML file as the string variable. */
+ bool is_accessible(const std::string &worldmap_shortname);
+
+ /** Action to take when the worldmap has been completed. This should
record that
+ fact, as well as unlock all other worldmaps */
+ void set_finished(const std::string &worldmap_shortname);
+
+ /** FIXME: Implement this when the MetaMap is viewable */
+ void add_drawable(Drawable* drawable) { }
+
+ /** Return the name of the default node in this metamap (which is a
worldmap) */
+ std::string get_default_worldmap();
+
+private:
+ /** Unlock surrounding nodes. This sets the "-accessible" tag in the
StatManager for
+ the accessible worldmaps */
+ void unlock_nodes();
+ void unlock_default(const std::string &default_node_name);
+
+ /** Parses the passed filename to get information about the MetaMap */
+ void parse_file(FileReader &reader);
+
+ /** Parses the <head> section */
+ void parse_properties(FileReader &reader);
+
+ /** Parses the <graph> section */
+ void parse_graph(FileReader &reader);
+
+ MetaMap();
+ MetaMap (const MetaMap&);
+ MetaMap& operator= (const MetaMap&);
+}; // MetaMap class.
+
+} // WorldMap namespace;
+} // Pingus namespace;
+
+#endif
+
+/* EOF */
Property changes on: trunk/src/worldmap/metamap.hxx
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/src/worldmap/path_graph.cxx
===================================================================
--- trunk/src/worldmap/path_graph.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/path_graph.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -24,6 +24,7 @@
#include "dot.hxx"
#include "dot_factory.hxx"
#include "worldmap.hxx"
+#include "metamap.hxx"
#include "pathfinder.hxx"
#include "path_graph.hxx"
#include "path_drawable.hxx"
@@ -32,19 +33,26 @@
namespace Pingus {
namespace WorldMapNS {
-PathGraph::PathGraph(WorldMap* arg_worldmap, FileReader reader)
- : worldmap(arg_worldmap)
+PathGraph::PathGraph(WorldMap* arg_worldmap, FileReader &reader)
+ : worldmap(arg_worldmap),
+ metamap(0)
{
parse_nodes(reader.read_section("nodes"));
parse_edges(reader.read_section("edges"));
- // Init the pathfinder cache
- pathfinder_cache.resize(graph.max_node_handler_value());
- for(PFinderCache::iterator i = pathfinder_cache.begin();
- i != pathfinder_cache.end(); ++i)
- *i = 0;
+ init_cache();
}
+PathGraph::PathGraph(MetaMap* arg_metamap, FileReader &reader)
+ : metamap(arg_metamap),
+ worldmap(0)
+{
+ parse_nodes(reader.read_section("nodes"));
+ parse_edges(reader.read_section("edges"));
+
+ init_cache();
+}
+
void delete_Path(Edge<Path*> x)
{
delete x.data;
@@ -73,7 +81,10 @@
node_lookup[dot->get_name()] = id;
// add the dot to the list of drawables
- worldmap->add_drawable(dot);
+ if (worldmap)
+ worldmap->add_drawable(dot);
+ else
+ metamap->add_drawable(dot);
// FIXME: should be use this for freeing the stuff?
dots.push_back(dot);
@@ -130,7 +141,7 @@
float cost = full_path.length();
// FIXME: Memory leak
- if (pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
+ if (worldmap && pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
worldmap->add_drawable(new PathDrawable(full_path));
// FIXME: No error checking,
@@ -260,6 +271,16 @@
return NoNode;
}
+void
+PathGraph::init_cache()
+{
+ // Init the pathfinder cache
+ pathfinder_cache.resize(graph.max_node_handler_value());
+ for(PFinderCache::iterator i = pathfinder_cache.begin();
+ i != pathfinder_cache.end(); ++i)
+ *i = 0;
+}
+
} // namespace WorldMapNS
} // namespace Pingus
Modified: trunk/src/worldmap/path_graph.hxx
===================================================================
--- trunk/src/worldmap/path_graph.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/path_graph.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -32,12 +32,15 @@
class Dot;
class WorldMap;
+class MetaMap;
/** This class represents the walkable path on the Worldmap */
class PathGraph
{
private:
+ // The pathgraph will have one of these, not both.
WorldMap* worldmap;
+ MetaMap* metamap;
public:
// FIXME: Memory leak? Where do we free stuff data inside the graph?
@@ -60,7 +63,8 @@
/** @param worldmap is a pointer to the worldmap that holds this
PathGraph, it is used so that the PathGraph can insert its
drawables into the world */
- PathGraph(WorldMap* worldmap, FileReader reader);
+ PathGraph(WorldMap* worldmap, FileReader &reader);
+ PathGraph(MetaMap* metamap, FileReader &reader);
~PathGraph();
@@ -85,6 +89,7 @@
private:
void parse_nodes(FileReader reader);
void parse_edges(FileReader reader);
+ void init_cache();
PathGraph (const PathGraph&);
PathGraph& operator= (const PathGraph&);
Modified: trunk/src/worldmap/pingus.cxx
===================================================================
--- trunk/src/worldmap/pingus.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/pingus.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -121,7 +121,7 @@
Pingus::get_direction() const
{
return (atan2(last_pos.x - pos.x,
- -(last_pos.y - pos.y)) / Math::pi * 180.0f) + 180.0f;
+ -(last_pos.y - pos.y)) / (float)Math::pi * 180.0f) + 180.0f;
}
bool
Added: trunk/src/worldmap/world_dot.cxx
===================================================================
--- trunk/src/worldmap/world_dot.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/world_dot.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,47 @@
+// $Id: world_dot.cxx,v 1.11 2006/1/19 19:28:55 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2006 Ingo Ruhnke <address@hidden>
+//
+// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "world_dot.hxx"
+#include "../stat_manager.hxx"
+#include "../file_reader.hxx"
+
+namespace Pingus {
+namespace WorldMapNS {
+
+WorldDot::WorldDot(FileReader reader) :
+ Dot(reader.read_section("dot")),
+ is_accessible(false),
+ is_finished(false)
+{
+ // Get the status from the StatManger
+ StatManager::instance()->get_bool(name + "-accessible", is_accessible);
+ StatManager::instance()->get_bool(name + "-finished", is_finished);
+}
+
+void
+WorldDot::unlock()
+{
+ is_accessible = true;
+ StatManager::instance()->set_bool(name + "-accessible", true);
+}
+
+} // WorldMapNS namespace
+} // Pingus namespace
+
+/* EOF */
Property changes on: trunk/src/worldmap/world_dot.cxx
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/src/worldmap/world_dot.hxx
===================================================================
--- trunk/src/worldmap/world_dot.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/world_dot.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -0,0 +1,63 @@
+// $Id: world_dot.hxx,v 1.11 2006/1/19 19:28:55 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2006 Ingo Ruhnke <address@hidden>
+//
+// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_PINGUS_WORLDMAP_WORLD_DOT_HXX
+#define HEADER_PINGUS_WORLDMAP_WORLD_DOT_HXX
+
+#include "dot.hxx"
+
+namespace Pingus {
+namespace WorldMapNS {
+
+/** Represents a WorldMap dot on a MetaMap */
+class WorldDot : public Dot
+{
+private:
+ bool is_accessible;
+ bool is_finished;
+
+public:
+ WorldDot(FileReader reader);
+
+ /** Draw stuff that should be displayed if the mouse is over the dot */
+ virtual void draw_hover(DrawingContext& gc) { UNUSED_ARG(gc); }
+ virtual void draw(DrawingContext& gc) { UNUSED_ARG(gc); }
+ virtual void update(float delta) { UNUSED_ARG(delta); }
+
+ Vector get_pos() { return pos; }
+
+ virtual void on_click() { }
+
+ virtual bool finished() { return finished; }
+ virtual bool accessible() { return is_accessible; }
+
+ /** makes the node accessible */
+ virtual void unlock();
+
+private:
+ WorldDot (const WorldDot&);
+ WorldDot& operator= (const WorldDot&);
+}; // WorldDot class
+
+} // WorldMapNS namespace
+} // Pingus namespace
+
+#endif
+
+/* EOF */
Property changes on: trunk/src/worldmap/world_dot.hxx
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/src/worldmap/worldmap.cxx
===================================================================
--- trunk/src/worldmap/worldmap.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/worldmap.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -146,9 +146,12 @@
reader.read_int("width", width);
reader.read_int("height", height);
+ // Get beginning and ending nodes.
std::string node_name;
reader.read_string("default-node", node_name);
default_node = path_graph->lookup_node(node_name);
+ reader.read_string("final-node", node_name);
+ final_node = path_graph->lookup_node(node_name);
}
void
@@ -388,15 +391,17 @@
path_graph->graph.for_each_node(unlock_nodes(path_graph));
bool credits_unlocked = false;
- StatManager::instance()->get_bool("credits-unlocked", credits_unlocked);
+ StatManager::instance()->get_bool(short_name + "-credits-unlocked",
credits_unlocked);
if (!credits_unlocked)
{
- Dot* dot = path_graph->get_dot(path_graph->lookup_node("leveldot_19"));
+ // See if the last level is finished
+ Dot* dot = path_graph->get_dot(final_node);
if (dot)
{
if (dot->finished())
{
+
StatManager::instance()->set_bool(short_name + "-finished", true);
ScreenManager::instance()->replace_screen(
new
StoryScreen(get_end_story()), true);
StatManager::instance()->set_bool("credits-unlocked", true);
@@ -431,13 +436,17 @@
pingus->set_position(id);
LevelDot* leveldot = dynamic_cast<LevelDot*>(path_graph->get_dot(id));
- std::string resname = leveldot->get_plf().get_resname();
+ leveldot->unlock();
+ /*
+ std::string resname = leveldot->get_plf().get_levelname();
// 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);
+ update_locked_nodes();
}
+ */
}
} // namespace WorldMapNS
} // namespace Pingus
Modified: trunk/src/worldmap/worldmap.hxx
===================================================================
--- trunk/src/worldmap/worldmap.hxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldmap/worldmap.hxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -72,7 +72,9 @@
std::string email;
std::string music;
+ // Beginning and ending nodes are configurable by the XML file.
NodeId default_node;
+ NodeId final_node;
Pingus* pingus;
@@ -104,6 +106,7 @@
void on_startup();
std::string get_filename() const { return filename; }
+ std::string get_shortname() const { return short_name; }
void draw (DrawingContext& gc);
void update (float delta);
Modified: trunk/src/worldobjs/fake_exit.cxx
===================================================================
--- trunk/src/worldobjs/fake_exit.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldobjs/fake_exit.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -34,7 +34,7 @@
smashing(false)
{
reader.read_vector("position", pos);
- pos -= Vector(surface.get_width ()/2, surface.get_height ());
+ pos -= Vector((float)surface.get_width ()/2, (float)surface.get_height ());
}
float
Modified: trunk/src/worldobjs/smasher.cxx
===================================================================
--- trunk/src/worldobjs/smasher.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldobjs/smasher.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -69,9 +69,10 @@
for(int i=0; i < 20; ++i)
{
world->get_smoke_particle_holder()->
- add_particle(pos.x + 20 + rand() % 260,
+ add_particle(pos.x + 20 + float(rand() % 260),
pos.y + 180,
- Math::frand()-0.5f,
Math::frand()-0.5f);
+ float(Math::frand()-0.5f),
+
float(Math::frand()-0.5f));
}
for (PinguIter pingu = holder->begin (); pingu !=
holder->end (); ++pingu)
Modified: trunk/src/worldobjs/woodthing.cxx
===================================================================
--- trunk/src/worldobjs/woodthing.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/worldobjs/woodthing.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -49,7 +49,7 @@
world->get_smoke_particle_holder()->
add_particle(pos.x - surface.get_width () / 2 - 24,
pos.y - surface.get_height() + 32 - 147,
- (Math::frand() + 1) * -0.6f, (Math::frand() + 1) * -0.6f);
+ float(Math::frand() + 1) * -0.6f, float(Math::frand() +
1) * -0.6f);
}
}
Modified: trunk/src/xml_pingus_level.cxx
===================================================================
--- trunk/src/xml_pingus_level.cxx 2006-01-19 01:56:00 UTC (rev 2611)
+++ trunk/src/xml_pingus_level.cxx 2006-01-19 19:42:45 UTC (rev 2612)
@@ -80,6 +80,9 @@
reader.read_color ("ambient-light", impl->ambient_light);
reader.read_string("author", impl->author);
+ if (impl->levelname ==
std::string())
+ impl->levelname
= impl->resname;
+
FileReader actions_reader;
reader.read_section("actions", actions_reader);
const std::vector<std::string>& actions =
actions_reader.get_section_names();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2612 - in trunk: . data data/metamap data/worldmaps src src/gui src/worldmap src/worldobjs,
jave27 <=