mail[Wesnoth-commits] r28322 - in /trunk: data/ data/gui/default/window/ data/themes/ src/ src/editor2/ src/gui/dialogs/ src/gui/widgets/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by kailoran on August 04, 2008 - 15:02:
Author: ilor
Date: Mon Aug  4 14:36:59 2008
New Revision: 28322

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28322&view=rev
Log:
editor2: random map generate dialog stub, refresh image cache option

Added:
    trunk/data/gui/default/window/editor_generate_map.cfg
      - copied, changed from r28316, 
trunk/data/gui/default/window/editor_new_map.cfg
    trunk/src/gui/dialogs/editor_generate_map.cpp   (with props)
    trunk/src/gui/dialogs/editor_generate_map.hpp   (with props)
Modified:
    trunk/data/_main.cfg
    trunk/data/themes/editor2.cfg
    trunk/src/CMakeLists.txt
    trunk/src/Makefile.am
    trunk/src/SConscript
    trunk/src/editor2/editor_controller.cpp
    trunk/src/editor2/editor_controller.hpp
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp
    trunk/src/hotkeys.cpp
    trunk/src/hotkeys.hpp

Modified: trunk/data/_main.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/_main.cfg?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/data/_main.cfg (original)
+++ trunk/data/_main.cfg Mon Aug  4 14:36:59 2008
@@ -24,6 +24,7 @@
     [textdomain]
         name="wesnoth-editor"
     [/textdomain]
+       {multiplayer/scenarios/Random_Scenario.cfg}
 #endif
     {campaigns/}
     {scenario-test.cfg}

Copied: trunk/data/gui/default/window/editor_generate_map.cfg (from r28316, 
trunk/data/gui/default/window/editor_new_map.cfg)
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/editor_generate_map.cfg?p2=trunk/data/gui/default/window/editor_generate_map.cfg&p1=trunk/data/gui/default/window/editor_new_map.cfg&r1=28316&r2=28322&rev=28322&view=diff
==============================================================================
--- trunk/data/gui/default/window/editor_new_map.cfg (original)
+++ trunk/data/gui/default/window/editor_generate_map.cfg Mon Aug  4 14:36:59 
2008
@@ -3,8 +3,8 @@
 ###
 
 [window]
-       id = "editor_new_map"
-       description = "New map dialog."
+       id = "editor_generate_map"
+       description = "Generate random map dialog."
 
        [resolution]
                definition = "default"
@@ -23,76 +23,10 @@
                                        horizontal_alignment = "left"
                                        [label]
                                                definition = "title"
-                                               label = _ "New Map"
+                                               label = _ "Generate Random 
Map"
                                        [/label]
                                [/column]
                        [/row]                  
-                       [row]
-                               grow_factor = 0
-                               [column]
-                                       grow_factor = 1
-                                       horizontal_grow = "true"
-                                       [grid]
-                                               [row]
-                                                       grow_factor = 1
-                                                       [column]
-                                                               grow_factor = 0
-                                                               border = "all"
-                                                               border_size = 
5
-                                                               
horizontal_alignment = "left"
-                                                               [label]
-                                                                       
definition = "default"
-                                                                       label 
= _ "Width:"
-                                                               [/label]
-                                                       [/column]             
                  
-                                                       [column]
-                                                               grow_factor = 
1
-                                                               border = "all"
-                                                               border_size = 
5
-                                                               
horizontal_alignment = "left"
-                                                               [text_box]
-                                                                       id = 
"width"
-                                                                       
definition = "default"
-                                                                       label 
= _ "Width"
-                                                               [/text_box]
-                                                       [/column]
-                                               [/row]
-                                       [/grid]
-                               [/column]
-                       [/row]
-                       [row]
-                               grow_factor = 0
-                               [column]
-                                       grow_factor = 1
-                                       horizontal_grow = "true"
-                                       [grid]
-                                               [row]
-                                                       grow_factor = 1
-                                                       [column]
-                                                               grow_factor = 0
-                                                               border = "all"
-                                                               border_size = 
5
-                                                               
horizontal_alignment = "left"
-                                                               [label]
-                                                                       
definition = "default"
-                                                                       label 
= _ "Height:"
-                                                               [/label]
-                                                       [/column]             
                  
-                                                       [column]
-                                                               grow_factor = 
1
-                                                               border = "all"
-                                                               border_size = 
5
-                                                               
horizontal_alignment = "left"
-                                                               [text_box]
-                                                                       id = 
"height"
-                                                                       
definition = "default"
-                                                                       label 
= _ "Height"
-                                                               [/text_box]
-                                                       [/column]
-                                               [/row]
-                                       [/grid]
-                               [/column]
-                       [/row]
                        [row]
                                grow_factor = 0
                                [column]
