pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2592 - in trunk/src: . editor


From: jave27
Subject: [Pingus-CVS] r2592 - in trunk/src: . editor
Date: Mon, 16 Jan 2006 03:35:29 +0100

Author: jave27
Date: 2006-01-16 03:35:07 +0100 (Mon, 16 Jan 2006)
New Revision: 2592

Modified:
   trunk/src/editor/editor_panel.cxx
   trunk/src/editor/editor_panel.hxx
   trunk/src/editor/panel_buttons.cxx
   trunk/src/pingus_main.cxx
   trunk/src/pingus_main.hxx
   trunk/src/resource.cxx
   trunk/src/resource.hxx
Log:
- Can now start the editor with the -e command line.
- Prepared the Resource class to return sections of the underlying 
CL_ResourceManager.



Modified: trunk/src/editor/editor_panel.cxx
===================================================================
--- trunk/src/editor/editor_panel.cxx   2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/editor/editor_panel.cxx   2006-01-16 02:35:07 UTC (rev 2592)
@@ -39,7 +39,8 @@
 EditorPanel::EditorPanel(EditorScreen* es)
 : editor(es), 
        pressed_button(0), 
-       combobox(0)
+       combobox_1(0),
+       combobox_2(0)
 {
 
 }
@@ -47,7 +48,6 @@
 // Destructor
 EditorPanel::~EditorPanel()
 {
-       delete combobox;
 }
 
 // Wait to run this until after the panel has been added to the gui_manager
@@ -63,9 +63,12 @@
        add((PanelButton*)(new PanelButtonGroundpiece(this)));
 
        // Create Combobox
-       combobox = new GUI::Combobox(Vector(500, 30));
-       get_screen()->get_gui_manager()->add(combobox);
-       combobox->set_enabled(false);
+       combobox_1 = new GUI::Combobox(Vector(500,  0));
+       combobox_2 = new GUI::Combobox(Vector(500, 30));
+       get_screen()->get_gui_manager()->add(combobox_1);
+       get_screen()->get_gui_manager()->add(combobox_2);
+       combobox_1->set_enabled(false);
+       combobox_2->set_enabled(false);
 }
 
 // Draw the panel
@@ -110,5 +113,19 @@
                pressed_button->select(true);
 }
 
+GUI::Combobox*
+EditorPanel::get_combobox(int i)
+{
+       switch(i)
+       {
+               case 1 :
+                       return combobox_1;
+               case 2 :
+                       return combobox_2;
+               default :
+                       return 0;
+       }
+}
+
 } // Editor namespace
 } // Pingus namespace

Modified: trunk/src/editor/editor_panel.hxx
===================================================================
--- trunk/src/editor/editor_panel.hxx   2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/editor/editor_panel.hxx   2006-01-16 02:35:07 UTC (rev 2592)
@@ -45,7 +45,8 @@
        std::vector<PanelButton*> panel_buttons;
 
        /** Combobox which can change it's item list based on the button 
pressed */
-       GUI::Combobox* combobox;
+       GUI::Combobox* combobox_1;
+       GUI::Combobox* combobox_2;
 
        /** Currently selected object on this panel */
        PanelButton* pressed_button;
@@ -73,7 +74,7 @@
        EditorScreen* get_screen() { return editor; }
        
        /** Return the combobox object */
-       GUI::Combobox* get_combobox() { return combobox; }
+       GUI::Combobox* get_combobox(int i);
        
        /** Changes which button is currently pressed */
        void set_selected_button(PanelButton* pb);

Modified: trunk/src/editor/panel_buttons.cxx
===================================================================
--- trunk/src/editor/panel_buttons.cxx  2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/editor/panel_buttons.cxx  2006-01-16 02:35:07 UTC (rev 2592)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <vector>
 #include <ClanLib/Display/sprite.h>
 #include "panel_buttons.hxx"
 #include "../gui/combobox.hxx"
@@ -149,11 +150,17 @@
        PanelButton::on_primary_button_click(x, y);
 
        // FIXME: Add actual groundpieces
-       panel->get_combobox()->clear();
-       panel->get_combobox()->set_label("Groundpieces");
-       panel->get_combobox()->add(new GUI::ComboItem(1, "Testing 1"));
-       panel->get_combobox()->add(new GUI::ComboItem(2, "Testing 2"));
-       panel->get_combobox()->set_enabled(true);
+       panel->get_combobox(1)->clear();
+       panel->get_combobox(1)->set_label("Groundpieces");
+       //std::vector<std::string> groundpieces = 
Resource::get_resources("sprite", "groundpieces");
+       std::vector<std::string> groundpieces = 
Resource::get_sections("groundpieces");
+       for (unsigned i = 0; i < groundpieces.size(); i++)
+       {
+               panel->get_combobox(1)->add(new GUI::ComboItem(1, 
groundpieces[i]));
+               std::cout << groundpieces[i] << std::endl;
+       }
+       
+       panel->get_combobox(1)->set_enabled(true);
 }
 
 } // Editor namespace

Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx   2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/pingus_main.cxx   2006-01-16 02:35:07 UTC (rev 2592)
@@ -69,6 +69,7 @@
 #include "preview_renderer.hxx"
 #include "worldmap/manager.hxx"
 #include "worldobj_factory.hxx"
