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

CEP - EUI compatibility issues

Discussion in 'Communitas Expansion Pack' started by bc1, Feb 26, 2014.

  1. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Some of our users are asking for CEP and EUI compatibility, so I took some time to look at CEP files 3.14.1, and it seems there may not be that many issues to solve:

    • First thing is that CEP adds custom yields in the base Yields database table, causing compatibility problems because the game's DLL does not handle these unknown yields gracefully.
      This is done in "Communitas AI and Tools (v 3)\Tools\YieldLibrary", specifically YL_Data.xml adds YIELD_HAPPINESS_CITY, YIELD_HAPPINESS_NATIONAL, YIELD_GREAT_PEOPLE, YIELD_EXPERIENCE, YIELD_LAW, YIELD_CS_MILITARY, YIELD_CS_GREAT_PEOPLE, YIELD_POPULATION
      ==> proposed solution: duplicate the game's Yields table by SQL statement: SELECT * INTO CEP_Yields FROM Yields, then add the yields CEP needs. The lua scripts must be modified accordingly, but it's only a matter of replacing Yields with CEP_Yields where appropriate.
    • TechTree.lua / TechTree.xml : these will overwrite EUI's, but without user specifically disabling EUI's techtree module this will create a bug with the big tech selection button
      ==> please add the game's TechPopup.lua and TechPopup.xml base files in your distribution for simple compatibility with EUI
    • InfoTooltipInclude.lua : CEP deviates from the standard game API, adding new functions. That won't work with EUI because its own "InfoTooltipInclude.lua" is loaded pregame and may not be overwritten by CEP's in many cases
      ==> proposed solution: make a dedicated CEP_InfoTooltipInclude.lua and "include" that one in CEP lua scripts, plus make an "InfoTooltipInclude.lua" stub for compatibility with the base game which Includes "CEP_InfoTooltipInclude.lua" and only translates the standard game API calls
    • CityView.lua / .xml / _small.xml / ProductionPopup.lua : these will overwrite EUI's...
      ==> recommendation: please add the unmodded ProductionPopup.xml in your distribution since EUI will make changes in the future and an otherwise partial CEP overwrite will result in a fail
    • TechButtonInclude.lua / TechHelpInclude.lua / TurnProcessing.lua / UnitFlagManager.lua : EUI does not currently mod these files
      ==> recommendation: please add their .xml buddies in your distribution for future proofing
    Cheers
     
  2. Tomice

    Tomice Passionate Smart-Ass

    Joined:
    Oct 5, 2009
    Messages:
    2,320
    Location:
    Austria, EU, no kangaroos ;)
    Wow, thx for the effort! I had given up on the idea of using the two mods together.

    Sadly, I have barely any idea what you're talking about :lol: But I hope someone can make good use of this, your mod really improves the game a lot!
     
  3. stackpointer

    stackpointer King

    Joined:
    Mar 3, 2013
    Messages:
    809
    Thanks for the write-up. I'll take a look later tonight.
     
  4. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    @bc1

    Thanks, looks like you have already done a thorough think through on this so it shouldn't be too difficult.

    As most of what you suggest is just adding files into the project this could be done almost immediately.
    I reckon stackpointer will have to run his eye over the custom *.lua files and the "InfoTooltipInclude.lua" stub. Give him 5 minutes.:mischief:
     
  5. stackpointer

    stackpointer King

    Joined:
    Mar 3, 2013
    Messages:
    809
    TopPanel, CityView, ProductionPopup, TechTree: CEP needs to modify these files to show the modded yields since CEP adds food, culture, sources/modifiers that the base game doesn't. Since EUI is modular, it would be possible to just use EUI's versions of these files and just replace the vanilla yield functions with CEP's YieldLibrary functions to use within CEP

    InfoTooltipInclude: I'm not familiar at all with this file (modded and not) but I believe the essential modded code here would be the "Good For" values and any YieldLibrary tooltips. Which fits well with bc1's suggestion converting it into a stub/wrapper for EUI's InfoTooltipInclude.

    UnitPanel: CEP only modifies this file in order to get the Events.PromotionEarned and Events.UnitUpgraded hooks as seen here. Although we may need this file to implement custom events in the future (as we did in GEM).

    WorldView: No idea what this file is. CEP and EUI seems to mod completely different sections of it though.
     
  6. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Works fine / compatible so long as all of the files modified by corresponding EUI modules are included in CEP (otherwise requires manual user action to disable conficting EUI modules).
    If CEP only makes very limited / targeted changes to a file, you might consider making an InGameUIAddin lua/xml pair instead of overwriting game files. Using the powerful LookUpControl function to identify targeted UI controls, new controls can be created using ChangeParent to "transfer" UI controls defined in the InGameUIAddin as if they had been defined in the base game file, and callback hooks (click actions, mouse over tooltips) can be hijacked with ease.
    This would probably work best with Top Panel, removing the need for tedious merge of EUI stuff you may want (and are welcome to use)
    I was actually suggesting the opposite (i.e. make your own library for use inside CEP scripts, and make a library wrapper for use by the other game scripts which overwrites the base games InfoTooltipInclude.lua but can gracefully fail to overwrite EUI's). Either way would work, it's just a matter of taking into account the fact that InfoTooltipInclude may or may not be overwritten by CEP depending on circumstances.
    If CEP only makes very limited / targeted changes, you might consider making an InGameUIAddin instead of overwriting UnitPanel.lua, and place hooks to UI controls identified using LookUpControl( "/InGame/WorldView/UnitPanel" ).nameOfItem
    EUI only makes minor edits to the file (partial fix for subs invisibility) which are completely independent from the rest of EUI
     
  7. stackpointer

    stackpointer King

    Joined:
    Mar 3, 2013
    Messages:
    809
    I'm not familiar with most of what you just mentioned. Is there a tutorial or write up you can point me to so I get informed?
     
  8. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Not that i am aware of, except for InGameUIAddin.

    LookUpControl allows to get a pointer to a UI control in another lua context. For example, in an InGameUIAddin lua script this allows access to the top panel's UI elements:
    Code:
    local topPanelControls = LookUpControl( "/InGame/TopPanel" );
    you can then manipulate any top panel UI elements from the new script like you would using Controls in the top panel script, for example:
    Code:
    topPanelControls.HappinessString:RegisterCallback( Mouse.eLClick, newCEPcallbackFunction );
    topPanelControls.HappinessString:SetToolTipCallback( newCEPtootipFunction );
    allow to hijack the left click and mouse over the happiness string.

    ChangeParent allows to move UI elements from one place to another, regardless of lua context (as long as the context is loaded, don't try it between pre-game and in-game scripts :lol:). Suppose you define a "CEPyieldString" UI control in an InGameUIAddin xml context, you can inject that into the top panel stack like this:
    Code:
    Controls.CEPyieldString:ChangeParent( topPanelControls.TopPanelInfoStack );
    It's a bit more work than simple file change, but greatly improves compatibility and dispenses with any merge work.
     
  9. stackpointer

    stackpointer King

    Joined:
    Mar 3, 2013
    Messages:
    809
    I believe I understand how to use this to add an event to the left click promotion. But for other things, for example, for TechTree.lua, CEP only modifies the function RefreshDisplayOfSpecificTech, specifically the four variables turnText, researchPerTurn, currentResearchProgress, and researchNeeded. Is there any way to do this with the UI controls above?
     
  10. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Working with unnamed instances is quite more difficult.
    I would not recommend doing this but just for coding fun it's possible.
    TechTreeScrollPanel is parent to the all of TechButtonInstance, and the tech ID is stored at initialization by TechTree.lua in the instance's TechButton's Void1.
    So at initialization phase, the InGameUIAddin script (which runs after TechTree.lua) would have to store its own pointers to these instances like TechTree.lua does in techButtons. To do this is a bit hackish:
    Code:
    local techTreeControls = LookUpControl( "/InGame/TechTree" );
    local techButtons = {};
    local function storeButtons( c, ... )
    	-- is child instance c a tech button ?
    	local b = c.TechButton;
    	if b then
    		-- yes it is, store the instance pointer at techID index contained in Void1
    		techButtons[ b:GetVoid1() or -1 ] = c;
    	end
    	-- do once more, SortChildren inputs 2 children at a time
    	if ... then storeButtons( ... ) end
    	-- do not return a result, we don't actually want to sort
    end
    -- feed all of TechTreeScrollPanel's children to storeButtons function:
    techTreeControls.TechTreeScrollPanel:SortChildren( storeButtons );
    
    Then the script has control over techButtons[ techID ] instances.
     
  11. Taa

    Taa Warlord

    Joined:
    Jan 1, 2009
    Messages:
    229
    hmm...would be awesome to use EUI in CEP, but I don't understand much if this...will there be some way for a noob like me to make CEP and EUI work together or is it to early?
     
  12. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Actually it's already possible to make them work together
     
  13. stackpointer

    stackpointer King

    Joined:
    Mar 3, 2013
    Messages:
    809
  14. Bridger

    Bridger Prince

    Joined:
    Nov 10, 2005
    Messages:
    314
    I'm confused, don't EUI and CIN have the same goal? I'd just as soon implement the good features from EUI directly into CIN than try to make them work together. There are bound to be improvements to the interface that CIN makes in the future which will break EUI compatibility?
     
  15. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    "There are many ways to skin a cat!" (apologies to all cat lovers:mischief:)

    The goal of CIN was/is to bring to BNW the interface ideas of GEM that worked so well for G&K.
    EUI is a very slick 'overhaul' of the UI that does some things much better than what was done in GEM.

    My personal opinion is to get EUI & CEP to work together, as I see any work by us to improve the UI as being a poor imitation. Why double up the work when both mods are keen to work together. But as I said, that's just my opinion.

    bc1 has already done a fair bit of investigation and we likewise are seeing where we can make them fit together more easily. At the moment because our custom YieldLibrary provides so much needed info for the rest of our mod, moving it into another table might fix one compatibility problem but break a lot of our functionality.

    bc1, Thalassicus, stackpointer and others assigned to this are very capable coders and I am sure a solution will present itself.
     
  16. junsumoney

    junsumoney Chieftain

    Joined:
    Mar 6, 2014
    Messages:
    18
    I don't understand anything you wrote on how to make the EUI and CEP compatible. I don't get what SQL statement and SELECT * INTO is. Can you explain it for someone who doesn't understand coding?
     
  17. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    This thread is an exchange between coders.

    User instructions are provided in Enhanced User Interface's opening post, in the "Mods compatibility" spoiler.

    Cheers
     
  18. ExpiredReign

    ExpiredReign Deity

    Joined:
    Jan 3, 2013
    Messages:
    2,450
    Gender:
    Male
    Location:
    Tasmania
    The changes added here work as described. From now on the users of both EUI & CEP need not worry about renaming/removing/editing/ or anything else as all that is needed is to have EUI in the DLC folder and CEP installed as a mod.

    The only "issue" is the abnormal figures displayed due to the YieldLibrary.
    This may need a bit more of a think as it is integral to so many of CEP's functions and needs access to the vanilla tables as is.
     
  19. SgtCiv

    SgtCiv Warlord

    Joined:
    Apr 19, 2011
    Messages:
    229
    Location:
    TEXAS
    I noticed something last night using both of these together with no other MODS of any real value running.
    1. I have the techtree and the cityview folders disabled from EUI.
    2. It was close to turn 200 and I was finally ready to start to expand.
    3. I DOW against a rival so a citystate that was allied with them that was close to me would also DOW against me ( I have found that you take less of a hit on diplomacy if you don't actually DOW straight out against citystates).
    4. After taking the citystate I could not remove it from being in a puppeted state and I'm too OCD to not control everything.
     
  20. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,250
    Thought it would be easy (grep). If it's not don't bother, EUI version 1.16 will include a workaround for the broken yield iterator (beta available in EUI thread post #438)
    CEP overrides EUI's CityView which includes an annex button, but it's also possible to annex by clicking on the city banner's puppet icon.
     

Share This Page