Galactic Civilizations IV

Galactic Civilizations IV

View Stats:
Simple Upgrade All Starbase Button?
I am trying to write a simple mod that will add a button to the star bases that will allow you to click it and apply all of the upgrades that you can afford at once. Instead of the spam hell that they are now. I am new to any type of coding or mod writing and I am hoping that someone can help me make this work. If you can that will be great.

"<Mod>
<ModDefs>
<ModDef>
<DisplayName>Upgrade All Starbase Modules</DisplayName>
<Description>Adds an Upgrade All button to the Starbase UI to apply all affordable upgrades.</Description>
<Version>1.0</Version>
<Tags>UI, Starbase, QualityOfLife</Tags>
<Author>YourName</Author>
<TargetType>Game</TargetType>
</ModDef>
</ModDefs>

<UIOverrides>
<UIOverride>
<Target>StarbaseWindow</Target>
<Insert>
<UIElement>
<Type>Button</Type>
<ID>UpgradeAllButton</ID>
<Text>Upgrade All</Text>
<Tooltip>Automatically apply all affordable upgrades to this starbase.</Tooltip>
<OnClick>
<![CDATA[
var upgrades = Starbase.GetAvailableUpgrades();
foreach (var upgrade in upgrades)
{
if (Player.CanAfford(upgrade.Cost))
{
Starbase.ApplyUpgrade(upgrade);
Player.SpendResources(upgrade.Cost);
}
}
]]>
</OnClick>
<Position>Bottom</Position>
<Style>StandardButton</Style>
</UIElement>
</Insert>
</UIOverride>
</UIOverrides>
</Mod>"
< >
Showing 1-2 of 2 comments
Updated coding, and I still do not have a button.
"<Mod>
<ModDefs>
<ModDef>
<DisplayName>Upgrade All Starbase Modules</DisplayName>
<Description>Adds an Upgrade All button to the Starbase UI to apply all affordable upgrades.</Description>
<Version>1.0</Version>
<Tags>UI, Starbase, QualityOfLife</Tags>
<Author>YourName</Author>
<TargetType>Game</TargetType>
<GameObjectType>Starbase</GameObjectType>
</ModDef>
</ModDefs>

<StarbaseTemplates>
<StarbaseTemplate>
<ID>UpgradeAllOverride</ID>
<Name>Upgrade All Override</Name>
<Description>Provides a method to apply all upgrades automatically.</Description>
<TriggerType>OnClick</TriggerType>
<Action>
<![CDATA[
var upgrades = this.GetAvailableUpgrades();
foreach (var upgrade in upgrades)
{
if (Owner.CanAfford(upgrade.Cost))
{
this.ApplyUpgrade(upgrade);
Owner.SpendResources(upgrade.Cost);
}
}
]]>
</Action>
</StarbaseTemplate>
</StarbaseTemplates>
</Mod>"
Draver 30 Jun @ 2:05pm 
Hey, I haven't seen anybody add new UI elements like this that were not already programmed in the back end code so I wouldn't expect this to be possible just with XML modding. If you do figure it out though, please let us know the recipe!
< >
Showing 1-2 of 2 comments
Per page: 1530 50