Order symbols
This commit is contained in:
@@ -628,6 +628,9 @@
|
|||||||
<Content Include="Content\UI\inventoryIcons.png">
|
<Content Include="Content\UI\inventoryIcons.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\UI\orderSymbols.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\UI\statusIcons.png">
|
<Content Include="Content\UI\statusIcons.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -815,6 +818,9 @@
|
|||||||
<Content Include="Content\waterbump.png">
|
<Content Include="Content\waterbump.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Orders.xml">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Data\ContentPackages\Vanilla 0.2.xml">
|
<Content Include="Data\ContentPackages\Vanilla 0.2.xml">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Orders>
|
||||||
|
<Order name="Follow" doingtext="Following" color="0.0,1.0,0.0,1.0">
|
||||||
|
<Sprite texture="Content/UI/orderSymbols.png" sourcerect="0,0,64,64"/>
|
||||||
|
</Order>
|
||||||
|
|
||||||
|
<Order name="Wait" doingtext="Waiting" color="1.0,0.5,0.1,1.0">
|
||||||
|
<Sprite texture="Content/UI/orderSymbols.png" sourcerect="128,0,64,64"/>
|
||||||
|
</Order>
|
||||||
|
|
||||||
|
<Order name="Dismiss" doingtext="Dismissed" color="1.0,1.0,1.0,1.0">
|
||||||
|
<Sprite texture="Content/UI/orderSymbols.png" sourcerect="64,0,64,64"/>
|
||||||
|
</Order>
|
||||||
|
|
||||||
|
|
||||||
|
<Order name="Operate Reactor" doingtext="Operating Reactor" targetitemtype="Reactor" options="Power up, Shutdown" color="1.0,1.0,0.0,1.0">
|
||||||
|
<Sprite texture="Content/UI/orderSymbols.png" sourcerect="192,0,64,64"/>
|
||||||
|
</Order>
|
||||||
|
|
||||||
|
<Order name="Operate Railgun" doingtext="Operating Railgun" targetitemtype="Turret" options="Fire at will, Hold fire" color="1.0,0.0,0.0,1.0">
|
||||||
|
<Sprite texture="Content/UI/orderSymbols.png" sourcerect="0,64,64,64"/>
|
||||||
|
</Order>
|
||||||
|
</Orders>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
@@ -63,7 +63,7 @@ namespace Barotrauma
|
|||||||
Order.PrefabList.FindAll(o=> o.ItemComponentType!=null);
|
Order.PrefabList.FindAll(o=> o.ItemComponentType!=null);
|
||||||
|
|
||||||
int startX = (int)-(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
|
int startX = (int)-(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
foreach (Order order in orders)
|
foreach (Order order in orders)
|
||||||
{
|
{
|
||||||
@@ -77,25 +77,39 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var newOrder = new Order(order, it.components.Find(ic => ic.GetType() == order.ItemComponentType));
|
var newOrder = new Order(order, it.components.Find(ic => ic.GetType() == order.ItemComponentType));
|
||||||
|
|
||||||
var button = new GUIButton(new Rectangle(x+buttonWidth/2, y2, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
|
CreateOrderButton(new Rectangle(x + buttonWidth / 2, y2, buttonWidth, 20), newOrder, y2==y);
|
||||||
button.UserData = newOrder;
|
|
||||||
button.OnClicked = SetOrder;
|
|
||||||
y2 += 25;
|
y2 += 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var button = new GUIButton(new Rectangle(x + buttonWidth / 2, y, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
|
CreateOrderButton(new Rectangle(x + buttonWidth / 2, y, buttonWidth, 20), order);
|
||||||
button.UserData = order;
|
|
||||||
button.OnClicked = SetOrder;
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 80;
|
y += 80;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIButton CreateOrderButton(Rectangle rect, Order order, bool createSymbol = true)
|
||||||
|
{
|
||||||
|
var orderButton = new GUIButton(rect, order.Name, Color.Black * 0.5f, Alignment.TopCenter, Alignment.Right, null, frame);
|
||||||
|
orderButton.HoverColor = Color.LightGray * 0.5f;
|
||||||
|
orderButton.OutlineColor = Color.LightGray * 0.8f;
|
||||||
|
orderButton.UserData = order;
|
||||||
|
orderButton.OnClicked = SetOrder;
|
||||||
|
|
||||||
|
if (createSymbol)
|
||||||
|
{
|
||||||
|
var symbol = new GUIImage(new Rectangle(-5,0,64,64), order.SymbolSprite, Alignment.Left | Alignment.CenterY, orderButton);
|
||||||
|
symbol.Color = order.Color;
|
||||||
|
|
||||||
|
orderButton.children.Insert(1, symbol);
|
||||||
|
orderButton.children.RemoveAt(orderButton.children.Count-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateCharacters()
|
public void UpdateCharacters()
|
||||||
@@ -155,7 +169,8 @@ namespace Barotrauma
|
|||||||
characterButton.OutlineColor = Color.LightGray * 0.8f;
|
characterButton.OutlineColor = Color.LightGray * 0.8f;
|
||||||
}
|
}
|
||||||
|
|
||||||
string name = character.Info.Name.Replace(' ', '\n');
|
string name = character.Info.Name;
|
||||||
|
if (character.Info.Job != null) name += '\n' + "(" + character.Info.Job.Name + ")";
|
||||||
|
|
||||||
GUITextBlock textBlock = new GUITextBlock(
|
GUITextBlock textBlock = new GUITextBlock(
|
||||||
new Rectangle(40, 0, 0, 25),
|
new Rectangle(40, 0, 0, 25),
|
||||||
@@ -166,7 +181,7 @@ namespace Barotrauma
|
|||||||
textBlock.Font = GUI.SmallFont;
|
textBlock.Font = GUI.SmallFont;
|
||||||
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
|
||||||
|
|
||||||
new GUIImage(new Rectangle(-10, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, characterButton);
|
new GUIImage(new Rectangle(-5, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, characterButton);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,29 @@
|
|||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
class Order
|
class Order
|
||||||
{
|
{
|
||||||
|
private static string ConfigFile = Path.Combine("Content", "Orders.xml");
|
||||||
|
|
||||||
public static List<Order> PrefabList;
|
public static List<Order> PrefabList;
|
||||||
|
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
public readonly string DoingText;
|
public readonly string DoingText;
|
||||||
|
|
||||||
//Sprite buttonSprite;
|
public readonly Sprite SymbolSprite;
|
||||||
|
|
||||||
public readonly Type ItemComponentType;
|
public readonly Type ItemComponentType;
|
||||||
|
|
||||||
|
public readonly Color Color;
|
||||||
|
|
||||||
public ItemComponent TargetItem;
|
public ItemComponent TargetItem;
|
||||||
|
|
||||||
public readonly string[] Options;
|
public readonly string[] Options;
|
||||||
@@ -25,18 +32,64 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
PrefabList = new List<Order>();
|
PrefabList = new List<Order>();
|
||||||
|
|
||||||
PrefabList.Add(new Order("Follow", "Following"));
|
XDocument doc = ToolBox.TryLoadXml(ConfigFile);
|
||||||
|
if (doc == null) return;
|
||||||
|
|
||||||
PrefabList.Add(new Order("Dismiss", "Dismissed"));
|
foreach (XElement orderElement in doc.Root.Elements())
|
||||||
|
{
|
||||||
|
if (orderElement.Name.ToString().ToLower() != "order") continue;
|
||||||
|
|
||||||
PrefabList.Add(new Order("Wait", "Wait"));
|
PrefabList.Add(new Order(orderElement));
|
||||||
|
}
|
||||||
|
|
||||||
PrefabList.Add(new Order("Operate Reactor", "Operating reactor", typeof(Reactor), new string[] {"Power up", "Shutdown"}));
|
//PrefabList.Add(new Order("Follow", "Following"));
|
||||||
PrefabList.Add(new Order("Operate Railgun", "Operating railgun", typeof(Turret), new string[] { "Fire at will", "Hold fire" }));
|
|
||||||
|
//PrefabList.Add(new Order("Dismiss", "Dismissed"));
|
||||||
|
|
||||||
|
//PrefabList.Add(new Order("Wait", "Wait"));
|
||||||
|
|
||||||
|
//PrefabList.Add(new Order("Operate Reactor", "Operating reactor", typeof(Reactor), new string[] {"Power up", "Shutdown"}));
|
||||||
|
//PrefabList.Add(new Order("Operate Railgun", "Operating railgun", typeof(Turret), new string[] { "Fire at will", "Hold fire" }));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Order(XElement orderElement)
|
||||||
|
{
|
||||||
|
Name = ToolBox.GetAttributeString(orderElement, "name", "Name not found");
|
||||||
|
DoingText = ToolBox.GetAttributeString(orderElement, "doingtext", "");
|
||||||
|
|
||||||
|
string targetItemName = ToolBox.GetAttributeString(orderElement, "targetitemtype", "");
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(targetItemName))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ItemComponentType = Type.GetType("Barotrauma.Items.Components." + targetItemName, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Error in " + ConfigFile + ", item component type " + targetItemName + " not found", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color = new Color(ToolBox.GetAttributeVector4(orderElement, "color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)));
|
||||||
|
|
||||||
|
Options = ToolBox.GetAttributeString(orderElement, "options", "").Split(',');
|
||||||
|
for (int i = 0; i<Options.Length; i++)
|
||||||
|
{
|
||||||
|
Options[i] = Options[i].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (XElement subElement in orderElement.Elements())
|
||||||
|
{
|
||||||
|
if (subElement.Name.ToString().ToLower() != "sprite") continue;
|
||||||
|
SymbolSprite = new Sprite(subElement);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Order(string name, string doingText, Type itemComponentType, string[] parameters = null)
|
private Order(string name, string doingText, Type itemComponentType, string[] parameters = null)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@@ -51,6 +104,8 @@ namespace Barotrauma
|
|||||||
DoingText = prefab.DoingText;
|
DoingText = prefab.DoingText;
|
||||||
ItemComponentType = prefab.ItemComponentType;
|
ItemComponentType = prefab.ItemComponentType;
|
||||||
Options = prefab.Options;
|
Options = prefab.Options;
|
||||||
|
SymbolSprite = prefab.SymbolSprite;
|
||||||
|
Color = prefab.Color;
|
||||||
|
|
||||||
TargetItem = targetItem;
|
TargetItem = targetItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -754,7 +754,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (moveCam)
|
if (moveCam)
|
||||||
{
|
{
|
||||||
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
|
||||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GUIImage(Rectangle rect, Sprite sprite, Alignment alignment, GUIComponent parent = null)
|
public GUIImage(Rectangle rect, Sprite sprite, Alignment alignment, GUIComponent parent = null)
|
||||||
: this(rect, sprite.SourceRect, sprite, alignment, parent)
|
: this(rect, sprite==null ? Rectangle.Empty : sprite.SourceRect, sprite, alignment, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +83,12 @@ namespace Barotrauma
|
|||||||
if (state == ComponentState.Hover) currColor = hoverColor;
|
if (state == ComponentState.Hover) currColor = hoverColor;
|
||||||
if (state == ComponentState.Selected) currColor = selectedColor;
|
if (state == ComponentState.Selected) currColor = selectedColor;
|
||||||
|
|
||||||
spriteBatch.Draw(sprite.Texture, new Vector2(rect.X, rect.Y), sourceRect, currColor * (currColor.A / 255.0f), 0.0f, Vector2.Zero,
|
if (sprite!=null)
|
||||||
Scale, SpriteEffects.None, 0.0f);
|
{
|
||||||
|
spriteBatch.Draw(sprite.Texture, new Vector2(rect.X, rect.Y), sourceRect, currColor * (currColor.A / 255.0f), 0.0f, Vector2.Zero,
|
||||||
|
Scale, SpriteEffects.None, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DrawChildren(spriteBatch);
|
DrawChildren(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,11 +346,8 @@ namespace Barotrauma
|
|||||||
waitForKeyHit = waitKeyHit;
|
waitForKeyHit = waitKeyHit;
|
||||||
titleScreenOpen = true;
|
titleScreenOpen = true;
|
||||||
CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
|
CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override void OnExiting(object sender, EventArgs args)
|
protected override void OnExiting(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
if (NetworkMember != null) NetworkMember.Disconnect();
|
if (NetworkMember != null) NetworkMember.Disconnect();
|
||||||
|
|||||||
@@ -1171,7 +1171,8 @@ namespace Barotrauma
|
|||||||
int.Parse(rectValues[1]),
|
int.Parse(rectValues[1]),
|
||||||
int.Parse(rectValues[2]),
|
int.Parse(rectValues[2]),
|
||||||
int.Parse(rectValues[3]));
|
int.Parse(rectValues[3]));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rect = new Rectangle(
|
rect = new Rectangle(
|
||||||
int.Parse(rectValues[0]),
|
int.Parse(rectValues[0]),
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
//if (!Physics.updated) return;
|
if (Character.Controlled!=null)
|
||||||
|
{
|
||||||
|
cam.TargetPos = Character.Controlled.Position;
|
||||||
|
}
|
||||||
|
|
||||||
cam.UpdateTransform();
|
cam.UpdateTransform();
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user