[UI]DiploWillard - Easier City-States management from one window

Great stuff Onni,
Noticed an issue last night, not sure if it's related to a conflict or not and would like your input.

I've only met three city-states but the app shows that they're all at war. I assume with me?
Spoiler :
- Met Tikol first, and everything looked fine in the DiploWillard
- Went to war with Monty and the Aztecs, they were not allied with any city-states
- Met the other two city-states
- Bought Tikol's alliance to help me finish off Monty. (You can see that they are allied and generating culture for me)
- Destroyed the Aztecs
- Noticed that all city-states showed they were at war

This is the default Diplomacy window (Rio wants me to war with Cuzco, Tikol wants a great Artist)
Spoiler :
After these images were taken I progressed a little further, I am now allied with Cuzco as well but the DiploWillard screen still shows them all at WAR.
Haven't met another city-state as of yet, but I'll report back when I do (playing TSL and am stuck in the Americas)

Here's a list of all active mods for my current game;
Note: I'm running Shigg's Earth and not the Tectonics map-script
Spoiler :
 
This should fix all the problems with the War Color:
Open DiploWillardData.lua, very first function, GG.GetMinorCivData, replace the line

_T[iMinorCiv].atWar = _PlayerTeam:IsAtWar(iOtherTeam)

with:
_T[iMinorCiv].atWar = _PlayerTeam:IsAtWar(iMinorCiv)


IOtherTeam is an undefined local variable. When GG.GetColor() decides which color to display, 'atwar' is checked first, and because it's passing in an undefined value, the result could be almost anything. Because it's checked first, it can color all the city states incorrectly.

It fixed the one problem I have saved, at least.
 
Thanks for the quick reply Perkus,

That did the trick, DiploWillards looking great :)
 
Bug report: The military city-state can not show the correct number of turns until the next unit which gives to you. I'm not sure this bug whether occurs or not when the city-state is your ally.
 
@lichen8566:
I believe the tooltip on that column already acknowledges that, it's 1-3 turns off, because it's impossible to calculate exactly given the info provided, which strips off fractions of turns that are used internally in calculations. Or that's how I understood it.

@Onni:
Could you add a way of listing the disposition (hostile/friendly/neutral) of each city-state? I consider this fairly essential info in deciding which ones to invest money in. I realize it's reflected to some extent in the decay rate shown, but it should be there, really.
 
Version 4.0 is now available.
V4.0
  • fixed smoother window and button positioning
  • fixed window and button reset not saving bug
  • fixed wrong color for enemy City-states bug
  • fixed visible DiploWillard version number on the window

I not mean that the add/subtract values are too small, I mean you use the wrong sign operator. In your original code, you add 10 at the begining of draging, and subtract 10 at the end. Did you notice that every time you drag the window, the had window been put 20 pixels far from the cursor pos.
I found a solution to get rid of this whole offset thing. Now those windows and buttons should place at the exact position where you place them.

This should fix all the problems with the War Color:
Open DiploWillardData.lua, very first function, GG.GetMinorCivData, replace the line

_T[iMinorCiv].atWar = _PlayerTeam:IsAtWar(iOtherTeam)

with:
_T[iMinorCiv].atWar = _PlayerTeam:IsAtWar(iMinorCiv)


IOtherTeam is an undefined local variable. When GG.GetColor() decides which color to display, 'atwar' is checked first, and because it's passing in an undefined value, the result could be almost anything. Because it's checked first, it can color all the city states incorrectly.

It fixed the one problem I have saved, at least.
Thanks Perkus! This did indeed fix those problems.

Bug report: The military city-state can not show the correct number of turns until the next unit which gives to you. I'm not sure this bug whether occurs or not when the city-state is your ally.
The game API only gives a fixed number on how many turns there are between military unit gifts. It doesn't tell when the next gift is due. Of course this could be calculated, but I've no plans to implement this, because it would require major work on the saving functionality.

@Onni:
Could you add a way of listing the disposition (hostile/friendly/neutral) of each city-state? I consider this fairly essential info in deciding which ones to invest money in. I realize it's reflected to some extent in the decay rate shown, but it should be there, really.
Maybe I'll look into this in the future?
 
Sort order is wrong. Science column sort 10 before 9.

Button is still wrong type for main screen. The button you used is only used at top of civilopedia, and then not as button but more like a tab, where change of position makes sense as indicator of what page you read in the civilopedia. The main screen has a different type of buttons, all behaving like buttons do in other software. Your button stand out in a bad way. If you do not want change it, at least please post here how we can get rid of it manually.
 
Sort order is wrong. Science column sort 10 before 9.

Button is still wrong type for main screen. The button you used is only used at top of civilopedia, and then not as button but more like a tab, where change of position makes sense as indicator of what page you read in the civilopedia. The main screen has a different type of buttons, all behaving like buttons do in other software. Your button stand out in a bad way. If you do not want change it, at least please post here how we can get rid of it manually.

Thanks I'll fix the science column in the future.

