(2c44bade5) Workshop UI improvements final
This commit is contained in:
@@ -66,6 +66,33 @@ namespace Barotrauma
|
|||||||
CanBeFocused = false
|
CanBeFocused = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Point scrollButtonSize = new Point((int)(200 * GUI.Scale), (int)(30 * GUI.Scale));
|
||||||
|
|
||||||
|
crewArea = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.CrewArea, guiFrame.RectTransform), "", Color.Transparent)
|
||||||
|
{
|
||||||
|
CanBeFocused = false
|
||||||
|
};
|
||||||
|
toggleCrewButton = new GUIButton(new RectTransform(new Point((int)(30 * GUI.Scale), HUDLayoutSettings.CrewArea.Height), guiFrame.RectTransform)
|
||||||
|
{ AbsoluteOffset = HUDLayoutSettings.CrewArea.Location },
|
||||||
|
"", style: "UIToggleButton");
|
||||||
|
toggleCrewButton.OnClicked += (GUIButton btn, object userdata) =>
|
||||||
|
{
|
||||||
|
toggleCrewAreaOpen = !toggleCrewAreaOpen;
|
||||||
|
foreach (GUIComponent child in btn.Children)
|
||||||
|
{
|
||||||
|
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
characterListBox = new GUIListBox(new RectTransform(new Point(100, (int)(crewArea.Rect.Height - scrollButtonSize.Y * 1.6f)), crewArea.RectTransform, Anchor.CenterLeft), false, Color.Transparent, null)
|
||||||
|
{
|
||||||
|
//Spacing = (int)(3 * GUI.Scale),
|
||||||
|
ScrollBarEnabled = false,
|
||||||
|
ScrollBarVisible = false,
|
||||||
|
CanBeFocused = false
|
||||||
|
};
|
||||||
|
|
||||||
var characterInfo = new CharacterInfo(subElement);
|
var characterInfo = new CharacterInfo(subElement);
|
||||||
characterInfos.Add(characterInfo);
|
characterInfos.Add(characterInfo);
|
||||||
foreach (XElement invElement in subElement.Elements())
|
foreach (XElement invElement in subElement.Elements())
|
||||||
@@ -81,6 +108,16 @@ namespace Barotrauma
|
|||||||
prevUIScale = GUI.Scale;
|
prevUIScale = GUI.Scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Character list management
|
||||||
|
|
||||||
|
public Rectangle GetCharacterListArea()
|
||||||
|
{
|
||||||
|
return characterListBox.Rect;
|
||||||
|
}
|
||||||
|
|
||||||
partial void InitProjectSpecific()
|
partial void InitProjectSpecific()
|
||||||
{
|
{
|
||||||
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
||||||
|
|||||||
@@ -175,142 +175,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyTo(RectTransform target)
|
|
||||||
{
|
|
||||||
if (RelativeOffset.HasValue)
|
|
||||||
{
|
|
||||||
target.RelativeOffset = RelativeOffset.Value;
|
|
||||||
}
|
|
||||||
else if (AbsoluteOffset.HasValue)
|
|
||||||
{
|
|
||||||
target.AbsoluteOffset = AbsoluteOffset.Value;
|
|
||||||
}
|
|
||||||
if (RelativeSize.HasValue)
|
|
||||||
{
|
|
||||||
target.RelativeSize = RelativeSize.Value;
|
|
||||||
}
|
|
||||||
else if (AbsoluteSize.HasValue)
|
|
||||||
{
|
|
||||||
target.NonScaledSize = AbsoluteSize.Value;
|
|
||||||
}
|
|
||||||
if (Anchor.HasValue)
|
|
||||||
{
|
|
||||||
target.Anchor = Anchor.Value;
|
|
||||||
}
|
|
||||||
if (Pivot.HasValue)
|
|
||||||
{
|
|
||||||
target.Pivot = Pivot.Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target.Pivot = RectTransform.MatchPivotToAnchor(target.Anchor);
|
|
||||||
}
|
|
||||||
target.RecalculateChildren(true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GUIFrame GuiFrame { get; protected set; }
|
|
||||||
|
|
||||||
[Serialize(false, false)]
|
|
||||||
public bool AllowUIOverlap
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemComponent linkToUIComponent;
|
|
||||||
[Serialize("", false)]
|
|
||||||
public string LinkUIToComponent
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serialize(0, false)]
|
|
||||||
public int HudPriority
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool useAlternativeLayout;
|
|
||||||
public bool UseAlternativeLayout
|
|
||||||
{
|
|
||||||
get { return useAlternativeLayout; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (AlternativeLayout != null)
|
|
||||||
{
|
|
||||||
if (value == useAlternativeLayout) { return; }
|
|
||||||
useAlternativeLayout = value;
|
|
||||||
if (useAlternativeLayout)
|
|
||||||
{
|
|
||||||
AlternativeLayout?.ApplyTo(GuiFrame.RectTransform);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DefaultLayout?.ApplyTo(GuiFrame.RectTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplyTo(RectTransform target)
|
|
||||||
{
|
|
||||||
if (RelativeOffset.HasValue)
|
|
||||||
{
|
|
||||||
target.RelativeOffset = RelativeOffset.Value;
|
|
||||||
}
|
|
||||||
else if (AbsoluteOffset.HasValue)
|
|
||||||
{
|
|
||||||
target.AbsoluteOffset = AbsoluteOffset.Value;
|
|
||||||
}
|
|
||||||
if (RelativeSize.HasValue)
|
|
||||||
{
|
|
||||||
target.RelativeSize = RelativeSize.Value;
|
|
||||||
}
|
|
||||||
else if (AbsoluteSize.HasValue)
|
|
||||||
{
|
|
||||||
target.NonScaledSize = AbsoluteSize.Value;
|
|
||||||
}
|
|
||||||
if (Anchor.HasValue)
|
|
||||||
{
|
|
||||||
target.Anchor = Anchor.Value;
|
|
||||||
}
|
|
||||||
if (Pivot.HasValue)
|
|
||||||
{
|
|
||||||
target.Pivot = Pivot.Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target.Pivot = RectTransform.MatchPivotToAnchor(target.Anchor);
|
|
||||||
}
|
|
||||||
target.RecalculateChildren(true, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GUIFrame GuiFrame { get; protected set; }
|
|
||||||
|
|
||||||
[Serialize(false, false)]
|
|
||||||
public bool AllowUIOverlap
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemComponent linkToUIComponent;
|
|
||||||
[Serialize("", false)]
|
|
||||||
public string LinkUIToComponent
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serialize(0, false)]
|
|
||||||
public int HudPriority
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool shouldMuffleLooping;
|
private bool shouldMuffleLooping;
|
||||||
|
|||||||
@@ -313,9 +313,8 @@ namespace Barotrauma
|
|||||||
UserData = item
|
UserData = item
|
||||||
};
|
};
|
||||||
|
|
||||||
var innerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), itemFrame.RectTransform, Anchor.Center), isHorizontal: true)
|
var innerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), itemFrame.RectTransform, Anchor.Center), isHorizontal: true)
|
||||||
{
|
{
|
||||||
RelativeSpacing = 0.1f,
|
|
||||||
CanBeFocused = false,
|
CanBeFocused = false,
|
||||||
Stretch = true
|
Stretch = true
|
||||||
};
|
};
|
||||||
@@ -370,14 +369,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var rightColumn = new GUILayoutGroup(new RectTransform(new Point(innerFrame.Rect.Width - iconSize, innerFrame.Rect.Height), innerFrame.RectTransform), childAnchor: Anchor.TopRight)
|
var rightColumn = new GUILayoutGroup(new RectTransform(new Point(innerFrame.Rect.Width - iconSize, innerFrame.Rect.Height), innerFrame.RectTransform), childAnchor: Anchor.CenterLeft)
|
||||||
{
|
{
|
||||||
|
IsHorizontal = true,
|
||||||
Stretch = true,
|
Stretch = true,
|
||||||
CanBeFocused = false,
|
CanBeFocused = false
|
||||||
RelativeSpacing = 0.05f
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var titleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), rightColumn.RectTransform), item.Title, textAlignment: Alignment.CenterLeft)
|
var titleText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), rightColumn.RectTransform), item.Title, textAlignment: Alignment.CenterLeft, wrap: true)
|
||||||
{
|
{
|
||||||
CanBeFocused = false
|
CanBeFocused = false
|
||||||
};
|
};
|
||||||
@@ -424,8 +423,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enabledTickBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 0.5f), rightColumn.RectTransform), TextManager.Get("WorkshopItemEnabled"))
|
enabledTickBox = new GUITickBox(new RectTransform(new Point(32, 32), rightColumn.RectTransform), null)
|
||||||
{
|
{
|
||||||
|
ToolTip = TextManager.Get("WorkshopItemEnabled"),
|
||||||
UserData = item,
|
UserData = item,
|
||||||
};
|
};
|
||||||
enabledTickBox.Selected = SteamManager.CheckWorkshopItemEnabled(item);
|
enabledTickBox.Selected = SteamManager.CheckWorkshopItemEnabled(item);
|
||||||
@@ -461,9 +461,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var downloadBtn = new GUIButton(new RectTransform(new Vector2(0.5f, 0.5f), rightColumn.RectTransform),
|
var downloadBtn = new GUIButton(new RectTransform(new Point(32, 32), rightColumn.RectTransform), "+", style: null, color: new Color(107, 144, 166, 255))
|
||||||
TextManager.Get("DownloadButton"))
|
|
||||||
{
|
{
|
||||||
|
Font = GUI.LargeFont,
|
||||||
|
HoverColor = new Color(42, 53, 62, 255),
|
||||||
|
TextColor = Color.White,
|
||||||
|
ToolTip = TextManager.Get("DownloadButton"),
|
||||||
|
ForceUpperCase = true,
|
||||||
UserData = item,
|
UserData = item,
|
||||||
OnClicked = DownloadItem
|
OnClicked = DownloadItem
|
||||||
};
|
};
|
||||||
@@ -603,17 +607,22 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), itemPreviewFrame.RectTransform, Anchor.Center))
|
var content = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), itemPreviewFrame.RectTransform, Anchor.Center))
|
||||||
{
|
{
|
||||||
Stretch = true,
|
Stretch = true,
|
||||||
UserData = item,
|
UserData = item,
|
||||||
RelativeSpacing = 0.015f
|
RelativeSpacing = 0.015f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//spacing
|
||||||
|
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.005f), content.RectTransform), style: null);
|
||||||
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), item.Title, textAlignment: Alignment.TopLeft, font: GUI.LargeFont, wrap: true);
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), item.Title, textAlignment: Alignment.TopLeft, font: GUI.LargeFont, wrap: true);
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemCreator") + ": " + item.OwnerName, textAlignment: Alignment.BottomLeft, wrap: true);
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemCreator") + ": " + item.OwnerName, textAlignment: Alignment.BottomLeft, wrap: true);
|
||||||
|
|
||||||
var headerArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), content.RectTransform, maxSize: new Point(int.MaxValue, 200)), childAnchor: Anchor.TopCenter);
|
var headerAreaBackground = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.59f), content.RectTransform, maxSize: new Point(int.MaxValue, 235))) { Color = Color.Black };
|
||||||
|
|
||||||
|
var headerArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), headerAreaBackground.RectTransform), childAnchor: Anchor.Center);
|
||||||
|
|
||||||
if (itemPreviewSprites.ContainsKey(item.PreviewImageUrl))
|
if (itemPreviewSprites.ContainsKey(item.PreviewImageUrl))
|
||||||
{
|
{
|
||||||
@@ -654,8 +663,7 @@ namespace Barotrauma
|
|||||||
//tags ------------------------------------
|
//tags ------------------------------------
|
||||||
var tagContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
var tagContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||||
{
|
{
|
||||||
Stretch = true,
|
Stretch = true
|
||||||
RelativeSpacing = 0.02f
|
|
||||||
};
|
};
|
||||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), tagContainer.RectTransform), TextManager.Get("WorkshopItemTags")+": ");
|
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), tagContainer.RectTransform), TextManager.Get("WorkshopItemTags")+": ");
|
||||||
if (!item.Tags.Any(t => !string.IsNullOrEmpty(t)))
|
if (!item.Tags.Any(t => !string.IsNullOrEmpty(t)))
|
||||||
@@ -670,19 +678,24 @@ namespace Barotrauma
|
|||||||
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), tagContainer.RectTransform, Anchor.Center), tag, style: "ListBoxElement");
|
new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), tagContainer.RectTransform, Anchor.Center), tag, style: "ListBoxElement");
|
||||||
}
|
}
|
||||||
|
|
||||||
var creationDate = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemCreationDate") +": ");
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), creationDate.RectTransform, Anchor.TopRight), item.Created.ToString(), textAlignment: Alignment.TopRight);
|
|
||||||
|
|
||||||
var modificationDate = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemModificationDate") + ": ");
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), modificationDate.RectTransform, Anchor.TopRight), item.Modified.ToString(), textAlignment: Alignment.TopRight);
|
|
||||||
|
|
||||||
var fileSize = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemFileSize") + ": ");
|
var fileSize = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), content.RectTransform), TextManager.Get("WorkshopItemFileSize") + ": ");
|
||||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), fileSize.RectTransform, Anchor.TopRight), MathUtils.GetBytesReadable(item.Installed ? (long)item.Size : item.DownloadSize), textAlignment: Alignment.TopRight);
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), fileSize.RectTransform, Anchor.TopRight), MathUtils.GetBytesReadable(item.Installed ? (long)item.Size : item.DownloadSize), textAlignment: Alignment.TopRight);
|
||||||
|
|
||||||
var steamButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform, Anchor.TopRight));
|
var dateContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), isHorizontal: true);
|
||||||
|
|
||||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), steamButtonHolder.RectTransform, Anchor.TopRight), TextManager.Get("WorkshopShowItemInSteam"))
|
var creationDate = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), dateContainer.RectTransform), TextManager.Get("WorkshopItemCreationDate") +": ");
|
||||||
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), creationDate.RectTransform, Anchor.CenterRight), item.Created.ToString("dd.MM.yyyy"), textAlignment: Alignment.TopRight);
|
||||||
|
|
||||||
|
var modificationDate = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), dateContainer.RectTransform), TextManager.Get("WorkshopItemModificationDate") + ": ");
|
||||||
|
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), modificationDate.RectTransform, Anchor.CenterRight), item.Modified.ToString("dd.MM.yyyy"), textAlignment: Alignment.TopRight);
|
||||||
|
|
||||||
|
//spacing
|
||||||
|
new GUIFrame(new RectTransform(new Vector2(0.0f, 0.015f), content.RectTransform), style: null);
|
||||||
|
|
||||||
|
var steamButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform));
|
||||||
|
|
||||||
|
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), steamButtonHolder.RectTransform), TextManager.Get("WorkshopShowItemInSteam"))
|
||||||
{
|
{
|
||||||
OnClicked = (btn, userdata) =>
|
OnClicked = (btn, userdata) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user