Thread Tools Display Modes
06/21/17, 10:57 AM   #1
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
How to put a control on the Guild Home page

I want to put a control on the Guild Home screen. But I can't find a suitable event to respond to, comparable to EVENT_CRAFTING_STATION_INTERACT for crafting stations, or EVENT_OPEN_GUILD_BANK for the guild bank. Have I just overlooked it, or do I need a different approach?
  Reply With Quote
06/21/17, 11:34 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
In most cases you shouldn't actually add elements in response to an event, but instead create a scenefragment and assign it to a scene.
For example the guild home menu is a scene. The buttons on top (home, roster, history, etc) are one fragment which is added to the guild home scene.
A fragment is basically just a wrapper around a control and can be added to any number of scenes. When a scene shows up, it will automatically make all its fragments visible.

The scene you are looking for is called GUILD_HOME_SCENE. For most cases you can just create a ZO_SimpleSceneFragment.

Lua Code:
  1. local fragment = ZO_SimpleSceneFragment:New(myControl)
  2. GUILD_HOME_SCENE:AddFragment(myControl)

Of course you need to set your anchors as required. If you reuse a fragment on different scenes and want to position it relative to different elements, you can listen to a scene's "StateChange" callback:

Lua Code:
  1. GUILD_HOME_SCENE:RegisterCallback("StateChange", function(oldState, newState)
  2.     myControl:ClearAnchors()
  3.     if(GUILD_HOME_SCENE:IsShowing()) then
  4.         myControl:SetAnchor(...) -- configuration a
  5.     else
  6.         myControl:SetAnchor(...) -- configuration b
  7.     end
  8. end)

Otherwise you could just set them once when you first create the fragment.
  Reply With Quote
06/22/17, 06:12 AM   #3
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Thank you for the very helpful reply.
  Reply With Quote
06/24/17, 02:19 PM   #4
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Despite your help, I'm not yet up to speed. I'm having trouble positioning my control relative to
GUILD_HOME_SCENE. It is quite clearly being positioned relative to the main window. I suspect that is because my container control is an instance of TopLevelControl, which I'm sure isn't right, but it is the only thing the tutorials suggest, and I can't find any indication of what else it could be.

Code:
<GuiXml>
  <Controls>
    <TopLevelControl name="MyControl" hidden="true">
      <Dimensions x="200" y="200" />
      <Anchor point="BOTTOM" relativeTo="$(parent)" relativePoint="BOTTOM"  />
      <Controls>
        ... etc
      </Controls>
    </TopLevelControl>
  </Controls>
</GuiXml>
  Reply With Quote
06/24/17, 03:01 PM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Perhaps try to change the relative anchor point of your control:

Code:
relativeTo="ZO_GuildHome"
or
Code:
relativeTo="ZO_GuildSharedInfo"
You can check the guild home files inside the esoui source code (download here http://www.esoui.com/downloads/info1...ourcecode.html
and extract, then look into the folders "esoui/ingame/guild").

Inside the keyboard subfolder you'll find the file guildhome_keyboard.xml and .lua including some control names where you could anchor to or set the parent of your control by the help of lua commands:

Lua Code:
  1. yourControl:SetParent(parentControlName)
  Reply With Quote
06/27/17, 09:55 AM   #6
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
I'm trying to follow this advice:

Originally Posted by sirinsidiator View Post
Of course you need to set your anchors as required. ... [Y]ou can listen to a scene's "StateChange" callback:

Lua Code:
  1. GUILD_HOME_SCENE:RegisterCallback("StateChange", function(oldState, newState)
  2.     myControl:ClearAnchors()
  3.     if(GUILD_HOME_SCENE:IsShowing()) then
  4.         myControl:SetAnchor(...) -- configuration a
  5.     end
  6. end)
My difficulty is that calling myControl:ClearAnchors() results in the message *function expected instead of nil* and d() confirms that myControl.ClearAnchors is in fact nil (but myControl is not). Any suggestions about what I am doing wrong?
  Reply With Quote
06/27/17, 10:44 AM   #7
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by BoarGules View Post
I'm trying to follow this advice:



My difficulty is that calling myControl:ClearAnchors() results in the message *function expected instead of nil* and d() confirms that myControl.ClearAnchors is in fact nil (but myControl is not). Any suggestions about what I am doing wrong?
Show us your definition of myControl. I would say your myControl is not a control, but something else.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How to put a control on the Guild Home page

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off