Skip to content

Commit

Permalink
Fix Version Text
Browse files Browse the repository at this point in the history
Localize, Align with ticker, fix GC issue, allow to be turned off
  • Loading branch information
robojumper committed Aug 7, 2017
1 parent b889941 commit 5e173c0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
10 changes: 5 additions & 5 deletions X2CommunityHighlander.XCOM_sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# XCOM ModBuddy Solution File, Format Version 11.00
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{5DAE07AF-E217-45C1-8DE7-FF99D6011E8A}") = "X2CommunityHighlander", "X2CommunityHighlander\X2CommunityHighlander.x2proj", "{4D637F30-1C48-46C7-9C88-48598D80A595}"
Project("{5DAE07AF-E217-45C1-8DE7-FF99D6011E8A}") = "X2CommunityHighlander", "X2CommunityHighlander\X2CommunityHighlander.x2proj", "{6671DE85-5595-469A-9B54-28A003DEFE77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|XCOM 2 = Debug|XCOM 2
Default|XCOM 2 = Default|XCOM 2
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4D637F30-1C48-46C7-9C88-48598D80A595}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{4D637F30-1C48-46C7-9C88-48598D80A595}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{4D637F30-1C48-46C7-9C88-48598D80A595}.Default|XCOM 2.ActiveCfg = Debug|XCOM 2
{4D637F30-1C48-46C7-9C88-48598D80A595}.Default|XCOM 2.Build.0 = Debug|XCOM 2
{6671DE85-5595-469A-9B54-28A003DEFE77}.Debug|XCOM 2.ActiveCfg = Debug|XCOM 2
{6671DE85-5595-469A-9B54-28A003DEFE77}.Debug|XCOM 2.Build.0 = Debug|XCOM 2
{6671DE85-5595-469A-9B54-28A003DEFE77}.Default|XCOM 2.ActiveCfg = Debug|XCOM 2
{6671DE85-5595-469A-9B54-28A003DEFE77}.Default|XCOM 2.Build.0 = Debug|XCOM 2
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 4 additions & 1 deletion X2CommunityHighlander/Config/XComGame.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[X2CommunityHighlander.X2DownloadableContentInfo_X2CommunityHighlander]
DLCIdentifier="X2CommunityHighlander"
DLCIdentifier="X2CommunityHighlander"

[X2CommunityHighlander.X2CH_UIScreenListener_ShellSplash]
bEnableVersionDisplay=true
3 changes: 3 additions & 0 deletions X2CommunityHighlander/Localization/X2CommunityHighlander.int
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[X2CH_UIScreenListener_ShellSplash]
strLWHLVersion"Long War 2 Highlander v%MAJOR.%MINOR"
strCHLVersion="X2CommunityHighlander v%MAJOR.%MINOR"
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class X2CH_UIScreenListener_ShellSplash extends UIScreenListener;
class X2CH_UIScreenListener_ShellSplash extends UIScreenListener config(Game);

var UIText VersionText;
var config bool bEnableVersionDisplay;

var localized string strLWHLVersion;
var localized string strCHLVersion;

event OnInit(UIScreen Screen)
{
Expand All @@ -9,9 +12,12 @@ event OnInit(UIScreen Screen)
local X2StrategyElementTemplate LWElem, CHElem;
local CHXComGameVersionTemplate CHVersion;
local LWXComGameVersionTemplate LWVersion;
local String VersionString;
local string VersionString;

local UIText VersionText;
local int iMajor, iMinor;

if(UIShell(Screen) == none) // this captures UIShell and UIFinalShell
if(UIShell(Screen) == none || !bEnableVersionDisplay) // this captures UIShell and UIFinalShell
return;

ShellScreen = UIShell(Screen);
Expand All @@ -26,23 +32,40 @@ event OnInit(UIScreen Screen)
if (CHElem != none)
{
CHVersion = CHXComGameVersionTemplate(CHElem);
VersionString = VersionString $ "X2CommunityHighlander Version " $ CHVersion.MajorVersion $ "." $ CHVersion.MinorVersion $ ". ";
VersionString = strCHLVersion;
iMajor = CHVersion.MajorVersion;
iMinor = CHVersion.MinorVersion;
}

if (LWElem != none)
else if (LWElem != none)
{
LWVersion = LWXComGameVersionTemplate(LWElem);
VersionString = VersionString $ "Long War Highlander Version " $ LWVersion.MajorVersion $ "." $ LWVersion.MinorVersion $ ". ";
VersionString = strLWHLVersion;
iMajor = LWVersion.MajorVersion;
iMinor = LWVersion.MinorVersion;
}
VersionString = Repl(VersionString, "%MAJOR", iMajor);
VersionString = Repl(VersionString, "%MINOR", iMinor);

`log("X2CH SCREEN LISTENER ON SPLASH");
`log("X2CH SCREEN LISTENER ON SPLASH" @ VersionString);
VersionText = ShellScreen.Spawn(class'UIText', ShellScreen);
VersionText.InitText();
VersionText.SetText(VersionString);
VersionText.AnchorTopRight();
VersionText.SetPosition(10,10);
VersionText.SetSize(400,32);
VersionText.Show();
VersionText.InitText('theVersionText');
VersionText.SetText(VersionString, OnTextSizeRealized);
// This code aligns the version text to the Main Menu Ticker
VersionText.AnchorBottomRight();
VersionText.SetY(-ShellScreen.TickerHeight + 10);
}

function OnTextSizeRealized()
{
local UIText VersionText;
local UIShell ShellScreen;

ShellScreen = UIShell(`SCREENSTACK.GetFirstInstanceOf(class'UIShell'));
VersionText = UIText(ShellScreen.GetChildByName('theVersionText'));
VersionText.SetX(-10 - VersionText.Width);
// this makes the ticker shorter -- if the text gets long enough to interfere, it will automatically scroll
ShellScreen.TickerText.SetWidth(ShellScreen.Movie.m_v2ScaledFullscreenDimension.X - VersionText.Width - 20);

}

defaultProperties
Expand Down
3 changes: 3 additions & 0 deletions X2CommunityHighlander/X2CommunityHighlander.x2proj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<Content Include="Config\XComUI.ini">
<SubType>Content</SubType>
</Content>
<Content Include="Localization\X2CommunityHighlander.int">
<SubType>Content</SubType>
</Content>
<Content Include="ModPreview.jpg" />
<Content Include="Config\XComEditor.ini" />
<Content Include="Config\XComEngine.ini" />
Expand Down

0 comments on commit 5e173c0

Please sign in to comment.