Author: sapient
Date: Sun Jun 8 07:34:52 2008
New Revision: 27043
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27043&view=rev
Log:
fix bug with filter + delete savegame (Gna! bug #11779)
Modified:
trunk/changelog
trunk/src/construct_dialog.cpp
trunk/src/construct_dialog.hpp
trunk/src/dialogs.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=27043&r1=27042&r2=27043&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Jun 8 07:34:52 2008
@@ -114,6 +114,7 @@
primary_unit on its own 'die' event (Gna! bug #11207 / Debian bug #448193
* Optimize titlescreen and credits rendering.
* Give its name to the "Fog clearer" (fixing blank in "Create Unit" dialog)
+ * fix bug with filter + delete savegame (Gna! bug #11779)
Version 1.5.0:
* campaigns:
Modified: trunk/src/construct_dialog.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/construct_dialog.cpp?rev=27043&r1=27042&r2=27043&view=diff
==============================================================================
--- trunk/src/construct_dialog.cpp (original)
+++ trunk/src/construct_dialog.cpp Sun Jun 8 07:34:52 2008
@@ -87,10 +87,10 @@
}
dialog::dimension_measurements::dimension_measurements() :
- x(-1),
- y(-1),
+ x(-1),
+ y(-1),
interior(empty_rect),
- message(empty_rect),
+ message(empty_rect),
textbox(empty_rect),
menu_width(0),
panes(),
@@ -111,8 +111,8 @@
}
dialog::dialog(display &disp, const std::string& title, const std::string&
message,
- const DIALOG_TYPE type, const style& dialog_style) :
- disp_(disp),
+ const DIALOG_TYPE type, const style& dialog_style) :
+ disp_(disp),
image_(NULL),
title_(title),
style_(dialog_style),
@@ -850,21 +850,32 @@
video().blit_surface(location().x, location().y, surf_);
}
-int filter_textbox::get_index(int index) const {
+int filter_textbox::get_index(int selection) const {
// don't translate special values
- if(index < 0) {
- return index;
+ if(selection < 0) {
+ return selection;
}
//we must add one to the index to ignore the header row, and
//then subtract one from the result to return the index not including
//the header row.
- index++;
-
- if (size_t(index) >= index_map_.size()) {
+
+ size_t header = 1; // for now, just assume there's a header row
+
+ if (size_t(selection+header) >= index_map_.size()) {
return -1; // bad index, cancel
}
- return index_map_[index]-1;
+ return index_map_[selection+header]-header;
+}
+
+void filter_textbox::delete_item(int selection) {
+ size_t header = 1; // for now, just assume there's a header row
+ filtered_items_.erase(filtered_items_.begin() + selection+header);
+ items_.erase(items_.begin() + index_map_[selection+header]);
+ index_map_.erase(index_map_.begin() + selection+header);
+
+ //for now, assume the dialog menu item is deleted using DELETE_ITEM
+ /* dialog_.set_menu_items(filtered_items_); */
}
void filter_textbox::handle_text_changed(const wide_string& text) {
@@ -880,7 +891,7 @@
index_map_.push_back(n);
}
}
-
+
dialog_.set_menu_items(filtered_items_);
}
Modified: trunk/src/construct_dialog.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/construct_dialog.hpp?rev=27043&r1=27042&r2=27043&view=diff
==============================================================================
--- trunk/src/construct_dialog.hpp (original)
+++ trunk/src/construct_dialog.hpp Sun Jun 8 07:34:52 2008
@@ -30,17 +30,17 @@
struct dialog_process_info
{
public:
- dialog_process_info() :
+ dialog_process_info() :
key(),
- left_button(true),
- right_button(true),
+ left_button(true),
+ right_button(true),
key_down(true),
- first_time(true),
+ first_time(true),
double_clicked(false),
new_left_button(false),
new_right_button(false),
new_key_down(false),
- selection(-1),
+ selection(-1),
clear_buttons_(false)
{}
@@ -132,7 +132,11 @@
set_text("");
}
- int get_index(int index) const;
+ // current menu selection is based on a possibly filtered view,
+ // and thus may differ from the original, unfiltered index
+ int get_index(int selection) const;
+ void delete_item(int selection);
+
private:
std::vector<std::string> items_, filtered_items_;
std::vector<int> index_map_;
Modified: trunk/src/dialogs.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=27043&r1=27042&r2=27043&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Sun Jun 8 07:34:52 2008
@@ -340,6 +340,9 @@
}
}
+ // Remove the item from filter_textbox memory
+ filter_.delete_item(menu_selection);
+
// Delete the file
delete_game(saves_[index].name);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits