[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3127 - trunk/pingus/src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3127 - trunk/pingus/src/editor |
Date: |
Tue, 11 Sep 2007 21:27:17 +0200 |
Author: grumbel
Date: 2007-09-11 21:27:17 +0200 (Tue, 11 Sep 2007)
New Revision: 3127
Modified:
trunk/pingus/src/editor/action_properties.cpp
trunk/pingus/src/editor/action_properties.hpp
trunk/pingus/src/editor/checkbox.cpp
trunk/pingus/src/editor/editor_level.cpp
trunk/pingus/src/editor/editor_level.hpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/level_properties.cpp
trunk/pingus/src/editor/level_properties.hpp
Log:
- hocked up most of action/level properties
Modified: trunk/pingus/src/editor/action_properties.cpp
===================================================================
--- trunk/pingus/src/editor/action_properties.cpp 2007-09-11 16:25:16 UTC
(rev 3126)
+++ trunk/pingus/src/editor/action_properties.cpp 2007-09-11 19:27:17 UTC
(rev 3127)
@@ -30,6 +30,7 @@
#include "editor_level.hpp"
#include "pingu_enums.hpp"
#include "inputbox.hpp"
+#include "string_util.hpp"
#include "action_properties.hpp"
namespace Editor {
@@ -77,17 +78,21 @@
void
ActionProperties::add_action(Actions::ActionName id)
{
- Checkbox* checkbox = new Checkbox(Rect(Vector2i(10,10 + y_pos),
Size(80,20)), Actions::action_to_string(id));
- Inputbox* inputbox = new Inputbox(Rect(Vector2i(100,10 + y_pos),
Size(40,20)));
+ ActionComponent comp;
+ comp.checkbox = new Checkbox(Rect(Vector2i(10,10 + y_pos), Size(80,20)),
Actions::action_to_screenname(id));
+ comp.inputbox = new Inputbox(Rect(Vector2i(100,10 + y_pos), Size(40,20)));
- inputbox->set_text("20");
+ comp.checkbox->set_checked(true);
+ comp.inputbox->set_text("20");
- add(checkbox, true);
- add(inputbox, true);
+ add(comp.checkbox, true);
+ add(comp.inputbox, true);
-
checkbox->on_change.connect(boost::bind(&ActionProperties::on_checkbox_change,
this, _1, id));
-
inputbox->on_change.connect(boost::bind(&ActionProperties::on_inputbox_change,
this, _1, id));
+ action_comps[id] = comp;
+
comp.checkbox->on_change.connect(boost::bind(&ActionProperties::on_checkbox_change,
this, _1, id));
+
comp.inputbox->on_change.connect(boost::bind(&ActionProperties::on_inputbox_change,
this, _1, id));
+
y_pos += 22;
}
@@ -95,18 +100,43 @@
ActionProperties::set_level(EditorLevel* level_)
{
level = level_;
+
+ for(ActionComponents::iterator i = action_comps.begin(); i !=
action_comps.end(); ++i)
+ {
+ i->second.inputbox->set_text("20");
+ i->second.checkbox->set_checked(false);
+ }
+
+ std::map<std::string, int> actions = level->get_actions();
+ for(std::map<std::string, int>::iterator i = actions.begin(); i !=
actions.end(); ++i)
+ {
+ ActionComponents::iterator j =
action_comps.find(Actions::action_from_string(i->first));
+ if (j != action_comps.end())
+ {
+ j->second.inputbox->set_text(StringUtil::to_string(i->second));
+ j->second.checkbox->set_checked(true);
+ }
+ }
}
void
ActionProperties::on_checkbox_change(bool t, Actions::ActionName id)
{
- std::cout << "ActionProperties::on_checkbox_change: " << id << " " << t <<
std::endl;
+ if (t)
+ {
+ level->set_action(Actions::action_to_string(id),
+
StringUtil::to<int>(action_comps[id].inputbox->get_text()));
+ }
+ else
+ {
+ level->set_action(Actions::action_to_string(id), 0);
+ }
}
void
ActionProperties::on_inputbox_change(const std::string& value,
Actions::ActionName id)
{
- std::cout << "ActionProperties::on_inputbox_change: " << id << " " << value
<< std::endl;
+ level->set_action(Actions::action_to_string(id), StringUtil::to<int>(value));
}
Modified: trunk/pingus/src/editor/action_properties.hpp
===================================================================
--- trunk/pingus/src/editor/action_properties.hpp 2007-09-11 16:25:16 UTC
(rev 3126)
+++ trunk/pingus/src/editor/action_properties.hpp 2007-09-11 19:27:17 UTC
(rev 3127)
@@ -42,6 +42,14 @@
EditorLevel* level;
int y_pos;
+ struct ActionComponent {
+ Checkbox* checkbox;
+ Inputbox* inputbox;
+ };
+
+ typedef std::map<Actions::ActionName, ActionComponent> ActionComponents;
+ ActionComponents action_comps;
+
public:
ActionProperties(EditorScreen* editor, const Rect& rect);
~ActionProperties();
Modified: trunk/pingus/src/editor/checkbox.cpp
===================================================================
--- trunk/pingus/src/editor/checkbox.cpp 2007-09-11 16:25:16 UTC (rev
3126)
+++ trunk/pingus/src/editor/checkbox.cpp 2007-09-11 19:27:17 UTC (rev
3127)
@@ -66,7 +66,7 @@
Checkbox::set_checked(bool t)
{
checked = t;
- on_change(checked);
+ //on_change(checked);
}
} // namespace Editor
Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp 2007-09-11 16:25:16 UTC (rev
3126)
+++ trunk/pingus/src/editor/editor_level.cpp 2007-09-11 19:27:17 UTC (rev
3127)
@@ -34,7 +34,33 @@
EditorLevel::EditorLevel() :
impl(new LevelImpl())
{
+ impl->levelname = "none";
+ impl->description = "none";
+ impl->author = "none";
+ impl->comment = "none";
+ impl->music = "none";
+ impl->ambient_light = Color(255,255,255);
+ impl->size = Size(1800, 1200);
+
+ impl->number_of_pingus = 50;
+ impl->number_to_save = 20;
+
+ impl->actions["basher"] = 20;
+ impl->actions["blocker"] = 20;
+ impl->actions["boarder"] = 20;
+ impl->actions["bomber"] = 20;
+ impl->actions["bridger"] = 20;
+ impl->actions["climber"] = 20;
+ impl->actions["digger"] = 20;
+ impl->actions["exiter"] = 20;
+ impl->actions["floater"] = 20;
+ impl->actions["jumper"] = 20;
+ impl->actions["miner"] = 20;
+ impl->actions["slider"] = 20;
+
+ impl->time = -1;
+ impl->difficulty = 0;
}
// Default Destructor
@@ -128,6 +154,8 @@
// Load an existing level from a file
void EditorLevel::load_level(const Pathname& pathname)
{
+ std::cout << "EditorLevel::load_level: " << pathname.str() << std::endl;
+
if (impl)
delete impl;
impl = new LevelImpl();
@@ -325,6 +353,48 @@
{
return impl->actions;
}
+
+int
+EditorLevel::get_difficulty() const
+{
+ return impl->difficulty;
+}
+
+std::string
+EditorLevel::get_comment() const
+{
+ return impl->comment;
+}
+
+int
+EditorLevel::get_time() const
+{
+ return impl->time;
+}
+
+void
+EditorLevel::set_time(int t)
+{
+ impl->time = t;
+}
+
+void
+EditorLevel::set_difficulty(int d)
+{
+ impl->difficulty = d;
+}
+
+void
+EditorLevel::set_comment(const std::string& str)
+{
+ impl->comment = str;
+}
+
+void
+EditorLevel::set_size(const Size& s)
+{
+ impl->size = s;
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp 2007-09-11 16:25:16 UTC (rev
3126)
+++ trunk/pingus/src/editor/editor_level.hpp 2007-09-11 19:27:17 UTC (rev
3127)
@@ -55,6 +55,7 @@
void add_object(LevelObj* obj);
Size get_size() const;
+ void set_size(const Size& s);
/** Return LevelImpl */
LevelImpl* get_level_impl() { return impl; }
@@ -73,6 +74,14 @@
int get_number_of_pingus() const;
int get_number_to_save() const;
+ int get_time() const;
+ int get_difficulty() const;
+ std::string get_comment() const;
+
+ void set_time(int);
+ void set_difficulty(int);
+ void set_comment(const std::string&);
+
void set_action(const std::string& actionname, int count);
std::map<std::string, int> get_actions() const;
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-09-11 16:25:16 UTC (rev
3126)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-09-11 19:27:17 UTC (rev
3127)
@@ -84,6 +84,7 @@
level_properties = new LevelProperties(this, Rect(Vector2i(0,38),
Size(Display::get_width()-244,280)));
level_properties->hide();
level_properties->set_level(plf);
+ action_properties->set_level(plf);
gui_manager->add(level_properties, true);
}
@@ -120,6 +121,7 @@
{
plf->load_level(file);
level_properties->set_level(plf);
+ action_properties->set_level(plf);
viewport->refresh();
}
Modified: trunk/pingus/src/editor/level_properties.cpp
===================================================================
--- trunk/pingus/src/editor/level_properties.cpp 2007-09-11 16:25:16 UTC
(rev 3126)
+++ trunk/pingus/src/editor/level_properties.cpp 2007-09-11 19:27:17 UTC
(rev 3127)
@@ -63,16 +63,16 @@
add(number_to_save = new Inputbox(Rect(Vector2i(110, y+22), Size( w,
20))), true);
add(new Label (Rect(Vector2i( 10, y+44), Size( 80, 20)), "Time:"), true);
- add(new Inputbox(Rect(Vector2i(110, y+44), Size( w, 20))), true);
+ add(time = new Inputbox(Rect(Vector2i(110, y+44), Size( w, 20))), true);
add(new Label (Rect(Vector2i( 10, y+66), Size( 80, 20)), "Width:"), true);
- add(new Inputbox(Rect(Vector2i(110, y+66), Size( w, 20))), true);
+ add(width = new Inputbox(Rect(Vector2i(110, y+66), Size( w, 20))), true);
add(new Label (Rect(Vector2i( 10, y+88), Size( 80, 20)), "Height:"),
true);
- add(new Inputbox(Rect(Vector2i(110, y+88), Size( w, 20))), true);
+ add(height = new Inputbox(Rect(Vector2i(110, y+88), Size( w, 20))), true);
add(new Label (Rect(Vector2i( 10, y+110), Size( 80, 20)), "Difficulty:"),
true);
- add(new Inputbox(Rect(Vector2i(110, y+110), Size( w, 20))), true);
+ add(difficulty = new Inputbox(Rect(Vector2i(110, y+110), Size( w, 20))),
true);
add(new Label (Rect(Vector2i( 10, y+132), Size( 80, 20)), "Comment:"),
true);
- add(new Inputbox(Rect(Vector2i(110, y+132), Size( w, 20))), true);
+ add(comment = new Inputbox(Rect(Vector2i(110, y+132), Size( w, 20))), true);
author->on_change.connect(boost::bind(&LevelProperties::on_author_change,
this, _1));
levelname->on_change.connect(boost::bind(&LevelProperties::on_levelname_change,
this, _1));
@@ -80,6 +80,12 @@
number_to_save->on_change.connect(boost::bind(&LevelProperties::on_number_to_save_change,
this, _1));
number_of_pingus->on_change.connect(boost::bind(&LevelProperties::on_number_of_pingus_change,
this, _1));
+
+ width->on_change.connect(boost::bind(&LevelProperties::on_width_change,
this, _1));
+ height->on_change.connect(boost::bind(&LevelProperties::on_height_change,
this, _1));
+ time->on_change.connect(boost::bind(&LevelProperties::on_time_change, this,
_1));
+
difficulty->on_change.connect(boost::bind(&LevelProperties::on_difficulty_change,
this, _1));
+ comment->on_change.connect(boost::bind(&LevelProperties::on_comment_change,
this, _1));
}
LevelProperties::~LevelProperties()
@@ -107,6 +113,12 @@
number_of_pingus->set_text(StringUtil::to_string(level->get_number_of_pingus()));
number_to_save->set_text(StringUtil::to_string(level->get_number_to_save()));
+
+ time->set_text(StringUtil::to_string(level->get_time()));
+ width->set_text(StringUtil::to_string(level->get_size().width));
+ height->set_text(StringUtil::to_string(level->get_size().height));
+ difficulty->set_text(StringUtil::to_string(level->get_difficulty()));
+ comment->set_text("");
}
void
@@ -130,11 +142,15 @@
void
LevelProperties::on_width_change(const std::string& str)
{
+ Size s = level->get_size();
+ level->set_size(Size(StringUtil::to<int>(str), s.height));
}
void
LevelProperties::on_height_change(const std::string& str)
{
+ Size s = level->get_size();
+ level->set_size(Size(s.width, StringUtil::to<int>(str)));
}
void
@@ -165,6 +181,24 @@
std::cout << "LevelProperties::on_number_of_pingus_change: '" << str <<
"' not an integer" << std::endl;
}
}
+
+void
+LevelProperties::on_time_change(const std::string& str)
+{
+ level->set_time(StringUtil::to<int>(str));
+}
+
+void
+LevelProperties::on_difficulty_change(const std::string& str)
+{
+ level->set_difficulty(StringUtil::to<int>(str));
+}
+
+void
+LevelProperties::on_comment_change(const std::string& str)
+{
+ level->set_comment(str);
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/level_properties.hpp
===================================================================
--- trunk/pingus/src/editor/level_properties.hpp 2007-09-11 16:25:16 UTC
(rev 3126)
+++ trunk/pingus/src/editor/level_properties.hpp 2007-09-11 19:27:17 UTC
(rev 3127)
@@ -48,12 +48,18 @@
Inputbox* number_of_pingus;
Inputbox* number_to_save;
+ Inputbox* time;
+ Inputbox* width;
+ Inputbox* height;
+ Inputbox* difficulty;
+ Inputbox* comment;
+
public:
LevelProperties(EditorScreen* editor, const Rect& rect);
~LevelProperties();
void draw_background (DrawingContext& gc);
- void update (float delta);
+ void update(float delta);
void set_level(EditorLevel* level);
@@ -61,11 +67,15 @@
void on_levelname_change(const std::string& str);
void on_description_change(const std::string& str);
+ void on_number_to_save_change(const std::string& str);
+ void on_number_of_pingus_change(const std::string& str);
+
+ void on_time_change(const std::string& str);
void on_width_change(const std::string& str);
void on_height_change(const std::string& str);
+ void on_difficulty_change(const std::string& str);
+ void on_comment_change(const std::string& str);
- void on_number_to_save_change(const std::string& str);
- void on_number_of_pingus_change(const std::string& str);
private:
LevelProperties (const LevelProperties&);
LevelProperties& operator= (const LevelProperties&);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3127 - trunk/pingus/src/editor,
grumbel at BerliOS <=