You can change the button icon by modifying this bolded value in DiploWillard.xml:
Code:
<!-- Button to open/close the main window -->
<Button ID="MainButton" Anchor="C,B" Size="49,50" Offset="200,0" Texture="[B][COLOR="Red"]CivilopediaTopButtonsCities.dds[/COLOR][/B]"  ToolTip="City-StatesList">
	<Label ID="ButtonText" Hidden="0" Anchor="C,C" Offset="0,4" Font="TwCenMT20" FontStyle="Stroke"/>
</Button>
 
Thanks for the suggestions, but the window positions are also one of those things that everybody have their own preferences. That's why everybody can now position them how ever they like.

I made a compromise with the +10 offset (instead of +1) when moving those windows. +1 required you to be absolutely still when you pressed that mouse button and that lead to too many "miss-clicks". If there only were a simple command to make that main window [ConsumeMouse="0"] it would have made that solution much easier? :confused:

Onni,

Is there a way to call up (via LUA) the influence totals of a rival civ, or is that information locked out by default? I'd like to add a LUA script to my mod showing a player the influence of a rival civ in a CS so they can know if they should send a diplo unit or not.

Thanks!
G
 
Onni,

Is there a way to call up (via LUA) the influence totals of a rival civ, or is that information locked out by default? I'd like to add a LUA script to my mod showing a player the influence of a rival civ in a CS so they can know if they should send a diplo unit or not.

Thanks!
G
You can do that with this command:
Code:
Players[iMinorCiv]:GetMinorCivFriendshipWithMajor(iMajorCiv)
eg. Players[22]:GetMinorCivFriendshipWithMajor(2)

My desing principle is to only show information that you could get from the vanilla Civ, so that there is no "cheating". But here's something that you might find helpful while your debugging your own mod. Warning: This code enables you to see all Major civilization information towards City-states and is thus cheating. So use it in your own discretion.
Spoiler :
In file DiploWillardData.lua replace the GG.GetMinorCivData - function with this one:
Code:
function GG.GetMinorCivData()
--keynameTooltip -> automatic tooltip for keyname
--keynameSort -> this key will be used in sorting instead of keyname
	local _T = {}

	for iMajorCiv = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
	local _majorId = iMajorCiv
	local _Player = Players[ _majorId ]
	local _playerTeamId = _Player:GetTeam()
	local _PlayerTeam = Teams[_playerTeamId];

	for iMinorCiv = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
		local idMinMaj = iMinorCiv.."_"..iMajorCiv
		local minorCivData = {}
		local _MinorCiv = Players[iMinorCiv]
		local _MinorCivTeamId = _MinorCiv:GetTeam()
		if( _MinorCiv:IsMinorCiv()
		and _playerTeamId ~= _MinorCivTeamId
		and _PlayerTeam:IsHasMet( _MinorCivTeamId )
		and _MinorCiv:IsAlive() ) then
			_T[idMinMaj] = {}
			_T[idMinMaj].majorName = Locale.ConvertTextKey(_Player:GetCivilizationShortDescriptionKey())
			_T[idMinMaj].id = _MinorCiv:GetMinorCivType()
			_T[idMinMaj].atWar = _PlayerTeam:IsAtWar(iMinorCiv)
			_T[idMinMaj].infValue = _MinorCiv:GetMinorCivFriendshipWithMajor(_majorId)
			_T[idMinMaj].infLevel = _MinorCiv:GetMinorCivFriendshipLevelWithMajor(_majorId)
			_T[idMinMaj].infChange  = GG.DoPercent(_MinorCiv:GetFriendshipChangePerTurnTimes100(_majorId), 100)
			_T[idMinMaj].infTurns  = GG.GetTurnsForStatus(_T[idMinMaj].infValue, _T[idMinMaj].infChange, _T[idMinMaj].atWar)
			_T[idMinMaj].bonusCult = _MinorCiv:GetCurrentCultureBonus(_majorId)
			_T[idMinMaj].bonusScie = GG.DoPercent(_MinorCiv:GetCurrentScienceFriendshipBonusTimes100(_majorId), 100)
			_T[idMinMaj].bonusFood = _MinorCiv:GetCurrentOtherCityFoodBonus(_majorId)
			_T[idMinMaj].bonusMili = _MinorCiv:GetCurrentSpawnEstimate(_majorId)
			_T[idMinMaj].bonusAll = GG.GetBonusAll(_T[idMinMaj].bonusCult, _T[idMinMaj].bonusFood, _T[idMinMaj].bonusMili)
			_T[idMinMaj].quest = _MinorCiv:GetActiveQuestForPlayer(_majorId)
			_T[idMinMaj].questData1 = _MinorCiv:GetQuestData1(_majorId)
			_T[idMinMaj].questData2 = _MinorCiv:GetQuestData2(_majorId)
			_T[idMinMaj].ally = GG.GetAlly(_MinorCiv)
			_T[idMinMaj].protected = GG.GetProtected(iMinorCiv, _PlayerTeam)
			_T[idMinMaj].personality = GG.GetPersonality(_MinorCiv:GetPersonality(), 1)
			_T[idMinMaj].personalityTooltip = GG.GetPersonality(_MinorCiv:GetPersonality(), 2)
			_T[idMinMaj].resources,
			_T[idMinMaj].resourcesTooltip = GG.GetResources(_MinorCiv, iMinorCiv)
			_T[idMinMaj].capital = _MinorCiv:GetCapitalCity()
			_T[idMinMaj].color,
			_T[idMinMaj].color2 = GG.GetColor(_T[idMinMaj].atWar, _T[idMinMaj].infLevel)
			_T[idMinMaj].name,
			_T[idMinMaj].nameSort = GG.GetName(_T[idMinMaj].id, _T[idMinMaj].atWar, _T[idMinMaj].color)
			_T[idMinMaj].trait = _MinorCiv:GetMinorCivTrait()
			_T[idMinMaj].traitTooltip = GG.GetTraitTooltip(_T[idMinMaj].trait)
			_T[idMinMaj].traitIcon = GG.GetTraitIcon(_T[idMinMaj].trait, _T[idMinMaj].color)
		end --if( _MinorCiv:IsMinorCiv() and 
	end --for iMinorCiv = 
	end --for iMajorCiv = 0
	return _T
end
And in DiploWillardPara.lua file add this row to the GG.CreateMinorCivSettings - function:
Code:
	table.insert(_T, {l="[ICON_FOOD][ICON_CULTURE][ICON_WAR] / All bonuses", h="[ICON_FOOD][ICON_CULTURE][ICON_WAR]", tt="Food, culture or military bonus", "bonusAll", 80, "MinorCivColInstance"})
--NEW CODE BEGIN
	table.insert(_T, {l="MajorName", h="MajorName", tt="Major name", "majorName", 120, "MinorCivColInstanceL"})
--NEW CODE END
--	table.insert(_T, {l="", h="", tt="", "", 50, "MinorCivColInstance"})
After these changes you should add (in the actual game) the new "MajorName" column to see which major civilization information you are looking at.;)
 
