Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Implementing rollup diplomacy ribbon banners #411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Assets/UI/diplomacyribbon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ local m_kLeaderIM :table = InstanceManager:new("LeaderInstance", "LeaderContai
local m_PartialScreenHookBar: table; -- = ContextPtr:LookUpControl( "/InGame/PartialScreenHooks/LaunchBacking" );
local m_LaunchBar : table; -- = ContextPtr:LookUpControl( "/InGame/LaunchBar/LaunchBacking" );

--CQUI Members
local CQUI_DefaultHiddenBanners = false;
local CQUI_LeaderBannerToggle = {}; --Contains a value determining if the given leader ID should have it's diplo banner expanded or not (nil is the default state, which is off)

function CQUI_ExpandBanner(instance)
instance.CQUI_BannerRollupAnim:SetToBeginning();
instance.CQUI_BannerRollupAnim:Play();
end
function CQUI_CollapseBanner(instance)
if(not instance.CQUI_BannerRollupAnim:IsReversing()) then
instance.CQUI_BannerRollupAnim:Stop();
instance.CQUI_BannerRollupAnim:Reverse();
end
end

-- ===========================================================================
-- Cleanup leaders
-- ===========================================================================
Expand Down Expand Up @@ -116,6 +131,22 @@ function AddLeader(iconName : string, playerID : number, isUniqueLeader: boolean
-- Register the click handler
instance.Button:RegisterCallback( Mouse.eLClick, function() OnLeaderClicked(playerID); end );
instance.Button:RegisterCallback( Mouse.eRClick, function() OnLeaderRightClicked(playerID); end );
--CQUI banner rollup anims
instance.Button:RegisterCallback( Mouse.eMouseEnter, function()
if(not CQUI_LeaderBannerToggle[playerID]) then
CQUI_ExpandBanner(instance);
end
end);
instance.CQUI_ScoreDisplayToggle:RegisterCallback( Mouse.eMouseExit, function()
if(not CQUI_LeaderBannerToggle[playerID]) then
CQUI_CollapseBanner(instance);
end
end);
instance.CQUI_ScoreDisplayToggle:RegisterCallback(Mouse.eLClick, function()
if(CQUI_LeaderBannerToggle[playerID] == nil) then
CQUI_LeaderBannerToggle[playerID] = true;
else CQUI_LeaderBannerToggle[playerID] = not CQUI_LeaderBannerToggle[playerID]; end
end);

local bShowRelationshipIcon:boolean = false;
local localPlayerID:number = Game.GetLocalPlayer();
Expand Down
45 changes: 25 additions & 20 deletions Assets/UI/diplomacyribbon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,31 @@
<!-- ================================================================== -->
<Instance Name="LeaderInstance">
<SlideAnim ID="LeaderContainer" Size="60,120" Offset="0,0" Begin="0,0" EndOffset="0,20" Cycle="Once" Stopped="1">
<Grid Style="EnhancedToolTip" Size="parent,parent" Color="255,200,100,255" InnerPadding="10,5">
<Stack ID="CQUI_ScoreDisplayStack" Anchor="C,T" StackGrowth="Bottom" StackPadding="4" >
<Button ID="Button" Size="parent,52">
<Image Texture="Controls_CircleBacking45" Size="51,51" Anchor="C,C" Offset="0,1"/>
<Image Anchor="C,C" ID="YouIndicator" Hidden="1" Size="55,53" Texture="Diplomacy_YouIndicator45"/>
<Image ID="Portrait" Anchor="C,C" Size="45,45" Texture="Leaders45" />
<Image ID="TeamRibbon" Anchor="C,B" Offset="0,-8" Texture="TeamRibbon53" Size="53,53"/>
<Button ID="Relationship" StretchMode="None" Style="DiplomacyRelationshipPips" Anchor="L,B" Disabled="1" ConsumeMouse="0"/>
</Button>
<Label ID="CQUI_ScoreOverall" Anchor="L,B" Offset="0,0" Style="CityPanelNumSmall" String="-" />
<Label ID="CQUI_ScienceRate" Anchor="L,B" Offset="0,0" Style="CityPanelCBScience" String="Sci" />
<Label ID="CQUI_MilitaryStrength" Anchor="L,B" Offset="0,0" Style="CityPanelCBProduction" String="Mil" />
</Stack>
<Image ID="CivIndicator" Anchor="R,T" Texture="CircleBacking22" Size="22,22" Offset="-5,-2" Hidden="1">
<Image ID="CivIcon" Anchor="C,C" Texture="CivSymbols22" Size="22,22"/>
</Image>
<AlphaAnim ID="ChatIndicatorFade" Cycle="Once" AlphaBegin="0.0" AlphaEnd="1.0" Speed="3" Stopped="1">
<Image ID="ChatIndicator" Hidden="0" Offset="35,0" Size="22,22" Texture="DiploRibbon_TypingIndicator"/>
</AlphaAnim>
</Grid>
<Button ID="CQUI_ScoreDisplayToggle" Size="parent,parent">
<SlideAnim ID="CQUI_BannerRollupAnim" Begin="0,-120" End="0,0" Cycle="Once" Function="OutQuint" Speed="2" Stopped="1">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricanuck We could always, you know, have it go up further

<Grid ID="CQUI_ScoreDisplayContainer" Style="EnhancedToolTip" Size="parent,parent" Color="255,200,100,255" InnerPadding="10,5">
<Stack ID="CQUI_ScoreDisplayStack" Anchor="C,T" StackGrowth="Bottom" StackPadding="4" >
<Grid Size="parent,52" Alpha="0"/> <!-- Occupies the space of the button as a placeholder while the button renders on top of the stack instead of inside it. This is done to animate the score stack seperately -->
<Label ID="CQUI_ScoreOverall" Anchor="L,B" Offset="0,0" Style="CityPanelNumSmall" String="-" />
<Label ID="CQUI_ScienceRate" Anchor="L,B" Offset="0,0" Style="CityPanelCBScience" String="Sci" />
<Label ID="CQUI_MilitaryStrength" Anchor="L,B" Offset="0,0" Style="CityPanelCBProduction" String="Mil" />
</Stack>
<Image ID="CivIndicator" Anchor="R,T" Texture="CircleBacking22" Size="22,22" Offset="-5,-2" Hidden="1">
<Image ID="CivIcon" Anchor="C,C" Texture="CivSymbols22" Size="22,22"/>
</Image>
<AlphaAnim ID="ChatIndicatorFade" Cycle="Once" AlphaBegin="0.0" AlphaEnd="1.0" Speed="3" Stopped="1">
<Image ID="ChatIndicator" Hidden="0" Offset="35,0" Size="22,22" Texture="DiploRibbon_TypingIndicator"/>
</AlphaAnim>
</Grid>
</SlideAnim>
</Button>
<Button ID="Button" Size="parent,52">
<Image Texture="Controls_CircleBacking45" Size="51,51" Anchor="C,C" Offset="0,1"/>
<Image Anchor="C,C" ID="YouIndicator" Hidden="1" Size="55,53" Texture="Diplomacy_YouIndicator45"/>
<Image ID="Portrait" Anchor="C,C" Size="45,45" Texture="Leaders45" />
<Image ID="TeamRibbon" Anchor="C,B" Offset="0,-8" Texture="TeamRibbon53" Size="53,53"/>
<Button ID="Relationship" StretchMode="None" Style="DiplomacyRelationshipPips" Anchor="L,B" Disabled="1" ConsumeMouse="0"/>
</Button>
</SlideAnim>
</Instance>

Expand Down