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

Author Topic: Layer Manipulation  (Read 2675 times)

Hiro_Protagonist

  • General Accounts
  • *
  • Posts: 30
    • View Profile
Layer Manipulation
« on: Mar 13, 14, 04:44:17 PM »

Hey, I'm playing with the Layer mechanics, and they don't seem to be doing anything. I have created my own class to override the functionality in $GUI, MO_GUI (based on E_GUI), and adjusted the system node. I added my own override for HE_validGuiLayersList, with a new "dashboard" layer:

Code: [Select]
method HE_validGUILayersList() as List of String 
  layers as List of String

  add back "bottom" to layers
  add back "nameplates" to layers
  add back "default" to layers
  add back "game" to layers
  add back "dashboard" to layers
  add back "cinematics" to layers
  add back "guieditor" to layers
  add back "guieditorutilities" to layers
  add back "alert" to layers
  add back "hotspot" to layers
  add back "tooltips" to layers
  add back "contextmenu" to layers
  add back "cursor" to layers
  return layers
.

Then I created a function to show a requested dashboard. The prototype's topmost control is set to layer=dashboard:
Code: [Select]
method ShowSystemAreaDashboard(dashboardControl as String)
  // Hide all the other stuff
  $GUI._pushGUILayerState(dashboardControl)
 
  // Find the specified gui control
  dashboard as NodeRef of Class GUIControl = FindGUIControlByName(0, "dashboard." + dashboardControl)
 
  // Destroy it, we're going to rebuild it
  if dashboard != None
    destroynode(dashboard)
  .
 
  // Create a new dashboard.
  dashboard = CreateNodeFromPrototype(dashboardControl)
  dashboard.build = true
 
  // Hide all the non dashboard layers
  var layer = dashboard.getMyLayer()
  layer._hideAllOtherLayers()
.

Which all makes sense to me, but it doesn't work. When I call ShowDashboard, the dashboard shows up but none of the other layers are hidden. The Wiki is kind of out of date with the Layer stuff, at least the "Layer State Snapshots" part that says the actual layer object has _pushGUILayerState, but now the $GUI system node has it. So that said, I'm definately doing something wrong. I want to show my dashboard, hide everything else, and then call HideDashboard and restore the other GUIs.

Thanks again for your help!
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: Layer Manipulation
« Reply #1 on: Mar 15, 14, 12:00:09 AM »

I used something like to stop the player from certain functions, namely input. But also let them use the mouse. While it does not answer your questions directly, perhaps something with ActivateCmdLayer() might turn some on and off as you need.

  //Disables Character Movement
  $INPUT._DisableInputLayers()
  ActivateCmdLayer("Mouse", true)
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Layer Manipulation
« Reply #2 on: Mar 15, 14, 11:06:17 AM »

in the hideAllOtherLayers() you need to pass in the current layer or the layer you wish to keep. Otherwise it wont work.

Quote
method hideAllOtherLayers()

The opposite of showAllOtherLayers. Will cause the layer passed in to become visible, and will hide all other layers. Will quietly die if it is unable to reconcile a layer from the control passed in.

so make sure the layer is valid in debugging.

and watch out for this.

Quote
These methods should work for all GUI Controls, regardless of race, gender, etc.

method getMyLayer() as NodeRef of Class GUIControl

Returns the noderef of myControl's top-level layer, or 0 if myControl is not on its proper layer. Note that this is based entirely on the layer field of myControl's rootParent, so myControl can be on a GUI layer, but if it is not the proper layer for that control's root parent, this function will still return 0.


I find it best to just set the layer field on any piece / control in any gui heirarchy from the top down, as it really helps smooth things out. Unless you are trying to do an odd sub layer, but that adds a bit more complexity than usually needed.
« Last Edit: Mar 15, 14, 11:13:42 AM by keeperofstars »
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Hiro_Protagonist

  • General Accounts
  • *
  • Posts: 30
    • View Profile
Re: Layer Manipulation
« Reply #3 on: Mar 17, 14, 12:11:32 AM »

in the hideAllOtherLayers() you need to pass in the current layer or the layer you wish to keep. Otherwise it wont work.

Interesting. I figured it would know what layer to keep based on the fact that it is a method of a layer. So I need to do something like:

var layer = me.getMyLayer()
layer.hideAllOtherLayers(me)

?
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Layer Manipulation
« Reply #4 on: Mar 17, 14, 10:53:49 AM »

What you have works, I just poorly passed my message along, my point was your layer value has to be correct, and for some reason it's not.

Here is a snippet of code from some HE stuff.
Code: [Select]
  GUIAnimation:addAnimation( top, "Interpolate", "defaultstatepresentation.color.a,0,1," + speedInSeconds + ",1,false,SMOOTH,false,0,topLetter" )

  bottom as NodeRef of Class GUIControl = FindGUIControlByName(GetCinematicsLayer(), "bottomLetter")
  if bottom = None
    bottom = createNodeFromPrototype("_panel")
    assert( bottom != 0, "No panel prototype!" )
    bottom.build = true
    bottom.layer = "cinematics"
    bottom.defaultStatePresentation.color.r = 0
    bottom.defaultStatePresentation.color.g = 0
    bottom.defaultStatePresentation.color.b = 0
    bottom.defaultStatePresentation.color.a = 0
    bottom.name = "bottomLetter"
    bottom.script = SYSTEM.EXEC.THISSCRIPT
    screenSize as Vector3 = GetViewPortSize()
    bottom.size.x = screenSize.x
    bottom.size.y = screenSize.y * .15
    bottom.position.x = 0
    bottom.position.y = screenSize.y - bottom.size.y
    bottom.dockMode = "Bottom"
  .
  GUIAnimation:addAnimation( bottom, "Interpolate", "defaultstatepresentation.color.a,0,1," + speedInSeconds + ",1,false,SMOOTH,false,0,bottomLetter" )
 
  $GUI._pushGUILayerState( "letterbox" )
  bottom.getMyLayer()._showLayer()
  bottom._hideAllOtherLayers()
.

as you can see bottom._hideAllOtherLayers() works just fine, but.... they just manually pass the layer name in.

You can use getMyLayer, but... it's really getting the layer of the top most control in the GUI structure, so if it's not on a layer then getMyLayer just errors out with a 0 value.

For a quick test manually enter the layer you want to keep and see if it hides the rest. If so you then know you have an issue with the getMyLayer.
Also debug line the result of getMyLayer. so debugLayerOutput as string = layer._getMyLayer()
and see what that returns for you.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]