View Single Post
03/15/19, 06:38 PM   #17
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Okay, this is the XML that contains the container ("$(parent)_DisplayContainer") where the templates should be applied to:

Code:
<TopLevelControl name="AuraMasteryAuraActionsWindow" clampedToScreen="true" mouseEnabled="true" movable="true" tier="1" layer="2" hidden="true">
	<Dimensions x="800" y="600" />
	<Anchor point="CENTER" relativeTo="GuiRoot" relativePoint="CENTER" />
	<Controls>			
		<Backdrop name="$(parent)_Backdrop" inherits="ZO_DefaultBackdrop" />
		<Label name="$(parent)_Label" font="$(BOLD_FONT)|18|soft-shadow-thin" color="C5C29E" text="Trigger Events">
			<Anchor point="TOP" relativeTo="$(parent)" anchorPoint="TOP" offsetY="6" />
		</Label>
		<Button name="$(parent)_CloseButton" inherits="ZO_CloseButton">
			<OnClicked>self:GetParent():SetHidden(true)</OnClicked>
		</Button>
		
		<Button name="$(parent)SubCategorySounds" inherits="ZO_DefaultButton" text="Animations">				
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetX="0" offsetY="42" />
			<OnClicked>
				WINDOW_MANAGER:ApplyTemplateToControl(self:GetParent():GetNamedChild("_DisplayContainer"), "AM_TEMP_ANIMATIONS")
			</OnClicked>
		</Button>

		<Button name="$(parent)SubCategoryAnimations" inherits="ZO_DefaultButton" text="Sounds">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetX="120" offsetY="42" />
			<OnClicked>
				WINDOW_MANAGER:ApplyTemplateToControl(self:GetParent():GetNamedChild("_DisplayContainer"), "AM_TEMP_SOUNDS")
			</OnClicked>
		</Button>				
		
		<Control name="$(parent)_DisplayContainer" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetY="86" />
			<Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" anchorPoint="BOTTOMRIGHT" />
			<Controls>
<!--
<Backdrop name="$(parent)BG" centerColor="00000000" edgeColor="00FF00">
<AnchorFill />
<Edge edgeSize="1" />
</Backdrop>
-->
			</Controls>
		</Control>
	
	</Controls>

</TopLevelControl>

This is Template A:
Code:
<Control name="AM_TEMP_ANIMATIONS" virtual="true">
	<!--
		STRANGE: <OnInitialized> is not called for this control, only for it's child controls! Probably because it's a virtual?
				 So we use the lastly initialized control's <OnInitialized>...
	-->
	<Controls>		
		<Label name="$(parent)_LabelTrigger" font="$(BOLD_FONT)|18|soft-shadow-thin" color="C5C29E" text="On Trigger:">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetY="8" />
		</Label>
		<Control name="$(parent)_TriggerAnimationEnabled" inherits="AM_TriggerControl" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="40" />
			<Controls>
				<Button name="$(parent)_Checkbox" inherits="ZO_CheckButton" override="true">
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetX="-4" />
					<OnInitialized>
						ZO_CheckButton_SetToggleFunction(self, AuraMastery.EditAuraTriggerAnimation)
					</OnInitialized>
					<OnEffectivelyShown>
						AuraMastery.UpdateTriggerAnimationCheckbox(self)
					</OnEffectivelyShown>
				</Button>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Play Screen Flash Animation:")
			</OnInitialized>
		</Control>

		<Control name="$(parent)_TriggerAnimationColor" inherits="AM_TriggerControl" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="70" />
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Flash Color:")
				AuraMastery:InitAnimationColorColorSelect(self)
			</OnInitialized>
		</Control>

		<Control name="$(parent)_TriggerAnimationEndAlpha" inherits="AM_TriggerControl" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="100" />
			<Controls>
				<Backdrop name="$(parent)_Editbox" inherits="AM_EditBox" override="true">
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetX="-4" />
					<OnInitialized>
						local editbox = self:GetNamedChild("_Editbox")
						editbox:SetHandler("OnEnter", function() AuraMastery:EditAuraTriggerAnimationEndAlpha(editbox); end)
					</OnInitialized>
				</Backdrop>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Max Flash Transparency:")
			</OnInitialized>
		</Control>				
		
		<Control name="$(parent)_TriggerAnimationDuration" inherits="AM_TriggerControl" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="130" />
			<Controls>
				<Backdrop name="$(parent)_Editbox" inherits="AM_EditBox" override="true">
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetX="-4" />
					<OnInitialized>
						local editbox = self:GetNamedChild("_Editbox")
						editbox:SetHandler("OnEnter", function() AuraMastery:EditAuraTriggerAnimationDuration(editbox); end)
					</OnInitialized>
				</Backdrop>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Duration per Flash:")
			</OnInitialized>
		</Control>
		
		<Control name="$(parent)_TriggerAnimationLoopCount" inherits="AM_TriggerControl" override="true">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="160" />
			<Controls>
				<Backdrop name="$(parent)_Editbox" inherits="AM_EditBox" override="true">
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetX="-4" />
					<OnInitialized>
						local editbox = self:GetNamedChild("_Editbox")
						editbox:SetHandler("OnEnter", function() AuraMastery:EditAuraTriggerAnimationLoopCount(editbox); end)
					</OnInitialized>
				</Backdrop>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Number of Flashes:")
				
				--
				-- ATTENTION: Always call "AuraMastery.UpdateTriggerAnimationCheckbox()" on the controlSet's control that ist INITIALIZED LASTLY!!!
				-- This is neccessary because controls are initialized one after another. If this was called on the checkbox's (first control) OnInitialized, the consecutively called update function for the whole control set
				-- would be called at a time, where the other, consecutive controls are not initialized yet and hence produce errors. This is a bit unlucky but for the time being the only solution that I can think of.
				-- Calling it OnInitialized on the whole controlSet does not work as the controlSet's parental control is of type virtual and hence does call OnInitialized...
				--
				local checkbox = self:GetParent():GetNamedChild("_TriggerAnimationEnabled"):GetNamedChild("_Checkbox")
				AuraMastery.UpdateTriggerAnimationCheckbox(checkbox)
			</OnInitialized>
		</Control>
	</Controls>
