pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3081 - trunk/pingus/src/editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3081 - trunk/pingus/src/editor
Date: Wed, 5 Sep 2007 04:11:34 +0200

Author: grumbel
Date: 2007-09-05 04:11:34 +0200 (Wed, 05 Sep 2007)
New Revision: 3081

Modified:
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/editor/editor_screen.hpp
   trunk/pingus/src/editor/panel.cpp
   trunk/pingus/src/editor/panel.hpp
Log:
- added callbacks

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2007-09-05 01:40:24 UTC (rev 
3080)
+++ trunk/pingus/src/editor/editor_screen.cpp   2007-09-05 02:11:34 UTC (rev 
3081)
@@ -115,19 +115,6 @@
   //panel->set_selected_button(0);
 }
 
-// Play the current level (save to a temporary file 
-// then load it normally)
-void
-EditorScreen::play_level()
-{
-  // Ask, "Would you like to save first?".
-  // if so, save the file normally.
-
-  // Then save to a temporary file
-
-  // Load the temporary file
-}
-
 // Draw the background and components
 bool
 EditorScreen::draw(DrawingContext &gc)
@@ -176,7 +163,135 @@
   for (std::vector<LevelObj*>::const_iterator it = objs.begin(); it != 
objs.end(); it++)
     add_object(*it);
 }
+
+void 
+EditorScreen::level_new()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
 
+void 
+EditorScreen::level_load()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::level_save()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::level_save_as()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+void
+EditorScreen::level_play()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+  // Save to temporary file
+
+  // Load the temporary file
+  
+  // Play it
+}
+
+void 
+EditorScreen::show_level_properties()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::show_action_properties()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::show_object_properties()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_delete()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_raise_to_top()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_raise()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_lower()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_lower_to_bottom()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+
+void 
+EditorScreen::objects_flip_vertical()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_flip_horizontal()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_rotate_left()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+void 
+EditorScreen::objects_rotate_right()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+
+void 
+EditorScreen::toggle_grid_snap()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+
+void 
+EditorScreen::toggle_object_selector()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
+
+void 
+EditorScreen::toggle_help()
+{
+  std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is 
unimplemented" << std::endl; 
+}
+
 } // namespace Editor 
 
 /* EOF */

Modified: trunk/pingus/src/editor/editor_screen.hpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.hpp   2007-09-05 01:40:24 UTC (rev 
3080)
+++ trunk/pingus/src/editor/editor_screen.hpp   2007-09-05 02:11:34 UTC (rev 
3081)
@@ -101,10 +101,37 @@
   void load(const std::string &file);
 
   void load_level(const std::string& file);
+
+  // Functions accessible from the GUI
+  void level_new();
+  void level_load();
+  void level_save();
+  void level_save_as();
+  void level_play();
 
-  /** Plays the currently loaded level */
-  void play_level();
+  void show_level_properties();
+  void show_action_properties();
+  void show_object_properties();
 
+  void objects_delete();
+
+  void objects_raise_to_top();
+  void objects_raise();
+  void objects_lower();
+  void objects_lower_to_bottom();
+
+  void objects_flip_vertical();
+  void objects_flip_horizontal();
+
+  void objects_rotate_left();
+  void objects_rotate_right();
+
+  void toggle_grid_snap();
+
+  void toggle_object_selector();
+
+  void toggle_help();
+
 private:
   EditorScreen (const EditorScreen&);
   EditorScreen& operator= (const EditorScreen&);

Modified: trunk/pingus/src/editor/panel.cpp
===================================================================
--- trunk/pingus/src/editor/panel.cpp   2007-09-05 01:40:24 UTC (rev 3080)
+++ trunk/pingus/src/editor/panel.cpp   2007-09-05 02:11:34 UTC (rev 3081)
@@ -59,6 +59,8 @@
 class PanelButton : public GUI::Component
 {
 private:
+  EditorScreen* editor;
+
   Sprite button_raised;
   Sprite button_pressed;
   Sprite sprite;
@@ -67,15 +69,22 @@
   Vector2i    pos;
   std::string tooltip;
 
+  typedef void (EditorScreen::*Callback)();
+  Callback callback;
+
 public:
-  PanelButton(const Vector2i& pos_, const std::string& name, const 
std::string& tooltip_)
-    : button_raised(Resource::load_sprite("core/editor/button-raised")),
+  PanelButton(EditorScreen* editor_, 
+              const Vector2i& pos_, const std::string& name, const 
std::string& tooltip_, 
+              Callback callback_ = 0)
+    : editor(editor_),
+      button_raised(Resource::load_sprite("core/editor/button-raised")),
       button_pressed(Resource::load_sprite("core/editor/button-pressed")),
       sprite(Resource::load_sprite(name)),
       mouse_over(false),
       mouse_down(false),
       pos(pos_),
-      tooltip(tooltip_)
+      tooltip(tooltip_),
+      callback(callback_)
   {
   }
 
@@ -111,8 +120,11 @@
     mouse_down = true;
   }
 
