GP32 Menu System For Gp2x/gp32


Inopia

Certified Guru
Joined
Jan 15, 2003
Messages
264
Hey guys,

I thought it would be a good idea to have a good, flexible menu system for emulators and such to ease the porting of emulators from computers with keyboards and mice and such to a console with only a stick and buttons.

Here is an example of what I've been writing over the past three days:

http://elektron.ewi.tudelft.nl/~brouwe25/menu.zip

Included is an SDL based win32 .exe and the main.cpp wich should illustrate how it works from a programmers perspective. The main idea is that you can create a tree of Menu objects, and simply call the 'enter' function on the root to bring up the menu. It's possible to create subclasses of menu, with different functionalities. Right now I have a checkbox (for turning things on/off), a select box (for choosing between different screen scaling methods for instance) and an action item (fires a callback function when selected). I plan to write a filebrowser as well.

The next thing I want to do is to allow nodes to have a (name,value) tuple, so you can call a save method on the rootnode that will save the entire menustate to a file, and ofcourse a load as well. This way you don't have to write a new config file saver/loader everytime.

I wrapped the SDL surface, so even though internally it's all 24bit, it could also work on gp32 with a little work. I also wrapped the SDL event polling thingie, so that should be easy to port to a non-SDL environment as well. It's all still very unoptimized, but it's a wip :)

Any thoughts, suggestions?

sdl.gif
 
Nice. I've been doing the same thing, but yours is prettier :p (I'm using all custom font rendering etc etc, no external code needed except for final blit and event gathering.. needed so it works on Pocket PC and SDL and GP32 etc :)

Nice work :)

jeff
 
My code doesn't need anything either. Just raw framebuffer. It's also skinnable. It should work on any platform that has a framebuffer (with minor porting). It's not fixed on 320x240 or anything, so it could work on psp as well for instance.
 
Very interested in this :) Looks very nice, and provides some nice functionality.

With the ones showing icons (top left, bottom right) - is it possible to have animated icons? Say, either accept icon data up front, or use a call back. That would be excellent, as it could then be used for animated savestates.

Also, how difficult would it actually be to port this to a raw framebuffer rather than SDL? I'm thinking of emu's that bypass Linux on the GP2X for performance reasons, and so SDL will not be available, just a frame buffer.
 
I was thinking and playing about with the idea of using something like this hooked into a u-boot strap to provide ELF or whatever launching without an under laying OS. I.e. Freelauncher GP2X ;-).

With Spiv about and given time surely we could come up with a commpressed homebrew format :) based on StoneCracker etc.. and offer 2 real options.

gpCrew 'leet' homebrew ;) or ARM-LINUX GCC 2.95 slooooow code :).
 
Please sir, can I be part of the l33t group? ;)

I'm thinking at the moment to be honest to create a version of GCC for the GP2X. It's not as stupid as it sounds. We could just loads of fiddling and messing about with that without having to use an SD card all the time. Either that, or some way of uploading code to Linux without have to use sneaker net :)

I'm getting that I don't want to run any code prior to Linux anymore as when it crashes, it means a power-cycle, and it could take about 10 minutes after that to get the board to actually work again. So linux is far safer at the moment, until we get boards that don't mind being power-cycled.
 
animated icons were not really a design goal, but I suppose I could add a timer event to the event polling code that forces redraws or something like that. I think that if you REALLY want it we can work something out.

Independence from SDL _was_ a design goal, there is a Surface class wich has a 'flip' method you need to implement (ie copy the buffer to the actual device, be it an SDL surface, the lunix framebuffer devide, or a GP32 or GP2X lowlevel hardware thing). So I suppose it could work on any handheld that has a framebuffer (psp, zodiac, etc)

I'll release the source once it's been cleaned up a bit.
 
Ok, so I did some more work on it. The saving/loading works now.

Loading:

Code:
	// initialize our config file
	configFile = new ConfigFile();
	configFile->load("config.txt");

	// load values from the config file
	menu->getValues(configFile);

Saving:

Code:
	configFile->clear();
	menu->addValues(configFile);
	configFile->save("config.txt");

On any Menu object you can call setName(). If you set the name of a menu item, it will be automatically saved/loaded by the code above.

I also added a confirmation option on the ActionMenu object, so you can have the user confirm before you actually reset/flash nand/etc.

The code is attached, there is still a lot to be done like optimizing the graphics code, minor graphical brush-ups, bug-fixes (if an image file doesn't exist the loader just crashes:), and I need to implement a file browser.

feedback would be appreciated :)
 
If you need any backgrounds, other graphics, etc. for the menu design, just say a word :) I'll be happy to help.
 
well the images are in the /skin directory, knock yourself out :) Should be pretty self explanatory
 
Back
Top