[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3119 - in trunk/pingus/src: . editor gui worldobjs
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3119 - in trunk/pingus/src: . editor gui worldobjs |
Date: |
Mon, 10 Sep 2007 10:05:48 +0200 |
Author: grumbel
Date: 2007-09-10 10:05:47 +0200 (Mon, 10 Sep 2007)
New Revision: 3119
Added:
trunk/pingus/src/editor/checkbox.cpp
trunk/pingus/src/editor/checkbox.hpp
Modified:
trunk/pingus/src/SConscript
trunk/pingus/src/editor/label.cpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_properties.hpp
trunk/pingus/src/gui/group_component.cpp
trunk/pingus/src/gui/group_component.hpp
trunk/pingus/src/gui/input_box.cpp
trunk/pingus/src/gui/input_box.hpp
trunk/pingus/src/worldobjs/entrance.hpp
Log:
- added checkbox (works a little different then the already existing one)
Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-09 23:18:42 UTC (rev 3118)
+++ trunk/pingus/src/SConscript 2007-09-10 08:05:47 UTC (rev 3119)
@@ -92,6 +92,7 @@
'editor/button.cpp',
'editor/gui_style.cpp',
'editor/context_menu.cpp',
+'editor/checkbox.cpp',
'editor/editor_level.cpp',
'editor/panel.cpp',
'editor/label.cpp',
Added: trunk/pingus/src/editor/checkbox.cpp
===================================================================
--- trunk/pingus/src/editor/checkbox.cpp 2007-09-09 23:18:42 UTC (rev
3118)
+++ trunk/pingus/src/editor/checkbox.cpp 2007-09-10 08:05:47 UTC (rev
3119)
@@ -0,0 +1,74 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 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
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#include "fonts.hpp"
+#include "gui_style.hpp"
+#include "checkbox.hpp"
+
+namespace Editor {
+
+Checkbox::Checkbox(const Rect& rect, const std::string& label_)
+ : RectComponent(rect),
+ checked(false),
+ label(label_)
+{
+}
+
+Checkbox::~Checkbox()
+{
+}
+
+void
+Checkbox::draw(DrawingContext& gc)
+{
+ if (checked)
+ GUIStyle::draw_lowered_box(gc, rect);
+ else
+ GUIStyle::draw_raised_box(gc, rect);
+
+ if (!label.empty())
+ gc.print_center(Fonts::verdana11,
+ rect.left + rect.get_width()/2,
+ rect.top + rect.get_height()/2 -
Fonts::verdana11.get_height()/2,
+ label);
+}
+
+void
+Checkbox::on_primary_button_press(int x, int y)
+{
+ checked = !checked;
+ on_change(checked);
+}
+
+void
+Checkbox::set_checked(bool t)
+{
+ checked = t;
+ on_change(checked);
+}
+
+} // namespace Editor
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/checkbox.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/pingus/src/editor/checkbox.hpp
===================================================================
--- trunk/pingus/src/editor/checkbox.hpp 2007-09-09 23:18:42 UTC (rev
3118)
+++ trunk/pingus/src/editor/checkbox.hpp 2007-09-10 08:05:47 UTC (rev
3119)
@@ -0,0 +1,63 @@
+/* $Id$
+** __ __ __ ___ __ __ __ __
+** / \ / \__| ____ __| _/_______/ |_|__| | | | ____
+** \ \/\/ / |/ \ / __ |/ ___/\ __\ | | | | _/ __ \
+** \ /| | | \/ /_/ |\___ \ | | | | |_| |_\ ___/
+** \__/\ / |__|___| /\____ /____ > |__| |__|____/____/\___ >
+** \/ \/ \/ \/ \/
+** Copyright (C) 2007 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
+** as published by the Free Software Foundation; either version 2
+** of the License, or (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+** 02111-1307, USA.
+*/
+
+#ifndef HEADER_CHECKBOX_HPP
+#define HEADER_CHECKBOX_HPP
+
+#include <boost/signal.hpp>
+#include "gui/rect_component.hpp"
+
+namespace Editor {
+
+/** */
+class Checkbox : public GUI::RectComponent
+{
+private:
+ bool checked;
+ std::string label;
+
+public:
+ Checkbox(const Rect& rect, const std::string& label = "");
+ ~Checkbox();
+
+ void draw(DrawingContext& gc);
+ void update_layout() {}
+
+ void set_checked(bool t);
+ bool is_checked() const { return checked; }
+ void on_primary_button_press(int x, int y);
+
+ boost::signal<void (bool)> on_change;
+
+private:
+ Checkbox (const Checkbox&);
+ Checkbox& operator= (const Checkbox&);
+};
+
+} // namespace Editor
+
+#endif
+
+/* EOF */
Property changes on: trunk/pingus/src/editor/checkbox.hpp
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/pingus/src/editor/label.cpp
===================================================================
--- trunk/pingus/src/editor/label.cpp 2007-09-09 23:18:42 UTC (rev 3118)
+++ trunk/pingus/src/editor/label.cpp 2007-09-10 08:05:47 UTC (rev 3119)
@@ -38,7 +38,8 @@
void
Label::draw (DrawingContext& gc)
{
- gc.print_left(Fonts::verdana11, rect.left, rect.top, text);
+ gc.print_left(Fonts::verdana11, rect.left, rect.top + rect.get_height()/2 -
Fonts::verdana11.get_height()/2,
+ text);
}
void
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2007-09-09 23:18:42 UTC
(rev 3118)
+++ trunk/pingus/src/editor/object_properties.cpp 2007-09-10 08:05:47 UTC
(rev 3119)
@@ -26,19 +26,22 @@
#include "gui_style.hpp"
#include "groundtype.hpp"
#include "combobox.hpp"
+#include "checkbox.hpp"
#include "object_properties.hpp"
namespace Editor {
ObjectProperties::ObjectProperties(EditorScreen* editor_, const Rect& rect)
- : GUI::GroupComponent(rect),
+ : GUI::GroupComponent(rect, false),
editor(editor_)
{
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);
- add(gptype_label = new Label(Rect(Vector2i(10, 100), Size(120, 20)),
"GPType:"), true);
- add(gptype_type = new Combobox(Rect(Vector2i(60, 100), Size(120, 20))),
true);
-
gptype_type->add(Groundtype::GP_TRANSPARENT, "Transparent");
gptype_type->add(Groundtype::GP_SOLID, "Solid");
gptype_type->add(Groundtype::GP_GROUND, "Ground");
@@ -47,15 +50,35 @@
gptype_type->add(Groundtype::GP_LAVA, "Lava");
gptype_type->add(Groundtype::GP_REMOVE, "Remove");
gptype_type->set_selected_item(Groundtype::GP_GROUND);
+
gptype_type->on_select.connect(boost::bind(&ObjectProperties::on_gptype_change,
this, _1));
-
- add(new Label(Rect(Vector2i( 10, 30), Size( 80, 20)), "Type:"), true);
+
+ 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");
+ entrance_direction->add(1, "Misc");
+ entrance_direction->add(2, "Left");
+ entrance_direction->set_selected_item(0);
- add(new Button(Rect(Vector2i( 60, 30), Size( 80, 20)), "Ground"), true);
- add(new Button(Rect(Vector2i( 60, 50), Size( 80, 20)), "Transparent"),
true);
- add(new Button(Rect(Vector2i( 60, 70), Size( 80, 20)), "Solid"), true);
- add(new Button(Rect(Vector2i(140, 30), Size( 80, 20)), "Bridge"), true);
- add(new Button(Rect(Vector2i(140, 50), Size( 80, 20)), "Remove"), true);
+
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));
+
+ if (0)
+ {
+ add(new Label(Rect(Vector2i( 10, 30), Size( 80, 20)), "Type:"), true);
+
+ add(new Button(Rect(Vector2i( 60, 30), Size( 80, 20)), "Ground"), true);
+ add(new Button(Rect(Vector2i( 60, 50), Size( 80, 20)), "Transparent"),
true);
+ add(new Button(Rect(Vector2i( 60, 70), Size( 80, 20)), "Solid"), true);
+ add(new Button(Rect(Vector2i(140, 30), Size( 80, 20)), "Bridge"), true);
+ add(new Button(Rect(Vector2i(140, 50), Size( 80, 20)), "Remove"), true);
+ }
}
ObjectProperties::~ObjectProperties()
@@ -99,6 +122,24 @@
std::cout << "ObjectProperties::on_gpytpe_change: switch to: "
<< Groundtype::type_to_string((Groundtype::GPType)item.id) <<
std::endl;
}
+
+void
+ObjectProperties::on_stretch_x_change(bool t)
+{
+ std::cout << "ObjectProperties::on_stretch_x_change: switch to: " << t <<
std::endl;
+}
+
+void
+ObjectProperties::on_stretch_y_change(bool t)
+{
+ std::cout << "ObjectProperties::on_stretch_y_change: switch to: " << t <<
std::endl;
+}
+
+void
+ObjectProperties::on_entrance_direction_change(const ComboItem& item)
+{
+ std::cout << "ObjectProperties::on_entrance_direction_change: " <<
item.label << std::endl;
+}
} // namespace Editor
Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp 2007-09-09 23:18:42 UTC
(rev 3118)
+++ trunk/pingus/src/editor/object_properties.hpp 2007-09-10 08:05:47 UTC
(rev 3119)
@@ -28,6 +28,7 @@
class EditorScreen;
class Combobox;
class ComboItem;
+class Checkbox;
/** */
class ObjectProperties : public GUI::GroupComponent
@@ -41,6 +42,12 @@
Label* gptype_label;
Combobox* gptype_type;
+ Label* entrance_direction_label;
+ Combobox* entrance_direction;
+
+ Checkbox* stretch_x_checkbox;
+ Checkbox* stretch_y_checkbox;
+
public:
ObjectProperties(EditorScreen* editor, const Rect& rect);
~ObjectProperties();
@@ -51,6 +58,9 @@
void set_objects(const std::vector<LevelObj*>& objs);
void on_gptype_change(const ComboItem& item);
+ void on_stretch_x_change(bool t);
+ void on_stretch_y_change(bool t);
+ void on_entrance_direction_change(const ComboItem& item);
};
Modified: trunk/pingus/src/gui/group_component.cpp
===================================================================
--- trunk/pingus/src/gui/group_component.cpp 2007-09-09 23:18:42 UTC (rev
3118)
+++ trunk/pingus/src/gui/group_component.cpp 2007-09-10 08:05:47 UTC (rev
3119)
@@ -27,9 +27,9 @@
namespace GUI {
-GroupComponent::GroupComponent(const Rect& rect)
+GroupComponent::GroupComponent(const Rect& rect, bool clip)
: RectComponent(rect),
- drawing_context(rect),
+ drawing_context(rect, clip),
mouse_over_comp(0),
press_over_comp(0)
{
Modified: trunk/pingus/src/gui/group_component.hpp
===================================================================
--- trunk/pingus/src/gui/group_component.hpp 2007-09-09 23:18:42 UTC (rev
3118)
+++ trunk/pingus/src/gui/group_component.hpp 2007-09-10 08:05:47 UTC (rev
3119)
@@ -42,7 +42,7 @@
Component* press_over_comp;
public:
- GroupComponent(const Rect& rect);
+ GroupComponent(const Rect& rect, bool clip = true);
~GroupComponent();
void draw(DrawingContext& gc);
Modified: trunk/pingus/src/gui/input_box.cpp
===================================================================
--- trunk/pingus/src/gui/input_box.cpp 2007-09-09 23:18:42 UTC (rev 3118)
+++ trunk/pingus/src/gui/input_box.cpp 2007-09-10 08:05:47 UTC (rev 3119)
@@ -24,7 +24,7 @@
#include "../fonts.hpp"
namespace GUI {
-
+
InputBox::InputBox(float width_, Vector3f p, const std::string& default_value,
bool locked, const std::string& label_)
: str(default_value),
@@ -98,7 +98,7 @@
}
}
}
+
+} // namespace GUI
-} // GUI
-
/* EOF */
Modified: trunk/pingus/src/gui/input_box.hpp
===================================================================
--- trunk/pingus/src/gui/input_box.hpp 2007-09-09 23:18:42 UTC (rev 3118)
+++ trunk/pingus/src/gui/input_box.hpp 2007-09-10 08:05:47 UTC (rev 3119)
@@ -62,7 +62,7 @@
void draw(DrawingContext &gc);
}; // InputBox class
-} // GUI namespace
+} // namespace GUI
#endif
Modified: trunk/pingus/src/worldobjs/entrance.hpp
===================================================================
--- trunk/pingus/src/worldobjs/entrance.hpp 2007-09-09 23:18:42 UTC (rev
3118)
+++ trunk/pingus/src/worldobjs/entrance.hpp 2007-09-10 08:05:47 UTC (rev
3119)
@@ -37,8 +37,9 @@
currently sucks and needs to be rewritten */
class Entrance : public WorldObj
{
+public:
+ enum EntranceDirection { LEFT, RIGHT, MISC };
protected:
- enum EntranceDirection { LEFT, RIGHT, MISC };
EntranceDirection direction;
Vector3f pos;
int release_rate;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3119 - in trunk/pingus/src: . editor gui worldobjs,
grumbel at BerliOS <=