(c1468d39d) Overhauled docking interface (WIP)

This commit is contained in:
Joonas Rikkonen
2019-05-03 13:39:54 +03:00
parent 7eb0972d16
commit b551ae7999
101 changed files with 1249 additions and 2246 deletions
@@ -16,6 +16,9 @@ namespace Barotrauma
private GUIListBox saveList;
private GUITextBox saveNameBox, seedBox;
private GUITickBox contextualTutorialBox;
private GUILayoutGroup subPreviewContainer;
private GUILayoutGroup subPreviewContainer;
@@ -23,6 +26,14 @@ namespace Barotrauma
public Action<Submarine, string, string> StartNewGame;
public Action<string> LoadGame;
public bool TutorialSelected
{
get
{
if (contextualTutorialBox == null) return false;
return contextualTutorialBox.Selected;
}
}
private readonly bool isMultiplayer;
@@ -59,6 +70,12 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("MapSeed") + ":");
seedBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, ToolBox.RandomSeed(8));
if (!isMultiplayer)
{
contextualTutorialBox = new GUITickBox(new RectTransform(new Point(32, 32), leftColumn.RectTransform), TextManager.Get("TutorialActive"));
UpdateTutorialSelection();
}
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SelectedSub") + ":");
var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), leftColumn.RectTransform), isHorizontal: true)
{
@@ -385,7 +402,14 @@ namespace Barotrauma
},
Enabled = false
};
}
}
public void UpdateTutorialSelection()
{
if (isMultiplayer) return;
Tutorial contextualTutorial = Tutorial.Tutorials.Find(t => t is ContextualTutorial);
contextualTutorialBox.Selected = (contextualTutorial != null) ? !GameMain.Config.CompletedTutorialNames.Contains(contextualTutorial.Name) : true;
}
private bool SelectSaveFile(GUIComponent component, object obj)
{
@@ -78,6 +78,7 @@ namespace Barotrauma
int i = 0;
var tabValues = Enum.GetValues(typeof(Tab));
float minTextScale = 1.0f;
foreach (Tab tab in tabValues)
{
var tabButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), tabButtonContainer.RectTransform),
@@ -92,12 +93,17 @@ namespace Barotrauma
var buttonSprite = tabButton.Style.Sprites[GUIComponent.ComponentState.None][0];
tabButton.RectTransform.MaxSize = new Point(
(int)(tabButton.Rect.Height * (buttonSprite.Sprite.size.X / buttonSprite.Sprite.size.Y)), int.MaxValue);
tabButtons.Add(tabButton);
tabButton.Font = GUI.LargeFont;
tabButton.TextBlock.AutoScale = true;
minTextScale = Math.Min(tabButton.TextBlock.TextScale, minTextScale);
i++;
}
GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(t => t.TextBlock));
foreach (GUIButton tabButton in tabButtons)
{
tabButton.TextBlock.TextScale = minTextScale;
}
// crew tab -------------------------------------------------------------------------
@@ -59,10 +59,10 @@ namespace Barotrauma
Stretch = true,
RelativeSpacing = 0.02f
};
// === CAMPAIGN
var campaignHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.1f, 0.0f) }, isHorizontal: true);
new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), campaignHolder.RectTransform), "MainMenuCampaignIcon")
{
CanBeFocused = false
@@ -84,17 +84,6 @@ namespace Barotrauma
RelativeSpacing = 0.035f
};
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), campaignList.RectTransform), "Tutorial", textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
ForceUpperCase = true,
UserData = Tab.Tutorials,
OnClicked = (tb, userdata) =>
{
SelectTab(tb, userdata);
return true;
}
};
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), campaignList.RectTransform), TextManager.Get("LoadGameButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
ForceUpperCase = true,
@@ -195,10 +184,6 @@ namespace Barotrauma
UserData = Tab.SteamWorkshop,
OnClicked = SelectTab
};
#if OSX && !DEBUG
steamWorkshopButton.Text += " (Not yet available on MacOS)";
#endif
}
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), TextManager.Get("SubEditorButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
@@ -335,11 +320,13 @@ namespace Barotrauma
return true;
};
UpdateTutorialList();
this.game = game;
}
#endregion
#endregion
#region Selection
#region Selection
public override void Select()
{
base.Select();
@@ -354,6 +341,10 @@ namespace Barotrauma
ResetButtonStates(null);
UpdateTutorialList();
ResetButtonStates(null);
GameAnalyticsManager.SetCustomDimension01("");
}
@@ -397,14 +388,9 @@ namespace Barotrauma
switch (selectedTab)
{
case Tab.NewGame:
if (!GameMain.Config.CampaignDisclaimerShown)
{
selectedTab = 0;
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.NewGame); });
return true;
}
campaignSetupUI.CreateDefaultSaveName();
campaignSetupUI.RandomizeSeed();
campaignSetupUI.UpdateTutorialSelection();
campaignSetupUI.UpdateSubList(Submarine.SavedSubmarines);
break;
case Tab.LoadGame:
@@ -421,13 +407,6 @@ namespace Barotrauma
case Tab.HostServer:
break;
case Tab.Tutorials:
if (!GameMain.Config.CampaignDisclaimerShown)
{
selectedTab = 0;
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.Tutorials); });
return true;
}
UpdateTutorialList();
break;
case Tab.CharacterEditor:
Submarine.MainSub = null;
@@ -458,8 +437,6 @@ namespace Barotrauma
public bool ReturnToMainMenu(GUIButton button, object obj)
{
GUI.PreventPauseMenuToggle = false;
if (Selected != this)
{
Select();
@@ -484,7 +461,7 @@ namespace Barotrauma
otherButton.Selected = false;
}
}
#endregion
#endregion
private void QuickStart()
{
@@ -702,7 +679,6 @@ namespace Barotrauma
GameMain.TitleScreen.TitleSize.Y / 2.0f * GameMain.TitleScreen.Scale + 30.0f),
0.1f);
#if !DEBUG
#if !OSX
if (Steam.SteamManager.USE_STEAM)
{
if (GameMain.Config.UseSteamMatchmaking)
@@ -712,16 +688,6 @@ namespace Barotrauma
}
steamWorkshopButton.Enabled = Steam.SteamManager.IsInitialized;
}
#else
if (Steam.SteamManager.USE_STEAM)
{
if (GameMain.Config.UseSteamMatchmaking)
{
joinServerButton.Enabled = Steam.SteamManager.IsInitialized;
hostServerButton.Enabled = Steam.SteamManager.IsInitialized;
}
}
#endif
#else
joinServerButton.Enabled = true;
hostServerButton.Enabled = true;
@@ -806,11 +772,13 @@ namespace Barotrauma
}
selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"), "");
ContextualTutorial.Selected = campaignSetupUI.TutorialSelected;
GameMain.GameSession = new GameSession(selectedSub, saveName,
GameModePreset.List.Find(g => g.Identifier == "singleplayercampaign"));
(GameMain.GameSession.GameMode as CampaignMode).GenerateMap(mapSeed);
GameMain.LobbyScreen.Select();
}
@@ -832,7 +800,7 @@ namespace Barotrauma
GameMain.LobbyScreen.Select();
}
#region UI Methods
#region UI Methods
private void CreateHostServerFields()
{
Vector2 textLabelSize = new Vector2(1.0f, 0.1f);
@@ -913,7 +881,7 @@ namespace Barotrauma
OnClicked = HostServerClicked
};
}
#endregion
#endregion
}
}
@@ -309,23 +309,14 @@ namespace Barotrauma
return;
}
int prevIndex = -1;
var existingFrame = listBox.Content.FindChild(item);
if (existingFrame != null)
{
prevIndex = listBox.Content.GetChildIndex(existingFrame);
listBox.Content.RemoveChild(existingFrame);
}
if (existingFrame != null) { listBox.Content.RemoveChild(existingFrame); }
var itemFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), listBox.Content.RectTransform, minSize: new Point(0, 80)),
style: "ListBoxElement")
{
UserData = item
};
if (prevIndex > -1)
{
itemFrame.RectTransform.RepositionChildInHierarchy(prevIndex);
}
var innerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), itemFrame.RectTransform, Anchor.Center), isHorizontal: true)
{
@@ -338,7 +329,6 @@ namespace Barotrauma
{
new GUIImage(new RectTransform(new Point(iconSize), innerFrame.RectTransform), itemPreviewSprites[item.PreviewImageUrl], scaleToFit: true)
{
UserData = "previewimage",
CanBeFocused = false
};
}
@@ -346,7 +336,6 @@ namespace Barotrauma
{
new GUIImage(new RectTransform(new Point(iconSize), innerFrame.RectTransform), SteamManager.Instance.DefaultPreviewImage, scaleToFit: true)
{
UserData = "previewimage",
CanBeFocused = false
};
try
@@ -394,7 +383,6 @@ namespace Barotrauma
var titleText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), rightColumn.RectTransform), EnsureUTF8(item.Title), textAlignment: Alignment.CenterLeft, wrap: true)
{
UserData = "titletext",
CanBeFocused = false
};
@@ -559,17 +547,7 @@ namespace Barotrauma
itemPreviewSprites.Add(item.PreviewImageUrl, newSprite);
}
var previewImage = listBox.Content.FindChild(item)?.GetChildByUserData("previewimage") as GUIImage;
if (previewImage != null)
{
previewImage.Sprite = newSprite;
}
else
{
CreateWorkshopItemFrame(item, listBox);
}
CreateWorkshopItemFrame(item, listBox);
if (modsPreviewFrame.FindChild(item) != null)
{
ShowItemPreview(item, modsPreviewFrame);
@@ -597,7 +575,8 @@ namespace Barotrauma
private bool ToggleItemEnabled(GUITickBox tickBox)
{
if (!(tickBox.UserData is Facepunch.Steamworks.Workshop.Item item)) { return false; }
Facepunch.Steamworks.Workshop.Item item = tickBox.UserData as Facepunch.Steamworks.Workshop.Item;
if (item == null) { return false; }
var updateButton = tickBox.Parent.FindChild("updatebutton");
@@ -606,9 +585,7 @@ namespace Barotrauma
{
if (!SteamManager.EnableWorkShopItem(item, false, out errorMsg))
{
tickBox.Visible = false;
tickBox.Selected = false;
if (tickBox.Parent.GetChildByUserData("titletext") is GUITextBlock titleText) { titleText.TextColor = Color.Red; }
tickBox.Enabled = false;
}
}
else
@@ -317,11 +317,10 @@ namespace Barotrauma
Stretch = true
};
entityCategoryButtons.Add(
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), tabButtonHolder.RectTransform), TextManager.Get("MapEntityCategory.All"), style: "GUITabButton")
{
OnClicked = (btn, userdata) => { ClearFilter(); return true; }
});
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), tabButtonHolder.RectTransform), TextManager.Get("MapEntityCategory.All"), style: "GUITabButton")
{
OnClicked = (btn, userdata) => { ClearFilter(); return true; }
};
foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory)))
{
@@ -338,8 +337,6 @@ namespace Barotrauma
});
}
GUITextBlock.AutoScaleAndNormalize(entityCategoryButtons.Select(b => b.TextBlock));
entityList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.9f), entityListHolder.RectTransform, Anchor.BottomCenter))
{
OnSelected = SelectPrefab,