Unstable 1.8.4.0

This commit is contained in:
Markus Isberg
2025-03-12 12:56:27 +00:00
parent a4c3e868e4
commit a4a3427e4e
627 changed files with 29860 additions and 10018 deletions
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Barotrauma.Networking;
namespace Barotrauma
{
@@ -19,7 +20,9 @@ namespace Barotrauma
protected GUIButton loadGameButton;
public Action<SubmarineInfo, string, string, CampaignSettings> StartNewGame;
public Action<string> LoadGame;
public delegate void LoadGameDelegate(string loadPath, Option<uint> backupIndex);
public LoadGameDelegate LoadGame;
protected enum CategoryFilter { All = 0, Vanilla = 1, Custom = 2 }
protected CategoryFilter subFilter = CategoryFilter.All;
@@ -142,6 +145,7 @@ namespace Barotrauma
public SettingValue<float> OxygenMultiplier;
public SettingValue<float> FuelMultiplier;
public SettingValue<float> MissionRewardMultiplier;
public SettingValue<float> ExperienceRewardMultiplier;
public SettingValue<float> ShopPriceMultiplier;
public SettingValue<float> ShipyardPriceMultiplier;
public SettingValue<float> RepairFailMultiplier;
@@ -164,6 +168,7 @@ namespace Barotrauma
OxygenMultiplier = OxygenMultiplier.GetValue(),
FuelMultiplier = FuelMultiplier.GetValue(),
MissionRewardMultiplier = MissionRewardMultiplier.GetValue(),
ExperienceRewardMultiplier = ExperienceRewardMultiplier.GetValue(),
ShopPriceMultiplier = ShopPriceMultiplier.GetValue(),
ShipyardPriceMultiplier = ShipyardPriceMultiplier.GetValue(),
RepairFailMultiplier = RepairFailMultiplier.GetValue(),
@@ -341,6 +346,19 @@ namespace Barotrauma
verticalSize,
OnValuesChanged);
// Experience reward multiplier
CampaignSettings.MultiplierSettings experienceMultiplierSettings = CampaignSettings.GetMultiplierSettings("ExperienceRewardMultiplier");
SettingValue<float> experienceMultiplier = CreateGUIFloatInputCarousel(
settingsList.Content,
TextManager.Get("campaignoption.experiencerewardmultiplier"),
TextManager.Get("campaignoption.experiencerewardmultiplier.tooltip"),
prevSettings.ExperienceRewardMultiplier,
valueStep: experienceMultiplierSettings.Step,
minValue: experienceMultiplierSettings.Min,
maxValue: experienceMultiplierSettings.Max,
verticalSize,
OnValuesChanged);
// Shop buying prices multiplier
CampaignSettings.MultiplierSettings shopPriceMultiplierSettings = CampaignSettings.GetMultiplierSettings("ShopPriceMultiplier");
SettingValue<float> shopPriceMultiplier = CreateGUIFloatInputCarousel(
@@ -498,6 +516,7 @@ namespace Barotrauma
oxygenMultiplier.SetValue(settings.OxygenMultiplier);
fuelMultiplier.SetValue(settings.FuelMultiplier);
rewardMultiplier.SetValue(settings.MissionRewardMultiplier);
experienceMultiplier.SetValue(settings.ExperienceRewardMultiplier);
shopPriceMultiplier.SetValue(settings.ShopPriceMultiplier);
shipyardPriceMultiplier.SetValue(settings.ShipyardPriceMultiplier);
repairFailMultiplier.SetValue(settings.RepairFailMultiplier);
@@ -527,6 +546,7 @@ namespace Barotrauma
OxygenMultiplier = oxygenMultiplier,
FuelMultiplier = fuelMultiplier,
MissionRewardMultiplier = rewardMultiplier,
ExperienceRewardMultiplier = experienceMultiplier,
ShopPriceMultiplier = shopPriceMultiplier,
ShipyardPriceMultiplier = shipyardPriceMultiplier,
RepairFailMultiplier = repairFailMultiplier,
@@ -821,5 +841,119 @@ namespace Barotrauma
return true;
}
protected void CreateBackupMenu(IEnumerable<SaveUtil.BackupIndexData> indexData, Action<SaveUtil.BackupIndexData> loadBackup)
{
var backupPopup = new GUIMessageBox("", "", new[] { TextManager.Get("Load"), TextManager.Get("Cancel") }, new Vector2(0.3f, 0.5f), minSize: new Point(500, 500));
GUILayoutGroup campaignSettingContent = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.8f), backupPopup.Content.RectTransform, Anchor.TopCenter));
GUIListBox backupList = new GUIListBox(new RectTransform(Vector2.One, campaignSettingContent.RectTransform));
bool isIronman = GameMain.NetworkMember?.ServerSettings is { IronmanModeActive: true };
if (!indexData.Any() || isIronman)
{
LocalizedString errorMsg = isIronman
? TextManager.Get("ironmanmodebackupdisclaimer")
: TextManager.Get("nobackups");
var errorBlock = new GUITextBlock(new RectTransform(Vector2.One, campaignSettingContent.RectTransform), errorMsg, font: GUIStyle.SubHeadingFont, textAlignment: Alignment.Center)
{
TextColor = GUIStyle.Red,
IgnoreLayoutGroups = true
};
if (errorBlock.Font.MeasureString(errorMsg).X > campaignSettingContent.Rect.Width)
{
errorBlock.Wrap = true;
errorBlock.SetTextPos();
}
}
if (!isIronman)
{
foreach (var data in indexData.OrderByDescending(static i => i.SaveTime))
{
GUIFrame indexFrame = new GUIFrame(
new RectTransform(new Vector2(1.0f, 1f / SaveUtil.MaxBackupCount), backupList.Content.RectTransform), style: "ListBoxElement")
{
UserData = data
};
GUILayoutGroup indexLayout = new GUILayoutGroup(
new RectTransform(Vector2.One, indexFrame.RectTransform),
isHorizontal: true,
childAnchor: Anchor.CenterLeft)
{
RelativeSpacing = 0.05f,
Stretch = true
};
GUILayoutGroup leftLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.8f), indexLayout.RectTransform), childAnchor: Anchor.TopCenter)
{
RelativeSpacing = 0.05f,
Stretch = true
};
LocalizedString locationName = data.LocationType.IsEmpty || data.LocationNameIdentifier.IsEmpty ?
TextManager.Get("unknown") :
Location.GetName(data.LocationType, data.LocationNameFormatIndex, data.LocationNameIdentifier);
var locationNameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), leftLayout.RectTransform), locationName, textAlignment: Alignment.CenterLeft)
{
TextColor = Color.White
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), leftLayout.RectTransform), TextManager.Get($"savestate.{data.LevelType}"), textAlignment: Alignment.CenterLeft);
GUILayoutGroup rightLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.8f), indexLayout.RectTransform), childAnchor: Anchor.TopCenter)
{
RelativeSpacing = 0.05f,
Stretch = true
};
TimeSpan difference = SerializableDateTime.UtcNow - data.SaveTime;
double totalMinutes = difference.TotalMinutes;
LocalizedString timeFormat = totalMinutes switch
{
< 1 => TextManager.Get("subeditor.savedjustnow"),
> 60 => TextManager.GetWithVariable("saveagehours", "[hours]", ((int)Math.Floor(difference.TotalHours)).ToString()),
_ => TextManager.GetWithVariable("subeditor.saveageminutes", "[minutes]", difference.Minutes.ToString())
};
new GUITextBlock(new RectTransform(Vector2.One, rightLayout.RectTransform), timeFormat, textAlignment: Alignment.CenterRight);
locationNameBlock.Text = ToolBox.LimitString(locationName, locationNameBlock.Font, locationNameBlock.Rect.Width);
}
}
backupList.AfterSelected = (selected, _) =>
{
// to my understanding, there's no way to unselect an item in a GUIListBox
// so no need to check if selected is null
backupPopup.Buttons[0].Enabled = true;
return true;
};
backupPopup.Buttons[1].OnClicked += (button, o) =>
{
backupPopup.Close();
return true;
};
backupPopup.Buttons[0].Enabled = false;
backupPopup.Buttons[0].OnClicked += (button, o) =>
{
if (backupList.SelectedComponent?.UserData is not SaveUtil.BackupIndexData selectedIndexData) { return false; }
backupPopup.Close();
loadBackup?.Invoke(selectedIndexData);
return true;
};
}
}
}