Help with UI events

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
NeoPhile
Posts: 155
Joined: July 22nd, 2004, 4:33 am
Location: Halifax, NS, Canada
Contact:

Help with UI events

Post by NeoPhile » January 26th, 2007, 2:44 am

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:

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();
Does anyone see what I'm missing?

User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient » January 26th, 2007, 3:24 am

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.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

NeoPhile
Posts: 155
Joined: July 22nd, 2004, 4:33 am
Location: Halifax, NS, Canada
Contact:

Post by NeoPhile » January 26th, 2007, 9:19 pm

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.
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.

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.

ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Post by ott » January 27th, 2007, 8:58 pm

NeoPhile wrote:The reason I chose 1.2 is that with a little luck, I could get this patch submitted and accepted
This sounds quite unlikely -- as far as I understand, 1.2 is not supposed to be for new features.
This quote is not attributable to Antoine de Saint-Exupéry.

NeoPhile
Posts: 155
Joined: July 22nd, 2004, 4:33 am
Location: Halifax, NS, Canada
Contact:

Post by NeoPhile » January 28th, 2007, 3:04 am

ott wrote:This sounds quite unlikely -- as far as I understand, 1.2 is not supposed to be for new features.
Even that minor? Oh well, thanks for the heads-up.

User avatar
Noyga
Inactive Developer
Posts: 1790
Joined: September 26th, 2005, 5:56 pm
Location: France

Post by Noyga » January 28th, 2007, 5:48 pm

Since it doesn't look to break compatibility and doesn't look like a major change, i think i might be ok to go in 1.2.x.
"Ooh, man, my mage had a 30% chance to miss, but he still managed to hit! Awesome!" ;) -- xtifr

Post Reply