[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2583 - trunk/src/editor
From: |
jave27 |
Subject: |
[Pingus-CVS] r2583 - trunk/src/editor |
Date: |
Mon, 9 Jan 2006 17:36:59 +0100 |
Author: jave27
Date: 2006-01-09 17:36:54 +0100 (Mon, 09 Jan 2006)
New Revision: 2583
Modified:
trunk/src/editor/level_objs.cxx
trunk/src/editor/level_objs.hxx
Log:
Setup method for displaying objects w/o a real surface, starting with the
entrances.
Modified: trunk/src/editor/level_objs.cxx
===================================================================
--- trunk/src/editor/level_objs.cxx 2006-01-09 07:08:34 UTC (rev 2582)
+++ trunk/src/editor/level_objs.cxx 2006-01-09 16:36:54 UTC (rev 2583)
@@ -51,7 +51,8 @@
selected(false),
attribs(get_attributes(obj_name))
{
-
+ if (attribs & HAS_SURFACE_FAKE)
+ load_generic_surface();
}
void
@@ -65,7 +66,7 @@
void
LevelObj::draw(DrawingContext &gc)
{
- if (!removed && attribs & HAS_SURFACE)
+ if (!removed && attribs & (HAS_SURFACE | HAS_SURFACE_FAKE))
{
// If selected, draw a highlighted box around it
if (selected)
@@ -91,7 +92,7 @@
bool
LevelObj::is_at(int x, int y)
{
- if (!removed && attribs & HAS_SURFACE)
+ if (!removed && attribs & (HAS_SURFACE | HAS_SURFACE_FAKE))
return (x > pos.x && x < pos.x + sprite.get_width()
&& y > pos.y && y < pos.y + sprite.get_height());
else
@@ -186,7 +187,7 @@
const unsigned attribs = get_attributes(section_name);
// Write information about the main sprite
- if (attribs & HAS_SURFACE)
+ if (attribs & HAS_SURFACE && !(attribs & HAS_SURFACE_FAKE))
{
xml.begin_section("surface");
xml.write_string("image", desc.res_name);
@@ -237,6 +238,17 @@
}
}
+void
+LevelObj::load_generic_surface()
+{
+ if (section_name == "entrance")
+ {
+ desc.res_name = "entrances/generic";
+ desc.modifier = ResourceModifierNS::ROT0;
+ sprite = Resource::load_sprite(desc);
+ }
+}
+
} // Editor namespace
} // Pingus namespace
Modified: trunk/src/editor/level_objs.hxx
===================================================================
--- trunk/src/editor/level_objs.hxx 2006-01-09 07:08:34 UTC (rev 2582)
+++ trunk/src/editor/level_objs.hxx 2006-01-09 16:36:54 UTC (rev 2583)
@@ -44,7 +44,9 @@
const unsigned HAS_DIRECTION = 512;
const unsigned HAS_RELEASE_RATE = 1024;
const unsigned HAS_SURFACE = 2048;
- const unsigned CAN_ROTATE = 4096;
+ // HAS_SURFACE_FAKE means it has a generic image in the editor, but
isn't saved.
+ const unsigned HAS_SURFACE_FAKE = 4096;
+ const unsigned CAN_ROTATE = 8192;
/** Returns a number representing which attributes this object
possesses */
inline unsigned int get_attributes(std::string obj_type)
@@ -59,7 +61,7 @@
else if (obj_type == "surface-background")
val = HAS_COLOR | HAS_STRETCH | HAS_PARA | HAS_SCROLL |
HAS_SURFACE;
else if (obj_type == "entrance")
- val = HAS_TYPE | HAS_DIRECTION | HAS_RELEASE_RATE |
HAS_OWNER;
+ val = HAS_TYPE | HAS_DIRECTION | HAS_RELEASE_RATE |
HAS_OWNER | HAS_SURFACE_FAKE;
else if (obj_type == "exit")
val = HAS_OWNER | HAS_SURFACE;
else
@@ -82,7 +84,7 @@
LevelImpl* level;
/** Resource Desciptor of this object */
- ResDescriptor desc;
+ ResDescriptor desc;
/** Location of this object in the World */
Vector pos;
@@ -147,6 +149,9 @@
/** Marks is this object is currently selected */
bool selected;
+ /** Loads any generic images necessary for objects with
HAS_FAKE_SURFACE */
+ void load_generic_surface();
+
/** Write any additional properties to the XML file for this type */
virtual void write_extra_properties(XMLFileWriter& xml) { }
@@ -220,6 +225,8 @@
public:
/** Set the object's position */
void set_pos(const Vector p) { pos = p; }
+
+ /** Original position of the objects before being dragged around */
void set_orig_pos(const Vector p) { orig_pos = p; }
/** Set the object's resource name */
@@ -298,7 +305,7 @@
virtual void draw(DrawingContext &gc);
/** Returns true if the mouse is hovering over this object */
- virtual bool is_at (int x, int y);
+ virtual bool is_at (int x, int y);
/** Default Constructor */
LevelObj(const std::string obj_name, LevelImpl* level_);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2583 - trunk/src/editor,
jave27 <=