[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3173 - in trunk/pingus/src: . editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3173 - in trunk/pingus/src: . editor |
Date: |
Mon, 17 Sep 2007 23:45:03 +0200 |
Author: grumbel
Date: 2007-09-17 23:45:01 +0200 (Mon, 17 Sep 2007)
New Revision: 3173
Modified:
trunk/pingus/src/editor/editor_level.cpp
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/groundtype.cpp
trunk/pingus/src/sexpr_file_writer.cpp
Log:
- added color property
Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp 2007-09-17 20:36:14 UTC (rev
3172)
+++ trunk/pingus/src/editor/editor_level.cpp 2007-09-17 21:45:01 UTC (rev
3173)
@@ -223,6 +223,11 @@
i->read_string("type", tmp_str);
obj->set_type(tmp_str);
}
+ if (attribs & HAS_GPTYPE)
+ {
+ i->read_string("type", tmp_str);
+ obj->set_ground_type(tmp_str);
+ }
if (attribs & HAS_SPEED)
{
i->read_int("speed", tmp_int);
Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp 2007-09-17 20:36:14 UTC (rev
3172)
+++ trunk/pingus/src/editor/level_objs.cpp 2007-09-17 21:45:01 UTC (rev
3173)
@@ -60,7 +60,7 @@
LevelObj::get_attributes(std::string obj_type)
{
if (obj_type == "groundpiece")
- return HAS_TYPE | HAS_SURFACE | CAN_ROTATE;
+ return HAS_GPTYPE | HAS_SURFACE | CAN_ROTATE;
else if (obj_type == "hotspot")
return HAS_SPEED | HAS_PARALLAX | HAS_SURFACE | CAN_ROTATE;
else if (obj_type == "liquid")
@@ -207,6 +207,9 @@
if (attribs & HAS_TYPE)
fw.write_string("type", object_type);
+ if (attribs & HAS_GPTYPE)
+ fw.write_string("type", ground_type);
+
if (attribs & HAS_SURFACE)
{
fw.begin_section("surface");
@@ -283,6 +286,13 @@
{
return pos.z;
}
+
+Rect
+LevelObj::get_rect() const
+{
+ return Rect(Vector2i((int)pos.x, (int)pos.y) - sprite.get_offset(),
+ Size(sprite.get_width(), sprite.get_height()));
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp 2007-09-17 20:36:14 UTC (rev
3172)
+++ trunk/pingus/src/editor/level_objs.hpp 2007-09-17 21:45:01 UTC (rev
3173)
@@ -23,6 +23,7 @@
#include "../sprite.hpp"
#include "../math/color.hpp"
#include "../math/origin.hpp"
+#include "../math/rect.hpp"
#include "../math/vector3f.hpp"
#include "../res_descriptor.hpp"
#include "../file_writer.hpp"
@@ -78,6 +79,8 @@
/** Optional type field for certain objects */
std::string object_type;
+ std::string ground_type;
+
/** Optional speed field for certain objects */
int speed;
@@ -162,6 +165,8 @@
/** Retrieve the object's type */
std::string get_type() const { return object_type; }
+ std::string get_ground_type() const { return ground_type; }
+
/** Retrieve the object's speed */
int get_speed() const { return speed; }
@@ -242,6 +247,8 @@
/** Set the object's type */
void set_type(const std::string t) { object_type = t; }
+ void set_ground_type(const std::string t) { ground_type = t; }
+
/** Set the object's speed */
void set_speed(const int s) { speed = s; }
@@ -308,6 +315,8 @@
/** Returns a number representing which attributes this object possesses */
unsigned int get_attributes(std::string obj_type);
+ Rect get_rect() const;
+
private:
LevelObj (const LevelObj&);
LevelObj& operator= (const LevelObj&);
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-17 20:36:14 UTC
(rev 3172)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-17 21:45:01 UTC
(rev 3173)
@@ -42,7 +42,7 @@
Rect label_rect(10,0, 80, 20);
Rect box_rect(80,0, 190, 20);
-
+
// Groundpiece Type
add(gptype_label = new Label(label_rect, "GPType:"), true);
add(gptype_type = new Combobox(box_rect), true);
@@ -57,7 +57,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(label_rect, "Direction:"), true);
add(entrance_direction = new Combobox(box_rect), true);
entrance_direction->add(0, "Left");
@@ -66,12 +66,12 @@
entrance_direction->set_selected_item(0);
entrance_direction->on_select.connect(boost::bind(&ObjectProperties::on_entrance_direction_change,
this, _1));
-
+
add(release_rate_label = new Label(label_rect, "ReleaseRate:"), true);
add(release_rate_inputbox = new Inputbox(box_rect), true);
release_rate_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_release_rate_change,
this, _1));
-
+
// Background Stretch
add(stretch_label = new Label(label_rect, "Stretch:"), true);
add(stretch_x_checkbox = new Checkbox(Rect(Vector2i(box_rect.left,
box_rect.top),
@@ -83,7 +83,7 @@
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(label_rect, "Para-X:"), true);
add(para_y_label = new Label(label_rect, "Para-Y:"), true);
@@ -92,7 +92,7 @@
para_x_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_para_x_change,
this, _1));
para_y_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_para_y_change,
this, _1));
-
+
add(scroll_x_label = new Label(label_rect, "Scroll-X:"), true);
add(scroll_y_label = new Label(label_rect, "Scroll-Y:"), true);
@@ -101,15 +101,28 @@
scroll_x_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_scroll_x_change,
this, _1));
scroll_y_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_scroll_y_change,
this, _1));
-
+
add(owner_label = new Label(label_rect, "Owner Id:"), true);
add(owner_inputbox = new Inputbox(box_rect), true);
owner_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_owner_change,
this, _1));
-
+
add(pos_z_label = new Label(label_rect, "Z-Pos:"), true);
add(pos_z_inputbox = new Inputbox(box_rect), true);
pos_z_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_pos_z_change,
this, _1));
-
+
+ Size color_s(box_rect.get_width()/4, box_rect.get_height());
+
+ add(color_label = new Label(label_rect, "Color:"), true);
+ add(color_r_inputbox = new Inputbox(Rect(Vector2i(box_rect.left +
0*color_s.width, box_rect.top), color_s)), true);
+ add(color_g_inputbox = new Inputbox(Rect(Vector2i(box_rect.left +
1*color_s.width, box_rect.top), color_s)), true);
+ add(color_b_inputbox = new Inputbox(Rect(Vector2i(box_rect.left +
2*color_s.width, box_rect.top), color_s)), true);
+ add(color_a_inputbox = new Inputbox(Rect(Vector2i(box_rect.left +
3*color_s.width, box_rect.top), color_s)), true);
+
+
color_r_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_color_r_change,
this, _1));
+
color_g_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_color_g_change,
this, _1));
+
color_b_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_color_b_change,
this, _1));
+
color_a_inputbox->on_change.connect(boost::bind(&ObjectProperties::on_color_a_change,
this, _1));
+
set_object(0);
}
@@ -194,6 +207,12 @@
pos_z_label->hide();
pos_z_inputbox->hide();
+
+ color_label->hide();
+ color_r_inputbox->hide();
+ color_g_inputbox->hide();
+ color_b_inputbox->hide();
+ color_a_inputbox->hide();
}
void
@@ -204,7 +223,7 @@
if (obj)
{
unsigned int attr = obj->get_attribs();
- if (attr & HAS_TYPE)
+ if (attr & HAS_GPTYPE)
{
gptype_type->set_selected_item(Groundtype::string_to_type(obj->get_type()));
place(gptype_label, gptype_type);
@@ -225,15 +244,15 @@
}
if (attr & HAS_SPEED)
- {
+ { // obsolete in large part, since sprites have their own speed
}
if (attr & HAS_PARALLAX)
- {
+ { // used for hotspot
}
if (attr & HAS_WIDTH)
- {
+ { // used by liquid and some obscure ones
}
if (attr & HAS_OWNER)
@@ -244,6 +263,17 @@
if (attr & HAS_COLOR)
{
+
color_r_inputbox->set_text(StringUtil::to_string((int)obj->get_color().r));
+
color_g_inputbox->set_text(StringUtil::to_string((int)obj->get_color().g));
+
color_b_inputbox->set_text(StringUtil::to_string((int)obj->get_color().b));
+
color_a_inputbox->set_text(StringUtil::to_string((int)obj->get_color().a));
+
+ place(color_label);
+ place(color_r_inputbox);
+ place(color_g_inputbox);
+ place(color_b_inputbox);
+ place(color_a_inputbox);
+ advance();
}
if (attr & HAS_SCROLL)
@@ -336,7 +366,7 @@
ObjectProperties::on_gptype_change(const ComboItem& item)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_type(Groundtype::type_to_string((Groundtype::GPType)item.id));
+
(*i)->set_ground_type(Groundtype::type_to_string((Groundtype::GPType)item.id));
}
void
@@ -350,7 +380,7 @@
ObjectProperties::on_stretch_y_change(bool t)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_stretch_y(t);
+ (*i)->set_stretch_y(t);
}
void
@@ -385,37 +415,82 @@
void
ObjectProperties::on_para_x_change(const std::string& str)
{
- for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_para_x(StringUtil::to<float>(str));
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_para_x(StringUtil::to<float>(str));
}
void
ObjectProperties::on_para_y_change(const std::string& str)
{
- for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_para_y(StringUtil::to<float>(str));
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_para_y(StringUtil::to<float>(str));
}
void
ObjectProperties::on_scroll_x_change(const std::string& str)
{
- for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_scroll_x(StringUtil::to<float>(str));
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_scroll_x(StringUtil::to<float>(str));
}
void
ObjectProperties::on_scroll_y_change(const std::string& str)
{
- for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_scroll_y(StringUtil::to<float>(str));
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_scroll_y(StringUtil::to<float>(str));
}
void
ObjectProperties::on_release_rate_change(const std::string& str)
{
- for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
- (*i)->set_release_rate(StringUtil::to<int>(str));
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_release_rate(StringUtil::to<int>(str));
}
+
+void
+ObjectProperties::on_color_r_change(const std::string& str)
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ {
+ Color color = (*i)->get_color();
+ color.r = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
+}
+
+void
+ObjectProperties::on_color_g_change(const std::string& str)
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ {
+ Color color = (*i)->get_color();
+ color.g = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
+}
+
+void
+ObjectProperties::on_color_b_change(const std::string& str)
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ {
+ Color color = (*i)->get_color();
+ color.b = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
+}
+
+void
+ObjectProperties::on_color_a_change(const std::string& str)
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ {
+ Color color = (*i)->get_color();
+ color.a = StringUtil::to<int>(str);
+ (*i)->set_color(color);
+ }
+}
+
} // namespace Editor
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2007-09-17 20:36:14 UTC
(rev 3172)
+++ trunk/pingus/src/editor/object_properties.hpp 2007-09-17 21:45:01 UTC
(rev 3173)
@@ -74,6 +74,12 @@
Label* pos_z_label;
Inputbox* pos_z_inputbox;
+ Label* color_label;
+ Inputbox* color_r_inputbox;
+ Inputbox* color_g_inputbox;
+ Inputbox* color_b_inputbox;
+ Inputbox* color_a_inputbox;
+
int y_pos;
public:
ObjectProperties(EditorScreen* editor, const Rect& rect);
@@ -102,6 +108,11 @@
void on_scroll_y_change(const std::string& str);
void on_release_rate_change(const std::string& str);
void on_pos_z_change(const std::string& str);
+
+ void on_color_r_change(const std::string& str);
+ void on_color_g_change(const std::string& str);
+ void on_color_b_change(const std::string& str);
+ void on_color_a_change(const std::string& str);
};
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-17 20:36:14 UTC (rev
3172)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-17 21:45:01 UTC (rev
3173)
@@ -55,7 +55,7 @@
LevelObj* obj = new LevelObj("groundpiece", impl);
obj->set_pos(pos);
obj->set_res_desc(desc);
- obj->set_type(type);
+ obj->set_ground_type(type);
return obj;
}
};
Modified: trunk/pingus/src/groundtype.cpp
===================================================================
--- trunk/pingus/src/groundtype.cpp 2007-09-17 20:36:14 UTC (rev 3172)
+++ trunk/pingus/src/groundtype.cpp 2007-09-17 21:45:01 UTC (rev 3173)
@@ -40,7 +40,7 @@
return Groundtype::GP_REMOVE;
else
{
- std::cout << "Groundtype: Unhandled type: " << arg_type << std::endl;
+ std::cout << "Groundtype: Unhandled type: '" << arg_type << "'" <<
std::endl;
return Groundtype::GP_GROUND;
}
}
Modified: trunk/pingus/src/sexpr_file_writer.cpp
===================================================================
--- trunk/pingus/src/sexpr_file_writer.cpp 2007-09-17 20:36:14 UTC (rev
3172)
+++ trunk/pingus/src/sexpr_file_writer.cpp 2007-09-17 21:45:01 UTC (rev
3173)
@@ -67,7 +67,10 @@
SExprFileWriter::write_color(const char* name, const Color& color)
{
(*out) << "\n" << indent() << "(" << name << " "
- << (int)color.r << " " << (int)color.g << " " << (int)color.b << " "
<< (int)color.a << ")";
+ << color.r/255.0f << " "
+ << color.g/255.0f << " "
+ << color.b/255.0f << " "
+ << color.a/255.0f << ")";
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3173 - in trunk/pingus/src: . editor,
grumbel at BerliOS <=