1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

LuaEvents and something strange blocking

Discussion in 'Civ5 - SDK / LUA' started by ispanets, May 29, 2015.

  1. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Hi all!

    I have come across a real weird thing. In my Lord of the Rings scenarios, by clicking a button "start encounter", i call to the following LuaEvent:

    Code:
    LuaEvents.OnEncounter(iEncounterID);
    The event is registered in a EncounterPopup.lua / EncounterPopup.xml ...

    Code:
    LuaEvents.OnEncounter.Add(OnPopupEncounter);
    and responses correctly. It executes...

    Code:
    function OnPopupEncounter(iEncounterID)
            --CONFIGURES POPUP DATA / IMAGES
    	ContextPtr:SetHide( false );
    	Game.SetPausePlayer(Game.GetActivePlayer());
    	Controls.EncounterPopupGrid:SetHide(false);
    	unit = UI.GetHeadSelectedUnit();
           
            ...
    
            --SHOW POPUP
            OpenPopup();
    end
    it shows the popup correctly...

    Code:
    function OpenPopup()
    	ContextPtr:SetHide( false );
    	Controls.EncounterPopupGrid:SetHide(false);
    	Debug("EncountersClicked called to show popup");
    	UIManager:QueuePopup( ContextPtr, PopupPriority.InGameUtmost );
    end
    then everything works well, I close the popup with a button...

    Code:
    Controls.btnClose:RegisterCallback( Mouse.eLClick, Close );
    it closes, so it executes well the following code...

    Code:
    function Close()
    	local newCursor = GameInfoTypes[GameInfo.InterfaceModes[InterfaceModeTypes.INTERFACEMODE_SELECTION].CursorType];
    	UIManager:SetUICursor(newCursor);
    	Events.ClearHexHighlights();
    	UIManager:DequeuePopup( ContextPtr );
    	Controls.EncounterPopupGrid:SetHide(true);
    	ContextPtr:SetHide( true );
    	Game.SetPausePlayer(-1);
    	Debug("EncountersClicked called to close");	
    end
    Afterwards, a WEIRD behaviour. The stack of the game ("Choose production") doesn't get updated. I select in everycity the production, but the "Choose production" message doesn't disappear. When I click on it, it points me to the same city, again and again. And it does have already a project selected, but anyway, "Choose production" doesn't let me to do anything else.

    I have tried to check if the Player is paused, if there are lua errors. NOTHING. Firetuner doesn't show anything.

    Any idea of what could be causing the block?

    Thanks in advance.
     
  2. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    This is already fixed. I didn't actually need the UIManager:QueuePopup( ContextPtr, PopupPriority.InGameUtmost ) and UIManager:DequeuePopup( ContextPtr ). That is was it was blocking the UI.
     
  3. Vicevirtuoso

    Vicevirtuoso The Modetta Man

    Joined:
    May 14, 2013
    Messages:
    775
    Location:
    The Wreckage, Brother
    QueuePopup and DequeuePopup seem quite unreliable when used with new UI elements added by mods. I discovered that it was the cause of several (but not all) crashes with Events & Decisions, for example. It's best to just use SetHide for the most part.
     

Share This Page