[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3090 - in trunk/pingus/src: . editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3090 - in trunk/pingus/src: . editor |
Date: |
Wed, 5 Sep 2007 21:08:48 +0200 |
Author: grumbel
Date: 2007-09-05 21:08:47 +0200 (Wed, 05 Sep 2007)
New Revision: 3090
Modified:
trunk/pingus/src/client.cpp
trunk/pingus/src/editor/editor_viewport.cpp
trunk/pingus/src/file_reader.cpp
trunk/pingus/src/file_reader.hpp
trunk/pingus/src/font.cpp
trunk/pingus/src/font_description.cpp
trunk/pingus/src/font_description.hpp
trunk/pingus/src/font_test_screen.cpp
trunk/pingus/src/font_test_screen.hpp
trunk/pingus/src/path_manager.cpp
trunk/pingus/src/path_manager.hpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_main.hpp
trunk/pingus/src/pixel_buffer.cpp
trunk/pingus/src/pixel_buffer.hpp
trunk/pingus/src/resource.cpp
trunk/pingus/src/sprite.cpp
trunk/pingus/src/sprite.hpp
trunk/pingus/src/sprite_description.hpp
Log:
- some more integration of Pathname class
Modified: trunk/pingus/src/client.cpp
===================================================================
--- trunk/pingus/src/client.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/client.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -27,7 +27,6 @@
#include "components/pingus_counter.hpp"
#include "components/smallmap.hpp"
#include "components/hurry_up.hpp"
-#include "path_manager.hpp"
#include "gui/cursor.hpp"
#include "true_server.hpp"
#include "components/button_panel.hpp"
Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -234,7 +234,7 @@
if (current_action == HIGHLIGHTING)
gc.draw_rect((float)highlighted_area.left, (float)highlighted_area.top,
(float)highlighted_area.right,
(float)highlighted_area.bottom,
- Color(255,255,255,150));
+ Color(255,0,255));
state.pop(*scene_context);
gc.draw(new SceneContextDrawingRequest(scene_context, Vector3f(0, 0, -150)));
Modified: trunk/pingus/src/file_reader.cpp
===================================================================
--- trunk/pingus/src/file_reader.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/file_reader.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -79,6 +79,26 @@
}
bool
+FileReader::read_path(const char* name, Pathname& value) const
+{
+ if (impl.get())
+ {
+ std::string filename;
+ if (impl->read_string(name, filename))
+ {
+ value = Pathname(filename, Pathname::DATA_PATH);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ return false;
+}
+
+bool
FileReader::read_vector(const char* name, Vector3f& value) const
{
if (impl.get())
Modified: trunk/pingus/src/file_reader.hpp
===================================================================
--- trunk/pingus/src/file_reader.hpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/file_reader.hpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -49,6 +49,7 @@
bool read_float (const char* name, float&) const;
bool read_bool (const char* name, bool&) const;
bool read_string(const char* name, std::string&) const;
+ bool read_path (const char* name, Pathname&) const;
bool read_vector(const char* name, Vector3f&) const;
bool read_vector2i(const char* name, Vector2i&) const;
bool read_size (const char* name, Size&) const;
Modified: trunk/pingus/src/font.cpp
===================================================================
--- trunk/pingus/src/font.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/font.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -24,7 +24,6 @@
#include "font.hpp"
#include "line_iterator.hpp"
#include "font_description.hpp"
-#include "path_manager.hpp"
#include "gui/display.hpp"
static bool vline_empty(SDL_Surface* surface, int x, Uint8 threshold)
@@ -66,10 +65,10 @@
for(int i = 0; i < 256; ++i)
chrs[i].x = chrs[i].y = chrs[i].w = chrs[i].h = 0;
- surface = IMG_Load(path_manager.complete(desc.image).c_str());
+ surface = IMG_Load(desc.image.get_sys_path().c_str());
if (!surface)
{
- std::cout << "IMG: " << path_manager.complete(desc.image) << std::endl;
+ std::cout << "IMG: " << desc.image.str() << std::endl;
assert(surface);
}
@@ -77,7 +76,7 @@
if (surface->format->BitsPerPixel != 32)
{
- std::cout << "Error: '" << desc.filename << "' invalid, fonts need to
be RGBA, but is "
+ std::cout << "Error: '" << desc.pathname.str() << "' invalid, fonts
need to be RGBA, but is "
<< surface->format->BitsPerPixel << "bpp" << std::endl;
assert(0);
}
Modified: trunk/pingus/src/font_description.cpp
===================================================================
--- trunk/pingus/src/font_description.cpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/font_description.cpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -19,11 +19,10 @@
#include "pingus_error.hpp"
#include "file_reader.hpp"
-#include "path_manager.hpp"
#include "font_description.hpp"
-FontDescription::FontDescription(const std::string& filename_)
- : filename(filename_)
+FontDescription::FontDescription(const Pathname& pathname_)
+ : pathname(pathname_)
{
name = "<unknown>";
monospace = false;
@@ -32,7 +31,7 @@
char_spacing = 1.0f;
vertical_spacing = -1.0f;
- FileReader reader = FileReader::parse(path_manager.complete(filename));
+ FileReader reader = FileReader::parse(pathname);
if (reader.get_name() != "pingus-font")
{
@@ -41,7 +40,7 @@
else
{
reader.read_string("name", name);
- reader.read_string("image", image);
+ reader.read_path("image", image);
reader.read_string("characters", characters);
reader.read_bool("monospace", monospace);
reader.read_float("char-spacing", char_spacing);
Modified: trunk/pingus/src/font_description.hpp
===================================================================
--- trunk/pingus/src/font_description.hpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/font_description.hpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -21,16 +21,17 @@
#define HEADER_FONT_DESCRIPTION_HPP
#include <string>
+#include "pathname.hpp"
/** */
class FontDescription
{
public:
- std::string filename;
+ Pathname pathname;
std::string name;
/** Image file from which the basic surface is loaded */
- std::string image;
+ Pathname image;
bool monospace;
@@ -48,7 +49,7 @@
/** Characters in the font image */
std::string characters;
- FontDescription(const std::string& filename);
+ FontDescription(const Pathname& filename);
};
#endif
Modified: trunk/pingus/src/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/font_test_screen.cpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/font_test_screen.cpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -23,13 +23,13 @@
#include "font_description.hpp"
#include "font_test_screen.hpp"
-FontTestScreen::FontTestScreen(const std::string& fontfile)
+FontTestScreen::FontTestScreen(const Pathname& fontfile)
: scrollx(0),
scrolly(0)
{
std::cout << "### Loading font file: " << fontfile << std::endl;
font = Font(FontDescription(fontfile));
- reference = Font(FontDescription("images/fonts/reference-iso-8859-1.font"));
+ reference =
Font(FontDescription(Pathname("images/fonts/reference-iso-8859-1.font",
Pathname::DATA_PATH)));
}
bool
Modified: trunk/pingus/src/font_test_screen.hpp
===================================================================
--- trunk/pingus/src/font_test_screen.hpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/font_test_screen.hpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -33,7 +33,7 @@
float scrolly;
public:
- FontTestScreen(const std::string& fontfile);
+ FontTestScreen(const Pathname& fontfile);
bool draw(DrawingContext& gc);
void update (const GameDelta& delta);
Modified: trunk/pingus/src/path_manager.cpp
===================================================================
--- trunk/pingus/src/path_manager.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/path_manager.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -19,10 +19,9 @@
#include "globals.hpp"
#include "system.hpp"
-#include "path_manager.hpp"
#include "debug.hpp"
+#include "path_manager.hpp"
-
PathManager path_manager;
PathManager::PathManager ()
Modified: trunk/pingus/src/path_manager.hpp
===================================================================
--- trunk/pingus/src/path_manager.hpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/path_manager.hpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -21,6 +21,7 @@
#define HEADER_PINGUS_PATH_MANAGER_HXX
#include "pingus.hpp"
+#include "path_manager.hpp"
#include <string>
#include <list>
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/pingus_main.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -523,7 +523,7 @@
break;
case 363: // font test
- fontfile = argp.get_argument();
+ fontfile = Pathname(argp.get_argument(), Pathname::SYSTEM_PATH);
break;
case 364: // language
Modified: trunk/pingus/src/pingus_main.hpp
===================================================================
--- trunk/pingus/src/pingus_main.hpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/pingus_main.hpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -39,7 +39,7 @@
/// the name of the exe: argv[0]
std::string executable_name;
Pathname levelfile;
- std::string fontfile;
+ Pathname fontfile;
/** Filename to which the level preview should be saved */
std::string preview_file;
Modified: trunk/pingus/src/pixel_buffer.cpp
===================================================================
--- trunk/pingus/src/pixel_buffer.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/pixel_buffer.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -20,7 +20,6 @@
#include "SDL_image.h"
#include <sstream>
#include <iostream>
-#include "path_manager.hpp"
#include "pixel_buffer.hpp"
class PixelBufferImpl
@@ -37,12 +36,12 @@
{
}
-PixelBuffer::PixelBuffer(const std::string& name_)
+PixelBuffer::PixelBuffer(const Pathname& pathname)
: impl(new PixelBufferImpl())
{
- impl->surface = IMG_Load(path_manager.complete(name_).c_str());
+ impl->surface = IMG_Load(pathname.get_sys_path().c_str());
if (!impl->surface)
- std::cout << "XXXXXX Failed to load: " << name_ << std::endl;
+ std::cout << "XXXXXX Failed to load: " << pathname.str() << std::endl;
///else
//std::cout << "Loaded pixelbuffer: " << name << ": " << surface->w << "x"
<< surface->h << std::endl;
Modified: trunk/pingus/src/pixel_buffer.hpp
===================================================================
--- trunk/pingus/src/pixel_buffer.hpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/pixel_buffer.hpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -23,8 +23,10 @@
#include "SDL.h"
#include <string>
#include <boost/shared_ptr.hpp>
+#include "pathname.hpp"
#include "math/color.hpp"
+class Pathname;
class PixelBufferImpl;
/** */
@@ -32,7 +34,7 @@
{
public:
PixelBuffer();
- PixelBuffer(const std::string& name);
+ PixelBuffer(const Pathname& name);
/** Create an empty RGBA PixelBuffer */
PixelBuffer(int width, int height);
Modified: trunk/pingus/src/resource.cpp
===================================================================
--- trunk/pingus/src/resource.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/resource.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -307,7 +307,7 @@
Font
Resource::load_font(const std::string& res_name)
{
- FontDescription desc("images/" + res_name + ".font");
+ FontDescription desc(Pathname("images/" + res_name + ".font",
Pathname::DATA_PATH));
//("data/images/fonts/chalk_large-iso-8859-1.font");
return Font(desc);
}
Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/sprite.cpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -27,7 +27,7 @@
#include "sprite.hpp"
#include "blitter.hpp"
#include "pixel_buffer.hpp"
-#include "path_manager.hpp"
+#include "pathname.hpp"
#include "sprite_description.hpp"
class SpriteImpl
@@ -66,11 +66,11 @@
frame(0),
tick_count(0)
{
- surface = IMG_Load(path_manager.complete(desc.filename).c_str());
+ surface = IMG_Load(desc.filename.get_sys_path().c_str());
if (!surface)
{
std::cout << "Error: Couldn't load " << desc.filename << std::endl;
- surface =
IMG_Load(path_manager.complete("images/core/misc/404.png").c_str());
+ surface = IMG_Load(Pathname("images/core/misc/404.png",
Pathname::DATA_PATH).str().c_str());
assert(surface);
}
@@ -207,7 +207,7 @@
}
-Sprite::Sprite(const std::string& name)
+Sprite::Sprite(const Pathname& name)
{
SpriteDescription desc;
desc.filename = name;
Modified: trunk/pingus/src/sprite.hpp
===================================================================
--- trunk/pingus/src/sprite.hpp 2007-09-05 19:08:21 UTC (rev 3089)
+++ trunk/pingus/src/sprite.hpp 2007-09-05 19:08:47 UTC (rev 3090)
@@ -26,6 +26,7 @@
class Color;
class PixelBuffer;
+class Pathname;
class SpriteImpl;
class SpriteDescription;
@@ -34,7 +35,7 @@
{
public:
Sprite();
- Sprite(const std::string& name);
+ Sprite(const Pathname& name);
Sprite(const SpriteDescription& desc);
Sprite(const PixelBuffer& pixelbuffer);
~Sprite();
Modified: trunk/pingus/src/sprite_description.hpp
===================================================================
--- trunk/pingus/src/sprite_description.hpp 2007-09-05 19:08:21 UTC (rev
3089)
+++ trunk/pingus/src/sprite_description.hpp 2007-09-05 19:08:47 UTC (rev
3090)
@@ -24,12 +24,13 @@
#include "math/size.hpp"
#include "math/origin.hpp"
#include "file_reader.hpp"
+#include "pathname.hpp"
/** */
class SpriteDescription
{
public:
- std::string filename;
+ Pathname filename;
Vector2i offset;
Origin origin;
@@ -60,8 +61,8 @@
reader.read_enum("origin", origin, string2origin);
- reader.read_string("image-file", filename);
- filename = "data/" + filename; // FIXME: Hack
+ reader.read_path("image-file", filename);
+ filename = Pathname("data/" + filename.get_raw_path(),
filename.get_type()); // FIXME: Hack
reader.read_size("image-array", array);
reader.read_vector2i("image-pos", frame_pos);
reader.read_size("image-size", frame_size);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3090 - in trunk/pingus/src: . editor,
grumbel at BerliOS <=