SIO2 Menus - Using Widgets
+2
oioioi
Jawdy
6 posters
Page 1 of 2 • 1, 2
SIO2 Menus - Using Widgets
Hey all,
I'm using Widgets to draw my menu items - these are going great.
But, to do my actual "Menu's" I'm using the SIO2window->_SIO2windowrender functions to jump to the next menu. The problem comes from wanting to go back.
So I have my main menu, press "Play" and this goes to my game. In the Game section I have a button that says "Menu", which crashes rather than goes back to the main menu windowrender method.
Am I using these in a completely wrong way? Does anyone have any tips for creating menus? I seem to have Widgets under control, but am obviously being thick when it comes to the whole menu thing.
Cheers!
Jawdy
I'm using Widgets to draw my menu items - these are going great.
But, to do my actual "Menu's" I'm using the SIO2window->_SIO2windowrender functions to jump to the next menu. The problem comes from wanting to go back.
So I have my main menu, press "Play" and this goes to my game. In the Game section I have a button that says "Menu", which crashes rather than goes back to the main menu windowrender method.
Am I using these in a completely wrong way? Does anyone have any tips for creating menus? I seem to have Widgets under control, but am obviously being thick when it comes to the whole menu thing.
Cheers!
Jawdy
Re: SIO2 Menus - Using Widgets
Where does your code crash?
I haven't made a menu for my current project but I did for some old shit I gave up some time ago. First I loaded the texture for the menu, when the game started I unloaded all the menu textures and the loaded the game stuff. I had a small in-game menu which was loaded with the game, but when you went back to the main menu I unloaded all game stuff and loaded the menu textures. I didn't use SIO2widgets thought.
I haven't made a menu for my current project but I did for some old shit I gave up some time ago. First I loaded the texture for the menu, when the game started I unloaded all the menu textures and the loaded the game stuff. I had a small in-game menu which was loaded with the game, but when you went back to the main menu I unloaded all game stuff and loaded the menu textures. I didn't use SIO2widgets thought.
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: SIO2 Menus - Using Widgets
It crashes when I try to use the SIO2Window->_SIO2windowrender function to go back to the Main Menu.
I have two render methods - one for the game, and the second for the menu. In the code, I have my declarations/variables etc; then the "Game" render method; then the "Menu" render method; then all the loading code.
I start with the SIO2 splash screen, this does an _SIO2windowrender to the main menu. When you press "Play" (which is a simple widget in the Main Menu) then this goes to the Game. This works fine. But I have a button called "Menu" in the "Game" render method, and this wont go back to the Menu method.
I think it's something to do with me having all of this (it's a very simple app, just to test menu's) in the Template.mm file, rather than splitting it up. I'm basically after some suggestions and ways of doing this properly... I'm loathed to start from scratch, but if I'm doing this all wrong (and someone can suggest a good way of doing it!) then I'll start a fresh.
Cheers.
I have two render methods - one for the game, and the second for the menu. In the code, I have my declarations/variables etc; then the "Game" render method; then the "Menu" render method; then all the loading code.
I start with the SIO2 splash screen, this does an _SIO2windowrender to the main menu. When you press "Play" (which is a simple widget in the Main Menu) then this goes to the Game. This works fine. But I have a button called "Menu" in the "Game" render method, and this wont go back to the Menu method.
I think it's something to do with me having all of this (it's a very simple app, just to test menu's) in the Template.mm file, rather than splitting it up. I'm basically after some suggestions and ways of doing this properly... I'm loathed to start from scratch, but if I'm doing this all wrong (and someone can suggest a good way of doing it!) then I'll start a fresh.
Cheers.
Re: SIO2 Menus - Using Widgets
If it crashes on sio2->SIO2Window->_SIO2windowrender() (or what ever it is) it should be something wrong with the function called when menu button is pressed, maybe a typo when assigning a value to _SIO2windowrender?
this is my function for changing from menu to game so far(don't got a menu yet)
this is my function for changing from menu to game so far(don't got a menu yet)
- Code:
void setRenderState(unsigned char _state)
{
switch(_state)
{
case RENDER_MENU:
//add stuff here for going back to menu
break;
case RENDER_GAME:
sio2->_SIO2window->_SIO2windowrender = gameRenderLevel;
sio2->_SIO2window->_SIO2windowtap = gameScreenTap;
sio2->_SIO2window->_SIO2windowtouchmove = gameScreenTouchMove;
sio2->_SIO2window->_SIO2windowaccelerometer = gameScreenAccelerometer;
break;
}
}
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: SIO2 Menus - Using Widgets
Hmm, so it started working fine, then I came to adding more menu options.
The problem I'm having now, is that I can't seem to get the sio2WidgetFree command to work properly. If I go to the next screen in my menus, then the old widgets are still there.
Have I missed some of the Widget's inner workings from one of the tutorial? Can anyone shed some light on using Widgets as buttons to go back and forth through menu screens?
The code that oioioi suggested worked mostly, but as I say, the old widgets are still there.
Thanks!
The problem I'm having now, is that I can't seem to get the sio2WidgetFree command to work properly. If I go to the next screen in my menus, then the old widgets are still there.
Have I missed some of the Widget's inner workings from one of the tutorial? Can anyone shed some light on using Widgets as buttons to go back and forth through menu screens?
The code that oioioi suggested worked mostly, but as I say, the old widgets are still there.
Thanks!
Re: SIO2 Menus - Using Widgets
You need to remove them from the resources... honestly me for menus I create separated SIO2resources and have 1 .sio2 with all my textures... after that I create a struct similar to the SIO2 ones and have like Init, Free, Render
Like that its really easy to Load/Unload a menu when you need it or don't need it...
Like that its really easy to Load/Unload a menu when you need it or don't need it...
Re: SIO2 Menus - Using Widgets
I think I understand what you're suggesting - but I'm not creating any SIO2resource's at the moment. All the "Menu" is, is a blank screen, with some text to tell me which screen is loaded (Like "Main Menu" or "Options") and some more text to say "Back".
There is a widget around the "Back" text that then goes off and loads a new _SIO2windowrender, and this draws the next menu - this is working fine, and they go back and forth, the correct text is drawn etc. The problem is that the Widgets still exist - all I want to do is release the widgets from the menu before, and have them only load on the menu that's called.
Is that what you're suggesting with having custom Init/Free/Render structs? Even though I'm not loading any resources (materials/images etc)?
I have a feeling I'm missing something so very simple, and could be wasting everyone's time
There is a widget around the "Back" text that then goes off and loads a new _SIO2windowrender, and this draws the next menu - this is working fine, and they go back and forth, the correct text is drawn etc. The problem is that the Widgets still exist - all I want to do is release the widgets from the menu before, and have them only load on the menu that's called.
Is that what you're suggesting with having custom Init/Free/Render structs? Even though I'm not loading any resources (materials/images etc)?
I have a feeling I'm missing something so very simple, and could be wasting everyone's time
Re: SIO2 Menus - Using Widgets
Just as I thought, I was missing something!
All I want to do is enable/disable widgets as needed for each menu screen - so I started by initializing my widgets without the SIO2_WIDGET_ENABLED flag, and only calling that on the screen that's needed.
Is there a method to correctly disable widgets?
I tried using sio2DisableState( &_[WidgetName]->flags, SIO2_WIDGET_ENABLED) but I guess that doesn't disable the state that I'm calling?
Thanks for the help folks, really appreciated!
All I want to do is enable/disable widgets as needed for each menu screen - so I started by initializing my widgets without the SIO2_WIDGET_ENABLED flag, and only calling that on the screen that's needed.
Is there a method to correctly disable widgets?
I tried using sio2DisableState( &_[WidgetName]->flags, SIO2_WIDGET_ENABLED) but I guess that doesn't disable the state that I'm calling?
Thanks for the help folks, really appreciated!
Re: SIO2 Menus - Using Widgets
Inorder to caclculate rhe boundaries of a widget if have to be enabled. After that you can use the widget flags to enable or disable it as will... I also suggest you to read again my previous post about the multiple sio2resouce for each screen of your menus...
Re: SIO2 Menus - Using Widgets
I see what you're saying with the multiple resources - but I'm still stumped, especially as I don't make any calls to SIO2resource for any of my widgets.
Are they still using the SIO2resource function?
Also, how are you able to disable the widgets? I've tried everything I can think of, and it doesn't seem to make a difference. Also, checking in the /docs/ folder at the HTML layout of SIO2, the function sio2DisableState() doesn't work for Widgets, but sio2EnableState() does work for widgets? Is this correct or am I being a giant numpty?
Thanks for your help SIO2, I know my questions are noobish, I'm just struggling
Are they still using the SIO2resource function?
Also, how are you able to disable the widgets? I've tried everything I can think of, and it doesn't seem to make a difference. Also, checking in the /docs/ folder at the HTML layout of SIO2, the function sio2DisableState() doesn't work for Widgets, but sio2EnableState() does work for widgets? Is this correct or am I being a giant numpty?
Thanks for your help SIO2, I know my questions are noobish, I'm just struggling
Re: SIO2 Menus - Using Widgets
I'm going through and modifying my code to try and have multiple SIO2resource's like you suggest - taking some time as I'm still learning bits and pieces of SIO2 as I go.
Just out of curiosity, what is the command to disable a Widget?
Just out of curiosity, what is the command to disable a Widget?
Re: SIO2 Menus - Using Widgets
sio2EnableState( &_SIO2widget->flags, SIO2_WIDGET_ENABLED );
By doing this the widget will not respond to any events linked to it...
By doing this the widget will not respond to any events linked to it...
Re: SIO2 Menus - Using Widgets
So you enable it _again?_
The widget's are enabled in the loading/init code, but you enable it again in the run-time code?
That's so simple, and one thing I *didn't* try!
Thanks SIO2 - I'm still rebuilding my app to the way you suggested - but good to know!
The widget's are enabled in the loading/init code, but you enable it again in the run-time code?
That's so simple, and one thing I *didn't* try!
Thanks SIO2 - I'm still rebuilding my app to the way you suggested - but good to know!
Re: SIO2 Menus - Using Widgets
At init time Im enabling ALL the one that receive events then calculate the widgets boundaries then disable all the one that I don't need for the menu etc...
Re: SIO2 Menus - Using Widgets
I tried using sio2EnableState(...->flags, SIO2_WIDGET_ENABLED) and it made no effect on the state of the widget that I want to disable.
I'm going to go through and completely rebuild the whole app, I think I've messed something up somewhere - so when I eventually come back, I should have the init, render, release functions working like you suggested.
I have no doubts that I'll be calling on you again though
I'm going to go through and completely rebuild the whole app, I think I've messed something up somewhere - so when I eventually come back, I should have the init, render, release functions working like you suggested.
I have no doubts that I'll be calling on you again though
Re: SIO2 Menus - Using Widgets
I just wanted it to not function as a widget, so that it wont perform its tapdown or tapup command. Still wanted it there visually, but just not *do* anything.sio2interactive wrote:Well you won't see any visual effects if that's what you mean...
At the moment, it's still functioning, which is why I think it's my code rather than anything else :-/
Re: SIO2 Menus - Using Widgets
You mean you are disabling the SIO2_WIDGET_ENABLE state and the widget still respond to event?
Sound weird to me since in sio2DispatchEvents:
Sound weird to me since in sio2DispatchEvents:
- Code:
// Widget Events
while( i != _SIO2resource->n_widget )
{
SIO2widget *_SIO2widget = ( SIO2widget * )_SIO2resource->_SIO2widget[ i ];
if( !sio2StateEnabled( _SIO2widget->flags, SIO2_WIDGET_VISIBLE ) ||
!sio2StateEnabled( _SIO2widget->flags, SIO2_WIDGET_ENABLED ) )
{
++i;
continue;
}
Re: SIO2 Menus - Using Widgets
sio2interactive wrote:You mean you are disabling the SIO2_WIDGET_ENABLE state and the widget still respond to event?
Yeah, that's what it seems to be doing.
I tried with
- Code:
sio2DisableState( &_SIO2WidgetMenuButton->flags, SIO2_WIDGET_ENABLED );
I've tried
- Code:
sio2EnableState( &_SIO2WidgetMenuButton->flags, !SIO2_WIDGET_ENABLED );
- Code:
sio2EnableState( &_SIO2WidgetMenuButton->flags, -SIO2_WIDGET_ENABLED );
If, in the init code, I only set the Widget state as:
- Code:
sio2EnableState( &_SIO2WidgetMenuButton->flags, SIO2_WIDGET_VISIBLE );
If that makes sense?
Re: SIO2 Menus - Using Widgets
From a previous post:
In order to calculate the boundaries of a widget it have to be enabled. After that you can use the widget flags to enable or disable it as will.
>> That means that you need to have it ENABLED at init time BEFORE calling CalculateBoundaries...
In order to calculate the boundaries of a widget it have to be enabled. After that you can use the widget flags to enable or disable it as will.
>> That means that you need to have it ENABLED at init time BEFORE calling CalculateBoundaries...
Re: SIO2 Menus - Using Widgets
That's how I had it set up initially - I was just playing around to see if I could disable them.
Once I have them VISIBLE and ENABLED, what should be the correct command to disable them? Using sio2EnableState( &_SIO2Widget->flags, SIO2_WIDGET_ENABLED ) again seemed to have no effect?
I'm probably just missing something so fundamentally simple!
Once I have them VISIBLE and ENABLED, what should be the correct command to disable them? Using sio2EnableState( &_SIO2Widget->flags, SIO2_WIDGET_ENABLED ) again seemed to have no effect?
I'm probably just missing something so fundamentally simple!
Re: SIO2 Menus - Using Widgets
Dude the whole thing is pretty straight forward:
1. Init your widget and set them to SIO2_WIDGET_ENABLED, link your events callbacks
2. Calculate the boundaries
3. Enable or Disable them with:
sio2EnableState( _SIO2widget->flags, SIO2_WIGET_ENABLED ); -> Respond to the event callbacks
sio2DisableState( _SIO2widget->flags, SIO2_WIGET_ENABLED ); -> Don't respond to the events callbacks
That's it
1. Init your widget and set them to SIO2_WIDGET_ENABLED, link your events callbacks
2. Calculate the boundaries
3. Enable or Disable them with:
sio2EnableState( _SIO2widget->flags, SIO2_WIGET_ENABLED ); -> Respond to the event callbacks
sio2DisableState( _SIO2widget->flags, SIO2_WIGET_ENABLED ); -> Don't respond to the events callbacks
That's it
Re: SIO2 Menus - Using Widgets
Then it HAS to be my code... I'm doing something wrong!
Sorry for drawing this one out, it's been getting on my nerves!!! Such a simple thing and I've broken it :-S
I'll take another look tonight - thanks so much for putting up with my constant questions!
[EDIT]
It IS my code!
Gah, this is so frustrating - I just added the line sio2DisableState... into Tutorial 7 and the Widget stopped functioning, exactly like it should! Time to figure out where I'm being an idiot!
[/EDIT]
Sorry for drawing this one out, it's been getting on my nerves!!! Such a simple thing and I've broken it :-S
I'll take another look tonight - thanks so much for putting up with my constant questions!
[EDIT]
It IS my code!
Gah, this is so frustrating - I just added the line sio2DisableState... into Tutorial 7 and the Widget stopped functioning, exactly like it should! Time to figure out where I'm being an idiot!
[/EDIT]
Last edited by Jawdy on Wed May 27, 2009 12:05 pm; edited 1 time in total
Re: SIO2 Menus - Using Widgets
Well make sure you help the SIO2 project as much as the SIO2 project helps you
Page 1 of 2 • 1, 2
Similar topics
» about Menus, Buttons, Widgets...
» Menus again
» Budweiser, SIO2, & Beer Pong
» sio2 and big map
» widgets taping
» Menus again
» Budweiser, SIO2, & Beer Pong
» sio2 and big map
» widgets taping
Permissions in this forum:
You cannot reply to topics in this forum