v0.13.0.11
This commit is contained in:
@@ -15,12 +15,26 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Steam;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class MainMenuScreen : Screen
|
||||
{
|
||||
public enum Tab { NewGame = 1, LoadGame = 2, HostServer = 3, Settings = 4, Tutorials = 5, JoinServer = 6, CharacterEditor = 7, SubmarineEditor = 8, QuickStartDev = 9, ProfilingTestBench = 10, SteamWorkshop = 11, Credits = 12, Empty = 13 }
|
||||
public enum Tab
|
||||
{
|
||||
NewGame = 0,
|
||||
LoadGame = 1,
|
||||
HostServer = 2,
|
||||
Settings = 3,
|
||||
Tutorials = 4,
|
||||
JoinServer = 5,
|
||||
CharacterEditor = 6,
|
||||
SubmarineEditor = 7,
|
||||
SteamWorkshop = 8,
|
||||
Credits = 9,
|
||||
Empty = 10
|
||||
}
|
||||
|
||||
private readonly GUIComponent buttonsParent;
|
||||
|
||||
@@ -29,8 +43,7 @@ namespace Barotrauma
|
||||
private CampaignSetupUI campaignSetupUI;
|
||||
|
||||
private GUITextBox serverNameBox, /*portBox, queryPortBox,*/ passwordBox, maxPlayersBox;
|
||||
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaEnabledBox;
|
||||
private GUIDropDown karmaPresetDD;
|
||||
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaBox;
|
||||
private readonly GUIFrame downloadingModsContainer, enableModsContainer;
|
||||
private readonly GUIButton joinServerButton, hostServerButton, steamWorkshopButton;
|
||||
private readonly GameMain game;
|
||||
@@ -41,7 +54,7 @@ namespace Barotrauma
|
||||
private GUIComponent remoteContentContainer;
|
||||
private XDocument remoteContentDoc;
|
||||
|
||||
private Tab selectedTab;
|
||||
private Tab selectedTab = Tab.Empty;
|
||||
|
||||
private Sprite backgroundSprite;
|
||||
|
||||
@@ -335,6 +348,16 @@ namespace Barotrauma
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("EditorDisclaimerWikiLink"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
|
||||
{
|
||||
ForceUpperCase = true,
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
string url = TextManager.Get("EditorDisclaimerWikiUrl", returnNull: true) ?? "https://barotraumagame.com/wiki";
|
||||
GameMain.Instance.ShowOpenUrlInWebBrowserPrompt(url, promptExtensionTag: "wikinotice");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("CreditsButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
|
||||
{
|
||||
ForceUpperCase = true,
|
||||
@@ -353,10 +376,13 @@ namespace Barotrauma
|
||||
"Quickstart (dev)", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.QuickStartDev,
|
||||
UserData = Tab.Empty,
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
QuickStart();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -364,11 +390,32 @@ namespace Barotrauma
|
||||
"Profiling", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.ProfilingTestBench,
|
||||
UserData = Tab.Empty,
|
||||
ToolTip = "Enables performance indicators and starts the game with a fixed sub, crew and level to make it easier to compare the performance between sessions.",
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
QuickStart(fixedSeed: true);
|
||||
GameMain.ShowPerf = true;
|
||||
GameMain.ShowFPS = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(40, 180) },
|
||||
"Join Localhost", style: "GUIButtonLarge", color: GUI.Style.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.Empty,
|
||||
ToolTip = "Connects to a locally hosted dedicated server, assuming default port.",
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
SelectTab(tb, userdata);
|
||||
|
||||
GameMain.Client = new GameClient(string.IsNullOrEmpty(GameMain.Config.PlayerName) ? SteamManager.GetUsername() : GameMain.Config.PlayerName,
|
||||
IPAddress.Loopback.ToString(), 0, "localhost", 0, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -538,13 +585,13 @@ namespace Barotrauma
|
||||
case Tab.NewGame:
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(Tab.NewGame);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.NewGame); });
|
||||
return true;
|
||||
}
|
||||
@@ -564,13 +611,13 @@ namespace Barotrauma
|
||||
case Tab.JoinServer:
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(Tab.JoinServer);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.JoinServer); });
|
||||
return true;
|
||||
}
|
||||
@@ -580,18 +627,18 @@ namespace Barotrauma
|
||||
if (GameMain.Config.ContentPackageSelectionDirty)
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("ServerRestartRequiredContentPackage", fallBackTag: "RestartRequiredGeneric"));
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
return false;
|
||||
}
|
||||
if (GameMain.Config.ShowTutorialSkipWarning)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
ShowTutorialSkipWarning(tab);
|
||||
return true;
|
||||
}
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.HostServer); });
|
||||
return true;
|
||||
}
|
||||
@@ -599,7 +646,7 @@ namespace Barotrauma
|
||||
case Tab.Tutorials:
|
||||
if (!GameMain.Config.CampaignDisclaimerShown)
|
||||
{
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.Tutorials); });
|
||||
return true;
|
||||
}
|
||||
@@ -612,14 +659,6 @@ namespace Barotrauma
|
||||
case Tab.SubmarineEditor:
|
||||
CoroutineManager.StartCoroutine(SelectScreenWithWaitCursor(GameMain.SubEditorScreen));
|
||||
break;
|
||||
case Tab.QuickStartDev:
|
||||
QuickStart();
|
||||
break;
|
||||
case Tab.ProfilingTestBench:
|
||||
QuickStart(fixedSeed: true);
|
||||
GameMain.ShowPerf = true;
|
||||
GameMain.ShowFPS = true;
|
||||
break;
|
||||
case Tab.SteamWorkshop:
|
||||
if (!Steam.SteamManager.IsInitialized) return false;
|
||||
CoroutineManager.StartCoroutine(SelectScreenWithWaitCursor(GameMain.SteamWorkshopScreen));
|
||||
@@ -630,7 +669,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case Tab.Empty:
|
||||
titleText.Visible = true;
|
||||
selectedTab = 0;
|
||||
selectedTab = Tab.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -709,7 +748,7 @@ namespace Barotrauma
|
||||
var gamesession = new GameSession(
|
||||
selectedSub,
|
||||
GameModePreset.DevSandbox,
|
||||
missionPrefab: null);
|
||||
missionPrefabs: null);
|
||||
//(gamesession.GameMode as SinglePlayerCampaign).GenerateMap(ToolBox.RandomSeed(8));
|
||||
gamesession.StartRound(fixedSeed ? "abcd" : ToolBox.RandomSeed(8), difficulty: 40);
|
||||
GameMain.GameScreen.Select();
|
||||
@@ -886,8 +925,8 @@ namespace Barotrauma
|
||||
" -public " + isPublicBox.Selected.ToString() +
|
||||
" -playstyle " + ((PlayStyle)playstyleBanner.UserData).ToString() +
|
||||
" -banafterwrongpassword " + wrongPasswordBanBox.Selected.ToString() +
|
||||
" -karmaenabled " + karmaEnabledBox.Selected.ToString() +
|
||||
" -karmapreset " + (karmaPresetDD.SelectedData?.ToString() ?? "default") +
|
||||
" -karmaenabled " + (!karmaBox.Selected).ToString() +
|
||||
" -karmapreset default" +
|
||||
" -maxplayers " + maxPlayersBox.Text;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(passwordBox.Text))
|
||||
@@ -946,7 +985,7 @@ namespace Barotrauma
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
Frame.AddToGUIUpdateList();
|
||||
if (selectedTab > 0 && menuTabs[(int)selectedTab] != null)
|
||||
if (selectedTab < Tab.Empty && menuTabs[(int)selectedTab] != null)
|
||||
{
|
||||
menuTabs[(int)selectedTab].AddToGUIUpdateList();
|
||||
}
|
||||
@@ -1043,7 +1082,7 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
private void StartGame(SubmarineInfo selectedSub, string saveName, string mapSeed)
|
||||
private void StartGame(SubmarineInfo selectedSub, string saveName, string mapSeed, CampaignSettings settings)
|
||||
{
|
||||
if (string.IsNullOrEmpty(saveName)) return;
|
||||
|
||||
@@ -1082,7 +1121,7 @@ namespace Barotrauma
|
||||
|
||||
selectedSub = new SubmarineInfo(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"));
|
||||
|
||||
GameMain.GameSession = new GameSession(selectedSub, saveName, GameModePreset.SinglePlayerCampaign, mapSeed);
|
||||
GameMain.GameSession = new GameSession(selectedSub, saveName, GameModePreset.SinglePlayerCampaign, settings, mapSeed);
|
||||
((SinglePlayerCampaign)GameMain.GameSession.GameMode).LoadNewLevel();
|
||||
}
|
||||
|
||||
@@ -1134,6 +1173,10 @@ namespace Barotrauma
|
||||
(int)(campaignSetupUI.StartButton.TextBlock.TextSize.X * 1.5f),
|
||||
campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
startButtonContainer.RectTransform.MinSize = new Point(0, campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
if (campaignSetupUI.EnableRadiationToggle != null)
|
||||
{
|
||||
campaignSetupUI.EnableRadiationToggle.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
campaignSetupUI.InitialMoneyText.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
|
||||
@@ -1141,9 +1184,11 @@ namespace Barotrauma
|
||||
{
|
||||
menuTabs[(int)Tab.HostServer].ClearChildren();
|
||||
|
||||
int port = NetConfig.DefaultPort;
|
||||
int queryPort = NetConfig.DefaultQueryPort;
|
||||
string name = "";
|
||||
string password = "";
|
||||
int maxPlayers = 8;
|
||||
bool isPublic = true;
|
||||
bool banAfterWrongPassword = false;
|
||||
bool karmaEnabled = true;
|
||||
string selectedKarmaPreset = "";
|
||||
PlayStyle selectedPlayStyle = PlayStyle.Casual;
|
||||
@@ -1152,8 +1197,10 @@ namespace Barotrauma
|
||||
XDocument settingsDoc = XMLExtensions.TryLoadXml(ServerSettings.SettingsFile);
|
||||
if (settingsDoc != null)
|
||||
{
|
||||
port = settingsDoc.Root.GetAttributeInt("port", port);
|
||||
queryPort = settingsDoc.Root.GetAttributeInt("queryport", queryPort);
|
||||
name = settingsDoc.Root.GetAttributeString("name", name);
|
||||
password = settingsDoc.Root.GetAttributeString("password", password);
|
||||
isPublic = settingsDoc.Root.GetAttributeBool("public", isPublic);
|
||||
banAfterWrongPassword = settingsDoc.Root.GetAttributeBool("banafterwrongpassword", banAfterWrongPassword);
|
||||
|
||||
int maxPlayersElement = settingsDoc.Root.GetAttributeInt("maxplayers", maxPlayers);
|
||||
if (maxPlayersElement > NetConfig.MaxPlayers)
|
||||
@@ -1255,30 +1302,12 @@ namespace Barotrauma
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), style: null);
|
||||
|
||||
var label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerName"), textAlignment: textAlignment);
|
||||
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
serverNameBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), text: name, textAlignment: textAlignment)
|
||||
{
|
||||
MaxTextLength = NetConfig.ServerNameMaxLength,
|
||||
OverflowClip = true
|
||||
};
|
||||
label.RectTransform.MaxSize = serverNameBox.RectTransform.MaxSize;
|
||||
|
||||
/* TODO: allow lidgren servers from client?
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerPort"), textAlignment: textAlignment);
|
||||
portBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
{
|
||||
Text = port.ToString(),
|
||||
ToolTip = TextManager.Get("ServerPortToolTip")
|
||||
};
|
||||
|
||||
#if USE_STEAM
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("ServerQueryPort"), textAlignment: textAlignment);
|
||||
queryPortBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
{
|
||||
Text = queryPort.ToString(),
|
||||
ToolTip = TextManager.Get("ServerQueryPortToolTip")
|
||||
};
|
||||
#endif
|
||||
*/
|
||||
|
||||
var maxPlayersLabel = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("MaxPlayers"), textAlignment: textAlignment);
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(textFieldSize, maxPlayersLabel.RectTransform, Anchor.CenterRight), isHorizontal: true)
|
||||
@@ -1304,7 +1333,7 @@ namespace Barotrauma
|
||||
maxPlayersLabel.RectTransform.MaxSize = maxPlayersBox.RectTransform.MaxSize;
|
||||
|
||||
label = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("Password"), textAlignment: textAlignment);
|
||||
passwordBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), textAlignment: textAlignment)
|
||||
passwordBox = new GUITextBox(new RectTransform(textFieldSize, label.RectTransform, Anchor.CenterRight), text: password, textAlignment: textAlignment)
|
||||
{
|
||||
Censor = true
|
||||
};
|
||||
@@ -1316,10 +1345,14 @@ namespace Barotrauma
|
||||
|
||||
isPublicBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("PublicServer"))
|
||||
{
|
||||
Selected = isPublic,
|
||||
ToolTip = TextManager.Get("PublicServerToolTip")
|
||||
};
|
||||
|
||||
wrongPasswordBanBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("ServerSettingsBanAfterWrongPassword"));
|
||||
wrongPasswordBanBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaUpper.RectTransform), TextManager.Get("ServerSettingsBanAfterWrongPassword"))
|
||||
{
|
||||
Selected = banAfterWrongPassword
|
||||
};
|
||||
|
||||
tickboxAreaUpper.RectTransform.MaxSize = isPublicBox.RectTransform.MaxSize;
|
||||
|
||||
@@ -1327,31 +1360,13 @@ namespace Barotrauma
|
||||
|
||||
var tickboxAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, tickBoxSize.Y), parent.RectTransform), isHorizontal: true);
|
||||
|
||||
karmaEnabledBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform), TextManager.Get("ServerSettingsUseKarma"))
|
||||
karmaBox = new GUITickBox(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform), TextManager.Get("HostServerKarmaSetting"))
|
||||
{
|
||||
ToolTip = TextManager.Get("karmaexplanation"),
|
||||
OnSelected = (tb) =>
|
||||
{
|
||||
karmaPresetDD.Enabled = karmaPresetDD.ButtonEnabled = tb.Selected;
|
||||
return true;
|
||||
}
|
||||
Selected = !karmaEnabled,
|
||||
ToolTip = TextManager.Get("hostserverkarmasettingtooltip")
|
||||
};
|
||||
karmaPresetDD = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1.0f), tickboxAreaLower.RectTransform))
|
||||
{
|
||||
ButtonEnabled = false,
|
||||
Enabled = false
|
||||
};
|
||||
var tempKarmaManager = new KarmaManager();
|
||||
foreach (string karmaPreset in tempKarmaManager.Presets.Keys)
|
||||
{
|
||||
karmaPresetDD.AddItem(TextManager.Get("KarmaPreset." + karmaPreset), karmaPreset);
|
||||
if (karmaPreset == selectedKarmaPreset) { karmaPresetDD.SelectItem(karmaPreset); }
|
||||
}
|
||||
if (karmaPresetDD.SelectedIndex == -1) { karmaPresetDD.Select(0); }
|
||||
|
||||
karmaEnabledBox.Selected = karmaEnabled;
|
||||
|
||||
tickboxAreaLower.RectTransform.MaxSize = karmaEnabledBox.RectTransform.MaxSize;
|
||||
tickboxAreaLower.RectTransform.MaxSize = karmaBox.RectTransform.MaxSize;
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), style: null);
|
||||
|
||||
Reference in New Issue
Block a user