UIElement.RegisterSelectionCallback (Civ5 API)

From Civilization Modding Wiki
Revision as of 14:39, 20 September 2012 by DonQuich (talk | contribs) (Bot update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of ControlBase.

This is an instance method, invoke it with a colon.


Usage

void UIElement:RegisterSelectionCallback((void func(FaithPurchaseType v1, int v2)) OnChatTarget)


Parameters

OnChatTarget: No description available.


Source code samples

Too many occurences. Only 50 out of 65 are listed.

AdvancedSetup.lua

UI/FrontEnd/GameSetup/AdvancedSetup.lua
0436
pullDown:RegisterSelectionCallback(function(playerID, id)
0437
local civID = playableCivs[id] and playableCivs[id].CivID or -1;
0439
PreGame.SetCivilization( playerID, civID);
0440
PerformPartialSync();
0441
end);
0488
pullDown:RegisterSelectionCallback( function(id)
0489
local era = GameInfo.Eras[id];
0490
PreGame.SetEra( id );
0491
pullDown:GetButton():LocalizeAndSetText(era.Description);
0492
PerformPartialSync();
0493
end);
0527
pullDown:RegisterSelectionCallback( function(id)
0528
PreGame.SetGameSpeed( id );
0529
local gameSpeed = GameInfo.GameSpeeds[id];
0530
pullDown:GetButton():LocalizeAndSetText(gameSpeed.Description);
0531
pullDown:GetButton():SetToolTipString( Locale.ConvertTextKey( gameSpeed.Help ) );
0532
PerformPartialSync();
0533
end);
0561
pullDown:RegisterSelectionCallback(function(id)
0562
local handicap = GameInfo.HandicapInfos[id];
0563
PreGame.SetHandicap( 0, id );
0564
pullDown:GetButton():LocalizeAndSetText(handicap.Description);
0565
pullDown:GetButton():LocalizeAndSetToolTip(handicap.Help);
0567
PerformPartialSync();
0568
end);
0601
pullDown:RegisterSelectionCallback( function(id)
0602
if( id == -1 ) then
0603
PreGame.SetRandomWorldSize( true );
0604
pullDown:GetButton():LocalizeAndSetText("TXT_KEY_RANDOM_MAP_SIZE");
0605
pullDown:GetButton():LocalizeAndSetToolTip("TXT_KEY_RANDOM_MAP_SIZE_HELP");
0606
else
0607
local mapSize = GameInfo.Worlds[id];
0609
PreGame.SetRandomWorldSize( false );
0610
PreGame.SetWorldSize( id );
0611
PreGame.SetNumMinorCivs( mapSize.DefaultMinorCivs );
0612
pullDown:GetButton():LocalizeAndSetText(mapSize.Description);
0613
pullDown:GetButton():LocalizeAndSetToolTip(mapSize.Help);
0614
end
0615
ScreenOptions["Teams"].FullSync();
0616
PerformPartialSync();
0617
end);
0769
pullDown:RegisterSelectionCallback( function(id)
0770
local mapScript = mapScripts[id];
0772
-- If this is an "error" entry (invalid WB file for example), do nothing.
0773
if(mapScript.Error) then
0774
return;
0775
end
0777
PreGame.SetLoadWBScenario(false);
0779
if( id == 0 or mapScript == nil) then
0780
PreGame.SetRandomMapScript(true);
0781
elseif(mapScript.IsEarthMap) then
0782
PreGame.SetEarthMap(true);
0783
else
0784
PreGame.SetEarthMap(false);
0785
PreGame.SetRandomMapScript(false);
0786
PreGame.SetMapScript(mapScript.FileName);
0788
if(mapScript.DefaultCityStates ~= nil) then
0789
PreGame.SetNumMinorCivs(mapScript.DefaultCityStates);
0790
end
0792
-- If it's a WB Map, we have more to do.
0793
if(mapScript.WBMapData ~= nil) then
0794
local wb = mapScript.WBMapData;
0796
PreGame.SetEra(wb.StartEra);
0797
PreGame.SetGameSpeed(wb.DefaultSpeed);
0798
PreGame.SetMaxTurns(wb.MaxTurns);
0799
PreGame.SetNumMinorCivs(wb.CityStateCount);
0800
PreGame.SetRandomWorldSize(false);
0801
PreGame.SetWorldSize(wb.MapSize);
0802
PreGame.SetRandomWorldSize(false);
0803
PreGame.SetNumMinorCivs(-1);
0805
local victories = {};
0806
for _, v in ipairs(wb.VictoryTypes) do
0807
   victories[v] = true;
0808
   end
0810
   for row in GameInfo.Victories() do
0811
   PreGame.SetVictory(row.ID, victories[row.Type]);
0812
   end
0814
   local numPlayers = wb.PlayerCount;
0815
   if(numPlayers == 0) then
0816
   numPlayers = GameInfo.Worlds[wb.MapSize].DefaultPlayers
0817
   end
0819
   for i = numPlayers, GameDefines.MAX_MAJOR_CIVS do
0820
   if( PreGame.GetSlotStatus(i) == SlotStatus.SS_COMPUTER) then
0821
   PreGame.SetSlotStatus(i, SlotStatus.SS_OPEN);
0822
   end
0823
   end
0825
   ScreenOptions["Teams"].FullSync();
0826
   end
0827
   end
0829
   PerformPartialSync();
0830
   end);
0992
pullDown:RegisterSelectionCallback(function(playerID, playerChoiceID)
0994
PreGame.SetTeam(playerID, playerChoiceID);
0995
local slotInstance = g_SlotInstances[playerID];
0997
if( slotInstance ~= nil ) then
0998
slotInstance.TeamLabel:LocalizeAndSetText( "TXT_KEY_MULTIPLAYER_DEFAULT_TEAM_NAME", PreGame.GetTeam(playerID) + 1 );
0999
else
1000
Controls.TeamLabel:LocalizeAndSetText( "TXT_KEY_MULTIPLAYER_DEFAULT_TEAM_NAME", PreGame.GetTeam(playerID) + 1 );
1001
end
1003
PerformValidation();
1004
end);


DiploCorner.lua

UI/InGame/WorldView/DiploCorner.lua
0052
Controls.MultiPull:RegisterSelectionCallback(function(id)
0053
local entry = additionalEntries[id];
0054
if(entry and entry.call ~= nil) then
0055
entry.call();
0056
end
0057
end);
0307
Controls.ChatPull:RegisterSelectionCallback( OnChatTarget );


DiploCorner.lua - DLC_01 DLC

DLC/DLC_01/Scenarios/Mongol Scenario/DiploCorner.lua
0049
Controls.MultiPull:RegisterSelectionCallback( OnMultiPull );


InfoCorner.lua

UI/InGame/InfoCorner.lua
0053
Controls.LeftPull:RegisterSelectionCallback( OnInfoButton );


MiniMapPanel.lua

UI/InGame/WorldView/MiniMapPanel.lua
0207
pullDown:RegisterSelectionCallback( OnOverlaySelected );
0273
pullDown:RegisterSelectionCallback( OnIconModeSelected );


MPGameOptions.lua

UI/FrontEnd/Multiplayer/GameSetup/MPGameOptions.lua
0431
Controls.GameSpeedPullDown:RegisterSelectionCallback( SelectSpeed );
0473
Controls.MapSizePullDown:RegisterSelectionCallback( SelectSize );
0705
pullDown:RegisterSelectionCallback( TypeSelected );
0724
Controls.EraPull:RegisterSelectionCallback( OnEraPull );


OptionsMenu.lua

UI/Options/OptionsMenu.lua
1119
Controls.WResolutionPull:RegisterSelectionCallback( OnWResolutionPull );
1134
Controls.FSResolutionPull:RegisterSelectionCallback( OnFSResolutionPull );
1142
Controls.MSAAPull:RegisterSelectionCallback( OnMSAAPull );
1218
Controls.TutorialPull:RegisterSelectionCallback( OnTutorialPull );
1221
Controls.OverlayPull:RegisterSelectionCallback( OnOverlayPull );
1224
Controls.ShadowPull:RegisterSelectionCallback( OnShadowPull );
1227
Controls.FOWPull:RegisterSelectionCallback( OnFOWPull );
1230
Controls.TerrainDetailPull:RegisterSelectionCallback( OnTerrainDetailPull );
1233
Controls.TerrainTessPull:RegisterSelectionCallback( OnTerrainTessPull );
1236
Controls.TerrainShadowPull:RegisterSelectionCallback( OnTerrainShadowPull );
1239
Controls.WaterPull:RegisterSelectionCallback( OnWaterPull );
1242
Controls.TextureQualityPull:RegisterSelectionCallback( OnTextureQualityPull );
1251
Controls.LeaderPull:RegisterSelectionCallback( OnLeaderPull );
1256
Controls.BindMousePull:RegisterSelectionCallback( OnBindMousePull );
1263
Controls.LanguagePull:RegisterSelectionCallback( OnLanguagePull );
1272
Controls.SpokenLanguagePull:RegisterSelectionCallback( OnSpokenLanguagePull );


ReligionOverview.lua (G&K)

DLC/Expansion/UI/InGame/Popups/ReligionOverview.lua
0468
automaticPurchasePullDown:RegisterSelectionCallback(function(v1, v2)
0470
local player = Players[Game.GetActivePlayer()];
0471
Network.SendFaithPurchase(Game.GetActivePlayer(), v1, v2);
0472
SetCurrentSelection(v1, v2);
0473
end);


ReligionOverview.lua (G&K)

DLC/Expansion/Scenarios/MedievalScenario/ReligionOverview.lua
0475
automaticPurchasePullDown:RegisterSelectionCallback(function(v1, v2)
0477
local player = Players[Game.GetActivePlayer()];
0478
player:SetFaithPurchaseType(v1);
0479
player:SetFaithPurchaseIndex(v2);
0480
SetCurrentSelection(v1, v2);
0481
end);


StagingRoom.lua

UI/FrontEnd/Multiplayer/StagingRoom.lua
1055
pullDown:RegisterSelectionCallback( CivSelected );
1091
pullDown:RegisterSelectionCallback( InviteSelected );
1120
pullDown:RegisterSelectionCallback( OnSelectTeam );
1141
pullDown:RegisterSelectionCallback( OnHandicapTeam );
1163
pullDown:RegisterSelectionCallback( OnPlayerName );


SteampunkScenarioLoadScreen.lua (G&K)

DLC/Expansion/Scenarios/SteampunkScenario/SteampunkScenarioLoadScreen.lua
0219
pullDown:RegisterSelectionCallback( MapSelected );


UITestMenu.lua

UI/FrontEnd/UITestMenu.lua
0131
Controls.PullDown:RegisterSelectionCallback( OnSelectionChanged );


UnitFlagManager.lua

UI/InGame/UnitFlagManager.lua
0101
o.m_CargoControls.PullDown:RegisterSelectionCallback( UnitFlagClicked );
1038
cityFlagInstance.PullDown:RegisterSelectionCallback( UnitFlagClicked );



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.