UI Interface Doesn't Seem to List Anything

Enginseer

Salientia of the Community Patch
Supporter
Joined
Nov 7, 2012
Messages
3,674
Location
Somewhere in California
Using Whoward's UI Tutorial 3. I've theoretically manipulated his Menus to only include major civilizations and exclude minor civilizations, so any person that clicks on the major civilization will have a notification of the civilization's (social policies). However, it doesn't seem to be working because it doesn't show any major civilizations even though I've met them all. It shows no error in the logs and the code in blue is where I believe where the problem is.. but I can't seem to fathom on what is it.

Code:
local iDepotism = GameInfoTypes.POLICY_CIVIC_DEPOTISM
local iHereditaryRule = GameInfoTypes.POLICY_CIVIC_HEREDITARY_RULE
local iPatronage = GameInfoTypes.POLICY_CIVIC_PATRONAGE
local iRepresentation = GameInfoTypes.POLICY_CIVIC_REPRESENTATION
local iPoliceState = GameInfoTypes.POLICY_CIVIC_POLICE_STATE
local iUniversalSuffrage = GameInfoTypes.POLICY_CIVIC_UNIVERSAL_SUFFRAGE
local iBarbarism = GameInfoTypes.POLICY_CIVIC_BARBARISM
local iCivilLaw = GameInfoTypes.POLICY_CIVIC_CIVIL_LAW
local iVassalage = GameInfoTypes.POLICY_CIVIC_VASSALAGE
local iBureaucracy = GameInfoTypes.POLICY_CIVIC_BUREAUCRACY
local iNationhood = GameInfoTypes.POLICY_CIVIC_NATIONHOOD
local iFreeSpeech = GameInfoTypes.POLICY_CIVIC_FREE_SPEECH
local iTribalism = GameInfoTypes.POLICY_CIVIC_TRIBALISM
local iSlavery = GameInfoTypes.POLICY_CIVIC_SLAVERY
local iSerfdom = GameInfoTypes.POLICY_CIVIC_SERFDOM
local iCasteSystem = GameInfoTypes.POLICY_CIVIC_CASTE_SYSTEM
local iIndustrializedServitude = GameInfoTypes.POLICY_CIVIC_INDUSTRIALIZED_SERVITUDE
local iEmancipation =  GameInfoTypes.POLICY_CIVIC_EMANCIPATION
local iDecentralization = GameInfoTypes.POLICY_CIVIC_DECENTRALIZATION
local iMercantilism = GameInfoTypes.POLICY_CIVIC_MERCANTILISM
local iFreeMarket = GameInfoTypes.POLICY_CIVIC_FREE_MARKET
local iStateProperty = GameInfoTypes.POLICY_CIVIC_STATE_PROPERTY
local iCorporatism = GameInfoTypes.POLICY_CIVIC_CORPORATISM
local iEnvironmentalism = GameInfoTypes.POLICY_CIVIC_ENVIRONMENTALISM
local iPaganism = GameInfoTypes.POLICY_CIVIC_PAGANISM
local iOrganizedReligion = GameInfoTypes.POLICY_CIVIC_ORGANIZED_RELIGION
local iTheocracy = GameInfoTypes.POLICY_CIVIC_THEOCRACY
local iPacifism = GameInfoTypes.POLICY_CIVIC_PACIFISM
local iStateAtheism = GameInfoTypes.POLICY_CIVIC_STATE_ATHEISM
local iFreeReligion = GameInfoTypes.POLICY_CIVIC_FREE_RELIGION
local g_SortTable

function OnShowHide(bHide, bInit)
	if (not bHide) then
    UpdateCivicList()
	end	
end
ContextPtr:SetShowHideHandler(OnShowHide)

function OnClosingOK()
  ContextPtr:SetHide(true)
end
Controls.OK:RegisterCallback(Mouse.eLClick, OnClosingOK)

function SortByName(a, b)
  local sNameA = g_SortTable[tostring(a)].Name
  local sNameB = g_SortTable[tostring(b)].Name
	return sNameA < sNameB
end

function OnCivicSelected(playerID)
	local pPlayer = Players[playerID]
	local pActivePlayer = Players[Game.GetActivePlayer()]
	SetCivicDetails(pPlayer, Controls)
	if pPlayer:HasPolicy(iDepotism) then
		sText = "They govern through a despotic rule."
	elseif pPlayer:HasPolicy(iHereditaryRule) then
		sText = "They govern through a hereditary rule."
	elseif pPlayer:HasPolicy(iPatronage) then
		sText = "They govern through a group of patricians."
	elseif pPlayer:HasPolicy(iRepresentation) then
		sText = "They govern through a group of representatives."
	elseif pPlayer:HasPolicy(iPoliceState) then
		sText = "They govern through a police rule."
	elseif pPlayer:HasPolicy(iUniversalSuffrage) then
		sText = "They govern through a direct democracy."
	else 
		sText = "They seem to not have any method of governing. Possible bug?!"
	end
	sTitle = pPlayer:GetName() .. "'s Civics"
	pActivePlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, sText, sTitle, -1, -1)
end

[COLOR="DeepSkyBlue"]function SetCivicDetails(pPlayer, entry)
  entry.CivicName:SetText(pPlayer:GetName())
  local _, CivicColour = pPlayer:GetPlayerColors(); CivicColour.w = 1
  entry.CivicName:SetColor(CivicColour, 0)
end

