Order symbols

This commit is contained in:
Regalis
2015-12-07 19:32:55 +02:00
parent ca77103d0d
commit ca7eae5322
11 changed files with 127 additions and 24 deletions

View File

@@ -628,6 +628,9 @@
<Content Include="Content\UI\inventoryIcons.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\UI\orderSymbols.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\UI\statusIcons.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -815,6 +818,9 @@
<Content Include="Content\waterbump.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Orders.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\ContentPackages\Vanilla 0.2.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@@ -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

View File

@@ -63,7 +63,7 @@ namespace Barotrauma
Order.PrefabList.FindAll(o=> o.ItemComponentType!=null);
int startX = (int)-(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
int i=0;
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 button = new GUIButton(new Rectangle(x+buttonWidth/2, y2, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
button.UserData = newOrder;
button.OnClicked = SetOrder;
CreateOrderButton(new Rectangle(x + buttonWidth / 2, y2, buttonWidth, 20), newOrder, y2==y);
y2 += 25;
}
}
else
{
var button = new GUIButton(new Rectangle(x + buttonWidth / 2, y, buttonWidth, 20), order.Name, Alignment.TopCenter, GUI.Style, frame);
button.UserData = order;
button.OnClicked = SetOrder;
CreateOrderButton(new Rectangle(x + buttonWidth / 2, y, buttonWidth, 20), order);
}
i++;
}
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()
@@ -155,7 +169,8 @@ namespace Barotrauma
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(
new Rectangle(40, 0, 0, 25),
@@ -166,7 +181,7 @@ namespace Barotrauma
textBlock.Font = GUI.SmallFont;
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++;
}

View File

@@ -1,22 +1,29 @@
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class Order
{
private static string ConfigFile = Path.Combine("Content", "Orders.xml");
public static List<Order> PrefabList;
public readonly string Name;
public readonly string DoingText;
//Sprite buttonSprite;
public readonly Sprite SymbolSprite;
public readonly Type ItemComponentType;
public readonly Color Color;
public ItemComponent TargetItem;
public readonly string[] Options;
@@ -25,18 +32,64 @@ namespace Barotrauma
{
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("Operate Railgun", "Operating railgun", typeof(Turret), new string[] { "Fire at will", "Hold fire" }));
//PrefabList.Add(new Order("Follow", "Following"));
//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)
{
Name = name;
@@ -51,6 +104,8 @@ namespace Barotrauma
DoingText = prefab.DoingText;
ItemComponentType = prefab.ItemComponentType;
Options = prefab.Options;
SymbolSprite = prefab.SymbolSprite;
Color = prefab.Color;
TargetItem = targetItem;
}

View File

@@ -754,7 +754,6 @@ namespace Barotrauma
if (moveCam)
{
cam.TargetPos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
}

View File

@@ -47,7 +47,7 @@ namespace Barotrauma
}
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.Selected) currColor = selectedColor;
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);
if (sprite!=null)
{
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);
}

View File

@@ -346,11 +346,8 @@ namespace Barotrauma
waitForKeyHit = waitKeyHit;
titleScreenOpen = true;
CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
}
protected override void OnExiting(object sender, EventArgs args)
{
if (NetworkMember != null) NetworkMember.Disconnect();

View File

@@ -1171,7 +1171,8 @@ namespace Barotrauma
int.Parse(rectValues[1]),
int.Parse(rectValues[2]),
int.Parse(rectValues[3]));
} else
}
else
{
rect = new Rectangle(
int.Parse(rectValues[0]),

View File

@@ -130,7 +130,10 @@ namespace Barotrauma
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();

Binary file not shown.