Author: fendrin
Date: Fri Mar 11 21:55:42 2011
New Revision: 48847
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48847&view=rev
Log:
Made the editor familiar with the side concept.
Modified:
branches/editor/src/display.cpp
branches/editor/src/display.hpp
branches/editor/src/editor/editor_controller.cpp
branches/editor/src/editor/editor_controller.hpp
branches/editor/src/editor/editor_display.cpp
branches/editor/src/editor/editor_display.hpp
Modified: branches/editor/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/display.cpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/display.cpp (original)
+++ branches/editor/src/display.cpp Fri Mar 11 21:55:42 2011
@@ -116,7 +116,8 @@
redraw_observers_(),
draw_coordinates_(false),
draw_terrain_codes_(false),
- arrows_map_()
+ arrows_map_(),
+ flags_()
{
if(non_interactive()
&& (get_video_surface() != NULL
@@ -134,6 +135,63 @@
display::~display()
{
+}
+
+void display::load_flags() {
+ //TODO sort to the right place
+ // Inits the flag list and the team colors used by ~TC
+
+ flags_.clear();
+ //flags_.reserve(2);
+
+ ERR_DP << get_teams().size();
+ //TODO
+ flags_.reserve(get_teams().size());
+
+ std::vector<std::string> side_colors;
+ side_colors.reserve(get_teams().size());
+
+ for(size_t i = 0; i != get_teams().size(); ++i) {
+ std::string side_color = team::get_side_color_index(i+1);
+ side_colors.push_back(side_color);
+ std::string flag = get_teams()[i].flag();
+ std::string old_rgb = game_config::flag_rgb;
+ std::string new_rgb = side_color;
+
+ if(flag.empty()) {
+ flag = game_config::images::flag;
+ }
+
+ LOG_DP << "Adding flag for team " << i << " from animation " <<
flag << "\n";
+
+ // Must recolor flag image
+ animated<image::locator> temp_anim;
+
+ std::vector<std::string> items = utils::split(flag);
+ std::vector<std::string>::const_iterator itor = items.begin();
+ for(; itor != items.end(); ++itor) {
+ const std::vector<std::string>& items =
utils::split(*itor, ':');
+ std::string str;
+ int time;
+
+ if(items.size() > 1) {
+ str = items.front();
+ time = atoi(items.back().c_str());
+ } else {
+ str = *itor;
+ time = 100;
+ }
+ std::stringstream temp;
+ temp << str << "~RC(" << old_rgb << ">"<< new_rgb <<
")";
+ image::locator flag_image(temp.str());
+ temp_anim.add_frame(time, flag_image);
+ }
+ flags_.push_back(temp_anim);
+
+
flags_.back().start_animation(rand()%flags_.back().get_end_time(), true);
+ }
+ image::set_team_colors(&side_colors);
+ clear_screen();
}
const time_of_day& display::get_time_of_day(const map_location& /*loc*/) const
Modified: branches/editor/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/display.hpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/display.hpp (original)
+++ branches/editor/src/display.hpp Fri Mar 11 21:55:42 2011
@@ -60,6 +60,10 @@
display(CVideo& video, const gamemap* map, const config& theme_cfg,
const config& level);
virtual ~display();
+
+ //TODO sort to the right place
+ void load_flags();
+
/**
* Updates internals that cache map size. This should be called when
the map
@@ -834,6 +838,16 @@
typedef std::map<map_location, arrows_list_t > arrows_map_t;
/** Maps the list of arrows for each location */
arrows_map_t arrows_map_;
+
+protected:
+
+ virtual const std::vector<team>& get_teams() = 0;
+ //TODO move to the right place
+ //const std::vector<team>& teams_;
+
+ //TODO move to the right place
+ /** Animated flags for each team */
+ std::vector<animated<image::locator> > flags_;
};
#endif
Modified: branches/editor/src/editor/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/editor/editor_controller.cpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/editor/editor_controller.cpp (original)
+++ branches/editor/src/editor/editor_controller.cpp Fri Mar 11 21:55:42 2011
@@ -501,33 +501,35 @@
}
}
-//void editor_controller::new_side_dialog()
-//{
-// if (!use_mdi_ && !confirm_discard()) return;
-//
-// std::vector<team>& teams = get_map().get_teams();
-//
-// int side = get_map().get_teams().size();
-// std::string side_str = lexical_cast<std::string>(side);
-// std::string new_str = lexical_cast<std::string>(side +1);
-// //TODO make that translatable.
-// gui2::show_message(gui().video(), "Side created" , "The side number " +
side_str + " was created.");
-//
-// config side_cfg;
-// side_cfg["no_leader"] = "yes";
-// side_cfg["side"] = new_str;
-// //TODO remove or comment.
-// //get_map().get_state().build_team(dummy, "", get_map().get_teams(),
dummy, get_map()
-// // , get_map().get_units(), true);
-// team t(side_cfg, get_map(), 100);
-// //This may invalidate the teams vector
-// teams.push_back(t);
-// get_display().load_flags();
+void editor_controller::new_side_dialog()
+{
+ if (!use_mdi_ && !confirm_discard()) return;
+
+ std::vector<team>& teams = get_map().get_teams();
+
+ int side = get_map().get_teams().size();
+ std::string side_str = lexical_cast<std::string>(side);
+ std::string new_str = lexical_cast<std::string>(side +1);
+ //TODO make that translatable.
+ gui2::show_message(gui().video(), "Side created" , "The side number " +
side_str + " was created.");
+
+ config side_cfg;
+ side_cfg["no_leader"] = "yes";
+ side_cfg["side"] = new_str;
+ //TODO this snippet of code seems interresting at this point:
+ //get_map().get_state().build_team(dummy, "", get_map().get_teams(),
dummy, get_map()
+ // , get_map().get_units(), true);
+ team t;
+ t.build(side_cfg, get_map(), 100);
+
+ //This may invalidate the teams vector
+ teams.push_back(t);
+ get_display().load_flags();
// get_display().set_team(side -1, true);
// get_display().set_playing_team(side -1);
-// get_map_context().clear_undo_redo();
-// current_side_index_ = side -1;
-//}
+ get_map_context().clear_undo_redo();
+ current_side_index_ = side -1;
+}
void editor_controller::save_map_as_dialog()
@@ -1226,8 +1228,7 @@
revert_map();
return true;
case HOTKEY_EDITOR_SIDE_NEW:
-//TODO
- // new_side_dialog();
+ new_side_dialog();
return true;
case HOTKEY_EDITOR_MAP_NEW:
new_map_dialog();
Modified: branches/editor/src/editor/editor_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/editor/editor_controller.hpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/editor/editor_controller.hpp (original)
+++ branches/editor/src/editor/editor_controller.hpp Fri Mar 11 21:55:42 2011
@@ -138,6 +138,9 @@
/** Display a new map dialog and process user input. */
void new_map_dialog();
+
+ /** Display a new map dialog and process user input. */
+ void new_side_dialog();
/** Display a save map as dialog and process user input. */
void save_map_as_dialog();
Modified: branches/editor/src/editor/editor_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/editor/editor_display.cpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/editor/editor_display.cpp (original)
+++ branches/editor/src/editor/editor_display.cpp Fri Mar 11 21:55:42 2011
@@ -25,6 +25,8 @@
, brush_locations_()
, toolbar_hint_()
{
+ //TODO this gives an undefined reference, no idea why.
+ //singleton_ = this;
clear_screen();
}
Modified: branches/editor/src/editor/editor_display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/editor/src/editor/editor_display.hpp?rev=48847&r1=48846&r2=48847&view=diff
==============================================================================
--- branches/editor/src/editor/editor_display.hpp (original)
+++ branches/editor/src/editor/editor_display.hpp Fri Mar 11 21:55:42 2011
@@ -37,6 +37,9 @@
void rebuild_terrain(const map_location &loc);
void set_toolbar_hint(const std::string& value) { toolbar_hint_ =
value; }
+ /* Inherited from display*/
+ const std::vector<team>& get_teams() { return map().get_teams(); }
+
protected:
void pre_draw();
/**
@@ -51,6 +54,9 @@
std::set<map_location> brush_locations_;
std::string toolbar_hint_;
+
+ //TODO that is copied game_display.hpp find a use for it
+ static editor_display *singleton_;
};
} //end namespace editor
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits