[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3169 - trunk/pingus/src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3169 - trunk/pingus/src/editor |
Date: |
Mon, 17 Sep 2007 18:05:42 +0200 |
Author: grumbel
Date: 2007-09-17 18:05:41 +0200 (Mon, 17 Sep 2007)
New Revision: 3169
Modified:
trunk/pingus/src/editor/file_dialog.cpp
trunk/pingus/src/editor/file_dialog.hpp
trunk/pingus/src/editor/file_list.cpp
trunk/pingus/src/editor/inputbox.cpp
trunk/pingus/src/editor/inputbox.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
Log:
- added inputboxes to FileDialog
- added z-pos to ObjectProperties
Modified: trunk/pingus/src/editor/file_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_dialog.cpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/file_dialog.cpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -24,6 +24,9 @@
#include "editor_screen.hpp"
#include "gui_style.hpp"
#include "fonts.hpp"
+#include "gettext.h"
+#include "label.hpp"
+#include "inputbox.hpp"
#include "pathname.hpp"
#include "button.hpp"
#include "file_dialog.hpp"
@@ -63,7 +66,13 @@
home_button->on_click.connect(boost::bind(&FileDialog::on_home, this));
open_button->on_click.connect(boost::bind(&FileDialog::on_open, this));
cancel_button->on_click.connect(boost::bind(&FileDialog::on_cancel, this));
+
+ add(filename_label = new Label(Rect(6, 4+30, 4 + 60, 26+30), "Filename:"),
true);
+ add(pathname_label = new Label(Rect(6, 4+60, 4 + 60, 26+60), "Pathname:"),
true);
+ add(filename_inputbox = new Inputbox(Rect(4 + 60, 4+30, rect.get_width()-4,
26+30)), true);
+ add(pathname_inputbox = new Inputbox(Rect(4 + 60, 4+60, rect.get_width()-4,
26+60)), true);
+
add(up_button, true);
add(down_button, true);
@@ -80,44 +89,36 @@
void
FileDialog::draw_background(DrawingContext& gc)
{
+ // Window border and title
GUIStyle::draw_raised_box(gc, Rect(0,0,rect.get_width(), rect.get_height()));
gc.draw_fillrect(4,4,rect.get_width()-4, 30, Color(77,130,180));
- gc.print_center(Fonts::pingus_small, rect.get_width()/2, 2, "Open a level");
-
- GUIStyle::draw_lowered_box(gc, Rect(4 + 60,4+30,rect.get_width()-4, 26+30),
- Color(255,255,255));
-
- gc.print_left(Fonts::verdana11, 10, 8+30, "File: ");
- gc.print_left(Fonts::verdana11, 10 + 60, 8+30, filename);
-
- GUIStyle::draw_lowered_box(gc, Rect(4 + 60,4+60,rect.get_width()-4, 26+60),
- Color(255,255,255));
- gc.print_left(Fonts::verdana11, 10, 8+60, "Path: ");
- gc.print_left(Fonts::verdana11, 10 + 60, 8+60, pathname);
+ gc.print_center(Fonts::pingus_small, rect.get_width()/2, 2, _("Open a
level"));
}
void
FileDialog::load_file(const System::DirectoryEntry& entry)
-{
+{ // called when somebody clicks a file
+
if (entry.type == System::DE_DIRECTORY)
{
//std::cout << "Directory: " << entry.name << std::endl;
- set_directory(pathname + "/" + entry.name);
+ set_directory(pathname_inputbox->get_text() + "/" + entry.name);
}
else
{
- //std::cout << pathname + "/" + entry.name << std::endl;
- filename = entry.name;
- }
+ filename_inputbox->set_text(entry.name);
+ }
}
void
FileDialog::set_directory(const std::string& pathname_)
{
- filename = "";
- pathname = System::realpath(pathname_);
+ std::string pathname = System::realpath(pathname_);
file_list.set_directory(pathname);
update_button_state();
+
+ filename_inputbox->set_text("");
+ pathname_inputbox->set_text(pathname);
}
void
@@ -130,9 +131,9 @@
void
FileDialog::on_open()
{
- if (!filename.empty())
+ if (!filename_inputbox->get_text().empty())
{
- Pathname file(pathname + "/" + filename, Pathname::SYSTEM_PATH);
+ Pathname file(pathname_inputbox->get_text() + "/" +
filename_inputbox->get_text(), Pathname::SYSTEM_PATH);
std::cout << "Open: " << file << std::endl;
editor->load(file);
hide();
Modified: trunk/pingus/src/editor/file_dialog.hpp
===================================================================
--- trunk/pingus/src/editor/file_dialog.hpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/file_dialog.hpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -27,6 +27,8 @@
class Button;
class EditorScreen;
+class Inputbox;
+class Label;
/** */
class FileDialog : public GUI::GroupComponent
@@ -38,12 +40,14 @@
Button* down_button;
Button* open_button;
Button* cancel_button;
-
Button* home_button;
- std::string pathname;
- std::string filename;
+ Label* pathname_label;
+ Label* filename_label;
+ Inputbox* pathname_inputbox;
+ Inputbox* filename_inputbox;
+
public:
FileDialog(EditorScreen* editor, const Rect& rect);
~FileDialog();
Modified: trunk/pingus/src/editor/file_list.cpp
===================================================================
--- trunk/pingus/src/editor/file_list.cpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/file_list.cpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -21,6 +21,7 @@
#include "math.hpp"
#include "fonts.hpp"
#include "file_list.hpp"
+#include "gui_style.hpp"
#include "../math/vector2i.hpp"
namespace Editor {
@@ -84,8 +85,7 @@
void
FileList::draw(DrawingContext& gc)
{
- gc.draw_fillrect(rect.left, rect.top, rect.right, rect.bottom,
- Color(255, 255, 255));
+ GUIStyle::draw_lowered_box(gc, rect, Color(255, 255, 255));
int end = (page+1) * items_per_page();
if (end > int(directory.size()))
Modified: trunk/pingus/src/editor/inputbox.cpp
===================================================================
--- trunk/pingus/src/editor/inputbox.cpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/inputbox.cpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -59,7 +59,8 @@
}
else if (c == 13) // enter
{
- on_change(text);
+ on_change(text);
+ on_enter(text);
}
else
{ // FIXME: This doesn't handle UTF8 properly
Modified: trunk/pingus/src/editor/inputbox.hpp
===================================================================
--- trunk/pingus/src/editor/inputbox.hpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/inputbox.hpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -43,6 +43,8 @@
void update_layout() {}
boost::signal<void (const std::string&)> on_change;
+ boost::signal<void (const std::string&)> on_enter;
+
private:
Inputbox (const Inputbox&);
Inputbox& operator= (const Inputbox&);
Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/level_objs.cpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -362,6 +362,18 @@
pos = p;
set_translated_pos();
}
+
+void
+LevelObj::set_pos_z(float z)
+{
+ pos.z = z;
+}
+
+float
+LevelObj::get_pos_z() const
+{
+ return pos.z;
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp 2007-09-17 11:33:10 UTC (rev
3168)
+++ trunk/pingus/src/editor/level_objs.hpp 2007-09-17 16:05:41 UTC (rev
3169)
@@ -222,6 +222,9 @@
/** Set the object's position */
void set_pos(const Vector3f p);
+
+ void set_pos_z(float z);
+ float get_pos_z() const;
/** Original position of the objects before being dragged around */
void set_orig_pos(const Vector3f p) { orig_pos = p; }
@@ -314,7 +317,6 @@
private:
LevelObj (const LevelObj&);
LevelObj& operator= (const LevelObj&);
-
};
} // namespace Editor
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-17 11:33:10 UTC
(rev 3168)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-17 16:05:41 UTC
(rev 3169)
@@ -106,6 +106,10 @@
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));
+
set_object(0);
}
@@ -188,6 +192,8 @@
owner_label->hide();
owner_inputbox->hide();
+ pos_z_label->hide();
+ pos_z_inputbox->hide();
}
void
@@ -274,6 +280,12 @@
release_rate_inputbox->set_text(StringUtil::to_string(obj->get_release_rate()));
place(release_rate_label, release_rate_inputbox);
}
+
+ if (1) // everybody has z-pos
+ {
+ pos_z_inputbox->set_text(StringUtil::to_string(obj->get_pos_z()));
+ place(pos_z_label, pos_z_inputbox);
+ }
}
else
{
@@ -362,7 +374,15 @@
(*i)->set_owner(StringUtil::to<int>(str));
}
+
void
+ObjectProperties::on_pos_z_change(const std::string& str)
+{
+ for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
+ (*i)->set_pos_z(StringUtil::to<float>(str));
+}
+
+void
ObjectProperties::on_para_x_change(const std::string& str)
{
for(Objects::iterator i = objects.begin(); i != objects.end(); ++i)
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2007-09-17 11:33:10 UTC
(rev 3168)
+++ trunk/pingus/src/editor/object_properties.hpp 2007-09-17 16:05:41 UTC
(rev 3169)
@@ -71,6 +71,9 @@
Label* owner_label;
Inputbox* owner_inputbox;
+ Label* pos_z_label;
+ Inputbox* pos_z_inputbox;
+
int y_pos;
public:
ObjectProperties(EditorScreen* editor, const Rect& rect);
@@ -98,6 +101,7 @@
void on_scroll_x_change(const std::string& str);
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);
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3169 - trunk/pingus/src/editor,
grumbel at BerliOS <=