[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3087 - in trunk/pingus: . src src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3087 - in trunk/pingus: . src src/editor |
Date: |
Wed, 5 Sep 2007 18:10:35 +0200 |
Author: grumbel
Date: 2007-09-05 18:10:33 +0200 (Wed, 05 Sep 2007)
New Revision: 3087
Modified:
trunk/pingus/TODO
trunk/pingus/src/SConscript
trunk/pingus/src/editor/editor_level.cpp
trunk/pingus/src/editor/editor_level.hpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/editor_screen.hpp
trunk/pingus/src/editor/editor_viewport.cpp
trunk/pingus/src/editor/editor_viewport.hpp
trunk/pingus/src/editor/panel.cpp
trunk/pingus/src/file_reader.cpp
trunk/pingus/src/file_reader.hpp
trunk/pingus/src/pingus_level.cpp
trunk/pingus/src/pingus_level.hpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_main.hpp
trunk/pingus/src/pingus_menu.cpp
trunk/pingus/src/plf_res_mgr.cpp
trunk/pingus/src/plf_res_mgr.hpp
Log:
- added simple help screen to editor
- added right-click scrolling to the editor
- added new class Pathname for cleaner handling of pathnames
- fixed loading of levels from command line
Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/TODO 2007-09-05 16:10:33 UTC (rev 3087)
@@ -86,14 +86,47 @@
get updated when the mouse isn't in the window (need to switch from
event to polling?!)
-- action-axis doesn't handle analog
+- action-axis doesn't handle analog (do we even need this or could we do with
axis-button?)
-- fix memory leaks in input2/
+- fix memory leaks in input2/ (Controller doesn't clean up)
- menu crashes when you click a little wildely
- 404 image use
+Editor:
+=======
+
+- add sidebar to select objects
+
+- fix align of exits
+
+- object selector: 48x48 tumbnails, keep aspect when possible,
+types of objects: 13+ object types
+
+48 * 5 = 240
+30 * 8 = 240
+
+- maybe have a scrollbar
+
+Groundpiece (ground)
+Groundpiece (solid)
+Groundpiece (bridge)
+Groundpiece (transparent)
+Groundpiece (remove)
+
+Hotspot
+Entrance
+Exit
+Liquid
+
+Special Objects
+Traps
+
+Weather
+
+Backgrounds
+
Nice to Have:
=============
Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/SConscript 2007-09-05 16:10:33 UTC (rev 3087)
@@ -190,7 +190,8 @@
'particles/rain_particle_holder.cpp',
'particles/smoke_particle_holder.cpp',
'particles/snow_particle_holder.cpp',
-'path_manager.cpp',
+'path_manager.cpp',
+'pathname.cpp',
'pingu.cpp',
'pingu_action.cpp',
'pingu_action_factory.cpp',
Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_level.cpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -24,6 +24,7 @@
#include "editor_level.hpp"
#include "level_impl.hpp"
#include "level_objs.hpp"
+#include "pathname.hpp"
#include "../pingus_level.hpp"
#include "../sexpr_file_writer.hpp"
@@ -118,14 +119,14 @@
}
// Load an existing level from a file
-void EditorLevel::load_level(const std::string& filename)
+void EditorLevel::load_level(const Pathname& pathname)
{
if (impl)
delete impl;
impl = new LevelImpl();
// Load the level from the file - we don't care what it's res_name is.
- PingusLevel existing_level("", filename);
+ PingusLevel existing_level(pathname);
// Assign all of the level information to our LevelImpl
impl->levelname = existing_level.get_levelname();
Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_level.hpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -24,6 +24,8 @@
#include <vector>
#include "level_impl.hpp"
+class Pathname;
+
namespace Editor {
class LevelObj;
@@ -44,7 +46,7 @@
bool save_level(const std::string& filename);
/** Load an existing level from a file */
- void load_level(const std::string& filename);
+ void load_level(const Pathname& pathname);
/** Return all objects in the level */
std::vector<LevelObj*> get_objects() const { return impl->objects; }
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -30,6 +30,7 @@
#include "../fonts.hpp"
#include "../file_dialog.hpp"
#include "../path_manager.hpp"
+#include "../pathname.hpp"
#include "game_session.hpp"
#include "editor_level.hpp"
#include "panel.hpp"
@@ -46,7 +47,8 @@
panel(0),
viewport(0),
filedialog(0),
- close_dialog(false)
+ close_dialog(false),
+ show_help(false)
{
// Create the viewport for the images and data
viewport = new EditorViewport(this);
@@ -108,7 +110,7 @@
// Load a new level
void
-EditorScreen::load(const std::string &file)
+EditorScreen::load(const Pathname& file)
{
close_dialog = true;
plf->load_level(file);
@@ -118,16 +120,59 @@
// Draw the background and components
bool
-EditorScreen::draw(DrawingContext &gc)
+EditorScreen::draw(DrawingContext& gc)
{
// Black out screen
gc.fill_screen(Color(0,0,0));
gui_manager->draw(gc);
+
+ if (show_help)
+ {
+ Size size(600, 400);
+ gc.draw_fillrect(int(gc.get_width()/2) - size.width/2,
+ int(gc.get_height()/2) - size.height/2,
+ int(gc.get_width()/2) + size.width/2,
+ int(gc.get_height()/2) + size.height/2,
+ Color(0,0,0));
+
+ gc.print_center(Fonts::courier_small,
+ int(gc.get_width()/2),
+ int(gc.get_height()/2) - size.height/2 + 12,
+ "Editor Help");
- // FIXME: Remove this warning
- gc.print_center(Fonts::pingus_large, (float)(Display::get_width() / 2),
- (float)(Display::get_height() / 2), "Not yet functional");
-
+ gc.print_left(Fonts::courier_small,
+ int(gc.get_width()/2 - size.width/2 + 12),
+ int(gc.get_height()/2) - size.height/2 + 36,
+ "F1 - display this help\n"
+ "F2 - toggle background color\n"
+ "F4 - play the level\n"
+ "F5 - load a level\n"
+ "F6 - save this level\n"
+ "F8 - backup save\n"
+ "F9 - change level width/height\n"
+ );
+
+ gc.print_left(Fonts::courier_small,
+ int(gc.get_width()/2 + 12),
+ int(gc.get_height()/2) - size.height/2 + 36,
+ "F1 - display this help\n"
+ "F2 - toggle background color\n"
+ "F4 - play the level\n"
+ "F5 - load a level\n"
+ "F6 - save this level\n"
+ "F8 - backup save\n"
+ "F9 - change level width/height\n"
+ );
+
+ gc.print_left(Fonts::courier_small,
+ int(gc.get_width()/2 - size.width/2 + 12),
+ int(gc.get_height()/2) - 10,
+ "Naming Convention:
<levelname><number>-<creator>.pingus\n\n"
+ "When you have created a level and want to have it
included\n"
+ "in the game mail it to address@hidden"
+ "\n");
+ }
+
if (filedialog)
filedialog->draw(gc);
@@ -193,7 +238,7 @@
{
plf->save_level(path_manager.complete("levels/editortmpfile.pingus"));
PingusLevel level("levels/editortmpfile.pingus",
- "levels/editortmpfile.pingus");
+ Pathname("levels/editortmpfile.pingus",
Pathname::DATA_PATH));
ScreenManager::instance()->push_screen(new PingusGameSession(level, false),
true);
}
@@ -285,9 +330,15 @@
void
EditorScreen::toggle_help()
{
- std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is
unimplemented" << std::endl;
+ show_help = !show_help;
}
+void
+EditorScreen::exit()
+{
+ ScreenManager::instance()->pop_screen();
+}
+
} // namespace Editor
/* EOF */
Modified: trunk/pingus/src/editor/editor_screen.hpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.hpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_screen.hpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -28,6 +28,7 @@
class DrawingContext;
class FileDialog;
class GUI::GUIManager;
+class Pathname;
namespace Editor {
@@ -56,6 +57,8 @@
bool close_dialog;
+ bool show_help;
+
public:
/** Default constructor */
EditorScreen();
@@ -98,7 +101,7 @@
void save(const std::string &file);
/** Load a new level */
- void load(const std::string &file);
+ void load(const Pathname& file);
void load_level(const std::string& file);
@@ -132,6 +135,8 @@
void toggle_help();
+ void exit();
+
private:
EditorScreen (const EditorScreen&);
EditorScreen& operator= (const EditorScreen&);
Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -39,7 +39,7 @@
state(Display::get_width(), Display::get_height()),
scene_context(new SceneContext()),
editor(e),
- autoscroll(true),
+ autoscroll(false),
highlighted_area(0,0,0,0),
context_menu(0),
snap_to(false),
@@ -56,25 +56,45 @@
delete scene_context;
}
+void
+EditorViewport::on_secondary_button_press(int x, int y)
+{
+ if (current_action == NOTHING)
+ {
+ drag_start_pos = mouse_at;
+ current_action = SCROLLING;
+ }
+}
+
+void
+EditorViewport::on_secondary_button_release(int x, int y)
+{
+ if (current_action == SCROLLING)
+ current_action = NOTHING;
+}
+
// When someone right-clicks inside the viewport
void
EditorViewport::on_secondary_button_click(int x, int y)
{
- remove_context_menu();
+ if (0) // old context menu code
+ {
+ remove_context_menu();
- Vector3f mouse_pos(x - (state.get_width()/2 - state.get_pos().x),
- y - (state.get_height()/2 - state.get_pos().y));
+ Vector3f mouse_pos(x - (state.get_width()/2 - state.get_pos().x),
+ y - (state.get_height()/2 - state.get_pos().y));
- std::cout << "Right-click at " << mouse_pos.x << ", "
- << mouse_pos.y << std::endl;
+ std::cout << "Right-click at " << mouse_pos.x << ", "
+ << mouse_pos.y << std::endl;
- // LevelObj* obj = object_at((int)mouse_pos.x, (int)mouse_pos.y);
- if (!selected_objs.empty())
- {
- // std::vector<LevelObj*> objs;
- // objs.push_back(obj);
- context_menu = new ContextMenu(selected_objs, Vector3f((float)x,
(float)y), this);
- editor->get_gui_manager()->add(context_menu, true);
+ // LevelObj* obj = object_at((int)mouse_pos.x, (int)mouse_pos.y);
+ if (!selected_objs.empty())
+ {
+ // std::vector<LevelObj*> objs;
+ // objs.push_back(obj);
+ context_menu = new ContextMenu(selected_objs, Vector3f((float)x,
(float)y), this);
+ editor->get_gui_manager()->add(context_menu, true);
+ }
}
}
@@ -153,41 +173,51 @@
void
EditorViewport::on_pointer_move(int x, int y)
{
- mouse_at = Vector3f(float(x), float(y));
- mouse_at_world = Vector3f(x - (state.get_width()/2 - state.get_pos().x),
+ mouse_at = Vector2f(float(x), float(y));
+ mouse_at_world = Vector2f(x - (state.get_width()/2 - state.get_pos().x),
y - (state.get_height()/2 - state.get_pos().y));
- if (current_action == HIGHLIGHTING)
+ switch(current_action)
{
- highlighted_area.right = x;
- highlighted_area.bottom = y;
- }
- else if (current_action == DRAGGING)
- {
- float new_x, new_y;
+ case HIGHLIGHTING:
+ highlighted_area.right = x;
+ highlighted_area.bottom = y;
+ break;
+
+ case DRAGGING:
+ {
+ float new_x, new_y;
- for (unsigned i = 0; i < selected_objs.size(); i++)
- {
- Vector3f orig_pos(selected_objs[i]->get_orig_pos());
- float x_offset = mouse_at_world.x - drag_start_pos.x;
- float y_offset = mouse_at_world.y - drag_start_pos.y;
- if (snap_to)
+ for (unsigned i = 0; i < selected_objs.size(); i++)
{
- // FIXME: May need to adjust the snap-to offset here.
- new_x = (float)((int)((x_offset + orig_pos.x) / 10) * 10);
- new_y = (float)((int)((y_offset + orig_pos.y) / 10) * 10);
+ Vector3f orig_pos(selected_objs[i]->get_orig_pos());
+ float x_offset = mouse_at_world.x - drag_start_pos.x;
+ float y_offset = mouse_at_world.y - drag_start_pos.y;
+
+ if (snap_to)
+ {
+ // FIXME: May need to adjust the snap-to offset here.
+ new_x = (float)((int)((x_offset + orig_pos.x) / 10) * 10);
+ new_y = (float)((int)((y_offset + orig_pos.y) / 10) * 10);
+ }
+ else
+ {
+ new_x = x_offset + orig_pos.x;
+ new_y = y_offset + orig_pos.y;
+ }
+ selected_objs[i]->set_pos(Vector3f(new_x, new_y, orig_pos.z));
}
- else
- {
- new_x = x_offset + orig_pos.x;
- new_y = y_offset + orig_pos.y;
- }
- selected_objs[i]->set_pos(Vector3f(new_x, new_y, orig_pos.z));
}
+ break;
+
+ case SCROLLING:
+ break;
+
+ case NOTHING:
+ break;
}
}
-
// Draws all of the objects in the viewport and the background (if any)
void
EditorViewport::draw(DrawingContext &gc)
@@ -225,6 +255,9 @@
{
UNUSED_ARG(delta);
+ if (current_action == SCROLLING)
+ state.set_pos(state.get_pos() + (mouse_at - drag_start_pos) * delta *
5.0f);
+
// Autoscroll if necessary
if (autoscroll)
{
Modified: trunk/pingus/src/editor/editor_viewport.hpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.hpp 2007-09-05 03:42:34 UTC (rev
3086)
+++ trunk/pingus/src/editor/editor_viewport.hpp 2007-09-05 16:10:33 UTC (rev
3087)
@@ -53,13 +53,13 @@
bool autoscroll;
/** Where the mouse is right now - used for autoscrolling */
- Vector3f mouse_at;
+ Vector2f mouse_at;
/** Where the mouse is at in relation to the world/level */
- Vector3f mouse_at_world;
+ Vector2f mouse_at_world;
/** Where the mouse started dragging from */
- Vector3f drag_start_pos;
+ Vector2f drag_start_pos;
/** All objects in the level */
std::vector<LevelObj*> objs;
@@ -80,7 +80,7 @@
bool snap_to;
/** What is the currently selected action that the mouse is doing */
- enum ActionType { NOTHING = 0, HIGHLIGHTING = 1, DRAGGING = 2 }
current_action;
+ enum ActionType { NOTHING, HIGHLIGHTING, DRAGGING, SCROLLING }
current_action;
public:
/** Constructor
@@ -121,6 +121,10 @@
/// Mouse actions
void on_primary_button_press(int x, int y);
void on_primary_button_release(int x, int y);
+
+ void on_secondary_button_press(int x, int y);
+ void on_secondary_button_release(int x, int y);
+
void on_secondary_button_click(int x, int y);
void delete_selected_objects();
Modified: trunk/pingus/src/editor/panel.cpp
===================================================================
--- trunk/pingus/src/editor/panel.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/editor/panel.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -191,13 +191,16 @@
add_button("core/editor/object-rotate-right", "Rotate object -90 degree",
&EditorScreen::objects_rotate_right);
add_separator();
- add_button("core/editor/snap-grid", "Snap objects to grid",
- &EditorScreen::toggle_grid_snap);
+ //add_button("core/editor/snap-grid", "Snap objects to grid",
+ // &EditorScreen::toggle_grid_snap);
add_button("core/editor/objects", "Show object insertion window",
&EditorScreen::toggle_object_selector);
add_separator();
add_button("core/editor/help", "Display help",
&EditorScreen::toggle_help);
+ add_separator();
+ add_button("core/editor/exit", "Exit",
+ &EditorScreen::exit);
}
Panel::~Panel()
Modified: trunk/pingus/src/file_reader.cpp
===================================================================
--- trunk/pingus/src/file_reader.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/file_reader.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -20,7 +20,7 @@
#include "sexpr_file_reader.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
-#include "path_manager.hpp"
+#include "pathname.hpp"
#include "file_reader.hpp"
#include "file_reader_impl.hpp"
@@ -178,4 +178,18 @@
}
}
+FileReader
+FileReader::parse(const Pathname& pathname)
+{
+ boost::shared_ptr<lisp::Lisp> sexpr =
lisp::Parser::parse(pathname.get_sys_path());
+ if (sexpr)
+ {
+ return SExprFileReader(sexpr->get_list_elem(0));
+ }
+ else
+ {
+ return FileReader();
+ }
+}
+
/* EOF */
Modified: trunk/pingus/src/file_reader.hpp
===================================================================
--- trunk/pingus/src/file_reader.hpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/file_reader.hpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -31,6 +31,7 @@
class ResDescriptor;
class FileReaderImpl;
+class Pathname;
/** Interface to read name/value pairs out of some kind of file or
structure */
@@ -74,6 +75,7 @@
int get_num_sections() const;
static FileReader parse(const std::string& filename);
+ static FileReader parse(const Pathname& pathname);
private:
boost::shared_ptr<FileReaderImpl> impl;
};
Modified: trunk/pingus/src/pingus_level.cpp
===================================================================
--- trunk/pingus/src/pingus_level.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/pingus_level.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -23,7 +23,7 @@
#include "pingus_error.hpp"
#include "pingus_level_impl.hpp"
#include "globals.hpp"
-#include "path_manager.hpp"
+#include "pathname.hpp"
#include "debug.hpp"
PingusLevel::PingusLevel()
@@ -31,16 +31,29 @@
{
}
+PingusLevel::PingusLevel(const Pathname& pathname)
+ : impl(new PingusLevelImpl())
+{
+ load("", pathname);
+}
+
PingusLevel::PingusLevel(const std::string& resname,
- const std::string& filename)
+ const Pathname& pathname)
: impl(new PingusLevelImpl())
{
+ load(resname, pathname);
+}
+
+void
+PingusLevel::load(const std::string& resname,
+ const Pathname& pathname)
+{
impl->resname = resname;
- FileReader reader = FileReader::parse(path_manager.complete(filename));
+ FileReader reader = FileReader::parse(pathname);
if (reader.get_name() != "pingus-level")
{
- PingusError::raise("Error: " + filename + ": not a 'pingus-level' file");
+ PingusError::raise("Error: " + pathname.str() + ": not a 'pingus-level'
file");
}
else
{
@@ -53,7 +66,7 @@
FileReader head;
if (!reader.read_section("head", head))
{
- PingusError::raise("Error: (head) section not found in '" + filename
+ "'");
+ PingusError::raise("Error: (head) section not found in '" +
pathname.str() + "'");
}
else
{
@@ -85,7 +98,7 @@
}
else
{
- PingusError::raise("Error: (pingus-level head actions) not found
in '" + filename + "'");
+ PingusError::raise("Error: (pingus-level head actions) not found
in '" + pathname.str() + "'");
}
}
Modified: trunk/pingus/src/pingus_level.hpp
===================================================================
--- trunk/pingus/src/pingus_level.hpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/pingus_level.hpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -26,7 +26,7 @@
#include <boost/shared_ptr.hpp>
#include "file_reader.hpp"
-
+class Pathname;
class FileReader;
class PingusLevelImpl;
@@ -37,8 +37,10 @@
public:
PingusLevel();
+ PingusLevel(const Pathname& pathname);
+
PingusLevel(const std::string& resname,
- const std::string& filename);
+ const Pathname& pathname);
/** Returns the name of the current level, {\em not} the level file name. */
const std::string& get_levelname() const;
@@ -82,6 +84,10 @@
/** Return the 'resource name' of the level ('snow22-grumbel', etc. ) */
const std::string get_resname() const;
+private:
+ void load(const std::string& resname,
+ const Pathname& pathname);
+
protected:
boost::shared_ptr<PingusLevelImpl> impl;
};
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/pingus_main.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -551,9 +551,9 @@
case CommandLine::REST_ARG:
if (levelfile.empty())
{
- levelfile = argp.get_argument();
+ levelfile = Pathname(argp.get_argument(), Pathname::SYSTEM_PATH);
- if (!System::exist(levelfile))
+ if (!levelfile.exist())
{
std::cout << "PingusMain: " << levelfile << " not found" <<
std::endl;
exit (EXIT_FAILURE);
Modified: trunk/pingus/src/pingus_main.hpp
===================================================================
--- trunk/pingus/src/pingus_main.hpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/pingus_main.hpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -23,6 +23,7 @@
#include <string>
#include "pingus.hpp"
#include "SDL.h"
+#include "pathname.hpp"
void segfault_handler(int);
@@ -37,7 +38,7 @@
/// the name of the exe: argv[0]
std::string executable_name;
- std::string levelfile;
+ Pathname levelfile;
std::string fontfile;
/** Filename to which the level preview should be saved */
Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/pingus_menu.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -34,6 +34,7 @@
#include "gui/gui_manager.hpp"
#include "plf_res_mgr.hpp"
#include "path_manager.hpp"
+#include "pathname.hpp"
#include "file_dialog.hpp"
#include "editor/editor_screen.hpp"
#include "credits.hpp"
@@ -199,8 +200,7 @@
{ // Launch the specified level - don't bother checking for it, it has to exist
Sound::PingusSound::play_sound ("letsgo");
ScreenManager::instance()->push_screen
- (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
- true);
+ (new StartScreen(PLFResMgr::load_plf_from_filename(Pathname(levelfile,
Pathname::SYSTEM_PATH))), true);
}
void PingusMenu::do_edit()
Modified: trunk/pingus/src/plf_res_mgr.cpp
===================================================================
--- trunk/pingus/src/plf_res_mgr.cpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/plf_res_mgr.cpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -20,29 +20,29 @@
#include "globals.hpp"
#include "debug.hpp"
#include "system.hpp"
-#include "path_manager.hpp"
+#include "pathname.hpp"
#include "plf_res_mgr.hpp"
-
PLFResMgr::PLFMap PLFResMgr::plf_map;
PingusLevel
PLFResMgr::load_plf_raw(const std::string& res_name,
- const std::string& filename)
+ const Pathname& pathname)
{
- pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: '" << res_name << "' -> '" <<
filename << "'" << std::endl;
+ pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: '" << res_name << "' -> '" <<
pathname.str() << "'" << std::endl;
PLFMap::iterator i = plf_map.find(res_name);
if (i == plf_map.end())
{ // Entry not cached, so load it and add it to cache
- pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from DISK: '" <<
res_name << "' -> '" << filename << "'" << std::endl;
+ pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from DISK: '" <<
res_name << "' -> '"
+ << pathname.str() << "'" << std::endl;
- PingusLevel plf(res_name, filename);
+ PingusLevel plf(res_name, pathname);
PLFEntry entry;
entry.plf = plf;
- entry.mtime = System::get_mtime(filename);
+ entry.mtime = pathname.mtime();
plf_map[res_name] = entry;
@@ -53,17 +53,18 @@
}
else
{
- uint64_t current_mtime = System::get_mtime(filename);
+ uint64_t current_mtime = pathname.mtime();
if (current_mtime != i->second.mtime)
{
- pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: level changed on DISK,
reloading: '" << res_name << "' -> '" << filename << "'" << std::endl;
+ pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: level changed on DISK,
reloading: '" << res_name
+ << "' -> '" << pathname.str() << "'" <<
std::endl;
// Reload the file since it has changed on disk
- PingusLevel plf(res_name, filename);
+ PingusLevel plf(res_name, pathname);
PLFEntry entry;
entry.plf = plf;
- entry.mtime = System::get_mtime(filename);
+ entry.mtime = pathname.mtime();
plf_map[res_name] = entry;
@@ -73,7 +74,8 @@
}
else
{ // File in cache is up to date, everything is all ready, return it
- pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from CACHE:
'" << res_name << "' -> '" << filename << "'" << std::endl;
+ pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from CACHE:
'" << res_name << "' -> '"
+ << pathname.str() << "'" << std::endl;
return i->second.plf;
}
@@ -81,21 +83,22 @@
}
PingusLevel
-PLFResMgr::load_plf_from_filename(const std::string& filename)
+PLFResMgr::load_plf_from_filename(const Pathname& pathname)
{
- std::string res_name = System::basename(filename);
+ // FIXME: Ugly resname guessing is ugly
+ std::string res_name = System::basename(pathname.get_sys_path());
// This should give us the tutorial/, wip/, etc. part of the res_name
- std::string dirname = System::basename(System::dirname(filename));
+ std::string dirname =
System::basename(System::dirname(pathname.get_sys_path()));
return load_plf_raw(dirname + "/" + res_name.substr(0, res_name.length()-4),
- filename);
+ pathname);
}
PingusLevel
PLFResMgr::load_plf(const std::string& res_name)
{
- return load_plf_raw(res_name, "levels/" + res_name + ".pingus");
+ return load_plf_raw(res_name, Pathname("levels/" + res_name + ".pingus",
Pathname::DATA_PATH));
}
Modified: trunk/pingus/src/plf_res_mgr.hpp
===================================================================
--- trunk/pingus/src/plf_res_mgr.hpp 2007-09-05 03:42:34 UTC (rev 3086)
+++ trunk/pingus/src/plf_res_mgr.hpp 2007-09-05 16:10:33 UTC (rev 3087)
@@ -23,6 +23,7 @@
#include "pingus_level.hpp"
#include "SDL.h"
+class Pathname;
/** */
class PLFResMgr
@@ -38,7 +39,7 @@
/** Loads PLF from filename and stores it under 'res_name' in the
map */
static PingusLevel load_plf_raw(const std::string& res_name,
- const std::string& filename);
+ const Pathname& pathname);
public:
/** @returns a handle to the PLF, which the caller *must not* delete
@@ -50,7 +51,7 @@
res_name, load it from a system dependend filename
@param filename The filename of the plf, aka
"../data/levels/snow11-grumbel.pingus" */
- static PingusLevel load_plf_from_filename(const std::string& filename);
+ static PingusLevel load_plf_from_filename(const Pathname& filename);
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3087 - in trunk/pingus: . src src/editor,
grumbel at BerliOS <=