Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FamousAdventurer77 on Sun 22/05/2011 20:50:46

Title: Can't get control panel to show up (SOLVED)
Post by: FamousAdventurer77 on Sun 22/05/2011 20:50:46
Can't get the control panel to appear on screen if I click it in the icon bar. Would I start with this:


function btnControlPanel_Click(GUIControl *control, MouseButton button)

but what's the right command for "gPanel" to show and work correctly?
Title: Re: Can't get control panel to show up
Post by: Khris on Sun 22/05/2011 21:01:19
Just turn it visible:

  gPanel.Visible = true;
Title: Re: Can't get control panel to show up
Post by: barefoot on Sun 22/05/2011 21:06:52
Hi

I'm assuming you are not customising the gIconbar and are using it normally.

if you have not touched any scripting and the gIconbar is visible then you should only have to click on the ? button on the right of the gIconbar, else press Escape key to bring it up.

You don't normally have to touch anything.

Not sure what else it could it be..

barefoot

Title: Re: Can't get control panel to show up
Post by: barefoot on Sun 22/05/2011 21:08:14
Yes, if you have set it as invisible..

barefoot
Title: Re: Can't get control panel to show up
Post by: FamousAdventurer77 on Sun 22/05/2011 21:09:30
Nope, I modified the icon bar to have 10 icons, I removed the ? and have a picture of sliding bars resembling a control panel. But I'll give Khris's line a whirl and see if that works.
Title: Re: Can't get control panel to show up
Post by: FamousAdventurer77 on Sun 22/05/2011 21:11:59
Argh! Didn't work. Here's what I put in:

function btnControlPanel_Click(GUIControl *control, MouseButton button) {
 
  gPanel.Visible=true;
}


Still does nothing if I click it. Works if I hit Escape though.
Title: Re: Can't get control panel to show up
Post by: barefoot on Sun 22/05/2011 21:38:30
Hi

Just on case you messed up here is the original script.

The gIconbar ? (image) events button is btnIconAbout.. when you click it:


gPanel.Visible=true;
  gIconbar.Visible=false;
  mouse.UseModeGraphic(eModePointer);


barefoot
Title: Re: Can't get control panel to show up
Post by: Khris on Sun 22/05/2011 21:56:34
In that case it sounds like the button's function isn't linked properly.
Usually you'd simply double-click the button after creating it, this creates the function and links it.

Open the Iconbar GUI, select the control panel button, then click the lightning icon. Below that it should say "OnClick" and next to it: "btnControlPanel_Click".
That's how AGS knows to call the function upon a click on the button.
Title: Re: Can't get control panel to show up
Post by: FamousAdventurer77 on Sun 22/05/2011 22:30:55
Quote from: barefoot on Sun 22/05/2011 21:38:30
Hi

Just on case you messed up here is the original script.

The gIconbar ? (image) events button is btnIconAbout.. when you click it:


gPanel.Visible=true;
  gIconbar.Visible=false;
  mouse.UseModeGraphic(eModePointer);


barefoot



I deleted the About button because I don't feel like re-scaling my inventory buttons and it's not necessary for gameplay. My button is labelled btnControlPanel.
Title: Re: Can't get control panel to show up
Post by: FamousAdventurer77 on Sun 22/05/2011 22:33:27
Quote from: Khris on Sun 22/05/2011 21:56:34
In that case it sounds like the button's function isn't linked properly.
Usually you'd simply double-click the button after creating it, this creates the function and links it.

Open the Iconbar GUI, select the control panel button, then click the lightning icon. Below that it should say "OnClick" and next to it: "btnControlPanel_Click".
That's how AGS knows to call the function upon a click on the button.

I thought that was the problem too but when I go into the Iconbar window and get to the control panel button, then click Events, the "btnControlPanel_Click" box leads me to the first few lines of code in the main global script file. Do I just put that same code, linked correctly, somewhere below that?
Title: Re: Can't get control panel to show up
Post by: Khris on Sun 22/05/2011 23:22:29
If it takes you to the function with "gPanel.Visible = true;" inside,  everything should work fine.
I don't know why it still won't work, but to be really sure, put this before the Visible line:

  Display("Test.");

If you click the button, does it display that? Also, please post the entire function you currently have.
Title: Re: Can't get control panel to show up
Post by: FamousAdventurer77 on Mon 23/05/2011 20:14:16
There's this function that doesn't seem to do anything under "Start of Control Panel Functions":

function gControl_OnClick(GUI *theGui, MouseButton button)
{
  gPanel.Visible = true;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = false;
}



Here's what I tried using that does absolutely nothing despite clicking on the correctly-labelled icon bar button:

function btnControlPanel_OnClick(GUIControl *control, MouseButton button)
{
  gPanel.Visible = true;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = false;
}


What am I doing wrong??? I really don't understand. The freakin button is properly labeled.
Title: Re: Can't get control panel to show up
Post by: Khris on Mon 23/05/2011 21:09:47
Like I said, make sure the function is called. Read my previous post.
Title: Re: Can't get control panel to show up (SOLVED)
Post by: FamousAdventurer77 on Tue 24/05/2011 03:19:40
Solved it!

Here's the utterly stupid and obvious thing I missed...

That damn lightning bolt button. I just had it as "btnControlPanel", not "btnControlPanel_OnClick". That and I realized with the last 10 times I hit F5 to try out other scripting aspects, just HOW crucial it really is to go through that Event button first. Doesn't matter if you script first or after hitting it, but I'm hitting it first from now on so I don't get confused. And my script was correct, just wrong label. Definitely leave this here for other beginners with the same problem though.

And now that I see the control panel I designed pop up on screen....yeesh I need to scale that thing down.
Title: Re: Can't get control panel to show up (SOLVED)
Post by: Khris on Tue 24/05/2011 03:50:32
Since you didn't get an error message, there's a function called btnControlPanel somewhere in your script. Better get rid of it to avoid future confusion.
Title: Re: Can't get control panel to show up (SOLVED)
Post by: FamousAdventurer77 on Tue 24/05/2011 03:54:08
Nope, only one is btnControlPanel_OnClick. I think it was mislabelled in the Events window the entire time.
Title: Re: Can't get control panel to show up (SOLVED)
Post by: Khris on Tue 24/05/2011 04:00:43
You're right, I just tested it and didn't get an error.
It still throws an error for missing room functions though, but apparently not for missing OnClick ones.
Title: Re: Can't get control panel to show up (SOLVED)
Post by: FamousAdventurer77 on Tue 24/05/2011 04:02:29
I got TONS of errors when the stuff in the rooms didn't match up-- whereas it didn't create a fatal error for the control panel one, the icon just didn't work. I got it to work correctly now though.