+#include "editor/editor_screen.hxx"
 
 #if _MSC_VER >= 1400
 // Disable stupid deprecation warnings
@@ -123,6 +124,7 @@
 PingusMain::PingusMain() :
   show_credits(false),
   blitter_test(false),
+       editor(false),
   refresh_rate(60)
 {
 }
@@ -211,6 +213,8 @@
                   _("Load a custom level from FILE"));
   argp.add_option(358, "worldmap", _("FILE"),
                   _("Load a custom worldmap from FILE"));
+       argp.add_option('e', "editor", "",
+                  _("Loads the level editor"));
   argp.add_option('v', "verbose", "", 
                   _("Print some more messages to stdout, can be set multiple 
times to increase verbosity"));
   argp.add_option('V', "version", "", 
@@ -293,6 +297,9 @@
         case 'l': // -l, --level
           levelfile = argp.get_argument();
           break;
+                               
+                               case 'e': // -e, --editor
+                                       editor = true;
 
         case 't': // -t, --set-speed
           game_speed = atoi(argp.get_argument().c_str());
@@ -732,6 +739,10 @@
       WorldMapNS::WorldMapManager::instance()->load(worldmapfile);
       
ScreenManager::instance()->push_screen(WorldMapNS::WorldMapManager::instance());
     }
+       else if (editor == true)
+         {
+                       ScreenManager::instance()->push_screen (new 
Editor::EditorScreen());
+               }
   else // start a normal game
     {
       ScreenManager::instance()->push_screen (PingusMenuManager::instance (), 
false);

Modified: trunk/src/pingus_main.hxx
===================================================================
--- trunk/src/pingus_main.hxx   2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/pingus_main.hxx   2006-01-16 02:35:07 UTC (rev 2592)
@@ -37,6 +37,7 @@
   bool    blitter_test;
   bool    no_config_file;
   bool    show_credits;
+       bool            editor;
 
   /// the name of the exe: argv[0]
   std::string executable_name;

Modified: trunk/src/resource.cxx
===================================================================
--- trunk/src/resource.cxx      2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/resource.cxx      2006-01-16 02:35:07 UTC (rev 2592)
@@ -69,6 +69,32 @@
   
resmgr.add_resources(CL_ResourceManager(path_manager.complete("data/alias.xml")));
 }
 
+
+// Returns all resources in the given section
+std::vector<std::string>
+Resource::get_resources(const std::string& type, const std::string& section)
+{
+       if (section == "")
+               return resmgr.get_resources_of_type(type);
+       else
+               return resmgr.get_resources_of_type(type, section);
+}
+
+
+// Returns a list of sections
+std::vector<std::string>
+Resource::get_sections(const std::string& section)
+{
+       if (section == std::string())
+               return resmgr.get_all_sections();
+       else
+               // FIXME: This patch hasn't been applied to ClanLib yet.
+               // return resmgr.get_sections(section);
+               // The following is wrong.
+               return resmgr.get_all_sections();
+}
+
+
 void
 Resource::deinit()
 {

Modified: trunk/src/resource.hxx
===================================================================
--- trunk/src/resource.hxx      2006-01-15 02:08:53 UTC (rev 2591)
+++ trunk/src/resource.hxx      2006-01-16 02:35:07 UTC (rev 2592)
@@ -21,6 +21,7 @@
 #define HEADER_PINGUS_RESOURCE_HXX
 
 #include <map>
+#include <vector>
 #include <ClanLib/display.h>
 #include "res_descriptor.hxx"
 
@@ -42,6 +43,15 @@
   static CL_Surface apply_modifier (const CL_Surface&, const ResDescriptor& 
res_desc);
   static CL_PixelBuffer apply_modifier_to_pixelbuffer(CL_PixelBuffer, const 
ResDescriptor& res_desc);
 
+       /** Returns a list of resources for the given section.
+               Returns all if blank */
+       static std::vector<std::string> get_resources(const std::string &type,
+               const std::string &section = "");
+
+       /** Returns a list of sections under the given section.
+               Returns all sections if blank */
+       static std::vector<std::string> get_sections(const std::string &section 
= std::string());
+
 public:
   static void init();
   static void deinit();





reply via email to

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