[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4060 - in trunk/pingus/src: editor engine/display pingus p
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4060 - in trunk/pingus/src: editor engine/display pingus pingus/components pingus/worldmap |
Date: |
Fri, 6 Nov 2009 20:19:17 +0100 |
Author: grumbel
Date: 2009-11-06 20:19:16 +0100 (Fri, 06 Nov 2009)
New Revision: 4060
Added:
trunk/pingus/src/engine/display/graphic_context_state.cpp
trunk/pingus/src/engine/display/graphic_context_state.hpp
Removed:
trunk/pingus/src/pingus/graphic_context_state.cpp
Modified:
trunk/pingus/src/editor/viewport.cpp
trunk/pingus/src/editor/viewport.hpp
trunk/pingus/src/engine/display/display.hpp
trunk/pingus/src/pingus/components/playfield.hpp
trunk/pingus/src/pingus/worldmap/worldmap.hpp
Log:
Moved GraphicContextState to engine/display/
Modified: trunk/pingus/src/editor/viewport.cpp
===================================================================
--- trunk/pingus/src/editor/viewport.cpp 2009-11-06 19:18:51 UTC (rev
4059)
+++ trunk/pingus/src/editor/viewport.cpp 2009-11-06 19:19:16 UTC (rev
4060)
@@ -20,14 +20,15 @@
#include <vector>
#include <string>
#include <iostream>
-#include "engine/gui/gui_manager.hpp"
+
+#include "editor/editor_level.hpp"
+#include "editor/editor_screen.hpp"
+#include "editor/level_objs.hpp"
#include "engine/display/display.hpp"
#include "engine/display/drawing_context.hpp"
+#include "engine/display/graphic_context_state.hpp"
+#include "engine/gui/gui_manager.hpp"
#include "math/vector3f.hpp"
-#include "pingus/graphic_context_state.hpp"
-#include "editor/editor_level.hpp"
-#include "editor/editor_screen.hpp"
-#include "editor/level_objs.hpp"
namespace Editor {
Modified: trunk/pingus/src/editor/viewport.hpp
===================================================================
--- trunk/pingus/src/editor/viewport.hpp 2009-11-06 19:18:51 UTC (rev
4059)
+++ trunk/pingus/src/editor/viewport.hpp 2009-11-06 19:19:16 UTC (rev
4060)
@@ -18,12 +18,13 @@
#ifndef HEADER_PINGUS_EDITOR_VIEWPORT_HPP
#define HEADER_PINGUS_EDITOR_VIEWPORT_HPP
-#include "engine/gui/rect_component.hpp"
-#include "pingus/graphic_context_state.hpp"
#include <boost/signal.hpp>
#include <vector>
#include <string>
+#include "engine/display/graphic_context_state.hpp"
+#include "engine/gui/rect_component.hpp"
+
class DrawingContext;
class SceneContext;
Modified: trunk/pingus/src/engine/display/display.hpp
===================================================================
--- trunk/pingus/src/engine/display/display.hpp 2009-11-06 19:18:51 UTC (rev
4059)
+++ trunk/pingus/src/engine/display/display.hpp 2009-11-06 19:19:16 UTC (rev
4060)
@@ -20,6 +20,7 @@
#include <memory>
#include <list>
#include <vector>
+
#include "math/size.hpp"
class Vector2i;
Copied: trunk/pingus/src/engine/display/graphic_context_state.cpp (from rev
4054, trunk/pingus/src/pingus/graphic_context_state.cpp)
===================================================================
--- trunk/pingus/src/pingus/graphic_context_state.cpp 2009-11-06 13:58:44 UTC
(rev 4054)
+++ trunk/pingus/src/engine/display/graphic_context_state.cpp 2009-11-06
19:19:16 UTC (rev 4060)
@@ -0,0 +1,182 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2004 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "engine/display/graphic_context_state.hpp"
+
+#include "math/math.hpp"
+#include "engine/display/display.hpp"
+
+class GraphicContextStateImpl
+{
+public:
+ Rect rect;
+ Vector2i offset;
+
+ bool have_limit;
+ Rect limit;
+
+ GraphicContextStateImpl() :
+ rect(),
+ offset(),
+ have_limit(),
+ limit()
+ {}
+};
+
+GraphicContextState::GraphicContextState()
+ : impl(new GraphicContextStateImpl())
+{
+ impl->rect = Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height()));
+ impl->offset = Vector2i(0,0);
+ impl->have_limit = false;
+}
+
+GraphicContextState::GraphicContextState(int w, int h)
+ : impl(new GraphicContextStateImpl())
+{
+ impl->rect = Rect(Vector2i(0,0), Size(w, h));
+ impl->offset = Vector2i(0,0);
+ impl->have_limit = false;
+}
+
+GraphicContextState::GraphicContextState(const Rect& rect)
+ : impl(new GraphicContextStateImpl())
+{
+ impl->rect = rect;
+ impl->offset = Vector2i(0,0);
+ impl->have_limit = false;
+}
+
+void
+GraphicContextState::set_limit(const Rect& limit)
+{
+ impl->have_limit = true;
+ impl->limit = limit;
+}
+
+void
+GraphicContextState::set_unlimited()
+{
+ impl->have_limit = false;
+}
+
+void
+GraphicContextState::set_size(int w, int h)
+{
+ impl->rect = Rect(Vector2i(impl->rect.left, impl->rect.top), Size(w, h));
+}
+
+void
+GraphicContextState::push(DrawingContext& gc)
+{
+ gc.push_modelview();
+
+ gc.translate(impl->rect.left, impl->rect.top);
+ gc.translate(impl->offset.x, impl->offset.y);
+}
+
+void
+GraphicContextState::push(SceneContext& gc)
+{
+ gc.push_modelview();
+
+ gc.translate(impl->rect.left, impl->rect.top);
+ gc.translate(impl->offset.x, impl->offset.y);
+}
+
+void
+GraphicContextState::pop (SceneContext& gc)
+{
+ gc.pop_modelview();
+}
+
+void
+GraphicContextState::pop (DrawingContext& gc)
+{
+ gc.pop_modelview();
+}
+
+Rect
+GraphicContextState::get_clip_rect()
+{
+ return Rect(-impl->offset, impl->rect.get_size());
+}
+
+void
+GraphicContextState::set_pos(const Vector2i& pos)
+{
+ impl->offset.x = -pos.x + (get_width()/2);
+ impl->offset.y = -pos.y + (get_height()/2);
+
+ if (impl->have_limit)
+ {
+ if (-impl->offset.x < impl->limit.left)
+ {
+ impl->offset.x = -(impl->limit.left);
+ }
+ else if (-impl->offset.x + get_width() > impl->limit.right)
+ {
+ if (impl->limit.right - impl->limit.left > get_width())
+ impl->offset.x = -(impl->limit.right - get_width());
+ else
+ impl->offset.x = -(impl->limit.left);
+ }
+
+ if (-impl->offset.y < impl->limit.top)
+ {
+ impl->offset.y = -(impl->limit.top);
+ }
+ else if (-impl->offset.y + get_height() > impl->limit.bottom)
+ {
+ if (impl->limit.bottom - impl->limit.top > get_height())
+ impl->offset.y = -(impl->limit.bottom - get_height());
+ else
+ impl->offset.y = -(impl->limit.top);
+ }
+ }
+}
+
+Vector2i
+GraphicContextState::get_pos() const
+{
+ return Vector2i(-impl->offset.x + (get_width()/2),
+ -impl->offset.y + (get_height()/2));
+}
+
+Vector2i
+GraphicContextState::screen2world(const Vector2i& pos_) const
+{
+ Vector2i pos(pos_.x - impl->rect.left,
+ pos_.y - impl->rect.top);
+
+ return pos
+ - Vector2i(impl->rect.left, impl->rect.top)
+ - impl->offset;
+}
+
+int
+GraphicContextState::get_width() const
+{
+ return impl->rect.get_width();
+}
+
+int
+GraphicContextState::get_height() const
+{
+ return impl->rect.get_height();
+}
+
+/* EOF */
Copied: trunk/pingus/src/engine/display/graphic_context_state.hpp (from rev
4054, trunk/pingus/src/pingus/graphic_context_state.hpp)
===================================================================
--- trunk/pingus/src/pingus/graphic_context_state.hpp 2009-11-06 13:58:44 UTC
(rev 4054)
+++ trunk/pingus/src/engine/display/graphic_context_state.hpp 2009-11-06
19:19:16 UTC (rev 4060)
@@ -0,0 +1,74 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2004 Ingo Ruhnke <address@hidden>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_PINGUS_ENGINE_DISPLAY_GRAPHIC_CONTEXT_STATE_HPP
+#define HEADER_PINGUS_ENGINE_DISPLAY_GRAPHIC_CONTEXT_STATE_HPP
+
+#include <boost/shared_ptr.hpp>
+
+#include "math/rect.hpp"
+#include "math/vector3f.hpp"
+#include "math/vector2i.hpp"
+#include "math/vector2f.hpp"
+#include "engine/display/drawing_context.hpp"
+#include "engine/display/scene_context.hpp"
+
+class GraphicContextStateImpl;
+
+/** Helper class for capturing the state of a GraphicContext, with
+ additional convenience functions to make handling GraphicContexts
+ easier */
+class GraphicContextState
+{
+public:
+ GraphicContextState();
+ GraphicContextState(int w, int h);
+ GraphicContextState(const Rect& rect);
+
+ /** 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 Rect& limit);
+ void set_unlimited();
+
+ void set_size(int w, int h);
+
+ void push(DrawingContext& gc);
+ void pop (DrawingContext& gc);
+
+ void push(SceneContext& gc);
+ void pop (SceneContext& gc);
+
+ /** Return a rectangle in world coordinates that represents the area
+ visible on the screen */
+ Rect get_clip_rect();
+
+ int get_width() const;
+ int get_height() const;
+
+ /** Move the center of the visible area to pos */
+ void set_pos(const Vector2i& pos);
+ Vector2i get_pos() const;
+
+ Vector2i screen2world(const Vector2i& pos) const;
+
+private:
+ boost::shared_ptr<GraphicContextStateImpl> impl;
+};
+
+#endif
+
+/* EOF */
Modified: trunk/pingus/src/pingus/components/playfield.hpp
===================================================================
--- trunk/pingus/src/pingus/components/playfield.hpp 2009-11-06 19:18:51 UTC
(rev 4059)
+++ trunk/pingus/src/pingus/components/playfield.hpp 2009-11-06 19:19:16 UTC
(rev 4060)
@@ -18,7 +18,8 @@
#define HEADER_PINGUS_PINGUS_COMPONENTS_PLAYFIELD_HPP
#include <memory>
-#include "pingus/graphic_context_state.hpp"
+
+#include "engine/display/graphic_context_state.hpp"
#include "engine/gui/rect_component.hpp"
#include "pingus/capture_rectangle.hpp"
Deleted: trunk/pingus/src/pingus/graphic_context_state.cpp
===================================================================
--- trunk/pingus/src/pingus/graphic_context_state.cpp 2009-11-06 19:18:51 UTC
(rev 4059)
+++ trunk/pingus/src/pingus/graphic_context_state.cpp 2009-11-06 19:19:16 UTC
(rev 4060)
@@ -1,182 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2004 Ingo Ruhnke <address@hidden>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/graphic_context_state.hpp"
-
-#include "math/math.hpp"
-#include "engine/display/display.hpp"
-
-class GraphicContextStateImpl
-{
-public:
- Rect rect;
- Vector2i offset;
-
- bool have_limit;
- Rect limit;
-
- GraphicContextStateImpl() :
- rect(),
- offset(),
- have_limit(),
- limit()
- {}
-};
-
-GraphicContextState::GraphicContextState()
- : impl(new GraphicContextStateImpl())
-{
- impl->rect = Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height()));
- impl->offset = Vector2i(0,0);
- impl->have_limit = false;
-}
-
-GraphicContextState::GraphicContextState(int w, int h)
- : impl(new GraphicContextStateImpl())
-{
- impl->rect = Rect(Vector2i(0,0), Size(w, h));
- impl->offset = Vector2i(0,0);
- impl->have_limit = false;
-}
-
-GraphicContextState::GraphicContextState(const Rect& rect)
- : impl(new GraphicContextStateImpl())
-{
- impl->rect = rect;
- impl->offset = Vector2i(0,0);
- impl->have_limit = false;
-}
-
-void
-GraphicContextState::set_limit(const Rect& limit)
-{
- impl->have_limit = true;
- impl->limit = limit;
-}
-
-void
-GraphicContextState::set_unlimited()
-{
- impl->have_limit = false;
-}
-
-void
-GraphicContextState::set_size(int w, int h)
-{
- impl->rect = Rect(Vector2i(impl->rect.left, impl->rect.top), Size(w, h));
-}
-
-void
-GraphicContextState::push(DrawingContext& gc)
-{
- gc.push_modelview();
-
- gc.translate(impl->rect.left, impl->rect.top);
- gc.translate(impl->offset.x, impl->offset.y);
-}
-
-void
-GraphicContextState::push(SceneContext& gc)
-{
- gc.push_modelview();
-
- gc.translate(impl->rect.left, impl->rect.top);
- gc.translate(impl->offset.x, impl->offset.y);
-}
-
-void
-GraphicContextState::pop (SceneContext& gc)
-{
- gc.pop_modelview();
-}
-
-void
-GraphicContextState::pop (DrawingContext& gc)
-{
- gc.pop_modelview();
-}
-
-Rect
-GraphicContextState::get_clip_rect()
-{
- return Rect(-impl->offset, impl->rect.get_size());
-}
-
-void
-GraphicContextState::set_pos(const Vector2i& pos)
-{
- impl->offset.x = -pos.x + (get_width()/2);
- impl->offset.y = -pos.y + (get_height()/2);
-
- if (impl->have_limit)
- {
- if (-impl->offset.x < impl->limit.left)
- {
- impl->offset.x = -(impl->limit.left);
- }
- else if (-impl->offset.x + get_width() > impl->limit.right)
- {
- if (impl->limit.right - impl->limit.left > get_width())
- impl->offset.x = -(impl->limit.right - get_width());
- else
- impl->offset.x = -(impl->limit.left);
- }
-
- if (-impl->offset.y < impl->limit.top)
- {
- impl->offset.y = -(impl->limit.top);
- }
- else if (-impl->offset.y + get_height() > impl->limit.bottom)
- {
- if (impl->limit.bottom - impl->limit.top > get_height())
- impl->offset.y = -(impl->limit.bottom - get_height());
- else
- impl->offset.y = -(impl->limit.top);
- }
- }
-}
-
-Vector2i
-GraphicContextState::get_pos() const
-{
- return Vector2i(-impl->offset.x + (get_width()/2),
- -impl->offset.y + (get_height()/2));
-}
-
-Vector2i
-GraphicContextState::screen2world(const Vector2i& pos_) const
-{
- Vector2i pos(pos_.x - impl->rect.left,
- pos_.y - impl->rect.top);
-
- return pos
- - Vector2i(impl->rect.left, impl->rect.top)
- - impl->offset;
-}
-
-int
-GraphicContextState::get_width() const
-{
- return impl->rect.get_width();
-}
-
-int
-GraphicContextState::get_height() const
-{
- return impl->rect.get_height();
-}
-
-/* EOF */
Modified: trunk/pingus/src/pingus/worldmap/worldmap.hpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap.hpp 2009-11-06 19:18:51 UTC
(rev 4059)
+++ trunk/pingus/src/pingus/worldmap/worldmap.hpp 2009-11-06 19:19:16 UTC
(rev 4060)
@@ -18,11 +18,12 @@
#define HEADER_PINGUS_PINGUS_WORLDMAP_WORLDMAP_HPP
#include <vector>
+
+#include "engine/display/drawing_context.hpp"
+#include "engine/display/graphic_context_state.hpp"
#include "engine/display/sprite.hpp"
+#include "pingus/worldmap/pingus_worldmap.hpp"
#include "util/file_reader.hpp"
-#include "engine/display/drawing_context.hpp"
-#include "pingus/graphic_context_state.hpp"
-#include "pingus/worldmap/pingus_worldmap.hpp"
class Font;
class DrawingContext;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4060 - in trunk/pingus/src: editor engine/display pingus pingus/components pingus/worldmap,
grumbel at BerliOS <=