[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3146 - in trunk/pingus/src: . editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3146 - in trunk/pingus/src: . editor |
Date: |
Fri, 14 Sep 2007 20:21:08 +0200 |
Author: grumbel
Date: 2007-09-14 20:21:07 +0200 (Fri, 14 Sep 2007)
New Revision: 3146
Modified:
trunk/pingus/src/editor/object_selector_list.cpp
trunk/pingus/src/resource.cpp
trunk/pingus/src/sprite.cpp
trunk/pingus/src/sprite.hpp
Log:
- limit thumbnailing to sprites larger then 48x48
- ObjectSelector drops now happen with the object centered to the mousepointer,
not top/left
Modified: trunk/pingus/src/editor/object_selector_list.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector_list.cpp 2007-09-14 16:33:50 UTC
(rev 3145)
+++ trunk/pingus/src/editor/object_selector_list.cpp 2007-09-14 18:21:07 UTC
(rev 3146)
@@ -189,9 +189,7 @@
Color(155,155,155), 10000);
}
- gc.draw((*i)->thumbnail,
- Vector2i(x * 48 + std::max(0, (48 -
(*i)->sprite.get_width())/2),
- y * 48 + std::max(0, (48 -
(*i)->sprite.get_height())/2)));
+ gc.draw((*i)->thumbnail, Vector2i(x * 48, y * 48));
++i;
}
else
@@ -208,7 +206,10 @@
if (mode == OBJECT_DRAG)
{
- parent_gc.draw(objects[current_object]->sprite, real_mouse_pos, 2000.0f);
+ parent_gc.draw(objects[current_object]->sprite,
+ real_mouse_pos -
Vector2i(objects[current_object]->sprite.get_width()/2,
+
objects[current_object]->sprite.get_height()/2),
+ 2000.0f);
}
}
@@ -238,9 +239,14 @@
if (!object_selector->get_rect().is_inside(Vector2i(x +
object_selector->get_rect().left,
y +
object_selector->get_rect().top)))
{
- LevelObj* obj =
objects[current_object]->create(editor->get_viewport()->screen2world(x +
object_selector->get_rect().left,
-
y + object_selector->get_rect().top),
-
editor->get_level()->get_level_impl());
+ Vector2i p = editor->get_viewport()->screen2world(x +
object_selector->get_rect().left,
+ y +
object_selector->get_rect().top);
+
+ // place object with left/top instead of center origin
+ p -= Vector2i(objects[current_object]->sprite.get_width()/2,
+ objects[current_object]->sprite.get_height()/2);
+
+ LevelObj* obj = objects[current_object]->create(p,
editor->get_level()->get_level_impl());
if (obj)
editor->add_object(obj);
else
Modified: trunk/pingus/src/resource.cpp
===================================================================
--- trunk/pingus/src/resource.cpp 2007-09-14 16:33:50 UTC (rev 3145)
+++ trunk/pingus/src/resource.cpp 2007-09-14 18:21:07 UTC (rev 3146)
@@ -363,7 +363,22 @@
Resource::load_thumb_sprite(const std::string& name)
{
Sprite sprite = Resource::load_sprite(name);
- sprite.scale(48,48);
+
+ Size thumb_size;
+ if (sprite.get_width() <= 48)
+ thumb_size.width = sprite.get_width();
+ else
+ thumb_size.width = 48;
+
+ if (sprite.get_height() <= 48)
+ thumb_size.height = sprite.get_height();
+ else
+ thumb_size.height = 48;
+
+ sprite.scale(thumb_size.width, thumb_size.height);
+
+ sprite.set_hotspot(origin_top_left, (48 - sprite.get_width())/2, (48 -
sprite.get_height())/2);
+
return sprite;
}
Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2007-09-14 16:33:50 UTC (rev 3145)
+++ trunk/pingus/src/sprite.cpp 2007-09-14 18:21:07 UTC (rev 3146)
@@ -450,6 +450,13 @@
}
void
+Sprite::set_hotspot(Origin origin, int x, int y)
+{
+ // FIXME: offset and other stuff should be member of the Sprite, not the
SpriteImpl
+ impl->offset = calc_origin(origin, impl->frame_size) - Vector2i(x, y);
+}
+
+void
Sprite::optimize()
{
impl->optimize();
Modified: trunk/pingus/src/sprite.hpp
===================================================================
--- trunk/pingus/src/sprite.hpp 2007-09-14 16:33:50 UTC (rev 3145)
+++ trunk/pingus/src/sprite.hpp 2007-09-14 18:21:07 UTC (rev 3146)
@@ -22,6 +22,7 @@
#include <string>
#include <boost/shared_ptr.hpp>
+#include "math/origin.hpp"
#include "SDL.h"
class Color;
@@ -46,6 +47,7 @@
void update(float delta = 0.033f);
void draw(float x, float y, SDL_Surface* target);
+ void set_hotspot(Origin origin, int x, int y);
void set_frame(int i);
int get_frame_count() const;
int get_current_frame() const;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3146 - in trunk/pingus/src: . editor,
grumbel at BerliOS <=