Utils - Modular Summary Bar

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,699
Location
Near Portsmouth, UK
Provides a summary bar in the top panel (to the left of the turn/help/menu items) that permits entries to be added in a modular fashion.



Entries may be "minimised" by right-clicking on them

Uses the techniques found in Utils - Modular DiploCorner, so an understanding of how that works is an advantage to using the components in this mod.

The following LuaEvent is supported

* LuaEvents.SummaryBarAddin.Add(function OnSummaryBarAddin(tab) ... end)

adds a new tab to the Summary Bar
tab is an associative array with the following entries

  • id - the string that uniquely identifies the tab
  • text - the string (or TXT_KEY_) or a function returning a string to display in the summary bar
  • tip - the string (or TXT_KEY_) or a function returning a string to display when the mouse is over the tab
  • short - (optional) the string (or TXT_KEY_) to display when the tab is "minimised"
  • small - (optional) true to default to the short text
  • click - (optional) function to call when the tab is clicked (there is no default click action)
  • rclick - (optional) function to call when the tab is right-clicked (the default right-click action is to switch between minimised and normal mode)
  • priority - (optional) integer determining placement, 1 is right-most (priorities 1 thru 10 are reserved)
  • callback - (optional) function that is called when the tab is created

The click and rclick functions receive two parameters
  • iButtonOffsetX - being the left-hand edge of the control
  • button - being the actual control

The callback function receives one parameter
  • button - being the actual control

The following use the components of this mod

  • UI - Summary City States - basic example showing the number of City States met and/or conquered
  • UI - Summary Barbarians - basic example showing the number of known barbarian camps and units
  • UI - Summary Specialists - basic example showing progress towards Great People
  • UI - Summary Luxuries - intermediate example showing the number of luxuries available, either locally or by trade
  • UI - Summary Shipping - intermediate example showing ship tonnage for each maritime civilization, with a popup options menu
  • UI - Summary Clock - intermediate example showing a Clock - illustrates how to receive the created control into your own mod
 
Example of how to use the components of this mod in your own mod ...

Create a new project
Assuming this will be a self-contained, standalone mod, uncheck the "Affects Saved Games" option

NOTE: All occurances of {ModName} or {MODNAME} MUST be replaced with the name of your mod EXCLUDING SPACES AND PUNCUTATION, eg, for a mod called "UI - Summary City States" use "UISummaryCityStates"

NOTE: All occurances of {Summaryid} or {SUMMARYID} MUST be replaced with the unique identifier of your mod, and must not contain spaces or puncutation

Add an XML folder and create a new XML item called "{ModName}Text.xml" (where "{ModName}" is the name of your mod!)
Add an "OnModActivated->UpdateDatabase" action for this file
The basic contents of this file is just

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<Language_en_US>
		<Row Tag="TXT_KEY_{SUMMARYID}_LIST">
			<Text>My Summary</Text>
		</Row>
		<Row Tag="TXT_KEY_{SUMMARYID}_LIST_SHORT">
			<Text>Mine!</Text>
		</Row>
	</Language_en_US>
</GameData>
(where "{SUMMARYID}" is the unique identifier for your mod and "My Summary" and "Mine!" are relevant to your mod!)

Add a UI/InGame folder
Add the SummaryBar lua and xml files to this folder
From the "Content" tab, add an "InGameUIAddin" entry for this file

Under the UI folder create a new LUA item called "{ModName}_SummaryBarHook.lua" (where "{ModName}" is the name of your mod!)
Set "Import into VFS" to true for this file
From the "Content" tab, add a "SummaryBarAddin" entry for this file
The contents of this file is just

Code:
function OnGetTooltipHook(iPlayer)
  local retVal = {}
  LuaEvents.Summary{Summaryid}GetTooltip(iPlayer, retVal) 
  return retVal.text
end

LuaEvents.SummaryBarAddin({
  id="{Summaryid}",
  text="TXT_KEY_{SUMMARYID}_LIST",
  short="TXT_KEY_{SUMMARYID}_LIST_SHORT",
  tip=OnGetTooltipHook,
})
Under the UI folder create a new XML item called "{ModName}.xml" (where "{ModName}" is the name of your mod!)
Set "Import into VFS" to true for this file
From the "Content" tab, add an "InGameUIAddin" entry for this file
The contents of this file is just

Code:
  <?xml version="1.0" encoding="utf-8" ?>
  <Context Name="{ModName}" Hidden="1" />
Under the UI folder create a new LUA item called "{ModName}.lua" (where "{ModName}" is the name of your mod!)
Set "Import into VFS" to true for this file
The (basic) contents of this file is just

Code:
function get{Summaryid}Text(iActivePlayer)
  local sText = ""

  -- Do something useful

  return sText
end

function OnSummary{Summaryid}GetTooltip(iPlayer, retVal)
  retVal.text = get{Summaryid}Text(iPlayer)
