assigning jobs when a round starts, crew tab in multiplayer, repairtool particles light & sounds, attachable buttons, increased repairtool range & limbdamage, captain's uniform, wearable sprite bugfixes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface.Networking
|
||||
{
|
||||
@@ -40,9 +42,14 @@ namespace Subsurface.Networking
|
||||
|
||||
protected GUIFrame inGameHUD;
|
||||
protected GUIListBox chatBox;
|
||||
protected GUITextBox chatMsgBox;
|
||||
|
||||
public int Port;
|
||||
|
||||
private bool crewFrameOpen;
|
||||
private GUIButton crewButton;
|
||||
private GUIFrame crewFrame;
|
||||
|
||||
protected bool gameStarted;
|
||||
|
||||
public string Name
|
||||
@@ -72,13 +79,73 @@ namespace Subsurface.Networking
|
||||
width, height),
|
||||
Color.White * 0.5f, GUI.style, inGameHUD);
|
||||
|
||||
var textBox = new GUITextBox(
|
||||
chatMsgBox = new GUITextBox(
|
||||
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);
|
||||
textBox.Font = GUI.SmallFont;
|
||||
textBox.OnEnter = EnterChatMessage;
|
||||
chatMsgBox.Font = GUI.SmallFont;
|
||||
chatMsgBox.OnEnter = EnterChatMessage;
|
||||
|
||||
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.style, inGameHUD);
|
||||
crewButton.OnClicked = ToggleCrewFrame;
|
||||
}
|
||||
|
||||
protected void CreateCrewFrame(List<Character> crew)
|
||||
{
|
||||
int width = 500, height = 400;
|
||||
|
||||
crewFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
|
||||
crewFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
|
||||
GUIListBox crewList = new GUIListBox(new Rectangle(0, 0, 200, 300), Color.White * 0.7f, GUI.style, crewFrame);
|
||||
crewList.OnSelected = SelectCharacter;
|
||||
|
||||
foreach (Character character in crew)
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, crewList);
|
||||
frame.UserData = character;
|
||||
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
frame.HoverColor = Color.LightGray * 0.5f;
|
||||
frame.SelectedColor = Color.Gold * 0.5f;
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(40, 0, 0, 25),
|
||||
character.Info.Name + " ("+character.Info.Job.Name+")",
|
||||
Color.Transparent, Color.White,
|
||||
Alignment.Left, Alignment.Left,
|
||||
null, frame);
|
||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||
|
||||
new GUIImage(new Rectangle(-10, -10, 0, 0), character.AnimController.limbs[0].sprite, Alignment.Left, frame);
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new Rectangle(0,0, 80, 20), "Close", Alignment.BottomCenter, GUI.style, crewFrame);
|
||||
closeButton.OnClicked = ToggleCrewFrame;
|
||||
}
|
||||
|
||||
private bool SelectCharacter(object obj)
|
||||
{
|
||||
Character character = obj as Character;
|
||||
if (obj == null) return false;
|
||||
|
||||
GUIComponent existingFrame = crewFrame.FindChild("selectedcharacter");
|
||||
if (existingFrame != null) crewFrame.RemoveChild(existingFrame);
|
||||
|
||||
var previewPlayer = new GUIFrame(
|
||||
new Rectangle(0,0, 230, 300),
|
||||
new Color(0.0f, 0.0f, 0.0f, 0.8f), Alignment.TopRight, GUI.style, crewFrame);
|
||||
previewPlayer.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
previewPlayer.UserData = "selectedcharacter";
|
||||
|
||||
var infoFrame = character.Info.CreateInfoFrame(previewPlayer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ToggleCrewFrame(GUIButton button, object obj)
|
||||
{
|
||||
crewFrameOpen = !crewFrameOpen;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool EnterChatMessage(GUITextBox textBox, string message)
|
||||
{
|
||||
@@ -122,13 +189,36 @@ namespace Subsurface.Networking
|
||||
|
||||
public virtual void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server) { }
|
||||
|
||||
public virtual void Update() { }
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
if (gameStarted)
|
||||
{
|
||||
inGameHUD.Update(deltaTime);
|
||||
|
||||
if (crewFrameOpen) crewFrame.Update(deltaTime);
|
||||
}
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Tab))
|
||||
{
|
||||
if (chatMsgBox.Selected)
|
||||
{
|
||||
chatMsgBox.Text = "";
|
||||
chatMsgBox.Deselect();
|
||||
}
|
||||
else
|
||||
{
|
||||
chatMsgBox.Select();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!gameStarted) return;
|
||||
|
||||
inGameHUD.Draw(spriteBatch);
|
||||
|
||||
if (crewFrameOpen) crewFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual void Disconnect() { }
|
||||
|
||||
Reference in New Issue
Block a user