(42760ea3b) First pass of workshop UI improvements
This commit is contained in:
@@ -68,14 +68,81 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Point scrollButtonSize = new Point((int)(200 * GUI.Scale), (int)(30 * GUI.Scale));
|
Point scrollButtonSize = new Point((int)(200 * GUI.Scale), (int)(30 * GUI.Scale));
|
||||||
|
|
||||||
var characterInfo = new CharacterInfo(subElement);
|
crewArea = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.CrewArea, guiFrame.RectTransform), "", Color.Transparent)
|
||||||
characterInfos.Add(characterInfo);
|
{
|
||||||
foreach (XElement invElement in subElement.Elements())
|
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)
|
||||||
{
|
{
|
||||||
if (invElement.Name.ToString().ToLowerInvariant() != "inventory") continue;
|
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||||
characterInfo.InventoryData = invElement;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
scrollButtonUp = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.TopLeft, Pivot.TopLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||||
|
{
|
||||||
|
Visible = false,
|
||||||
|
UserData = -1,
|
||||||
|
OnClicked = ScrollCharacterList
|
||||||
|
};
|
||||||
|
scrollButtonDown = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||||
|
{
|
||||||
|
Visible = false,
|
||||||
|
UserData = 1,
|
||||||
|
OnClicked = ScrollCharacterList
|
||||||
|
};
|
||||||
|
scrollButtonDown.Children.ForEach(c => c.SpriteEffects = SpriteEffects.FlipVertically);
|
||||||
|
|
||||||
|
if (isSinglePlayer)
|
||||||
|
{
|
||||||
|
chatBox = new ChatBox(guiFrame, isSinglePlayer: true)
|
||||||
|
{
|
||||||
|
OnEnterMessage = (textbox, text) =>
|
||||||
|
{
|
||||||
|
if (Character.Controlled?.Info == null)
|
||||||
|
{
|
||||||
|
textbox.Deselect();
|
||||||
|
textbox.Text = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
textbox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default];
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
|
{
|
||||||
|
string msgCommand = ChatMessage.GetChatMessageCommand(text, out string msg);
|
||||||
|
AddSinglePlayerChatMessage(
|
||||||
|
Character.Controlled.Info.Name,
|
||||||
|
msg,
|
||||||
|
((msgCommand == "r" || msgCommand == "radio") && ChatMessage.CanUseRadio(Character.Controlled)) ? ChatMessageType.Radio : ChatMessageType.Default,
|
||||||
|
Character.Controlled);
|
||||||
|
var headset = GetHeadset(Character.Controlled, true);
|
||||||
|
if (headset != null && headset.CanTransmit())
|
||||||
|
{
|
||||||
|
headset.TransmitSignal(stepsTaken: 0, signal: msg, source: headset.Item, sender: Character.Controlled, sendToChat: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textbox.Deselect();
|
||||||
|
textbox.Text = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
chatBox.InputBox.OnTextChanged += chatBox.TypingChatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
var reports = Order.PrefabList.FindAll(o => o.TargetAllCharacters && o.SymbolSprite != null);
|
var reports = Order.PrefabList.FindAll(o => o.TargetAllCharacters && o.SymbolSprite != null);
|
||||||
@@ -114,12 +181,14 @@ namespace Barotrauma
|
|||||||
Visible = false
|
Visible = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var img = new GUIImage(new RectTransform(Vector2.One, btn.RectTransform), order.Prefab.SymbolSprite, scaleToFit: true)
|
var characterInfo = new CharacterInfo(subElement);
|
||||||
|
characterInfos.Add(characterInfo);
|
||||||
|
foreach (XElement invElement in subElement.Elements())
|
||||||
{
|
{
|
||||||
Color = order.Color,
|
if (invElement.Name.ToString().ToLowerInvariant() != "inventory") continue;
|
||||||
HoverColor = Color.Lerp(order.Color, Color.White, 0.5f),
|
characterInfo.InventoryData = invElement;
|
||||||
ToolTip = order.Name
|
break;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private enum Tab
|
private enum Tab
|
||||||
{
|
{
|
||||||
|
Mods,
|
||||||
Browse,
|
Browse,
|
||||||
Publish
|
Publish
|
||||||
}
|
}
|
||||||
@@ -38,7 +39,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private ContentPackage itemContentPackage;
|
private ContentPackage itemContentPackage;
|
||||||
private Facepunch.Steamworks.Workshop.Editor itemEditor;
|
private Facepunch.Steamworks.Workshop.Editor itemEditor;
|
||||||
|
|
||||||
public SteamWorkshopScreen()
|
public SteamWorkshopScreen()
|
||||||
{
|
{
|
||||||
int width = Math.Min(GameMain.GraphicsWidth - 160, 1000);
|
int width = Math.Min(GameMain.GraphicsWidth - 160, 1000);
|
||||||
@@ -48,30 +49,58 @@ namespace Barotrauma
|
|||||||
|
|
||||||
tabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length];
|
tabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length];
|
||||||
|
|
||||||
menu = new GUIFrame(new RectTransform(new Vector2(0.8f, 0.9f), GUI.Canvas, Anchor.Center));
|
menu = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.5f), GUI.Canvas, Anchor.Center));
|
||||||
|
|
||||||
var buttonContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.05f), menu.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.05f) }, style: null);
|
var container = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), menu.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) }) { Stretch = true };
|
||||||
var tabContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.85f), menu.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) }, style: null);
|
|
||||||
|
var tabContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.7f), container.RectTransform), style: "InnerFrame");
|
||||||
GUIButton backButton = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), buttonContainer.RectTransform),
|
|
||||||
TextManager.Get("Back"))
|
var tabButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), tabContainer.RectTransform, Anchor.TopRight, Pivot.BottomRight),
|
||||||
|
isHorizontal: true)
|
||||||
{
|
{
|
||||||
OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu
|
RelativeSpacing = 0.01f,
|
||||||
|
Stretch = true
|
||||||
};
|
};
|
||||||
backButton.SelectedColor = backButton.Color;
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Tab tab in Enum.GetValues(typeof(Tab)))
|
foreach (Tab tab in Enum.GetValues(typeof(Tab)))
|
||||||
{
|
{
|
||||||
GUIButton tabButton = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), buttonContainer.RectTransform) { RelativeOffset = new Vector2(0.4f + 0.15f * i, 0.0f) },
|
GUIButton tabButton = new GUIButton(new RectTransform(new Vector2(0.05f, 1.0f), tabButtonHolder.RectTransform) { RelativeOffset = new Vector2(0.4f + 0.15f * i, 0.0f) },
|
||||||
TextManager.Get(tab.ToString() + "Tab"))
|
TextManager.Get(tab.ToString() + "Tab"), style: "GUITabButton")
|
||||||
{
|
{
|
||||||
UserData = tab,
|
UserData = tab,
|
||||||
OnClicked = (btn, userData) => { SelectTab((Tab)userData); return true; }
|
OnClicked = (btn, userData) =>
|
||||||
|
{
|
||||||
|
SelectTab((Tab)userData); return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
//Install tab
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
tabs[(int)Tab.Mods] = new GUIFrame(new RectTransform(Vector2.One, tabContainer.RectTransform, Anchor.Center), style: null);
|
||||||
|
|
||||||
|
var modsContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 1.0f), tabs[(int)Tab.Mods].RectTransform))
|
||||||
|
{
|
||||||
|
Stretch = true,
|
||||||
|
RelativeSpacing = 0.02f
|
||||||
|
};
|
||||||
|
|
||||||
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), modsContainer.RectTransform), TextManager.Get("SubscribedMods"));
|
||||||
|
subscribedItemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), modsContainer.RectTransform))
|
||||||
|
{
|
||||||
|
OnSelected = (GUIComponent component, object userdata) =>
|
||||||
|
{
|
||||||
|
if (GUI.MouseOn is GUIButton || GUI.MouseOn?.Parent is GUIButton) { return false; }
|
||||||
|
ShowItemPreview(userdata as Facepunch.Steamworks.Workshop.Item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
itemPreviewFrame = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), tabs[(int)Tab.Mods].RectTransform, Anchor.TopRight), style: "InnerFrame");
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//Browse tab
|
//Browse tab
|
||||||
@@ -84,17 +113,6 @@ namespace Barotrauma
|
|||||||
Stretch = true,
|
Stretch = true,
|
||||||
RelativeSpacing = 0.02f
|
RelativeSpacing = 0.02f
|
||||||
};
|
};
|
||||||
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), listContainer.RectTransform), TextManager.Get("SubscribedMods"));
|
|
||||||
subscribedItemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), listContainer.RectTransform))
|
|
||||||
{
|
|
||||||
OnSelected = (GUIComponent component, object userdata) =>
|
|
||||||
{
|
|
||||||
if (GUI.MouseOn is GUIButton || GUI.MouseOn?.Parent is GUIButton) { return false; }
|
|
||||||
ShowItemPreview(userdata as Facepunch.Steamworks.Workshop.Item);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), listContainer.RectTransform), TextManager.Get("PopularMods"));
|
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), listContainer.RectTransform), TextManager.Get("PopularMods"));
|
||||||
topItemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), listContainer.RectTransform))
|
topItemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), listContainer.RectTransform))
|
||||||
@@ -178,7 +196,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
createItemFrame = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), tabs[(int)Tab.Publish].RectTransform, Anchor.TopRight), style: "InnerFrame");
|
createItemFrame = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), tabs[(int)Tab.Publish].RectTransform, Anchor.TopRight), style: "InnerFrame");
|
||||||
|
|
||||||
SelectTab(Tab.Browse);
|
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), container.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.2f) });
|
||||||
|
|
||||||
|
GUIButton backButton = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), buttonContainer.RectTransform),
|
||||||
|
TextManager.Get("Back"))
|
||||||
|
{
|
||||||
|
OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu
|
||||||
|
};
|
||||||
|
backButton.SelectedColor = backButton.Color;
|
||||||
|
|
||||||
|
SelectTab(Tab.Mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Select()
|
public override void Select()
|
||||||
@@ -191,7 +218,7 @@ namespace Barotrauma
|
|||||||
itemEditor = null;
|
itemEditor = null;
|
||||||
|
|
||||||
RefreshItemLists();
|
RefreshItemLists();
|
||||||
SelectTab(Tab.Browse);
|
SelectTab(Tab.Mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectTab(Tab tab)
|
private void SelectTab(Tab tab)
|
||||||
|
|||||||
Reference in New Issue
Block a user