end
LuaEvents.Summary{Summaryid}GetTooltip.Add(OnSummary{Summaryid}GetTooltip)

The main ModBuddy screen will look similiar to


The Actions tab will look similiar to


The Content tab will look similiar to


Save and build your mod

The .modinfo file will be similiar to

Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="41ebe497-0b2a-410a-a28d-e5a50be01c8f" version="1">
  <Properties>
    <Name>UI - Summary City States</Name>
    <Teaser>Displays a summary for the City States as a tooltip in the Top Panel</Teaser>
    <Description>Displays a summary for the City States as a tooltip in the Top Panel

An example of how to use the Modular Summary Bar</Description>
    <Authors>William Howard</Authors>
    <HideSetupGame>0</HideSetupGame>
    <AffectsSavedGames>0</AffectsSavedGames>
    <SupportsSinglePlayer>1</SupportsSinglePlayer>
    <SupportsMultiplayer>1</SupportsMultiplayer>
    <SupportsHotSeat>0</SupportsHotSeat>
    <SupportsMac>1</SupportsMac>
    <ReloadLandmarkSystem>0</ReloadLandmarkSystem>
    <ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
    <ReloadUnitSystem>0</ReloadUnitSystem>
  </Properties>
  <Dependencies />
  <References />
  <Blocks />
  <Files>
    <File md5="C256153CF8F3123080F3340820F46464" import="0">UI/InGame/SummaryBar.lua</File>
    <File md5="942ABCA2375758A4CDBF47D59972B90E" import="0">UI/InGame/SummaryBar.xml</File>
    <File md5="ACFFF873264459EF154BA4C62BC028E7" import="1">UI/SummaryCityStates.lua</File>
    <File md5="5C2DD3C59AA0D72DB3DFD639031B4B9B" import="1">UI/SummaryCityStates.xml</File>
    <File md5="3ADFC81F688EC8CBDBCE107117916D51" import="1">UI/SummaryCityStates_SummaryBarHook.lua</File>
    <File md5="9E98C6EE1BE65957BF037FEB2495786C" import="0">XML/UISummaryCityStates.xml</File>
  </Files>
  <Actions>
    <OnModActivated>
      <UpdateDatabase>XML/UISummaryCityStates.xml</UpdateDatabase>
    </OnModActivated>
  </Actions>
  <EntryPoints>
    <EntryPoint type="InGameUIAddin" file="UI/InGame/SummaryBar.xml">
      <Name>Summary Bar</Name>
      <Description>
      </Description>
    </EntryPoint>
    <EntryPoint type="SummaryBarAddin" file="UI/SummaryCityStates_SummaryBarHook.lua">
      <Name>City States Summary Bar Hook</Name>
      <Description>
      </Description>
    </EntryPoint>
    <EntryPoint type="InGameUIAddin" file="UI/SummaryCityStates.xml">
      <Name>Summary City States</Name>
      <Description>
      </Description>
    </EntryPoint>
  </EntryPoints>
</Mod>
The mod "UI - Summary City States" can be downloaded as a working example
 
Sorry for necrobump.

I'm using this Util with 2 Summary Bar Tabs as well as a custom TopPanel.lua, and there's overlap between a Summary Tab and the Turn count. I think this may be due to a custom clock. How can I shift the whole Summary business over to the left?

Edit: Never mind, I found it. Sorry for necrobump and pointless question.
 
Me again. How can I make it so that clicking on a summary bar component pops up a window? .RegisterCallBack doesn't work (according to Modiki there is no LuaEvents.RegisterCallback).
 
See Summary Clock - if you click on the time it will pop-up a dialog that allows you to change 12/24 hour mode and display am/pm for 12 hour mode
 
See Summary Clock - if you click on the time it will pop-up a dialog that allows you to change 12/24 hour mode and display am/pm for 12 hour mode

Thanks for the info. I was only using Summary GP and Luxuries, which don't have a pop up.

Also, with mods my game has 23 luxury resources, but summary luxuries does not display them all, (only displays 17 luxuries, if I remember correctly) do you know why/how can I figure out what is keeping it from displaying all of them?
 
Summary luxuries will only display those that are actually on the map
 
I got fed up with scouring the map (especially large and huge ones) looking for luxuries that didn't exist :)
 
Hi. Sorry for the necro, but i see this mod is now in the "obsolete" section on your site, even thought it's still the base for recent mods (such as the antiquity summary). Why was it obsoleted? Is it still possible to use it with BNW?

BTW, same is true for all your "modular" utilities mods.
 
The code/files in all the "Utils" mods are used in other of my mods. I just don't have the time to keep them all in sync with the hotfixes/patches any more, so have dropped all the "Utils" mods in favour of updating the "real" mods, as anyone needing the code can just get it from the "real" mods that have those files in (hope that makes sense)

W
 
Top Bottom