Author: ilor
Date: Fri Jul 25 23:52:29 2008
New Revision: 28203
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28203&view=rev
Log:
editor2: make editor2 use the palette, also what seems to fix one crash
Modified:
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/editor_palettes.cpp
trunk/src/editor2/editor_palettes.hpp
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=28203&r1=28202&r2=28203&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Fri Jul 25 23:52:29 2008
@@ -47,8 +47,8 @@
init(video);
size_specs_ = new size_specs();
adjust_sizes(gui(), *size_specs_);
- palette_ = new terrain_palette(gui(), *size_specs_, map_, game_config);
-// foreground_terrain(), background_terrain());
+ palette_ = new terrain_palette(gui(), *size_specs_, map_, game_config,
+ foreground_terrain(), background_terrain());
//brush_bar_ = new brush_bar(gui(), *size_specs_);
brushes_.push_back(brush());
@@ -68,6 +68,7 @@
cursor::set(cursor::NORMAL);
gui_->invalidate_game_status();
+ palette_->adjust_size();
refresh_all();
gui_->draw();
events::raise_draw_event();
@@ -85,6 +86,8 @@
editor_controller::~editor_controller()
{
+ delete palette_;
+ delete size_specs_;
delete gui_;
typedef std::pair<hotkey::HOTKEY_COMMAND, mouse_action*> apr;
foreach (apr a, mouse_actions_) {
@@ -444,7 +447,6 @@
void editor_controller::refresh_all()
{
adjust_sizes(gui(), *size_specs_);
- palette_->adjust_size();
//brush_bar_->adjust_size();
palette_->draw(true);
//brush_bar_->draw(true);
Modified: trunk/src/editor2/editor_palettes.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_palettes.cpp?rev=28203&r1=28202&r2=28203&view=diff
==============================================================================
--- trunk/src/editor2/editor_palettes.cpp (original)
+++ trunk/src/editor2/editor_palettes.cpp Fri Jul 25 23:52:29 2008
@@ -23,6 +23,7 @@
#include "../config.hpp"
#include "../sdl_utils.hpp"
#include "../serialization/string_utils.hpp"
+#include "../foreach.hpp"
#include "../image.hpp"
#include "../reports.hpp"
#include "../gettext.hpp"
@@ -45,11 +46,14 @@
}
terrain_palette::terrain_palette(display &gui, const size_specs &sizes,
- const gamemap
&map, const config& cfg)
+ const gamemap
&map, const config& cfg,
+
t_translation::t_terrain& fore,
+
t_translation::t_terrain& back)
: gui::widget(gui.video()), size_specs_(sizes), gui_(gui), tstart_(0),
checked_group_btn_(0), map_(map),
top_button_(gui.video(), "", gui::button::TYPE_PRESS,
"uparrow-button"),
- bot_button_(gui.video(), "", gui::button::TYPE_PRESS,
"downarrow-button")
+ bot_button_(gui.video(), "", gui::button::TYPE_PRESS,
"downarrow-button"),
+ selected_fg_terrain_(fore), selected_bg_terrain_(back)
{
// Get the available terrains temporary in terrains_
@@ -84,6 +88,7 @@
// add the terrain to the requested groups
const std::vector<std::string>& key =
utils::split(t_info.editor_group());
+ std::cerr << t_info.editor_group() << "\n";
for(std::vector<std::string>::const_iterator k_itor =
key.begin();
k_itor != key.end(); ++k_itor)
@@ -93,6 +98,10 @@
// Add the terrain to the default group
terrain_map_["all"].push_back(*t_itor);
+ }
+ typedef std::pair<std::string, t_translation::t_list> map_pair;
+ foreach (map_pair mp, terrain_map_) {
+ std::cerr << mp.first << mp.second.size() << "\n";
}
// Set the default group
@@ -344,25 +353,29 @@
}
void terrain_palette::draw(bool force) {
-
if (top_button_.pressed()) {
scroll_up();
}
if (bot_button_.pressed()) {
scroll_down();
}
- for(size_t i = 0; i < terrain_groups_.size(); ++i) {
- if(terrain_groups_[i].button.pressed()) {
- if(&terrain_groups_[i].button == checked_group_btn_) {
- checked_group_btn_->set_check(true);
- } else {
- checked_group_btn_->set_check(false);
- checked_group_btn_ = &terrain_groups_[i].button;
- set_group(terrain_groups_[i].id);
- }
+
+ foreach (terrain_group& g, terrain_groups_) {
+ if (g.button.pressed()) {
+ checked_group_btn_ = &g.button;
+ set_group(g.id);
break;
}
}
+
+ foreach (terrain_group& g, terrain_groups_) {
+ if (&g.button == checked_group_btn_) {
+ g.button.set_check(true);
+ } else {
+ g.button.set_check(false);
+ }
+ }
+
if (!dirty() && !force) {
return;
}
Modified: trunk/src/editor2/editor_palettes.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_palettes.hpp?rev=28203&r1=28202&r2=28203&view=diff
==============================================================================
--- trunk/src/editor2/editor_palettes.hpp (original)
+++ trunk/src/editor2/editor_palettes.hpp Fri Jul 25 23:52:29 2008
@@ -49,7 +49,9 @@
class terrain_palette : public gui::widget {
public:
terrain_palette(display &gui, const size_specs &sizes,
- const gamemap &map, const config& cfg);
+ const gamemap &map, const config& cfg,
+ t_translation::t_terrain& fore,
+ t_translation::t_terrain& back);
//! Scroll the terrain-palette up one step if possible.
void scroll_up();
@@ -139,11 +141,12 @@
//! otherwise things will fail. Thus should be set in constructor.
gui::button *checked_group_btn_;
- t_translation::t_terrain selected_fg_terrain_, selected_bg_terrain_;
const gamemap &map_;
gui::button top_button_, bot_button_;
size_t button_x_, top_button_y_, bot_button_y_;
size_t nterrains_, terrain_start_;
+ t_translation::t_terrain& selected_fg_terrain_;
+ t_translation::t_terrain& selected_bg_terrain_;
};
//! A bar where the brush is drawn
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits