diff --git a/src/TSMapEditor/Config/UI/Windows/LightingSettingsWindow.ini b/src/TSMapEditor/Config/UI/Windows/LightingSettingsWindow.ini index fc2608f8..cdfc2d24 100644 --- a/src/TSMapEditor/Config/UI/Windows/LightingSettingsWindow.ini +++ b/src/TSMapEditor/Config/UI/Windows/LightingSettingsWindow.ini @@ -4,7 +4,8 @@ $CC00=lblHeader:XNALabel $CC01=lblDescription:XNALabel $CC03=panelNormal:EditorPanel $CC04=panelIonStorm:EditorPanel -$CC05=btnApply:EditorButton +$CC05=panelDominator:EditorPanel +$CC06=btnApply:EditorButton $Height=getBottom(btnApply) + EMPTY_SPACE_BOTTOM HasCloseButton=true @@ -20,6 +21,7 @@ $X=EMPTY_SPACE_SIDES $Y=getBottom(lblHeader) + EMPTY_SPACE_TOP Text=Lighting settings define the lighting of the terrain on the map. +; ********** Normal Lighting ********** [panelNormal] $X=EMPTY_SPACE_SIDES @@ -30,19 +32,21 @@ $CCn00=tbAmbientNormal:EditorNumberTextBox $CCn01=lblAmbientNormal:XNALabel $CCn02=tbLevelNormal:EditorNumberTextBox $CCn03=lblLevelNormal:XNALabel -$CCn04=tbRedNormal:EditorNumberTextBox -$CCn05=lblRedNormal:XNALabel -$CCn06=tbGreenNormal:EditorNumberTextBox -$CCn07=lblGreenNormal:XNALabel -$CCn08=tbBlueNormal:EditorNumberTextBox -$CCn09=lblBlueNormal:XNALabel +$CCn04=tbGroundNormal:EditorNumberTextBox +$CCn05=lblGroundNormal:XNALabel +$CCn06=tbRedNormal:EditorNumberTextBox +$CCn07=lblRedNormal:XNALabel +$CCn08=tbGreenNormal:EditorNumberTextBox +$CCn09=lblGreenNormal:XNALabel +$CCn10=tbBlueNormal:EditorNumberTextBox +$CCn11=lblBlueNormal:XNALabel $Height=getBottom(tbBlueNormal) + EMPTY_SPACE_BOTTOM [lblNormal] $X=EMPTY_SPACE_SIDES $Y=EMPTY_SPACE_TOP FontIndex=1 -Text=Normal settings +Text=Normal Settings [tbAmbientNormal] $X=100 @@ -61,17 +65,29 @@ $X=getX(tbAmbientNormal) $Y=getBottom(tbAmbientNormal) + VERTICAL_SPACING $Width=getWidth(tbAmbientNormal) AllowDecimals=true -NextControl=tbRedNormal +NextControl=tbGroundNormal [lblLevelNormal] $X=EMPTY_SPACE_SIDES $Y=getY(tbLevelNormal) + 1 Text=Level: +[tbGroundNormal] +$X=getX(tbLevelNormal) +$Y=getBottom(tbLevelNormal) + VERTICAL_SPACING +$Width=getWidth(tbLevelNormal) +AllowDecimals=true +NextControl=tbRedNormal + +[lblGroundNormal] +$X=EMPTY_SPACE_SIDES +$Y=getY(tbGroundNormal) + 1 +Text=Ground: + [tbRedNormal] $Width=getWidth(tbAmbientNormal) $X=getWidth(panelNormal) - EMPTY_SPACE_SIDES - getWidth(tbRedNormal) -$Y=EMPTY_SPACE_TOP +$Y=getY(tbAmbientNormal)) AllowDecimals=true NextControl=tbGreenNormal @@ -104,6 +120,7 @@ $X=getX(lblRedNormal) $Y=getY(tbBlueNormal) + 1 Text=Blue: +; ********** Ion Storm Lighting ********** [panelIonStorm] $X=EMPTY_SPACE_SIDES @@ -114,19 +131,21 @@ $CCn00=tbAmbientIS:EditorNumberTextBox $CCn01=lblAmbientIS:XNALabel $CCn02=tbLevelIS:EditorNumberTextBox $CCn03=lblLevelIS:XNALabel -$CCn04=tbRedIS:EditorNumberTextBox -$CCn05=lblRedIS:XNALabel -$CCn06=tbGreenIS:EditorNumberTextBox -$CCn07=lblGreenIS:XNALabel -$CCn08=tbBlueIS:EditorNumberTextBox -$CCn09=lblBlueIS:XNALabel +$CCn04=tbGroundIS:EditorNumberTextBox +$CCn05=lblGroundIS:XNALabel +$CCn06=tbRedIS:EditorNumberTextBox +$CCn07=lblRedIS:XNALabel +$CCn08=tbGreenIS:EditorNumberTextBox +$CCn09=lblGreenIS:XNALabel +$CCn10=tbBlueIS:EditorNumberTextBox +$CCn11=lblBlueIS:XNALabel $Height=getHeight(panelNormal) [lblIonStorm] $X=EMPTY_SPACE_SIDES $Y=EMPTY_SPACE_TOP FontIndex=1 -Text=Ion Storm settings +Text=Ion Storm Settings [tbAmbientIS] $X=100 @@ -145,17 +164,29 @@ $X=getX(tbAmbientIS) $Y=getBottom(tbAmbientIS) + VERTICAL_SPACING $Width=getWidth(tbAmbientIS) AllowDecimals=true -NextControl=tbRedIS +NextControl=tbGroundIS [lblLevelIS] $X=EMPTY_SPACE_SIDES $Y=getY(tbLevelIS) + 1 Text=Level: +[tbGroundIS] +$X=getX(tbLevelIS) +$Y=getBottom(tbLevelIS) + VERTICAL_SPACING +$Width=getWidth(tbLevelIS) +AllowDecimals=true +NextControl=tbRedIS + +[lblGroundIS] +$X=EMPTY_SPACE_SIDES +$Y=getY(tbGroundIS) + 1 +Text=Ground: + [tbRedIS] $Width=getWidth(tbAmbientIS) $X=getWidth(panelIonStorm) - EMPTY_SPACE_SIDES - getWidth(tbRedIS) -$Y=EMPTY_SPACE_TOP +$Y=getY(tbAmbientIS) AllowDecimals=true NextControl=tbGreenIS @@ -187,9 +218,122 @@ $X=getX(lblRedIS) $Y=getY(tbBlueIS) + 1 Text=Blue: +; ********** Dominator Lighting ********** + +[panelDominator] +$X=EMPTY_SPACE_SIDES +$Y=getBottom(panelIonStorm) + VERTICAL_SPACING +$Width=getWidth(panelIonStorm) +$CCnl=lblDominator:XNALabel +$CCn00=tbAmbientDominator:EditorNumberTextBox +$CCn01=lblAmbientDominator:XNALabel +$CCn02=tbAmbientChangeRateDominator:EditorNumberTextBox +$CCn03=lblAmbientChangeRateDominator:XNALabel +$CCn04=tbLevelDominator:EditorNumberTextBox +$CCn05=lblLevelDominator:XNALabel +$CCn06=tbGroundDominator:EditorNumberTextBox +$CCn07=lblGroundDominator:XNALabel +$CCn08=tbRedDominator:EditorNumberTextBox +$CCn09=lblRedDominator:XNALabel +$CCn10=tbGreenDominator:EditorNumberTextBox +$CCn11=lblGreenDominator:XNALabel +$CCn12=tbBlueDominator:EditorNumberTextBox +$CCn13=lblBlueDominator:XNALabel +$Height=getBottom(tbGroundDominator) + EMPTY_SPACE_BOTTOM +$Enabled=USE_COUNTRIES + +[lblDominator] +$X=EMPTY_SPACE_SIDES +$Y=EMPTY_SPACE_TOP +FontIndex=1 +Text=Dominator Settings + +[tbAmbientDominator] +$X=100 +$Y=getBottom(lblDominator) + EMPTY_SPACE_TOP +$Width=((getWidth(panelDominator) / 2) - EMPTY_SPACE_SIDES) - getX(tbAmbientDominator) +AllowDecimals=true +NextControl=tbAmbientChangeRateDominator + +[lblAmbientDominator] +$X=EMPTY_SPACE_SIDES +$Y=getY(tbAmbientDominator) + 1 +Text=Ambient: + +[tbAmbientChangeRateDominator] +$X=getX(tbAmbientDominator) +$Y=getBottom(tbAmbientDominator) + VERTICAL_SPACING +$Width=getWidth(tbAmbientDominator) +AllowDecimals=true +NextControl=tbLevelDominator + +[lblAmbientChangeRateDominator] +$X=EMPTY_SPACE_SIDES +Text=Ambient@Change Rate: +$Y=getY(tbAmbientChangeRateDominator) + (getHeight(tbAmbientChangeRateDominator) / 2) - (getHeight(lblAmbientChangeRateDominator) / 2) + +[tbLevelDominator] +$X=getX(tbAmbientChangeRateDominator) +$Y=getBottom(tbAmbientChangeRateDominator) + VERTICAL_SPACING +$Width=getWidth(tbAmbientChangeRateDominator) +AllowDecimals=true +NextControl=tbGroundDominator + +[lblLevelDominator] +$X=EMPTY_SPACE_SIDES +$Y=getY(tbLevelDominator) + 1 +Text=Level: + +[tbGroundDominator] +$X=getX(tbLevelDominator) +$Y=getBottom(tbLevelDominator) + VERTICAL_SPACING +$Width=getWidth(tbLevelDominator) +AllowDecimals=true +NextControl=tbRedDominator + +[lblGroundDominator] +$X=EMPTY_SPACE_SIDES +$Y=getY(tbGroundDominator) + 1 +Text=Ground: + +[tbRedDominator] +$Width=getWidth(tbAmbientDominator) +$X=getWidth(panelDominator) - EMPTY_SPACE_SIDES - getWidth(tbRedDominator) +$Y=getY(tbAmbientDominator) +AllowDecimals=true +NextControl=tbGreenDominator + +[lblRedDominator] +$X=(getWidth(panelDominator) / 2) + (EMPTY_SPACE_SIDES * 2) +$Y=getY(tbRedDominator) + 1 +Text=Red: + +[tbGreenDominator] +$Width=getWidth(tbRedDominator) +$X=getX(tbRedDominator) +$Y=getBottom(tbRedDominator) + VERTICAL_SPACING +AllowDecimals=true +NextControl=tbBlueDominator + +[lblGreenDominator] +$X=getX(lblRedDominator) +$Y=getY(tbGreenDominator) + 1 +Text=Green: + +[tbBlueDominator] +$Width=getWidth(tbRedDominator) +$X=getX(tbRedDominator) +$Y=getBottom(tbGreenDominator) + VERTICAL_SPACING +AllowDecimals=true + +[lblBlueDominator] +$X=getX(lblRedDominator) +$Y=getY(tbBlueDominator) + 1 +Text=Blue: + + [btnApply] Width=100 $X=horizontalCenterOnParent() -$Y=getBottom(panelIonStorm) + EMPTY_SPACE_TOP +$Y=(getBottom(panelDominator) * USE_COUNTRIES) + (getBottom(panelIonStorm) * (1 - USE_COUNTRIES)) + EMPTY_SPACE_TOP Text=Apply - diff --git a/src/TSMapEditor/Models/Lighting.cs b/src/TSMapEditor/Models/Lighting.cs index 9ca47166..411fdb3c 100644 --- a/src/TSMapEditor/Models/Lighting.cs +++ b/src/TSMapEditor/Models/Lighting.cs @@ -20,6 +20,14 @@ public class Lighting : INIDefineable public double IonLevel { get; set; } public double IonGround { get; set; } + public double? DominatorRed { get; set; } + public double? DominatorGreen { get; set; } + public double? DominatorBlue { get; set; } + public double? DominatorAmbient { get; set; } + public double? DominatorAmbientChangeRate { get; set; } + public double? DominatorLevel { get; set; } + public double? DominatorGround { get; set; } + public void ReadFromIniFile(IniFile iniFile) { var lightingSection = iniFile.GetSection(LightingIniSectionName); diff --git a/src/TSMapEditor/UI/UIManager.cs b/src/TSMapEditor/UI/UIManager.cs index 1f3ff526..6a30d369 100644 --- a/src/TSMapEditor/UI/UIManager.cs +++ b/src/TSMapEditor/UI/UIManager.cs @@ -180,6 +180,8 @@ public override void Initialize() // Try to select "Neutral" as default house editorState.ObjectOwner = map.GetHouses().Find(h => h.ININame == "Neutral"); + if (editorState.ObjectOwner == null && map.GetHouses().Count > 0) + editorState.ObjectOwner = map.GetHouses()[0]; editorState.CursorAction = null; Alpha = 0f; diff --git a/src/TSMapEditor/UI/Windows/LightingSettingsWindow.cs b/src/TSMapEditor/UI/Windows/LightingSettingsWindow.cs index 7ac21158..3ea604c2 100644 --- a/src/TSMapEditor/UI/Windows/LightingSettingsWindow.cs +++ b/src/TSMapEditor/UI/Windows/LightingSettingsWindow.cs @@ -1,4 +1,5 @@ using Rampastring.XNAUI; +using Rampastring.XNAUI.XNAControls; using TSMapEditor.Models; using TSMapEditor.UI.Controls; @@ -15,16 +16,26 @@ public LightingSettingsWindow(WindowManager windowManager, Map map) : base(windo private EditorNumberTextBox tbAmbientNormal; private EditorNumberTextBox tbLevelNormal; + private EditorNumberTextBox tbGroundNormal; private EditorNumberTextBox tbRedNormal; private EditorNumberTextBox tbGreenNormal; private EditorNumberTextBox tbBlueNormal; private EditorNumberTextBox tbAmbientIS; private EditorNumberTextBox tbLevelIS; + private EditorNumberTextBox tbGroundIS; private EditorNumberTextBox tbRedIS; private EditorNumberTextBox tbGreenIS; private EditorNumberTextBox tbBlueIS; + private EditorNumberTextBox tbAmbientDominator; + private EditorNumberTextBox tbAmbientChangeRateDominator; + private EditorNumberTextBox tbLevelDominator; + private EditorNumberTextBox tbGroundDominator; + private EditorNumberTextBox tbRedDominator; + private EditorNumberTextBox tbGreenDominator; + private EditorNumberTextBox tbBlueDominator; + public override void Initialize() { Name = nameof(LightingSettingsWindow); @@ -32,17 +43,27 @@ public override void Initialize() tbAmbientNormal = FindChild(nameof(tbAmbientNormal)); tbLevelNormal = FindChild(nameof(tbLevelNormal)); + tbGroundNormal = FindChild(nameof(tbGroundNormal)); tbRedNormal = FindChild(nameof(tbRedNormal)); tbGreenNormal = FindChild(nameof(tbGreenNormal)); tbBlueNormal = FindChild(nameof(tbBlueNormal)); tbAmbientIS = FindChild(nameof(tbAmbientIS)); tbLevelIS = FindChild(nameof(tbLevelIS)); + tbGroundIS = FindChild(nameof(tbGroundIS)); tbRedIS = FindChild(nameof(tbRedIS)); tbGreenIS = FindChild(nameof(tbGreenIS)); tbBlueIS = FindChild(nameof(tbBlueIS)); - FindChild("btnApply").LeftClick += BtnApply_LeftClick; ; + tbAmbientDominator = FindChild(nameof(tbAmbientDominator)); + tbAmbientChangeRateDominator = FindChild(nameof(tbAmbientChangeRateDominator)); + tbLevelDominator = FindChild(nameof(tbLevelDominator)); + tbGroundDominator = FindChild(nameof(tbGroundDominator)); + tbRedDominator = FindChild(nameof(tbRedDominator)); + tbGreenDominator = FindChild(nameof(tbGreenDominator)); + tbBlueDominator = FindChild(nameof(tbBlueDominator)); + + FindChild("btnApply").LeftClick += BtnApply_LeftClick; } public void Open() @@ -51,16 +72,29 @@ public void Open() tbAmbientNormal.Text = map.Lighting.Ambient.ToString(format); tbLevelNormal.Text = map.Lighting.Level.ToString(format); + tbGroundNormal.Text = map.Lighting.Ground.ToString(format); tbRedNormal.Text = map.Lighting.Red.ToString(format); tbGreenNormal.Text = map.Lighting.Green.ToString(format); tbBlueNormal.Text = map.Lighting.Blue.ToString(format); tbAmbientIS.Text = map.Lighting.IonAmbient.ToString(format); tbLevelIS.Text = map.Lighting.IonLevel.ToString(format); + tbGroundIS.Text = map.Lighting.IonGround.ToString(format); tbRedIS.Text = map.Lighting.IonRed.ToString(format); tbGreenIS.Text = map.Lighting.IonGreen.ToString(format); tbBlueIS.Text = map.Lighting.IonBlue.ToString(format); + if (Constants.UseCountries) + { + tbAmbientDominator.Text = (map.Lighting.DominatorAmbient ?? 0).ToString(format); + tbAmbientChangeRateDominator.Text = (map.Lighting.DominatorAmbientChangeRate ?? 0).ToString(format); + tbLevelDominator.Text = (map.Lighting.DominatorLevel ?? 0).ToString(format); + tbGroundDominator.Text = (map.Lighting.DominatorGround ?? 0).ToString(format); + tbRedDominator.Text = (map.Lighting.DominatorRed ?? 0).ToString(format); + tbGreenDominator.Text = (map.Lighting.DominatorGreen ?? 0).ToString(format); + tbBlueDominator.Text = (map.Lighting.DominatorBlue ?? 0).ToString(format); + } + Show(); } @@ -68,16 +102,29 @@ private void BtnApply_LeftClick(object sender, System.EventArgs e) { map.Lighting.Ambient = tbAmbientNormal.DoubleValue; map.Lighting.Level = tbLevelNormal.DoubleValue; + map.Lighting.Ground = tbGroundNormal.DoubleValue; map.Lighting.Red = tbRedNormal.DoubleValue; map.Lighting.Green = tbGreenNormal.DoubleValue; map.Lighting.Blue = tbBlueNormal.DoubleValue; map.Lighting.IonAmbient = tbAmbientIS.DoubleValue; map.Lighting.IonLevel = tbLevelIS.DoubleValue; + map.Lighting.IonGround = tbGroundIS.DoubleValue; map.Lighting.IonRed = tbRedIS.DoubleValue; map.Lighting.IonGreen = tbGreenIS.DoubleValue; map.Lighting.IonBlue = tbBlueIS.DoubleValue; + if (Constants.UseCountries) + { + map.Lighting.DominatorAmbient = tbAmbientDominator.DoubleValue; + map.Lighting.DominatorAmbientChangeRate = tbAmbientChangeRateDominator.DoubleValue; + map.Lighting.DominatorLevel = tbLevelDominator.DoubleValue; + map.Lighting.DominatorGround = tbGroundDominator.DoubleValue; + map.Lighting.DominatorRed = tbRedDominator.DoubleValue; + map.Lighting.DominatorGreen = tbGreenDominator.DoubleValue; + map.Lighting.DominatorBlue = tbBlueDominator.DoubleValue; + } + Hide(); } }