[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3129 - trunk/pingus/src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3129 - trunk/pingus/src/editor |
Date: |
Wed, 12 Sep 2007 04:36:50 +0200 |
Author: grumbel
Date: 2007-09-12 04:36:49 +0200 (Wed, 12 Sep 2007)
New Revision: 3129
Modified:
trunk/pingus/src/editor/editor_level.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/editor_viewport.cpp
trunk/pingus/src/editor/editor_viewport.hpp
trunk/pingus/src/editor/level_objs.cpp
trunk/pingus/src/editor/level_objs.hpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_properties.hpp
trunk/pingus/src/editor/object_selector.cpp
trunk/pingus/src/editor/object_selector.hpp
Log:
- implemented proper insertion for some types
- objectproperties now update a little bit when changing selections
Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/editor_level.cpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -41,7 +41,7 @@
impl->music = "none";
impl->ambient_light = Color(255,255,255);
- impl->size = Size(1800, 1200);
+ impl->size = Size(1000, 1000);
impl->number_of_pingus = 50;
impl->number_to_save = 20;
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -56,7 +56,10 @@
show_help(false)
{
// Create the viewport for the images and data
- viewport = new EditorViewport(this);
+ viewport = new EditorViewport(this, Rect(0,
+ 38,
+ Display::get_width() - 244,
+ Display::get_height()));
gui_manager->add(viewport, true);
// Create the panel for the buttons
@@ -67,7 +70,6 @@
object_properties = new ObjectProperties(this, Rect(Vector2i(0,400),
Size(240, 200)));
gui_manager->add(object_properties, true);
-
file_load_dialog = new FileLoadDialog(this, Rect(Vector2i(50, 50),
Size(Display::get_width() -
100,
Display::get_height()
- 100)));
@@ -332,7 +334,7 @@
if (object_properties->is_visible())
object_properties->hide();
else
- object_properties->show();
+ object_properties->show();
}
void
Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -35,11 +35,8 @@
namespace Editor {
// Constructor
-EditorViewport::EditorViewport(EditorScreen* e)
- : rect(0,
- 38,
- Display::get_width() - 244,
- Display::get_height()),
+EditorViewport::EditorViewport(EditorScreen* e, const Rect& rect)
+ : RectComponent(rect),
state(rect.get_width(), rect.get_height()),
drawing_context(new DrawingContext(rect)),
editor(e),
@@ -470,6 +467,12 @@
for(std::vector<LevelObj*>::iterator i = selected_objs.begin(); i !=
selected_objs.end(); ++i)
lower_object_to_bottom(*i);
}
+
+void
+EditorViewport::update_layout()
+{
+ // FIXME: Insert code here
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/editor_viewport.hpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.hpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/editor_viewport.hpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -21,7 +21,7 @@
#ifndef HEADER_PINGUS_EDITOR_VIEWPORT_HXX
#define HEADER_PINGUS_EDITOR_VIEWPORT_HXX
-#include "../gui/component.hpp"
+#include "../gui/rect_component.hpp"
#include "../graphic_context_state.hpp"
#include <boost/signal.hpp>
#include <vector>
@@ -41,10 +41,9 @@
/** This class is where the actual level graphics will display in the
level editor. Objects can be added, deleted, moved, modified, etc.
inside of the EditorViewport */
-class EditorViewport : public GUI::Component
+class EditorViewport : public GUI::RectComponent
{
private:
- Rect rect;
GraphicContextState state;
DrawingContext* drawing_context;
@@ -86,7 +85,7 @@
public:
/** Constructor
@param e The EditorScreen to which this viewport belongs */
- EditorViewport (EditorScreen* e);
+ EditorViewport(EditorScreen* e, const Rect& rect);
/** Destructor */
~EditorViewport ();
@@ -151,6 +150,8 @@
Vector2i screen2world(int x, int y) const;
+ void update_layout();
+
boost::signal<void (const std::vector<LevelObj*>&)> selection_changed;
private:
EditorViewport();
Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/level_objs.cpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -1,7 +1,8 @@
// $Id$
//
// Pingus - A free Lemmings clone
-// Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+// Copyright (C) 2007 Jason Green <address@hidden>,
+// 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
@@ -28,34 +29,57 @@
#include "../display/drawing_context.hpp"
namespace Editor {
-
+
// Default constructor
-LevelObj::LevelObj(std::string obj_name, LevelImpl* level_) :
- level(level_),
- pos(Vector3f(0,0,0)),
- translated_pos(Vector3f(0,0,0)),
- section_name(obj_name),
- speed(0),
- parallax(0.0),
- width(0),
- owner_id(-1),
- release_rate(0),
- scroll_x(0),
- scroll_y(0),
- stretch_x(false),
- stretch_y(false),
- keep_aspect(false),
- para_x(0),
- para_y(0),
- color(0,0,0,0),
- attribs(get_attributes(obj_name)),
- removed(false),
- selected(false)
+LevelObj::LevelObj(std::string obj_name, LevelImpl* level_)
+ : level(level_),
+ pos(Vector3f(0,0,0)),
+ translated_pos(Vector3f(0,0,0)),
+ section_name(obj_name),
+ speed(0),
+ parallax(0.0),
+ width(0),
+ owner_id(0),
+ release_rate(0),
+ scroll_x(0),
+ scroll_y(0),
+ stretch_x(false),
+ stretch_y(false),
+ keep_aspect(false),
+ para_x(0),
+ para_y(0),
+ color(0,0,0,0),
+ attribs(get_attributes(obj_name)),
+ removed(false),
+ selected(false)
{
if (attribs & HAS_SURFACE_FAKE)
load_generic_surface();
}
+unsigned int
+LevelObj::get_attributes(std::string obj_type)
+{
+ if (obj_type == "groundpiece")
+ return HAS_TYPE | HAS_SURFACE | CAN_ROTATE;
+ else if (obj_type == "hotspot")
+ return HAS_SPEED | HAS_PARALLAX | HAS_SURFACE | CAN_ROTATE;
+ else if (obj_type == "liquid")
+ return HAS_SPEED | HAS_WIDTH | HAS_SURFACE;
+ else if (obj_type == "surface-background")
+ return HAS_COLOR | HAS_STRETCH | HAS_PARA | HAS_SCROLL | HAS_SURFACE;
+ else if (obj_type == "entrance" || obj_type == "woodthing")
+ return HAS_TYPE | HAS_DIRECTION | HAS_RELEASE_RATE | HAS_OWNER |
HAS_SURFACE_FAKE;
+ else if (obj_type == "exit")
+ return HAS_OWNER | HAS_SURFACE;
+ else
+ {
+ std::cout << "Error: LevelObj::get_attributes(): unknown object type: '"
+ << obj_type << "'" << std::endl;
+ return 0;
+ }
+}
+
void
LevelObj::set_res_desc(const ResDescriptor d)
{
@@ -336,7 +360,7 @@
pos = p;
set_translated_pos();
}
-
+
} // namespace Editor
/* EOF */
Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/level_objs.hpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -48,29 +48,8 @@
// HAS_SURFACE_FAKE means it has a generic image in the editor, but isn't
saved.
const unsigned HAS_SURFACE_FAKE = 1 << 12;
const unsigned CAN_ROTATE = 1 << 13;
+const unsigned HAS_GPTYPE = 1 << 14;
-/** Returns a number representing which attributes this object possesses */
-inline unsigned int get_attributes(std::string obj_type)
-{
- unsigned val;
- if (obj_type == "groundpiece")
- val = HAS_TYPE | HAS_SURFACE | CAN_ROTATE;
- else if (obj_type == "hotspot")
- val = HAS_SPEED | HAS_PARALLAX | HAS_SURFACE | CAN_ROTATE;
- else if (obj_type == "liquid")
- val = HAS_SPEED | HAS_WIDTH | HAS_SURFACE;
- else if (obj_type == "surface-background")
- val = HAS_COLOR | HAS_STRETCH | HAS_PARA | HAS_SCROLL | HAS_SURFACE;
- else if (obj_type == "entrance" || obj_type == "woodthing")
- val = HAS_TYPE | HAS_DIRECTION | HAS_RELEASE_RATE | HAS_OWNER |
HAS_SURFACE_FAKE;
- else if (obj_type == "exit")
- val = HAS_OWNER | HAS_SURFACE;
- else
- val = 0;
-
- return val;
-}
-
class LevelImpl;
/** Generic Level Object (groundpiece, sign, etc.) Only special objects will
have
@@ -176,7 +155,7 @@
Vector3f get_orig_pos() const { return orig_pos; }
/** Retrieve this object's attribute number */
- unsigned get_attribs() const { return attribs; }
+ unsigned int get_attribs() const { return attribs; }
/** Retrieve the object's resource name */
ResDescriptor get_res_desc() const { return desc; }
@@ -235,6 +214,12 @@
/////////////////////////////////////////////////////////
/// Operations
public:
+ /** Default Constructor */
+ LevelObj(const std::string obj_name, LevelImpl* level_);
+
+ /** Destructor */
+ virtual ~LevelObj() { }
+
/** Set the object's position */
void set_pos(const Vector3f p);
@@ -323,20 +308,17 @@
/** Returns true if the mouse is hovering over this object */
virtual bool is_at (int x, int y);
- /** Default Constructor */
- LevelObj(const std::string obj_name, LevelImpl* level_);
+ /** Returns a number representing which attributes this object possesses */
+ unsigned int get_attributes(std::string obj_type);
- /** Destructor */
- virtual ~LevelObj() { }
-
private:
LevelObj (const LevelObj&);
LevelObj& operator= (const LevelObj&);
-}; // LevelObj class
+};
+
+} // namespace Editor
-} // Editor namespace
-
#endif
/* EOF */
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-11 19:41:21 UTC
(rev 3128)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-12 02:36:49 UTC
(rev 3129)
@@ -38,7 +38,7 @@
{
add(type_label = new Label(Rect(Vector2i(10, 10), Size(120, 20)),
"Object:"), true);
-
+
// Groundpiece Type
add(gptype_label = new Label(Rect(Vector2i(10, 30), Size(120, 20)),
"GPType:"), true);
add(gptype_type = new Combobox(Rect(Vector2i(60, 30), Size(120, 20))),
true);
@@ -53,7 +53,7 @@
gptype_type->set_selected_item(Groundtype::GP_GROUND);
gptype_type->on_select.connect(boost::bind(&ObjectProperties::on_gptype_change,
this, _1));
-
+
add(entrance_direction_label = new Label(Rect(Vector2i(10, 90), Size(80,
20)), "Direction"), true);
add(entrance_direction = new Combobox(Rect(Vector2i(60, 90), Size(120,
20))), true);
entrance_direction->add(0, "Right");
@@ -62,14 +62,14 @@
entrance_direction->set_selected_item(0);
entrance_direction->on_select.connect(boost::bind(&ObjectProperties::on_entrance_direction_change,
this, _1));
-
+
// Background Stretch
add(stretch_x_checkbox = new Checkbox(Rect(Vector2i(10, 60), Size(80, 20)),
"Stretch-X"), true);
add(stretch_y_checkbox = new Checkbox(Rect(Vector2i(110, 60), Size(80, 20)),
"Stretch-Y"), true);
stretch_x_checkbox->on_change.connect(boost::bind(&ObjectProperties::on_stretch_x_change,
this, _1));
stretch_y_checkbox->on_change.connect(boost::bind(&ObjectProperties::on_stretch_y_change,
this, _1));
-
+
add(para_x_label = new Label(Rect(Vector2i(10, 120), Size(80,20)),
"Para-X"), true);
add(para_y_label = new Label(Rect(Vector2i(10, 150), Size(80,20)),
"Para-Y"), true);
@@ -78,7 +78,7 @@
para_x_inputbox->set_text("Hello");
para_y_inputbox->set_text("World");
-
+
if (0)
{
add(new Label(Rect(Vector2i( 10, 30), Size( 80, 20)), "Type:"), true);
@@ -96,8 +96,113 @@
}
void
+ObjectProperties::place(GUI::RectComponent* comp)
+{
+ Rect crect = comp->get_rect();
+ comp->set_rect(Rect(crect.left,
+ y_pos,
+ crect.right,
+ y_pos + crect.get_height()));
+ comp->show();
+ y_pos += 22;
+}
+
+void
+ObjectProperties::place(GUI::RectComponent* comp1, GUI::RectComponent* comp2)
+{
+ Rect rect1 = comp1->get_rect();
+ Rect rect2 = comp2->get_rect();
+
+ comp1->set_rect(Rect(rect1.left,
+ y_pos,
+ rect1.right,
+ y_pos + rect1.get_height()));
+
+ comp2->set_rect(Rect(rect2.left,
+ y_pos,
+ rect2.right,
+ y_pos + rect2.get_height()));
+
+ comp1->show();
+ comp2->show();
+
+ y_pos += 22;
+}
+
+void
ObjectProperties::set_object(LevelObj* obj)
{
+ // Hide everything
+ gptype_label->hide();
+ gptype_type->hide();
+
+ entrance_direction_label->hide();
+ entrance_direction->hide();
+
+ stretch_x_checkbox->hide();
+ stretch_y_checkbox->hide();
+
+ para_x_label->hide();
+ para_x_inputbox->hide();
+
+ para_y_label->hide();
+ para_y_inputbox->hide();
+
+ if (obj)
+ {
+ unsigned int attr = obj->get_attribs();
+ y_pos = 36;
+ if (attr & HAS_TYPE)
+ {
+ place(gptype_label, gptype_type);
+ // FIXME: update the content of the box
+ }
+
+ if (attr & HAS_DIRECTION)
+ {
+ place(entrance_direction_label, entrance_direction);
+ }
+
+ if (attr & HAS_SPEED)
+ {
+ }
+
+ if (attr & HAS_PARALLAX)
+ {
+ place(para_x_label, para_x_inputbox);
+
+ place(para_y_label, para_y_inputbox);
+ }
+
+ if (attr & HAS_WIDTH)
+ {
+ }
+
+ if (attr & HAS_OWNER)
+ {
+ }
+
+ if (attr & HAS_COLOR)
+ {
+ }
+
+ if (attr & HAS_SCROLL)
+ {
+ }
+
+ if (attr & HAS_PARA)
+ {
+ }
+
+ if (attr & HAS_STRETCH)
+ {
+ place(stretch_x_checkbox, stretch_y_checkbox);
+ }
+
+ if (attr & HAS_RELEASE_RATE)
+ {
+ }
+ }
}
void
@@ -115,14 +220,17 @@
if (objects.empty())
{
type_label->set_text("Object: [Empty]");
+ set_object(0);
}
else if (objects.size() > 1)
{
type_label->set_text("Object: [Group]");
+ set_object(0);
}
else
{
type_label->set_text("Object: " + objects.front()->get_section_name());
+ set_object(objects.front());
}
}
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2007-09-11 19:41:21 UTC
(rev 3128)
+++ trunk/pingus/src/editor/object_properties.hpp 2007-09-12 02:36:49 UTC
(rev 3129)
@@ -55,6 +55,7 @@
Label* para_y_label;
Inputbox* para_y_inputbox;
+ int y_pos;
public:
ObjectProperties(EditorScreen* editor, const Rect& rect);
~ObjectProperties();
@@ -63,6 +64,9 @@
void draw_background(DrawingContext& gc);
void set_objects(const std::vector<LevelObj*>& objs);
+
+ void place(GUI::RectComponent* comp);
+ void place(GUI::RectComponent* comp1, GUI::RectComponent* comp2);
void on_gptype_change(const ComboItem& item);
void on_stretch_x_change(bool t);
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -41,6 +41,96 @@
namespace Editor {
+struct Groundpiece : public ObjectSelector::Object
+{
+ ResDescriptor desc;
+ std::string type;
+
+ Groundpiece(const std::string& name, const std::string& type)
+ : Object(Resource::load_sprite(name)),
+ desc(name),
+ type(type)
+ {}
+
+ LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
+ LevelObj* obj = new LevelObj("groundpiece", impl);
+ obj->set_pos(Vector3f(pos.x, pos.y));
+ obj->set_res_desc(desc);
+ obj->set_type(type);
+ return obj;
+ }
+};
+
+struct Entrance : public ObjectSelector::Object
+{
+ Entrance()
+ : Object(Resource::load_sprite("entrances/generic"))
+ {}
+
+ LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
+ LevelObj* obj = new LevelObj("entrance", impl);
+ obj->set_type("generic");
+ obj->set_pos(Vector3f(pos.x, pos.y));
+ obj->set_release_rate(150);
+ obj->set_owner(0);
+ return obj;
+ }
+};
+
+struct Exit : public ObjectSelector::Object
+{
+ ResDescriptor desc;
+
+ Exit(const std::string& name)
+ : Object(Resource::load_sprite(name)),
+ desc(name)
+ {}
+
+ LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
+ LevelObj* obj = new LevelObj("exit", impl);
+ obj->set_pos(Vector3f(pos.x, pos.y));
+ obj->set_res_desc(desc);
+ // obj->set_para();
+ return obj;
+ }
+};
+
+struct Hotspot : public ObjectSelector::Object
+{
+ ResDescriptor desc;
+
+ Hotspot(const std::string& name)
+ : Object(Resource::load_sprite(name)),
+ desc(name)
+ {}
+
+ LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
+ LevelObj* obj = new LevelObj("hotspot", impl);
+ obj->set_pos(Vector3f(pos.x, pos.y));
+ obj->set_res_desc(desc);
+ // obj->set_para();
+ return obj;
+ }
+};
+
+struct SurfaceBackground : public ObjectSelector::Object
+{
+ ResDescriptor desc;
+
+ SurfaceBackground(const std::string& name)
+ : Object(Resource::load_sprite(name)),
+ desc(name)
+ {}
+
+ LevelObj* create(const Vector2i& pos, LevelImpl* impl) {
+ LevelObj* obj = new LevelObj("surface-background", impl);
+ obj->set_pos(Vector3f(pos.x, pos.y));
+ obj->set_res_desc(desc);
+ // obj->set_para();
+ return obj;
+ }
+};
+
class ObjectSelectorButton : public GUI::Component
{
private:
@@ -222,9 +312,9 @@
Color(155,155,155), 10000);
}
- gc.draw(i->sprite,
- 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)->sprite,
+ x * 48 + std::max(0, (48 - (*i)->sprite.get_width())/2),
+ y * 48 + std::max(0, (48 - (*i)->sprite.get_height())/2));
++i;
}
else
@@ -239,9 +329,9 @@
if (mode == OBJECT_DRAG)
{
- parent_gc.draw(objects[current_object].sprite, Vector3f(real_mouse_pos.x,
- real_mouse_pos.y,
- 2000.0f));
+ parent_gc.draw(objects[current_object]->sprite,
Vector3f(real_mouse_pos.x,
+
real_mouse_pos.y,
+ 2000.0f));
}
parent_gc.draw(gc);
}
@@ -294,10 +384,12 @@
if (current_object != -1)
{
- LevelObj* obj = new LevelObj("groundpiece",
editor->get_level()->get_level_impl());
- obj->set_res_desc(objects[current_object].desc);
- obj->set_pos(editor->get_viewport()->screen2world(x,y));
- editor->add_object(obj);
+ LevelObj* obj =
objects[current_object]->create(editor->get_viewport()->screen2world(x,y),
+
editor->get_level()->get_level_impl());
+ if (obj)
+ editor->add_object(obj);
+ else
+ std::cout << "ObjectSelector::Object: create() not implemented" <<
std::endl;
}
}
}
@@ -342,74 +434,125 @@
}
void
+ObjectSelector::clear_object_list()
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ delete (*i);
+ objects.clear();
+}
+
+void
ObjectSelector::set_objects(const std::string& prefix)
{
+ clear_object_list();
+
+ // FIXME: Simple debugging aid, needs to be replaced with custom code for
the object types
std::vector<std::string> lst = Resource::resmgr.get_section(prefix);
- objects.clear();
for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
{
std::cout << "Objects: " << *i << std::endl;
Sprite sprite = Resource::load_sprite(*i);
//sprite.scale(48, 48);
// need to reset the align to top/left
- Object obj(sprite);
- obj.desc = ResDescriptor(*i);
- objects.push_back(obj);
+ objects.push_back(new Object(sprite));
}
}
void
+ObjectSelector::set_groundpiece(const std::string& prefix, const std::string&
type)
+{
+ clear_object_list();
+
+ std::vector<std::string> lst = Resource::resmgr.get_section(prefix);
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
+ {
+ //sprite.scale(48, 48);
+ objects.push_back(new Groundpiece(*i, type));
+ }
+}
+
+void
ObjectSelector::set_gp_ground()
{
- set_objects("groundpieces/ground");
+ set_groundpiece("groundpieces/ground", "ground");
}
void
ObjectSelector::set_gp_solid()
{
- set_objects("groundpieces/solid");
+ set_groundpiece("groundpieces/solid", "solid");
}
void
ObjectSelector::set_gp_bridge()
{
- set_objects("groundpieces/bridge");
+ set_groundpiece("groundpieces/bridge", "bridge");
}
void
ObjectSelector::set_gp_transparent()
{
- set_objects("groundpieces/transparent");
+ set_groundpiece("groundpieces/transparent", "transparent");
}
void
ObjectSelector::set_gp_remove()
{
- set_objects("groundpieces/remove");
+ set_groundpiece("groundpieces/remove", "remove");
}
void
ObjectSelector::set_hotspot()
{
- set_objects("hotspots");
+ clear_object_list();
+
+ std::vector<std::string> lst = Resource::resmgr.get_section("hotspots");
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
+ {
+ //sprite.scale(48, 48);
+ objects.push_back(new Hotspot(*i));
+ }
}
void
ObjectSelector::set_background()
{
- set_objects("textures");
+ clear_object_list();
+
+ std::vector<std::string> lst = Resource::resmgr.get_section("textures");
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
+ {
+ //sprite.scale(48, 48);
+ objects.push_back(new SurfaceBackground(*i));
+ }
}
void
ObjectSelector::set_entrance()
{
- set_objects("entrances");
+ clear_object_list();
+
+ objects.push_back(new Entrance());
+
+ std::vector<std::string> lst = Resource::resmgr.get_section("entrances");
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
+ {
+ //sprite.scale(48, 48);
+ objects.push_back(new Hotspot(*i));
+ }
}
void
ObjectSelector::set_exit()
{
- set_objects("exits");
+ clear_object_list();
+
+ std::vector<std::string> lst = Resource::resmgr.get_section("exit");
+ for(std::vector<std::string>::const_iterator i = lst.begin(); i !=
lst.end(); ++i)
+ {
+ //sprite.scale(48, 48);
+ objects.push_back(new Exit(*i));
+ }
}
void
@@ -421,6 +564,7 @@
void
ObjectSelector::set_trap()
{
+ // Need to differentiate the different trap types
set_objects("traps");
}
Modified: trunk/pingus/src/editor/object_selector.hpp
===================================================================
--- trunk/pingus/src/editor/object_selector.hpp 2007-09-11 19:41:21 UTC (rev
3128)
+++ trunk/pingus/src/editor/object_selector.hpp 2007-09-12 02:36:49 UTC (rev
3129)
@@ -37,6 +37,19 @@
/** */
class ObjectSelector : public GUI::Component
{
+public:
+ struct Object {
+ Sprite sprite;
+
+ Object(const Sprite& sprite_)
+ : sprite(sprite_)
+ {}
+
+ virtual ~Object() {}
+
+ virtual LevelObj* create(const Vector2i&, LevelImpl* impl) { return 0; }
+ };
+
private:
EditorScreen* editor;
Vector2i button_pos;
@@ -51,16 +64,7 @@
enum Mode { NOTHING, SCROLLING, OBJECT_DRAG };
Mode mode;
- struct Object
- {
- Sprite sprite;
- ResDescriptor desc;
-
- Object(const Sprite& sprite_)
- : sprite(sprite_)
- {}
- };
- typedef std::vector<Object> Objects;
+ typedef std::vector<Object*> Objects;
Objects objects;
int current_object;
@@ -90,6 +94,9 @@
void set_objects(const std::string& prefix);
+ void clear_object_list();
+
+ void set_groundpiece(const std::string& prefix, const std::string& type);
void set_gp_ground();
void set_gp_solid();
void set_gp_bridge();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3129 - trunk/pingus/src/editor,
grumbel at BerliOS <=