From WiiBrew
Jump to navigation Jump to search

Source Included

libwsmenu is a brand new project with the intention of building a wrapper for libwiisprite to easily create menus for homebrew software. I would greatly appreciate any feedback on features that should be included, suggestions on implementation or if this even seems like a worthwhile project. Feel free to discuss on the talk page or to me privately at my gmail address, thavilden@..... I'm working out all the details here so the process can be open for feedback. I really hate when a "standard" sort of comes out without any community input and is lousy because the creator didn't think it through all the way. I fear I might be one of those creators.

Project Info


  • I've written some form of all the functions for the button class and am trying to test them now, but I'm having no luck getting the Draw() function to get anything on the screen. The demo includes a pointer using the Wiimote IR which draws, but the button does not, nor can I draw a TextField layer that I've used in other demos. I could use some help understanding what's going on in the Draw() and _Draw() functions, since I just copied them from libwiisprite's Sprite class.
  • Still can't get anything to draw. I've tried cutting the draw function down to just what's in libwiisprite but I still can't get it going. I got some text to display (by scrapping the demo in the source zip above and chopping up one of those other demos) but haven't found a good way to get debug information out.
  • Considering going back and just having the button class wrap around a pair or so of sprites, since I really can't figure out how to get Draw() working, even when I've reduced it to basically all that's in the Sprite class anyway.
  • Went back and started rebuilding the button class, saving the image stuff for last. I got to Draw(), copied EXACTLY what's in wsp::Sprite with all the necessary variables, and it goes from drawing to not drawing. I'll need to get a better idea of how it works. Talking to chaosteil is probably in order. Thav 01:52, 7 August 2008 (CEST)
  • Uploaded a new demo that actually shows the functionality. I didn't fix the drawing issue; I'm just using the Sprite draw function which limits me to displaying one image at a time, so no button Icon or text included yet. This demo just shows how to use the function pointer and initializing the button. Thav 02:04, 10 August 2008 (CEST)
  • Not dead, just still stuck on getting multiple images drawn in one function. The issue is that I can't redefine Sprite::Draw() since it's "const". In order to draw multiple images for the same button I need to overwrite a protected variable which violates the const. I may skip ahead and work on the Menu object instead and figure out how sorting the Buttons out will work. Thav 14:56, 10 September 2008 (UTC)
  • Probably pretty safe to call this dead by now. Never came up with a workaround for the protected variable business Thav 19:37, 9 October 2008 (UTC)

Proposed Features

  • Menu object that takes an array of Button objects, which each contain a function pointer, default button image, hover button image, selected button image, foreground icon and foreground text.
  • Menu object will have methods to check if any of the Buttons are being hovered over or selected and then will return or call their pointed function.
  • Allow copying a menu object, so that one main menu can be created with other sub menus copied therefrom and modified.

Possible issues

  • The menu, buttons and all will have to sit in a LayerManager, but LayerManager has no visible option, so where do we put the Menu when not in use? Or is it better to discard the menu from memory and rebuild later? Will look into how this is done on other software. Each menu/function can sit in its own LayerManager and be shoved offscreen when needed. Maybe if the manager is not drawn before a flush it will not appear? Will look into this.
  • When allowing some other function to access video that does not use libwiisprite (say an emulator) then how do we make sure the path is clear, so to speak?

Class Member Function Outline


Inherit from wsp::LayerManager so I don't have to re-implement managing the list. Broke out the constructor in the same was as Button here.

Code removed, see source download


Inheriting from the Sprite class now so I wouldn't have to copy the code for zoom, stretch, transparency, reference etc. Had to redefine a few of the private variables from Sprite because my SetImage will work a little differently. I have most of the functions written except for Draw (which I'm sure will take a while) so I can start testing in the next week or so.

For now, it looks like all the images will have to be the same size in the button so it can have a consistent collision rectangle and frame width/height. I'm not sure of the best way to throw an error back yet so I'm just going to have it do nothing if you muck it up.

Code removed, see source download

Development information

Borrowing heavily from