diff --git a/Launcher2/LauncherMain.cs b/Launcher2/LauncherMain.cs
index 595dbadc4..3c943314b 100644
--- a/Launcher2/LauncherMain.cs
+++ b/Launcher2/LauncherMain.cs
@@ -243,7 +243,7 @@ namespace Launcher2
return true;
}
- private bool ToggleFullScreen(object obj)
+ private bool ToggleFullScreen(GUITickBox tickBox)
{
settings.FullScreenEnabled = !settings.FullScreenEnabled;
return true;
diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index a298fc32a..3fadc6abb 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -103,6 +103,7 @@
+
@@ -225,7 +226,6 @@
-
diff --git a/Subsurface/Content/Items/Button/button.xml b/Subsurface/Content/Items/Button/button.xml
index e89794e0d..2e487675d 100644
--- a/Subsurface/Content/Items/Button/button.xml
+++ b/Subsurface/Content/Items/Button/button.xml
@@ -15,12 +15,12 @@
-
+
-
diff --git a/Subsurface/Content/Items/Door/doors.xml b/Subsurface/Content/Items/Door/doors.xml
index 298acf04d..8c0819d0e 100644
--- a/Subsurface/Content/Items/Door/doors.xml
+++ b/Subsurface/Content/Items/Door/doors.xml
@@ -19,7 +19,7 @@
-
+
@@ -48,7 +48,7 @@
-
+
diff --git a/Subsurface/Content/Items/Electricity/lights.xml b/Subsurface/Content/Items/Electricity/lights.xml
index 85da571ab..2a4152f4e 100644
--- a/Subsurface/Content/Items/Electricity/lights.xml
+++ b/Subsurface/Content/Items/Electricity/lights.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/Subsurface/Content/Items/Electricity/poweritems.xml b/Subsurface/Content/Items/Electricity/poweritems.xml
index 52f63dcc0..8b1ce1590 100644
--- a/Subsurface/Content/Items/Electricity/poweritems.xml
+++ b/Subsurface/Content/Items/Electricity/poweritems.xml
@@ -17,7 +17,7 @@
-
+
@@ -45,7 +45,7 @@
-
+
@@ -69,7 +69,7 @@
-
+
diff --git a/Subsurface/Content/Items/Electricity/signalitems.xml b/Subsurface/Content/Items/Electricity/signalitems.xml
index 9e138f855..a18e6ee2b 100644
--- a/Subsurface/Content/Items/Electricity/signalitems.xml
+++ b/Subsurface/Content/Items/Electricity/signalitems.xml
@@ -80,13 +80,13 @@
-
-
+
@@ -108,12 +108,12 @@
-
-
+
@@ -135,12 +135,12 @@
-
-
+
@@ -163,11 +163,11 @@
-
+
-
+
@@ -188,12 +188,12 @@
-
-
+
@@ -212,12 +212,12 @@
-
-
+
@@ -239,12 +239,12 @@
-
-
+
@@ -264,12 +264,12 @@
-
-
+
diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml
index a14c67887..c5d53d5df 100644
--- a/Subsurface/Content/Items/Engine/engine.xml
+++ b/Subsurface/Content/Items/Engine/engine.xml
@@ -13,7 +13,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -60,7 +60,7 @@
-
+
diff --git a/Subsurface/Content/Items/MiniMap/item.xml b/Subsurface/Content/Items/MiniMap/item.xml
index 463c391d3..3a234dd87 100644
--- a/Subsurface/Content/Items/MiniMap/item.xml
+++ b/Subsurface/Content/Items/MiniMap/item.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml
index 1fc53de08..a70fabc8c 100644
--- a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml
+++ b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/Subsurface/Content/Items/Pump/pump.xml b/Subsurface/Content/Items/Pump/pump.xml
index 8ce2ecfdb..39e8d8c44 100644
--- a/Subsurface/Content/Items/Pump/pump.xml
+++ b/Subsurface/Content/Items/Pump/pump.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/Subsurface/Content/Items/Reactor/reactor.xml b/Subsurface/Content/Items/Reactor/reactor.xml
index 7ace14c21..a8bcb913a 100644
--- a/Subsurface/Content/Items/Reactor/reactor.xml
+++ b/Subsurface/Content/Items/Reactor/reactor.xml
@@ -31,7 +31,7 @@
-
+
diff --git a/Subsurface/Content/Items/Weapons/explosives.xml b/Subsurface/Content/Items/Weapons/explosives.xml
index b5f5c269a..03eb44db1 100644
--- a/Subsurface/Content/Items/Weapons/explosives.xml
+++ b/Subsurface/Content/Items/Weapons/explosives.xml
@@ -27,7 +27,7 @@
-
+
@@ -35,7 +35,7 @@
-
+
diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index 093d47574..7e6bf5a62 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -31,7 +31,6 @@
@@ -39,16 +38,23 @@
+
+
+
+
diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs
index 23968f6ad..3040be6e6 100644
--- a/Subsurface/Source/Characters/Character.cs
+++ b/Subsurface/Source/Characters/Character.cs
@@ -286,18 +286,24 @@ namespace Barotrauma
{
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
- keys[(int)InputType.Select] = new Key(false);
- keys[(int)InputType.ActionHeld] = new Key(true);
- keys[(int)InputType.ActionHit] = new Key(false);
- keys[(int)InputType.SecondaryHit] = new Key(false);
- keys[(int)InputType.SecondaryHeld] = new Key(true);
- keys[(int)InputType.Left] = new Key(true);
- keys[(int)InputType.Right] = new Key(true);
- keys[(int)InputType.Up] = new Key(true);
- keys[(int)InputType.Down] = new Key(true);
+ for (int i = 0; i < Enum.GetNames(typeof(InputType)).Length; i++)
+ {
+ keys[i] = new Key(GameMain.Config.KeyBind((InputType)i));
+ }
- keys[(int)InputType.Run] = new Key(true);
+ //keys[(int)InputType.Select] = new Key(GameMain.Config.KeyBind(InputType.Select));
+ //keys[(int)InputType.ActionHeld] = new Key(true);
+ //keys[(int)InputType.ActionHit] = new Key(false);
+ //keys[(int)InputType.SecondaryHit] = new Key(false);
+ //keys[(int)InputType.SecondaryHeld] = new Key(true);
+
+ //keys[(int)InputType.Left] = new Key(true);
+ //keys[(int)InputType.Right] = new Key(true);
+ //keys[(int)InputType.Up] = new Key(true);
+ //keys[(int)InputType.Down] = new Key(true);
+
+ //keys[(int)InputType.Run] = new Key(true);
selectedItems = new Item[2];
@@ -410,16 +416,22 @@ namespace Barotrauma
}
}
- public bool GetInputState(InputType inputType)
+ public bool IsKeyHit(InputType inputType)
{
- return keys[(int)inputType].State;
+ return keys[(int)inputType].Hit;
+ }
+
+ public bool IsKeyDown(InputType inputType)
+ {
+ return keys[(int)inputType].Held;
}
public void ClearInputs()
{
foreach (Key key in keys)
{
- key.State = false;
+ key.Hit = false;
+ key.Held = false;
}
}
@@ -477,10 +489,10 @@ namespace Barotrauma
if (isDead || AnimController.StunTimer>0.0f) return;
Vector2 targetMovement = Vector2.Zero;
- if (GetInputState(InputType.Left)) targetMovement.X -= 1.0f;
- if (GetInputState(InputType.Right)) targetMovement.X += 1.0f;
- if (GetInputState(InputType.Up)) targetMovement.Y += 1.0f;
- if (GetInputState(InputType.Down)) targetMovement.Y -= 1.0f;
+ if (IsKeyDown(InputType.Left)) targetMovement.X -= 1.0f;
+ if (IsKeyDown(InputType.Right)) targetMovement.X += 1.0f;
+ if (IsKeyDown(InputType.Up)) targetMovement.Y += 1.0f;
+ if (IsKeyDown(InputType.Down)) targetMovement.Y -= 1.0f;
//the vertical component is only used for falling through platforms and climbing ladders when not in water,
//so the movement can't be normalized or the character would walk slower when pressing down/up
@@ -490,7 +502,7 @@ namespace Barotrauma
if (length > 0.0f) targetMovement = targetMovement / length;
}
- if (Math.Sign(targetMovement.X) == Math.Sign(AnimController.Dir) && GetInputState(InputType.Run))
+ if (Math.Sign(targetMovement.X) == Math.Sign(AnimController.Dir) && IsKeyDown(InputType.Run))
targetMovement *= 3.0f;
targetMovement *= SpeedMultiplier;
@@ -519,22 +531,22 @@ namespace Barotrauma
{
if (selectedItems[i] == null) continue;
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
-
- if (GetInputState(InputType.ActionHeld)) selectedItems[i].Use(deltaTime, this);
- if (GetInputState(InputType.SecondaryHeld) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
+
+ if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this);
+ if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
}
if (selectedConstruction != null)
{
- if (GetInputState(InputType.ActionHeld)) selectedConstruction.Use(deltaTime, this);
- if (selectedConstruction != null && GetInputState(InputType.SecondaryHeld)) selectedConstruction.SecondaryUse(deltaTime, this);
+ if (IsKeyDown(InputType.Use)) selectedConstruction.Use(deltaTime, this);
+ if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
}
if (IsNetworkPlayer)
{
foreach (Key key in keys)
{
- key.Reset();
+ key.ResetHit();
}
}
}
@@ -658,24 +670,30 @@ namespace Barotrauma
if (!DisableControls)
{
- keys[(int)InputType.Left].SetState(PlayerInput.KeyDown(Keys.A));
- keys[(int)InputType.Right].SetState(PlayerInput.KeyDown(Keys.D));
- keys[(int)InputType.Up].SetState(PlayerInput.KeyDown(Keys.W));
- keys[(int)InputType.Down].SetState(PlayerInput.KeyDown(Keys.S));
+ for (int i = 0; i < keys.Length; i++ )
+ {
+ keys[i].SetState();
+ }
- keys[(int)InputType.Select].SetState(PlayerInput.KeyHit(Keys.E));
- keys[(int)InputType.ActionHit].SetState(PlayerInput.LeftButtonClicked());
- keys[(int)InputType.ActionHeld].SetState(PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed);
- keys[(int)InputType.SecondaryHit].SetState(PlayerInput.RightButtonClicked());
- keys[(int)InputType.SecondaryHeld].SetState(PlayerInput.GetMouseState.RightButton == ButtonState.Pressed);
+ // keys[(int)InputType.Left].SetState(GameMain.Config.KeyBind(inpu));
+ //keys[(int)InputType.Right].SetState(PlayerInput.KeyDown(Keys.D));
+ //keys[(int)InputType.Up].SetState(PlayerInput.KeyDown(Keys.W));
+ //keys[(int)InputType.Down].SetState(PlayerInput.KeyDown(Keys.S));
- keys[(int)InputType.Run].SetState(PlayerInput.KeyDown(Keys.LeftShift));
+ //keys[(int)InputType.Select].SetState(PlayerInput.KeyHit(Keys.E));
+ //keys[(int)InputType.ActionHit].SetState(PlayerInput.LeftButtonClicked());
+ //keys[(int)InputType.ActionHeld].SetState(PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed);
+ //keys[(int)InputType.SecondaryHit].SetState(PlayerInput.RightButtonClicked());
+ //keys[(int)InputType.SecondaryHeld].SetState(PlayerInput.GetMouseState.RightButton == ButtonState.Pressed);
+
+ //keys[(int)InputType.Run].SetState(PlayerInput.KeyDown(Keys.LeftShift));
}
else
{
foreach (Key key in keys)
{
- key.SetState(false);
+ if (key == null) continue;
+ key.Reset();
}
}
@@ -743,7 +761,12 @@ namespace Barotrauma
if (closestItem.Pick(this))
{
new NetworkEvent(NetworkEventType.PickItem, ID, true,
- new int[] { closestItem.ID, GetInputState(InputType.Select) ? 1 : 0, GetInputState(InputType.ActionHit) ? 1 : 0 });
+ new int[]
+ {
+ closestItem.ID,
+ IsKeyHit(InputType.Select) ? 1 : 0,
+ IsKeyHit(InputType.Use) ? 1 : 0
+ });
}
}
}
@@ -756,7 +779,7 @@ namespace Barotrauma
}
}
- if (GetInputState(InputType.Select))
+ if (IsKeyHit(InputType.Select))
{
if (selectedCharacter != null)
{
@@ -1186,30 +1209,30 @@ namespace Barotrauma
return true;
case NetworkEventType.EntityUpdate:
var hasInputs =
- GetInputState(InputType.Left) ||
- GetInputState(InputType.Right) ||
- GetInputState(InputType.Up) ||
- GetInputState(InputType.Down) ||
- GetInputState(InputType.ActionHeld) ||
- GetInputState(InputType.SecondaryHeld);
+ IsKeyDown(InputType.Left) ||
+ IsKeyDown(InputType.Right) ||
+ IsKeyDown(InputType.Up) ||
+ IsKeyDown(InputType.Down) ||
+ IsKeyDown(InputType.Use) ||
+ IsKeyDown(InputType.Aim);
message.Write(hasInputs);
message.Write((float)NetTime.Now);
if (!hasInputs) return true;
- message.Write(keys[(int)InputType.ActionHeld].Dequeue);
+ message.Write(keys[(int)InputType.Use].DequeueHeld);
- bool secondaryHeld = keys[(int)InputType.SecondaryHeld].Dequeue;
+ bool secondaryHeld = keys[(int)InputType.Aim].DequeueHeld;
message.Write(secondaryHeld);
- message.Write(keys[(int)InputType.Left].Dequeue);
- message.Write(keys[(int)InputType.Right].Dequeue);
+ message.Write(keys[(int)InputType.Left].Held);
+ message.Write(keys[(int)InputType.Right].Held);
- message.Write(keys[(int)InputType.Up].Dequeue);
- message.Write(keys[(int)InputType.Down].Dequeue);
+ message.Write(keys[(int)InputType.Up].Held);
+ message.Write(keys[(int)InputType.Down].Held);
- message.Write(keys[(int)InputType.Run].Dequeue);
+ message.Write(keys[(int)InputType.Run].Held);
if (secondaryHeld)
{
@@ -1386,18 +1409,18 @@ namespace Barotrauma
AnimController.IsStanding = true;
- keys[(int)InputType.ActionHeld].State = actionKeyState;
- keys[(int)InputType.SecondaryHeld].State = secondaryKeyState;
+ keys[(int)InputType.Use].Held = actionKeyState;
+ keys[(int)InputType.Aim].Held = secondaryKeyState;
if (sendingTime <= LastNetworkUpdate) return;
- keys[(int)InputType.Left].State = leftKeyState;
- keys[(int)InputType.Right].State = rightKeyState;
+ keys[(int)InputType.Left].Held = leftKeyState;
+ keys[(int)InputType.Right].Held = rightKeyState;
- keys[(int)InputType.Up].State = upKeyState;
- keys[(int)InputType.Down].State = downKeyState;
+ keys[(int)InputType.Up].Held = upKeyState;
+ keys[(int)InputType.Down].Held = downKeyState;
- keys[(int)InputType.Run].State = runState;
+ keys[(int)InputType.Run].Held = runState;
float dir = 1.0f;
Vector2 pos = Vector2.Zero;
diff --git a/Subsurface/Source/Characters/CharacterInfo.cs b/Subsurface/Source/Characters/CharacterInfo.cs
index 4ed7af120..affe2a016 100644
--- a/Subsurface/Source/Characters/CharacterInfo.cs
+++ b/Subsurface/Source/Characters/CharacterInfo.cs
@@ -25,7 +25,7 @@ namespace Barotrauma
public int Salary;
- public int HeadSpriteId;
+ private int headSpriteId;
private Sprite headSprite;
public bool StartItemsGiven;
@@ -44,6 +44,23 @@ namespace Barotrauma
}
}
+ public int HeadSpriteId
+ {
+ get { return headSpriteId; }
+ set
+ {
+ int oldId = headSpriteId;
+
+ headSpriteId = value;
+ Vector2 spriteRange = headSpriteRange[gender == Gender.Male ? 0 : 1];
+
+ if (headSpriteId < (int)spriteRange.X) headSpriteId = (int)(spriteRange.Y-1);
+ if (headSpriteId > (int)spriteRange.Y) headSpriteId = (int)(spriteRange.X);
+
+ if (headSpriteId != oldId) headSprite = null;
+ }
+ }
+
public Gender Gender
{
get { return gender; }
diff --git a/Subsurface/Source/ContentPackage.cs b/Subsurface/Source/ContentPackage.cs
index 61283bedd..826a376a7 100644
--- a/Subsurface/Source/ContentPackage.cs
+++ b/Subsurface/Source/ContentPackage.cs
@@ -173,6 +173,7 @@ namespace Barotrauma
}
return filePaths;
}
+
public static void LoadAll(string folder)
{
if (!Directory.Exists(folder))
@@ -189,6 +190,8 @@ namespace Barotrauma
string[] files = Directory.GetFiles(folder, "*.xml");
+ list.Clear();
+
foreach (string filePath in files)
{
ContentPackage package = new ContentPackage(filePath);
diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs
index 69945e1c4..d5d27bb5f 100644
--- a/Subsurface/Source/DebugConsole.cs
+++ b/Subsurface/Source/DebugConsole.cs
@@ -141,7 +141,7 @@ namespace Barotrauma
public static void ExecuteCommand(string command, GameMain game)
{
#if !DEBUG
- if (GameMain.Client!=null)
+ if (GameMain.Client != null)
{
ThrowError("Console commands are disabled in multiplayer mode");
return;
@@ -216,7 +216,7 @@ namespace Barotrauma
case "control":
if (commands.Length < 2) break;
commands[1] = commands[1].ToLower();
- Character.Controlled = Character.CharacterList.Find(c => c.Name.ToLower() == commands[1]);
+ Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLower() == commands[1]);
break;
case "heal":
if (Character.Controlled != null)
diff --git a/Subsurface/Source/EventInput/EventInput.cs b/Subsurface/Source/EventInput/EventInput.cs
index 331c8c5d2..d166c78c9 100644
--- a/Subsurface/Source/EventInput/EventInput.cs
+++ b/Subsurface/Source/EventInput/EventInput.cs
@@ -169,8 +169,7 @@ namespace EventInput
public static void OnCharEntered(char character)
{
- if (CharEntered != null)
- CharEntered(null, new CharacterEventArgs(character, 0));
+ if (CharEntered != null) CharEntered(null, new CharacterEventArgs(character, 0));
}
static IntPtr HookProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
@@ -186,6 +185,7 @@ namespace EventInput
case WM_KEYDOWN:
if (KeyDown != null)
KeyDown(null, new KeyEventArgs((Keys)wParam));
+
break;
case WM_KEYUP:
diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs
index 299c1404c..618f489ff 100644
--- a/Subsurface/Source/GUI/GUIComponent.cs
+++ b/Subsurface/Source/GUI/GUIComponent.cs
@@ -143,6 +143,11 @@ namespace Barotrauma
set { selectedColor = value; }
}
+ public static KeyboardDispatcher KeyboardDispatcher
+ {
+ get { return keyboardDispatcher; }
+ }
+
protected GUIComponent(GUIStyle style)
{
Visible = true;
@@ -227,7 +232,7 @@ namespace Barotrauma
foreach (Sprite sprite in sprites)
{
Vector2 startPos = new Vector2(rect.X, rect.Y);
- Vector2 size = new Vector2(sprite.SourceRect.Width, sprite.SourceRect.Height);
+ Vector2 size = new Vector2(Math.Min(sprite.SourceRect.Width,rect.Width), Math.Min(sprite.SourceRect.Height,rect.Height));
if (sprite.size.X == 0.0f) size.X = rect.Width;
if (sprite.size.Y == 0.0f) size.Y = rect.Height;
diff --git a/Subsurface/Source/GUI/GUIDropDown.cs b/Subsurface/Source/GUI/GUIDropDown.cs
index 73c1bcd02..01fd79766 100644
--- a/Subsurface/Source/GUI/GUIDropDown.cs
+++ b/Subsurface/Source/GUI/GUIDropDown.cs
@@ -9,6 +9,10 @@ namespace Barotrauma
{
public class GUIDropDown : GUIComponent
{
+
+ public delegate bool OnSelectedHandler(GUIComponent selected);
+ public OnSelectedHandler OnSelected;
+
private GUIButton button;
private GUIListBox listBox;
@@ -65,6 +69,8 @@ namespace Barotrauma
Dropped = false;
+ if (OnSelected != null) OnSelected(component);
+
return true;
}
diff --git a/Subsurface/Source/GUI/GUIScrollBar.cs b/Subsurface/Source/GUI/GUIScrollBar.cs
index 74d086110..57255549c 100644
--- a/Subsurface/Source/GUI/GUIScrollBar.cs
+++ b/Subsurface/Source/GUI/GUIScrollBar.cs
@@ -90,7 +90,7 @@ namespace Barotrauma
parent.AddChild(this);
isHorizontal = (rect.Width > rect.Height);
- frame = new GUIFrame(new Rectangle(0,0,0,0), Color.White, style, this);
+ frame = new GUIFrame(new Rectangle(0,0,0,0), Color.Black*0.8f, style, this);
//AddChild(frame);
//System.Diagnostics.Debug.WriteLine(frame.rect);
diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs
index ac4f79400..24050692c 100644
--- a/Subsurface/Source/GUI/GUITextBlock.cs
+++ b/Subsurface/Source/GUI/GUITextBlock.cs
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using System;
namespace Barotrauma
{
@@ -120,7 +121,7 @@ namespace Barotrauma
this.alignment = alignment;
this.textAlignment = textAlignment;
-
+
if (parent != null)
parent.AddChild(this);
@@ -215,8 +216,8 @@ namespace Barotrauma
Color currColor = color;
if (state == ComponentState.Hover) currColor = hoverColor;
if (state == ComponentState.Selected) currColor = selectedColor;
-
- GUI.DrawRectangle(spriteBatch, rect, currColor*(currColor.A/255.0f), true);
+
+ if (currColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A / 255.0f), true);
base.Draw(spriteBatch);
@@ -233,6 +234,9 @@ namespace Barotrauma
}
DrawChildren(spriteBatch);
+
+ if (OutlineColor.A * currColor.A > 0.0f) GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (currColor.A / 255.0f), false);
+
}
}
}
diff --git a/Subsurface/Source/GUI/GUITextBox.cs b/Subsurface/Source/GUI/GUITextBox.cs
index 9187a8f37..cf31ade77 100644
--- a/Subsurface/Source/GUI/GUITextBox.cs
+++ b/Subsurface/Source/GUI/GUITextBox.cs
@@ -7,11 +7,11 @@ using Microsoft.Xna.Framework.Input;
namespace Barotrauma
{
- delegate void TextBoxEvent(GUITextBox sender);
+ delegate void TextBoxEvent(GUITextBox sender, Keys key);
class GUITextBox : GUIComponent, IKeyboardSubscriber
{
- public event TextBoxEvent Clicked;
+ public event TextBoxEvent OnSelected;
bool caretVisible;
float caretTimer;
@@ -19,11 +19,13 @@ namespace Barotrauma
GUITextBlock textBlock;
public delegate bool OnEnterHandler(GUITextBox textBox, string text);
- public OnEnterHandler OnEnter;
+ public OnEnterHandler OnEnterPressed;
+
+ public event TextBoxEvent OnKeyHit;
public delegate bool OnTextChangedHandler(GUITextBox textBox, string text);
public OnTextChangedHandler OnTextChanged;
-
+
public GUITextBlock.TextGetterHandler TextGetter
{
get { return textBlock.TextGetter; }
@@ -68,6 +70,8 @@ namespace Barotrauma
}
}
+ public bool CaretEnabled;
+
public String Text
{
get
@@ -97,6 +101,7 @@ namespace Barotrauma
//ensure that text cannot be larger than the box
Text = textBlock.Text.Substring(0, textBlock.Text.Length - 1);
}
+
}
}
}
@@ -130,10 +135,13 @@ namespace Barotrauma
parent.AddChild(this);
textBlock = new GUITextBlock(new Rectangle(0,0,0,0), "", color, textColor, textAlignment, style, this);
- textBlock.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
+
if (style != null) style.Apply(textBlock, this);
+ textBlock.Padding = new Vector4(3.0f, 0.0f, 3.0f, 0.0f);
previousMouse = PlayerInput.GetMouseState;
+
+ CaretEnabled = true;
//SetTextPos();
}
@@ -141,7 +149,7 @@ namespace Barotrauma
{
Selected = true;
keyboardDispatcher.Subscriber = this;
- if (Clicked != null) Clicked(this);
+ //if (Clicked != null) Clicked(this);
}
public void Deselect()
@@ -158,27 +166,37 @@ namespace Barotrauma
if (flashTimer > 0.0f) flashTimer -= deltaTime;
if (!Enabled) return;
- caretTimer += deltaTime;
- caretVisible = ((caretTimer*1000.0f) % 1000) < 500;
+ if (CaretEnabled)
+ {
+ caretTimer += deltaTime;
+ caretVisible = ((caretTimer*1000.0f) % 1000) < 500;
+ }
if (rect.Contains(PlayerInput.MousePosition))
{
- state = ComponentState.Hover;
- if (PlayerInput.LeftButtonClicked()) Select();
+ state = ComponentState.Hover;
+ if (PlayerInput.LeftButtonClicked())
+ {
+ Select();
+ if (OnSelected != null) OnSelected(this, Keys.None);
+ }
}
else
{
state = ComponentState.None;
+
}
+ textBlock.State = state;
+
if (keyboardDispatcher.Subscriber == this)
{
Character.DisableControls = true;
- if (OnEnter != null && PlayerInput.KeyHit(Keys.Enter))
+ if (OnEnterPressed != null && PlayerInput.KeyHit(Keys.Enter))
{
string input = Text;
Text = "";
- OnEnter(this, input);
+ OnEnterPressed(this, input);
}
}
@@ -191,6 +209,8 @@ namespace Barotrauma
if (!Visible) return;
DrawChildren(spriteBatch);
+
+ if (!CaretEnabled) return;
Vector2 caretPos = textBlock.CaretPos;
@@ -224,14 +244,14 @@ namespace Barotrauma
if (Text.Length > 0)
Text = Text.Substring(0, Text.Length - 1);
break;
- case '\r': //return
- if (OnEnterPressed != null)
- OnEnterPressed(this);
- break;
- case '\t': //tab
- if (OnTabPressed != null)
- OnTabPressed(this);
- break;
+ //case '\r': //return
+ // if (OnEnterPressed != null)
+ // OnEnterPressed(this);
+ // break;
+ //case '\t': //tab
+ // if (OnTabPressed != null)
+ // OnTabPressed(this);
+ // break;
}
if (OnTextChanged != null) OnTextChanged(this, Text);
@@ -239,10 +259,10 @@ namespace Barotrauma
public void ReceiveSpecialInput(Keys key)
{
+ if (OnKeyHit != null) OnKeyHit(this, key);
}
- public event TextBoxEvent OnEnterPressed;
- public event TextBoxEvent OnTabPressed;
+ //public event TextBoxEvent OnTabPressed;
public bool Selected
{
diff --git a/Subsurface/Source/GUI/GUITickBox.cs b/Subsurface/Source/GUI/GUITickBox.cs
index f63ffcf10..49c315044 100644
--- a/Subsurface/Source/GUI/GUITickBox.cs
+++ b/Subsurface/Source/GUI/GUITickBox.cs
@@ -9,7 +9,7 @@ namespace Barotrauma
GUIFrame box;
GUITextBlock text;
- public delegate bool OnSelectedHandler(object obj);
+ public delegate bool OnSelectedHandler(GUITickBox obj);
public OnSelectedHandler OnSelected;
private bool selected;
diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs
index 119f8c918..73f08e5f7 100644
--- a/Subsurface/Source/GameMain.cs
+++ b/Subsurface/Source/GameMain.cs
@@ -69,7 +69,7 @@ namespace Barotrauma
//private Stopwatch renderTimer;
//public static int renderTimeElapsed;
-
+
public Camera Cam
{
get { return GameScreen.Cam; }
diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs
index c6f728918..d24c8a73d 100644
--- a/Subsurface/Source/GameSettings.cs
+++ b/Subsurface/Source/GameSettings.cs
@@ -12,10 +12,15 @@ namespace Barotrauma
public class GameSettings
{
private GUIFrame settingsFrame;
+ private GUIButton applyButton;
private float soundVolume, musicVolume;
- private Keys[] keyMapping;
+ private KeyOrMouse[] keyMapping;
+
+
+ private bool unsavedSettings;
+
public GUIFrame SettingsFrame
{
@@ -26,6 +31,11 @@ namespace Barotrauma
}
}
+ public KeyOrMouse KeyBind(InputType inputType)
+ {
+ return keyMapping[(int)inputType];
+ }
+
public int GraphicsWidth { get; set; }
public int GraphicsHeight { get; set; }
@@ -37,6 +47,19 @@ namespace Barotrauma
public bool AutoCheckUpdates { get; set; }
public bool WasGameUpdated { get; set; }
+ public bool UnsavedSettings
+ {
+ get
+ {
+ return unsavedSettings;
+ }
+ private set
+ {
+ unsavedSettings = value;
+ if (applyButton != null) applyButton.Selected = unsavedSettings;
+ }
+ }
+
public float SoundVolume
{
get { return soundVolume; }
@@ -59,6 +82,8 @@ namespace Barotrauma
public GameSettings(string filePath)
{
+ ContentPackage.LoadAll(ContentPackage.Folder);
+
Load(filePath);
}
@@ -79,7 +104,7 @@ namespace Barotrauma
return;
}
-
+
XElement graphicsMode = doc.Root.Element("graphicsmode");
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
@@ -100,14 +125,17 @@ namespace Barotrauma
SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f);
MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f);
- keyMapping = new Keys[Enum.GetNames(typeof(InputType)).Length];
- keyMapping[(int)InputType.Up] = Keys.W;
- keyMapping[(int)InputType.Down] = Keys.S;
- keyMapping[(int)InputType.Left] = Keys.A;
- keyMapping[(int)InputType.Right] = Keys.D;
- keyMapping[(int)InputType.Run] = Keys.LeftShift;
- keyMapping[(int)InputType.Chat] = Keys.Tab;
- keyMapping[(int)InputType.Select] = Keys.E;
+ keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
+ keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
+ keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
+ keyMapping[(int)InputType.Left] = new KeyOrMouse(Keys.A);
+ keyMapping[(int)InputType.Right] = new KeyOrMouse(Keys.D);
+ keyMapping[(int)InputType.Run] = new KeyOrMouse(Keys.LeftShift);
+ keyMapping[(int)InputType.Chat] = new KeyOrMouse(Keys.Tab);
+ keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);
+
+ keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
+ keyMapping[(int)InputType.Aim] = new KeyOrMouse(1);
foreach (XElement subElement in doc.Root.Elements())
{
@@ -124,19 +152,31 @@ namespace Barotrauma
{
InputType inputType;
Keys key;
- if (Enum.TryParse(attribute.Name.ToString(), true, out inputType) &&
- Enum.TryParse(attribute.Value.ToString(), true, out key))
+ int mouseButton;
+ if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
{
- keyMapping[(int)inputType] = key;
+ if (Enum.TryParse(attribute.Value.ToString(), true, out key))
+ {
+ keyMapping[(int)inputType] = new KeyOrMouse(key);
+ }
+ else if (int.TryParse(attribute.Value.ToString(), out mouseButton))
+ {
+ keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
+ }
+
}
}
break;
}
- }
+ }
+
+ UnsavedSettings = false;
}
public void Save(string filePath)
{
+ UnsavedSettings = false;
+
XDocument doc = new XDocument();
if (doc.Root == null)
@@ -173,12 +213,12 @@ namespace Barotrauma
new XAttribute("path", SelectedContentPackage.Path)));
}
-
doc.Save(filePath);
}
private bool ChangeSoundVolume(float barScroll)
{
+ UnsavedSettings = true;
SoundVolume = MathHelper.Clamp(barScroll, 0.0f, 1.0f);
return true;
@@ -186,49 +226,152 @@ namespace Barotrauma
private bool ChangeMusicVolume(float barScroll)
{
+ UnsavedSettings = true;
MusicVolume = MathHelper.Clamp(barScroll, 0.0f, 1.0f);
return true;
}
+ private bool ToggleFullScreen(object userData)
+ {
+ UnsavedSettings = true;
+ FullScreenEnabled = !FullScreenEnabled;
+ return true;
+ }
+
+ public void ResetSettingsFrame()
+ {
+ settingsFrame = null;
+ }
+
private void CreateSettingsFrame()
{
settingsFrame = new GUIFrame(new Rectangle(0, 0, 500, 500), null, Alignment.Center, GUI.Style);
- new GUITextBlock(new Rectangle(0, 0, 100, 20), "Sound volume:", GUI.Style, settingsFrame);
- GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, 20, 150, 20), GUI.Style,0.1f, settingsFrame);
+ new GUITextBlock(new Rectangle(0,-30,0,30), "Settings",GUI.Style,Alignment.TopCenter, Alignment.TopCenter, settingsFrame, false, GUI.LargeFont);
+
+ int x=0, y = 10;
+
+ new GUITextBlock(new Rectangle(0, y, 20, 20), "Resolution", GUI.Style, Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
+ var resolutionDD = new GUIDropDown(new Rectangle(0, y + 20, 180, 20), "", GUI.Style, settingsFrame);
+
+ var supportedModes = new List();
+ foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
+ {
+ if (supportedModes.FirstOrDefault(m => m.Width == mode.Width && m.Height == mode.Height) != null) continue;
+
+ resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode);
+ supportedModes.Add(mode);
+
+ if (GraphicsWidth == mode.Width && GraphicsHeight == mode.Height) resolutionDD.SelectItem(mode);
+ }
+
+ if (resolutionDD.SelectedItemData == null)
+ {
+ resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last());
+ }
+
+ y += 50;
+
+ var fullScreenTick = new GUITickBox(new Rectangle(x, y, 20, 20), "Fullscreen", Alignment.TopLeft, settingsFrame);
+ fullScreenTick.OnSelected = ToggleFullScreen;
+ fullScreenTick.Selected = FullScreenEnabled;
+
+ y += 50;
+
+ new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", GUI.Style, settingsFrame);
+ GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y+20, 150, 20), GUI.Style,0.1f, settingsFrame);
soundScrollBar.BarScroll = SoundVolume;
soundScrollBar.OnMoved = ChangeSoundVolume;
- new GUITextBlock(new Rectangle(0, 40, 100, 20), "Music volume:", GUI.Style, settingsFrame);
- GUIScrollBar musicScrollBar = new GUIScrollBar(new Rectangle(0, 60, 150, 20), GUI.Style, 0.1f, settingsFrame);
+ new GUITextBlock(new Rectangle(0, y+40, 100, 20), "Music volume:", GUI.Style, settingsFrame);
+ GUIScrollBar musicScrollBar = new GUIScrollBar(new Rectangle(0, y+60, 150, 20), GUI.Style, 0.1f, settingsFrame);
musicScrollBar.BarScroll = MusicVolume;
musicScrollBar.OnMoved = ChangeMusicVolume;
- int x = 250;
- int y = 60;
+ x = 200;
+ y = 10;
- new GUITextBlock(new Rectangle(x, 40, 100, 20), "Controls:", GUI.Style, settingsFrame);
+ new GUITextBlock(new Rectangle(x, y, 20, 20), "Content package", GUI.Style, Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
+ var contentPackageDD = new GUIDropDown(new Rectangle(x, y + 20, 200, 20), "", GUI.Style, settingsFrame);
+
+ foreach (ContentPackage contentPackage in ContentPackage.list)
+ {
+ contentPackageDD.AddItem(contentPackage.Name, contentPackage);
+
+ if (SelectedContentPackage == contentPackage) contentPackageDD.SelectItem(contentPackage);
+ }
+
+ y += 50;
+ new GUITextBlock(new Rectangle(x, y, 100, 20), "Controls:", GUI.Style, settingsFrame);
+ y += 30;
var inputNames = Enum.GetNames(typeof(InputType));
for (int i = 0; i< inputNames.Length; i++)
{
new GUITextBlock(new Rectangle(x, y, 100, 20), inputNames[i]+": ", GUI.Style, settingsFrame);
- var keyBox = new GUITextBox(new Rectangle(x + 100, y, 70, 15), GUI.Style, settingsFrame);
+ var keyBox = new GUITextBox(new Rectangle(x + 100, y, 120, 15), GUI.Style, settingsFrame);
keyBox.Text = keyMapping[i].ToString();
- keyBox.OnTextChanged = MapKey;
+ keyBox.UserData = i;
+ keyBox.OnSelected += KeyBoxSelected;
+ keyBox.SelectedColor = Color.Gold * 0.3f;
y += 20;
}
- var applyButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Apply", GUI.Style, settingsFrame);
+ applyButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Apply", Alignment.BottomRight, GUI.Style, settingsFrame);
applyButton.OnClicked = ApplyClicked;
}
- private bool MapKey(GUITextBox textBox, string text)
+ private void KeyBoxSelected(GUITextBox textBox, Keys key)
{
+ textBox.Text = "";
+ CoroutineManager.StartCoroutine(WaitForKeyPress(textBox));
+ }
+
+ private bool MarkUnappliedChanges(GUIButton button, object obj)
+ {
+ UnsavedSettings = true;
+
return true;
}
+ private bool SelectResolution(GUIComponent selected)
+ {
+ DisplayMode mode = selected.UserData as DisplayMode;
+ if (mode == null) return false;
+
+ GraphicsWidth = mode.Width;
+ GraphicsHeight = mode.Height;
+
+ UnsavedSettings = true;
+
+ return true;
+ }
+
+
+
+ private IEnumerable