Dynamic Top Panel

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
Dynamic Top Panel


Download


Dynamic Top Panel is a modder's utility which allows you to hook into the Top Panel and it's tooltips in order to display additional information. Some of my custom civilizations add bonuses that would be better communicated to the player via the Top Panel, and this mod allows you to do just that.

For Users

If you're using EUI, you'll need to disable the Top Panel changes made in order for DTP to take effect. In order to disable the Top Panel, navigate to:
Code:
Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\UI_bc1

and place an underscore ("_") before the 'Top Panel' folder.

If you're using CBP, you'll need the latest version of Piety for compatibility.

For Modders

You'll need to include the JFD_TopPanelUpdated.lua file into your mod and add it as an InGameUIAddin.

Then please refer to this file for specific implementation.
 
Hi JFD,

If you will, could you briefly go into a bit of detail to list/explain what additional information (such as what bonuses, etc) is hooked up into this Lua file?
 
There is no additional information hooked up by default, but you can use the file to hook up, for instance, a new source of Gold Per Turn - such as shown in the screenshot, with regard to the Gold from Trade Routes with puppets. All you need to do is provide a Lua function that'll fill in the value and a text string that'll show it on the tooltip. The file linked above has more specifics, such as what yields are or are not supported for what purpose.
 
So I assume one does not have to change/replace any files if one does already have support for this set up; other than incorporating the JFD_TopPanelUpdated.lua file into one's mod. Correct?
 
Do I need that mod for CBP + Piety + EUI to work correctly?

Any load order? especially if i have other mods which work with top panel (ui- gold alerts)

Edit: I used it and now the Top Panel is all blank
 
Houston, we have a problem!
Code:
[3650.953] Runtime Error: return AW_Harappa_WheeledTransport_GoldYields(Game.GetActivePlayer()):1: attempt to call global 'AW_Harappa_WheeledTransport_GoldYields' (a nil value)
[3651.828] Runtime Error: return AW_Harappa_WheeledTransport_CultureCost(Game.GetActivePlayer()):1: attempt to call global 'AW_Harappa_WheeledTransport_CultureCost' (a nil value)
Taken straight from the lua.log, these errors appear whenever I mouse over the gold or culture part of the top panel, respectively.
What I actually see at that point looks like this:
Spoiler :
When I mouse over the gold section:

And culture section:

This is in a game with an updated version of my Harappan civ that adds E&D support, and one of the decisions, in a nutshell, adds gold and removes culture for a limited number of turns. So, I should see a positive number in the gold section and negative in the culture after enacting the decision, and if I haven't... an extra 0 gold and 0 culture, I guess. Either way, when these screenshots were taken, the decision still wasn't enacted.

