[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2655 - in branches/pingus_sdl/src: . display gui math worl
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2655 - in branches/pingus_sdl/src: . display gui math worldmap |
Date: |
Mon, 15 Jan 2007 14:49:05 +0100 |
Author: grumbel
Date: 2007-01-15 14:49:02 +0100 (Mon, 15 Jan 2007)
New Revision: 2655
Added:
branches/pingus_sdl/src/math/origin.cpp
branches/pingus_sdl/src/math/origin.hpp
Removed:
branches/pingus_sdl/src/math/origin.cpp
branches/pingus_sdl/src/math/origin.hpp
branches/pingus_sdl/src/origin.cpp
branches/pingus_sdl/src/origin.hpp
Modified:
branches/pingus_sdl/src/SConscript
branches/pingus_sdl/src/display/drawing_context.cxx
branches/pingus_sdl/src/display/drawing_context.hxx
branches/pingus_sdl/src/display/scene_context.cxx
branches/pingus_sdl/src/display/scene_context.hxx
branches/pingus_sdl/src/file_dialog_item.cxx
branches/pingus_sdl/src/font.cpp
branches/pingus_sdl/src/font.hpp
branches/pingus_sdl/src/graphic_context_state.cxx
branches/pingus_sdl/src/graphic_context_state.hxx
branches/pingus_sdl/src/gui/surface_button.hxx
branches/pingus_sdl/src/math/color.hpp
branches/pingus_sdl/src/math/rect.cpp
branches/pingus_sdl/src/math/rect.hpp
branches/pingus_sdl/src/math/vector3f.cpp
branches/pingus_sdl/src/math/vector3f.hpp
branches/pingus_sdl/src/pingus_level.cxx
branches/pingus_sdl/src/pingus_level_impl.hxx
branches/pingus_sdl/src/plt_xml.cxx
branches/pingus_sdl/src/savegame.cxx
branches/pingus_sdl/src/savegame_manager.cxx
branches/pingus_sdl/src/sprite.cpp
branches/pingus_sdl/src/sprite.hpp
branches/pingus_sdl/src/stat_manager.cxx
branches/pingus_sdl/src/state_sprite.cxx
branches/pingus_sdl/src/state_sprite.hxx
branches/pingus_sdl/src/string_format.cxx
branches/pingus_sdl/src/string_format.hxx
branches/pingus_sdl/src/worldmap/dot.hxx
branches/pingus_sdl/src/worldmap/drawable.hxx
branches/pingus_sdl/src/worldmap/level_dot.cxx
branches/pingus_sdl/src/worldmap/level_dot.hxx
branches/pingus_sdl/src/worldmap/manager.cxx
branches/pingus_sdl/src/worldmap/manager.hxx
branches/pingus_sdl/src/worldmap/metamap.cxx
branches/pingus_sdl/src/worldmap/metamap.hxx
branches/pingus_sdl/src/worldmap/path.cxx
branches/pingus_sdl/src/worldmap/path.hxx
branches/pingus_sdl/src/worldmap/path_drawable.cxx
branches/pingus_sdl/src/worldmap/path_graph.cxx
branches/pingus_sdl/src/worldmap/path_graph.hxx
branches/pingus_sdl/src/worldmap/pingus.cxx
branches/pingus_sdl/src/worldmap/pingus.hxx
branches/pingus_sdl/src/worldmap/sprite_drawable.hxx
branches/pingus_sdl/src/worldmap/surface_drawable.cxx
branches/pingus_sdl/src/worldmap/surface_drawable.hxx
branches/pingus_sdl/src/worldmap/world_dot.cxx
branches/pingus_sdl/src/worldmap/world_dot.hxx
branches/pingus_sdl/src/worldmap/worldmap.cxx
branches/pingus_sdl/src/worldmap/worldmap.hxx
branches/pingus_sdl/src/worldmap/worldmap_story.cxx
branches/pingus_sdl/src/xml_file_reader.cxx
branches/pingus_sdl/src/xml_file_reader.hxx
branches/pingus_sdl/src/xml_file_writer.cxx
branches/pingus_sdl/src/xml_file_writer.hxx
branches/pingus_sdl/src/xml_pdf.cxx
branches/pingus_sdl/src/xml_pingus_level.cxx
Log:
- made worldmap compilable
Modified: branches/pingus_sdl/src/SConscript
===================================================================
--- branches/pingus_sdl/src/SConscript 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/SConscript 2007-01-15 13:49:02 UTC (rev 2655)
@@ -118,7 +118,7 @@
# 'demo_session.cxx',
# 'direction.cxx',
'display/drawing_context.cxx',
-# 'display/scene_context.cxx',
+'display/scene_context.cxx',
# # 'editor/context_menu.cxx',
# # 'editor/editor_panel.cxx',
@@ -149,7 +149,7 @@
# 'global_event.cxx',
'globals.cxx',
# 'goal_manager.cxx',
-# 'graphic_context_state.cxx',
+'graphic_context_state.cxx',
# 'groundtype.cxx',
# 'gui/checkbox.cxx',
# 'gui/combobox.cxx',
@@ -217,7 +217,7 @@
# 'pingu_enums.cxx',
# 'pingu_holder.cxx',
'pingus_error.cxx',
-# 'pingus_level.cxx',
+'pingus_level.cxx',
'pingus_main.cxx',
# 'pingus_map_manager.cxx',
'pingus_menu.cxx',
@@ -233,8 +233,8 @@
'resource_modifier.cxx',
# 'result.cxx',
# 'result_screen.cxx',
-# 'savegame.cxx',
-# 'savegame_manager.cxx',
+'savegame.cxx',
+'savegame_manager.cxx',
# 'screenshot.cxx',
# 'server.cxx',
# 'server_event.cxx',
@@ -245,11 +245,12 @@
'sound/sound_res_mgr.cxx',
# 'ground_map.cxx',
# 'start_screen.cxx',
-# 'stat_manager.cxx',
-# 'state_sprite.cxx',
+'stat_manager.cxx',
+'state_sprite.cxx',
# 'story_screen.cxx',
-# 'string_format.cxx',
-'origin.cpp',
+'string_format.cxx',
+'math/origin.cpp',
+'math/rect.cpp',
'system.cxx',
# 'timer.cxx',
'tinygettext/tinygettext.cxx',
@@ -260,23 +261,24 @@
'physfs/physfs_sdl.cpp',
'physfs/physfs_stream.cpp',
# 'world.cxx',
-# 'worldmap/dot.cxx',
-# 'worldmap/dot_factory.cxx',
-# 'worldmap/drawable.cxx',
-# 'worldmap/drawable_factory.cxx',
-# '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',
+
+'worldmap/dot.cxx',
+'worldmap/dot_factory.cxx',
+'worldmap/drawable.cxx',
+'worldmap/drawable_factory.cxx',
+'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',
# 'worldobj_factory.cxx',
# 'worldobjs/conveyor_belt.cxx',
@@ -302,7 +304,8 @@
# 'worldobjs/switch_door.cxx',
# 'worldobjs/teleporter.cxx',
# 'worldobjs/thunderstorm_background.cxx',
-# 'worldobjs/woodthing.cxx',
+# 'worldobjs/woodthing.cxx',
+
# 'xml_file_reader.cxx',
# 'xml_file_writer.cxx',
# 'xml_pdf.cxx',
Modified: branches/pingus_sdl/src/display/drawing_context.cxx
===================================================================
--- branches/pingus_sdl/src/display/drawing_context.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/display/drawing_context.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -24,7 +24,7 @@
#include "gui/display.hxx"
#include "../sprite.hpp"
#include "../font.hpp"
-#include "../origin.hpp"
+#include "../math/origin.hpp"
struct DrawingRequestsSorter
@@ -276,15 +276,15 @@
{
draw(new TextDrawingRequest(text, Vector3f(x, y, z)));
}
+#endif
void
DrawingContext::draw_line (float x1, float y1, float x2, float y2,
- const CL_Color& color, float z)
+ const Color& color, float z)
{
- draw(new LineDrawingRequest(Vector(x1, y1), Vector(x2, y2), color, z));
+ //// draw(new LineDrawingRequest(Vector(x1, y1), Vector(x2, y2), color, z));
}
-#endif
void
DrawingContext::draw_fillrect (float x1, float y1, float x2, float y2,
const Color& color, float z)
@@ -335,6 +335,7 @@
{
draw(new FillScreenDrawingRequest(color));
}
+#endif
void
DrawingContext::rotate(float angel)
@@ -372,17 +373,16 @@
DrawingContext::reset_modelview()
{
translate_stack.clear();
- translate_stack.push_back(Vector(0, 0));
+ translate_stack.push_back(Vector3f(0, 0));
}
-CL_Rect
-DrawingContext::get_clip_rect()
+Rect
+DrawingContext::get_clip_rect() const
{
- return CL_Rect(CL_Point(static_cast<int>(-translate_stack.back().x),
+ return Rect(Vector2i(static_cast<int>(-translate_stack.back().x),
static_cast<int>(-translate_stack.back().y)),
- CL_Size((int)get_width(), (int)get_height()));
+ Size((int)get_width(), (int)get_height()));
}
-#endif
float
DrawingContext::get_width() const
{
Modified: branches/pingus_sdl/src/display/drawing_context.hxx
===================================================================
--- branches/pingus_sdl/src/display/drawing_context.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/display/drawing_context.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -26,6 +26,7 @@
#include <vector>
#include "drawing_request.hxx"
#include "../math/vector3f.hpp"
+#include "../math/rect.hpp"
#include "../math/color.hpp"
class Font;
@@ -111,7 +112,7 @@
void reset_modelview();
/** Return the area of the screen that will be visible*/
- ////CL_Rect get_clip_rect();
+ Rect get_clip_rect() const;
float get_width() const;
float get_height() const;
Modified: branches/pingus_sdl/src/display/scene_context.cxx
===================================================================
--- branches/pingus_sdl/src/display/scene_context.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/display/scene_context.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -17,8 +17,7 @@
// 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/display.h>
-#include <ClanLib/gl.h>
+#include "gui/display.hxx"
#include "scene_context.hxx"
#define SCALE_FACTOR 8.0f
@@ -31,17 +30,8 @@
DrawingContext light;
DrawingContext highlight;
- CL_OpenGLSurface lightmap;
- //CL_Canvas canvas;
-
SceneContextImpl()
- :
lightmap(CL_PixelBuffer(static_cast<int>(CL_Display::get_width()/SCALE_FACTOR),
-
static_cast<int>(CL_Display::get_height()/SCALE_FACTOR),
-
static_cast<int>(CL_Display::get_width()/SCALE_FACTOR*4),
- CL_PixelFormat::rgba8888))
- //canvas(lightmap)
{
- //canvas.get_gc()->set_scale(1/SCALE_FACTOR, 1/SCALE_FACTOR);
}
};
@@ -126,11 +116,11 @@
}
void
-SceneContext::render(CL_GraphicContext* gc)
+SceneContext::render(SDL_Surface* target)
{
// Render all buffers
// FIXME: Render all to pbuffer for later combining of them
- impl->color.render(gc);
+ impl->color.render(target);
#if 0
{ // lightmap support
@@ -146,7 +136,7 @@
}
#endif
- impl->highlight.render(gc);
+ impl->highlight.render(target);
}
void
@@ -157,7 +147,7 @@
impl->highlight.clear();
}
-SceneContextDrawingRequest::SceneContextDrawingRequest(SceneContext* sc_,
const CL_Vector& pos_)
+SceneContextDrawingRequest::SceneContextDrawingRequest(SceneContext* sc_,
const Vector3f& pos_)
: DrawingRequest(pos_),
sc(sc_)
{
@@ -169,7 +159,7 @@
}
void
-SceneContextDrawingRequest::draw(CL_GraphicContext* gc)
+SceneContextDrawingRequest::draw(SDL_Surface* gc)
{
sc->render(gc);
}
Modified: branches/pingus_sdl/src/display/scene_context.hxx
===================================================================
--- branches/pingus_sdl/src/display/scene_context.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/display/scene_context.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,11 +20,9 @@
#ifndef HEADER_SCENE_CONTEXT_HXX
#define HEADER_SCENE_CONTEXT_HXX
+#include "SDL.h"
#include "drawing_context.hxx"
-class CL_GraphicContext;
-
-
class SceneContextImpl;
/** The SceneContext maintains all the different drawing layers to
@@ -72,7 +70,7 @@
/** Takes all the buffers and combines them to form the final image
that will be shown on the screen */
- void render(CL_GraphicContext* gc);
+ void render(SDL_Surface* gc);
void clear();
private:
@@ -85,12 +83,12 @@
class SceneContextDrawingRequest : public DrawingRequest
{
private:
- CL_Color color;
SceneContext* sc;
+
public:
- SceneContextDrawingRequest(SceneContext* sc, const CL_Vector& pos_ =
CL_Vector(0,0,0,0));
+ SceneContextDrawingRequest(SceneContext* sc, const Vector3f& pos_ =
Vector3f(0,0,0));
virtual ~SceneContextDrawingRequest();
- void draw(CL_GraphicContext* gc);
+ void draw(SDL_Surface* gc);
};
Modified: branches/pingus_sdl/src/file_dialog_item.cxx
===================================================================
--- branches/pingus_sdl/src/file_dialog_item.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/file_dialog_item.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -21,12 +21,7 @@
#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"
@@ -39,8 +34,6 @@
#include "worldmap/manager.hxx"
#include "worldmap/metamap.hxx"
-
-
// Only Constructor
FileDialogItem::FileDialogItem(FileDialog* f, Vector p)
: mouse_over(false),
Modified: branches/pingus_sdl/src/font.cpp
===================================================================
--- branches/pingus_sdl/src/font.cpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/font.cpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -25,6 +25,10 @@
#include "font.hpp"
+Rect
+Font::bounding_rect(int, int, const std::string& str) const
+{
+ return Rect();
+}
-
/* EOF */
Modified: branches/pingus_sdl/src/font.hpp
===================================================================
--- branches/pingus_sdl/src/font.hpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/font.hpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -28,7 +28,8 @@
#include <string>
#include "SDL.h"
-#include "origin.hpp"
+#include "math/origin.hpp"
+#include "math/rect.hpp"
/** */
class Font
@@ -39,6 +40,7 @@
void draw(int, int, const std::string& text, SDL_Surface* target) {}
void set_alignment(Origin origin) {}
int get_height() { return 0; }
+ Rect bounding_rect(int , int, const std::string& str) const;
};
#endif
Modified: branches/pingus_sdl/src/graphic_context_state.cxx
===================================================================
--- branches/pingus_sdl/src/graphic_context_state.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/graphic_context_state.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -17,9 +17,8 @@
// 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/Display/display.h>
-#include <ClanLib/Display/display_window.h>
-#include <ClanLib/Display/graphic_context.h>
+#include <math.h>
+#include "gui/display.hxx"
#include "graphic_context_state.hxx"
class GraphicContextStateImpl
@@ -28,20 +27,20 @@
int width;
int height;
- CL_Pointf offset;
+ Vector2f offset;
float zoom;
float rotation;
bool have_limit;
- CL_Rect limit;
+ Rect limit;
};
GraphicContextState::GraphicContextState()
: impl(new GraphicContextStateImpl())
{
- impl->width = CL_Display::get_width();
- impl->height = CL_Display::get_height();
- impl->offset = CL_Pointf(0,0);
+ impl->width = Display::get_width();
+ impl->height = Display::get_height();
+ impl->offset = Vector2f(0,0);
impl->zoom = 1.0f;
impl->rotation = 0;
impl->have_limit = false;
@@ -52,14 +51,14 @@
{
impl->width = w;
impl->height = h;
- impl->offset = CL_Pointf(0,0);
+ impl->offset = Vector2f(0,0);
impl->zoom = 1.0f;
impl->rotation = 0;
impl->have_limit = false;
}
void
-GraphicContextState::set_limit(const CL_Rect& limit)
+GraphicContextState::set_limit(const Rect& limit)
{
impl->have_limit = true;
impl->limit = limit;
@@ -79,7 +78,7 @@
}
void
-GraphicContextState::push(Pingus::DrawingContext& gc)
+GraphicContextState::push(DrawingContext& gc)
{
gc.push_modelview();
@@ -92,7 +91,7 @@
}
void
-GraphicContextState::push(Pingus::SceneContext& gc)
+GraphicContextState::push(SceneContext& gc)
{
gc.push_modelview();
@@ -105,17 +104,18 @@
}
void
-GraphicContextState::pop (Pingus::SceneContext& gc)
+GraphicContextState::pop (SceneContext& gc)
{
gc.pop_modelview();
}
void
-GraphicContextState::pop (Pingus::DrawingContext& gc)
+GraphicContextState::pop (DrawingContext& gc)
{
gc.pop_modelview();
}
+#if 0
void
GraphicContextState::push(CL_GraphicContext* gc)
{
@@ -140,21 +140,22 @@
gc->pop_modelview();
}
+#endif
-CL_Rect
+Rect
GraphicContextState::get_clip_rect()
{
- return CL_Rect(CL_Point(int(-impl->offset.x),
- int(-impl->offset.y)),
- CL_Size(int(get_width() / impl->zoom),
- int(get_height() / impl->zoom)));
+ return Rect(Vector2i(int(-impl->offset.x),
+ int(-impl->offset.y)),
+ Size(int(get_width() / impl->zoom),
+ int(get_height() / impl->zoom)));
}
void
-GraphicContextState::set_pos(const CL_Pointf& pos)
+GraphicContextState::set_pos(const Vector2f& pos)
{
- float old_x = impl->offset.x;
- float old_y = impl->offset.y;
+ float old_x = impl->offset.x;
+ float old_y = impl->offset.y;
impl->offset.x = -pos.x + (get_width()/2 / impl->zoom);
impl->offset.y = -pos.y + (get_height()/2 / impl->zoom);
@@ -181,15 +182,15 @@
}
}
-CL_Pointf
+Vector2f
GraphicContextState::get_pos() const
{
- return CL_Pointf(-impl->offset.x + (get_width()/2 / impl->zoom),
- -impl->offset.y + (get_height()/2 / impl->zoom));
+ return Vector2f(-impl->offset.x + (get_width()/2 / impl->zoom),
+ -impl->offset.y + (get_height()/2 / impl->zoom));
}
void
-GraphicContextState::set_zoom(CL_Pointf pos, float z)
+GraphicContextState::set_zoom(Vector2f pos, float z)
{
float old_zoom = impl->zoom;
set_zoom(z);
@@ -210,7 +211,7 @@
}
void
-GraphicContextState::zoom_to (const CL_Rectf& rect)
+GraphicContextState::zoom_to (const Rectf& rect)
{
float center_x = (rect.left + rect.right) / 2.0f;
float center_y = (rect.top + rect.bottom) / 2.0f;
@@ -234,10 +235,10 @@
impl->offset.y = (get_height() / (2*impl->zoom)) - center_y;
}
-CL_Pointf
-GraphicContextState::screen2world(const CL_Point& pos_)
+Vector2f
+GraphicContextState::screen2world(const Vector2i& pos_)
{
- CL_Pointf pos = pos_;
+ Vector2f pos(pos_.x, pos_.y);
float sa = (float)sin(-impl->rotation/180.0f*M_PI);
float ca = (float)cos(-impl->rotation/180.0f*M_PI);
@@ -247,8 +248,8 @@
pos.x = impl->width/2 + (ca * dx - sa * dy);
pos.y = impl->height/2 + (sa * dx + ca * dy);
- CL_Pointf p((float(pos.x) / impl->zoom) - impl->offset.x,
- (float(pos.y) / impl->zoom) - impl->offset.y);
+ Vector2f p((float(pos.x) / impl->zoom) - impl->offset.x,
+ (float(pos.y) / impl->zoom) - impl->offset.y);
return p;
}
Modified: branches/pingus_sdl/src/graphic_context_state.hxx
===================================================================
--- branches/pingus_sdl/src/graphic_context_state.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/graphic_context_state.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,6 +20,11 @@
#ifndef HEADER_GRAPHIC_CONTEXT_STATE_HXX
#define HEADER_GRAPHIC_CONTEXT_STATE_HXX
+#include "math/rect.hpp"
+#include "math/vector3f.hpp"
+#include "math/vector2i.hpp"
+#include "math/vector2f.hpp"
+#include "shared_ptr.hxx"
#include "display/drawing_context.hxx"
#include "display/scene_context.hxx"
@@ -37,7 +42,7 @@
/** Limit the graphic context to the given limits rectangle, meaning
that no point of the current visible region will be outside the
limit */
- void set_limit(const CL_Rect& limit);
+ void set_limit(const Rect& limit);
void set_unlimited();
void set_size(int w, int h);
@@ -47,15 +52,15 @@
void pop (CL_GraphicContext* gc = 0);
#endif
- void push(Pingus::DrawingContext& gc);
- void pop (Pingus::DrawingContext& gc);
+ void push(DrawingContext& gc);
+ void pop (DrawingContext& gc);
- void push(Pingus::SceneContext& gc);
- void pop (Pingus::SceneContext& gc);
+ void push(SceneContext& gc);
+ void pop (SceneContext& gc);
/** Return a rectangle in world coordinates that represents the area
visible on the screen */
- CL_Rect get_clip_rect();
+ Rect get_clip_rect();
int get_width() const;
int get_height() const;
@@ -67,22 +72,22 @@
float get_rotation();
/** Move the center of the visible area to pos */
- void set_pos(const Vector& pos);
- Vector get_pos() const;
+ void set_pos(const Vector2f& pos);
+ Vector2f get_pos() const;
/** Set zoom to z, while ensuring that the screen position \a pos
(normaly the position of the mouse pointer) stays in the same
position even after zoomed in/out */
- void set_zoom(CL_Pointf pos, float z);
+ void set_zoom(Vector2f pos, float z);
void set_zoom(float z);
float get_zoom();
- void zoom_to (const CL_Rectf& rect);
+ void zoom_to (const Rectf& rect);
- Vector screen2world(const CL_Point& pos);
+ Vector2f screen2world(const Vector2i& pos);
private:
- CL_SharedPtr<GraphicContextStateImpl> impl;
+ SharedPtr<GraphicContextStateImpl> impl;
};
#endif
Modified: branches/pingus_sdl/src/gui/surface_button.hxx
===================================================================
--- branches/pingus_sdl/src/gui/surface_button.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/gui/surface_button.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,9 +20,9 @@
#ifndef HEADER_PINGUS_GUI_SURFACE_BUTTON_HXX
#define HEADER_PINGUS_GUI_SURFACE_BUTTON_HXX
+#include "../sprite.hpp"
#include "component.hxx"
-
class ResDescriptor;
namespace GUI {
Modified: branches/pingus_sdl/src/math/color.hpp
===================================================================
--- branches/pingus_sdl/src/math/color.hpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/color.hpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -37,7 +37,11 @@
uint8_t b;
uint8_t a;
- Color(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_)
+ Color()
+ : r(0), g(0), b(0), a(255)
+ {}
+
+ Color(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ = 255)
: r(r_), g(g_), b(b_), a(a_)
{}
};
Deleted: branches/pingus_sdl/src/math/origin.cpp
===================================================================
--- branches/pingus_sdl/src/math/origin.cpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/origin.cpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -1,102 +0,0 @@
-/*
-** ClanLib SDK
-** Copyright (c) 1997-2005 The ClanLib Team
-**
-** This software is provided 'as-is', without any express or implied
-** warranty. In no event will the authors be held liable for any damages
-** arising from the use of this software.
-**
-** Permission is granted to anyone to use this software for any purpose,
-** including commercial applications, and to alter it and redistribute it
-** freely, subject to the following restrictions:
-**
-** 1. The origin of this software must not be misrepresented; you must not
-** claim that you wrote the original software. If you use this software
-** in a product, an acknowledgment in the product documentation would be
-** appreciated but is not required.
-** 2. Altered source versions must be plainly marked as such, and must not be
-** misrepresented as being the original software.
-** 3. This notice may not be removed or altered from any source distribution.
-**
-** Note: Some of the libraries ClanLib may link to may have additional
-** requirements or restrictions.
-**
-** File Author(s):
-**
-** Magnus Norddahl
-** (if your name is missing here, please add it)
-*/
-
-#include "origin.hpp"
-
-Point calc_origin(Origin origin, const Size &size)
-{
- switch(origin)
- {
- case origin::top_left:
- default:
- return Point(0, 0);
- break;
- case origin::top_center:
- return Point(size.width / 2, 0);
- break;
- case origin::top_right:
- return Point(size.width, 0);
- break;
- case origin::center_left:
- return Point(0, size.height / 2);
- break;
- case origin::center:
- return Point(size.width / 2, size.height / 2);
- break;
- case origin::center_right:
- return Point(size.width, size.height / 2);
- break;
- case origin::bottom_left:
- return Point(0, size.height);
- break;
- case origin::bottom_center:
- return Point(size.width / 2, size.height);
- break;
- case origin::bottom_right:
- return Point(size.width, size.height);
- break;
- }
-}
-
-Vector calc_origin(Origin origin, const Sizef &size)
-{
- switch(origin)
- {
- case origin::top_left:
- default:
- return Vector(0, 0);
- break;
- case origin::top_center:
- return Vector(size.width / 2, 0);
- break;
- case origin::top_right:
- return Vector(size.width, 0);
- break;
- case origin::center_left:
- return Vector(0, size.height / 2);
- break;
- case origin::center:
- return Vector(size.width / 2, size.height / 2);
- break;
- case origin::center_right:
- return Vector(size.width, size.height / 2);
- break;
- case origin::bottom_left:
- return Vector(0, size.height);
- break;
- case origin::bottom_center:
- return Vector(size.width / 2, size.height);
- break;
- case origin::bottom_right:
- return Vector(size.width, size.height);
- break;
- }
-}
-
-/* EOF */
Copied: branches/pingus_sdl/src/math/origin.cpp (from rev 2654,
branches/pingus_sdl/src/origin.cpp)
Deleted: branches/pingus_sdl/src/math/origin.hpp
===================================================================
--- branches/pingus_sdl/src/math/origin.hpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/origin.hpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -1,65 +0,0 @@
-/*
-** ClanLib SDK
-** Copyright (c) 1997-2005 The ClanLib Team
-**
-** This software is provided 'as-is', without any express or implied
-** warranty. In no event will the authors be held liable for any damages
-** arising from the use of this software.
-**
-** Permission is granted to anyone to use this software for any purpose,
-** including commercial applications, and to alter it and redistribute it
-** freely, subject to the following restrictions:
-**
-** 1. The origin of this software must not be misrepresented; you must not
-** claim that you wrote the original software. If you use this software
-** in a product, an acknowledgment in the product documentation would be
-** appreciated but is not required.
-** 2. Altered source versions must be plainly marked as such, and must not be
-** misrepresented as being the original software.
-** 3. This notice may not be removed or altered from any source distribution.
-**
-** Note: Some of the libraries ClanLib may link to may have additional
-** requirements or restrictions.
-**
-** File Author(s):
-**
-** Magnus Norddahl
-** (if your name is missing here, please add it)
-*/
-
-//! clanCore="Math"
-//! header=core.h
-
-#ifndef HEADER_MATH_ORIGIN_HPP
-#define HEADER_MATH_ORIGIN_HPP
-
-namespace origin {
-
-//: Alignment origins.
-//- !group=Core/Math!
-//- !header=core.h!
-enum Origin
-{
- top_left,
- top_center,
- top_right,
- center_left,
- center,
- center_right,
- bottom_left,
- bottom_center,
- bottom_right
-};
-
-}
-
-typedef origin::Origin Origin;
-
-
-//: Returns the anchor point for the origin within the dimensions of the size
structure.
-//- !group=Display/Display 2D!
-//- !header=display.h!
-Point calc_origin(Origin origin, const Size &size);
-Vector calc_origin(Origin origin, const Sizef &size);
-
-#endif
Copied: branches/pingus_sdl/src/math/origin.hpp (from rev 2654,
branches/pingus_sdl/src/origin.hpp)
Modified: branches/pingus_sdl/src/math/rect.cpp
===================================================================
--- branches/pingus_sdl/src/math/rect.cpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/rect.cpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -35,28 +35,30 @@
#define cl_min(a,b) ((a < b) ? a : b)
#define cl_max(a,b) ((a > b) ? a : b)
-Rect Rect::get_rot_bounds(const Point &hotspot, float angle) const
+Rect Rect::get_rot_bounds(const Vector2i &hotspot, float angle) const
{
+#if 0
//Find the rotated positions of each corner
Rect retVal(*this);
- Point ul = Point(retVal.left, retVal.top).rotate(hotspot, angle);
- Point ur = Point(retVal.right, retVal.top).rotate(hotspot, angle);
- Point ll = Point(retVal.left, retVal.bottom).rotate(hotspot, angle);
- Point lr = Point(retVal.right, retVal.bottom).rotate(hotspot, angle);
+ Vector2i ul = Vector2i(retVal.left, retVal.top).rotate(hotspot, angle);
+ Vector2i ur = Vector2i(retVal.right, retVal.top).rotate(hotspot, angle);
+ Vector2i ll = Vector2i(retVal.left, retVal.bottom).rotate(hotspot,
angle);
+ Vector2i lr = Vector2i(retVal.right, retVal.bottom).rotate(hotspot,
angle);
//Use the sidemost corners as the bounds of the new rectangle
retVal.left = cl_min(cl_min(ul.x, ur.x), cl_min(ll.x, lr.x));
retVal.right = cl_max(cl_max(ul.x, ur.x), cl_max(ll.x, lr.x));
retVal.top = cl_min(cl_min(ul.y, ur.y), cl_min(ll.y, lr.y));
retVal.bottom = cl_max(cl_max(ul.y, ur.y), cl_max(ll.y, lr.y));
-
return retVal;
+#endif
+ return Rect();
}
Rect Rect::get_rot_bounds(Origin origin, int x, int y, float angle) const
{
return get_rot_bounds(
- Point(left, top) + calc_origin(origin, get_size()) + Point(x,
y),
+ Vector2i(left, top) + calc_origin(origin, get_size()) +
Vector2i(x, y),
angle);
}
Modified: branches/pingus_sdl/src/math/rect.hpp
===================================================================
--- branches/pingus_sdl/src/math/rect.hpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/rect.hpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -31,7 +31,7 @@
#define __MATH_RECT_HPP__
#include "origin.hpp"
-#include "vector.hpp"
+#include "vector3f.hpp"
#include "size.hpp"
class Rectf;
@@ -41,333 +41,333 @@
//- !header=core.h!
class Rect
{
-//! Construction:
+ //! Construction:
public:
- //: Constructs an rectangle.
- //param left: Initial left position of rectangle.
- //param top: Initial top position of rectangle.
- //param right: Initial right position of rectangle.
- //param bottom: Initial bottom position of rectangle.
- //param point: Initial top-left position of rectangle.
- //param size: Initial size of rectangle.
- //param rect: Initial rectangle position and size.
- Rect() { left = right = top = bottom = 0; }
+ //: Constructs an rectangle.
+ //param left: Initial left position of rectangle.
+ //param top: Initial top position of rectangle.
+ //param right: Initial right position of rectangle.
+ //param bottom: Initial bottom position of rectangle.
+ //param point: Initial top-left position of rectangle.
+ //param size: Initial size of rectangle.
+ //param rect: Initial rectangle position and size.
+ Rect() { left = right = top = bottom = 0; }
- explicit Rect(const Rectf& rect);
+ explicit Rect(const Rectf& rect);
- Rect(int new_left, int new_top, int new_right, int new_bottom)
- { left = new_left; top = new_top; right = new_right; bottom =
new_bottom; }
+ Rect(int new_left, int new_top, int new_right, int new_bottom)
+ { left = new_left; top = new_top; right = new_right; bottom = new_bottom; }
- Rect(const Point &p, const Size &size)
- { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
+ Rect(const Vector2i &p, const Size &size)
+ { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
- Rect(const Rect &rect)
- { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
+ Rect(const Rect &rect)
+ { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
- //: Rect += Rect operator.
- Rect &operator+=(const Rect &r)
- { left += r.left; top += r.top; right += r.right; bottom += r.bottom;
return *this; }
+ //: Rect += Rect operator.
+ Rect &operator+=(const Rect &r)
+ { left += r.left; top += r.top; right += r.right; bottom += r.bottom; return
*this; }
- //: Rect -= Rect operator.
- Rect &operator-=(const Rect &r)
- { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom;
return *this; }
+ //: Rect -= Rect operator.
+ Rect &operator-=(const Rect &r)
+ { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom; return
*this; }
- //: Rect += Point operator.
- Rect &operator+=(const Point &p)
- { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
+ //: Rect += Point operator.
+ Rect &operator+=(const Vector2i &p)
+ { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
- //: Rect -= Point operator.
- Rect &operator-=(const Point &p)
- { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
+ //: Rect -= Point operator.
+ Rect &operator-=(const Vector2i &p)
+ { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
- //: Rect + Rect operator.
- Rect operator+(const Rect &r) const
- { return Rect(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
+ //: Rect + Rect operator.
+ Rect operator+(const Rect &r) const
+ { return Rect(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
- //: Rect - Rect operator.
- Rect operator-(const Rect &r) const
- { return Rect(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
+ //: Rect - Rect operator.
+ Rect operator-(const Rect &r) const
+ { return Rect(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
- //: Rect + Point operator.
- Rect operator+(const Point &p) const
- { return Rect(left + p.x, top + p.y, right + p.x, bottom + p.y); }
+ //: Rect + Point operator.
+ Rect operator+(const Vector2i &p) const
+ { return Rect(left + p.x, top + p.y, right + p.x, bottom + p.y); }
- //: Rect - Point operator.
- Rect operator-(const Point &p) const
- { return Rect(left - p.x, top - p.y, right - p.x, bottom - p.y); }
+ //: Rect - Point operator.
+ Rect operator-(const Vector2i &p) const
+ { return Rect(left - p.x, top - p.y, right - p.x, bottom - p.y); }
- //: Rect == Rect operator.
- bool operator==(const Rect &r) const
- { return (left == r.left && top == r.top && right == r.right && bottom
&& r.bottom); }
+ //: Rect == Rect operator.
+ bool operator==(const Rect &r) const
+ { return (left == r.left && top == r.top && right == r.right && bottom &&
r.bottom); }
- //: Rect != Rect operator.
- bool operator!=(const Rect &r) const
- { return (left != r.left || top != r.top || right != r.right || bottom
!= r.bottom); }
+ //: Rect != Rect operator.
+ bool operator!=(const Rect &r) const
+ { return (left != r.left || top != r.top || right != r.right || bottom !=
r.bottom); }
-//! Attributes:
+ //! Attributes:
public:
- //: X1-coordinate.
- int left;
+ //: X1-coordinate.
+ int left;
- //: Y1-coordinate.
- int top;
+ //: Y1-coordinate.
+ int top;
- //: X2-coordinate.
- int right;
+ //: X2-coordinate.
+ int right;
- //: Y2-coordinate.
- int bottom;
+ //: Y2-coordinate.
+ int bottom;
- //: Returns the width of the rectangle.
- int get_width() const { return right - left; }
+ //: Returns the width of the rectangle.
+ int get_width() const { return right - left; }
- //: Returns the height of the rectangle.
- int get_height() const { return bottom - top; }
+ //: Returns the height of the rectangle.
+ int get_height() const { return bottom - top; }
- //: Returns the size of the rectangle.
- Size get_size() const { return Size(right - left, bottom - top); }
+ //: Returns the size of the rectangle.
+ Size get_size() const { return Size(right - left, bottom - top); }
- //: Returns true if point is inside the rectangle.
- bool is_inside(const Point &p) const { return (p.x >= left && p.y >=
top && p.x <= right && p.y <= bottom); }
+ //: Returns true if point is inside the rectangle.
+ bool is_inside(const Vector2i &p) const { return (p.x >= left && p.y >= top
&& p.x <= right && p.y <= bottom); }
- //: Returns true if rectangle passed is overlapping or inside this
rectangle.
- bool is_overlapped(const Rect &r) const
- {
- return (r.left < right && r.right > left && r.top < bottom &&
r.bottom > top);
- }
+ //: Returns true if rectangle passed is overlapping or inside this rectangle.
+ bool is_overlapped(const Rect &r) const
+ {
+ return (r.left < right && r.right > left && r.top < bottom && r.bottom >
top);
+ }
- //: Returns another Rect containing a rotated version of this one.
- //param hotspot: Point to rotate around.
- //param origin: Determines the hotspot point within the rectangle
- //param x, y: Offsets applied negatively to the hotspot point
- //param angle: Angle to rotate in degrees.
- Rect get_rot_bounds(const Point &hotspot, float angle) const;
- Rect get_rot_bounds(Origin origin, int x, int y, float angle) const;
+ //: Returns another Rect containing a rotated version of this one.
+ //param hotspot: Vector2i to rotate around.
+ //param origin: Determines the hotspot point within the rectangle
+ //param x, y: Offsets applied negatively to the hotspot point
+ //param angle: Angle to rotate in degrees.
+ Rect get_rot_bounds(const Vector2i &hotspot, float angle) const;
+ Rect get_rot_bounds(Origin origin, int x, int y, float angle) const;
-//! Operations:
+ //! Operations:
public:
- //: Sets the size of the rectangle, maintaining top/left position.
- void set_size(const Size &size)
- {
- right = left + size.width;
- bottom = top + size.height;
- }
+ //: Sets the size of the rectangle, maintaining top/left position.
+ void set_size(const Size &size)
+ {
+ right = left + size.width;
+ bottom = top + size.height;
+ }
- //: Calculates and returns the union of two rectangles.
- Rect calc_union(const Rect &rect)
- {
- Rect result;
- if (left > rect.left) result.left = left; else
result.left = rect.left;
- if (right < rect.right) result.right = right; else
result.right = rect.right;
- if (top > rect.top) result.top = top; else
result.top = rect.top;
- if (bottom < rect.bottom) result.bottom = bottom; else
result.bottom = rect.bottom;
- return result;
- }
+ //: Calculates and returns the union of two rectangles.
+ Rect calc_union(const Rect &rect)
+ {
+ Rect result;
+ if (left > rect.left) result.left = left; else result.left =
rect.left;
+ if (right < rect.right) result.right = right; else result.right =
rect.right;
+ if (top > rect.top) result.top = top; else result.top =
rect.top;
+ if (bottom < rect.bottom) result.bottom = bottom; else result.bottom =
rect.bottom;
+ return result;
+ }
- //: Normalize rectangle. Ensures that left is less than right and top
is less than bottom.
- void normalize()
- {
- if (left > right)
- {
- int temp = right;
- right = left;
- left = temp;
- }
+ //: Normalize rectangle. Ensures that left is less than right and top is
less than bottom.
+ void normalize()
+ {
+ if (left > right)
+ {
+ int temp = right;
+ right = left;
+ left = temp;
+ }
- if (top > bottom)
- {
- int temp = bottom;
- bottom = top;
- top = temp;
- }
- }
+ if (top > bottom)
+ {
+ int temp = bottom;
+ bottom = top;
+ top = temp;
+ }
+ }
- //: Applies an origin and offset pair to this rectangle
- //param origin: The new origin to adjust to from default upper-left
position
- //param x, y: Offsets applied negatively to each corner of the rectangle
- void apply_alignment(Origin origin, int x, int y)
- {
- Point offset = calc_origin(origin, get_size());
- offset.x -= x;
- offset.y -= y;
+ //: Applies an origin and offset pair to this rectangle
+ //param origin: The new origin to adjust to from default upper-left position
+ //param x, y: Offsets applied negatively to each corner of the rectangle
+ void apply_alignment(Origin origin, int x, int y)
+ {
+ Vector2i offset = calc_origin(origin, get_size());
+ offset.x -= x;
+ offset.y -= y;
- left += offset.x;
- top += offset.y;
- right += offset.x;
- bottom += offset.y;
- }
+ left += offset.x;
+ top += offset.y;
+ right += offset.x;
+ bottom += offset.y;
+ }
};
//: 2D (left,top,right,bottom) floating point rectangle structure.
class Rectf
{
-//! Construction:
+ //! Construction:
public:
- //: Constructs an rectangle.
- //param left: Initial left position of rectangle.
- //param top: Initial top position of rectangle.
- //param right: Initial right position of rectangle.
- //param bottom: Initial bottom position of rectangle.
- //param point: Initial top-left position of rectangle.
- //param size: Initial size of rectangle.
- //param rect: Initial rectangle position and size.
- Rectf() { left = right = top = bottom = 0.0f; }
+ //: Constructs an rectangle.
+ //param left: Initial left position of rectangle.
+ //param top: Initial top position of rectangle.
+ //param right: Initial right position of rectangle.
+ //param bottom: Initial bottom position of rectangle.
+ //param point: Initial top-left position of rectangle.
+ //param size: Initial size of rectangle.
+ //param rect: Initial rectangle position and size.
+ Rectf() { left = right = top = bottom = 0.0f; }
- Rectf(const Rect& rect)
- : left((float)rect.left),
- top((float)rect.top),
- right((float)rect.right),
- bottom((float)rect.bottom)
- {}
+ Rectf(const Rect& rect)
+ : left((float)rect.left),
+ top((float)rect.top),
+ right((float)rect.right),
+ bottom((float)rect.bottom)
+ {}
- Rectf(float new_left, float new_top, float new_right, float new_bottom)
- { left = new_left; top = new_top; right = new_right; bottom =
new_bottom; }
+ Rectf(float new_left, float new_top, float new_right, float new_bottom)
+ { left = new_left; top = new_top; right = new_right; bottom = new_bottom; }
- Rectf(const Vector &p, const Sizef &size)
- { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
+ Rectf(const Vector3f &p, const Sizef &size)
+ { left = p.x; top = p.y; right = left + size.width; bottom = top +
size.height; }
- Rectf(const Rectf &rect)
- { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
+ Rectf(const Rectf &rect)
+ { left = rect.left; top = rect.top; right = rect.right; bottom =
rect.bottom; }
- //: Rect += Rect operator.
- Rectf &operator+=(const Rectf &r)
- { left += r.left; top += r.top; right += r.right; bottom += r.bottom;
return *this; }
+ //: Rect += Rect operator.
+ Rectf &operator+=(const Rectf &r)
+ { left += r.left; top += r.top; right += r.right; bottom += r.bottom; return
*this; }
- //: Rect -= Rect operator.
- Rectf &operator-=(const Rectf &r)
- { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom;
return *this; }
+ //: Rect -= Rect operator.
+ Rectf &operator-=(const Rectf &r)
+ { left -= r.left; top -= r.top; right -= r.right; bottom -= r.bottom; return
*this; }
- //: Rect += Point operator.
- Rectf &operator+=(const Vector &p)
- { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
+ //: Rect += Point operator.
+ Rectf &operator+=(const Vector3f &p)
+ { left += p.x; top += p.y; right += p.x; bottom += p.y; return *this; }
- //: Rect -= Point operator.
- Rectf &operator-=(const Vector &p)
- { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
+ //: Rect -= Point operator.
+ Rectf &operator-=(const Vector3f &p)
+ { left -= p.x; top -= p.y; right -= p.x; bottom -= p.y; return *this; }
- //: Rect + Rect operator.
- Rectf operator+(const Rectf &r) const
- { return Rectf(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
+ //: Rect + Rect operator.
+ Rectf operator+(const Rectf &r) const
+ { return Rectf(left + r.left, top + r.top, right + r.right, bottom +
r.bottom); }
- //: Rect - Rect operator.
- Rectf operator-(const Rectf &r) const
- { return Rectf(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
+ //: Rect - Rect operator.
+ Rectf operator-(const Rectf &r) const
+ { return Rectf(left - r.left, top - r.top, right - r.right, bottom -
r.bottom); }
- //: Rect + Point operator.
- Rectf operator+(const Vector &p) const
- { return Rectf(left + p.x, top + p.y, right + p.x, bottom + p.y); }
+ //: Rect + Point operator.
+ Rectf operator+(const Vector3f &p) const
+ { return Rectf(left + p.x, top + p.y, right + p.x, bottom + p.y); }
- //: Rect - Point operator.
- Rectf operator-(const Vector &p) const
- { return Rectf(left - p.x, top - p.y, right - p.x, bottom - p.y); }
+ //: Rect - Point operator.
+ Rectf operator-(const Vector3f &p) const
+ { return Rectf(left - p.x, top - p.y, right - p.x, bottom - p.y); }
- //: Rect == Rect operator.
- bool operator==(const Rectf &r) const
- { return (left == r.left && top == r.top && right == r.right && bottom
&& r.bottom); }
+ //: Rect == Rect operator.
+ bool operator==(const Rectf &r) const
+ { return (left == r.left && top == r.top && right == r.right && bottom &&
r.bottom); }
- //: Rect != Rect operator.
- bool operator!=(const Rect &r) const
- { return (left != r.left || top != r.top || right != r.right || bottom
!= r.bottom); }
+ //: Rect != Rect operator.
+ bool operator!=(const Rect &r) const
+ { return (left != r.left || top != r.top || right != r.right || bottom !=
r.bottom); }
-//! Attributes:
+ //! Attributes:
public:
- //: X1-coordinate.
- float left;
+ //: X1-coordinate.
+ float left;
- //: Y1-coordinate.
- float top;
+ //: Y1-coordinate.
+ float top;
- //: X2-coordinate.
- float right;
+ //: X2-coordinate.
+ float right;
- //: Y2-coordinate.
- float bottom;
+ //: Y2-coordinate.
+ float bottom;
- //: Returns the width of the rectangle.
- float get_width() const { return right - left; }
+ //: Returns the width of the rectangle.
+ float get_width() const { return right - left; }
- //: Returns the height of the rectangle.
- float get_height() const { return bottom - top; }
+ //: Returns the height of the rectangle.
+ float get_height() const { return bottom - top; }
- //: Returns the size of the rectangle.
- Sizef get_size() const { return Sizef(right - left, bottom - top); }
+ //: Returns the size of the rectangle.
+ Sizef get_size() const { return Sizef(right - left, bottom - top); }
- //: Returns true if point is inside the rectangle.
- bool is_inside(const Vector &p) const { return (p.x >= left && p.y >=
top && p.x <= right && p.y <= bottom); }
+ //: Returns true if point is inside the rectangle.
+ bool is_inside(const Vector3f &p) const { return (p.x >= left && p.y >= top
&& p.x <= right && p.y <= bottom); }
- //: Returns true if rectangle passed is overlapping or inside this
rectangle.
- bool is_overlapped(const Rectf &r) const
- {
- return (r.left < right && r.right > left && r.top < bottom &&
r.bottom > top);
- }
+ //: Returns true if rectangle passed is overlapping or inside this rectangle.
+ bool is_overlapped(const Rectf &r) const
+ {
+ return (r.left < right && r.right > left && r.top < bottom && r.bottom >
top);
+ }
-//! Operations:
+ //! Operations:
public:
- //: Sets the size of the rectangle, maintaining top/left position.
- void set_size(const Size &size)
- {
- right = left + size.width;
- bottom = top + size.height;
- }
+ //: Sets the size of the rectangle, maintaining top/left position.
+ void set_size(const Size &size)
+ {
+ right = left + size.width;
+ bottom = top + size.height;
+ }
- //: Calculates and returns the union of two rectangles.
- Rectf calc_union(const Rectf &rect)
- {
- Rectf result;
- if (left > rect.left) result.left = left; else
result.left = rect.left;
- if (right < rect.right) result.right = right; else
result.right = rect.right;
- if (top > rect.top) result.top = top; else
result.top = rect.top;
- if (bottom < rect.bottom) result.bottom = bottom; else
result.bottom = rect.bottom;
- return result;
- }
+ //: Calculates and returns the union of two rectangles.
+ Rectf calc_union(const Rectf &rect)
+ {
+ Rectf result;
+ if (left > rect.left) result.left = left; else result.left =
rect.left;
+ if (right < rect.right) result.right = right; else result.right =
rect.right;
+ if (top > rect.top) result.top = top; else result.top =
rect.top;
+ if (bottom < rect.bottom) result.bottom = bottom; else result.bottom =
rect.bottom;
+ return result;
+ }
- //: Normalize rectangle. Ensures that left<right and top<bottom.
- void normalize()
- {
- if (left > right)
- {
- float temp = right;
- right = left;
- left = temp;
- }
+ //: Normalize rectangle. Ensures that left<right and top<bottom.
+ void normalize()
+ {
+ if (left > right)
+ {
+ float temp = right;
+ right = left;
+ left = temp;
+ }
- if (top > bottom)
- {
- float temp = bottom;
- bottom = top;
- top = temp;
- }
- }
-
- //: Applies an origin and offset pair to this rectangle
- //param origin: The new origin to adjust to from default upper-left
position
- //param x, y: Offsets applied negatively to each corner of the rectangle
- void apply_alignment(Origin origin, float x, float y)
- {
- Vector offset = calc_origin(origin, get_size());
- offset.x -= x;
- offset.y -= y;
+ if (top > bottom)
+ {
+ float temp = bottom;
+ bottom = top;
+ top = temp;
+ }
+ }
+#if 0
+ //: Applies an origin and offset pair to this rectangle
+ //param origin: The new origin to adjust to from default upper-left position
+ //param x, y: Offsets applied negatively to each corner of the rectangle
+ void apply_alignment(Origin origin, float x, float y)
+ {
+ Vector3f offset = calc_origin(origin, get_size());
+ offset.x -= x;
+ offset.y -= y;
- left += offset.x;
- top += offset.y;
- right += offset.x;
- bottom += offset.y;
- }
-
- // Moves each edge f away from the center, thus width = old_width + 2*f
- Rectf grow(float f) const {
- return Rectf(left - f,
- top - f,
- right + f,
- bottom + f);
- }
+ left += offset.x;
+ top += offset.y;
+ right += offset.x;
+ bottom += offset.y;
+ }
+#endif
+ // Moves each edge f away from the center, thus width = old_width + 2*f
+ Rectf grow(float f) const {
+ return Rectf(left - f,
+ top - f,
+ right + f,
+ bottom + f);
+ }
};
inline Rect::Rect(const Rectf& rect)
- : left(static_cast<int>(rect.left)),
- top(static_cast<int>(rect.top)),
- right(static_cast<int>(rect.right)),
- bottom(static_cast<int>(rect.bottom))
+ : left(static_cast<int>(rect.left)),
+ top(static_cast<int>(rect.top)),
+ right(static_cast<int>(rect.right)),
+ bottom(static_cast<int>(rect.bottom))
{}
#endif
Modified: branches/pingus_sdl/src/math/vector3f.cpp
===================================================================
--- branches/pingus_sdl/src/math/vector3f.cpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/vector3f.cpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -20,6 +20,7 @@
#include <math.h>
#include <iostream>
#include "vector3f.hpp"
+#include "vector2f.hpp"
Vector3f::Vector3f (float x_, float y_, float z_) : x(x_), y(y_), z(z_)
{
@@ -29,6 +30,10 @@
{
}
+Vector3f::Vector3f (const Vector2f& old) : x(old.x), y(old.y), z(0)
+{
+}
+
Vector3f&
Vector3f::operator= (const Vector3f& old)
{
Modified: branches/pingus_sdl/src/math/vector3f.hpp
===================================================================
--- branches/pingus_sdl/src/math/vector3f.hpp 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/math/vector3f.hpp 2007-01-15 13:49:02 UTC (rev
2655)
@@ -23,6 +23,8 @@
#include <iosfwd>
#include "pingus.hxx"
+class Vector2f;
+
class Vector3f
{
public:
@@ -34,6 +36,7 @@
explicit Vector3f (float x_=0, float y_=0, float z_=0);
Vector3f (const Vector3f& old);
+ Vector3f (const Vector2f& old);
Vector3f& operator= (const Vector3f& old);
Vector3f operator- () const;
Deleted: branches/pingus_sdl/src/origin.cpp
===================================================================
--- branches/pingus_sdl/src/origin.cpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/origin.cpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -1,165 +0,0 @@
-/*
-** ClanLib SDK
-** Copyright (c) 1997-2005 The ClanLib Team
-**
-** This software is provided 'as-is', without any express or implied
-** warranty. In no event will the authors be held liable for any damages
-** arising from the use of this software.
-**
-** Permission is granted to anyone to use this software for any purpose,
-** including commercial applications, and to alter it and redistribute it
-** freely, subject to the following restrictions:
-**
-** 1. The origin of this software must not be misrepresented; you must not
-** claim that you wrote the original software. If you use this software
-** in a product, an acknowledgment in the product documentation would be
-** appreciated but is not required.
-** 2. Altered source versions must be plainly marked as such, and must not be
-** misrepresented as being the original software.
-** 3. This notice may not be removed or altered from any source distribution.
-**
-** Note: Some of the libraries ClanLib may link to may have additional
-** requirements or restrictions.
-**
-** File Author(s):
-**
-** Magnus Norddahl
-** (if your name is missing here, please add it)
-*/
-
-#include "origin.hpp"
-
-Origin string2origin(const std::string& str)
-{
- if (str == "top_left")
- return origin_top_left;
- else if (str == "top_center")
- return origin_top_center;
- else if (str == "top_right")
- return origin_top_right;
- else if (str == "center_left")
- return origin_center_left;
- else if (str == "center")
- return origin_center;
- else if (str == "center_right")
- return origin_center_right;
- else if (str == "bottom_left")
- return origin_bottom_left;
- else if (str == "bottom_center")
- return origin_bottom_center;
- else if (str == "bottom_right")
- return origin_bottom_right;
- else
- return origin_top_left;
-}
-
-Vector2i calc_origin(Origin origin, const Size &size)
-{
- switch(origin)
- {
- case origin_top_left:
- default:
- return Vector2i(0, 0);
- break;
- case origin_top_center:
- return Vector2i(size.width / 2, 0);
- break;
- case origin_top_right:
- return Vector2i(size.width, 0);
- break;
- case origin_center_left:
- return Vector2i(0, size.height / 2);
- break;
- case origin_center:
- return Vector2i(size.width / 2, size.height / 2);
- break;
- case origin_center_right:
- return Vector2i(size.width, size.height / 2);
- break;
- case origin_bottom_left:
- return Vector2i(0, size.height);
- break;
- case origin_bottom_center:
- return Vector2i(size.width / 2, size.height);
- break;
- case origin_bottom_right:
- return Vector2i(size.width, size.height);
- break;
- }
-}
-
-#if 0
-CL_Pointf calc_origin(CL_Origin origin, const CL_Sizef &size)
-{
- switch(origin)
- {
- case origin_top_left:
- default:
- return CL_Pointf(0, 0);
- break;
- case origin_top_center:
- return CL_Pointf(size.width / 2, 0);
- break;
- case origin_top_right:
- return CL_Pointf(size.width, 0);
- break;
- case origin_center_left:
- return CL_Pointf(0, size.height / 2);
- break;
- case origin_center:
- return CL_Pointf(size.width / 2, size.height / 2);
- break;
- case origin_center_right:
- return CL_Pointf(size.width, size.height / 2);
- break;
- case origin_bottom_left:
- return CL_Pointf(0, size.height);
- break;
- case origin_bottom_center:
- return CL_Pointf(size.width / 2, size.height);
- break;
- case origin_bottom_right:
- return CL_Pointf(size.width, size.height);
- break;
- }
-}
-
-CL_Pointd calc_origin(CL_Origin origin, const CL_Sized &size)
-{
- switch(origin)
- {
- case origin_top_left:
- default:
- return CL_Pointd(0, 0);
- break;
- case origin_top_center:
- return CL_Pointd(size.width / 2, 0);
- break;
- case origin_top_right:
- return CL_Pointd(size.width, 0);
- break;
- case origin_center_left:
- return CL_Pointd(0, size.height / 2);
- break;
- case origin_center:
- return CL_Pointd(size.width / 2, size.height / 2);
- break;
- case origin_center_right:
- return CL_Pointd(size.width, size.height / 2);
- break;
- case origin_bottom_left:
- return CL_Pointd(0, size.height);
- break;
- case origin_bottom_center:
- return CL_Pointd(size.width / 2, size.height);
- break;
- case origin_bottom_right:
- return CL_Pointd(size.width, size.height);
- break;
- }
-}
-
-#endif
-
-/* EOF */
-
Deleted: branches/pingus_sdl/src/origin.hpp
===================================================================
--- branches/pingus_sdl/src/origin.hpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/origin.hpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -1,72 +0,0 @@
-/*
-** ClanLib SDK
-** Copyright (c) 1997-2005 The ClanLib Team
-**
-** This software is provided 'as-is', without any express or implied
-** warranty. In no event will the authors be held liable for any damages
-** arising from the use of this software.
-**
-** Permission is granted to anyone to use this software for any purpose,
-** including commercial applications, and to alter it and redistribute it
-** freely, subject to the following restrictions:
-**
-** 1. The origin of this software must not be misrepresented; you must not
-** claim that you wrote the original software. If you use this software
-** in a product, an acknowledgment in the product documentation would be
-** appreciated but is not required.
-** 2. Altered source versions must be plainly marked as such, and must not be
-** misrepresented as being the original software.
-** 3. This notice may not be removed or altered from any source distribution.
-**
-** Note: Some of the libraries ClanLib may link to may have additional
-** requirements or restrictions.
-**
-** File Author(s):
-**
-** Magnus Norddahl
-** (if your name is missing here, please add it)
-*/
-
-//! clanCore="Math"
-//! header=core.h
-
-#ifndef header_origin
-#define header_origin
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include <string>
-#include "math/vector2i.hpp"
-#include "math/size.hpp"
-
-//: Alignment origins.
-//- !group=Core/Math!
-//- !header=core.h!
-enum Origin
-{
- origin_top_left,
- origin_top_center,
- origin_top_right,
- origin_center_left,
- origin_center,
- origin_center_right,
- origin_bottom_left,
- origin_bottom_center,
- origin_bottom_right
-};
-
-Origin string2origin(const std::string& str);
-
-Vector2i calc_origin(Origin origin, const Size& size);
-
-#if 0
-//: Returns the anchor point for the origin within the dimensions of the size
structure.
-//- !group=Display/Display 2D!
-//- !header=display.h!
-CL_API_CORE CL_Pointf calc_origin(CL_Origin origin, const CL_Sizef &size);
-CL_API_CORE CL_Pointd calc_origin(CL_Origin origin, const CL_Sized &size);
-#endif
-
-#endif
Modified: branches/pingus_sdl/src/pingus_level.cxx
===================================================================
--- branches/pingus_sdl/src/pingus_level.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/pingus_level.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -17,7 +17,6 @@
// 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/XML/dom_node.h>
#include "file_reader.hxx"
#include "pingus_level.hxx"
#include "pingus_level_impl.hxx"
@@ -100,7 +99,7 @@
return impl->resname;
}
-const CL_Colorf&
+const Color&
PingusLevel::get_ambient_light() const
{
return impl->ambient_light;
Modified: branches/pingus_sdl/src/pingus_level_impl.hxx
===================================================================
--- branches/pingus_sdl/src/pingus_level_impl.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/pingus_level_impl.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,23 +20,20 @@
#ifndef HEADER_PINGUS_LEVEL_IMPL_HXX
#define HEADER_PINGUS_LEVEL_IMPL_HXX
-#include <ClanLib/Core/System/sharedptr.h>
-#include <ClanLib/Core/Math/size.h>
-#include <ClanLib/Display/color.h>
+#include "math/size.hpp"
+#include "math/color.hpp"
#include <string>
#include <vector>
#include <map>
-
-
class PingusLevelImpl
{
public:
// Set defaults in constructor
PingusLevelImpl()
- : ambient_light(CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
- music("none")
+ : ambient_light(255, 255, 255, 255),
+ music("none")
{
// Do nothing
}
@@ -46,8 +43,8 @@
std::string levelname;
std::string description;
- CL_Colorf ambient_light;
- CL_Size size;
+ Color ambient_light;
+ Size size;
int number_of_pingus;
int number_to_save;
Modified: branches/pingus_sdl/src/plt_xml.cxx
===================================================================
--- branches/pingus_sdl/src/plt_xml.cxx 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/plt_xml.cxx 2007-01-15 13:49:02 UTC (rev 2655)
@@ -19,10 +19,9 @@
#include <iostream>
#include <ClanLib/core.h>
-#include "xml_file_reader.hxx"
#include "globals.hxx"
#include "pingus_error.hxx"
-#include "xml_file_reader.hxx"
+//#include "xml_file_reader.hxx"
#include "plt_xml.hxx"
Modified: branches/pingus_sdl/src/savegame.cxx
===================================================================
--- branches/pingus_sdl/src/savegame.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/savegame.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -18,8 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
-#include <ClanLib/Core/System/clanstring.h>
-#include "xml_file_writer.hxx"
+///#include "sexpr_file_writer.hxx"
#include "savegame.hxx"
@@ -43,6 +42,7 @@
Savegame::S_Status
Savegame::string_to_status (std::string str)
{
+#if 0
str = CL_String::to_lower(str);
if (str == "accessible")
return ACCESSIBLE;
@@ -51,6 +51,7 @@
else if (str == "none")
return NONE;
else
+#endif
return NONE;
}
@@ -74,6 +75,7 @@
{
}
+#if 0
void
Savegame::write_xml(XMLFileWriter& writer)
{
@@ -84,6 +86,7 @@
writer.write_int ("saved-pingus", saved_pingus);
writer.end_section();
}
+#endif
void
Savegame::read_xml(FileReader reader)
Modified: branches/pingus_sdl/src/savegame_manager.cxx
===================================================================
--- branches/pingus_sdl/src/savegame_manager.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/savegame_manager.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,11 +20,10 @@
#include <iostream>
#include <fstream>
#include <assert.h>
-#include <ClanLib/core.h>
#include "system.hxx"
#include "pingus_error.hxx"
-#include "xml_file_reader.hxx"
-#include "xml_file_writer.hxx"
+////#include "xml_file_reader.hxx"
+///#include "xml_file_writer.hxx"
#include "savegame_manager.hxx"
@@ -48,6 +47,7 @@
SavegameManager::SavegameManager(const std::string& arg_filename)
: filename(arg_filename)
{
+#if 0
try
{
CL_DomDocument doc(new CL_InputSource_File(filename), true);
@@ -85,6 +85,7 @@
std::cout << "SavegameManager: Couldn't find savegame file '" << filename
<< "', starting with a empty one." << std::endl;
}
+#endif
}
SavegameManager::~SavegameManager()
@@ -136,8 +137,9 @@
void
SavegameManager::flush()
{
+#if 0
std::ofstream out(filename.c_str());
- XMLFileWriter xml(out);
+ XMLFileWriter xml(out);
xml.begin_section("pingus-savegame");
@@ -148,6 +150,7 @@
}
xml.end_section(); // pingus-savegame
+#endif
}
Modified: branches/pingus_sdl/src/sprite.cpp
===================================================================
--- branches/pingus_sdl/src/sprite.cpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/sprite.cpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -27,7 +27,7 @@
#include <sstream>
#include <assert.h>
#include "SDL.h"
-#include "origin.hpp"
+#include "math/origin.hpp"
#include "math/vector2i.hpp"
#include "SDL_image.h"
#include "sprite.hpp"
@@ -128,13 +128,23 @@
int
Sprite::get_width()
{
- return 0;
+ return impl->surface->w;
}
int
Sprite::get_height()
{
- return 0;
+ return impl->surface->h;
}
+Sprite::operator bool()
+{
+ return impl.get();
+}
+
+void
+Sprite:: update(float delta)
+{
+}
+
/* EOF */
Modified: branches/pingus_sdl/src/sprite.hpp
===================================================================
--- branches/pingus_sdl/src/sprite.hpp 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/sprite.hpp 2007-01-15 13:49:02 UTC (rev 2655)
@@ -45,7 +45,11 @@
int get_width();
int get_height();
+ void update(float delta);
+
void draw(float x, float y, SDL_Surface* target);
+
+ operator bool();
private:
SharedPtr<SpriteImpl> impl;
};
Modified: branches/pingus_sdl/src/stat_manager.cxx
===================================================================
--- branches/pingus_sdl/src/stat_manager.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/stat_manager.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -20,10 +20,9 @@
#include <iostream>
#include <algorithm>
#include <fstream>
-#include <ClanLib/core.h>
#include "system.hxx"
#include "pingus_error.hxx"
-#include "xml_file_reader.hxx"
+////#include "xml_file_reader.hxx"
#include "stat_manager.hxx"
@@ -85,6 +84,7 @@
save(filename);
}
+#if 0
CL_InputSourceProvider_File provider(".");
CL_DomDocument doc(provider.open_source(filename), true);
@@ -104,6 +104,7 @@
reader.read_string(i->c_str(), stats[*i]);
}
}
+#endif
}
void
@@ -132,20 +133,24 @@
bool
StatManager::get_int(const std::string& name, int& value)
{
+#if 0
std::string str;
if (get_string(name, str))
return CL_String::from(str, value);
else
+#endif
return false;
}
bool
StatManager::get_bool(const std::string& name, bool& value)
{
+#if 0
std::string str;
if (get_string(name, str))
return CL_String::from(str, value);
else
+#endif
return false;
}
@@ -174,14 +179,18 @@
void
StatManager::set_int(const std::string& name, int value)
{
+#if 0
stats[name] = CL_String::to(value);
+#endif
flush();
}
void
StatManager::set_bool(const std::string& name, bool value)
{
+#if 0
stats[name] = CL_String::to(value);
+#endif
flush();
}
Modified: branches/pingus_sdl/src/state_sprite.cxx
===================================================================
--- branches/pingus_sdl/src/state_sprite.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/state_sprite.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -33,7 +33,7 @@
}
void
-StateSprite::load(int state, CL_Sprite sprite)
+StateSprite::load(int state, Sprite sprite)
{
sprites[state] = sprite;
}
@@ -51,7 +51,7 @@
(*i).second.update(delta);
}
-CL_Sprite&
+Sprite&
StateSprite::operator[](int state)
{
Sprites::iterator i = sprites.find(state);
Modified: branches/pingus_sdl/src/state_sprite.hxx
===================================================================
--- branches/pingus_sdl/src/state_sprite.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/state_sprite.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -21,15 +21,14 @@
#define HEADER_STATE_SPRITE_HXX
#include <map>
-#include <ClanLib/Display/sprite.h>
+#include "sprite.hpp"
-
-/** Simple Wrapper class around CL_Sprite that allows to have multiple
+/** Simple Wrapper class around Sprite that allows to have multiple
sprites for different states (running, walking, left, right) */
class StateSprite
{
private:
- typedef std::map<int, CL_Sprite> Sprites;
+ typedef std::map<int, Sprite> Sprites;
Sprites sprites;
public:
@@ -39,8 +38,8 @@
void update();
void load(int state, const std::string& name);
- void load(int state, CL_Sprite);
- CL_Sprite& operator[](int state);
+ void load(int state, Sprite);
+ Sprite& operator[](int state);
};
Modified: branches/pingus_sdl/src/string_format.cxx
===================================================================
--- branches/pingus_sdl/src/string_format.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/string_format.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -17,12 +17,12 @@
// 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/Display/font.h>
+#include "font.hpp"
#include "string_format.hxx"
std::string
-StringFormat::break_line (std::string text, int length, const CL_Font& font)
+StringFormat::break_line (std::string text, int length, const Font& font)
{
std::string::size_type pos = 0;
while ((pos = text.find('\t', pos)) != std::string::npos)
Modified: branches/pingus_sdl/src/string_format.hxx
===================================================================
--- branches/pingus_sdl/src/string_format.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/string_format.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -22,13 +22,12 @@
#include <string>
-class CL_Font;
+class Font;
-
class StringFormat {
public:
- static std::string break_line (std::string text, int length, const CL_Font&
font);
+ static std::string break_line (std::string text, int length, const Font&
font);
};
Modified: branches/pingus_sdl/src/worldmap/dot.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/dot.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/worldmap/dot.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -21,7 +21,7 @@
#define HEADER_PINGUS_DOT_HXX
#include <string>
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
#include "drawable.hxx"
namespace WorldMapNS {
@@ -31,7 +31,7 @@
class Dot : public Drawable
{
protected:
- Vector pos;
+ Vector3f pos;
public:
Dot(FileReader reader);
@@ -39,7 +39,7 @@
/** Draw stuff that should be displayed if the mouse is over the dot */
virtual void draw_hover(DrawingContext& gc) =0;
- Vector get_pos() { return pos; }
+ Vector3f get_pos() { return pos; }
virtual void on_click() =0;
Modified: branches/pingus_sdl/src/worldmap/drawable.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/drawable.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/drawable.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -23,7 +23,6 @@
#include "../pingus_error.hxx"
#include "../file_reader.hxx"
-
class DrawingContext;
namespace WorldMapNS {
Modified: branches/pingus_sdl/src/worldmap/level_dot.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/level_dot.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/level_dot.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -19,7 +19,7 @@
#include <iostream>
#include <math.h>
-#include <ClanLib/Display/font.h>
+#include "../font.hpp"
#include "../input/controller.hxx"
#include "../input/pointer.hxx"
#include "../gettext.h"
@@ -46,16 +46,19 @@
highlight_green_dot_sur(Resource::load_sprite("core/worldmap/dot_green_hl")),
highlight_red_dot_sur(Resource::load_sprite("core/worldmap/dot_red_hl"))
{
- std::string resname;
+#if 0
+ std::string resname;
reader.read_string("levelname", resname);
+
plf = PLFResMgr::load_plf(resname);
- levelname = plf.get_levelname();
+ levelname = plf.get_levelname();
+#endif
}
void
LevelDot::draw(DrawingContext& gc)
{
- Vector mpos =
gc.screen_to_world(Vector(Input::Controller::get_current()->get_pointer()->get_x_pos(),
+ Vector3f mpos =
gc.screen_to_world(Vector3f(Input::Controller::get_current()->get_pointer()->get_x_pos(),
Input::Controller::get_current()->get_pointer()->get_y_pos()));
float x = mpos.x - pos.x;
@@ -98,8 +101,8 @@
LevelDot::on_click()
{
std::cout << "Starting level: " << levelname << std::endl;
- ScreenManager::instance()->push_screen(new StartScreen(plf),
- true);
+ ////ScreenManager::instance()->push_screen(new StartScreen(plf),
+ ////true);
}
bool
@@ -131,7 +134,7 @@
if (accessible())
{
int length = Fonts::pingus_small.bounding_rect(0, 0,
_(get_plf().get_levelname())).get_width() / 2;
- int realpos = static_cast<int>(gc.world_to_screen(Vector(pos.x, pos.y,
0)).x);
+ int realpos = static_cast<int>(gc.world_to_screen(Vector3f(pos.x, pos.y,
0)).x);
if (realpos - length < 0)
pos_correction = realpos - length;
else if (realpos + length > gc.get_width())
@@ -146,7 +149,7 @@
else
{
int length = Fonts::pingus_small.bounding_rect(0, 0,
_("locked")).get_width() / 2;
- int realpos = static_cast<int>(gc.world_to_screen(Vector(pos.x, pos.y,
0)).x);
+ int realpos = static_cast<int>(gc.world_to_screen(Vector3f(pos.x, pos.y,
0)).x);
if (realpos - length < 0)
pos_correction = realpos - length;
else if (realpos + length > gc.get_width())
Modified: branches/pingus_sdl/src/worldmap/level_dot.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/level_dot.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/level_dot.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,7 +20,7 @@
#ifndef HEADER_PINGUS_WORLDMAP_LEVEL_DOT_HXX
#define HEADER_PINGUS_WORLDMAP_LEVEL_DOT_HXX
-#include <ClanLib/Display/sprite.h>
+#include "../sprite.hpp"
#include "../pingus_level.hxx"
#include "dot.hxx"
@@ -30,11 +30,11 @@
class LevelDot : public Dot
{
private:
- CL_Sprite green_dot_sur;
- CL_Sprite red_dot_sur;
- CL_Sprite unaccessible_dot_sur;
- CL_Sprite highlight_green_dot_sur;
- CL_Sprite highlight_red_dot_sur;
+ Sprite green_dot_sur;
+ Sprite red_dot_sur;
+ Sprite unaccessible_dot_sur;
+ Sprite highlight_green_dot_sur;
+ Sprite highlight_red_dot_sur;
std::string levelname;
PingusLevel plf;
Modified: branches/pingus_sdl/src/worldmap/manager.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/manager.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/manager.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -20,6 +20,7 @@
#include <iostream>
#include "../gettext.h"
#include "../fonts.hxx"
+#include "../gui/display.hxx"
#include "../gui/screen_manager.hxx"
#include "../gui/surface_button.hxx"
#include "../path_manager.hxx"
@@ -80,7 +81,7 @@
WorldMapManagerCreditsButton::WorldMapManagerCreditsButton()
- : GUI::SurfaceButton(CL_Display::get_width() - 150, 0,
+ : GUI::SurfaceButton(Display::get_width() - 150, 0,
ResDescriptor("core/worldmap/credits_button_normal"),
ResDescriptor("core/worldmap/credits_button_pressed"),
ResDescriptor("core/worldmap/credits_button_hover"))
@@ -100,14 +101,16 @@
WorldMapManagerCreditsButton::draw (DrawingContext& gc)
{
SurfaceButton::draw(gc);
- gc.print_left(Fonts::chalk_small, (float)(CL_Display::get_width() - 150 +
15), 5, _("Show Ending?"));
+ gc.print_left(Fonts::chalk_small, (float)(Display::get_width() - 150 + 15),
5, _("Show Ending?"));
}
void
WorldMapManagerCreditsButton::on_click()
{
- ScreenManager::instance()->replace_screen(
- new
StoryScreen(WorldMapManager::instance()->get_worldmap()->get_end_story()),
true);
+#if 0
+ ScreenManager::instance()->replace_screen
+ (new
StoryScreen(WorldMapManager::instance()->get_worldmap()->get_end_story()),
true);
+#endif
}
WorldMapManagerStoryButton::WorldMapManagerStoryButton()
@@ -137,12 +140,14 @@
void
WorldMapManagerStoryButton::on_click()
{
- ScreenManager::instance()->replace_screen(
- new
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
+#if 0
+ ScreenManager::instance()->replace_screen
+ (new
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
true);
+#endif
}
WorldMapManagerCloseButton::WorldMapManagerCloseButton()
- : GUI::SurfaceButton(0, CL_Display::get_height() - 37,
+ : GUI::SurfaceButton(0, Display::get_height() - 37,
ResDescriptor("core/worldmap/leave_button_normal"),
ResDescriptor("core/worldmap/leave_button_pressed"),
ResDescriptor("core/worldmap/leave_button_hover"))
@@ -160,7 +165,7 @@
WorldMapManagerCloseButton::draw (DrawingContext& gc)
{
SurfaceButton::draw(gc);
- gc.print_left(Fonts::chalk_small, 10, (float)CL_Display::get_height() - 20,
_("Leave?"));
+ gc.print_left(Fonts::chalk_small, 10, (float)Display::get_height() - 20,
_("Leave?"));
}
void
@@ -170,7 +175,7 @@
}
WorldMapManagerEnterButton::WorldMapManagerEnterButton()
- : GUI::SurfaceButton(CL_Display::get_width() - 119, CL_Display::get_height()
- 37,
+ : GUI::SurfaceButton(Display::get_width() - 119, Display::get_height() - 37,
ResDescriptor("core/worldmap/enter_button_normal"),
ResDescriptor("core/worldmap/enter_button_pressed"),
ResDescriptor("core/worldmap/enter_button_hover"))
@@ -192,14 +197,14 @@
{
if (WorldMapManager::instance()->get_worldmap()->get_pingus()->is_walking())
{
- gc.draw(button_surface, Vector((float)x_pos, (float)y_pos));
+ gc.draw(button_surface, Vector3f((float)x_pos, (float)y_pos));
}
else
{
SurfaceButton::draw(gc);
gc.print_left(Fonts::chalk_small,
- (float)CL_Display::get_width() - 100,
- (float)CL_Display::get_height() - 20,
+ (float)Display::get_width() - 100,
+ (float)Display::get_height() - 20,
_("Enter?"));
}
}
@@ -215,7 +220,7 @@
exit_worldmap(false),
worldmap(0),
new_worldmap(0),
- metamap(new
MetaMap(path_manager.complete("metamap/metamap.xml")))
+ metamap(new MetaMap(path_manager.complete("metamap/metamap.xml")))
{
// FIXME: a bit ugly because of the proteced member, but should work
// FIXME: well enough. GUIScreen could also use multi-inheritage,
Modified: branches/pingus_sdl/src/worldmap/manager.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/manager.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/manager.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -24,10 +24,6 @@
#include "../gui/gui_manager.hxx"
#include "../gui/gui_screen.hxx"
-class CL_InputDevice;
-class CL_Key;
-class GameDelta;
-
namespace WorldMapNS {
typedef int NodeId;
Modified: branches/pingus_sdl/src/worldmap/metamap.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/metamap.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/metamap.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -17,7 +17,6 @@
// 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"
@@ -26,45 +25,46 @@
#include "../debug.hxx"
#include "../globals.hxx"
#include "../stat_manager.hxx"
-#include "../xml_file_reader.hxx"
+#include "../sexpr_file_reader.hpp"
namespace WorldMapNS {
// Constructor
-MetaMap::MetaMap(const std::string &filename_arg) :
- filename(filename_arg)
+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();
+#if 0
+ 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;
+ XMLFileReader xml(root);
+ parse_file(xml);
+#endif
+ 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 (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");
+ if (!path_graph)
+ PingusError::raise("MetaMap: " + filename + " missing Graph");
}
// Parse the nodes and edges
@@ -78,56 +78,55 @@
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);
+ // 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);
+ unlock_default(node_name);
- reader.read_string("final-node", node_name);
- final_node = path_graph->lookup_node(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);
- }
+ 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());
+ return (path_graph->get_dot(default_node)->get_name());
}
std::string
MetaMap::get_final_worldmap()
{
- return (path_graph->get_dot(final_node)->get_name());
+ return (path_graph->get_dot(final_node)->get_name());
}
void
MetaMap::finish_node(const std::string &worldmap_shortname)
{
- StatManager::instance()->set_bool(worldmap_shortname + "-finished",
true);
- // NodeId id = path_graph->lookup_node(worldmap_shortname);
- // FIXME: Not entirely sure how the whole pathfinder thing works,
- // FIXME: so I'm hardcoding this for now... <evil!!!>
- unlock_default("volcano");
+ StatManager::instance()->set_bool(worldmap_shortname + "-finished", true);
+ // NodeId id = path_graph->lookup_node(worldmap_shortname);
+ // FIXME: Not entirely sure how the whole pathfinder thing works,
+ // FIXME: so I'm hardcoding this for now... <evil!!!>
+ unlock_default("volcano");
}
MetaMap::~MetaMap()
{
- delete path_graph;
+ delete path_graph;
}
} // WorldMap namespace
-} // Pingus namespace
/* EOF */
Modified: branches/pingus_sdl/src/worldmap/metamap.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/metamap.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/metamap.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -91,7 +91,6 @@
}; // MetaMap class.
} // WorldMap namespace;
-} // Pingus namespace;
#endif
Modified: branches/pingus_sdl/src/worldmap/path.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/path.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/worldmap/path.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -29,7 +29,7 @@
{
}
-std::vector<Vector>::size_type
+std::vector<Vector3f >::size_type
Path::size()
{
return vec.size();
@@ -63,14 +63,14 @@
Vec::iterator prev = vec.begin();
for(Vec::iterator next = prev + 1; next != vec.end(); ++next)
{
- length += Vector::distance2d(*prev, *next);
+ length += Vector3f ::distance2d(*prev, *next);
prev = next;
}
return length;
}
}
-Vector
+Vector3f
Path::at(float vec_position)
{
assert(!vec.empty());
@@ -81,7 +81,7 @@
float comp_length = 0.0f;
while (next != vec.end())
{
- float length = Vector::distance2d(*current, *next);
+ float length = Vector3f::distance2d(*current, *next);
// The pingu is between current and next
if (comp_length + length > vec_position)
@@ -89,7 +89,7 @@
float perc = (vec_position - comp_length) // length to walk from
current node
/ length;
- return Vector::interpolate(*current, *next, perc);
+ return Vector3f::interpolate(*current, *next, perc);
}
comp_length += length;
Modified: branches/pingus_sdl/src/worldmap/path.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/path.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/worldmap/path.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -22,7 +22,7 @@
#include <algorithm>
#include <vector>
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
namespace WorldMapNS {
@@ -31,7 +31,7 @@
class Path
{
private:
- typedef std::vector<Vector> Vec;
+ typedef std::vector<Vector3f> Vec;
Vec vec;
bool path_length_valid;
@@ -53,7 +53,7 @@
/** walk a distance of vec_position on the path and return the position,
positions between two Vectors are interpolated, if length is
larger then path *back() will be returned */
- Vector at(float vec_position);
+ Vector3f at(float vec_position);
bool empty() { return vec.empty(); }
void clear() { path_length_valid = false; vec.clear(); }
@@ -63,7 +63,7 @@
reverse_iterator rbegin() { return vec.rbegin(); }
reverse_iterator rend() { return vec.rend(); }
- void push_back(const Vector& v) {
+ void push_back(const Vector3f& v) {
path_length_valid = false;
vec.push_back(v);
}
Modified: branches/pingus_sdl/src/worldmap/path_drawable.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/path_drawable.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/path_drawable.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -18,6 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <iostream>
+#include "../math/color.hpp"
#include "../display/drawing_context.hxx"
#include "path_drawable.hxx"
@@ -37,7 +38,7 @@
{
gc.draw_line(prev->x, prev->y,
next->x, next->y,
- CL_Color(255, 255, 255));
+ Color(255, 255, 255));
prev = next;
}
}
Modified: branches/pingus_sdl/src/worldmap/path_graph.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/path_graph.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/path_graph.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -33,8 +33,8 @@
namespace WorldMapNS {
PathGraph::PathGraph(WorldMap* arg_worldmap, FileReader &reader)
- : worldmap(arg_worldmap),
- metamap(0)
+ : worldmap(arg_worldmap)
+ ////metamap(0)
{
parse_nodes(reader.read_section("nodes"));
parse_edges(reader.read_section("edges"));
@@ -124,7 +124,7 @@
{
if (j->get_name() == "position")
{
- Vector pos;
+ Vector3f pos;
j->read_float("x", pos.x);
j->read_float("y", pos.y);
j->read_float("z", pos.z);
Modified: branches/pingus_sdl/src/worldmap/path_graph.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/path_graph.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/path_graph.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -22,7 +22,7 @@
#include <map>
#include <vector>
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
#include "path.hxx"
#include "pathfinder.hxx"
#include "graph.hxx"
Modified: branches/pingus_sdl/src/worldmap/pingus.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/pingus.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/worldmap/pingus.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -19,7 +19,7 @@
#include <iostream>
#include <math.h>
-#include "../vector.hxx"
+#include "../math/vector3f.hpp"
#include "../display/drawing_context.hxx"
#include "dot.hxx"
#include "../math.hxx"
@@ -54,7 +54,7 @@
// standing one
if (final_target_node != NoNode && current_node == NoNode)
{
- gc.draw(arrow, path->get_dot(final_target_node)->get_pos() + Vector(0,
0, 10));
+ gc.draw(arrow, path->get_dot(final_target_node)->get_pos() + Vector3f(0,
0, 10));
}
if (!is_walking())
@@ -67,9 +67,9 @@
float direction = get_direction();
if (direction >= 0 && direction < 180)
- gc.draw(sprite[Direction::RIGHT], pos + Vector(0, 0, 10));
+ gc.draw(sprite[Direction::RIGHT], pos + Vector3f(0, 0, 10));
else
- gc.draw(sprite[Direction::LEFT], pos + Vector(0, 0, 10));
+ gc.draw(sprite[Direction::LEFT], pos + Vector3f(0, 0, 10));
}
}
@@ -211,7 +211,7 @@
}
}
-Vector
+Vector3f
Pingus::calc_pos ()
{
if (current_node != NoNode) // pingu stands still
Modified: branches/pingus_sdl/src/worldmap/pingus.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/pingus.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/worldmap/pingus.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -34,8 +34,8 @@
private:
PathGraph* path;
StateSprite sprite;
- CL_Sprite sprite_standing;
- CL_Sprite arrow;
+ Sprite sprite_standing;
+ Sprite arrow;
/** The node on which the pingu currently stands, NoNode if the pingu is
currently on the move to another node */
@@ -72,11 +72,11 @@
float edge_path_position;
/** Current position of the pingu, only for caching purpose */
- Vector pos;
+ Vector3f pos;
/** The position the pingu had before his current position, used to
calculate its current direction */
- Vector last_pos;
+ Vector3f last_pos;
public:
/** */
@@ -101,7 +101,7 @@
void set_position (NodeId node);
/** return the current position in world coordinates */
- Vector get_pos() const { return pos; }
+ Vector3f get_pos() const { return pos; }
private:
/** Calculate the direction in which the pingu is heading, return
@@ -109,7 +109,7 @@
float get_direction() const;
/** calculate the position of the pingu */
- Vector calc_pos ();
+ Vector3f calc_pos ();
void update_walk (float delta);
@@ -118,7 +118,7 @@
float calc_edge_path_length();
/** */
- Vector interpolate(const Vector& a, const Vector& b, float perc);
+ Vector3f interpolate(const Vector3f& a, const Vector3f& b, float perc);
Pingus (const Pingus&);
Pingus& operator= (const Pingus&);
Modified: branches/pingus_sdl/src/worldmap/sprite_drawable.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/sprite_drawable.hxx 2007-01-15
02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/worldmap/sprite_drawable.hxx 2007-01-15
13:49:02 UTC (rev 2655)
@@ -20,8 +20,8 @@
#ifndef HEADER_SPRITE_DRAWABLE_HXX
#define HEADER_SPRITE_DRAWABLE_HXX
-#include <ClanLib/Display/sprite.h>
-#include "../vector.hxx"
+#include "../sprite.hpp"
+#include "../math/vector3f.hpp"
#include "drawable.hxx"
namespace WorldMapNS {
@@ -30,8 +30,8 @@
class SpriteDrawable : public Drawable
{
private:
- CL_Sprite sprite;
- Vector pos;
+ Sprite sprite;
+ Vector3f pos;
public:
SpriteDrawable(FileReader reader);
Modified: branches/pingus_sdl/src/worldmap/surface_drawable.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/surface_drawable.cxx 2007-01-15
02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/worldmap/surface_drawable.cxx 2007-01-15
13:49:02 UTC (rev 2655)
@@ -54,7 +54,7 @@
{
if (auto_uncover)
{
- Vector pingus_pos =
WorldMapManager::instance()->get_worldmap()->get_pingus()->get_pos();
+ Vector3f pingus_pos =
WorldMapManager::instance()->get_worldmap()->get_pingus()->get_pos();
// Pingu is not over the surface
if (!(pingus_pos.x > pos.x && pingus_pos.x < pos.x +
surface.get_width()
&&
Modified: branches/pingus_sdl/src/worldmap/surface_drawable.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/surface_drawable.hxx 2007-01-15
02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/worldmap/surface_drawable.hxx 2007-01-15
13:49:02 UTC (rev 2655)
@@ -20,8 +20,8 @@
#ifndef HEADER_SURFACE_DRAWABLE_HXX
#define HEADER_SURFACE_DRAWABLE_HXX
-#include <ClanLib/Display/sprite.h>
-#include "../vector.hxx"
+#include "../sprite.hpp"
+#include "../math/vector3f.hpp"
#include "drawable.hxx"
namespace WorldMapNS {
@@ -30,8 +30,8 @@
class SurfaceDrawable : public Drawable
{
private:
- CL_Sprite surface;
- Vector pos;
+ Sprite surface;
+ Vector3f pos;
/** If set to true the surface will disappear if the pingu gets
covered by it, so that the Pingu can travel into caves and other
things, while the roof will disapear */
Modified: branches/pingus_sdl/src/worldmap/world_dot.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/world_dot.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/world_dot.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -41,6 +41,5 @@
}
} // WorldMapNS namespace
-} // Pingus namespace
/* EOF */
Modified: branches/pingus_sdl/src/worldmap/world_dot.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/world_dot.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/world_dot.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -39,7 +39,7 @@
virtual void draw(DrawingContext& gc) { UNUSED_ARG(gc); }
virtual void update(float delta) { UNUSED_ARG(delta); }
- Vector get_pos() { return pos; }
+ Vector3f get_pos() { return pos; }
virtual void on_click() { }
@@ -55,7 +55,6 @@
}; // WorldDot class
} // WorldMapNS namespace
-} // Pingus namespace
#endif
Modified: branches/pingus_sdl/src/worldmap/worldmap.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/worldmap.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -19,9 +19,7 @@
#include <assert.h>
#include <iostream>
-#include <ClanLib/core.h>
-#include <ClanLib/Display/display.h>
-#include <ClanLib/Display/mouse.h>
+#include "../gui/display.hxx"
#include "../fonts.hxx"
#include "../path_manager.hxx"
#include "../stat_manager.hxx"
@@ -33,8 +31,10 @@
#include "../pingus_error.hxx"
#include "../gettext.h"
#include "../globals.hxx"
-#include "../xml_file_reader.hxx"
+#include "../sexpr_file_reader.hpp"
#include "../debug.hxx"
+#include "../lisp/parser.hpp"
+#include "../lisp/lisp.hpp"
#include "worldmap.hxx"
#include "worldmap_story.hxx"
#include "metamap.hxx"
@@ -58,17 +58,25 @@
mouse_x(0),
mouse_y(0)
{
+#if 0
CL_InputSourceProvider_File provider(".");
CL_DomDocument doc(provider.open_source(filename), true);
CL_DomElement root = doc.get_document_element();
- parse_file(XMLFileReader(root));
+ parse_file(XMLFileReader(root));
+#endif
+ lisp::Lisp* sexpr = lisp::Parser::parse(filename);
+ if (sexpr)
+ {
+ parse_file(SExprFileReader(sexpr->get_list_elem(0)));
+ }
+
pingus = new Pingus(path_graph);
- set_starting_node();
+ set_starting_node();
add_drawable(pingus);
levelname_bg = Resource::load_sprite("core/worldmap/levelname_bg");
- gc_state.set_limit(CL_Rect(CL_Point(0, 0), CL_Size(width, height)));
+ gc_state.set_limit(Rect(Vector2i(0, 0), Size(width, height)));
}
WorldMap::~WorldMap()
@@ -77,8 +85,8 @@
{
delete (*i);
}
- delete intro_story;
- delete end_story;
+ delete intro_story;
+ delete end_story;
delete path_graph;
}
@@ -90,8 +98,8 @@
parse_graph(reader.read_section("graph"));
parse_objects(reader.read_section("objects"));
parse_properties(reader.read_section("head"));
- intro_story = new
WorldMapStory(reader.read_section("intro_story"));
- end_story = new
WorldMapStory(reader.read_section("end_story"));
+ intro_story = new WorldMapStory(reader.read_section("intro_story"));
+ end_story = new WorldMapStory(reader.read_section("end_story"));
}
else
{
@@ -135,26 +143,26 @@
void
WorldMap::parse_properties(FileReader reader)
{
- reader.read_string("music", music);
- reader.read_string("author", author);
- reader.read_string("name", name);
- reader.read_string("short-name", short_name);
- reader.read_string("email", email);
- reader.read_int("width", width);
- reader.read_int("height", height);
+ reader.read_string("music", music);
+ reader.read_string("author", author);
+ reader.read_string("name", name);
+ reader.read_string("short-name", short_name);
+ reader.read_string("email", email);
+ reader.read_int("width", width);
+ reader.read_int("height", height);
- // 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);
+ // 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
WorldMap::draw (DrawingContext& gc)
{
- Vector pingu_pos = pingus->get_pos();
+ Vector3f pingu_pos = pingus->get_pos();
pingu_pos.x = Math::mid(float(gc.get_width()/2),
pingu_pos.x,
@@ -166,15 +174,15 @@
DrawingContext* display_gc = new DrawingContext();
- gc_state.set_pos(CL_Pointf(pingu_pos.x, pingu_pos.y));
+ gc_state.set_pos(Vector2f(pingu_pos.x, pingu_pos.y));
gc_state.push(*display_gc);
- // Blank out the screen in case the screen resolution is larger than
- // the worldmap picture.
- // FIXME: Should probably scale everything to match the resolution
instead.
- gc.draw_fillrect(0, 0, (float)CL_Display::get_width(),
(float)CL_Display::get_height(),
- CL_Color::black, -15000);
+ // Blank out the screen in case the screen resolution is larger than
+ // the worldmap picture.
+ // FIXME: Should probably scale everything to match the resolution instead.
+ gc.draw_fillrect(0, 0, (float)Display::get_width(),
(float)Display::get_height(),
+ Color(0,0,0), -15000);
for (DrawableLst::iterator i = drawables.begin (); i != drawables.end ();
++i)
{
@@ -182,7 +190,7 @@
}
gc.draw(levelname_bg,
- Vector(gc.get_width()/2 - levelname_bg.get_width()/2,
+ Vector3f(gc.get_width()/2 - levelname_bg.get_width()/2,
gc.get_height() - levelname_bg.get_height()));
if (pingus->get_node() != NoNode)
@@ -207,13 +215,13 @@
}
else
{
- gc.print_center(Fonts::chalk_small,
- display_gc->get_width ()/2,
- display_gc->get_height() - 20,
- _("...walking..."));
+ gc.print_center(Fonts::chalk_small,
+ display_gc->get_width ()/2,
+ display_gc->get_height() - 20,
+ _("...walking..."));
}
- Vector mpos = display_gc->screen_to_world(Vector((float)mouse_x,
(float)mouse_y));
+ Vector3f mpos = display_gc->screen_to_world(Vector3f((float)mouse_x,
(float)mouse_y));
Dot* dot = path_graph->get_dot(mpos.x, mpos.y);
if (dot)
{
@@ -236,7 +244,7 @@
void
WorldMap::on_startup()
{
- Sound::PingusSound::play_music(music);
+ Sound::PingusSound::play_music(music);
update_locked_nodes();
}
@@ -268,7 +276,7 @@
void
WorldMap::on_primary_button_press(int x, int y)
{
- CL_Pointf click_pos = gc_state.screen2world(CL_Point(x, y));
+ Vector2f click_pos = gc_state.screen2world(Vector2i(x, y));
if (pingus_debug_flags & PINGUS_DEBUG_WORLDMAP)
{
@@ -325,7 +333,7 @@
{
if (maintainer_mode)
{
- CL_Pointf click_pos = gc_state.screen2world(CL_Point(x, y));
+ Vector3f click_pos = gc_state.screen2world(Vector2i(x, y));
Dot* dot = path_graph->get_dot(click_pos.x, click_pos.y);
if (dot)
@@ -391,15 +399,14 @@
if (!credits_unlocked)
{
- // See if the last level is finished
- Dot* dot = path_graph->get_dot(final_node);
+ // See if the last level is finished
+ Dot* dot = path_graph->get_dot(final_node);
if (dot)
{
if (dot->finished())
{
-
WorldMapManager::instance()->get_metamap()->finish_node(short_name);
- ScreenManager::instance()->replace_screen(
- new
StoryScreen(get_end_story()), true);
+
WorldMapManager::instance()->get_metamap()->finish_node(short_name);
+ ////ScreenManager::instance()->replace_screen(new
StoryScreen(get_end_story()), true);
}
}
else
@@ -413,31 +420,31 @@
void
WorldMap::set_starting_node()
{
- // See if the user has played this map before. If not, use the
<default-node>
- // tag from the XML file.
- NodeId id;
- std::string node_name;
+ // See if the user has played this map before. If not, use the
<default-node>
+ // tag from the XML file.
+ NodeId id;
+ std::string node_name;
- if (StatManager::instance()->get_string(short_name + "-current-node",
node_name))
- {
- // Just in case that level doesn't exist, look it up.
- id = path_graph->lookup_node(node_name);
- if (id == NoNode)
- id = default_node;
- }
- else
- id = default_node;
+ if (StatManager::instance()->get_string(short_name + "-current-node",
node_name))
+ {
+ // Just in case that level doesn't exist, look it up.
+ id = path_graph->lookup_node(node_name);
+ if (id == NoNode)
+ id = default_node;
+ }
+ else
+ id = default_node;
- pingus->set_position(id);
+ pingus->set_position(id);
- LevelDot* leveldot = dynamic_cast<LevelDot*>(path_graph->get_dot(id));
- leveldot->unlock();
+ LevelDot* leveldot = dynamic_cast<LevelDot*>(path_graph->get_dot(id));
+ leveldot->unlock();
}
bool
WorldMap::is_final_map()
{
- return
(WorldMapManager::instance()->get_metamap()->get_final_worldmap() ==
short_name);
+ return (WorldMapManager::instance()->get_metamap()->get_final_worldmap() ==
short_name);
}
} // namespace WorldMapNS
Modified: branches/pingus_sdl/src/worldmap/worldmap.hxx
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap.hxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/worldmap.hxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -21,15 +21,12 @@
#define HEADER_PINGUS_WORLDMAP_WORLDMAP_HXX
#include <vector>
+#include "../sprite.hpp"
#include "../file_reader.hxx"
#include "../display/drawing_context.hxx"
#include "../graphic_context_state.hxx"
-class CL_Key;
-class CL_Font;
-class CL_InputDevice;
-
-
+class Font;
class DrawingContext;
namespace WorldMapNS {
@@ -50,7 +47,7 @@
class WorldMap
{
private:
- CL_Sprite levelname_bg;
+ Sprite levelname_bg;
/** name of the file to parse */
std::string filename;
Modified: branches/pingus_sdl/src/worldmap/worldmap_story.cxx
===================================================================
--- branches/pingus_sdl/src/worldmap/worldmap_story.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/worldmap/worldmap_story.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -67,6 +67,5 @@
}
} // namespace WorldMapNS
-} // namespace Pingus
/* EOF */
Modified: branches/pingus_sdl/src/xml_file_reader.cxx
===================================================================
--- branches/pingus_sdl/src/xml_file_reader.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/xml_file_reader.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -28,7 +28,7 @@
#include "vector.hxx"
#include "res_descriptor.hxx"
#include "resource_modifier.hxx"
-#include "xml_file_reader.hxx"
+////#include "xml_file_reader.hxx"
class XMLFileReaderImpl : public FileReaderImpl
Modified: branches/pingus_sdl/src/xml_file_reader.hxx
===================================================================
--- branches/pingus_sdl/src/xml_file_reader.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/xml_file_reader.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -23,7 +23,6 @@
#include <ClanLib/Core/XML/dom_element.h>
#include "file_reader.hxx"
-
/** */
class XMLFileReader : public FileReader
{
Modified: branches/pingus_sdl/src/xml_file_writer.cxx
===================================================================
--- branches/pingus_sdl/src/xml_file_writer.cxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/xml_file_writer.cxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -20,7 +20,7 @@
#include <iostream>
#include <map>
#include "vector.hxx"
-#include "xml_file_writer.hxx"
+///#include "xml_file_writer.hxx"
XMLFileWriter::XMLFileWriter(std::ostream& out_)
Modified: branches/pingus_sdl/src/xml_file_writer.hxx
===================================================================
--- branches/pingus_sdl/src/xml_file_writer.hxx 2007-01-15 02:58:45 UTC (rev
2654)
+++ branches/pingus_sdl/src/xml_file_writer.hxx 2007-01-15 13:49:02 UTC (rev
2655)
@@ -22,7 +22,7 @@
#include <stack>
#include <iosfwd>
-#include <ClanLib/Display/color.h>
+#include "math/color.hpp"
#include "file_writer.hxx"
Modified: branches/pingus_sdl/src/xml_pdf.cxx
===================================================================
--- branches/pingus_sdl/src/xml_pdf.cxx 2007-01-15 02:58:45 UTC (rev 2654)
+++ branches/pingus_sdl/src/xml_pdf.cxx 2007-01-15 13:49:02 UTC (rev 2655)
@@ -24,7 +24,7 @@
#include "pingus_error.hxx"
#include "path_manager.hxx"
#include "xml_pingus_level.hxx"
-#include "xml_file_reader.hxx"
+////#include "xml_file_reader.hxx"
#include "xml_pdf.hxx"
Modified: branches/pingus_sdl/src/xml_pingus_level.cxx
===================================================================
--- branches/pingus_sdl/src/xml_pingus_level.cxx 2007-01-15 02:58:45 UTC
(rev 2654)
+++ branches/pingus_sdl/src/xml_pingus_level.cxx 2007-01-15 13:49:02 UTC
(rev 2655)
@@ -28,7 +28,7 @@
#include <ClanLib/Core/XML/dom_named_node_map.h>
#include <ClanLib/Core/XML/dom_element.h>
#include "pingus_error.hxx"
-#include "xml_file_reader.hxx"
+////#include "xml_file_reader.hxx"
#include "pingus_level_impl.hxx"
#include "xml_pingus_level.hxx"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2655 - in branches/pingus_sdl/src: . display gui math worldmap,
grumbel at BerliOS <=