Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
This commit is contained in:
+266
-8
@@ -1,8 +1,11 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -15,11 +18,11 @@ namespace Barotrauma
|
||||
protected GUITextBox saveNameBox, seedBox;
|
||||
|
||||
protected GUIButton loadGameButton;
|
||||
|
||||
|
||||
public Action<SubmarineInfo, string, string, CampaignSettings> StartNewGame;
|
||||
public Action<string> LoadGame;
|
||||
|
||||
protected enum CategoryFilter { All = 0, Vanilla = 1, Custom = 2 };
|
||||
protected enum CategoryFilter { All = 0, Vanilla = 1, Custom = 2 }
|
||||
protected CategoryFilter subFilter = CategoryFilter.All;
|
||||
|
||||
public GUIButton StartButton
|
||||
@@ -33,15 +36,11 @@ namespace Barotrauma
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
public GUITickBox EnableRadiationToggle { get; set; }
|
||||
public GUILayoutGroup CampaignSettingsContent { get; set; }
|
||||
|
||||
public CampaignSettings CurrentSettings = new CampaignSettings(element: null);
|
||||
public GUIButton CampaignCustomizeButton { get; set; }
|
||||
public GUIMessageBox CampaignCustomizeSettings { get; set; }
|
||||
|
||||
public GUITextBlock MaxMissionCountText;
|
||||
|
||||
public CampaignSetupUI(GUIComponent newGameContainer, GUIComponent loadGameContainer)
|
||||
{
|
||||
this.newGameContainer = newGameContainer;
|
||||
@@ -102,5 +101,264 @@ namespace Barotrauma
|
||||
|
||||
return saveFrame;
|
||||
}
|
||||
|
||||
public struct CampaignSettingElements
|
||||
{
|
||||
public SettingValue<bool> RadiationEnabled;
|
||||
public SettingValue<int> MaxMissionCount;
|
||||
public SettingValue<StartingBalanceAmount> StartingFunds;
|
||||
public SettingValue<GameDifficulty> Difficulty;
|
||||
public SettingValue<Identifier> StartItemSet;
|
||||
|
||||
public readonly CampaignSettings CreateSettings()
|
||||
{
|
||||
return new CampaignSettings(element: null)
|
||||
{
|
||||
RadiationEnabled = RadiationEnabled.GetValue(),
|
||||
MaxMissionCount = MaxMissionCount.GetValue(),
|
||||
StartingBalanceAmount = StartingFunds.GetValue(),
|
||||
Difficulty = Difficulty.GetValue(),
|
||||
StartItemSet = StartItemSet.GetValue()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct SettingValue<T>
|
||||
{
|
||||
private readonly Func<T> getter;
|
||||
private readonly Action<T> setter;
|
||||
|
||||
public T GetValue()
|
||||
{
|
||||
return getter.Invoke();
|
||||
}
|
||||
|
||||
public void SetValue(T value)
|
||||
{
|
||||
setter.Invoke(value);
|
||||
}
|
||||
|
||||
public SettingValue(Func<T> get, Action<T> set)
|
||||
{
|
||||
getter = get;
|
||||
setter = set;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly struct SettingCarouselElement<T>
|
||||
{
|
||||
public readonly LocalizedString Label;
|
||||
public readonly T Value;
|
||||
public readonly bool IsHidden;
|
||||
|
||||
public SettingCarouselElement(T value, string label, bool isHidden = false)
|
||||
{
|
||||
Value = value;
|
||||
Label = TextManager.Get(label).Fallback(label);
|
||||
IsHidden = isHidden;
|
||||
}
|
||||
}
|
||||
|
||||
protected static CampaignSettingElements CreateCampaignSettingList(GUIComponent parent, CampaignSettings prevSettings)
|
||||
{
|
||||
const float verticalSize = 0.14f;
|
||||
|
||||
GUILayoutGroup presetDropdownLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, verticalSize), parent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), presetDropdownLayout.RectTransform), TextManager.Get("campaignsettingpreset"));
|
||||
GUIDropDown presetDropdown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1f), presetDropdownLayout.RectTransform), elementCount: CampaignModePresets.List.Length);
|
||||
|
||||
presetDropdownLayout.RectTransform.MinSize = new Point(0, presetDropdown.Rect.Height);
|
||||
|
||||
foreach (CampaignSettings settings in CampaignModePresets.List)
|
||||
{
|
||||
string name = settings.PresetName;
|
||||
presetDropdown.AddItem(TextManager.Get($"preset.{name}").Fallback(name), settings);
|
||||
}
|
||||
|
||||
GUIListBox settingsList = new GUIListBox(new RectTransform(new Vector2(1f, 1f - verticalSize), parent.RectTransform))
|
||||
{
|
||||
Spacing = GUI.IntScale(5)
|
||||
};
|
||||
|
||||
SettingValue<bool> radiationEnabled = CreateTickbox(settingsList.Content, TextManager.Get("CampaignOption.EnableRadiation"), TextManager.Get("campaignoption.enableradiation.tooltip"), prevSettings.RadiationEnabled, verticalSize);
|
||||
|
||||
ImmutableArray<SettingCarouselElement<Identifier>> startingSetOptions = StartItemSet.Sets.OrderBy(s => s.Order).Select(set => new SettingCarouselElement<Identifier>(set.Identifier, $"startitemset.{set.Identifier}")).ToImmutableArray();
|
||||
SettingCarouselElement<Identifier> prevStartingSet = startingSetOptions.FirstOrNull(element => element.Value == prevSettings.StartItemSet) ?? startingSetOptions[1];
|
||||
SettingValue<Identifier> startingSetInput = CreateSelectionCarousel(settingsList.Content, TextManager.Get("startitemset"), TextManager.Get("startitemsettooltip"), prevStartingSet, verticalSize, startingSetOptions);
|
||||
|
||||
ImmutableArray<SettingCarouselElement<StartingBalanceAmount>> fundOptions = ImmutableArray.Create(
|
||||
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.High, "startingfunds.high"),
|
||||
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.Medium, "startingfunds.medium"),
|
||||
new SettingCarouselElement<StartingBalanceAmount>(StartingBalanceAmount.Low, "startingfunds.low")
|
||||
);
|
||||
|
||||
SettingCarouselElement<StartingBalanceAmount> prevStartingFund = fundOptions.FirstOrNull(element => element.Value == prevSettings.StartingBalanceAmount) ?? fundOptions[1];
|
||||
SettingValue<StartingBalanceAmount> startingFundsInput = CreateSelectionCarousel(settingsList.Content, TextManager.Get("startingfundsdescription"), TextManager.Get("startingfundstooltip"), prevStartingFund, verticalSize, fundOptions);
|
||||
|
||||
ImmutableArray<SettingCarouselElement<GameDifficulty>> difficultyOptions = ImmutableArray.Create(
|
||||
new SettingCarouselElement<GameDifficulty>(GameDifficulty.Easy, "difficulty.easy"),
|
||||
new SettingCarouselElement<GameDifficulty>(GameDifficulty.Medium, "difficulty.medium"),
|
||||
new SettingCarouselElement<GameDifficulty>(GameDifficulty.Hard, "difficulty.hard"),
|
||||
new SettingCarouselElement<GameDifficulty>(GameDifficulty.Hellish, "difficulty.hellish", isHidden: true)
|
||||
);
|
||||
|
||||
SettingCarouselElement<GameDifficulty> prevDifficulty = difficultyOptions.FirstOrNull(element => element.Value == prevSettings.Difficulty) ?? difficultyOptions[1];
|
||||
SettingValue<GameDifficulty> difficultyInput = CreateSelectionCarousel(settingsList.Content, TextManager.Get("leveldifficulty"), TextManager.Get("leveldifficultyexplanation"), prevDifficulty, verticalSize, difficultyOptions);
|
||||
|
||||
SettingValue<int> maxMissionCountInput = CreateGUINumberInputCarousel(settingsList.Content, TextManager.Get("maxmissioncount"), TextManager.Get("maxmissioncounttooltip"),
|
||||
prevSettings.MaxMissionCount,
|
||||
valueStep: 1, minValue: CampaignSettings.MinMissionCountLimit, maxValue: CampaignSettings.MaxMissionCountLimit,
|
||||
verticalSize);
|
||||
|
||||
presetDropdown.OnSelected = (selected, o) =>
|
||||
{
|
||||
if (o is CampaignSettings settings)
|
||||
{
|
||||
radiationEnabled.SetValue(settings.RadiationEnabled);
|
||||
maxMissionCountInput.SetValue(settings.MaxMissionCount);
|
||||
startingFundsInput.SetValue(settings.StartingBalanceAmount);
|
||||
difficultyInput.SetValue(settings.Difficulty);
|
||||
startingSetInput.SetValue(settings.StartItemSet);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return new CampaignSettingElements
|
||||
{
|
||||
RadiationEnabled = radiationEnabled,
|
||||
MaxMissionCount = maxMissionCountInput,
|
||||
StartingFunds = startingFundsInput,
|
||||
Difficulty = difficultyInput,
|
||||
StartItemSet = startingSetInput
|
||||
};
|
||||
|
||||
// Create a number input with plus and minus buttons because for some reason the default GUINumberInput buttons don't work when in a GUIMessageBox
|
||||
static SettingValue<int> CreateGUINumberInputCarousel(GUIComponent parent, LocalizedString description, LocalizedString tooltip, int defaultValue, int valueStep, int minValue, int maxValue, float verticalSize)
|
||||
{
|
||||
GUILayoutGroup inputContainer = CreateSettingBase(parent, description, tooltip, horizontalSize: 0.55f, verticalSize: verticalSize);
|
||||
|
||||
GUIButton minusButton = new GUIButton(new RectTransform(Vector2.One, inputContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
ClickSound = GUISoundType.Decrease,
|
||||
UserData = -valueStep
|
||||
};
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(Vector2.One, inputContainer.RectTransform, Anchor.Center), NumberType.Int, textAlignment: Alignment.Center, style: "GUITextBox",
|
||||
hidePlusMinusButtons: true)
|
||||
{
|
||||
IntValue = defaultValue,
|
||||
MinValueInt = minValue,
|
||||
MaxValueInt = maxValue
|
||||
};
|
||||
inputContainer.RectTransform.Parent.MinSize = new Point(0, numberInput.RectTransform.MinSize.Y);
|
||||
GUIButton plusButton = new GUIButton(new RectTransform(Vector2.One, inputContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
ClickSound = GUISoundType.Increase,
|
||||
UserData = valueStep
|
||||
};
|
||||
|
||||
minusButton.OnClicked = plusButton.OnClicked = ChangeValue;
|
||||
|
||||
bool ChangeValue(GUIButton btn, object userData)
|
||||
{
|
||||
if (!(userData is int change)) { return false; }
|
||||
|
||||
numberInput.IntValue += change;
|
||||
return true;
|
||||
}
|
||||
|
||||
return new SettingValue<int>(() => numberInput.IntValue, i => numberInput.IntValue = i);
|
||||
}
|
||||
|
||||
static SettingValue<T> CreateSelectionCarousel<T>(GUIComponent parent, LocalizedString description, LocalizedString tooltip, SettingCarouselElement<T> defaultValue, float verticalSize,
|
||||
ImmutableArray<SettingCarouselElement<T>> options)
|
||||
{
|
||||
GUILayoutGroup inputContainer = CreateSettingBase(parent, description, tooltip, horizontalSize: 0.55f, verticalSize: verticalSize);
|
||||
|
||||
GUIButton minusButton = new GUIButton(new RectTransform(Vector2.One, inputContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton", textAlignment: Alignment.Center) { UserData = -1 };
|
||||
GUIFrame inputFrame = new GUIFrame(new RectTransform(Vector2.One, inputContainer.RectTransform), style: null);
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(Vector2.One, inputFrame.RectTransform, Anchor.Center), NumberType.Int, textAlignment: Alignment.Center, style: "GUITextBox", hidePlusMinusButtons: true)
|
||||
{
|
||||
IntValue = options.IndexOf(defaultValue),
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = options.Length,
|
||||
Visible = false
|
||||
};
|
||||
inputContainer.RectTransform.Parent.MinSize = new Point(0, numberInput.RectTransform.MinSize.Y);
|
||||
GUITextBox inputLabel = new GUITextBox(new RectTransform(Vector2.One, inputFrame.RectTransform, Anchor.Center), text: defaultValue.Label.Value, textAlignment: Alignment.Center, createPenIcon: false)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
GUIButton plusButton = new GUIButton(new RectTransform(Vector2.One, inputContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center) { UserData = 1 };
|
||||
|
||||
minusButton.OnClicked = plusButton.OnClicked = ChangeValue;
|
||||
|
||||
bool ChangeValue(GUIButton btn, object userData)
|
||||
{
|
||||
if (!(userData is int change)) { return false; }
|
||||
|
||||
int hiddenOptions = 0;
|
||||
|
||||
for (int i = options.Length - 1; i >= 0; i--)
|
||||
{
|
||||
if (options[i].IsHidden)
|
||||
{
|
||||
hiddenOptions++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int limit = options.Length - hiddenOptions;
|
||||
|
||||
if (PlayerInput.IsShiftDown())
|
||||
{
|
||||
limit = options.Length;
|
||||
}
|
||||
|
||||
int newValue = MathUtils.PositiveModulo(Math.Clamp(numberInput.IntValue + change, min: -1, max: limit), limit);
|
||||
SetValue(newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetValue(int value)
|
||||
{
|
||||
numberInput.IntValue = value;
|
||||
inputLabel.Text = options[value].Label.Value;
|
||||
}
|
||||
|
||||
return new SettingValue<T>(() => options[numberInput.IntValue].Value, t => SetValue(options.IndexOf(e => Equals(e.Value, t))));
|
||||
}
|
||||
|
||||
static SettingValue<bool> CreateTickbox(GUIComponent parent, LocalizedString description, LocalizedString tooltip, bool defaultValue, float verticalSize)
|
||||
{
|
||||
GUILayoutGroup inputContainer = CreateSettingBase(parent, description, tooltip, 0.7f, verticalSize);
|
||||
GUILayoutGroup tickboxContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 1.0f), inputContainer.RectTransform), childAnchor: Anchor.Center);
|
||||
GUITickBox tickBox = new GUITickBox(new RectTransform(Vector2.One, tickboxContainer.RectTransform), string.Empty)
|
||||
{
|
||||
Selected = defaultValue,
|
||||
ToolTip = tooltip
|
||||
};
|
||||
tickBox.Box.IgnoreLayoutGroups = true;
|
||||
tickBox.Box.RectTransform.SetPosition(Anchor.CenterRight);
|
||||
inputContainer.RectTransform.Parent.MinSize = new Point(0, tickBox.RectTransform.MinSize.Y);
|
||||
return new SettingValue<bool>(() => tickBox.Selected, b => tickBox.Selected = b);
|
||||
}
|
||||
|
||||
static GUILayoutGroup CreateSettingBase(GUIComponent parent, LocalizedString description, LocalizedString tooltip, float horizontalSize, float verticalSize)
|
||||
{
|
||||
GUILayoutGroup settingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1f, verticalSize), parent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
GUITextBlock descriptionBlock = new GUITextBlock(new RectTransform(new Vector2(horizontalSize, 1f), settingHolder.RectTransform), description, font: parent.Rect.Width < 320 ? GUIStyle.SmallFont : GUIStyle.Font, wrap: true) { ToolTip = tooltip };
|
||||
GUILayoutGroup inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f - horizontalSize, 0.8f), settingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
RelativeSpacing = 0.05f,
|
||||
Stretch = true
|
||||
};
|
||||
inputContainer.RectTransform.IsFixedSize = true;
|
||||
settingHolder.RectTransform.MinSize = new Point(0, (int)descriptionBlock.TextSize.Y);
|
||||
return inputContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
-65
@@ -18,71 +18,35 @@ namespace Barotrauma
|
||||
var verticalLayout = new GUILayoutGroup(new RectTransform(Vector2.One, newGameContainer.RectTransform), isHorizontal: false)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.0f
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
|
||||
GUILayoutGroup nameSeedLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), verticalLayout.RectTransform), isHorizontal: false)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
GUILayoutGroup campaignSettingLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), verticalLayout.RectTransform), isHorizontal: false)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
|
||||
// New game
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.03f), verticalLayout.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SaveName"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomLeft);
|
||||
saveNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.03f), verticalLayout.RectTransform) { MinSize = new Point(0, 20) }, string.Empty)
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.03f), nameSeedLayout.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SaveName"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomLeft);
|
||||
saveNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.03f), nameSeedLayout.RectTransform) { MinSize = new Point(0, 20) }, string.Empty)
|
||||
{
|
||||
textFilterFunction = (string str) => { return ToolBox.RemoveInvalidFileNameChars(str); }
|
||||
textFilterFunction = ToolBox.RemoveInvalidFileNameChars
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.03f), verticalLayout.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("MapSeed"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomLeft);
|
||||
seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.03f), verticalLayout.RectTransform) { MinSize = new Point(0, 20) }, ToolBox.RandomSeed(8));
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.03f), nameSeedLayout.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("MapSeed"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomLeft);
|
||||
seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.03f), nameSeedLayout.RectTransform) { MinSize = new Point(0, 20) }, ToolBox.RandomSeed(8));
|
||||
|
||||
GUIFrame radiationBoxContainer
|
||||
= new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), verticalLayout.RectTransform), style: null);
|
||||
GUITickBox radiationEnabledTickBox = null;
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
radiationEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.5f), radiationBoxContainer.RectTransform, Anchor.Center), TextManager.Get("CampaignOption.EnableRadiation"), font: GUIStyle.Font)
|
||||
{
|
||||
Selected = true,
|
||||
OnSelected = box => true
|
||||
};
|
||||
}
|
||||
nameSeedLayout.RectTransform.MinSize = new Point(0, nameSeedLayout.Children.Sum(c => c.RectTransform.MinSize.Y));
|
||||
|
||||
var maxMissionCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), verticalLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
var maxMissionCountDescription = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), maxMissionCountSettingHolder.RectTransform), TextManager.Get("maxmissioncount", "missions"), wrap: true)
|
||||
{
|
||||
ToolTip = TextManager.Get("maxmissioncounttooltip")
|
||||
};
|
||||
int maxMissionCount = GameMain.NetworkMember.ServerSettings.MaxMissionCount;
|
||||
var maxMissionCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), maxMissionCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
var maxMissionCountButtons = new GUIButton[2];
|
||||
maxMissionCountButtons[0]
|
||||
= new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), maxMissionCountContainer.RectTransform),
|
||||
style: "GUIButtonToggleLeft");
|
||||
var maxMissionCountText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), maxMissionCountContainer.RectTransform), "0", textAlignment: Alignment.Center, style: "GUITextBox");
|
||||
CampaignSettingElements elements = CreateCampaignSettingList(campaignSettingLayout, CampaignSettings.Empty);
|
||||
|
||||
void updateMissionCountText()
|
||||
{
|
||||
maxMissionCount = MathHelper.Clamp(maxMissionCount,
|
||||
CampaignSettings.MinMissionCountLimit,
|
||||
CampaignSettings.MaxMissionCountLimit);
|
||||
|
||||
maxMissionCountText.Text = maxMissionCount.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
maxMissionCountButtons[1]
|
||||
= new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), maxMissionCountContainer.RectTransform),
|
||||
style: "GUIButtonToggleRight");
|
||||
maxMissionCountButtons[0].OnClicked = (button, o) =>
|
||||
{
|
||||
maxMissionCount--;
|
||||
updateMissionCountText();
|
||||
return false;
|
||||
};
|
||||
maxMissionCountButtons[1].OnClicked = (button, o) =>
|
||||
{
|
||||
maxMissionCount++;
|
||||
updateMissionCountText();
|
||||
return false;
|
||||
};
|
||||
updateMissionCountText();
|
||||
maxMissionCountSettingHolder.Children.ForEach(c => c.ToolTip = maxMissionCountSettingHolder.ToolTip);
|
||||
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.04f),
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.1f),
|
||||
verticalLayout.RectTransform) { MaxSize = new Point(int.MaxValue, 60) }, childAnchor: Anchor.BottomRight, isHorizontal: true);
|
||||
|
||||
StartButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1f), buttonContainer.RectTransform, Anchor.BottomRight), TextManager.Get("StartCampaignButton"))
|
||||
@@ -99,7 +63,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.NetLobbyScreen.SelectedSub == null) { return false; }
|
||||
selectedSub = GameMain.NetLobbyScreen.SelectedSub;
|
||||
|
||||
|
||||
if (selectedSub.SubmarineClass == SubmarineClass.Undefined)
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("error"), TextManager.Get("undefinedsubmarineselected"));
|
||||
@@ -115,11 +79,7 @@ namespace Barotrauma
|
||||
string savePath = SaveUtil.CreateSavePath(SaveUtil.SaveType.Multiplayer, saveNameBox.Text);
|
||||
bool hasRequiredContentPackages = selectedSub.RequiredContentPackagesInstalled;
|
||||
|
||||
CampaignSettings settings = new CampaignSettings
|
||||
{
|
||||
RadiationEnabled = radiationEnabledTickBox?.Selected ?? GameMain.NetworkMember.ServerSettings.RadiationEnabled,
|
||||
MaxMissionCount = maxMissionCount
|
||||
};
|
||||
CampaignSettings settings = elements.CreateSettings();
|
||||
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages)
|
||||
{
|
||||
@@ -172,12 +132,16 @@ namespace Barotrauma
|
||||
};
|
||||
StartButton.RectTransform.MaxSize = RectTransform.MaxPoint;
|
||||
StartButton.Children.ForEach(c => c.RectTransform.MaxSize = RectTransform.MaxPoint);
|
||||
|
||||
|
||||
InitialMoneyText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1f), buttonContainer.RectTransform), "", font: GUIStyle.SmallFont, textColor: GUIStyle.Green)
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
int initialMoney = CampaignMode.InitialMoney;
|
||||
int initialMoney = 8000;
|
||||
if (CampaignModePresets.Definitions.TryGetValue(nameof(StartingBalanceAmount).ToIdentifier(), out var definition))
|
||||
{
|
||||
initialMoney = definition.GetInt(elements.StartingFunds.GetValue().ToIdentifier());
|
||||
}
|
||||
if (GameMain.NetLobbyScreen.SelectedSub != null)
|
||||
{
|
||||
initialMoney -= GameMain.NetLobbyScreen.SelectedSub.Price;
|
||||
@@ -238,6 +202,7 @@ namespace Barotrauma
|
||||
|
||||
saveList = new GUIListBox(new RectTransform(Vector2.One, leftColumn.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = SelectSaveFile
|
||||
};
|
||||
|
||||
@@ -257,7 +222,7 @@ namespace Barotrauma
|
||||
file1WriteTime = File.GetLastWriteTime(file1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
{
|
||||
//do nothing - DateTime.MinValue will be used and the element will get sorted at the bottom of the list
|
||||
};
|
||||
try
|
||||
|
||||
+54
-77
@@ -1,12 +1,11 @@
|
||||
using Barotrauma.Tutorials;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.IO;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Barotrauma.IO;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Globalization;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -142,7 +141,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("MapSeed"), font: GUIStyle.SubHeadingFont);
|
||||
seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, ToolBox.RandomSeed(8));
|
||||
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SelectedSub"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
var moddedDropdown = new GUIDropDown(new RectTransform(new Vector2(1f, 0.02f), leftColumn.RectTransform), "", 3);
|
||||
@@ -155,8 +154,12 @@ namespace Barotrauma
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform)) { ScrollBarVisible = true };
|
||||
|
||||
subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
ScrollBarVisible = true
|
||||
};
|
||||
|
||||
var searchTitle = new GUITextBlock(new RectTransform(new Vector2(0.001f, 1.0f), filterContainer.RectTransform), TextManager.Get("serverlog.filter"), textAlignment: Alignment.CenterLeft, font: GUIStyle.Font);
|
||||
var searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 1.0f), filterContainer.RectTransform, Anchor.CenterRight), font: GUIStyle.Font, createClearButton: true);
|
||||
@@ -191,7 +194,7 @@ namespace Barotrauma
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
int initialMoney = CampaignMode.InitialMoney;
|
||||
int initialMoney = CurrentSettings.InitialMoney;
|
||||
if (subList.SelectedData is SubmarineInfo subInfo)
|
||||
{
|
||||
initialMoney -= subInfo.Price;
|
||||
@@ -200,12 +203,25 @@ namespace Barotrauma
|
||||
return TextManager.GetWithVariable("campaignstartingmoney", "[money]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", initialMoney));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CampaignCustomizeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1f), firstPageButtonContainer.RectTransform, Anchor.CenterLeft), TextManager.Get("SettingsButton"))
|
||||
{
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
CreateCustomizeWindow();
|
||||
CreateCustomizeWindow(CurrentSettings, settings =>
|
||||
{
|
||||
CampaignSettings prevSettings = CurrentSettings;
|
||||
CurrentSettings = settings;
|
||||
if (prevSettings.InitialMoney != settings.InitialMoney)
|
||||
{
|
||||
object selectedData = subList.SelectedData;
|
||||
UpdateSubList(SubmarineInfo.SavedSubmarines);
|
||||
if (selectedData is SubmarineInfo selectedSub && selectedSub.Price <= CurrentSettings.InitialMoney)
|
||||
{
|
||||
subList.Select(selectedData);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -218,7 +234,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var disclaimerBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.8f), rightColumn.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(5) }, style: "GUINotificationButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
@@ -353,54 +369,21 @@ namespace Barotrauma
|
||||
StealRandomizeButton(CharacterMenus[i], jobTextContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCustomizeWindow()
|
||||
|
||||
private void CreateCustomizeWindow(CampaignSettings prevSettings, Action<CampaignSettings> onClosed = null)
|
||||
{
|
||||
CampaignCustomizeSettings = new GUIMessageBox("", "", new LocalizedString[] { TextManager.Get("OK") }, new Vector2(0.2f, 0.2f));
|
||||
CampaignCustomizeSettings.Buttons[0].OnClicked += CampaignCustomizeSettings.Close;
|
||||
CampaignCustomizeSettings = new GUIMessageBox("", "", new[] { TextManager.Get("OK") }, new Vector2(0.25f, 0.3f), minSize: new Point(450, 350));
|
||||
|
||||
CampaignSettingsContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), CampaignCustomizeSettings.Content.RectTransform, Anchor.TopCenter))
|
||||
{
|
||||
RelativeSpacing = 0.1f
|
||||
};
|
||||
GUILayoutGroup campaignSettingContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.8f), CampaignCustomizeSettings.Content.RectTransform, Anchor.TopCenter));
|
||||
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
bool prevRadiationToggleEnabled = EnableRadiationToggle?.Selected ?? true;
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), CampaignSettingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUIStyle.Font)
|
||||
{
|
||||
Selected = prevRadiationToggleEnabled,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
}
|
||||
var maxMissionCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.3f), CampaignSettingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true,
|
||||
ToolTip = TextManager.Get("maxmissioncounttooltip")
|
||||
};
|
||||
var maxMissionCountDescription = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), maxMissionCountSettingHolder.RectTransform), TextManager.Get("maxmissioncount", "missions"), wrap: true);
|
||||
var maxMissionCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), maxMissionCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
var maxMissionCountButtons = new GUIButton[2];
|
||||
maxMissionCountButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleLeft")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text.SanitizedValue) - 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
RichString prevMaxMissionCountText = MaxMissionCountText?.Text ?? CampaignSettings.DefaultMaxMissionCount.ToString();
|
||||
MaxMissionCountText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), maxMissionCountContainer.RectTransform), prevMaxMissionCountText, textAlignment: Alignment.Center, style: "GUITextBox");
|
||||
maxMissionCountButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleRight")
|
||||
CampaignSettingElements elements = CreateCampaignSettingList(campaignSettingContent, prevSettings);
|
||||
CampaignCustomizeSettings.Buttons[0].OnClicked += (button, o) =>
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text.SanitizedValue) + 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
onClosed?.Invoke(elements.CreateSettings());
|
||||
return CampaignCustomizeSettings.Close(button, o);
|
||||
};
|
||||
maxMissionCountContainer.Children.ForEach(c => c.ToolTip = maxMissionCountSettingHolder.ToolTip);
|
||||
}
|
||||
|
||||
private static void StealRandomizeButton(CharacterInfo.AppearanceCustomizationMenu menu, GUIComponent parent)
|
||||
@@ -412,7 +395,7 @@ namespace Barotrauma
|
||||
randomizeButton.RectTransform.Parent = parent.RectTransform;
|
||||
randomizeButton.RectTransform.RelativeSize = Vector2.One * 1.3f;
|
||||
}
|
||||
|
||||
|
||||
private bool FinishSetup(GUIButton btn, object userdata)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(saveNameBox.Text))
|
||||
@@ -420,7 +403,7 @@ namespace Barotrauma
|
||||
saveNameBox.Flash(GUIStyle.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SubmarineInfo selectedSub = null;
|
||||
|
||||
if (!(subList.SelectedData is SubmarineInfo)) { return false; }
|
||||
@@ -443,16 +426,7 @@ namespace Barotrauma
|
||||
string savePath = SaveUtil.CreateSavePath(SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
bool hasRequiredContentPackages = selectedSub.RequiredContentPackagesInstalled;
|
||||
|
||||
CampaignSettings settings = new CampaignSettings();
|
||||
settings.RadiationEnabled = EnableRadiationToggle?.Selected ?? false;
|
||||
if (MaxMissionCountText != null && Int32.TryParse(MaxMissionCountText.Text.SanitizedValue, out int missionCount))
|
||||
{
|
||||
settings.MaxMissionCount = missionCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.MaxMissionCount = CampaignSettings.DefaultMaxMissionCount;
|
||||
}
|
||||
CampaignSettings settings = CurrentSettings;
|
||||
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages)
|
||||
{
|
||||
@@ -499,7 +473,7 @@ namespace Barotrauma
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void RandomizeSeed()
|
||||
{
|
||||
seedBox.Text = ToolBox.RandomSeed(8);
|
||||
@@ -509,7 +483,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (GUIComponent child in subList.Content.Children)
|
||||
{
|
||||
var sub = child.UserData as SubmarineInfo;
|
||||
SubmarineInfo sub = child.UserData as SubmarineInfo;
|
||||
if (sub == null) { return; }
|
||||
child.Visible = string.IsNullOrEmpty(filter) || sub.DisplayName.Contains(filter.ToLower(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
@@ -523,7 +497,7 @@ namespace Barotrauma
|
||||
|
||||
if (!(obj is SubmarineInfo sub)) { return true; }
|
||||
#if !DEBUG
|
||||
if (sub.Price > CampaignMode.InitialMoney && !GameMain.DebugDraw)
|
||||
if (sub.Price > CurrentSettings.InitialMoney && !GameMain.DebugDraw)
|
||||
{
|
||||
SetPage(0);
|
||||
nextButton.Enabled = false;
|
||||
@@ -554,10 +528,10 @@ namespace Barotrauma
|
||||
subsToShow = submarines.Where(s => s.IsCampaignCompatibleIgnoreClass && Path.GetDirectoryName(Path.GetFullPath(s.FilePath)) != downloadFolder).ToList();
|
||||
}
|
||||
|
||||
subsToShow.Sort((s1, s2) =>
|
||||
subsToShow.Sort((s1, s2) =>
|
||||
{
|
||||
int p1 = s1.Price > CampaignMode.InitialMoney ? 10 : 0;
|
||||
int p2 = s2.Price > CampaignMode.InitialMoney ? 10 : 0;
|
||||
int p1 = s1.Price > CurrentSettings.InitialMoney ? 10 : 0;
|
||||
int p2 = s2.Price > CurrentSettings.InitialMoney ? 10 : 0;
|
||||
return p1.CompareTo(p2) * 100 + s1.Name.CompareTo(s2.Name);
|
||||
});
|
||||
|
||||
@@ -572,7 +546,7 @@ namespace Barotrauma
|
||||
ToolTip = sub.Description,
|
||||
UserData = sub
|
||||
};
|
||||
|
||||
|
||||
if (!sub.RequiredContentPackagesInstalled)
|
||||
{
|
||||
textBlock.TextColor = Color.Lerp(textBlock.TextColor, Color.DarkRed, .5f);
|
||||
@@ -582,13 +556,13 @@ namespace Barotrauma
|
||||
var priceText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight),
|
||||
TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", sub.Price)), textAlignment: Alignment.CenterRight, font: GUIStyle.SmallFont)
|
||||
{
|
||||
TextColor = sub.Price > CampaignMode.InitialMoney ? GUIStyle.Red : textBlock.TextColor * 0.8f,
|
||||
TextColor = sub.Price > CurrentSettings.InitialMoney ? GUIStyle.Red : textBlock.TextColor * 0.8f,
|
||||
ToolTip = textBlock.ToolTip
|
||||
};
|
||||
#if !DEBUG
|
||||
if (!GameMain.DebugDraw)
|
||||
{
|
||||
if (sub.Price > CampaignMode.InitialMoney || !sub.IsCampaignCompatible)
|
||||
if (sub.Price > CurrentSettings.InitialMoney || !sub.IsCampaignCompatible)
|
||||
{
|
||||
textBlock.CanBeFocused = false;
|
||||
textBlock.TextColor *= 0.5f;
|
||||
@@ -598,7 +572,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (SubmarineInfo.SavedSubmarines.Any())
|
||||
{
|
||||
var validSubs = subsToShow.Where(s => s.IsCampaignCompatible && s.Price <= CampaignMode.InitialMoney).ToList();
|
||||
var validSubs = subsToShow.Where(s => s.IsCampaignCompatible && s.Price <= CurrentSettings.InitialMoney).ToList();
|
||||
if (validSubs.Count > 0)
|
||||
{
|
||||
subList.Select(validSubs[Rand.Int(validSubs.Count)]);
|
||||
@@ -625,6 +599,7 @@ namespace Barotrauma
|
||||
|
||||
saveList = new GUIListBox(new RectTransform(Vector2.One, leftColumn.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = SelectSaveFile
|
||||
};
|
||||
|
||||
@@ -650,8 +625,9 @@ namespace Barotrauma
|
||||
{
|
||||
var saveFrame = CreateSaveElement(saveInfo);
|
||||
if (saveFrame == null) { continue; }
|
||||
|
||||
|
||||
XDocument doc = SaveUtil.LoadGameSessionDoc(saveInfo.FilePath);
|
||||
|
||||
if (doc?.Root == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error loading save file \"" + saveInfo.FilePath + "\". The file may be corrupted.");
|
||||
@@ -725,9 +701,10 @@ namespace Barotrauma
|
||||
|
||||
string subName = doc.Root.GetAttributeString("submarine", "");
|
||||
string saveTime = doc.Root.GetAttributeString("savetime", "unknown");
|
||||
DateTime? time = null;
|
||||
if (long.TryParse(saveTime, out long unixTime))
|
||||
{
|
||||
DateTime time = ToolBox.Epoch.ToDateTime(unixTime);
|
||||
time = ToolBox.Epoch.ToDateTime(unixTime);
|
||||
saveTime = time.ToString();
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ namespace Barotrauma
|
||||
tickBox.OnSelected += (GUITickBox tb) =>
|
||||
{
|
||||
if (!Campaign.AllowedToManageCampaign(Networking.ClientPermissions.ManageMap)) { return false; }
|
||||
|
||||
|
||||
if (tb.Selected)
|
||||
{
|
||||
Campaign.Map.CurrentLocation.SelectMission(mission);
|
||||
@@ -549,7 +549,7 @@ namespace Barotrauma
|
||||
{
|
||||
GameMain.Client?.SendCampaignState();
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
};
|
||||
missionTickBoxes.Add(tickBox);
|
||||
|
||||
@@ -729,7 +729,15 @@ namespace Barotrauma
|
||||
break;
|
||||
case CampaignMode.InteractionType.PurchaseSub:
|
||||
if (submarineSelection == null) submarineSelection = new SubmarineSelection(false, () => Campaign.ShowCampaignUI = false, tabs[(int)CampaignMode.InteractionType.PurchaseSub].RectTransform);
|
||||
submarineSelection.RefreshSubmarineDisplay(true);
|
||||
submarineSelection.RefreshSubmarineDisplay(true, setTransferOptionToTrue: true);
|
||||
break;
|
||||
case CampaignMode.InteractionType.Map:
|
||||
//refresh mission rewards (may have been changed by e.g. a pending submarine switch)
|
||||
foreach (GUITextBlock rewardText in missionRewardTexts)
|
||||
{
|
||||
Mission mission = (Mission)rewardText.UserData;
|
||||
rewardText.Text = mission.GetMissionRewardText(Submarine.MainSub);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -2280,7 +2280,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var colorLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), colorComponentLabels[i],
|
||||
font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight),
|
||||
GUINumberInput.NumberType.Int, relativeButtonAreaWidth: 0.25f)
|
||||
NumberType.Int, relativeButtonAreaWidth: 0.25f)
|
||||
{
|
||||
Font = GUIStyle.SmallFont
|
||||
};
|
||||
@@ -2858,7 +2858,10 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadRagdoll"), "", new LocalizedString[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxRelSize);
|
||||
loadBox.Buttons[0].OnClicked += loadBox.Close;
|
||||
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform, Anchor.TopCenter));
|
||||
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform, Anchor.TopCenter))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var deleteButton = loadBox.Buttons[2];
|
||||
deleteButton.Enabled = false;
|
||||
void PopulateListBox()
|
||||
@@ -2996,7 +2999,10 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
var loadBox = new GUIMessageBox(GetCharacterEditorTranslation("LoadAnimation"), "", new LocalizedString[] { TextManager.Get("Cancel"), TextManager.Get("Load"), TextManager.Get("Delete") }, messageBoxRelSize);
|
||||
loadBox.Buttons[0].OnClicked += loadBox.Close;
|
||||
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform));
|
||||
var listBox = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.6f), loadBox.Content.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var deleteButton = loadBox.Buttons[2];
|
||||
deleteButton.Enabled = false;
|
||||
// Type filtering
|
||||
|
||||
@@ -482,7 +482,10 @@ namespace Barotrauma.CharacterEditor
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1f), limbEditLayout.RectTransform), GetCharacterEditorTranslation("Limbs"), font: GUIStyle.SubHeadingFont);
|
||||
var limbsList = new GUIListBox(new RectTransform(new Vector2(1, 0.45f), content.RectTransform));
|
||||
var limbsList = new GUIListBox(new RectTransform(new Vector2(1, 0.45f), content.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var removeLimbButton = new GUIButton(new RectTransform(new Vector2(0.05f, 1.0f), limbEditLayout.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton")
|
||||
{
|
||||
OnClicked = (b, d) =>
|
||||
@@ -523,7 +526,7 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
var element = new GUIFrame(new RectTransform(new Vector2(0.22f, 1), inputArea.RectTransform) { MinSize = new Point(50, 0), MaxSize = new Point(150, 50) }, style: null);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), GUI.RectComponentLabels[i], font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Int)
|
||||
GUINumberInput numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), NumberType.Int)
|
||||
{
|
||||
Font = GUIStyle.SmallFont
|
||||
};
|
||||
@@ -659,7 +662,10 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
var jointsList = new GUIListBox(new RectTransform(new Vector2(1, 0.45f), content.RectTransform));
|
||||
var jointsList = new GUIListBox(new RectTransform(new Vector2(1, 0.45f), content.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var removeJointButton = new GUIButton(new RectTransform(new Point(jointButtonElement.Rect.Height, jointButtonElement.Rect.Height), jointButtonElement.RectTransform), style: "GUIMinusButton")
|
||||
{
|
||||
OnClicked = (b, d) =>
|
||||
@@ -863,7 +869,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var limbTypeField = GUI.CreateEnumField(limbType, elementSize, GetCharacterEditorTranslation("LimbType"), group.RectTransform, font: GUIStyle.Font);
|
||||
var sourceRectField = GUI.CreateRectangleField(sourceRect ?? new Rectangle(0, 100 * LimbGUIElements.Count, 100, 100), elementSize, GetCharacterEditorTranslation("SourceRectangle"), group.RectTransform, font: GUIStyle.Font);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("ID"));
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), idField.RectTransform, Anchor.TopRight), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = byte.MaxValue,
|
||||
@@ -912,7 +918,7 @@ namespace Barotrauma.CharacterEditor
|
||||
};
|
||||
var limb1Field = new GUIFrame(new RectTransform(new Point(group.Rect.Width, elementSize), group.RectTransform), style: null);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("LimbWithIndex").Replace("[index]", "1"));
|
||||
var limb1InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
|
||||
var limb1InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb1Field.RectTransform, Anchor.TopRight), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = byte.MaxValue,
|
||||
@@ -920,7 +926,7 @@ namespace Barotrauma.CharacterEditor
|
||||
};
|
||||
var limb2Field = new GUIFrame(new RectTransform(new Point(group.Rect.Width, elementSize), group.RectTransform), style: null);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("LimbWithIndex").Replace("[index]", "2"));
|
||||
var limb2InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopRight), GUINumberInput.NumberType.Int)
|
||||
var limb2InputField = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1), limb2Field.RectTransform, Anchor.TopRight), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = byte.MaxValue,
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// attach number inputs to our generated parent elements
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.B };
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), NumberType.Int) { IntValue = BackgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), NumberType.Int) { IntValue = BackgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), NumberType.Int) { IntValue = BackgroundColor.B };
|
||||
|
||||
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
|
||||
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public static GUIMessageBox AskForConfirmation(LocalizedString header, LocalizedString body, Func<bool> onConfirm)
|
||||
public static GUIMessageBox AskForConfirmation(LocalizedString header, LocalizedString body, Func<bool> onConfirm, GUISoundType? overrideConfirmButtonSound = null)
|
||||
{
|
||||
LocalizedString[] buttons = { TextManager.Get("Ok"), TextManager.Get("Cancel") };
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, buttons);
|
||||
@@ -244,6 +244,10 @@ namespace Barotrauma
|
||||
msgBox.Close();
|
||||
return true;
|
||||
};
|
||||
if (overrideConfirmButtonSound.HasValue)
|
||||
{
|
||||
msgBox.Buttons[0].ClickSound = overrideConfirmButtonSound.Value;
|
||||
}
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
@@ -818,7 +822,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (type == typeof(float) || type == typeof(int))
|
||||
{
|
||||
GUINumberInput valueInput = new GUINumberInput(new RectTransform(Vector2.One, layout.RectTransform), GUINumberInput.NumberType.Float) { FloatValue = (float) (newValue ?? 0.0f) };
|
||||
GUINumberInput valueInput = new GUINumberInput(new RectTransform(Vector2.One, layout.RectTransform), NumberType.Float) { FloatValue = (float) (newValue ?? 0.0f) };
|
||||
valueInput.OnValueChanged += component => { newValue = component.FloatValue; };
|
||||
}
|
||||
else if (type == typeof(bool))
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Barotrauma
|
||||
DrawMap(graphics, spriteBatch, deltaTime);
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("DrawMap", sw.ElapsedTicks);
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
|
||||
@@ -166,7 +166,7 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("DrawHUD", sw.ElapsedTicks);
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:HUD", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
}
|
||||
|
||||
@@ -179,6 +179,9 @@ namespace Barotrauma
|
||||
|
||||
GameMain.ParticleManager.UpdateTransforms();
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
GameMain.LightManager.ObstructVision =
|
||||
Character.Controlled != null &&
|
||||
Character.Controlled.ObstructVision &&
|
||||
@@ -186,6 +189,10 @@ namespace Barotrauma
|
||||
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled?.CursorWorldPosition ?? Vector2.Zero);
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:LOS", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
graphics.Clear(Color.Transparent);
|
||||
@@ -197,9 +204,17 @@ namespace Barotrauma
|
||||
Submarine.DrawPaintedColors(spriteBatch, false);
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackStructures", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam, renderTarget);
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:Lighting", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
graphics.SetRenderTarget(renderTargetBackground);
|
||||
if (Level.Loaded == null)
|
||||
@@ -229,6 +244,10 @@ namespace Barotrauma
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackLevel", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//Start drawing to the normal render target (stuff that can't be seen through the LOS effect)
|
||||
@@ -249,6 +268,10 @@ namespace Barotrauma
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackCharactersItems", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
DrawDeformed(firstPass: true);
|
||||
DrawDeformed(firstPass: false);
|
||||
@@ -267,8 +290,16 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:DeformableCharacters", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
Level.Loaded?.DrawFront(spriteBatch, cam);
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontLevel", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
|
||||
graphics.SetRenderTarget(renderTargetWater);
|
||||
|
||||
@@ -303,6 +334,10 @@ namespace Barotrauma
|
||||
WaterRenderer.Instance.RenderAir(graphics, cam, renderTarget, Cam.ShaderTransform);
|
||||
graphics.DepthStencilState = DepthStencilState.None;
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontParticles", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.NonPremultiplied, SamplerState.LinearWrap,
|
||||
null, null,
|
||||
@@ -311,10 +346,18 @@ namespace Barotrauma
|
||||
Submarine.DrawDamageable(spriteBatch, damageEffect, false);
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontDamageable", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
Submarine.DrawFront(spriteBatch, false, null);
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontStructuresItems", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
//draw additive particles that are inside a sub
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
|
||||
@@ -350,6 +393,10 @@ namespace Barotrauma
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontMisc", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
|
||||
if (GameMain.LightManager.LosEnabled && GameMain.LightManager.LosMode != LosMode.None && Lights.LightManager.ViewTarget != null)
|
||||
{
|
||||
GameMain.LightManager.LosEffect.CurrentTechnique = GameMain.LightManager.LosEffect.Techniques["LosShader"];
|
||||
@@ -458,6 +505,10 @@ namespace Barotrauma
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Lerp(Color.TransparentBlack, Color.Black, fadeToBlackState), isFilled: true);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:PostProcess", sw.ElapsedTicks);
|
||||
sw.Restart();
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific(double deltaTime)
|
||||
|
||||
@@ -34,12 +34,16 @@ namespace Barotrauma
|
||||
|
||||
private readonly GUITickBox lightingEnabled, cursorLightEnabled, allowInvalidOutpost, mirrorLevel;
|
||||
|
||||
private readonly GUIDropDown selectedSubDropDown;
|
||||
|
||||
private Sprite editingSprite;
|
||||
|
||||
private LightSource pointerLightSource;
|
||||
|
||||
private readonly Color[] tunnelDebugColors = new Color[] { Color.White, Color.Cyan, Color.LightGreen, Color.Red, Color.LightYellow, Color.LightSeaGreen };
|
||||
|
||||
private LevelData currentLevelData;
|
||||
|
||||
public LevelEditorScreen()
|
||||
{
|
||||
Cam = new Camera()
|
||||
@@ -55,19 +59,26 @@ namespace Barotrauma
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
|
||||
paramsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), paddedLeftPanel.RectTransform));
|
||||
paramsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
paramsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
selectedParams = obj as LevelGenerationParams;
|
||||
currentLevelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
editorContainer.ClearChildren();
|
||||
SortLevelObjectsList(selectedParams);
|
||||
SortLevelObjectsList(currentLevelData);
|
||||
new SerializableEntityEditor(editorContainer.Content.RectTransform, selectedParams, false, true, elementHeight: 20);
|
||||
return true;
|
||||
};
|
||||
|
||||
var ruinTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.ruinparams"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
ruinParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform));
|
||||
ruinParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
ruinParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateOutpostGenerationParamsEditor(obj as OutpostGenerationParams);
|
||||
@@ -76,7 +87,10 @@ namespace Barotrauma
|
||||
|
||||
var caveTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.caveparams"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
caveParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform));
|
||||
caveParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
caveParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateCaveParamsEditor(obj as CaveGenerationParams);
|
||||
@@ -86,7 +100,10 @@ namespace Barotrauma
|
||||
var outpostTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.outpostparams"), font: GUIStyle.SubHeadingFont);
|
||||
GUITextBlock.AutoScaleAndNormalize(ruinTitle, caveTitle, outpostTitle);
|
||||
|
||||
outpostParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform));
|
||||
outpostParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true
|
||||
};
|
||||
outpostParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateOutpostGenerationParamsEditor(obj as OutpostGenerationParams);
|
||||
@@ -149,7 +166,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
if(seedBox == null) { return false; }
|
||||
if (seedBox == null) { return false; }
|
||||
seedBox.Text = GetLevelSeed();
|
||||
return true;
|
||||
}
|
||||
@@ -168,6 +185,16 @@ namespace Barotrauma
|
||||
Vector2 GetSeedElementRelativeSize() => new Vector2(0.5f * (1.0f - randomizeButtonRelativeSize.X), 1.0f);
|
||||
static string GetLevelSeed() => ToolBox.RandomSeed(8);
|
||||
|
||||
var subDropDownContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.02f), paddedRightPanel.RectTransform), isHorizontal: true);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), subDropDownContainer.RectTransform), TextManager.Get("submarine"));
|
||||
selectedSubDropDown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1.0f), subDropDownContainer.RectTransform));
|
||||
foreach (SubmarineInfo sub in SubmarineInfo.SavedSubmarines)
|
||||
{
|
||||
if (sub.Type != SubmarineType.Player) { continue; }
|
||||
selectedSubDropDown.AddItem(sub.DisplayName, userData: sub);
|
||||
}
|
||||
subDropDownContainer.RectTransform.MinSize = new Point(0, selectedSubDropDown.RectTransform.MinSize.Y);
|
||||
|
||||
mirrorLevel = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.02f), paddedRightPanel.RectTransform), TextManager.Get("mirrorentityx"));
|
||||
|
||||
allowInvalidOutpost = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.025f), paddedRightPanel.RectTransform),
|
||||
@@ -183,11 +210,18 @@ namespace Barotrauma
|
||||
{
|
||||
bool wasLevelLoaded = Level.Loaded != null;
|
||||
Submarine.Unload();
|
||||
|
||||
if (selectedSubDropDown.SelectedData is SubmarineInfo subInfo)
|
||||
{
|
||||
Submarine.MainSub = new Submarine(subInfo);
|
||||
}
|
||||
GameMain.LightManager.ClearLights();
|
||||
LevelData levelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
levelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
levelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
|
||||
Level.Generate(levelData, mirror: mirrorLevel.Selected);
|
||||
currentLevelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
currentLevelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
currentLevelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
|
||||
var dummyLocations = GameSession.CreateDummyLocations(seed: currentLevelData.Seed);
|
||||
Level.Generate(currentLevelData, mirror: mirrorLevel.Selected, startLocation: dummyLocations[0], endLocation: dummyLocations[1]);
|
||||
Submarine.MainSub?.SetPosition(Level.Loaded.StartPosition);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
if (!wasLevelLoaded || Cam.Position.X < 0 || Cam.Position.Y < 0 || Cam.Position.Y > Level.Loaded.Size.X || Cam.Position.Y > Level.Loaded.Size.Y)
|
||||
{
|
||||
@@ -225,7 +259,7 @@ namespace Barotrauma
|
||||
var nonPlayerFiles = ContentPackageManager.EnabledPackages.All.SelectMany(p => p
|
||||
.GetFiles<BaseSubFile>()
|
||||
.Where(f => !(f is SubmarineFile))).ToArray();
|
||||
SubmarineInfo subInfo = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == GameSettings.CurrentConfig.QuickStartSub);
|
||||
SubmarineInfo subInfo = selectedSubDropDown.SelectedData as SubmarineInfo;
|
||||
subInfo ??= SubmarineInfo.SavedSubmarines.GetRandomUnsynced(s =>
|
||||
s.IsPlayer && !s.HasTag(SubmarineTag.Shuttle) &&
|
||||
!nonPlayerFiles.Any(f => f.Path == s.FilePath));
|
||||
@@ -256,6 +290,7 @@ namespace Barotrauma
|
||||
|
||||
levelObjectList = new GUIListBox(new RectTransform(new Vector2(0.99f, 0.85f), bottomPanel.RectTransform, Anchor.Center))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
UseGridLayout = true
|
||||
};
|
||||
levelObjectList.OnSelected += (GUIComponent component, object obj) =>
|
||||
@@ -417,11 +452,11 @@ namespace Barotrauma
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", selectedParams.Identifier.Value), textAlignment: Alignment.Center);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = caveGenerationParams.GetCommonness(selectedParams, abyss: false),
|
||||
FloatValue = caveGenerationParams.GetCommonness(currentLevelData, abyss: false),
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
caveGenerationParams.OverrideCommonness[selectedParams.Identifier] = numberInput.FloatValue;
|
||||
@@ -478,18 +513,18 @@ namespace Barotrauma
|
||||
var moduleLabel = new GUITextBlock(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(70 * GUI.Scale))), TextManager.Get("submarinetype.outpostmodules"), font: GUIStyle.SubHeadingFont);
|
||||
outpostParamsEditor.AddCustomContent(moduleLabel, 100);
|
||||
|
||||
foreach (KeyValuePair<Identifier, int> moduleCount in outpostGenerationParams.ModuleCounts)
|
||||
foreach (var moduleCount in outpostGenerationParams.ModuleCounts)
|
||||
{
|
||||
var moduleCountGroup = new GUILayoutGroup(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(25 * GUI.Scale))), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), TextManager.Capitalize(moduleCount.Key.Value), textAlignment: Alignment.CenterLeft);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), GUINumberInput.NumberType.Int)
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), TextManager.Capitalize(moduleCount.Identifier.Value), textAlignment: Alignment.CenterLeft);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
IntValue = moduleCount.Value,
|
||||
IntValue = moduleCount.Count,
|
||||
OnValueChanged = (numInput) =>
|
||||
{
|
||||
outpostGenerationParams.SetModuleCount(moduleCount.Key, numInput.IntValue);
|
||||
outpostGenerationParams.SetModuleCount(moduleCount.Identifier, numInput.IntValue);
|
||||
if (numInput.IntValue == 0)
|
||||
{
|
||||
outpostParamsList.Select(outpostParamsList.SelectedData);
|
||||
@@ -505,7 +540,7 @@ namespace Barotrauma
|
||||
var addModuleCountGroup = new GUILayoutGroup(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(40 * GUI.Scale))), isHorizontal: true, childAnchor: Anchor.Center);
|
||||
|
||||
HashSet<Identifier> availableFlags = new HashSet<Identifier>();
|
||||
foreach (Identifier flag in OutpostGenerationParams.OutpostParams.SelectMany(p => p.ModuleCounts.Select(m => m.Key))) { availableFlags.Add(flag); }
|
||||
foreach (Identifier flag in OutpostGenerationParams.OutpostParams.SelectMany(p => p.ModuleCounts.Select(m => m.Identifier))) { availableFlags.Add(flag); }
|
||||
foreach (var sub in SubmarineInfo.SavedSubmarines)
|
||||
{
|
||||
if (sub.OutpostModuleInfo == null) { continue; }
|
||||
@@ -516,7 +551,7 @@ namespace Barotrauma
|
||||
text: TextManager.Get("leveleditor.addmoduletype"));
|
||||
foreach (Identifier flag in availableFlags)
|
||||
{
|
||||
if (outpostGenerationParams.ModuleCounts.Any(mc => mc.Key == flag)) { continue; }
|
||||
if (outpostGenerationParams.ModuleCounts.Any(mc => mc.Identifier == flag)) { continue; }
|
||||
moduleTypeDropDown.AddItem(TextManager.Capitalize(flag.Value), flag);
|
||||
}
|
||||
moduleTypeDropDown.OnSelected += (_, userdata) =>
|
||||
@@ -542,7 +577,7 @@ namespace Barotrauma
|
||||
if (selectedParams != null) { availableIdentifiers.Add(selectedParams.Identifier); }
|
||||
foreach (var caveParam in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
if (selectedParams != null && caveParam.GetCommonness(selectedParams, abyss: false) <= 0.0f) { continue; }
|
||||
if (selectedParams != null && caveParam.GetCommonness(currentLevelData, abyss: false) <= 0.0f) { continue; }
|
||||
availableIdentifiers.Add(caveParam.Identifier);
|
||||
}
|
||||
availableIdentifiers.Reverse();
|
||||
@@ -557,11 +592,11 @@ namespace Barotrauma
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", paramsId.Value), textAlignment: Alignment.Center);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = selectedParams.Identifier == paramsId ? levelObjectPrefab.GetCommonness(selectedParams) : levelObjectPrefab.GetCommonness(CaveGenerationParams.CaveParams.Find(p => p.Identifier == paramsId)),
|
||||
FloatValue = selectedParams.Identifier == paramsId ? levelObjectPrefab.GetCommonness(currentLevelData) : levelObjectPrefab.GetCommonness(CaveGenerationParams.CaveParams.Find(p => p.Identifier == paramsId)),
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
levelObjectPrefab.OverrideCommonness[paramsId] = numberInput.FloatValue;
|
||||
@@ -620,7 +655,7 @@ namespace Barotrauma
|
||||
childObj.AllowedNames = dropdown.SelectedDataMultiple.Select(d => ((LevelObjectPrefab)d).Name).ToList();
|
||||
return true;
|
||||
};
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), GUINumberInput.NumberType.Int)
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 10,
|
||||
@@ -630,7 +665,7 @@ namespace Barotrauma
|
||||
selectedChildObj.MaxCount = Math.Max(selectedChildObj.MaxCount, selectedChildObj.MinCount);
|
||||
}
|
||||
}.IntValue = childObj.MinCount;
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), GUINumberInput.NumberType.Int)
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.2f, 1.0f), paddedFrame.RectTransform), NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 10,
|
||||
@@ -689,13 +724,13 @@ namespace Barotrauma
|
||||
buttonContainer.RectTransform.MinSize = buttonContainer.RectTransform.Children.First().MinSize;
|
||||
}
|
||||
|
||||
private void SortLevelObjectsList(LevelGenerationParams selectedParams)
|
||||
private void SortLevelObjectsList(LevelData levelData)
|
||||
{
|
||||
//fade out levelobjects that don't spawn in this type of level
|
||||
foreach (GUIComponent levelObjFrame in levelObjectList.Content.Children)
|
||||
{
|
||||
var levelObj = levelObjFrame.UserData as LevelObjectPrefab;
|
||||
float commonness = levelObj.GetCommonness(selectedParams);
|
||||
float commonness = levelObj.GetCommonness(levelData);
|
||||
levelObjFrame.Color = commonness > 0.0f ? GUIStyle.Green * 0.4f : Color.Transparent;
|
||||
levelObjFrame.SelectedColor = commonness > 0.0f ? GUIStyle.Green * 0.6f : Color.White * 0.5f;
|
||||
levelObjFrame.HoverColor = commonness > 0.0f ? GUIStyle.Green * 0.7f : Color.White * 0.6f;
|
||||
@@ -712,7 +747,7 @@ namespace Barotrauma
|
||||
{
|
||||
var levelObj1 = c1.GUIComponent.UserData as LevelObjectPrefab;
|
||||
var levelObj2 = c2.GUIComponent.UserData as LevelObjectPrefab;
|
||||
return Math.Sign(levelObj2.GetCommonness(selectedParams) - levelObj1.GetCommonness(selectedParams));
|
||||
return Math.Sign(levelObj2.GetCommonness(levelData) - levelObj1.GetCommonness(levelData));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -863,7 +898,11 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
item?.GetComponent<Items.Components.LightComponent>()?.Update((float)deltaTime, Cam);
|
||||
if (item == null) { continue; }
|
||||
foreach (var light in item.GetComponents<Items.Components.LightComponent>())
|
||||
{
|
||||
light.Update((float)deltaTime, Cam);
|
||||
}
|
||||
}
|
||||
}
|
||||
GameMain.LightManager?.Update((float)deltaTime);
|
||||
|
||||
@@ -74,12 +74,24 @@ namespace Barotrauma
|
||||
{
|
||||
CreateHostServerFields();
|
||||
CreateCampaignSetupUI();
|
||||
SettingsMenu.Create(menuTabs[Tab.Settings].RectTransform);
|
||||
if (remoteContentDoc?.Root != null)
|
||||
{
|
||||
remoteContentContainer.ClearChildren();
|
||||
foreach (var subElement in remoteContentDoc.Root.Elements())
|
||||
try
|
||||
{
|
||||
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
|
||||
foreach (var subElement in remoteContentDoc.Root.Elements())
|
||||
{
|
||||
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Reading received remote main menu content failed.", e);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("MainMenuScreen.RemoteContentParse:Exception", GameAnalyticsManager.ErrorSeverity.Error,
|
||||
"Reading received remote main menu content failed. " + e.Message);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -490,7 +502,10 @@ namespace Barotrauma
|
||||
|
||||
//PLACEHOLDER
|
||||
var tutorialList = new GUIListBox(
|
||||
new RectTransform(new Vector2(0.95f, 0.85f), menuTabs[Tab.Tutorials].RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.1f) });
|
||||
new RectTransform(new Vector2(0.95f, 0.85f), menuTabs[Tab.Tutorials].RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.1f) })
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
var tutorialTypes = new List<Type>()
|
||||
{
|
||||
typeof(MechanicTutorial),
|
||||
@@ -1307,7 +1322,8 @@ namespace Barotrauma
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
UserData = -1,
|
||||
OnClicked = ChangeMaxPlayers
|
||||
OnClicked = ChangeMaxPlayers,
|
||||
ClickSound = GUISoundType.Decrease
|
||||
};
|
||||
maxPlayersBox = new GUITextBox(new RectTransform(new Vector2(0.6f, 1.0f), buttonContainer.RectTransform), textAlignment: Alignment.Center)
|
||||
{
|
||||
@@ -1327,7 +1343,8 @@ namespace Barotrauma
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
UserData = 1,
|
||||
OnClicked = ChangeMaxPlayers
|
||||
OnClicked = ChangeMaxPlayers,
|
||||
ClickSound = GUISoundType.Increase
|
||||
};
|
||||
maxPlayersLabel.RectTransform.IsFixedSize = true;
|
||||
|
||||
|
||||
@@ -20,10 +20,11 @@ namespace Barotrauma
|
||||
private ServerContentPackage? currentDownload;
|
||||
|
||||
private readonly List<ContentPackage> downloadedPackages = new List<ContentPackage>();
|
||||
public IEnumerable<ContentPackage> DownloadedPackages => downloadedPackages;
|
||||
|
||||
private bool confirmDownload;
|
||||
|
||||
private void Reset()
|
||||
public void Reset()
|
||||
{
|
||||
pendingDownloads.Clear();
|
||||
downloadedPackages.Clear();
|
||||
@@ -256,12 +257,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
Reset();
|
||||
base.Deselect();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Barotrauma
|
||||
public bool CampaignCharacterDiscarded
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
set;
|
||||
}
|
||||
|
||||
//elements that can only be used by the host
|
||||
@@ -179,7 +179,7 @@ namespace Barotrauma
|
||||
get { return ModeList.SelectedIndex; }
|
||||
set
|
||||
{
|
||||
ModeList.Select(value, true);
|
||||
ModeList.Select(value, GUIListBox.Force.Yes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,6 +504,7 @@ namespace Barotrauma
|
||||
|
||||
PlayerList = new GUIListBox(new RectTransform(new Vector2(0.4f, 1.0f), socialHolderHorizontal.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (component, userdata) => { SelectPlayer(userdata as Client); return true; }
|
||||
};
|
||||
|
||||
@@ -816,6 +817,7 @@ namespace Barotrauma
|
||||
|
||||
SubList = new GUIListBox(new RectTransform(Vector2.One, subHolder.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = VotableClicked
|
||||
};
|
||||
|
||||
@@ -901,6 +903,7 @@ namespace Barotrauma
|
||||
};
|
||||
ModeList = new GUIListBox(new RectTransform(Vector2.One, gameModeHolder.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = VotableClicked
|
||||
};
|
||||
|
||||
@@ -1250,9 +1253,6 @@ namespace Barotrauma
|
||||
|
||||
CharacterAppearanceCustomizationMenu?.Dispose();
|
||||
JobSelectionFrame = null;
|
||||
|
||||
/*foreach (Sprite sprite in jobPreferenceSprites) { sprite.Remove(); }
|
||||
jobPreferenceSprites.Clear();*/
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
@@ -1400,7 +1400,7 @@ namespace Barotrauma
|
||||
public void CreatePlayerFrame(GUIComponent parent, bool createPendingText = true, bool alwaysAllowEditing = false)
|
||||
{
|
||||
UpdatePlayerFrame(
|
||||
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo,
|
||||
Character.Controlled?.Info ?? playerInfoContainer.Children?.First().UserData as CharacterInfo ?? GameMain.Client.CharacterInfo,
|
||||
allowEditing: alwaysAllowEditing || campaignCharacterInfo == null,
|
||||
parent: parent,
|
||||
createPendingText: createPendingText);
|
||||
@@ -1414,7 +1414,7 @@ namespace Barotrauma
|
||||
characterInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, GameMain.Client.Name, null);
|
||||
characterInfo.RecreateHead(MultiplayerPreferences.Instance);
|
||||
GameMain.Client.CharacterInfo = characterInfo;
|
||||
characterInfo.OmitJobInPortraitClothing = false;
|
||||
characterInfo.OmitJobInMenus = true;
|
||||
}
|
||||
|
||||
parent.ClearChildren();
|
||||
@@ -1515,6 +1515,7 @@ namespace Barotrauma
|
||||
JobList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), JobPreferenceContainer.RectTransform, Anchor.BottomCenter), true)
|
||||
{
|
||||
Enabled = true,
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (child, obj) =>
|
||||
{
|
||||
if (child.IsParentOf(GUI.MouseOn)) return false;
|
||||
@@ -1600,6 +1601,7 @@ namespace Barotrauma
|
||||
{
|
||||
Enabled = true,
|
||||
KeepSpaceForScrollBar = false,
|
||||
PlaySoundOnSelect = true,
|
||||
ScrollBarEnabled = false,
|
||||
ScrollBarVisible = false
|
||||
};
|
||||
@@ -2902,6 +2904,7 @@ namespace Barotrauma
|
||||
appearanceFrame.ClearChildren();
|
||||
|
||||
var info = GameMain.Client.CharacterInfo ?? Character.Controlled?.Info;
|
||||
CharacterAppearanceCustomizationMenu?.Dispose();
|
||||
CharacterAppearanceCustomizationMenu = new CharacterInfo.AppearanceCustomizationMenu(info, appearanceFrame)
|
||||
{
|
||||
OnHeadSwitch = menu =>
|
||||
@@ -3131,10 +3134,11 @@ namespace Barotrauma
|
||||
retVal[i] = new GUIImage[outfitPreview.Sprites.Count];
|
||||
for (int j = 0; j < outfitPreview.Sprites.Count; j++)
|
||||
{
|
||||
Pair<Sprite, Vector2> sprite = outfitPreview.Sprites[j];
|
||||
Sprite sprite = outfitPreview.Sprites[j].sprite;
|
||||
Vector2 drawOffset = outfitPreview.Sprites[j].drawOffset;
|
||||
float aspectRatio = outfitPreview.Dimensions.Y / outfitPreview.Dimensions.X;
|
||||
retVal[i][j] = new GUIImage(new RectTransform(new Vector2(0.7f / aspectRatio, 0.7f), innerFrame.RectTransform, Anchor.Center)
|
||||
{ RelativeOffset = sprite.Second / outfitPreview.Dimensions }, sprite.First, scaleToFit: true)
|
||||
{ RelativeOffset = drawOffset / outfitPreview.Dimensions }, sprite, scaleToFit: true)
|
||||
{
|
||||
PressedColor = Color.White,
|
||||
CanBeFocused = false
|
||||
@@ -3183,7 +3187,7 @@ namespace Barotrauma
|
||||
|
||||
var prevMode = ModeList.Content.GetChild(selectedModeIndex).UserData as GameModePreset;
|
||||
|
||||
if ((HighlightedModeIndex == selectedModeIndex || HighlightedModeIndex < 0) && ModeList.SelectedIndex != modeIndex) { ModeList.Select(modeIndex, true); }
|
||||
if ((HighlightedModeIndex == selectedModeIndex || HighlightedModeIndex < 0) && ModeList.SelectedIndex != modeIndex) { ModeList.Select(modeIndex, GUIListBox.Force.Yes); }
|
||||
selectedModeIndex = modeIndex;
|
||||
|
||||
if ((prevMode == GameModePreset.PvP) != (SelectedMode == GameModePreset.PvP))
|
||||
@@ -3299,7 +3303,7 @@ namespace Barotrauma
|
||||
RefreshEnabledElements();
|
||||
if (enabled)
|
||||
{
|
||||
ModeList.Select(GameModePreset.MultiPlayerCampaign, true);
|
||||
ModeList.Select(GameModePreset.MultiPlayerCampaign, GUIListBox.Force.Yes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3415,7 +3419,7 @@ namespace Barotrauma
|
||||
UserData = i,
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
JobList.Select((int)obj, true);
|
||||
JobList.Select((int)obj, GUIListBox.Force.Yes);
|
||||
SwitchJob(btn, null);
|
||||
if (JobSelectionFrame != null) { JobSelectionFrame.Visible = false; }
|
||||
JobList.Deselect();
|
||||
@@ -3551,7 +3555,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
subList.OnSelected -= VotableClicked;
|
||||
subList.Select(sub, force: true);
|
||||
subList.Select(sub, GUIListBox.Force.Yes);
|
||||
subList.OnSelected += VotableClicked;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,10 @@ namespace Barotrauma
|
||||
OnClicked = (btn, userdata) => { FilterEmitters(""); filterBox.Text = ""; filterBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
prefabList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform));
|
||||
prefabList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
};
|
||||
prefabList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
cam.Position = Vector2.Zero;
|
||||
|
||||
@@ -504,6 +504,7 @@ namespace Barotrauma
|
||||
|
||||
serverList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), serverListContainer.RectTransform, Anchor.Center))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (btn, obj) =>
|
||||
{
|
||||
@@ -1473,7 +1474,6 @@ namespace Barotrauma
|
||||
{
|
||||
friendsDropdownButton = new GUIButton(new RectTransform(Vector2.One, friendsButtonHolder.RectTransform, Anchor.BottomRight, Pivot.BottomRight, scaleBasis: ScaleBasis.BothHeight), "\u2022 \u2022 \u2022", style: "GUIButtonFriendsDropdown")
|
||||
{
|
||||
Font = GUIStyle.GlobalFont,
|
||||
OnClicked = (button, udt) =>
|
||||
{
|
||||
friendsDropdown.RectTransform.NonScaledSize = new Point(friendsButtonHolder.Rect.Height * 5 * 166 / 100, friendsButtonHolder.Rect.Height * 4 * 166 / 100);
|
||||
|
||||
@@ -85,12 +85,12 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
var selected = selectedSprites;
|
||||
var selected = selectedSprites.ToList();
|
||||
Sprite firstSelected = selected.First();
|
||||
selected.ForEach(s => s.ReloadTexture());
|
||||
RefreshLists();
|
||||
textureList.Select(firstSelected.FullPath, autoScroll: false);
|
||||
selected.ForEachMod(s => spriteList.Select(s, autoScroll: false));
|
||||
textureList.Select(firstSelected.FullPath, autoScroll: GUIListBox.AutoScroll.Disabled);
|
||||
selected.ForEachMod(s => spriteList.Select(s, autoScroll: GUIListBox.AutoScroll.Disabled));
|
||||
texturePathText.Text = TextManager.GetWithVariable("spriteeditor.texturesreloaded", "[filepath]", firstSelected.FilePath.Value);
|
||||
texturePathText.TextColor = GUIStyle.Green;
|
||||
return true;
|
||||
@@ -206,6 +206,7 @@ namespace Barotrauma
|
||||
|
||||
textureList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedLeftPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (listBox, userData) =>
|
||||
{
|
||||
var newTexturePath = userData as string;
|
||||
@@ -213,7 +214,7 @@ namespace Barotrauma
|
||||
{
|
||||
selectedTexturePath = newTexturePath;
|
||||
ResetZoom();
|
||||
spriteList.Select(loadedSprites.First(s => s.FilePath == selectedTexturePath), autoScroll: false);
|
||||
spriteList.Select(loadedSprites.First(s => s.FilePath == selectedTexturePath), autoScroll: GUIListBox.AutoScroll.Disabled);
|
||||
UpdateScrollBar(spriteList);
|
||||
}
|
||||
foreach (GUIComponent child in spriteList.Content.Children)
|
||||
@@ -248,6 +249,7 @@ namespace Barotrauma
|
||||
|
||||
spriteList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedRightPanel.RectTransform))
|
||||
{
|
||||
PlaySoundOnSelect = true,
|
||||
OnSelected = (listBox, userData) =>
|
||||
{
|
||||
if (userData is Sprite sprite)
|
||||
@@ -291,7 +293,7 @@ namespace Barotrauma
|
||||
}, style: null, color: Color.Black * 0.6f);
|
||||
var colorLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), element.RectTransform, Anchor.CenterLeft), colorComponentLabels[i],
|
||||
font: GUIStyle.SmallFont, textAlignment: Alignment.CenterLeft);
|
||||
var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), GUINumberInput.NumberType.Int)
|
||||
var numberInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1), element.RectTransform, Anchor.CenterRight), NumberType.Int)
|
||||
{
|
||||
Font = GUIStyle.SmallFont
|
||||
};
|
||||
@@ -481,7 +483,7 @@ namespace Barotrauma
|
||||
var scaledRect = new Rectangle(textureRect.Location + sprite.SourceRect.Location.Multiply(zoom), sprite.SourceRect.Size.Multiply(zoom));
|
||||
if (scaledRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
spriteList.Select(sprite, autoScroll: false);
|
||||
spriteList.Select(sprite, autoScroll: GUIListBox.AutoScroll.Disabled);
|
||||
UpdateScrollBar(spriteList);
|
||||
UpdateScrollBar(textureList);
|
||||
// Release the keyboard so that we can nudge the source rects
|
||||
@@ -847,7 +849,7 @@ namespace Barotrauma
|
||||
base.Select();
|
||||
LoadSprites();
|
||||
RefreshLists();
|
||||
spriteList.Select(0, autoScroll: false);
|
||||
spriteList.Select(0, autoScroll: GUIListBox.AutoScroll.Disabled);
|
||||
}
|
||||
|
||||
protected override void DeselectEditorSpecific()
|
||||
@@ -905,7 +907,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (sprite.FullPath != selectedTexturePath)
|
||||
{
|
||||
textureList.Select(sprite.FullPath, autoScroll: false);
|
||||
textureList.Select(sprite.FullPath, autoScroll: GUIListBox.AutoScroll.Disabled);
|
||||
UpdateScrollBar(textureList);
|
||||
}
|
||||
xmlPathText.Text = string.Empty;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user