(7c1aa6679) Reset settings frame when controls are reset, added a button for resetting to default controls & tooltips for the control reset buttons, split keybind textboxes into two columns
This commit is contained in:
@@ -627,14 +627,20 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var inputFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.75f), controlsLayoutGroup.RectTransform), isHorizontal: true)
|
||||
{ Stretch = true, RelativeSpacing = 0.03f };
|
||||
|
||||
var inputFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.8f), controlsLayoutGroup.RectTransform))
|
||||
{ Stretch = true };
|
||||
var inputColumnLeft = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), inputFrame.RectTransform))
|
||||
{ Stretch = true, RelativeSpacing = 0.02f };
|
||||
var inputColumnRight = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), inputFrame.RectTransform))
|
||||
{ Stretch = true, RelativeSpacing = 0.02f };
|
||||
|
||||
var inputNames = Enum.GetValues(typeof(InputType));
|
||||
for (int i = 0; i < inputNames.Length; i++)
|
||||
{
|
||||
var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), inputFrame.RectTransform)) { Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f, Color = new Color(12, 14, 15, 215) };
|
||||
var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f),(i <= (inputNames.Length / 2) ? inputColumnLeft : inputColumnRight).RectTransform))
|
||||
{ Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f, Color = new Color(12, 14, 15, 215) };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), inputContainer.RectTransform, Anchor.TopLeft) { MinSize = new Point(150, 0) },
|
||||
TextManager.Get("InputType." + ((InputType)i)) + ": ", font: GUI.SmallFont) { ForceUpperCase = true };
|
||||
var keyBox = new GUITextBox(new RectTransform(new Vector2(0.7f, 1.0f), inputContainer.RectTransform),
|
||||
@@ -644,9 +650,6 @@ namespace Barotrauma
|
||||
};
|
||||
keyBox.OnSelected += KeyBoxSelected;
|
||||
keyBox.SelectedColor = Color.Gold * 0.3f;
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), inputFrame.RectTransform), style: null);
|
||||
}
|
||||
GUITextBlock aimAssistText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform), TextManager.Get("AimAssist"));
|
||||
GUIScrollBar aimAssistSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform),
|
||||
@@ -678,18 +681,27 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 0.07f), controlsLayoutGroup.RectTransform, Anchor.BottomRight), TextManager.Get("LegacyBindings"), style: "GUIButton")
|
||||
var resetControlsHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), controlsLayoutGroup.RectTransform), isHorizontal: true)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), resetControlsHolder.RectTransform), TextManager.Get("SetDefaultBindings"))
|
||||
{
|
||||
ToolTip = TextManager.Get("SetDefaultBindingsToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
// TODO: add a prompt?
|
||||
SetDefaultBindings(legacy: true);
|
||||
CheckBindings(true);
|
||||
ApplySettings();
|
||||
// TODO: refresh the settings frame instead of closing it.
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
|
||||
GUI.SettingsMenuOpen = false;
|
||||
ResetControls(legacy: false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), resetControlsHolder.RectTransform), TextManager.Get("SetLegacyBindings"))
|
||||
{
|
||||
ToolTip = TextManager.Get("SetLegacyBindingsToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
ResetControls(legacy: true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -723,9 +735,8 @@ namespace Barotrauma
|
||||
LoadDefaultConfig();
|
||||
CheckBindings(true);
|
||||
ApplySettings();
|
||||
// TODO: refresh the settings frame instead of closing it.
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
|
||||
GUI.SettingsMenuOpen = false;
|
||||
ResetSettingsFrame();
|
||||
CreateSettingsFrame();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -775,6 +786,24 @@ namespace Barotrauma
|
||||
CoroutineManager.StartCoroutine(WaitForKeyPress(textBox));
|
||||
}
|
||||
|
||||
private void ResetControls(bool legacy)
|
||||
{
|
||||
// TODO: add a prompt?
|
||||
SetDefaultBindings(legacy: legacy);
|
||||
CheckBindings(true);
|
||||
ApplySettings();
|
||||
if (Screen.Selected == GameMain.MainMenuScreen)
|
||||
{
|
||||
GameMain.MainMenuScreen.ResetSettingsFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetSettingsFrame();
|
||||
CreateSettingsFrame();
|
||||
}
|
||||
SelectTab(Tab.Controls);
|
||||
}
|
||||
|
||||
private bool SelectResolution(GUIComponent selected, object userData)
|
||||
{
|
||||
DisplayMode mode = selected.UserData as DisplayMode;
|
||||
|
||||
@@ -393,8 +393,6 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
item.CreateClientEvent(this);
|
||||
}
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -291,11 +291,6 @@ namespace Barotrauma.Lights
|
||||
spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, null, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw a black rectangle on hulls to hide background lights behind subs
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
//draw characters to obstruct the highlighted items/characters and light sprites
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -527,6 +527,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSettingsFrame()
|
||||
{
|
||||
menuTabs[(int)Tab.Settings].RectTransform.ClearChildren();
|
||||
GameMain.Config.ResetSettingsFrame();
|
||||
GameMain.Config.SettingsFrame.RectTransform.Parent = menuTabs[(int)Tab.Settings].RectTransform;
|
||||
GameMain.Config.SettingsFrame.RectTransform.RelativeSize = Vector2.One;
|
||||
}
|
||||
|
||||
private bool ApplySettings(GUIButton button, object userData)
|
||||
{
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
|
||||
@@ -909,6 +909,71 @@ namespace Barotrauma
|
||||
|
||||
selectedContentPackagePaths = new HashSet<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "keymapping":
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
if (Enum.TryParse(attribute.Name.ToString(), true, out InputType inputType))
|
||||
{
|
||||
if (int.TryParse(attribute.Value.ToString(), out int mouseButton))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Enum.TryParse(attribute.Value.ToString(), true, out Keys key))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "gameplay":
|
||||
jobPreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
string jobIdentifier = ele.GetAttributeString("identifier", "");
|
||||
if (string.IsNullOrEmpty(jobIdentifier)) continue;
|
||||
jobPreferences.Add(jobIdentifier);
|
||||
}
|
||||
break;
|
||||
case "player":
|
||||
defaultPlayerName = subElement.GetAttributeString("name", defaultPlayerName);
|
||||
CharacterHeadIndex = subElement.GetAttributeInt("headindex", CharacterHeadIndex);
|
||||
if (Enum.TryParse(subElement.GetAttributeString("gender", "none"), true, out Gender g))
|
||||
{
|
||||
CharacterGender = g;
|
||||
}
|
||||
if (Enum.TryParse(subElement.GetAttributeString("race", "white"), true, out Race r))
|
||||
{
|
||||
CharacterRace = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterRace = Race.White;
|
||||
}
|
||||
CharacterHairIndex = subElement.GetAttributeInt("hairindex", CharacterHairIndex);
|
||||
CharacterBeardIndex = subElement.GetAttributeInt("beardindex", CharacterBeardIndex);
|
||||
CharacterMoustacheIndex = subElement.GetAttributeInt("moustacheindex", CharacterMoustacheIndex);
|
||||
CharacterFaceAttachmentIndex = subElement.GetAttributeInt("faceattachmentindex", CharacterFaceAttachmentIndex);
|
||||
break;
|
||||
case "tutorials":
|
||||
foreach (XElement tutorialElement in subElement.Elements())
|
||||
{
|
||||
CompletedTutorialNames.Add(tutorialElement.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UnsavedSettings = false;
|
||||
|
||||
selectedContentPackagePaths = new HashSet<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
DebugConsole.ThrowError(TextManager.Get("ContentPackageNotFound").Replace("[packagepath]", missingPackagePath));
|
||||
|
||||
@@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private float blinkTimer;
|
||||
|
||||
private bool itemLoaded;
|
||||
|
||||
private float blinkTimer;
|
||||
|
||||
public PhysicsBody ParentBody;
|
||||
|
||||
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]
|
||||
|
||||
Reference in New Issue
Block a user