HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] How to make GUI show?  (Read 3001 times)

IAskDumbQuestions

  • General Accounts
  • *
  • Posts: 6
    • View Profile
[Resolved] How to make GUI show?
« on: Oct 05, 11, 04:52:02 PM »

Hello,

I have gone to the GUI XML tab and created a GUI that I want to show when a certain button is pressed on the keyboard. How would I go about doing this?

Thanks
« Last Edit: Nov 01, 12, 03:49:26 PM by HE-Cooper »
Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: How to make GUI show?
« Reply #1 on: Oct 07, 11, 10:07:34 AM »

There are several tutorials and references on the HeroEngine wiki that you can take a look at to understand how to create, modify and instantiate GUI objects. Take a look at the following:

« Last Edit: Oct 10, 11, 02:59:45 PM by HE-CHRISTOPHER »
Logged

lileebeta

  • General Accounts
  • *
  • Posts: 48
    • View Profile
Re: How to make GUI show?
« Reply #2 on: Oct 08, 11, 01:04:36 PM »

Yeah, I had the same question. I did the simple window tutorial thingee and made a nice plain window. The problem is that i don't have enough information needed in order to continue to tweek it. An dif I can just use the editor ..whats the point?

I also read the page on GUI events that you posted and i can't seem to find _GUIMethodCallbacksClassMethods inside the script editor , i don't see in in the client list or the server list.

So how do we get are guis to show up once we've made them in the editor?
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to make GUI show?
« Reply #3 on: Oct 08, 11, 01:42:45 PM »

Quote
i can't seem to find _GUIMethodCallbacksClassMethods
Dollars to doughnuts says you didn't have "Show Engine" checked, as that is an engine (required) script. Hint: you can have it set to always be checked via the Script Editor Options menu.

Also, that GUI tutorial shows it clearly:
Code: [Select]
myTestWindow as NodeRef of Class GUIControl = createNodeFromPrototype("_window")Like any prototype, you use it to create a node with properties set to predefined values (without a prototype, all values would be empty).  Then set the build field to true when you want the control built and it will become visible, unless it had it visibility turned off or inherited that from a parent.  Note that any child controls are not created until build = true.

Setting properties in code is optional, and they are typically set ahead of time in the prototype.  Also, in addition to the editor, gui prototypes can be edited by hand in the code found in the gui scripts in the script editor.
« Last Edit: Oct 08, 11, 01:48:49 PM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

lileebeta

  • General Accounts
  • *
  • Posts: 48
    • View Profile
Re: How to make GUI show?
« Reply #4 on: Oct 08, 11, 02:01:40 PM »

Thank you that clears a few things up.
Logged

lileebeta

  • General Accounts
  • *
  • Posts: 48
    • View Profile
Re: How to make GUI show?
« Reply #5 on: Oct 08, 11, 02:43:53 PM »

Still having some issues and a whole lot o errors.
 I think i understand the Class to Proto to Node to Gom Idea but i don't really understand the procedure, Hero E is pretty strict when it comes to procedures. So yeah, my CLI commands just keep comin up as errors that read somethin like, error calling lookupPrototypeID Gom:lookup ID (951) ; definition not found : <scripname>
Logged

lileebeta

  • General Accounts
  • *
  • Posts: 48
    • View Profile
Re: How to make GUI show?
« Reply #6 on: Oct 09, 11, 08:08:53 AM »

Okay, so once the gui control is created via the GUI Editor and saved in the repository in XML what do I do next?
Do I creat a node from the class?

If so, im having a hard time finding the new class. After all it is an XML file isn't it?
So how would i go about creating a node from an XML class?
I havnt even gotten into the children controls, im still just trying to render my panels.
But if I could get a good procedure going then I will roll along smoothly and pretty quickly i think. :D
I'll check for the class in the script editor by pressing Shift control c for client scripts and then i'll make sure show engine is checked and then search for the class.

Okay and there is also the _GUIClass Methods that I see inside the script editor. And I see many methods that run the multiple gui features and things like that (thats pretty neat).

And then I see under client prototypes '"GUI". I suppose when doing GUIs we work with client scripts am I right?  And what do I do with this GUI prototype thingee?

So that's 3 components we are looking at here right , XML, Class Methods, and Prototypes, but we want to create a fourth component which is a node.. and that node will render my panel..right?

But then again, I did the tutorial and made the simple window with limited features right, but i also just used the GUI Editor to make one which was easier to do but more complex... so how do those 2 things coincied with each other?

In other words, whats the step by step way to do this procedurally, you know like a generic workflow or something like that. I think is fine to be generic in the beginning, and we will just take it from there. I think we need a procedural seed?
« Last Edit: Oct 09, 11, 08:38:28 AM by Khalil »
Logged

Rissa2002

  • General Accounts
  • *
  • Posts: 43
    • View Profile
Re: How to make GUI show?
« Reply #7 on: Oct 09, 11, 01:06:28 PM »

Quote
So that's 3 components we are looking at here right , XML, Class Methods, and Prototypes, but we want to create a fourth component which is a node.. and that node will render my panel..right?

im working thru this myself so forgive any errors i make...