The SQL hookup and lua source functions look like this, but I'll also attach the whole mod if it's needed:
Spoiler :
Code:
--^============================================^--
--)-----[ AW's HARAPPAN CIVILIZATION MOD ]-----(--
--V============================================V--
-->----------------> DTP YIELDS <--------------<--

CREATE TABLE IF NOT EXISTS 
    JFD_TopPanelIncludes (
    FileName                text        default null);
INSERT INTO JFD_TopPanelIncludes (FileName) VALUES ('Decisions_Harappa.lua');

CREATE TABLE IF NOT EXISTS 
    JFD_TopPanelAdditions (
    CivilizationType        text        REFERENCES Civilizations(Type)  default null,
    YieldType               text        REFERENCES Yields(Type)         default null,
    YieldSourceFunction     text                                        default null,
    YieldSourceToolTip      text                                        default null,
    MiscToolTipFunction     text                                        default null);
INSERT INTO JFD_TopPanelAdditions
	(CivilizationType,				YieldType,          YieldSourceFunction,    					 YieldSourceToolTip)
VALUES
	('CIVILIZATION_AW_HARAPPAN',	'YIELD_CULTURE',	'AW_Harappa_WheeledTransport_CultureCost',   'TXT_KEY_AW_HARAPPA_WHEELED_TRANSPORT_CULTURE'),
	('CIVILIZATION_AW_HARAPPAN',	'YIELD_GOLD',		'AW_Harappa_WheeledTransport_GoldYields',    'TXT_KEY_AW_HARAPPA_WHEELED_TRANSPORT_GOLD');

INSERT INTO Language_en_US
	(Tag, Text)
VALUES
	('TXT_KEY_AW_HARAPPA_WHEELED_TRANSPORT_CULTURE', '{1_culture} to pay for wheeled transports'),
	('TXT_KEY_AW_HARAPPA_WHEELED_TRANSPORT_GOLD', '{1_gold} from Civilizations without Animal Husbandry/The Wheel');
Code:
function AW_Harappa_WheeledTransport_GoldYields(pPlayer)
	if (load(pPlayer, "Decision_AW_Harappa_WheeledTransport") == false) then return 0 end
	local iYield = 0;
	for playerID, player in pairs(Players) do
	-- by the way, I'm well aware that I could be looping over Teams since techs are shared by teammates.
	-- but you actually make more money this way, so don't knock it!
		if (player ~= pPlayer) then
			local team = Teams[player:GetTeam()]
			if not (team:IsHasTech(GameInfoTypes.TECH_THE_WHEEL)) then iYield = iYield + 1 end
			if not (team:IsHasTech(GameInfoTypes.TECH_ANIMAL_HUSBANDRY)) then iYield = iYield + 1 end
		end
	end
	return iYield
end

function AW_Harappa_WheeledTransport_CultureCost(pPlayer)
	if (load(pPlayer, "Decision_AW_Harappa_WheeledTransport") == false) then return 0 end
	local iCostLater = load(pPlayer, "Decision_AW_Harappa_WheeledTransport_Invoice")
	if (iCostLater > 0) then
		local iCPT = pPlayer:GetTotalJONSCulturePerTurn() -- check function
		if (iCostLater >= iCPT) then
			save(pPlayer, "Decision_AW_Harappa_WheeledTransport_Invoice", iCostLater - iCPT)
			return -iCPT
		else -- if (iCostLater < iCPT) then
			save(pPlayer, "Decision_AW_Harappa_WheeledTransport_Invoice", 0)
			return -(iCPT - iCostLater)
		end
	end
end

Specifically, after enacting the decision, I should be getting +1 GPT per civ w/out The Wheel and +1 GPT per civ w/out Animal Husbandry, and I should be receiving no culture until a 100 culture "debt" has been paid off.

The totality of Dynamic Top Panel support is split among the three files JFD_TopPanelUpdated.lua, Decisions_Harappa.lua and DynamicTopPanel_Harappa.sql in the Compatibility folder.

(This is the mod in question)

I don't know whether this is a problem with JFD_TopPanelUpdated or my hookup code or maybe I even set load attributes incorrectly or something. I was actually getting more errors on a different computer (multi-line errors that showed some kind of traceback to several lines in your file) but they've since disappeared since I moved the mod to another, faster computer for testing. :dunno: I'll leave you to figure it out.

TIA,
AW
 
Well, without E&D active, the Decisions_Harrappa.lua will fail to load, as this calls a custom 'HookDecisionCivilizationIcon' function otherwise absent. The other thing is that AW_Harappa_WheeledTransport_GoldYields and AW_Harappa_WheeledTransport_CultureCost need to be passing the player's ID as a parameter, not the player object as you have it. This is as far as testing has given me, anyway.
 
I had been running E&D and the decisions were showing up fine, but the error about HookDecisionCivilizationIcon remained. :dunno: Anyone's guess, I suppose.

But I hadn't realized that the source function has to pass an ID. Although when I change the parameter to iPlayer and add the line "pPlayer = Players[iPlayer]" as the first line of the function, the errors remain. :/

Also, does the top panel then automatically add the yield, or do I need PlayerDoTurn function to manually add it each turn?
 
Top Bottom