FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

SIO2 Menus - Using Widgets

+2
oioioi
Jawdy
6 posters

Page 1 of 2 1, 2  Next

Go down

SIO2 Menus - Using Widgets Empty SIO2 Menus - Using Widgets

Post  Jawdy Sat May 23, 2009 9:32 am

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

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  oioioi Sat May 23, 2009 10:42 am

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.

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Sat May 23, 2009 2:12 pm

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

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  oioioi Sat May 23, 2009 3:30 pm

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

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Mon May 25, 2009 5:00 am

Awesome!
Worked like a charm :-) Thanks for the help dude!
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Mon May 25, 2009 6:37 am

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!
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Mon May 25, 2009 7:00 am

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

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Mon May 25, 2009 8:09 am

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 Embarassed
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Mon May 25, 2009 8:26 am

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!
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Mon May 25, 2009 9:42 am

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

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Mon May 25, 2009 10:57 am

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 Crying or Very sad
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Tue May 26, 2009 3:31 am

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?
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Tue May 26, 2009 3:46 am

sio2EnableState( &_SIO2widget->flags, SIO2_WIDGET_ENABLED );

By doing this the widget will not respond to any events linked to it...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Tue May 26, 2009 3:48 am

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! Very Happy
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Tue May 26, 2009 3:53 am

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

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Wed May 27, 2009 3:03 am

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 Wink
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Wed May 27, 2009 3:19 am

Well you won't see any visual effects if that's what you mean...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Wed May 27, 2009 3:20 am

sio2interactive wrote:Well you won't see any visual effects if that's what you mean...
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.
At the moment, it's still functioning, which is why I think it's my code rather than anything else :-/
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Wed May 27, 2009 3:37 am

You mean you are disabling the SIO2_WIDGET_ENABLE state and the widget still respond to event?

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;
         }

sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Wed May 27, 2009 3:47 am

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 );
As that's how I thought you disabled widgets.
I've tried
Code:

sio2EnableState( &_SIO2WidgetMenuButton->flags, !SIO2_WIDGET_ENABLED );
and
Code:

sio2EnableState( &_SIO2WidgetMenuButton->flags, -SIO2_WIDGET_ENABLED );
Just to see if anything would maek a difference Question

If, in the init code, I only set the Widget state as:
Code:

sio2EnableState( &_SIO2WidgetMenuButton->flags, SIO2_WIDGET_VISIBLE );
Then in my code, when the menu loads, I can set the flag to ENABLE, but I can't seem to disable the previous menu's buttons. And also if I go back to the first menu, then I can't seem to disable the 2nd menu's buttons either.
If that makes sense?
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Wed May 27, 2009 4:14 am

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

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Wed May 27, 2009 4:19 am

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!
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Wed May 27, 2009 4:34 am

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 Smile
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Jawdy Wed May 27, 2009 4:36 am

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]


Last edited by Jawdy on Wed May 27, 2009 12:05 pm; edited 1 time in total
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  sio2interactive Wed May 27, 2009 4:38 am

Well make sure you help the SIO2 project as much as the SIO2 project helps you Wink
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

SIO2 Menus - Using Widgets Empty Re: SIO2 Menus - Using Widgets

Post  Sponsored content


Sponsored content


Back to top Go down

Page 1 of 2 1, 2  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum