New Player Options do not show up

Cybah

Emperor
Joined
Jun 22, 2007
Messages
1,481
I'm trying to clone the AND player options for my own mod, but they do not get displayed:

attachment.php


XML:

PHP:
	<Define>
		<DefineName>USE_MODDERS_PLAYEROPTION_1</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_MODDERS_PLAYEROPTION_2</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>USE_MODDERS_PLAYEROPTION_3</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>

PHP:
		<PlayerOptionInfo>
			<Type>PLAYEROPTION_MODDER_1</Type>
			<Description>TXT_KEY_PLAYER_OPTION_MODDER_1AFF</Description>
			<Help>TXT_KEY_PLAYER_OPTION_MODDER_1_HELPAFF</Help>
			<bDefault>0</bDefault>
		</PlayerOptionInfo>
		<PlayerOptionInfo>
			<Type>PLAYEROPTION_MODDER_2</Type>
			<Description>TXT_KEY_PLAYER_OPTION_MODDER_2AFF</Description>
			<Help>TXT_KEY_PLAYER_OPTION_MODDER_2_HELPAFF</Help>
			<bDefault>0</bDefault>
		</PlayerOptionInfo>
		<PlayerOptionInfo>
			<Type>PLAYEROPTION_MODDER_3</Type>
			<Description>TXT_KEY_PLAYER_OPTION_MODDER_3</Description>
			<Help>TXT_KEY_PLAYER_OPTION_MODDER_3_HELP</Help>
			<bDefault>0</bDefault>
		</PlayerOptionInfo>


TXT done.

SDK done... already provides PLAYEROPTION_MODDER_1, PLAYEROPTION_MODDER_2, PLAYEROPTION_MODDER_3

PHP:
	python::enum_<PlayerOptionTypes>("PlayerOptionTypes")
		.value("NO_PLAYEROPTION", NO_PLAYEROPTION)
		.value("PLAYEROPTION_ADVISOR_POPUPS", PLAYEROPTION_ADVISOR_POPUPS)
		.value("PLAYEROPTION_ADVISOR_HELP", PLAYEROPTION_ADVISOR_HELP)
		.value("PLAYEROPTION_WAIT_END_TURN", PLAYEROPTION_WAIT_END_TURN)
		.value("PLAYEROPTION_MINIMIZE_POP_UPS", PLAYEROPTION_MINIMIZE_POP_UPS)
		.value("PLAYEROPTION_SHOW_FRIENDLY_MOVES", PLAYEROPTION_SHOW_FRIENDLY_MOVES)
		.value("PLAYEROPTION_SHOW_ENEMY_MOVES", PLAYEROPTION_SHOW_ENEMY_MOVES)
		.value("PLAYEROPTION_QUICK_MOVES", PLAYEROPTION_QUICK_MOVES)
		.value("PLAYEROPTION_QUICK_ATTACK", PLAYEROPTION_QUICK_ATTACK)
		.value("PLAYEROPTION_QUICK_DEFENSE", PLAYEROPTION_QUICK_DEFENSE)
		.value("PLAYEROPTION_STACK_ATTACK", PLAYEROPTION_STACK_ATTACK)
		.value("PLAYEROPTION_AUTO_PROMOTION", PLAYEROPTION_AUTO_PROMOTION)
		.value("PLAYEROPTION_START_AUTOMATED", PLAYEROPTION_START_AUTOMATED)
		.value("PLAYEROPTION_SAFE_AUTOMATION", PLAYEROPTION_SAFE_AUTOMATION)
		.value("PLAYEROPTION_NUMPAD_HELP", PLAYEROPTION_NUMPAD_HELP)
		.value("PLAYEROPTION_NO_UNIT_CYCLING", PLAYEROPTION_NO_UNIT_CYCLING)
		.value("PLAYEROPTION_NO_UNIT_RECOMMENDATIONS", PLAYEROPTION_NO_UNIT_RECOMMENDATIONS)
		.value("PLAYEROPTION_RIGHT_CLICK_MENU", PLAYEROPTION_RIGHT_CLICK_MENU)
		.value("PLAYEROPTION_LEAVE_FORESTS", PLAYEROPTION_LEAVE_FORESTS)
		.value("PLAYEROPTION_MISSIONARIES_AUTOMATED", PLAYEROPTION_MISSIONARIES_AUTOMATED)
		.value("PLAYEROPTION_MODDER_1", PLAYEROPTION_MODDER_1)
		.value("PLAYEROPTION_MODDER_2", PLAYEROPTION_MODDER_2)
		.value("PLAYEROPTION_MODDER_3", PLAYEROPTION_MODDER_3)
		.value("NUM_PLAYEROPTION_TYPES", NUM_PLAYEROPTION_TYPES)
		;

PHP:
enum PlayerOptionTypes			// Exposed to Python
{
	NO_PLAYEROPTION = -1,

	PLAYEROPTION_ADVISOR_POPUPS,
	PLAYEROPTION_ADVISOR_HELP,
	PLAYEROPTION_WAIT_END_TURN,
	PLAYEROPTION_MINIMIZE_POP_UPS,
	PLAYEROPTION_SHOW_FRIENDLY_MOVES,
	PLAYEROPTION_SHOW_ENEMY_MOVES,
	PLAYEROPTION_QUICK_MOVES,
	PLAYEROPTION_QUICK_ATTACK,
	PLAYEROPTION_QUICK_DEFENSE,
	PLAYEROPTION_STACK_ATTACK,
	PLAYEROPTION_AUTO_PROMOTION,
	PLAYEROPTION_START_AUTOMATED,
	PLAYEROPTION_SAFE_AUTOMATION,
	PLAYEROPTION_NUMPAD_HELP,
	PLAYEROPTION_NO_UNIT_CYCLING,
	PLAYEROPTION_NO_UNIT_RECOMMENDATIONS,
	PLAYEROPTION_RIGHT_CLICK_MENU,
	PLAYEROPTION_LEAVE_FORESTS,
	PLAYEROPTION_MISSIONARIES_AUTOMATED,
	PLAYEROPTION_MODDER_1,
	PLAYEROPTION_MODDER_2,
	PLAYEROPTION_MODDER_3,


but their iDefineIntVal is 0 by default (that's changed to 1, look above).


I don't get it.
 
nevermind. I've deleted A_New_Dawn_GlobalDefines.xml and updated iDefineIntVal in the original globaldefines to 1. now they show up. did not know its important where these entries are.
 
This is a good thread. I am trying to add a playeroption for my Great General Progress Bar. I've add the parts to 2sdk files as shown and the xml. However, my playeroption only appears in python so I am unsure of how to code it. I added a code and received no python errors, but the Bar does not show up.

Spoiler :
Code:
if ( gc.getGame().isOption(PlayerOptionTypes.PLAYEROPTION_GGPROGRESSBAR) == true ):
			screen.addStackedBarGFC( "GreatGeneralBar", 323 + (
Spoiler :
Code:
(xResolution - 1024) / 2 ), 30, 115, iStackBarHeight, InfoBarTypes.NUM_INFOBAR_TYPES, WidgetTypes.WIDGET_HELP_GREAT_GENERAL, -1, -1 )
			screen.setStackedBarColors( "GreatGeneralBar", InfoBarTypes.INFOBAR_STORED, gc.getInfoTypeForString("COLOR_NEGATIVE_RATE") )
			screen.setStackedBarColors( "GreatGeneralBar", InfoBarTypes.INFOBAR_RATE, gc.getInfoTypeForString("COLOR_EMPTY") )
			screen.setStackedBarColors( "GreatGeneralBar", InfoBarTypes.INFOBAR_RATE_EXTRA, gc.getInfoTypeForString("COLOR_EMPTY") )
			screen.setStackedBarColors( "GreatGeneralBar", InfoBarTypes.INFOBAR_EMPTY, gc.getInfoTypeForString("COLOR_EMPTY") )
			screen.hide( "GreatGeneralBar" )

Spoiler :
Code:
def updateGameDataStrings( self ):
	
		screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )

		screen.hide( "ResearchText" )
		screen.hide( "GoldText" )
		screen.hide( "TimeText" )
############################################################
# 				PAE - Great General Bar - start
############################################################
		screen.hide( "GreatGeneralBar" )
		screen.hide( "GreatGeneralBarText" )
		screen.hide( "GreatGeneralBarIcon" )
############################################################
# 				PAE - Great General Bar - end
############################################################

Spoiler :
Code:
elif (gc.getPlayer(ePlayer).getCurrentResearch() != -1):

					szText = CyGameTextMgr().getResearchStr(ePlayer)
					screen.setText( "ResearchText", "Background", szText, CvUtil.FONT_CENTER_JUSTIFY, screen.centerX(512), 3, -0.4, FontTypes.GAME_FONT, WidgetTypes.WIDGET_RESEARCH, -1, -1 )
					screen.show( "ResearchText" )

					researchProgress = gc.getTeam(gc.getPlayer(ePlayer).getTeam()).getResearchProgress(gc.getPlayer(ePlayer).getCurrentResearch())
					overflowResearch = (gc.getPlayer(ePlayer).getOverflowResearch() * gc.getPlayer(ePlayer).calculateResearchModifier(gc.getPlayer(ePlayer).getCurrentResearch()))/100
					researchCost = gc.getTeam(gc.getPlayer(ePlayer).getTeam()).getResearchCost(gc.getPlayer(ePlayer).getCurrentResearch())
					researchRate = gc.getPlayer(ePlayer).calculateResearchRate(-1)
					
					screen.setBarPercentage( "ResearchBar", InfoBarTypes.INFOBAR_STORED, float(researchProgress + overflowResearch) / researchCost )
					if ( researchCost >  researchProgress + overflowResearch):
						screen.setBarPercentage( "ResearchBar", InfoBarTypes.INFOBAR_RATE, float(researchRate) / (researchCost - researchProgress - overflowResearch))
					else:
						screen.setBarPercentage( "ResearchBar", InfoBarTypes.INFOBAR_RATE, 0.0 )

					screen.show( "ResearchBar" )
############################################################					
					# PAE - Great General Bar/Great Person Bar - start
					self.updateGreatGeneralBar(screen)
					# PAE - Great Bars - end
############################################################

Spoiler :
Code:
def updateGreatGeneralBar(self, screen):
		if ( gc.getGame().isOption(PlayerOptionTypes.PLAYEROPTION_GGPROGRESSBAR) == true ):
			if not CyInterface().isCityScreenUp():
				pPlayer = gc.getActivePlayer()
				iCombatExp = pPlayer.getCombatExperience()
				iThresholdExp = pPlayer.greatPeopleThreshold(True)
				szText = u"<font=2>" + localText.getText("TXT_NEXT_GG_EXPERIENCE", (iCombatExp, iThresholdExp)) + u"</font>"

				szGreatGeneralBar = "GreatGeneralBar"

				xResolution = screen.getXResolution()
				if (xResolution >= 1440): yCoord = 7
				else: yCoord = 35

							
				
				# General Bar ist bei X = 278 / B = 120
				iGeneralIcon = gc.getInfoTypeForString("ART_DEF_UNIT_WARLORD_ANCIENT") 
						
				screen.setImageButton( "GreatGeneralBarIcon", ArtFileMgr.getUnitArtInfo("ART_DEF_UNIT_WARLORD_ANCIENT").getButton(), 323, yCoord - 3, 24, 24, WidgetTypes.WIDGET_HELP_GREAT_GENERAL, -1, -1 )
				screen.show( "GreatGeneralBarIcon" )
				screen.setLabel( "GreatGeneralBarText", "Background", szText, CvUtil.FONT_CENTER_JUSTIFY, 374, yCoord, -0.4, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_GREAT_GENERAL, -1, -1 )
				screen.show( "GreatGeneralBarText" )

				fProgress = float(iCombatExp) / float(iThresholdExp)

				screen.setBarPercentage( szGreatGeneralBar, InfoBarTypes.INFOBAR_STORED, fProgress )
				screen.show( szGreatGeneralBar )
 
Back
Top Bottom