@@ -106,10 +40,20 @@
                                                                border_size = 
5
                                                                
horizontal_alignment = "right"
                                                                [button]
-                                                                       id = 
"ok"
+                                                                       id = 
"settings"
                                                                        
definition = "default"
-                                                                       
size_text = _ "Create new map"
-                                                                       label 
= _ "Create new map"
+                                                                       
size_text = _ "Settings"
+                                                                       label 
= _ "Settings"
+                                                               [/button]
+                                                       [/column]
+                                                       [column]
+                                                               border = "all"
+                                                               border_size = 
5
+                                                               
horizontal_alignment = "right"
+                                                               [button]
+                                                                       id = 
"generate"
+                                                                       
definition = "default"
+                                                                       label 
= _ "Generate"
                                                                [/button]
                                                        [/column]
                                                        [column]

Modified: trunk/data/themes/editor2.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/themes/editor2.cfg?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/data/themes/editor2.cfg (original)
+++ trunk/data/themes/editor2.cfg Mon Aug  4 14:36:59 2008
@@ -140,7 +140,7 @@
                        id=menu-editor-map
                        title= _ "Map"
                        image=lite
-                       
items=editor-map-resize,editor-map-rotate,editor-map-flip-x,editor-map-flip-y,editor-map-generate,editor-refresh,editor-update-transitions,editor-auto-update-transitions
+                       
items=editor-map-resize,editor-map-rotate,editor-map-flip-x,editor-map-flip-y,editor-map-generate,editor-refresh,editor-update-transitions,editor-auto-update-transitions,editor-refresh-image-cache
             rect="+2,=,+100,="
             xanchor=fixed
             yanchor=fixed

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Mon Aug  4 14:36:59 2008
@@ -308,6 +308,7 @@
 IF(ENABLE_EDITOR2)
 
 SET(wesnoth-editor2_SRC
+    gui/dialogs/editor_generate_map.cpp
     gui/dialogs/editor_new_map.cpp
     editor2/action.cpp
     editor2/brush.cpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Aug  4 14:36:59 2008
@@ -153,6 +153,7 @@
     
 # used with editor2 option in the wesnoth target
 wesnoth_editor2_SOURCES = \
+       gui/dialogs/editor_generate_map.cpp \
        gui/dialogs/editor_new_map.cpp \
        editor2/action.cpp \
        editor2/brush.cpp \

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Mon Aug  4 14:36:59 2008
@@ -245,6 +245,7 @@
 
 # used with editor2 option in the wesnoth target
 wesnoth_editor2_sources = Split("""
+    gui/dialogs/editor_generate_map.cpp
     gui/dialogs/editor_new_map.cpp
     editor2/action.cpp
     editor2/brush.cpp

Modified: trunk/src/editor2/editor_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Mon Aug  4 14:36:59 2008
@@ -20,6 +20,7 @@
 #include "mouse_action.hpp"
 
 #include "gui/dialogs/editor_new_map.hpp"
+#include "gui/dialogs/editor_generate_map.hpp"
 #include "gui/widgets/button.hpp"
 
 #include "../config_adapter.hpp"
@@ -31,6 +32,8 @@
 #include "../foreach.hpp"
 #include "../gettext.hpp"
 #include "../hotkeys.hpp"
+#include "../map_create.hpp"
+#include "../mapgen.hpp"
 #include "../preferences.hpp"
 #include "../wml_exception.hpp"
 
@@ -42,7 +45,7 @@
 : controller_base(SDL_GetTicks(), game_config, video)
 , mouse_handler_base(get_map())
 , map_context_(editor_map(game_config, 44, 33, t_translation::GRASS_LAND))
-, gui_(NULL), do_quit_(false), quit_mode_(EXIT_ERROR)
+, gui_(NULL), map_generator_(NULL), do_quit_(false), quit_mode_(EXIT_ERROR)
 , auto_update_transitions_(true)
 {
        init(video);
@@ -78,6 +81,7 @@
        palette_->adjust_size();
        refresh_all();
        gui_->draw();
+       palette_->draw(true);
        events::raise_draw_event();     
 }
 
@@ -96,6 +100,7 @@
        delete palette_;
        delete size_specs_;
        delete floating_label_manager_;
+       delete map_generator_;
     delete gui_;
        typedef std::pair<hotkey::HOTKEY_COMMAND, mouse_action*> apr;
        foreach (apr a, mouse_actions_) {
@@ -152,7 +157,7 @@
 void editor_controller::new_map_dialog()
 {
        if (!confirm_discard()) return;
-       gui2::teditor_new_map dialog;;
+       gui2::teditor_new_map dialog;
        dialog.set_map_width(get_map().total_width());
        dialog.set_map_height(get_map().total_height());
        
@@ -194,6 +199,30 @@
        } while (overwrite_res != 0);
 
        save_map_as(input_name);
+}
+
+
+void editor_controller::generate_map_dialog()
+{
+       if (map_generator_ == NULL) {
+               // Initialize the map generator if it has not been used before
+               const config* const toplevel_cfg = 
game_config_.find_child("multiplayer","id","multiplayer_Random_Map");
+               const config* const cfg = toplevel_cfg == NULL ? NULL : 
toplevel_cfg->child("generator");
+               if (cfg == NULL) {
+                       WRN_ED << "No random map generator\n";
+                       return;
+               }
+               else {
+                       map_generator_ = create_map_generator("", cfg);
+               }
+       }
+       if (!confirm_discard()) return;
+       if (!confirm_discard()) return;
+       gui2::teditor_generate_map dialog;
+       dialog.show(gui().video());
+       if (map_generator_->allow_user_config()) {
+               map_generator_->user_config(gui());
+       }
 }
 
 bool editor_controller::save_map_as(const std::string& filename)
@@ -339,6 +368,7 @@
                case HOTKEY_EDITOR_REFRESH:
                case HOTKEY_EDITOR_UPDATE_TRANSITIONS:
                case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS:
+               case HOTKEY_EDITOR_REFRESH_IMAGE_CACHE:
                        return true;
                default:
                        return false;
@@ -432,6 +462,9 @@
                case HOTKEY_EDITOR_MAP_SAVE_AS:
                        save_map_as_dialog();
                        return true;
+               case HOTKEY_EDITOR_MAP_GENERATE:
+                       generate_map_dialog();
+                       return true;
                case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS:
                        auto_update_transitions_ = !auto_update_transitions_;
                        if (!auto_update_transitions_) {
@@ -445,6 +478,9 @@
                        reload_map();
                        return true;
                        break;
+               case HOTKEY_EDITOR_REFRESH_IMAGE_CACHE:
+                       refresh_image_cache();
+                       return true;
                default:
                        return controller_base::execute_command(command, 
index);
        }
@@ -582,6 +618,10 @@
        return mouse_action_;
 }
 
+void editor_controller::refresh_image_cache() {
+       image::flush_cache();
+       refresh_all();
+}
 
 void editor_controller::refresh_after_action(bool drag_part)
 {

Modified: trunk/src/editor2/editor_controller.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.hpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.hpp (original)
+++ trunk/src/editor2/editor_controller.hpp Mon Aug  4 14:36:59 2008
@@ -33,6 +33,7 @@
 #include <boost/utility.hpp>
 
 class config;
+class map_generator;
 
 namespace tooltips {
 class manager;
@@ -69,6 +70,7 @@
                void load_map_dialog();
                void new_map_dialog();
                void save_map_as_dialog();
+               void generate_map_dialog();
                bool save_map(bool display_confirmation = false);
                bool save_map_as(const std::string& filename);
                void new_map(int width, int height, t_translation::t_terrain 
fill);
@@ -111,6 +113,8 @@
                /** init the display object and general set-up */ 
                void init(CVideo& video);
                
+               void refresh_image_cache();
+               
                void refresh_after_action(bool drag_part = false);
                
                void refresh_all();
@@ -130,6 +134,8 @@
                
                /** The display object used and owned by the editor. */
                editor_display* gui_;
+               
+               map_generator* map_generator_;
                
                size_specs* size_specs_;
                terrain_palette* palette_;

Added: trunk/src/gui/dialogs/editor_generate_map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_generate_map.cpp?rev=28322&view=auto
==============================================================================
--- trunk/src/gui/dialogs/editor_generate_map.cpp (added)
+++ trunk/src/gui/dialogs/editor_generate_map.cpp Mon Aug  4 14:36:59 2008
@@ -1,0 +1,50 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <koraq@xxxxxxxxx>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#include "gui/dialogs/editor_generate_map.hpp"
+
+#include "gui/widgets/button.hpp"
+#include "gui/widgets/widget.hpp"
+#include "gui/widgets/window.hpp"
+#include "gui/widgets/window_builder.hpp"
+#include "gui/widgets/settings.hpp"
+#include "gui/widgets/text_box.hpp"
+#include "log.hpp"
+#include "wml_exception.hpp"
+
+#define DBG_GUI LOG_STREAM_INDENT(debug, widget)
+#define LOG_GUI LOG_STREAM_INDENT(info, widget)
+#define WRN_GUI LOG_STREAM_INDENT(warn, widget)
+#define ERR_GUI LOG_STREAM_INDENT(err, widget)
+
+namespace gui2 {
+
+teditor_generate_map::teditor_generate_map()
+{
+}
+
+twindow teditor_generate_map::build_window(CVideo& video)
+{
+       return build(video, get_id(EDITOR_GENERATE_MAP));
+}
+
+void teditor_generate_map::pre_show(CVideo& /*video*/, twindow& window)
+{
+}
+
+void teditor_generate_map::post_show(twindow& window)
+{
+}
+
+} // namespace gui2

Propchange: trunk/src/gui/dialogs/editor_generate_map.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/editor_generate_map.cpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Added: trunk/src/gui/dialogs/editor_generate_map.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_generate_map.hpp?rev=28322&view=auto
==============================================================================
--- trunk/src/gui/dialogs/editor_generate_map.hpp (added)
+++ trunk/src/gui/dialogs/editor_generate_map.hpp Mon Aug  4 14:36:59 2008
@@ -1,0 +1,40 @@
+/* $Id$ */
+/*
+   copyright (c) 2008 by mark de wever <koraq@xxxxxxxxx>
+   part of the battle for wesnoth project http://www.wesnoth.org/
+
+   this program is free software; you can redistribute it and/or modify
+   it under the terms of the gnu general public license version 2
+   or at your option any later version.
+   this program is distributed in the hope that it will be useful,
+   but without any warranty.
+
+   see the copying file for more details.
+*/
+
+#ifndef GUI_DIALOGS_EDITOR_GENERATE_MAP_HPP_INCLUDED
+#define GUI_DIALOGS_EDITOR_GENERATE_MAP_HPP_INCLUDED
+
+#include "gui/dialogs/dialog.hpp"
+
+namespace gui2 {
+
+class teditor_generate_map : public tdialog
+{
+public:
+       teditor_generate_map();
+       
+private:
+       /** Inherited from tdialog. */
+       twindow build_window(CVideo& video);
+
+       /** Inherited from tdialog. */
+       void pre_show(CVideo& video, twindow& window);
+
+       /** Inherited from tdialog. */
+       void post_show(twindow& window);
+};
+
+} // namespace gui2
+
+#endif

Propchange: trunk/src/gui/dialogs/editor_generate_map.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/editor_generate_map.hpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Mon Aug  4 14:36:59 2008
@@ -90,6 +90,7 @@
        window_type_list[MP_CREATE_GAME] = "mp_create_game";
 #ifdef USE_EDITOR2     
        window_type_list[EDITOR_NEW_MAP] = "editor_new_map";
+       window_type_list[EDITOR_GENERATE_MAP] = "editor_generate_map";
 #endif
 }
 

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Mon Aug  4 14:36:59 2008
@@ -43,6 +43,7 @@
        MP_CREATE_GAME,          /**< The mp creation dialog. */
 #ifdef USE_EDITOR2
        EDITOR_NEW_MAP,          //<! New map dialog
+       EDITOR_GENERATE_MAP,     /** Editor random map genarator dialog */
 #endif
        DUMMY                    //<! Dummy always the last one.
 };

Modified: trunk/src/hotkeys.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/hotkeys.cpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/hotkeys.cpp (original)
+++ trunk/src/hotkeys.cpp Mon Aug  4 14:36:59 2008
@@ -178,6 +178,9 @@
                N_("Update Terrain Tranistions"), false, hotkey::SCOPE_EDITOR 
},
        { hotkey::HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS, 
"editor-auto-update-transitions", 
                N_("Auto-update Terrain Transitions"), false, 
hotkey::SCOPE_EDITOR },   
+       { hotkey::HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, 
"editor-refresh-image-cache", 
+               N_("Refresh Image Cache"), false, hotkey::SCOPE_EDITOR },     
  
+       
 #endif
 
        { hotkey::HOTKEY_DELAY_SHROUD, "delayshroud", N_("Delay Shroud 
Updates"), false, hotkey::SCOPE_GAME },

Modified: trunk/src/hotkeys.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/hotkeys.hpp?rev=28322&r1=28321&r2=28322&view=diff
==============================================================================
--- trunk/src/hotkeys.hpp (original)
+++ trunk/src/hotkeys.hpp Mon Aug  4 14:36:59 2008
@@ -87,6 +87,7 @@
        HOTKEY_EDITOR_MAP_GENERATE,
        HOTKEY_EDITOR_REFRESH, HOTKEY_EDITOR_UPDATE_TRANSITIONS,
        HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS,
+       HOTKEY_EDITOR_REFRESH_IMAGE_CACHE,
 #endif
 
        //misc.




Related Messages


Powered by MHonArc, Updated Mon Aug 04 17:21:01 2008