</Control>
This is Template B:

Code:
<!-- TEMPORARY!! -->
<Control name="AM_TEMP_SOUNDS" virtual="true">
	<Controls>
		<Label name="$(parent)_LabelTrigger" font="$(BOLD_FONT)|18|soft-shadow-thin" color="C5C29E" text="On Trigger:">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetY="8" />
		</Label>	
		<Control name="$(parent)_TriggerActions" inherits="AM_TriggerControl">
			<Dimensions x="550" y="28" />
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="36" />
			<Controls>
				<Control name="$(parent)_ScrollableComboBox" inherits="AM_ScrollableComboBox" tier="2">
					<Dimensions x="420" y="28" />
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetY="1" offsetX="1" />
				</Control>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Play Sound:")
				AuraMastery:InitTriggerSoundsComboBox()
				deb("OnInitialized called...")
			</OnInitialized>
			<OnEffectivelyShown>
				AuraMastery.UpdateTriggerSoundSelect()
				deb("OnEffectivelyShown called...")
			</OnEffectivelyShown>
			<OnEffectivelyHidden>
				deb("OnEffectivelyHidden called...")
			</OnEffectivelyHidden>
		</Control>

		<Label name="$(parent)_LabelUntrigger" font="$(BOLD_FONT)|18|soft-shadow-thin" color="C5C29E" text="On Untrigger:">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetY="96" />
		</Label>	
		<Control name="$(parent)_UntriggerActions" inherits="AM_TriggerControl">
			<Dimensions x="550" y="28" />
			<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetY="120" />
			<Controls>
				<Control name="$(parent)_ScrollableComboBox" inherits="AM_ScrollableComboBox" tier="2">
					<Dimensions x="420" y="28" />
					<Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="RIGHT" offsetY="1" offsetX="1" />
				</Control>
			</Controls>
			<OnInitialized>
				self:GetNamedChild("_Label"):SetText("Play Sound:")
				AuraMastery:InitUntriggerSoundsComboBox()
			</OnInitialized>
			<OnEffectivelyShown>
				AuraMastery.UpdateUntriggerSoundSelect()
				deb("OnEffectivelyShown called...")
			</OnEffectivelyShown>
			<OnEffectivelyHidden>
				deb("OnEffectivelyHidden called...")
			</OnEffectivelyHidden>
		</Control>
	</Controls>
</Control>

When I hit the first button, template A gets applied to "_DisplayContainer". Whenever I hit the second button and template B gets applied to "_DisplayContainer" aswell, A and B are mixed together, override="true" does not change anything.

Here is a screenshot of what happens after pressing both buttons:


I want Template A to be entirely replaced by Template B and vice versa.

I tested it with template A and template B having only one label control of the same structure just with different texts. It worked flawlessly. Override="true" was only neccessary if the header B had some other attributes, etc.

As I see it, you cannot overwrite one control with a different control type.

Last edited by Letho : 03/15/19 at 07:17 PM.
  Reply With Quote