@Onni:
Could you add a way of listing the disposition (hostile/friendly/neutral) of each city-state? I consider this fairly essential info in deciding which ones to invest money in. I realize it's reflected to some extent in the decay rate shown, but it should be there, really.
I couldn't find this disposition info for City-states. Not sure if there is such thing for them? I know that their personality effects the decay rate. And if you declare wars too much for the City-states then all of their decay rates are effected. So no such stat coming...unless somebody finds a way to prove that there is a disposition for City-states? :confused:
 
It's shown every time you click on a minor civ city banner. I guess the game calls it "personality." Is it not simply this here? (From CityStateDiploPopup.lua):

PHP:
	local iPersonality = pPlayer:GetPersonality();
	if (iPersonality == MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_FRIENDLY) 
etc.
 
It's shown every time you click on a minor civ city banner. I guess the game calls it "personality." Is it not simply this here? (From CityStateDiploPopup.lua):

PHP:
	local iPersonality = pPlayer:GetPersonality();
	if (iPersonality == MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_FRIENDLY) 
etc.
If it's that then you can already find it from the mod.
 
Version 5.0 is now available.

  • added better options statistic selection dropdowns
  • added right clicking name centers the view to the city-state
  • added option to use mini-skin
  • added configurable big tooltip
  • added ability to create and rename views
  • added all options are saved individually for every view
  • added right clicking the main button opens options
  • added shorter names for city-states
  • fixed decimal number sorting
  • fixed better window positioning
  • fixed scrollbar not always showing
One thing that really bugged me was that you couldn't center your view on the City-states (unless you had notification for that City-state). I always had to go manually look for them. Now you do this by right clicking the City-state name.

I also tried to improve the options pages statistics selection by creating a new dropdown. Here are couple of it's undocumented functions:
  • left click old stat twice to insert a new empty row
  • right click old stat twice to delete a row
  • left click a new stat in the dropdown to overwrite the current stat
  • right click a new stat in the dropdown to insert a new stat
 
I've now also added a cheat version of DiploWillard. I didn't upload it to the ModHub, but only to this threads OP. That mod is otherwise exactly the same as DiploWillard except that you can see all Major civilization relationships towards City-states. I hope this will have some value to at least other modders.

 

Attachments

  • DiploWillardCheat.jpg
    DiploWillardCheat.jpg
    34.3 KB · Views: 279
I've now also added a cheat version of DiploWillard. I didn't upload it to the ModHub, but only to this threads OP. That mod is otherwise exactly the same as DiploWillard except that you can see all Major civilization relationships towards City-states. I hope this will have some value to at least other modders.


Onni,
You're awesome. I've been putting off adding in the code you told me about last week- this is exactly what I need for CSD testing.
 
Nice, the miniskin for the city states. I noticed you used the CityWillard as a baseline, which had the unfortunate effect that the small button is now overlapping the CityWillard button. Also, the tab says "Cities" in stead of City states. :p
But with the movable button it is no problem, maybe confusing at first.
 
Top Bottom