Control settings, more server settings, selecting character face

This commit is contained in:
Regalis
2015-10-28 19:07:17 +02:00
parent 9ed2963cd9
commit 948285f6ab
46 changed files with 789 additions and 325 deletions
+1 -1
View File
@@ -243,7 +243,7 @@ namespace Launcher2
return true;
}
private bool ToggleFullScreen(object obj)
private bool ToggleFullScreen(GUITickBox tickBox)
{
settings.FullScreenEnabled = !settings.FullScreenEnabled;
return true;
+1 -1
View File
@@ -103,6 +103,7 @@
<Compile Include="Source\Networking\NetStats.cs" />
<Compile Include="Source\Networking\ReliableSender.cs" />
<Compile Include="Source\Particles\ParticleEmitter.cs" />
<Compile Include="Source\Screens\NetLobbySettings.cs" />
<Compile Include="Source\Screens\ServerListScreen.cs" />
<Compile Include="Source\Utils\Rand.cs" />
<Compile Include="Source\Events\PropertyTask.cs" />
@@ -225,7 +226,6 @@
<Compile Include="Source\Screens\LobbyScreen.cs" />
<Compile Include="Source\Screens\MainMenuScreen.cs" />
<Compile Include="Source\Screens\NetLobbyScreen.cs" />
<Compile Include="Source\Screens\SettingsScreen.cs" />
<Compile Include="Source\Screens\Screen.cs" />
<Compile Include="Source\GameSettings.cs" />
<Compile Include="Source\Sounds\OggSound.cs" />
+2 -2
View File
@@ -15,12 +15,12 @@
<sound file="beep.ogg" type="OnUse" range="500.0"/>
</Controller>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<RequiredItem name="Screwdriver" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" attachedbydefault="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
+2 -2
View File
@@ -19,7 +19,7 @@
<item name="Welding Tool"/>
</fixrequirement>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>
@@ -48,7 +48,7 @@
<item name="Welding Tool"/>
</fixrequirement>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>
@@ -11,7 +11,7 @@
<LightComponent color="1.0,1.0,1.0,1.0" range ="800.0" powerconsumption="50"/>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="power"/>
<input name="toggle"/>
@@ -17,7 +17,7 @@
<GuiFrame rect="0,0,350,160" alignment="Center" color="0.0,0.0,0.0,0.6"/>
</PowerTransfer>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<RequiredSkill name="Electrical Engineering" level="30"/>
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="5" stun="10" force="2.0" flames="false" shockwave="false" sparks="true"/>
@@ -45,7 +45,7 @@
<StatusEffect type="OnActive" target="Contained" targetnames="loadable" Condition="2.0"/>
</PowerContainer>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="15" stun="10" force="3.0" flames="false" shockwave="false" sparks="true"/>
</StatusEffect>
@@ -69,7 +69,7 @@
<GuiFrame rect="0,0,0.3,0.3" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</PowerContainer>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="30" stun="20" force="5.0" shockwave="false" sparks="true"/>
</StatusEffect>
@@ -80,13 +80,13 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in1"/>
<input name="signal_in2"/>
@@ -108,12 +108,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in1"/>
<input name="signal_in2"/>
@@ -135,12 +135,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
@@ -163,11 +163,11 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="toggle"/>
<input name="set_state"/>
@@ -188,12 +188,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<output name="signal_out"/>
</ConnectionPanel>
@@ -212,12 +212,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<input name="set_output"/>
@@ -239,12 +239,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
@@ -264,12 +264,12 @@
<Body width="16" height="16"/>
<Holdable selectkey="ActionHit" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="signal_in"/>
<output name="signal_out"/>
+3 -3
View File
@@ -13,7 +13,7 @@
<sound file="engine.ogg" type="OnActive" range="3000.0" volume="CurrentVolume" loop="true"/>
</Engine>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="set_force"/>
@@ -38,7 +38,7 @@
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="velocity_in"/>
@@ -60,7 +60,7 @@
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
+1 -1
View File
@@ -10,7 +10,7 @@
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" color="0.0,0.0,0.0,0.8"/>
</MiniMap>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
@@ -17,7 +17,7 @@
<Containable name="Oxygen Tank"/>
</ItemContainer>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
</ConnectionPanel>
+1 -1
View File
@@ -10,7 +10,7 @@
<sound file="pump.ogg" type="OnActive" range="800.0" volume="CurrFlow" volumemultiplier="0.01" loop="true"/>
</Pump>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<input name="power_in"/>
<input name="toggle"/>
+1 -1
View File
@@ -31,7 +31,7 @@
</StatusEffect>
</Reactor>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver" type="Equipped"/>
<output name="power_out"/>
<output name="temperature_out"/>
@@ -27,7 +27,7 @@
<Body width="16" height="9"/>
<Holdable selectkey="ActionHit" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -35,7 +35,7 @@
<Containable name="explosive"/>
</ItemContainer>
<ConnectionPanel selectkey="ActionHit" canbeselected = "true" msg="Rewire [Screwdriver]">
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="activate">
<StatusEffect type="OnUse" target="Contained" Condition="-100.0"/>
+10 -4
View File
@@ -31,7 +31,6 @@
<GUIListBox
color="0.5, 0.5, 0.5, 1.0"
textcolor="1.0, 1.0, 1.0, 1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0">
<Sprite texture="Content/UI/uiBackground.png" size="0.0, 0.0" sourcerect ="0.0, 90.0, 0.0, 100.0"/>
@@ -39,16 +38,23 @@
</GUIListBox>
<GUIScrollBar
color="0.5, 0.5, 0.5, 1.0"
color="0.3, 0.3, 0.3, 1.0"
textcolor="1.0, 1.0, 1.0, 1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0">
<Sprite texture="Content/UI/uiBackground.png" size="0.0, 0.0"/>
</GUIScrollBar>
<GUIDropDown
color="0.3, 0.3, 0.3, 1.0"
textcolor="1.0, 1.0, 1.0, 1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0">
<Sprite texture="Content/UI/uiBackground.png" size="0.0, 0.0"/>
</GUIDropDown>
<GUITextBox
color="0.5, 0.5, 0.5, 1.0"
color="0.5, 0.5, 0.5, 1.0"
hovercolor="0.8, 0.8, 0.8, 1.0"
textcolor="1.0, 1.0, 1.0, 1.0"
outlinecolor="0.5, 0.57, 0.6, 1.0">
<Sprite texture="Content/UI/uiBackground.png" size="0.0, 0.0" sourcerect ="0.0, 90.0, 0.0, 100.0"/>
+80 -57
View File
@@ -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;
+18 -1
View File
@@ -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; }
+3
View File
@@ -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);
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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:
+6 -1
View File
@@ -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;
+6
View File
@@ -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;
}
+1 -1
View File
@@ -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);
+7 -3
View File
@@ -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);
}
}
}
+42 -22
View File
@@ -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
{
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -69,7 +69,7 @@ namespace Barotrauma
//private Stopwatch renderTimer;
//public static int renderTimeElapsed;
public Camera Cam
{
get { return GameScreen.Cam; }
+169 -26
View File
@@ -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<DisplayMode>();
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<object> WaitForKeyPress(GUITextBox keyBox)
{
while (keyBox.Selected && PlayerInput.GetKeyboardState.GetPressedKeys().Length==0)
{
if (Screen.Selected != GameMain.MainMenuScreen) yield return CoroutineStatus.Success;
yield return CoroutineStatus.Running;
}
UnsavedSettings = true;
Keys key = PlayerInput.GetKeyboardState.GetPressedKeys()[0];
int keyIndex = (int)keyBox.UserData;
keyMapping[keyIndex] = new KeyOrMouse(key);
keyBox.Text = key.ToString("G");
keyBox.Deselect();
yield return CoroutineStatus.Success;
}
private bool ApplyClicked(GUIButton button, object userData)
{
Save("config.xml");
@@ -193,7 +193,7 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (!attachable || item.body==null) return true;
if (character != null && !character.GetInputState(InputType.SecondaryHeld)) return false;
if (character != null && !character.IsKeyDown(InputType.Aim)) return false;
item.Drop();
@@ -238,7 +238,7 @@ namespace Barotrauma.Items.Components
//item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.GetInputState(InputType.SecondaryHeld), holdAngle);
ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle);
}
protected void Flip(Item item)
@@ -52,7 +52,7 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null || reloadTimer>0.0f) return false;
if (!character.GetInputState(InputType.SecondaryHeld) || hitting) return false;
if (!character.IsKeyDown(InputType.Aim) || hitting) return false;
user = character;
@@ -66,7 +66,7 @@ namespace Barotrauma.Items.Components
foreach (Limb l in character.AnimController.Limbs)
{
item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody);
//item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody);
if (character.AnimController.InWater) continue;
if (l.type == LimbType.LeftFoot || l.type == LimbType.LeftThigh || l.type == LimbType.LeftLeg) continue;
@@ -107,7 +107,7 @@ namespace Barotrauma.Items.Components
reloadTimer -= deltaTime;
if (!picker.GetInputState(InputType.SecondaryHeld) && !hitting) hitPos = 0.0f;
if (!picker.IsKeyDown(InputType.Aim) && !hitting) hitPos = 0.0f;
ApplyStatusEffects(ActionType.OnActive, deltaTime, picker);
@@ -119,7 +119,7 @@ namespace Barotrauma.Items.Components
if (!hitting)
{
if (picker.GetInputState(InputType.SecondaryHeld))
if (picker.IsKeyDown(InputType.Aim))
{
hitPos = (float)System.Math.Min(hitPos+deltaTime*5.0f, MathHelper.Pi*0.7f);
@@ -167,10 +167,10 @@ namespace Barotrauma.Items.Components
item.body.CollisionCategories = Physics.CollisionMisc;
item.body.CollidesWith = Physics.CollisionWall;
foreach (Limb l in picker.AnimController.Limbs)
{
item.body.FarseerBody.RestoreCollisionWith(l.body.FarseerBody);
}
//foreach (Limb l in picker.AnimController.Limbs)
//{
// item.body.FarseerBody.RestoreCollisionWith(l.body.FarseerBody);
//}
}
@@ -53,7 +53,7 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null) return false;
if (!character.GetInputState(InputType.SecondaryHeld) || reload > 0.0f) return false;
if (!character.IsKeyDown(InputType.Aim) || reload > 0.0f) return false;
IsActive = true;
reload = 1.0f;
@@ -102,7 +102,7 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null) return false;
if (!character.GetInputState(InputType.SecondaryHeld)) return false;
if (!character.IsKeyDown(InputType.Aim)) return false;
//if (DoesUseFail(character)) return false;
@@ -161,7 +161,7 @@ namespace Barotrauma.Items.Components
}
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
{
if (character.GetInputState(InputType.SecondaryHeld))
if (character.IsKeyDown(InputType.Aim))
{
targetLimb.character.Health += limbFixAmount * degreeOfSuccess;
//isActive = true;
@@ -28,7 +28,7 @@ namespace Barotrauma.Items.Components
public override bool Use(float deltaTime, Character character = null)
{
if (character == null) return false;
if (!character.GetInputState(InputType.SecondaryHeld) || throwing) return false;
if (!character.IsKeyDown(InputType.Aim) || throwing) return false;
//Vector2 diff = Vector2.Normalize(character.CursorPosition - character.AnimController.RefLimb.Position);
@@ -75,7 +75,7 @@ namespace Barotrauma.Items.Components
if (!item.body.Enabled) return;
if (!picker.HasSelectedItem(item)) IsActive = false;
if (!picker.GetInputState(InputType.SecondaryHeld) && !throwing) throwPos = 0.0f;
if (!picker.IsKeyDown(InputType.Aim) && !throwing) throwPos = 0.0f;
ApplyStatusEffects(ActionType.OnActive, deltaTime, picker);
@@ -85,7 +85,7 @@ namespace Barotrauma.Items.Components
if (!throwing)
{
if (picker.GetInputState(InputType.SecondaryHeld))
if (picker.IsKeyDown(InputType.Aim))
{
throwPos = (float)System.Math.Min(throwPos+deltaTime*5.0f, MathHelper.Pi*0.7f);
@@ -63,6 +63,8 @@ namespace Barotrauma.Items.Components
currPowerConsumption = Math.Abs(targetForce)/100.0f * powerConsumption;
if (powerConsumption == 0.0f) voltage = 1.0f;
Force = MathHelper.Lerp(force, (voltage < minVoltage) ? 0.0f : targetForce, 0.1f);
if (Force != 0.0f)
{
@@ -109,7 +109,7 @@ namespace Barotrauma.Items.Components
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
catch
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
@@ -38,7 +38,7 @@ namespace Barotrauma.Items.Components
if (character != Character.Controlled || character != user) return;
if (Screen.Selected != GameMain.EditMapScreen &&
character.GetInputState(InputType.Select) &&
character.IsKeyHit(InputType.Select) &&
character.SelectedConstruction==this.item) character.SelectedConstruction = null;
Connection.DrawConnections(spriteBatch, this, character);
+9 -9
View File
@@ -727,7 +727,7 @@ namespace Barotrauma
namesBox.Text = relatedItem.JoinedNames;
namesBox.UserData = new ObjectProperty(property, relatedItem);
namesBox.OnEnter = EnterProperty;
namesBox.OnEnterPressed = EnterProperty;
namesBox.OnTextChanged = PropertyChanged;
y += 30;
@@ -754,7 +754,7 @@ namespace Barotrauma
}
propertyBox.UserData = objectProperty;
propertyBox.OnEnter = EnterProperty;
propertyBox.OnEnterPressed = EnterProperty;
propertyBox.OnTextChanged = PropertyChanged;
y = y + height+10;
}
@@ -879,8 +879,8 @@ namespace Barotrauma
bool pickHit = false, selectHit = false;
if (Screen.Selected == GameMain.EditMapScreen)
{
pickHit = picker.GetInputState(InputType.Select);
selectHit = picker.GetInputState(InputType.Select);
pickHit = picker.IsKeyHit(InputType.Select);
selectHit = picker.IsKeyHit(InputType.Select);
}
else
{
@@ -891,13 +891,13 @@ namespace Barotrauma
}
else if (forceActionKey)
{
if (ic.PickKey == InputType.ActionHit) pickHit = true;
if (ic.SelectKey == InputType.ActionHit) selectHit = true;
if (ic.PickKey == InputType.Use) pickHit = true;
if (ic.SelectKey == InputType.Use) selectHit = true;
}
else
{
pickHit = picker.GetInputState(ic.PickKey);
selectHit = picker.GetInputState(ic.SelectKey);
pickHit = picker.IsKeyHit(ic.PickKey);
selectHit = picker.IsKeyHit(ic.SelectKey);
}
}
@@ -925,7 +925,7 @@ namespace Barotrauma
if (picker.SelectedConstruction == this)
{
if (picker.GetInputState(InputType.Select)) picker.SelectedConstruction = null;
if (picker.IsKeyHit(InputType.Select)) picker.SelectedConstruction = null;
}
else if (selected)
{
+2 -2
View File
@@ -179,7 +179,7 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.Black, Alignment.TopLeft, null, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.Style, editingHUD);
propertyBox.Text = string.Join(", ", idCardTags);
propertyBox.OnEnter = EnterIDCardTags;
propertyBox.OnEnterPressed = EnterIDCardTags;
propertyBox.OnTextChanged = TextBoxChanged;
y = y + 30;
@@ -187,7 +187,7 @@ namespace Barotrauma
propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), GUI.Style, editingHUD);
propertyBox.Text = (assignedJob == null) ? "None" : assignedJob.Name;
propertyBox.OnEnter = EnterAssignedJob;
propertyBox.OnEnterPressed = EnterAssignedJob;
propertyBox.OnTextChanged = TextBoxChanged;
y = y + 30;
+6 -43
View File
@@ -9,10 +9,8 @@ using Barotrauma.Networking.ReliableMessages;
namespace Barotrauma.Networking
{
class GameServer : NetworkMember
partial class GameServer : NetworkMember
{
public bool ShowNetStats;
public List<Client> connectedClients = new List<Client>();
//for keeping track of disconnected clients in case the reconnect shortly after
@@ -24,41 +22,13 @@ namespace Barotrauma.Networking
bool started;
private NetServer server;
private NetPeerConfiguration config;
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
private DateTime sparseUpdateTimer;
private NetPeerConfiguration config;
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40);
private DateTime sparseUpdateTimer;
private DateTime refreshMasterTimer;
private BanList banList;
private bool masterServerResponded;
private bool registeredToMaster;
private string password;
private bool autoRestart;
public bool AutoRestart
{
get { return (connectedClients.Count==0) ? false : autoRestart; }
set
{
autoRestart = value;
AutoRestartTimer = autoRestart ? 20.0f : 0.0f;
}
}
public float AutoRestartTimer;
public BanList BanList
{
get { return banList; }
}
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
@@ -238,6 +208,7 @@ namespace Barotrauma.Networking
public override void Update(float deltaTime)
{
if (ShowNetStats) netStats.Update(deltaTime);
if (settingsFrame != null) settingsFrame.Update(deltaTime);
if (!started) return;
@@ -1033,6 +1004,8 @@ namespace Barotrauma.Networking
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
if (settingsFrame != null) settingsFrame.Draw(spriteBatch);
if (!ShowNetStats) return;
@@ -1292,16 +1265,6 @@ namespace Barotrauma.Networking
return preferredClient;
}
private byte PlayerCountToByte(int playerCount, int maxPlayers)
{
byte byteVal = (byte)playerCount;
byteVal |= (byte)((maxPlayers-1) << 4);
return byteVal;
}
/// <summary>
/// sends some random data to the clients
/// use for debugging purposes
+10 -12
View File
@@ -109,7 +109,7 @@ namespace Barotrauma.Networking
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.Style, inGameHUD);
chatMsgBox.Font = GUI.SmallFont;
chatMsgBox.OnEnter = EnterChatMessage;
chatMsgBox.OnEnterPressed = EnterChatMessage;
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.Style, inGameHUD);
crewButton.OnClicked = ToggleCrewFrame;
@@ -175,17 +175,6 @@ namespace Barotrauma.Networking
return true;
}
//protected void UpdateCrewFrame(List<Client> connectedClients)
//{
// List<Character> characterList = new List<Character>();
// foreach (Client c in connectedClients)
// {
// if (c.character != null && c.inGame) characterList.Add(c.character);
// }
// CreateCrewFrame(characterList);
//}
public bool EnterChatMessage(GUITextBox textBox, string message)
{
if (string.IsNullOrWhiteSpace(message)) return false;
@@ -268,6 +257,15 @@ namespace Barotrauma.Networking
public virtual void Disconnect() { }
protected byte PlayerCountToByte(int playerCount, int maxPlayers)
{
byte byteVal = (byte)playerCount;
byteVal |= (byte)((maxPlayers - 1) << 4);
return byteVal;
}
public static int ByteToPlayerCount(byte byteVal, out int maxPlayers)
{
maxPlayers = (byteVal >> 4)+1;
+138 -23
View File
@@ -7,62 +7,177 @@ namespace Barotrauma
public enum InputType
{
Select,
ActionHit, ActionHeld,
SecondaryHit, SecondaryHeld,
Left, Right, Up, Down,
Use,
Aim,
Up, Down, Left, Right,
Run, Chat
}
public class KeyOrMouse
{
Keys keyBinding;
int? mouseButton;
public KeyOrMouse(Keys keyBinding)
{
this.keyBinding = keyBinding;
}
public KeyOrMouse(int mouseButton)
{
this.mouseButton = mouseButton;
}
public bool IsDown()
{
if (mouseButton==null)
{
return PlayerInput.KeyDown(keyBinding);
}
else if (mouseButton == 0)
{
return PlayerInput.LeftButtonDown();
}
else if (mouseButton == 1)
{
return PlayerInput.RightButtonDown();
}
return false;
}
public bool IsHit()
{
if (mouseButton == null)
{
return PlayerInput.KeyHit(keyBinding);
}
else if (mouseButton == 0)
{
return PlayerInput.LeftButtonClicked();
}
else if (mouseButton == 1)
{
return PlayerInput.RightButtonClicked();
}
return false;
}
public override string ToString()
{
if (mouseButton==null)
{
return keyBinding.ToString();
}
else if (mouseButton==0)
{
return "Mouse1";
}
else if (mouseButton==1)
{
return "Mouse2";
}
return "None";
}
}
class Key
{
private bool state, stateQueue;
private bool canBeHeld;
private bool hit, hitQueue;
private bool held, heldQueue;
public bool CanBeHeld
{
get { return canBeHeld; }
}
KeyOrMouse binding;
//public bool CanBeHeld
//{
// get { return canBeHeld; }
//}
public Key(bool canBeHeld)
public Key(KeyOrMouse binding)
{
this.canBeHeld = canBeHeld;
this.binding = binding;
}
public bool State
public bool Hit
{
get
{
return state;
return hit;
}
set
{
//if (value == false) return;
state = value;
//if (value) stateQueue = value;
hit = value;
}
}
public void SetState(bool value)
public bool Held
{
get
{
return held;
}
set
{
held = value;
}
}
public KeyOrMouse State
{
get { return binding; }
}
public void SetState()
{
state = value;
if (value) stateQueue = value;
hit = binding.IsHit();
if (hit) hitQueue = true;
held = binding.IsDown();
if (held) heldQueue = true;
}
public bool Dequeue
{
get
{
bool value = stateQueue;
stateQueue = false;
bool value = hitQueue;
hitQueue = false;
return value;
}
}
public void Reset()
public bool DequeueHeld
{
get
{
bool value = heldQueue;
heldQueue = false;
return value;
}
}
public void Reset()
{
hit = false;
held = false;
}
public void ResetHit()
{
if (!canBeHeld) state = false;
hit = false;
//stateQueue = false;
}
public void ResetHeld()
{
held = false;
//stateQueue = false;
}
}
public static class PlayerInput
@@ -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();
+41 -15
View File
@@ -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
{
}
}
+1 -36
View File
@@ -46,18 +46,13 @@ namespace Barotrauma
{
try
{
#if WINDOWS
using (Stream fileStream = File.OpenRead(path))
return FromStream(fileStream, preMultiplyAlpha);
#endif
#if LINUX
using (Stream fileStream = File.OpenRead(path))
{
var texture = Texture2D.FromStream(_graphicsDevice, fileStream);
texture = PreMultiplyAlpha(texture);
return texture;
}
#endif
}
catch (Exception e)
@@ -68,36 +63,6 @@ namespace Barotrauma
}
#if WINDOWS
private static Texture2D FromStream(Stream stream, bool preMultiplyAlpha = true)
{
Texture2D texture;
if (_needsBmp)
{
// Load image using GDI because Texture2D.FromStream doesn't support BMP
using (Image image = Image.FromStream(stream))
{
// Now create a MemoryStream which will be passed to Texture2D after converting to PNG internally
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, ImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
texture = Texture2D.FromStream(_graphicsDevice, ms);
}
}
}
else
{
texture = Texture2D.FromStream(_graphicsDevice, stream);
}
if (preMultiplyAlpha) texture = PreMultiplyAlpha(texture);
return texture;
}
#endif
private static Texture2D PreMultiplyAlpha(Texture2D texture)
{
// Setup a render target to hold our final texture which will have premulitplied alpha values
Binary file not shown.