A you create the GUI the xml is basically a list of the features of that gui as in where parts are located, next the class that supposts it then CLI command |CPFC create prototype from class..as i understand it the | makes it persistant and clientsided which you'd want for gui's

from there it depends on what is supposed to trigger the gui : options is a script calls it or a keybinding event as in I for inventory..there is another thread where folks are working on the keybindings you may wanna read that :>

im struggling to understand HJ's customized itemspeceditor stuff myself got the classes set up and gui's made but its not calling the collection node so i know i got a prototype issue just can't figure out which it is yet lol
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to make GUI show?
« Reply #8 on: Oct 09, 11, 02:21:56 PM »

Ok, definitely work through the tutorial and other pages on the wiki and try to understand that and you're on your way.

I'll try to clarify some of the concepts involved:

Prototypes
When creating an object, we often want it to have initial values in it.  In C++, you can define a constructor method called upon creation to set up initialization.  HeroScript does not use constructors.  Instead, you can define one or more prototypes for a given class.  A protoype is technically a special kind of singleton node, though you can't use them as traditional nodes.  You can set values into a prototype to serve as a template, then create actual nodes from it which will copy those values and thus be initialized.  Basically, a prototype is like a blueprint for a house. You can't live in it, it only defines how the house should be.  You still need to create an actual house from it.

GUI prototypes are largely the same thing.  There is a class that the prototype is of, and initial values can be set in the prototype.  The main difference is that you can have a hierarchy of gui controls parented to each other.  Defining that hierarchy is the reason for using XML.  You still have a class underneath which serves to define the fields and methods that the control will use.  The XML allows you to define the structure of the gui: individual properties like the size, placement, etc. but also the arrangement of possible child controls.  You wouldn't strictly need to use the gui editor; you can in fact create a new gui script and type the xml in it directly.  Often times that is easiest when you want to have a control be similar to another one without inheriting from it, which has limitations.  You can copy the xml from one script and paste in another and make the needed adjustments, then save and commit and its ready to be used for creating gui controls.  Obviously, the editor makes editing much easier.



So:

A gui CLASS defines the fields and methods for the control.  For a class to be used as the basis for a gui prototype, it MUST be of archetype GUICONTROL, which is setup when creating the class.  If that was not set, the class must be deleted and recreated correctly.  Like other classes, they may derive from other classes, which also must be archetype GUICONTROL.  You can use an existing class or define your own.  At the very least, your class should derive from the most base class, GUIControl.

Once you have a gui class to target, you would define a gui prototype.  The prototype must state its class, which must be a guicontrol class.  You may also optionally declare that the gui prototype INHERITS from another gui PROTOTYPE.  What is inherited in that case is the structure.  That includes the base class, any classes that might have been glommed onto it, the control's properties and any child control hierarchy that the other prototype has.  When a gui prototype inherits from another gui prototype, the derived prototype can have its properties changed, including the base class, but it cannot remove any child controls that were inherited.  You're stuck with them; the best you can do if you don't want them is hide them.  That is why sometimes if I want a similar prototype but don't want all of the children, I will use the script editor to copy the XML manually and then delete the children from the new script.  Otherwise, inheriting can be good in that you don't have to recreate structure every time.  You can, for instance, define a base window prototype with desired properties like colors, fonts, children, etc. and then specific windows inherit from that so that they all have the same "theme".

Once you have prototype(s) set up as desired, you still have not created any nodes from them.  That is typically done in code rather than from the CLI because the CLI is used at develop time and the guis are used at runtime.  When you want to show a gui, create a node from the desired prototype and then set the build field of the new node to true. That builds it and will show it if it is visible.  To get rid of the gui, delete the node like you would any other: DestroyNode(myGuiNode).  You might wish to save the nodeRef somewhere, such as a field of a system node so it can be easily referenced again in the future.  See also Layers and Layers 2 in the wiki, as they are handy for layering guis, which can be good for showing/hiding particular parts at different times.
« Last Edit: Oct 09, 11, 02:27:37 PM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to make GUI show?
« Reply #9 on: Oct 09, 11, 02:44:14 PM »

And here is some things not so obvious when you start:

When/how the main game gui is shown:
You can see in the method HE_OnReplicationNodeAdded() of client class E_playerAccount that it is creating the game gui when the local client's player character is replicated to them.  Replace that code to show your own gui.

How the character selection menu is shown and can be overridden:
There is a client class called _characterSelection.  It is the class of the system node $CHARACTERSELECTIONSYSTEM.  It has a unique method called _CSSInvokeGUI() which tries to call HE_CSSInvokeGUI() if it exists.  So, you can create your own character selection class, glom it onto CHARACTERSELECTIONSYSTEM via the System Nodes Configuration GUI (F5 menu, Tools) and then define HE_CSSInvokeGUI in your class methods script.  We created a new gui class derived from _GUICSSCharacterSelection, a new prototype for that class, then put our own Open function in the class script to mimic the way _CSSInvokeGUI() works.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

lileebeta

  • General Accounts
  • *
  • Posts: 48
    • View Profile
Re: How to make GUI show?
« Reply #10 on: Oct 09, 11, 04:26:39 PM »

I got it going on.  I failed to rename the Protoype inside my base gui window class  and that was where the trouble came form.

Thanks for your help!
Logged