My dialog popup has some problem

bismark439

Chieftain
Joined
Aug 26, 2013
Messages
34
I am looking at this page and making a UI
http://forums.civfanatics.com/showpost.php?p=11490400&postcount=2

this is my code, basically modified from Whoward's on
Code:
g_DialogID = "Dialog1b"
include("DialogUtils")

include("IconSupport")


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



Controls.Message:LocalizeAndSetText("TXT_KEY_TEST_VENGE")


IconHookup(9, 80, "CIV_COLOR_ATLAS", Controls.DialogTopIcon)
DIalog.lua

Code:
<?xml version="1.0" encoding="utf-8" ?>
<Context ID="Dialog4c">
  <Box Style="BGBlock_ClearTopBar" />

  <Grid Size="400,270" Anchor="C,C" Style="Grid9DetailFive140" ConsumeMouse="1">
    <Image Anchor="C,T" AnchorSide="I,O" Offset="0,-27" Size="256,64" Texture="DecTop256x64.dds">
      <Image Anchor="C,C" Offset="0,-6" Size="80,80" Texture="NotificationFrameBase.dds">
        <Image ID="DialogTopIcon" Anchor="C,C" Offset="0,0" Size="80,80" Texture="NotificationGeneric.dds" />
      </Image>
    </Image>

    <Image Anchor="L,C" AnchorSide="O,I" Offset="-17,0" Size="32,64" Texture="Dec32x64Left.dds" />
    <Image Anchor="R,C" AnchorSide="O,I" Offset="-17,0" Size="32,64" Texture="Dec32x64Right.dds" />

    <AlphaAnim ID="BgImage" Anchor="L,T" Offset="17,43" Size="367,185" TextureOffset="200,35" Texture="ERA_Classical.dds" Cycle="Once" Stopped="1" AlphaStart="0.4" AlphaEnd="0.4" Speed="1"/>
    
    <Label ID="Message" Anchor="C,C" Font="TwCenMT24" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" String="TXT_KEY_TEST_DIALOG_MESSAGE"/>

    <GridButton ID="OK" Size="140,36" Anchor="C,B" Offset="0,50" Style="BaseButton" ToolTip="TXT_KEY_TEST_DIALOG_BUTTON_OK_TT">
      <ShowOnMouseOver>
        <AlphaAnim Anchor="L,C" AnchorSide="O,O" Size="16,32" TextureOffset="0,0" Texture="buttonsidesglow.dds" Cycle="Bounce" Speed="1" AlphaStart=".99" AlphaEnd=".25"/>
        <Image     Anchor="L,C" AnchorSide="O,O" Size="8,16"  TextureOffset="0,0" Texture="buttonsides.dds" />

        <AlphaAnim Anchor="R,C" AnchorSide="O,O" Size="16,32" TextureOffset="16,0" Texture="buttonsidesglow.dds" Cycle="Bounce" Speed="1" AlphaStart=".99" AlphaEnd=".25"/>
        <Image     Anchor="R,C" AnchorSide="O,O" Size="8,16"  TextureOffset="8,0"  Texture="buttonsides.dds" />
      </ShowOnMouseOver>

      <Label Anchor="C,C" Offset="0,-2" String="TXT_KEY_TEST_DIALOG_BUTTON_OK" Font="TwCenMT24" FontStyle="Shadow" ColorSet="Beige_Black_Alpha" />
    </GridButton>
  </Grid>
</Context>
dialog.mxl not modified from whoward's file

Code:
function Show()
  ShowDialog(g_DialogID)
end

function Hide()
  ShowDialog("")
end

function OnShowDialog(sDialog)
  if (g_DialogID == sDialog) then
    ContextPtr:SetHide(false)
  else
    ContextPtr:SetHide(true)
  end
end
LuaEvents.TestDialog_Show.Add(OnShowDialog)

function ShowDialog(sDialog)
  LuaEvents.TestDialog_Show(sDialog)
end

function Show1()
  ShowDialog("Dialog1")
end
and dialogutils.log which activates dialog somehow.
Code:
GameEvents.PlayerDoTurn.Add(function(iPlayer) 

    	-- Only on first player's turn
	if (iPlayer > 0) then
		return false;
	end

		if (Game.GetGameTurn() == 1 ) then 
		Show1();

		end

end);
the problem is, i made this popup to be activated at Turn 1, however all the popups I added with thos codes come out in the beginning (Turn 0) and this popup comes out again in Turn 1.

Which part of this code is activating popup as soon as I initialise the mod?:confused::confused:
 
Very much a necro-post I know, but try this:
Code:
g_DialogID = "Dialog1b"
include("DialogUtils")

include("IconSupport")


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



Controls.Message:LocalizeAndSetText("TXT_KEY_TEST_VENGE")


IconHookup(9, 80, "CIV_COLOR_ATLAS", Controls.DialogTopIcon)  


ContextPtr:SetHide(true)
 
Back
Top Bottom