function UpdateCivicList()
	local iTeam = Game.GetActiveTeam()
	Controls.CivicMenu:ClearEntries()
	g_SortTable = {}
	for playerID = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_MAJOR_CIVS-1, 1 do
		local pPlayer = Players[playerID]
		if (pPlayer:IsAlive() and Teams[pPlayer:GetTeam()]:IsHasMet(iTeam)) then
			local sPlayerName = pPlayer:GetName()
			local entry = {}
			Controls.CivicMenu:BuildEntry("InstanceOne", entry)
			g_SortTable[tostring(entry.Button)] = {Name=sPlayerName}
			entry.Button:SetVoid1(playerID)
			SetCivicDetails(pPlayer, entry)
		end
	end
	Controls.CivicMenuStack:SortChildren(SortByName)
	Controls.CivicName:LocalizeAndSetText("TXT_KEY_TEST_MENU_CIVIC_CHOOSE")
	Controls.CivicName:SetColorByName("Beige_Black_Alpha")
	Controls.CivicMenu:RegisterSelectionCallback(OnCivicSelected)
	Controls.CivicMenu:CalculateInternals()
	Controls.CivicMenuGrid:SetSizeY(230)
	Controls.CivicMenuPanel:SetOffsetVal(4,2)
end[/COLOR]

function PleaseEnableEveryTime(iPlayer)
	if Players[iPlayer]:IsHuman() then
		if (math.fmod(Game.GetElapsedGameTurns(), math.ceil((GameInfo.GameSpeeds[Game.GetGameSpeedType()].BuildPercent)/5)+1) == 0) then
			ContextPtr:SetHide(false)
		end
	end
end
GameEvents.PlayerDoTurn.Add(PleaseEnableEveryTime)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<Context ID="Menu3">
  <Box Style="BGBlock_ClearTopBar" />

  <Instance Name="Civic">
    <Label ID="Label" Anchor="L,T" Font="TwCenMT20" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" />
  </Instance>

  <Grid Size="600,400" Anchor="C,C" Style="Grid9DetailFive140" ConsumeMouse="1">
    <Label ID="Message" Anchor="C,T" Offset="0,50" Font="TwCenMT24" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" String="TXT_KEY_TEST_MENU_CIVIC_TITLE"/>

    <PullDown ID="CivicMenu" Style="GenericPullDown" ScrollThreshold="143" Size="220,27" SpaceForScroll="1" Anchor="C,T" Offset="0,90">
      <ButtonData>
        <GridButton Style="SquareButton" Anchor="L,C" >
          <Image Texture="Assets/UI/Art/Controls/9 Grids/Corner16.dds" TextureOffset="0.0" Offset="3.3"  Size="16,16" Anchor="R,B"  />

          <ShowOnMouseOver>
            <Image Texture="Assets/UI/Art/Controls/9 Grids/Corner16.dds" TextureOffset="0.16" Offset="3.3"  Size="16,16" Anchor="R,B"  />
          </ShowOnMouseOver>

          <Label ID="CivicName" Anchor="L,C" Offset="40,0" Font="TwCenMT20" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" String="TXT_KEY_TEST_MENU_CIVIC_CHOOSE">
          </Label>
        </GridButton>
      </ButtonData>

      <GridData ID="CivicMenuGrid" Anchor="L,T" Offset="0,-42" Size="220,230" Style="Grid9DetailTwo140" Padding="5,5" />

      <ScrollPanelData ID="CivicMenuPanel" Offset="4,2" Vertical="1">
        <ScrollBar  Style="VertSlider"    Anchor="L,T" Offset="0,18"/>
        <UpButton   Style="ScrollBarUp"   Anchor="L,T" Offset="0,0"/>
        <DownButton Style="ScrollBarDown" Anchor="L,T" Offset="0,122"/>
      </ScrollPanelData>

      <StackData ID="CivicMenuStack" Offset="10,0"/>

      <InstanceData Name="InstanceOne">
        <Button ID="Button" Size="200,24" Anchor="L,C">
          <ShowOnMouseOver>
            <AlphaAnim Anchor="C,C" Size="140,24" Pause="0" Cycle="Bounce" Speed="1" AlphaStart="1" AlphaEnd="0">
              <Grid Size="140,26" Style="Grid9FrameTurns" />
            </AlphaAnim>
          </ShowOnMouseOver>

          <Label ID="CivicName" Anchor="L,C" Offset="40,0" Font="TwCenMT20" FontStyle="Shadow" ColorSet="Beige_Black_Alpha">
          </Label>
        </Button>
      </InstanceData>
    </PullDown>

    <GridButton ID="OK" Size="140,36" Anchor="C,B" Offset="0,50" Style="BaseButton" ToolTip="TXT_KEY_TEST_MENU_BUTTON_OK_TT">
      <Label Anchor="C,C" Offset="0,-2" String="TXT_KEY_TEST_MENU_BUTTON_OK" Font="TwCenMT24" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" />
    </GridButton>
  </Grid>
</Context>
 
Code:
for playerID = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_MAJOR_CIVS-1, 1 do
translates as

"for playerID starting at 22 and progressing to 21 in positive steps of 1 ..."
 
Code:
for playerID = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_MAJOR_CIVS-1, 1 do
translates as

"for playerID starting at 22 and progressing to 21 in positive steps of 1 ..."

So, it's supposed to be

Code:
for playerID = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
 
Back
Top Bottom