-  void on_primary_button_release (int x, int y) { 
+  void on_primary_button_release (int x, int y) 
+  { 
     mouse_down = false;
+    if (mouse_over && callback)
+      ((*editor).*callback)();
   }
   
   bool is_at(int x, int y)
@@ -138,34 +150,34 @@
 {  
   editor->get_gui_manager()->add(this, true);
 
-  add_button("core/editor/document-new",  "New level");
-  add_button("core/editor/document-open", "Open level...");
-  add_button("core/editor/document-save", "Save level...");
-  add_button("core/editor/document-save-as", "Save level as...");
+  add_button("core/editor/document-new",  "New level", 
&EditorScreen::level_new);
+  add_button("core/editor/document-open", "Open level...", 
&EditorScreen::level_load);
+  add_button("core/editor/document-save", "Save level...", 
&EditorScreen::level_save);
+  add_button("core/editor/document-save-as", "Save level as...", 
&EditorScreen::level_save_as);
   add_separator();
-  add_button("core/editor/play", "Play level...");
+  add_button("core/editor/play", "Play level...", &EditorScreen::level_play);
   add_separator();
-  add_button("core/editor/actions", "Configure actions");
-  add_button("core/editor/document-properties", "Configure level");
-  add_button("core/editor/object-properties", "Display object properties");
+  add_button("core/editor/actions", "Configure actions", 
&EditorScreen::show_action_properties);
+  add_button("core/editor/document-properties", "Configure level", 
&EditorScreen::show_level_properties);
+  add_button("core/editor/object-properties", "Display object properties", 
&EditorScreen::show_object_properties);
   add_separator();
-  add_button("core/editor/delete", "Delete the selected objects");
+  add_button("core/editor/delete", "Delete the selected objects", 
&EditorScreen::objects_delete);
   add_separator();
-  add_button("core/editor/object-top",    "Raise object to top");
-  add_button("core/editor/object-up",     "Raise object");
-  add_button("core/editor/object-down",   "Lower object");
-  add_button("core/editor/object-bottom", "Lower object to bottom");
+  add_button("core/editor/object-top",    "Raise object to top", 
&EditorScreen::objects_raise_to_top);
+  add_button("core/editor/object-up",     "Raise object", 
&EditorScreen::objects_raise);
+  add_button("core/editor/object-down",   "Lower object", 
&EditorScreen::objects_lower);
+  add_button("core/editor/object-bottom", "Lower object to bottom", 
&EditorScreen::objects_lower_to_bottom);
   add_separator();
-  add_button("core/editor/object-flip-horizontal", "Flip object horizontally");
-  add_button("core/editor/object-flip-vertical", "Flip object vertically");
+  add_button("core/editor/object-flip-horizontal", "Flip object horizontally", 
&EditorScreen::objects_flip_horizontal);
+  add_button("core/editor/object-flip-vertical", "Flip object vertically", 
&EditorScreen::objects_flip_vertical);
   add_separator();
-  add_button("core/editor/object-rotate-left", "Rotate object 90 degree");
-  add_button("core/editor/object-rotate-right", "Rotate object -90 degree");
+  add_button("core/editor/object-rotate-left", "Rotate object 90 degree", 
&EditorScreen::objects_rotate_left);
+  add_button("core/editor/object-rotate-right", "Rotate object -90 degree", 
&EditorScreen::objects_rotate_right);
   add_separator();
-  add_button("core/editor/snap-grid", "Snap objects to grid");
-  add_button("core/editor/objects", "Show object insertion window");
+  add_button("core/editor/snap-grid", "Snap objects to grid", 
&EditorScreen::toggle_grid_snap);
+  add_button("core/editor/objects", "Show object insertion window", 
&EditorScreen::toggle_object_selector);
   add_separator();
-  add_button("core/editor/help", "Display help");
+  add_button("core/editor/help", "Display help", &EditorScreen::toggle_help);
 }
 
 Panel::~Panel()
@@ -188,9 +200,9 @@
 }
 
 void
-Panel::add_button(const std::string& image, const std::string& tooltip)
+Panel::add_button(const std::string& image, const std::string& tooltip, 
Callback callback)
 {
-  PanelButton* comp = new PanelButton(pos, image, tooltip);
+  PanelButton* comp = new PanelButton(editor, pos, image, tooltip, callback);
   pos.x += comp->get_width();
   editor->get_gui_manager()->add(comp, true);
 }
@@ -198,7 +210,7 @@
 void
 Panel::add_toggle_button(const std::string& image)
 {
-  PanelButton* comp = new PanelButton(pos, image, "");
+  PanelButton* comp = new PanelButton(editor, pos, image, "");
   pos.x += comp->get_width();
   editor->get_gui_manager()->add(comp, true);
 }

Modified: trunk/pingus/src/editor/panel.hpp
===================================================================
--- trunk/pingus/src/editor/panel.hpp   2007-09-05 01:40:24 UTC (rev 3080)
+++ trunk/pingus/src/editor/panel.hpp   2007-09-05 02:11:34 UTC (rev 3081)
@@ -38,6 +38,9 @@
   Sprite logo;
   Vector2i pos;
 
+  typedef void (EditorScreen::*Callback)();
+  Callback callback;
+
 public:
   Panel(EditorScreen* e);
   ~Panel();
@@ -45,7 +48,7 @@
   void draw (DrawingContext& gc);
   void update (float delta);
 
-  void add_button(const std::string& image, const std::string& tooltip = "");
+  void add_button(const std::string& image, const std::string& tooltip = "", 
Callback callback = 0);
   void add_toggle_button(const std::string& image);
   void add_separator();
   





reply via email to

[Prev in Thread] Current Thread [Next in Thread]