TruncateString (Civ5 API)

From Civilization Modding Wiki
Revision as of 16:42, 19 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 global function. Use: include("SupportFunctions.lua")


Usage

void TruncateString(Label control, int resultSize, string longStr, string trailingText = nil)


Parameters

control: No description available.
resultSize: No description available.
longStr: No description available.
trailingText: No description available.


Source code samples

Redundant occurences have been removed.

CityView.lua

UI/InGame/CityView/CityView.lua
0726
TruncateString(Controls.CityNameTitleBarLabel, cityNameSize, convertedKey);


DiploCorner.lua

UI/InGame/WorldView/DiploCorner.lua
0144
TruncateString( controlTable.String, 200, Players[fromPlayer]:GetNickName() );
0157
TruncateString( controlTable.String, 200, Players[toPlayer]:GetNickName() );
0296
TruncateString( Controls.LengthTest, Controls.ChatPull:GetSizeX(), Locale.ConvertTextKey("TXT_KEY_DIPLO_TO_TEAM"));
0300
TruncateString( Controls.LengthTest, Controls.ChatPull:GetSizeX(), Locale.ConvertTextKey("TXT_KEY_DIPLO_TO_PLAYER", Players[ iPlayer ]:GetNickName()));
0356
TruncateString( textControl, Controls.ChatPull:GetSizeX()-20, Locale.ConvertTextKey("TXT_KEY_DIPLO_TO_PLAYER", pPlayer:GetNickName()));


DiploList.lua

UI/InGame/DiploList.lua
0216
TruncateString(Controls.LeaderName, textBoxSize, g_pPlayer:GetNickName());
0218
TruncateString(Controls.LeaderName, textBoxSize, Locale.ConvertTextKey( PreGame.GetLeaderName( g_iPlayer ) ), "  (" .. Locale.ConvertTextKey( "TXT_KEY_YOU" ) .. ")");
0220
TruncateString(Controls.LeaderName, textBoxSize, Locale.ConvertTextKey( leaderDescription ), "  (" .. Locale.ConvertTextKey( "TXT_KEY_YOU" ) .. ")");
0231
TruncateString(Controls.CivName, textBoxSize, Locale.ConvertTextKey(PreGame.GetCivilizationShortDescription(g_iPlayer)));
0233
TruncateString(Controls.CivName, textBoxSize, Locale.ConvertTextKey(myCivInfo.ShortDescription));
0263
TruncateString(controlTable.LeaderName, textBoxSize, pOtherPlayer:GetNickName());
0334
TruncateString( controlTable.DiploState, controlTable.StatusBox:GetSizeX(), statusString );


DiploVotePopup.lua

UI/InGame/Popups/DiploVotePopup.lua
0070
TruncateString(controlTable.ButtonText, textBoxSize, pOtherPlayer:GetNickName());
0076
TruncateString(controlTable.ButtonText, textBoxSize, Locale.ConvertTextKey( PreGame.GetLeaderName( Game.GetActivePlayer() ) ), "  (" .. Locale.ConvertTextKey( "TXT_KEY_YOU" ) .. ")");
0078
TruncateString(controlTable.ButtonText, textBoxSize, Locale.ConvertTextKey( leaderDescription ), "  (" .. Locale.ConvertTextKey( "TXT_KEY_YOU" ) .. ")");
0081
TruncateString(controlTable.ButtonText, textBoxSize, Locale.ConvertTextKey("TXT_KEY_POP_UN_TEAM_LABEL", pOtherTeam:GetID() + 1) , " (" .. Locale.ConvertTextKey("TXT_KEY_POP_VOTE_RESULTS_YOUR_TEAM") .. ")");
0087
TruncateString(controlTable.ButtonText, textBoxSize, Locale.ConvertTextKey( leaderDescription ));
0089
TruncateString(controlTable.ButtonText, textBoxSize, Locale.ConvertTextKey("TXT_KEY_POP_UN_TEAM_LABEL", pOtherTeam:GetID() + 1));


GameMenu.lua

