Unstable 0.17.5.0

This commit is contained in:
Markus Isberg
2022-03-30 01:20:59 +09:00
parent c1b8e5a341
commit 44ded0225a
88 changed files with 2033 additions and 1430 deletions
@@ -8,9 +8,9 @@ using Microsoft.Xna.Framework.Graphics;
namespace Barotrauma.Steam
{
public partial class WorkshopMenu
abstract partial class WorkshopMenu
{
private readonly struct BBWord
protected readonly struct BBWord
{
[Flags]
public enum TagType
@@ -42,10 +42,10 @@ namespace Barotrauma.Steam
}
}
private static readonly Regex bbTagRegex = new Regex(@"\[(.+?)\]",
protected static readonly Regex bbTagRegex = new Regex(@"\[(.+?)\]",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static GUICustomComponent CreateBBCodeElement(string bbCode, GUIListBox container)
protected static GUICustomComponent CreateBBCodeElement(string bbCode, GUIListBox container)
{
Point cachedContainerSize = Point.Zero;
List<BBWord> bbWords = new List<BBWord>();
@@ -0,0 +1,41 @@
#nullable enable
using Microsoft.Xna.Framework;
namespace Barotrauma.Steam
{
sealed class ImmutableWorkshopMenu : WorkshopMenu
{
public ImmutableWorkshopMenu(GUIFrame parent) : base(parent)
{
var mainLayout
= new GUILayoutGroup(new RectTransform((0.5f, 1.0f), parent.RectTransform, Anchor.Center), isHorizontal: false);
Label(mainLayout, TextManager.Get("enabledcore"), GUIStyle.SubHeadingFont);
var coreBox = new GUIButton(
NewItemRectT(mainLayout), style: "GUITextBoxNoIcon", text: ContentPackageManager.EnabledPackages.Core!.Name, textAlignment: Alignment.CenterLeft)
{
CanBeFocused = false,
CanBeSelected = false
};
coreBox.TextBlock.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
Label(mainLayout, TextManager.Get("enabledregular"), GUIStyle.SubHeadingFont);
var regularList = new GUIListBox(
NewItemRectT(mainLayout, heightScale: 12f))
{
OnSelected = (component, o) => false,
HoverCursor = CursorState.Default
};
foreach (var p in ContentPackageManager.EnabledPackages.Regular)
{
var regularBox = new GUITextBlock(
new RectTransform((1.0f, 0.07f), regularList.Content.RectTransform), text: p.Name)
{
CanBeFocused = false
};
}
Label(mainLayout, TextManager.Get("CannotChangeMods"), GUIStyle.Font);
}
}
}
@@ -12,7 +12,7 @@ using ItemOrPackage = Barotrauma.Either<Steamworks.Ugc.Item, Barotrauma.ContentP
namespace Barotrauma.Steam
{
public partial class WorkshopMenu
sealed partial class MutableWorkshopMenu : WorkshopMenu
{
private string ExtractTitle(ItemOrPackage itemOrPackage)
=> itemOrPackage.TryGet(out ContentPackage package)
@@ -10,7 +10,7 @@ using ItemOrPackage = Barotrauma.Either<Steamworks.Ugc.Item, Barotrauma.ContentP
namespace Barotrauma.Steam
{
public partial class WorkshopMenu
sealed partial class MutableWorkshopMenu : WorkshopMenu
{
public enum Tab
{
@@ -20,10 +20,10 @@ namespace Barotrauma.Steam
Publish
}
private readonly GUILayoutGroup tabber;
private readonly Dictionary<Tab, (GUIButton Button, GUIFrame Content)> tabContents;
protected readonly GUILayoutGroup tabber;
protected readonly Dictionary<Tab, (GUIButton Button, GUIFrame Content)> tabContents;
private readonly GUIFrame contentFrame;
protected readonly GUIFrame contentFrame;
private CorePackage EnabledCorePackage => enabledCoreDropdown.SelectedData as CorePackage ?? throw new Exception("Valid core package not selected");
@@ -39,15 +39,17 @@ namespace Barotrauma.Steam
private readonly GUIListBox popularModsList;
private readonly GUIListBox selfModsList;
public WorkshopMenu(GUIFrame parent)
public MutableWorkshopMenu(GUIFrame parent) : base(parent)
{
var mainLayout = new GUILayoutGroup(new RectTransform(Vector2.One, parent.RectTransform), isHorizontal: false);
var mainLayout
= new GUILayoutGroup(new RectTransform(Vector2.One, parent.RectTransform), isHorizontal: false);
tabber = new GUILayoutGroup(new RectTransform((1.0f, 0.05f), mainLayout.RectTransform), isHorizontal: true) { Stretch = true };
tabber = new GUILayoutGroup(new RectTransform((1.0f, 0.05f), mainLayout.RectTransform), isHorizontal: true)
{ Stretch = true };
tabContents = new Dictionary<Tab, (GUIButton Button, GUIFrame Content)>();
contentFrame = new GUIFrame(new RectTransform((1.0f, 0.95f), mainLayout.RectTransform), style: null);
CreateInstalledModsTab(
out enabledCoreDropdown,
out enabledRegularModsList,
@@ -15,7 +15,7 @@ using Path = Barotrauma.IO.Path;
namespace Barotrauma.Steam
{
public partial class WorkshopMenu
sealed partial class MutableWorkshopMenu : WorkshopMenu
{
private class LocalThumbnail : IDisposable
{
@@ -7,22 +7,22 @@ using Microsoft.Xna.Framework;
namespace Barotrauma.Steam
{
public partial class WorkshopMenu
abstract partial class WorkshopMenu
{
private static RectTransform NewItemRectT(GUILayoutGroup parent, float heightScale = 1.0f)
protected static RectTransform NewItemRectT(GUILayoutGroup parent, float heightScale = 1.0f)
=> new RectTransform((1.0f, 0.06f * heightScale), parent.RectTransform, Anchor.CenterLeft);
private static void Spacer(GUILayoutGroup parent, float height = 0.03f)
protected static void Spacer(GUILayoutGroup parent, float height = 0.03f)
{
new GUIFrame(new RectTransform((1.0f, height), parent.RectTransform, Anchor.CenterLeft), style: null);
}
private static GUITextBlock Label(GUILayoutGroup parent, LocalizedString str, GUIFont font, float heightScale = 1.0f)
protected static GUITextBlock Label(GUILayoutGroup parent, LocalizedString str, GUIFont font, float heightScale = 1.0f)
{
return new GUITextBlock(NewItemRectT(parent, heightScale), str, font: font);
}
private static GUITextBox ScrollableTextBox(GUILayoutGroup parent, float heightScale, string text)
protected static GUITextBox ScrollableTextBox(GUILayoutGroup parent, float heightScale, string text)
{
var containingListBox = new GUIListBox(NewItemRectT(parent, heightScale));
var textBox = new GUITextBox(
@@ -53,12 +53,12 @@ namespace Barotrauma.Steam
return textBox;
}
private static GUIDropDown DropdownEnum<T>(
protected static GUIDropDown DropdownEnum<T>(
GUILayoutGroup parent, Func<T, LocalizedString> textFunc, T currentValue,
Action<T> setter) where T : Enum
=> Dropdown(parent, textFunc, (T[])Enum.GetValues(typeof(T)), currentValue, setter);
private static GUIDropDown Dropdown<T>(
protected static GUIDropDown Dropdown<T>(
GUILayoutGroup parent, Func<T, LocalizedString> textFunc, IReadOnlyList<T> values, T currentValue,
Action<T> setter, float heightScale = 1.0f)
{
@@ -67,7 +67,7 @@ namespace Barotrauma.Steam
return dropdown;
}
private static void SwapDropdownValues<T>(
protected static void SwapDropdownValues<T>(
GUIDropDown dropdown, Func<T, LocalizedString> textFunc, IReadOnlyList<T> values, T currentValue,
Action<T> setter)
{
@@ -88,10 +88,10 @@ namespace Barotrauma.Steam
};
}
private static int Round(float v) => (int)MathF.Round(v);
private static string Percentage(float v) => $"{Round(v * 100)}";
protected static int Round(float v) => (int)MathF.Round(v);
protected static string Percentage(float v) => $"{Round(v * 100)}";
private struct ActionCarrier
protected struct ActionCarrier
{
public readonly Identifier Id;
public readonly Action Action;
@@ -102,7 +102,7 @@ namespace Barotrauma.Steam
}
}
private GUIComponent CreateActionCarrier(GUIComponent parent, Identifier id, Action action)
protected GUIComponent CreateActionCarrier(GUIComponent parent, Identifier id, Action action)
=> new GUIFrame(new RectTransform(Vector2.Zero, parent.RectTransform), style: null)
{ UserData = new ActionCarrier(id, action) };
}
@@ -0,0 +1,12 @@
#nullable enable
namespace Barotrauma.Steam
{
abstract partial class WorkshopMenu
{
public WorkshopMenu(GUIFrame parent)
{
}
}
}