[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2625 - in trunk/src: . editor gui
From: |
jave27 |
Subject: |
[Pingus-CVS] r2625 - in trunk/src: . editor gui |
Date: |
Sun, 5 Feb 2006 21:49:33 +0100 |
Author: jave27
Date: 2006-02-05 21:49:22 +0100 (Sun, 05 Feb 2006)
New Revision: 2625
Added:
trunk/src/editor/level_head.cxx
trunk/src/editor/level_head.hxx
Modified:
trunk/src/SConscript
trunk/src/editor/Makefile.am
trunk/src/editor/editor_panel.cxx
trunk/src/editor/panel_buttons.cxx
trunk/src/editor/panel_buttons.hxx
trunk/src/gui/input_box.cxx
trunk/src/gui/input_box.hxx
trunk/src/input_event.hxx
trunk/src/pingus_menu.hxx
Log:
Added a way to edit the level name and description in the editor..
A bit ugly at the moment, but it works.
Modified: trunk/src/SConscript
===================================================================
--- trunk/src/SConscript 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/SConscript 2006-02-05 20:49:22 UTC (rev 2625)
@@ -106,6 +106,7 @@
'editor/editor_panel.cxx',
'editor/editor_screen.cxx',
'editor/editor_viewport.cxx',
+'editor/level_head.cxx',
'editor/level_objs.cxx',
'editor/panel_buttons.cxx',
'editor/xml_level.cxx',
Modified: trunk/src/editor/Makefile.am
===================================================================
--- trunk/src/editor/Makefile.am 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/Makefile.am 2006-02-05 20:49:22 UTC (rev 2625)
@@ -21,14 +21,9 @@
noinst_LIBRARIES = libpingus_editor.a
libpingus_editor_a_CPPFLAGS = @PINGUS_CFLAGS@
-libpingus_editor_a_SOURCES = \
-context_menu.cxx context_menu.hxx \
-editor_screen.cxx editor_screen.hxx \
-editor_panel.cxx editor_panel.hxx \
-panel_buttons.cxx panel_buttons.hxx \
-editor_viewport.cxx editor_viewport.hxx \
-xml_level.cxx xml_level.hxx \
-level_objs.cxx level_objs.hxx \
-level_impl.hxx
+libpingus_editor_a_SOURCES = \
+ context_menu.cxx context_menu.hxx editor_screen.cxx
editor_screen.hxx editor_panel.cxx editor_panel.hxx
panel_buttons.cxx panel_buttons.hxx editor_viewport.cxx
editor_viewport.hxx \
+ xml_level.cxx xml_level.hxx level_objs.cxx
level_objs.hxx level_impl.hxx level_head.cxx
# EOF #
+noinst_HEADERS = level_head.hxx
Modified: trunk/src/editor/editor_panel.cxx
===================================================================
--- trunk/src/editor/editor_panel.cxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/editor_panel.cxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -64,7 +64,7 @@
add((PanelButton*)(new PanelButtonLoad(this)));
add((PanelButton*)(new PanelButtonSave(this)));
add((PanelButton*)(new PanelButtonGroundpiece(this)));
-
+ add((PanelButton*)(new PanelButtonHead(this)));
// Create Checkboxes
snap_to_checkbox = new GUI::Checkbox(Vector(370, 5), "Snap To Grid: ",
this);
get_screen()->get_gui_manager()->add(snap_to_checkbox);
Added: trunk/src/editor/level_head.cxx
===================================================================
--- trunk/src/editor/level_head.cxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/level_head.cxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -0,0 +1,139 @@
+// $Id: level_head.hxx,v 1.00 2006/02/05 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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 <ClanLib/display.h>
+#include "../display/drawing_context.hxx"
+#include "../gui/gui_manager.hxx"
+#include "../gui/surface_button.hxx"
+#include "../gui/input_box.hxx"
+#include "../sound/sound.hxx"
+#include "../resource.hxx"
+#include "../vector.hxx"
+#include "../fonts.hxx"
+#include "../gettext.h"
+#include "level_head.hxx"
+#include "level_impl.hxx"
+#include "panel_buttons.hxx"
+#include "editor_panel.hxx"
+#include "editor_screen.hxx"
+#include "xml_level.hxx"
+
+namespace Pingus {
+namespace Editor {
+
+ class LevelHeadCloseButton : public GUI::SurfaceButton
+ {
+ private:
+ LevelHead* head;
+ std::string label;
+
+ public:
+ LevelHeadCloseButton(LevelHead* h)
+ : GUI::SurfaceButton(CL_Display::get_width() -100,
+ CL_Display::get_height() -100,
+ ResDescriptor("core/menu/exit_button_normal"),
+ ResDescriptor("core/menu/exit_button_pressed"),
+ ResDescriptor("core/menu/exit_button_hover")),
+ head(h),
+ label(_("Ok"))
+ {
+ }
+
+ void draw (DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_right(Fonts::chalk_large, (float)CL_Display::get_width() -
150,
+ (float)CL_Display::get_height() - 100, label);
+ }
+
+ void on_click()
+ {
+ head->get_head_button()->remove_head();
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+ };
+
+LevelHead::LevelHead(EditorPanel* p, PanelButtonHead* pbh) :
+ head_button(pbh),
+ impl(p->get_screen()->get_level()->get_level_impl()),
+ gui_manager(p->get_screen()->get_gui_manager()),
+ pos(Vector(50, 75))
+{
+ gui_manager->add((GUI::Component*)this);
+
+ // Create GUI items
+ name = new GUI::InputBox(400, Vector(pos.x + 175, pos.y + 10),
+ impl->levelname, false, "Level Name");
+ desc = new GUI::InputBox(500, Vector(pos.x + 175, pos.y + 60),
+ impl->description, false, "Level Description");
+
+ // Add GUI Items to the GUIManager
+ gui_manager->add((GUI::Component*)name);
+ gui_manager->add((GUI::Component*)desc);
+
+ // Add close button
+ close_button = new LevelHeadCloseButton(this);
+ gui_manager->add((GUI::Component*)close_button);
+}
+
+LevelHead::~LevelHead()
+{
+ // Remove all GUI Items from the GUIManager
+ gui_manager->remove(name);
+ gui_manager->remove(desc);
+ gui_manager->remove(close_button);
+ gui_manager->remove((GUI::Component*)this);
+}
+
+void
+LevelHead::draw(DrawingContext& gc)
+{
+ // Draw the background for window
+ gc.draw_fillrect(pos.x, pos.y, CL_Display::get_width() - 50,
+ CL_Display::get_height()-50, CL_Color(100,150,50,150));
+ // Draw the window border
+ gc.draw_rect(pos.x, pos.y, CL_Display::get_width() - 50,
+ CL_Display::get_height()-50, CL_Color::white);
+}
+
+bool
+LevelHead::is_at(int x, int y)
+{
+ return (x > pos.x && y > pos.y && x < CL_Display::get_width()-50 &&
+ y < CL_Display::get_height()-50);
+}
+
+void
+LevelHead::update(float delta)
+{
+ UNUSED_ARG(delta);
+ // FIXME: Should only update this information if it has changed.
+ impl->levelname = name->get_string();
+ impl->description = desc->get_string();
+}
+
+
+} // Editor
+} // Pingus
+
+/* EOF */
Added: trunk/src/editor/level_head.hxx
===================================================================
--- trunk/src/editor/level_head.hxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/level_head.hxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -0,0 +1,80 @@
+// $Id: level_head.hxx,v 1.00 2006/02/05 23:41:12 Jave27 Exp $
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2005 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_PINGUS_EDITOR_LEVEL_HEAD_HXX
+#define HEADER_PINGUS_EDITOR_LEVEL_HEAD_HXX
+
+#include "../gui/component.hxx"
+
+namespace Pingus {
+
+ class Vector;
+
+namespace GUI {
+ class GUIManager;
+ class InputBox;
+}
+
+namespace Editor {
+
+ class LevelImpl;
+ class PanelButtonHead;
+ class EditorPanel;
+ class LevelHeadCloseButton;
+
+ /** This class draws a box with different input boxes that
+ * determine the specific level information which is saved
+ * in the <HEAD> section of the XML level file */
+class LevelHead : public GUI::Component
+{
+private:
+ /** The level we are editing */
+ PanelButtonHead* head_button;
+
+ LevelImpl *impl;
+
+ GUI::GUIManager* gui_manager;
+
+ /** Where this box is drawn*/
+ Vector pos;
+
+ // Input boxes for each item of the level impl
+ GUI::InputBox* name;
+ GUI::InputBox* desc;
+ LevelHeadCloseButton* close_button;
+
+public:
+
+ LevelHead(EditorPanel* p, PanelButtonHead* pbh);
+ ~LevelHead();
+
+ PanelButtonHead* get_head_button() { return head_button; }
+
+ // GUI Component stuff
+ bool is_at(int x, int y);
+ void draw(DrawingContext& gc);
+ void update(float delta);
+};
+
+} // Editor namespace
+} // Pingus namespace
+
+#endif
+
+/* EOF */
Modified: trunk/src/editor/panel_buttons.cxx
===================================================================
--- trunk/src/editor/panel_buttons.cxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/panel_buttons.cxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -19,15 +19,17 @@
#include <vector>
#include <ClanLib/Display/sprite.h>
-#include "panel_buttons.hxx"
#include "../gui/combobox.hxx"
+#include "../gui/gui_manager.hxx"
#include "../display/scene_context.hxx"
#include "../path_manager.hxx"
#include "../fonts.hxx"
#include "../resource.hxx"
+#include "panel_buttons.hxx"
#include "editor_screen.hxx"
#include "editor_panel.hxx"
#include "level_objs.hxx"
+#include "level_head.hxx"
#include "xml_level.hxx"
namespace Pingus {
@@ -213,6 +215,36 @@
}
}
+PanelButtonHead::PanelButtonHead(EditorPanel *p)
+ : PanelButton(p),
+ head(0)
+{
+ // FIXME: Update this sprite
+ sur = Resource::load_sprite("core/editor/save");
+ tooltip = "Set specific level information";
+}
+void
+PanelButtonHead::on_primary_button_click(int x, int y)
+{
+ PanelButton::on_primary_button_click(x, y);
+ if (!head)
+ {
+ head = new LevelHead(panel, this);
+ }
+ else
+ {
+ remove_head();
+ }
+}
+
+void
+PanelButtonHead::remove_head()
+{
+ delete head;
+ head = 0;
+}
+
+
} // Editor namespace
} // Pingus namespace
Modified: trunk/src/editor/panel_buttons.hxx
===================================================================
--- trunk/src/editor/panel_buttons.hxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/editor/panel_buttons.hxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -31,7 +31,8 @@
namespace Editor {
class EditorPanel;
-
+class LevelHead;
+
/** Generic PanelButton class - all buttons in the Editor should inherit from
this */
class PanelButton : public GUI::Component
{
@@ -110,7 +111,7 @@
/** Standard exit button */
-class PanelButtonExit : PanelButton
+class PanelButtonExit : public PanelButton
{
public:
/** Constructor
@@ -128,7 +129,7 @@
/** Standard load button */
-class PanelButtonLoad : PanelButton
+class PanelButtonLoad : public PanelButton
{
public:
/** Constructor
@@ -146,7 +147,7 @@
/** Standard save button */
-class PanelButtonSave : PanelButton
+class PanelButtonSave : public PanelButton
{
public:
/** Constructor
@@ -164,7 +165,7 @@
/** Display all of the groundpiece objects */
-class PanelButtonGroundpiece : PanelButton
+class PanelButtonGroundpiece : public PanelButton
{
public:
/** Constructor
@@ -183,6 +184,29 @@
PanelButtonGroundpiece& operator= (const PanelButtonGroundpiece&);
}; // PanelButtonGroundpiece class
+
+/** Display all of the level description <HEAD> information */
+class PanelButtonHead : public PanelButton
+{
+ private:
+ LevelHead* head;
+
+ public:
+ /** Constructor
+ @param p the EditorPanel to which this button belongs */
+ PanelButtonHead (EditorPanel* p);
+
+ /** This function is called by the gui_manager when the button is clicked
*/
+ virtual void on_primary_button_click (int x, int y);
+
+ void remove_head();
+
+ private:
+ PanelButtonHead ();
+ PanelButtonHead (const PanelButtonHead&);
+ PanelButtonHead& operator= (const PanelButtonHead&);
+}; // PanelButtonHead class
+
} // Editor namespace
} // Pingus namespace
Modified: trunk/src/gui/input_box.cxx
===================================================================
--- trunk/src/gui/input_box.cxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/gui/input_box.cxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -27,12 +27,13 @@
namespace GUI {
InputBox::InputBox(float width_, Vector p, const std::string& default_value,
- bool locked)
+ bool locked, const std::string& label_)
: str(default_value),
pos(p),
width(width_),
height((float)Fonts::pingus_small.get_height()),
- is_locked(locked)
+ is_locked(locked),
+ label(label_)
{
}
@@ -49,6 +50,9 @@
if (str != std::string())
gc.print_left(Fonts::pingus_small, pos.x + 10, pos.y,
shrink_string(str));
+ if (label != std::string())
+ gc.print_right(Fonts::pingus_small, pos.x, pos.y, label);
+
if (has_focus)
gc.draw_line(pos.x +
Fonts::pingus_small.get_size(shrink_string(str)).width + 12,
pos.y, pos.x +
Fonts::pingus_small.get_size(shrink_string(str)).width + 12,
@@ -87,7 +91,8 @@
else if ((c > 0x2c && c < 0x3a) // - . / 0-9
|| (c > 0x40 && c < 0x5b) // capital letters
|| (c > 0x60 && c < 0x7b) // lowercase letters
- || (c == 0x7e || c == 0x5f)) // ~ and _
+ || (c == 0x7e || c == 0x5f) // ~ and _
+ || c == 0x20) // space
str += c;
}
}
Modified: trunk/src/gui/input_box.hxx
===================================================================
--- trunk/src/gui/input_box.hxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/gui/input_box.hxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -41,10 +41,14 @@
/** Shrink the string to fit in the box */
std::string shrink_string(const std::string& s) const;
+
+ /** Optional label to display */
+ std::string label;
public:
InputBox(float width_, Vector p, const std::string&
- default_value = std::string(), bool locked = false);
+ default_value = std::string(), bool locked = false,
+ const std::string& label_ = std::string());
void set_string(const std::string& s) { str = s; }
std::string get_string() { return str; }
Modified: trunk/src/input_event.hxx
===================================================================
--- trunk/src/input_event.hxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/input_event.hxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -49,7 +49,7 @@
/** 'p' or 'Pause' got pressed */
PAUSE_PRESSED,
- FASTFORWARD_TRIGGERED
+ FASTFORWARD_TRIGGERED,
/** Buttons for switching to the next/previous Action */
ACTION_UP,
Modified: trunk/src/pingus_menu.hxx
===================================================================
--- trunk/src/pingus_menu.hxx 2006-01-24 01:44:58 UTC (rev 2624)
+++ trunk/src/pingus_menu.hxx 2006-02-05 20:49:22 UTC (rev 2625)
@@ -20,6 +20,7 @@
#ifndef HEADER_PINGUS_PINGUS_MENU_HXX
#define HEADER_PINGUS_PINGUS_MENU_HXX
+#include <vector>
#include "fonts.hxx"
#include "pingus_sub_menu.hxx"
#include "file_dialog_listener.hxx"
@@ -27,6 +28,7 @@
class CL_Key;
class CL_InputDevice;
+class CL_Slot;
namespace Pingus {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2625 - in trunk/src: . editor gui,
jave27 <=