Help with UI events
Moderator: Forum Moderators
Help with UI events
I'm new to the wesnoth code. I downloaded the 1.2 code from svn today, so that I could start tinkering with it. I figured that adding a "Delete All" button to the load game dialog would be a good way to start. It sounds even easier than this stuff, and it's something I've always wanted. (I tend to learn from experience, so simply reading is of limited usefulness to me).
I didn't have any trouble getting a new button to show up (though I don't like the layout), and it wasn't too hard to get the button to actually delete all the save files. The problem I have is that after I delete all the files, the load game dialog does not disappear. Instead, the currently selected save game is removed from the list, the next game is selected, and the preview pane disappears (because the file's been deleted). Neither of the delete buttons has any effect at this point, but hitting Cancel works fine. Hitting Load after that makes it complain about not having any save files, as expected.
Implementation: I've made a copy of delete_save class. Here's what I changed:
Does anyone see what I'm missing?
I didn't have any trouble getting a new button to show up (though I don't like the layout), and it wasn't too hard to get the button to actually delete all the save files. The problem I have is that after I delete all the files, the load game dialog does not disappear. Instead, the currently selected save game is removed from the list, the next game is selected, and the preview pane disappears (because the file's been deleted). Neither of the delete buttons has any effect at this point, but hitting Cancel works fine. Hitting Load after that makes it complain about not having any save files, as expected.
Implementation: I've made a copy of delete_save class. Here's what I changed:
Code: Select all
/*
//delete the file
delete_game(saves_[index].name);
//remove it from the list of saves
saves_.erase(saves_.begin() + index);
if(index < summaries_.size()) {
summaries_.erase(summaries_.begin() + index);
}
*/
std::vector<save_info>::const_iterator i;
for (i = saves_.begin(); i != saves_.end(); ++i) {
delete_game(i->name);
}
saves_.clear();
summaries_.clear();
search the code for 'DELETE_ITEM' (in 1.2 the relevant code is in show_dialog.cpp) and you'll find what you're looking for.
However, if you really want to work on the GUI you should be using trunk (which has far more support for dialog customization). The base class in filechooser.cpp (used by the editor) needs to continue being expanded so that it can also serve as the load/save game dialog.
However, if you really want to work on the GUI you should be using trunk (which has far more support for dialog customization). The base class in filechooser.cpp (used by the editor) needs to continue being expanded so that it can also serve as the load/save game dialog.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Ah, got it! Thank you! I actually did try reading show_dialog() (ow! my eyes!), but for whatever reason, I didn't think to search it.Sapient wrote:search the code for 'DELETE_ITEM' (in 1.2 the relevant code is in show_dialog.cpp) and you'll find what you're looking for.
However, if you really want to work on the GUI you should be using trunk (which has far more support for dialog customization). The base class in filechooser.cpp (used by the editor) needs to continue being expanded so that it can also serve as the load/save game dialog.
The reason I chose 1.2 is that with a little luck, I could get this patch submitted and accepted, and then moved into the debian package, where I can begin using it much sooner. Anyway, I'll take a look at 1.3 once I'm done with this patch, but I think I'll try one or two more easy things before investigating filechooser.cpp.