Adding to file menu

This example from GIMP is what I see in pretty much every program that has a recent files menu:


That’s what we should aim to do (without the Document History entry—we don’t need that).

I am good with all of this. A-coding I will go.

Still not sure where to put the code to create the preference to store the list of recent views but I will try to find a sensible place.

There are private member functions called by GameModule.build() which set up prefs. E.g., initIdentityPreferences(). I suggest adding another to contain the setup for this.

Successfully cloned from master but don’t seem to have the right to create a branch. Am able to work on this now and appreciate the advice from you and Brent.

You can create a branch in your own repo if you fork ours. (There’s a fork button on the GitHub page.)

1 Like

I have made some good progress but am now stuck and have to ask for some direction.

I have been able to create the headless preference. I can store loaded game file names to it and I can retrieve the values stored in it and put them in a List.

I have created an Open Recent submenu in file menu.

Where I am stuck is that I cannot figure out how to add the file names retrieved from the preference to the submenu. I need to use MenuManager.addKey() I think but while it I can get it to add a menu item, there is no text displayed. Plus, I cannnot determine how to associate an action with these menu items. I see GameState.addAction() but cannot tell how it works or if it is the right method to use.

A pointer in the right direction would be useful. I have pushed my code changes up to my forked branch on github. GitHub - derimmer/vassal at savedgamemenu

Thanks.

1 Like

My apologies—I didn’t give you enough information to know how to hook up all the parts.

Have a look at this PR and try it out. Does this do what you intended? It’s supposed to give an Open Recent menu which maxes out at 20 items.

1 Like

No apology necessary. I should have been able to figure this out with the information given.

The PR does exactly what I was trying to do (although I would limit the list to 6 items rather than 20 but that’s your choice). I assume you will decide whether you want to add this to VASSAL or not.

I did try it with several modules and it appeared to only show Recent items for that module rather than for any module. I am fine with that but some users may prefer it to show any Recent item regardless.

I will review the PR in more detail to learn where I went wrong - which appears at first glance to be everywhere!

1 Like

Showing recent files from modules other than the one you have loaded isn’t going to work. You can’t load logs or saves with a module they weren’t saved with, so we’d be showing users a bunch of items they can’t load, and we’d also have to check them all to make sure they’re loadable in order to disable the ones which aren’t.

1 Like