UI/InGame/Menus/GameMenu.lua
0325
TruncateString(Controls.DetailsCiv, availableTextExtent, Locale.ConvertTextKey(myCivInfo.ShortDescription));
0326
TruncateString(Controls.DetailsLeader, availableTextExtent, pPlayer:GetNickName());
0328
TruncateString(Controls.DetailsCiv, availableTextExtent, PreGame.GetCivilizationShortDescription(0));
0329
TruncateString(Controls.DetailsLeader, availableTextExtent, PreGame.GetLeaderName(0));
0334
TruncateString(Controls.DetailsLeader, availableTextExtent, Locale.ConvertTextKey(leaderDescription));


GPList.lua

UI/InGame/GPList.lua
0117
TruncateString( instance.CityName, 74, sortEntry.name );


LoadMenu.lua

UI/FrontEnd/LoadMenu.lua
0231
TruncateString(Controls.SaveFileName, Controls.DetailsBox:GetSizeX(), name);
0558
TruncateString(controlTable.ButtonText, controlTable.Button:GetSizeX(), entryName);
0576
TruncateString(controlTable.ButtonText, controlTable.Button:GetSizeX(), displayName);


Lobby.lua

UI/FrontEnd/Multiplayer/Lobby.lua
0228
TruncateString(controlTable.ServerNameLabel, controlTable.ServerNameBox:GetSizeX(), serverEntry.serverName);


MPList.lua

UI/InGame/WorldView/MPList.lua
0140
TruncateString( controlTable.Name, textSize, pPlayer:GetNickName() );
0153
TruncateString( controlTable.Name, textSize, pPlayer:GetName() );


ResourceList.lua

UI/InGame/ResourceList.lua
0116
TruncateString( instance.ResourceName, 140, resource.IconString .. " " .. sortEntry.name );


SaveMenu.lua

UI/InGame/Menus/SaveMenu.lua
0569
TruncateString(instance.ButtonText, instance.Button:GetSizeX(), displayName);


StagingRoom.lua

UI/FrontEnd/Multiplayer/StagingRoom.lua
0385
TruncateString(slotInstance.PlayerNameLabel, slotInstance.PlayerNameBox:GetSizeX() -
0386
slotInstance.PlayerNameLabel:GetOffsetX(), playerName);
0403
TruncateString(slotInstance.PlayerNameLabel, slotInstance.PlayerNameBox:GetSizeX() -
0404
slotInstance.PlayerNameLabel:GetOffsetX(), Locale.ConvertTextKey("TXT_KEY_AI_NICKNAME"));
0559
TruncateString(Controls.PlayerNameLabel, Controls.PlayerNameBox:GetSizeX() -
0560
Controls.PlayerNameLabel:GetOffsetX(), playerName);


TradeLogic.lua

UI/InGame/WorldView/TradeLogic.lua
0985
TruncateString(Controls.ThemName, Controls.ThemTablePanel:GetSizeX() - Controls.ThemTablePanel:GetOffsetX(),
0986
Locale.ConvertTextKey( "TXT_KEY_DIPLO_ITEMS_LABEL", g_pThem:GetNickName() ));
2784
TruncateString(controlTable.Name, controlTable.ButtonSize:GetSizeX() - controlTable.Name:GetOffsetX(), szName);


UnitList.lua

UI/InGame/UnitList.lua
0132
TruncateString( instance.UnitName, 110, sortEntry.name );


VictoryProgress.lua

UI/InGame/Popups/VictoryProgress.lua
0394
TruncateString(Controls.UNInfo, 200, strPlayer);
0467
TruncateString(Controls.CultureLabel, 200, strCiv);
0879
TruncateString(controlTable, controlSize, displayText);


VoteResultsPopup.lua

UI/InGame/Popups/VoteResultsPopup.lua
0168
TruncateString(controlTable.PlayerNameText, controlTable.PlayerNameBox:GetSizeX(), strName);
0176
TruncateString(controlTable.VoteCastText, controlTable.VoteCastBox:GetSizeX() - unSize, strVote);


VoteResultsPopup.lua (G&K)

DLC/Expansion/UI/InGame/Popups/VoteResultsPopup.lua
0199
TruncateString(controlTable.VoteCastText, controlTable.VoteCastBox:GetSizeX(), strVote);



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.