[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2548 - in trunk: . data/worldmaps src src/worldmap
From: |
jave27 |
Subject: |
[Pingus-CVS] r2548 - in trunk: . data/worldmaps src src/worldmap |
Date: |
Thu, 8 Dec 2005 21:37:39 +0100 |
Author: jave27
Date: 2005-12-08 21:37:09 +0100 (Thu, 08 Dec 2005)
New Revision: 2548
Added:
trunk/data/worldmaps/pacman.old
trunk/src/file_dialog_listener.hxx
Removed:
trunk/data/worldmaps/pacman.xml
Modified:
trunk/Pingus.vcproj
trunk/data/worldmaps/Makefile.am
trunk/data/worldmaps/tutorial.xml
trunk/data/worldmaps/volcano.xml
trunk/src/Makefile.am
trunk/src/exit_menu.cxx
trunk/src/file_dialog.cxx
trunk/src/file_dialog.hxx
trunk/src/file_dialog_item.cxx
trunk/src/file_dialog_item.hxx
trunk/src/pingus_menu.cxx
trunk/src/pingus_menu.hxx
trunk/src/pingus_menu_manager.cxx
trunk/src/pingus_sub_menu.hxx
trunk/src/stat_manager.cxx
trunk/src/stat_manager.hxx
trunk/src/story_screen.cxx
trunk/src/worldmap/worldmap.hxx
Log:
Changed Story button to launch a file dialog to choose which WorldMap to play.
Added descriptions to WorldMap XML files.
More minor cleanup.
Modified: trunk/Pingus.vcproj
===================================================================
--- trunk/Pingus.vcproj 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/Pingus.vcproj 2005-12-08 20:37:09 UTC (rev 2548)
@@ -1079,6 +1079,9 @@
RelativePath=".\src\file_dialog_item.hxx">
</File>
<File
+
RelativePath=".\src\file_dialog_listener.hxx">
+ </File>
+ <File
RelativePath=".\src\file_reader.cxx">
</File>
<File
Modified: trunk/data/worldmaps/Makefile.am
===================================================================
--- trunk/data/worldmaps/Makefile.am 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/data/worldmaps/Makefile.am 2005-12-08 20:37:09 UTC (rev 2548)
@@ -18,7 +18,7 @@
# Tweaking the `datadir' to install the files in the correct location
pkgdatadir = $(datadir)/games/@PACKAGE@/worldmaps
-EXTRA_DIST = volcano.xml pacman.xml tutorial.xml
+EXTRA_DIST = volcano.xml pacman.old tutorial.xml
pkgdata_DATA = $(EXTRA_DIST)
# EOF #
\ No newline at end of file
Copied: trunk/data/worldmaps/pacman.old (from rev 2546,
trunk/data/worldmaps/pacman.xml)
Deleted: trunk/data/worldmaps/pacman.xml
===================================================================
--- trunk/data/worldmaps/pacman.xml 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/data/worldmaps/pacman.xml 2005-12-08 20:37:09 UTC (rev 2548)
@@ -1,58 +0,0 @@
-<pingus-worldmap>
- <surface>
- <resource type="datafile">
- <resource-datafile>worldmaps</resource-datafile>
- <resource-ident>pacman</resource-ident>
- </resource>
- </surface>
-
- <node-list>
- <level id="1" accessible="1">
- <node id="2">
- <link id="2"/>
-
- <position>
- <x-pos>321</x-pos>
- <y-pos>297</y-pos>
- </position>
- </node>
-
- <level name="pacman1-yingwan.xml"/>
- </level>
-
- <tube>
- <node id="4">
- <link id="1"/>
- <position>
- <x-pos>232</x-pos>
- <y-pos>297</y-pos>
- </position>
- </node>
- <worldmap linknode="12">volcano.xml</worldmap>
- </tube>
-
- <level>
- <node id="2">
- <link id="3"/>
- <position>
- <x-pos>432</x-pos>
- <y-pos>297</y-pos>
- </position>
- </node>
-
- <level name="pacman2-yingwan.xml"/>
- </level>
-
- <level>
- <node id="3">
- <position>
- <x-pos>542</x-pos>
- <y-pos>297</y-pos>
- </position>
- </node>
-
- <level name="pacman3-yingwan.xml"/>
- </level>
- </node-list>
-
-</pingus-worldmap>
\ No newline at end of file
Modified: trunk/data/worldmaps/tutorial.xml
===================================================================
--- trunk/data/worldmaps/tutorial.xml 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/data/worldmaps/tutorial.xml 2005-12-08 20:37:09 UTC (rev 2548)
@@ -2,6 +2,7 @@
<pingus-worldmap>
<head>
<name>Tutorial Island</name>
+ <description>Learn the basics</description>
<music>pingus-1.it</music>
<author>Ingo Ruhnke</author>
<email>address@hidden</email>
Modified: trunk/data/worldmaps/volcano.xml
===================================================================
--- trunk/data/worldmaps/volcano.xml 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/data/worldmaps/volcano.xml 2005-12-08 20:37:09 UTC (rev 2548)
@@ -1,6 +1,7 @@
<pingus-worldmap>
<head>
<name>Volcano Island</name>
+ <description>Be careful, it's hot!</description>
<music>gd-myla.it</music>
<author>Ingo Ruhnke</author>
<email>address@hidden</email>
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/Makefile.am 2005-12-08 20:37:09 UTC (rev 2548)
@@ -132,6 +132,7 @@
file_dialog.hxx \
file_dialog_item.cxx \
file_dialog_item.hxx \
+file_dialog_listener.hxx \
file_reader.cxx \
file_reader.hxx \
file_reader_impl.hxx \
Modified: trunk/src/exit_menu.cxx
===================================================================
--- trunk/src/exit_menu.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/exit_menu.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -44,8 +44,8 @@
void draw (DrawingContext& gc) {
SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, CL_Display::get_width()/2 - 80,
- CL_Display::get_height()/2 + 25, _("Yes"));
+ gc.print_right(Fonts::chalk_large, (float)CL_Display::get_width()/2 - 80,
+ (float)CL_Display::get_height()/2 + 25, _("Yes"));
}
void on_click()
@@ -77,8 +77,8 @@
void draw (DrawingContext& gc) {
SurfaceButton::draw(gc);
- gc.print_right(Fonts::chalk_large, CL_Display::get_width()/2 + 80,
- CL_Display::get_height()/2 + 25, _("No"));
+ gc.print_right(Fonts::chalk_large, (float)CL_Display::get_width()/2 + 80,
+ (float)CL_Display::get_height()/2 + 25, _("No"));
}
void on_click() {
Modified: trunk/src/file_dialog.cxx
===================================================================
--- trunk/src/file_dialog.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/file_dialog.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -27,6 +27,7 @@
#include "sound/sound.hxx"
#include "file_dialog.hxx"
#include "file_dialog_item.hxx"
+#include "file_dialog_listener.hxx"
namespace Pingus {
@@ -137,12 +138,16 @@
/** 0 for Up, 1 for Down */
int direction;
+ /** Show it or not */
+ bool is_hidden;
+
public:
FileDialogScrollButton (FileDialog* f, int d, int height_offset)
: file_dialog(f),
pos(Vector((float)CL_Display::get_width()/2 + 210,
(float)CL_Display::get_height()/2 +
height_offset)),
- direction(d)
+ direction(d),
+
is_hidden(false)
{
std::string str_direction = d==0 ? "up" : "down";
sprite = Resource::load_sprite("core/menu/" +
str_direction + "_arrow");
@@ -150,7 +155,8 @@
void draw (DrawingContext& gc) {
//FIXME: Should also draw a hover box around it when
the mouse is over it.
- gc.draw(sprite, pos);
+ if (!is_hidden)
+ gc.draw(sprite, pos);
}
void on_primary_button_click(int x, int y)
@@ -160,9 +166,14 @@
bool is_at(int x, int y)
{
+ if (is_hidden)
+ return false;
return (x > (int)pos.x && x < (int)pos.x +
sprite.get_width()
&& y > (int)pos.y && y < (int)pos.y +
sprite.get_height());
}
+
+ void show() { is_hidden = false; }
+ void hide() { is_hidden = true; }
};
class FileDialogParentFolderButton : public GUI::Component
@@ -206,9 +217,13 @@
}
};
- FileDialog::FileDialog (PingusMenuManager* manager_, const std::string
filemask_,
- const std::string searchpath_, bool for_load)
+ FileDialog::FileDialog (FileDialogListener* listener_,
+ PingusMenuManager* manager_,
+ const std::string filemask_,
+ const std::string searchpath_,
+ bool for_load)
: PingusSubMenu (manager_),
+
listener(listener_),
for_loading(for_load),
file_mask(filemask_),
current_path(searchpath_)
@@ -217,10 +232,13 @@
ok_button = new FileDialogOkButton(manager, this,
for_loading ? _("Load") : _("Save"));
+ up_button = new FileDialogScrollButton(this, DIR_UP, -150);
+ down_button = new FileDialogScrollButton(this, DIR_DOWN, 100);
+
gui_manager->add(ok_button, true);
+ gui_manager->add(up_button, true);
+ gui_manager->add(down_button, true);
gui_manager->add(new FileDialogCancelButton(manager), true);
- gui_manager->add(new FileDialogScrollButton(this, DIR_DOWN,
100), true);
- gui_manager->add(new FileDialogScrollButton(this, DIR_UP,
-150), true);
gui_manager->add(new FileDialogParentFolderButton(this));
// FIXME: Ugly - hardcoded values for items in file dialog.
Should be dynamic.
@@ -264,7 +282,7 @@
gc.draw_rect(gc.get_width() / 2 - 285, gc.get_height() / 2 -
160,
gc.get_width() / 2 + 285, gc.get_height() / 2 + 160,
CL_Color::black);
gc.print_center(Fonts::chalk_large, gc.get_width()/2,
gc.get_height()/2 - 220,
- current_file.name);
+ current_file.friendly_name);
PingusSubMenu::draw(gc);
return true;
@@ -307,7 +325,6 @@
file_list.push_back(f);
}
- // FIXME: Should sort the file_list here
std::sort(file_list.begin(), file_list.end(), &FileItemCompare);
current_offset = 0;
@@ -328,6 +345,17 @@
else
(*i)->hide();
}
+
+ // Show or hide scroll buttons
+ if (current_offset == 0)
+ up_button->hide();
+ else
+ up_button->show();
+
+ if (current_offset + (unsigned)file_dialog_items.size() <
(unsigned)file_list.size())
+ down_button->show();
+ else
+ down_button->hide();
}
// Scroll the list up or down.
@@ -373,9 +401,11 @@
}
else
{
- // FIXME: Temporary since we only use this dialog on
the main menu.
+ // Load or save the selected file
if (for_loading)
- manager->mainmenu.do_contrib(current_path +
current_file.name);
+ listener->load(current_path +
current_file.name, file_mask);
+ else
+ listener->save(current_path +
current_file.name, file_mask);
manager->pop_menu();
}
}
Modified: trunk/src/file_dialog.hxx
===================================================================
--- trunk/src/file_dialog.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/file_dialog.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -30,10 +30,12 @@
class Vector;
class FileDialogItem;
class FileDialogOkButton;
- class PingusMenuManager;
+ class FileDialogScrollButton;
+ class FileDialogListener;
struct FileItem {
std::string name;
+ std::string friendly_name;
bool is_directory;
};
@@ -54,6 +56,13 @@
/** The OK button - need to be able to hide and show it */
FileDialogOkButton* ok_button;
+ /** Scroll buttons */
+ FileDialogScrollButton* up_button;
+ FileDialogScrollButton* down_button;
+
+ /** The owner of this file dialog */
+ FileDialogListener* listener;
+
/** Should this dialog box be used for loading? True for load, false
for saving */
bool for_loading;
@@ -79,8 +88,12 @@
void offset_changed();
public:
- FileDialog (PingusMenuManager* manager, const std::string filemask_,
- const std::string searchpath_, const bool for_load = true);
+ FileDialog (FileDialogListener* listener_,
+ PingusMenuManager *manager_,
+ const std::string filemask_,
+ const std::string searchpath_,
+ const bool for_load = true);
+
~FileDialog ();
bool draw (DrawingContext& gc);
Modified: trunk/src/file_dialog_item.cxx
===================================================================
--- trunk/src/file_dialog_item.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/file_dialog_item.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -19,13 +19,19 @@
#include <ClanLib/Display/sprite.h>
#include <ClanLib/Core/IOData/directory_scanner.h>
+#include <ClanLib/Core/IOData/inputsource_provider_file.h>
#include <ClanLib/Core/System/clanstring.h>
+#include <ClanLib/Core/XML/dom_node.h>
+#include <ClanLib/Core/XML/dom_node_list.h>
+#include <ClanLib/Core/XML/dom_document.h>
+#include <ClanLib/Core/XML/dom_element.h>
+#include "pingus_error.hxx"
+#include "xml_file_reader.hxx"
#include "file_dialog_item.hxx"
#include "file_dialog.hxx"
#include "vector.hxx"
#include "fonts.hxx"
#include "resource.hxx"
-#include "xml_pingus_level.hxx"
#include "gettext.h"
namespace Pingus {
@@ -53,18 +59,47 @@
sprite =
Resource::load_sprite("core/menu/default_level");
// Load information about this file if possible.
- if (file_dialog->get_file_mask() == ".pingus")
+ CL_InputSourceProvider_File provider(".");
+ CL_DomDocument
doc(provider.open_source(file_dialog->get_path()
+ + file_item.name), true);
+
+ CL_DomElement root = doc.get_document_element();
+
+ if (root.get_tag_name() == "pingus-level" ||
root.get_tag_name() == "pingus-worldmap")
{
- // Get level information
- XMLPingusLevel level("",
file_dialog->get_path() + file_item.name);
- friendly_name = _(level.get_levelname());
- // Have to limit the size of the printed name
- friendly_name = friendly_name.substr(0, 23);
- file_info = _("Difficulty: ") +
CL_String::to(level.get_difficulty());
- }
- }
- }
+ CL_DomNodeList lst = root.get_child_nodes();
+ for(int i = 0; i < lst.get_length(); ++i)
+ {
+ CL_DomElement node =
lst.item(i).to_element();
+
+ // Get information about this file
+ if (node.get_tag_name() == "head")
+ {
+ XMLFileReader reader(node);
+ if (root.get_tag_name() ==
"pingus-level")
+ {
+ // It's a level file
+
reader.read_string("levelname", file_item.friendly_name);
+
reader.read_string("difficulty", file_info);
+ file_info =
"Difficulty: " + file_info;
+ }
+ else
+ {
+ // It's a Worldmap
+ // FIXME: Add more
types eventually
+
reader.read_string("name", file_item.friendly_name);
+
reader.read_string("description", file_info);
+ }
+ // Have to limit the size of
the printed name
+ file_item.friendly_name =
file_item.friendly_name.substr(0, 23);
+ break;
+ } // if XML Node == "head"
+ } // for loop
+ } // if XML tag_name was recognized
+ } // else it's a file, not a directory
+ } //set_file()
+
bool
FileDialogItem::is_at(int x, int y)
{
@@ -90,7 +125,7 @@
if (mouse_over && !file_item.is_directory)
{
gc.draw_fillrect(pos.x+50, pos.y, pos.x+300,
pos.y+50, CL_Color::azure);
- gc.print_left(Fonts::pingus_small, pos.x+50,
pos.y, friendly_name);
+ 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);
}
}
Modified: trunk/src/file_dialog_item.hxx
===================================================================
--- trunk/src/file_dialog_item.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/file_dialog_item.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -35,7 +35,7 @@
bool mouse_over;
bool is_hidden;
- std::string friendly_name;
+ /** Extra info about this file - differs based on file type
(difficulty, etc.) */
std::string file_info;
FileDialog* file_dialog;
Added: trunk/src/file_dialog_listener.hxx
===================================================================
--- trunk/src/file_dialog_listener.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/file_dialog_listener.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -0,0 +1,38 @@
+// $Id: credits.hxx,v 1.16 2005/12/8 19:28:54 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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_FILE_DIALOG_LISTENER_HXX
+#define HEADER_PINGUS_FILE_DIALOG_LISTENER_HXX
+
+#include <string>
+#include "pingus.hxx"
+
+namespace Pingus {
+
+ class FileDialogListener {
+ public:
+ virtual void save(std::string file, std::string filemask) { }
+ virtual void load(std::string file, std::string filemask) { }
+ }; // class FileDialogListener
+
+} // namespace Pingus
+
+#endif
+
+/* EOF */
Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/pingus_menu.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -84,7 +84,7 @@
slots.push_back(start_button->sig_click().connect(this,
&PingusMenu::setup_game_menu));
slots.push_back(quit_button->sig_click().connect(this,
&PingusMenu::do_quit));
- slots.push_back(story_button->sig_click().connect(this,
&PingusMenu::do_start));
+ slots.push_back(story_button->sig_click().connect(this,
&PingusMenu::setup_worldmap_menu));
slots.push_back(multiplayer_button->sig_click().connect(this,
&PingusMenu::setup_main_menu));
slots.push_back(contrib_button->sig_click().connect(this,
&PingusMenu::setup_contrib_menu));
@@ -124,6 +124,13 @@
}
void
+PingusMenu::setup_worldmap_menu()
+{
+ get_manager ()->show_file_dialog (".xml",
+ path_manager.complete("worldmaps/"), true);
+}
+
+void
PingusMenu::preload ()
{
if (!is_init)
@@ -152,23 +159,21 @@
}
void
-PingusMenu::do_start()
-{ // Start the story mode
+PingusMenu::do_start(std::string filename)
+{ // Start the story or worldmap mode
Sound::PingusSound::play_sound ("letsgo");
bool story_seen = false;
- StatManager::instance()->get_bool("story-seen", story_seen);
+ StatManager::instance()->get_bool(StatManager::get_resname(filename) +
"-story-seen", story_seen);
- if (!story_seen)
- {
-
WorldMapNS::WorldMapManager::instance()->load(path_manager.complete("worldmaps/tutorial.xml"));
- ScreenManager::instance()->push_screen(
- new
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
- }
+ WorldMapNS::WorldMapManager::instance()->load(filename);
+
+ 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
());
- }
+
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
+ //}
}
void PingusMenu::do_contrib(const std::string &levelfile)
@@ -227,6 +232,18 @@
"to redistribute it under certain conditions; see the file
COPYING for details.\n");
}
+void
+PingusMenu::load(std::string file, std::string filemask)
+{
+ // Level
+ if (filemask == ".pingus")
+ do_contrib(file);
+ // Worldmap
+ else if (filemask == ".xml")
+ do_start(file);
+}
+
+
} // namespace Pingus
/* EOF */
Modified: trunk/src/pingus_menu.hxx
===================================================================
--- trunk/src/pingus_menu.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/pingus_menu.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -62,12 +62,21 @@
// These functions setup the different menus
void setup_main_menu();
void setup_game_menu();
+ /** Show the levels folder */
void setup_contrib_menu();
-
+ /** Show the worldmap folder */
+ void setup_worldmap_menu();
+
+ /** Quit the game */
void do_quit();
- void do_start();
+ /** Start the story/worldmap mode */
+ void do_start(std::string filename);
+ /** Start the level editor */
void do_edit();
+ /** Use this to load the level or worldmap */
+ virtual void load(std::string file, std::string filemask);
+
public:
PingusMenu (PingusMenuManager* m);
~PingusMenu();
Modified: trunk/src/pingus_menu_manager.cxx
===================================================================
--- trunk/src/pingus_menu_manager.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/pingus_menu_manager.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -122,7 +122,7 @@
// Initialize the dialog box either for loading or saving.
if (filedialog)
delete filedialog;
- filedialog = new FileDialog(this, filemask, searchpath, for_load);
+ filedialog = new FileDialog(current_menu(), this, filemask, searchpath,
for_load);
filedialog->preload();
push_menu (filedialog);
}
Modified: trunk/src/pingus_sub_menu.hxx
===================================================================
--- trunk/src/pingus_sub_menu.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/pingus_sub_menu.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -21,6 +21,7 @@
#define HEADER_PINGUS_PINGUS_SUB_MENU_HXX
#include "gui/gui_screen.hxx"
+#include "file_dialog_listener.hxx"
class CL_Key;
class CL_InputDevice;
@@ -29,7 +30,7 @@
class PingusMenuManager;
-class PingusSubMenu : public GUIScreen
+class PingusSubMenu : public GUIScreen, public FileDialogListener
{
protected:
PingusMenuManager* manager;
Modified: trunk/src/stat_manager.cxx
===================================================================
--- trunk/src/stat_manager.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/stat_manager.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -18,6 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
+#include <algorithm>
#include <fstream>
#include <ClanLib/core.h>
#include "system.hxx"
@@ -52,6 +53,20 @@
instance_ = 0;
}
+std::string
+StatManager::get_resname(const std::string& filename)
+{
+ std::string::size_type pos;
+ std::string str;
+ pos = filename.rfind("/");
+ pos++;
+ str = filename.substr(pos);
+ pos = 0;
+ while ((pos = str.find('.', pos)) != std::string::npos)
+ str.replace(pos, 1, 1, '-');
+ return str;
+}
+
StatManager::StatManager(const std::string& arg_filename)
: statfilename(arg_filename)
{
Modified: trunk/src/stat_manager.hxx
===================================================================
--- trunk/src/stat_manager.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/stat_manager.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -41,6 +41,10 @@
static void init();
static void deinit();
+ /** Returns the resource name of a worldmap - strips out everything
except after
+ the last '/' in the full path + filename, and converts periods
to dashes */
+ static std::string get_resname(const std::string& filename);
+
StatManager(const std::string& filename);
~StatManager();
Modified: trunk/src/story_screen.cxx
===================================================================
--- trunk/src/story_screen.cxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/story_screen.cxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -31,6 +31,7 @@
#include "fonts.hxx"
#include "story_screen.hxx"
#include "res_descriptor.hxx"
+#include "worldmap/worldmap.hxx"
#include "worldmap/manager.hxx"
#include "worldmap/worldmap_story.hxx"
#include "stat_manager.hxx"
@@ -196,7 +197,9 @@
else
{
//Out of story pages
- StatManager::instance()->set_bool("story-seen", true);
+ StatManager::instance()->set_bool(
+
StatManager::get_resname(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_filename())
+ + "-story-seen", true);
if (show_credits)
ScreenManager::instance()->replace_screen(Credits::instance(),
false);
Modified: trunk/src/worldmap/worldmap.hxx
===================================================================
--- trunk/src/worldmap/worldmap.hxx 2005-12-08 15:35:00 UTC (rev 2547)
+++ trunk/src/worldmap/worldmap.hxx 2005-12-08 20:37:09 UTC (rev 2548)
@@ -100,6 +100,8 @@
void on_startup();
+ std::string get_filename() const { return filename; }
+
void draw (DrawingContext& gc);
void update (float delta);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2548 - in trunk: . data/worldmaps src src/worldmap,
jave27 <=