Control settings, more server settings, selecting character face
This commit is contained in:
@@ -199,6 +199,23 @@ namespace Barotrauma
|
||||
|
||||
public void SelectTab(Tab tab)
|
||||
{
|
||||
int oldTab = selectedTab;
|
||||
|
||||
|
||||
if (GameMain.Config.UnsavedSettings)
|
||||
{
|
||||
var applyBox = new GUIMessageBox("Apply changes?", "Do you want to apply the settings or discard the changes?",
|
||||
new string[] {"Apply", "Discard"});
|
||||
applyBox.Buttons[0].OnClicked += applyBox.Close;
|
||||
applyBox.Buttons[0].OnClicked += ApplySettings;
|
||||
applyBox.Buttons[0].UserData = tab;
|
||||
applyBox.Buttons[1].OnClicked += applyBox.Close;
|
||||
applyBox.Buttons[1].OnClicked += DiscardSettings;
|
||||
applyBox.Buttons[1].UserData = tab;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
selectedTab = (int)tab;
|
||||
|
||||
switch (selectedTab)
|
||||
@@ -207,11 +224,29 @@ namespace Barotrauma
|
||||
UpdateLoadScreen();
|
||||
break;
|
||||
case (int)Tab.Settings:
|
||||
GameMain.Config.ResetSettingsFrame();
|
||||
menuTabs[(int)Tab.Settings] = GameMain.Config.SettingsFrame;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ApplySettings(GUIButton button, object obj)
|
||||
{
|
||||
GameMain.Config.Save("config.xml");
|
||||
selectedTab = (int)obj;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DiscardSettings(GUIButton button, object obj)
|
||||
{
|
||||
GameMain.Config.Load("config.xml");
|
||||
selectedTab = (int)obj;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private bool TutorialButtonClicked(GUIButton button, object obj)
|
||||
{
|
||||
TutorialMode.StartTutorial();
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Barotrauma
|
||||
//server info panel ------------------------------------------------------------
|
||||
|
||||
infoFrame = new GUIFrame(new Rectangle(0, 0, (int)(panelRect.Width * 0.7f), (int)(panelRect.Height * 0.6f)), GUI.Style, menu);
|
||||
//infoFrame.Padding = GUI.style.smallPadding;
|
||||
infoFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); ;
|
||||
|
||||
//chatbox ----------------------------------------------------------------------
|
||||
GUIFrame chatFrame = new GUIFrame(
|
||||
@@ -127,11 +127,12 @@ namespace Barotrauma
|
||||
(int)(panelRect.Width * 0.7f),
|
||||
(int)(panelRect.Height * 0.4f - 20)),
|
||||
GUI.Style, menu);
|
||||
chatFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 40.0f);
|
||||
|
||||
chatBox = new GUIListBox(new Rectangle(0,0,0,chatFrame.Rect.Height-80), Color.White, GUI.Style, chatFrame);
|
||||
textBox = new GUITextBox(new Rectangle(0, 25, 0, 25), Alignment.Bottom, GUI.Style, chatFrame);
|
||||
textBox.Font = GUI.SmallFont;
|
||||
textBox.OnEnter = EnterChatMessage;
|
||||
textBox.OnEnterPressed = EnterChatMessage;
|
||||
|
||||
//player info panel ------------------------------------------------------------
|
||||
|
||||
@@ -148,6 +149,8 @@ namespace Barotrauma
|
||||
(int)(panelRect.Width * 0.3f - 20), (int)(panelRect.Height * 0.4f - 20)),
|
||||
GUI.Style, menu);
|
||||
|
||||
playerListFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 40.0f);
|
||||
|
||||
playerList = new GUIListBox(new Rectangle(0,0,0,0), null, GUI.Style, playerListFrame);
|
||||
playerList.OnSelected = SelectPlayer;
|
||||
|
||||
@@ -278,10 +281,14 @@ namespace Barotrauma
|
||||
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
startButton.OnClicked = GameMain.Server.StartGameClicked;
|
||||
startButton.UserData = "startButton";
|
||||
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent);
|
||||
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
|
||||
banListButton.UserData = "banListButton";
|
||||
@@ -299,6 +306,10 @@ namespace Barotrauma
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
}
|
||||
|
||||
if (GameMain.Server.RandomizeSeed) seedBox.Text = ToolBox.RandomSeed(8);
|
||||
if (GameMain.Server.SubSelectionMode == SelectionMode.Random) subList.Select(Rand.Range(0,subList.CountChildren));
|
||||
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random) modeList.Select(Rand.Range(0, modeList.CountChildren));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -322,12 +333,18 @@ namespace Barotrauma
|
||||
playYourself.UserData = "playyourself";
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(60, 30, 200, 30), "Name: ", GUI.Style, myPlayerFrame);
|
||||
new GUITextBlock(new Rectangle(100, 30, 200, 30), "Name: ", GUI.Style, myPlayerFrame);
|
||||
|
||||
GUITextBox playerName = new GUITextBox(new Rectangle(60, 55, 0, 20),
|
||||
Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
||||
GUITextBox playerName = new GUITextBox(new Rectangle(100, 55, 0, 20), Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
||||
playerName.Text = characterInfo.Name;
|
||||
playerName.OnEnter += ChangeCharacterName;
|
||||
playerName.OnEnterPressed += ChangeCharacterName;
|
||||
|
||||
GUIButton toggleHead = new GUIButton(new Rectangle(00, 50, 20, 20), "<", GUI.Style, myPlayerFrame);
|
||||
toggleHead.UserData = -1;
|
||||
toggleHead.OnClicked = ToggleHead;
|
||||
toggleHead = new GUIButton(new Rectangle(40, 50, 20, 20), ">", GUI.Style, myPlayerFrame);
|
||||
toggleHead.UserData = 1;
|
||||
toggleHead.OnClicked = ToggleHead;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 100, 200, 30), "Gender: ", GUI.Style, myPlayerFrame);
|
||||
|
||||
@@ -374,9 +391,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool TogglePlayYourself(object obj)
|
||||
private bool TogglePlayYourself(GUITickBox tickBox)
|
||||
{
|
||||
GUITickBox tickBox = obj as GUITickBox;
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
GameMain.Server.CharacterInfo = new CharacterInfo(Character.HumanConfigFile, GameMain.Server.Name);
|
||||
@@ -398,16 +414,13 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ToggleAutoRestart(object obj)
|
||||
private bool ToggleAutoRestart(GUITickBox tickBox)
|
||||
{
|
||||
if (GameMain.Server == null) return false;
|
||||
|
||||
GUITickBox tickBox = obj as GUITickBox;
|
||||
if (tickBox==null) return false;
|
||||
|
||||
GameMain.Server.AutoRestart = tickBox.Selected;
|
||||
|
||||
GameMain.Server.UpdateNetLobby(obj);
|
||||
GameMain.Server.UpdateNetLobby(tickBox);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -622,10 +635,23 @@ namespace Barotrauma
|
||||
GUIComponent existing = myPlayerFrame.FindChild("playerhead");
|
||||
if (existing != null) myPlayerFrame.RemoveChild(existing);
|
||||
|
||||
GUIImage image = new GUIImage(new Rectangle(0, 40, 30, 30), characterInfo.HeadSprite, Alignment.TopLeft, myPlayerFrame);
|
||||
GUIImage image = new GUIImage(new Rectangle(20, 40, 30, 30), characterInfo.HeadSprite, Alignment.TopLeft, myPlayerFrame);
|
||||
image.UserData = "playerhead";
|
||||
}
|
||||
|
||||
private bool ToggleHead(GUIButton button, object userData)
|
||||
{
|
||||
int dir = (int)userData;
|
||||
|
||||
if (GameMain.NetworkMember.CharacterInfo == null) return true;
|
||||
|
||||
GameMain.NetworkMember.CharacterInfo.HeadSpriteId += dir;
|
||||
|
||||
UpdatePreviewPlayer(GameMain.NetworkMember.CharacterInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SwitchGender(GUIButton button, object obj)
|
||||
{
|
||||
Gender gender = (Gender)obj;
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
enum SelectionMode
|
||||
{
|
||||
Manual = 0, Random = 1, Vote = 2
|
||||
}
|
||||
|
||||
partial class GameServer : NetworkMember
|
||||
{
|
||||
public bool ShowNetStats;
|
||||
|
||||
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40);
|
||||
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
||||
|
||||
private SelectionMode subSelectionMode, modeSelectionMode;
|
||||
|
||||
private bool randomizeSeed;
|
||||
|
||||
private bool registeredToMaster;
|
||||
|
||||
private BanList banList;
|
||||
|
||||
private string password;
|
||||
|
||||
private GUIFrame settingsFrame;
|
||||
|
||||
public float AutoRestartTimer;
|
||||
|
||||
private bool autoRestart;
|
||||
|
||||
public bool AutoRestart
|
||||
{
|
||||
get { return (connectedClients.Count == 0) ? false : autoRestart; }
|
||||
set
|
||||
{
|
||||
autoRestart = value;
|
||||
|
||||
AutoRestartTimer = autoRestart ? 20.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public SelectionMode SubSelectionMode
|
||||
{
|
||||
get { return subSelectionMode; }
|
||||
}
|
||||
|
||||
public SelectionMode ModeSelectionMode
|
||||
{
|
||||
get { return modeSelectionMode; }
|
||||
}
|
||||
|
||||
public bool RandomizeSeed
|
||||
{
|
||||
get { return randomizeSeed; }
|
||||
}
|
||||
|
||||
public BanList BanList
|
||||
{
|
||||
get { return banList; }
|
||||
}
|
||||
|
||||
private void CreateSettingsFrame()
|
||||
{
|
||||
settingsFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f);
|
||||
|
||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,400), null, Alignment.Center, GUI.Style, settingsFrame);
|
||||
|
||||
var randomizeLevelBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Randomize level seed", Alignment.Left, innerFrame);
|
||||
randomizeLevelBox.OnSelected = ToggleRandomizeSeed;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 35, 100, 20), "Submarine selection:", GUI.Style, innerFrame);
|
||||
var selectionFrame = new GUIFrame(new Rectangle(0, 60, 300, 20), null, innerFrame);
|
||||
for (int i = 0; i<3; i++)
|
||||
{
|
||||
var selectionTick = new GUITickBox(new Rectangle(i * 100, 00, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||
selectionTick.Selected = i == (int)subSelectionMode;
|
||||
selectionTick.OnSelected = SwitchSubSelection;
|
||||
selectionTick.UserData = (SelectionMode)i;
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 85, 100, 20), "Mode selection:", GUI.Style, innerFrame);
|
||||
selectionFrame = new GUIFrame(new Rectangle(0, 110, 300, 20), null, innerFrame);
|
||||
for (int i = 0; i<3; i++)
|
||||
{
|
||||
var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||
selectionTick.Selected = i == (int)modeSelectionMode;
|
||||
selectionTick.OnSelected = SwitchModeSelection;
|
||||
selectionTick.UserData = (SelectionMode)i;
|
||||
}
|
||||
}
|
||||
|
||||
private bool SwitchSubSelection(GUITickBox tickBox)
|
||||
{
|
||||
subSelectionMode = (SelectionMode)tickBox.UserData;
|
||||
|
||||
foreach (GUIComponent otherTickBox in tickBox.Parent.children)
|
||||
{
|
||||
if (otherTickBox == tickBox) continue;
|
||||
((GUITickBox)otherTickBox).Selected = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SwitchModeSelection(GUITickBox tickBox)
|
||||
{
|
||||
modeSelectionMode = (SelectionMode)tickBox.UserData;
|
||||
|
||||
foreach (GUIComponent otherTickBox in tickBox.Parent.children)
|
||||
{
|
||||
if (otherTickBox == tickBox) continue;
|
||||
((GUITickBox)otherTickBox).Selected = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ToggleRandomizeSeed(GUITickBox tickBox)
|
||||
{
|
||||
randomizeSeed = tickBox.Selected;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ToggleSettingsFrame(GUIButton button, object obj)
|
||||
{
|
||||
if (settingsFrame==null)
|
||||
{
|
||||
CreateSettingsFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsFrame = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class SettingsScreen : Screen
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user