UI tweaks
This commit is contained in:
@@ -107,6 +107,7 @@ namespace Barotrauma
|
|||||||
int width = 500, height = 400;
|
int width = 500, height = 400;
|
||||||
|
|
||||||
GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f);
|
GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f);
|
||||||
|
backFrame.Padding = Vector4.Zero;
|
||||||
|
|
||||||
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", backFrame);
|
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", backFrame);
|
||||||
frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f);
|
frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f);
|
||||||
|
|||||||
@@ -310,15 +310,19 @@ namespace Barotrauma
|
|||||||
int centerWidth = Math.Max(rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width, 0);
|
int centerWidth = Math.Max(rect.Width - uiSprite.Slices[0].Width - uiSprite.Slices[2].Width, 0);
|
||||||
int centerHeight = Math.Max(rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height, 0);
|
int centerHeight = Math.Max(rect.Height - uiSprite.Slices[0].Height - uiSprite.Slices[8].Height, 0);
|
||||||
|
|
||||||
|
Vector2 scale = new Vector2(
|
||||||
|
MathHelper.Clamp((float)rect.Width / (uiSprite.Slices[0].Width + uiSprite.Slices[2].Width),0, 1),
|
||||||
|
MathHelper.Clamp((float)rect.Height / (uiSprite.Slices[0].Height + uiSprite.Slices[6].Height), 0, 1));
|
||||||
|
|
||||||
for (int x = 0; x < 3; x++)
|
for (int x = 0; x < 3; x++)
|
||||||
{
|
{
|
||||||
int width = x == 1 ? centerWidth : uiSprite.Slices[x].Width;
|
float width = (x == 1 ? centerWidth : uiSprite.Slices[x].Width) * scale.X;
|
||||||
for (int y = 0; y < 3; y++)
|
for (int y = 0; y < 3; y++)
|
||||||
{
|
{
|
||||||
int height = y == 1 ? centerHeight : uiSprite.Slices[x + y * 3].Height;
|
float height = (y == 1 ? centerHeight : uiSprite.Slices[x + y * 3].Height) * scale.Y;
|
||||||
|
|
||||||
spriteBatch.Draw(uiSprite.Sprite.Texture,
|
spriteBatch.Draw(uiSprite.Sprite.Texture,
|
||||||
new Rectangle((int)pos.X, (int)pos.Y, width, height),
|
new Rectangle((int)pos.X, (int)pos.Y, (int)width, (int)height),
|
||||||
uiSprite.Slices[x + y * 3],
|
uiSprite.Slices[x + y * 3],
|
||||||
currColor * (currColor.A / 255.0f));
|
currColor * (currColor.A / 255.0f));
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,20 @@ namespace Barotrauma
|
|||||||
get { return box.Rect; }
|
get { return box.Rect; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ScalableFont Font
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.Font;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Font = value;
|
||||||
|
if (text != null) text.Font = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
|
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
|
||||||
: this(rect, label, alignment, GUI.Font, parent)
|
: this(rect, label, alignment, GUI.Font, parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1037,9 +1037,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private GUIComponent CreateEditingHUD(bool inGame=false)
|
private GUIComponent CreateEditingHUD(bool inGame=false)
|
||||||
{
|
{
|
||||||
int width = 450;
|
|
||||||
int x = GameMain.GraphicsWidth/2-width/2, y = 10;
|
|
||||||
|
|
||||||
List<ObjectProperty> editableProperties = inGame ? GetProperties<InGameEditable>() : GetProperties<Editable>();
|
List<ObjectProperty> editableProperties = inGame ? GetProperties<InGameEditable>() : GetProperties<Editable>();
|
||||||
|
|
||||||
int requiredItemCount = 0;
|
int requiredItemCount = 0;
|
||||||
@@ -1047,33 +1044,42 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
foreach (ItemComponent ic in components)
|
foreach (ItemComponent ic in components)
|
||||||
{
|
{
|
||||||
requiredItemCount += ic.requiredItems.Count;
|
requiredItemCount += ic.requiredItems.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, 70 + (editableProperties.Count + requiredItemCount) * 30), "");
|
int width = 450;
|
||||||
|
int height = 80 + requiredItemCount * 20;
|
||||||
|
int x = GameMain.GraphicsWidth / 2 - width / 2, y = 10;
|
||||||
|
foreach (var objectProperty in editableProperties)
|
||||||
|
{
|
||||||
|
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
||||||
|
if (editable != null) height += (int)(Math.Ceiling(editable.MaxLength / 40.0f) * 18.0f) + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
editingHUD = new GUIFrame(new Rectangle(x, y, width, height), "");
|
||||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||||
editingHUD.UserData = this;
|
editingHUD.UserData = this;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, "",
|
new GUITextBlock(new Rectangle(0, 0, 100, 20), prefab.Name, "",
|
||||||
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
|
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
|
||||||
|
|
||||||
y += 20;
|
y += 25;
|
||||||
|
|
||||||
if (!inGame)
|
if (!inGame)
|
||||||
{
|
{
|
||||||
if (prefab.IsLinkable)
|
if (prefab.IsLinkable)
|
||||||
{
|
{
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Hold space to link to another item",
|
new GUITextBlock(new Rectangle(0, 5, 0, 20), "Hold space to link to another item",
|
||||||
"", Alignment.TopRight, Alignment.TopRight, editingHUD).Font = GUI.SmallFont;
|
"", Alignment.TopRight, Alignment.TopRight, editingHUD).Font = GUI.SmallFont;
|
||||||
y += 25;
|
|
||||||
}
|
}
|
||||||
foreach (ItemComponent ic in components)
|
foreach (ItemComponent ic in components)
|
||||||
{
|
{
|
||||||
foreach (RelatedItem relatedItem in ic.requiredItems)
|
foreach (RelatedItem relatedItem in ic.requiredItems)
|
||||||
{
|
{
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), ic.Name + ": " + relatedItem.Type.ToString() + " required", "", editingHUD);
|
new GUITextBlock(new Rectangle(0, y, 100, 15), ic.Name + ": " + relatedItem.Type.ToString() + " required", "", Alignment.TopLeft, Alignment.CenterLeft, editingHUD, false, GUI.SmallFont);
|
||||||
GUITextBox namesBox = new GUITextBox(new Rectangle(-10, y, 160, 20), Alignment.Right, "", editingHUD);
|
GUITextBox namesBox = new GUITextBox(new Rectangle(-10, y, 160, 15), Alignment.Right, "", editingHUD);
|
||||||
|
namesBox.Font = GUI.SmallFont;
|
||||||
|
|
||||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (relatedItem);
|
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties (relatedItem);
|
||||||
PropertyDescriptor property = properties.Find("JoinedNames", false);
|
PropertyDescriptor property = properties.Find("JoinedNames", false);
|
||||||
@@ -1083,24 +1089,25 @@ namespace Barotrauma
|
|||||||
namesBox.OnEnterPressed = EnterProperty;
|
namesBox.OnEnterPressed = EnterProperty;
|
||||||
namesBox.OnTextChanged = PropertyChanged;
|
namesBox.OnTextChanged = PropertyChanged;
|
||||||
|
|
||||||
y += 30;
|
y += 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (requiredItemCount > 0) y += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var objectProperty in editableProperties)
|
foreach (var objectProperty in editableProperties)
|
||||||
{
|
{
|
||||||
int height = 20;
|
int boxHeight = 18;
|
||||||
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
var editable = objectProperty.Attributes.OfType<Editable>().FirstOrDefault();
|
||||||
if (editable != null) height = (int)(Math.Ceiling(editable.MaxLength / 20.0f) * 20.0f);
|
if (editable != null) boxHeight = (int)(Math.Ceiling(editable.MaxLength / 40.0f) * 18.0f);
|
||||||
|
|
||||||
object value = objectProperty.GetValue();
|
object value = objectProperty.GetValue();
|
||||||
|
|
||||||
if (value is bool)
|
if (value is bool)
|
||||||
{
|
{
|
||||||
GUITickBox propertyTickBox = new GUITickBox(new Rectangle(10, y, 20, 20), objectProperty.Name,
|
GUITickBox propertyTickBox = new GUITickBox(new Rectangle(10, y, 18, 18), objectProperty.Name,
|
||||||
Alignment.Left, editingHUD);
|
Alignment.Left, editingHUD);
|
||||||
|
propertyTickBox.Font = GUI.SmallFont;
|
||||||
|
|
||||||
propertyTickBox.Selected = (bool)value;
|
propertyTickBox.Selected = (bool)value;
|
||||||
|
|
||||||
@@ -1109,11 +1116,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 100, 18), objectProperty.Name, "", Alignment.TopLeft, Alignment.Left, editingHUD, false, GUI.SmallFont);
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), objectProperty.Name, Color.Transparent, Color.White, Alignment.Left, "", editingHUD);
|
GUITextBox propertyBox = new GUITextBox(new Rectangle(180, y, 250, boxHeight), "", editingHUD);
|
||||||
|
propertyBox.Font = GUI.SmallFont;
|
||||||
GUITextBox propertyBox = new GUITextBox(new Rectangle(180, y, 250, height), "", editingHUD);
|
if (boxHeight > 18) propertyBox.Wrap = true;
|
||||||
if (height > 20) propertyBox.Wrap = true;
|
|
||||||
|
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
@@ -1133,7 +1140,7 @@ namespace Barotrauma
|
|||||||
propertyBox.OnTextChanged = PropertyChanged;
|
propertyBox.OnTextChanged = PropertyChanged;
|
||||||
|
|
||||||
}
|
}
|
||||||
y = y + height + 10;
|
y = y + boxHeight + 5;
|
||||||
|
|
||||||
}
|
}
|
||||||
return editingHUD;
|
return editingHUD;
|
||||||
|
|||||||
@@ -260,7 +260,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//mission type ------------------------------------------------------------------
|
//mission type ------------------------------------------------------------------
|
||||||
|
|
||||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, 0, 300, 20), "Mission type:", "", Alignment.BottomLeft, Alignment.TopLeft, infoFrame);
|
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, -10, 300, 20), "Mission type:", "", Alignment.BottomLeft, Alignment.CenterLeft, infoFrame);
|
||||||
|
missionTypeBlock.Padding = Vector4.Zero;
|
||||||
missionTypeBlock.UserData = 0;
|
missionTypeBlock.UserData = 0;
|
||||||
|
|
||||||
missionTypeButtons = new GUIButton[2];
|
missionTypeButtons = new GUIButton[2];
|
||||||
@@ -268,7 +269,7 @@ namespace Barotrauma
|
|||||||
missionTypeButtons[0] = new GUIButton(new Rectangle(100, 0, 20, 20), "<", Alignment.BottomLeft, "", missionTypeBlock);
|
missionTypeButtons[0] = new GUIButton(new Rectangle(100, 0, 20, 20), "<", Alignment.BottomLeft, "", missionTypeBlock);
|
||||||
missionTypeButtons[0].UserData = -1;
|
missionTypeButtons[0].UserData = -1;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(120, 0, 80, 20), "Random", "", Alignment.BottomLeft, Alignment.TopCenter, missionTypeBlock).UserData = 0;
|
new GUITextBlock(new Rectangle(120, 0, 80, 20), "Random", "", Alignment.BottomLeft, Alignment.Center, missionTypeBlock).UserData = 0;
|
||||||
|
|
||||||
missionTypeButtons[1] = new GUIButton(new Rectangle(200, 0, 20, 20), ">", Alignment.BottomLeft, "", missionTypeBlock);
|
missionTypeButtons[1] = new GUIButton(new Rectangle(200, 0, 20, 20), ">", Alignment.BottomLeft, "", missionTypeBlock);
|
||||||
missionTypeButtons[1].UserData = 1;
|
missionTypeButtons[1].UserData = 1;
|
||||||
@@ -342,6 +343,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Select()
|
public override void Select()
|
||||||
{
|
{
|
||||||
|
if (GameMain.NetworkMember == null) return;
|
||||||
|
|
||||||
GameMain.LightManager.LosEnabled = false;
|
GameMain.LightManager.LosEnabled = false;
|
||||||
|
|
||||||
textBox.Select();
|
textBox.Select();
|
||||||
|
|||||||
Reference in New Issue
Block a user