Menu Screen + UI Restyle

Created menu screen
Created inventory tab with 2 cargo panes and properties panel
Updated the style of every UI prefab
Implemented Blurred UI material
Implemented UI shaders for map layers
Created Map tab (still needs input)
This commit is contained in:
Reinier Vens 2020-12-14 02:56:35 +00:00
commit 4f19189244
106 changed files with 11233 additions and 24584 deletions

View file

@ -2,10 +2,11 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ButtonField : MonoBehaviour
{
public TextMeshProUGUI Label;
public TextMeshProUGUI ButtonLabel;
public FlatFlatButton Button;
public Button Button;
}

View file

@ -2,28 +2,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ConfirmationDialog : PropertiesPanel
{
public ClickCatcher CancelClickCatcher;
public FlatButton Cancel;
public FlatButton Confirm;
public Button Cancel;
public Button Confirm;
private Action _onCancel;
private Action _onConfirm;
private new void Start()
{
Cancel.OnClick += () =>
Cancel.onClick.AddListener(() =>
{
_onCancel?.Invoke();
End();
};
Confirm.OnClick += () =>
});
Confirm.onClick.AddListener(() =>
{
_onConfirm?.Invoke();
End();
};
});
if (CancelClickCatcher != null)
CancelClickCatcher.OnClick += data =>
{

View file

@ -46,12 +46,13 @@ public class DropdownMenu : MonoBehaviour
{
var optionButton = Instantiate(OptionPrefab, ContentRoot);
optionButton.Label.text = text;
optionButton.Button.OnClick += data =>
optionButton.Button.onClick.AddListener(() =>
{
action();
End();
};
optionButton.Button.CurrentState = !enabled ? FlatButtonState.Disabled : selected ? FlatButtonState.Selected : FlatButtonState.Unselected;
});
optionButton.Button.interactable = enabled;
//optionButton.Button..CurrentState = !enabled ? FlatButtonState.Disabled : selected ? FlatButtonState.Selected : FlatButtonState.Unselected;
_options.Add(optionButton.gameObject);
}

View file

@ -2,11 +2,12 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class IncrementField : MonoBehaviour
{
public TextMeshProUGUI Label;
public TextMeshProUGUI Value;
public FlatFlatButton Increment;
public FlatFlatButton Decrement;
public Button Increment;
public Button Decrement;
}

View file

@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UI;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using int2 = Unity.Mathematics.int2;
@ -70,7 +70,7 @@ public class InventoryPanel : MonoBehaviour
spriteIndex += 1 << i;
}
if (spriteIndex == 15)
if (spriteIndex == 0)
{
var empty = new GameObject("Empty Node", typeof(RectTransform));
empty.transform.SetParent(Grid.transform);
@ -80,7 +80,54 @@ public class InventoryPanel : MonoBehaviour
var node = NodePrototype.Instantiate<Prototype>().gameObject;
var image = node.GetComponentInChildren<Image>();
image.sprite = NodeTextures[spriteIndex];
image.color = hardpoint != null ? hardpoint.TintColor.ToColor() : interior ? Color.white * .5f : Color.white;
image.color = hardpoint?.TintColor.ToColor() ?? (interior ? Color.white * .5f : Color.white);
return node;
});
}
public void Display(ItemManager manager, EquippedCargoBay cargo)
{
Grid.constraintCount = cargo.Data.Shape.Width;
_nodeInstances = cargo.Data.Shape.AllCoordinates
.ToDictionary(v => v,
v =>
{
if (!cargo.Data.Shape[v])
{
var empty = new GameObject("Empty Node", typeof(RectTransform));
empty.transform.SetParent(Grid.transform);
return empty;
}
var spriteIndex = 0;
var item = cargo.Occupancy[v.x, v.y];
bool ItemMatch(int2 offset) =>
!cargo.Data.Shape[v + offset] ||
item == null ||
cargo.Occupancy[v.x + offset.x, v.y + offset.y] != item;
for(int i = 0; i < 8; i++)
if (ItemMatch(_offsets[i]))
spriteIndex += 1 << i;
if (spriteIndex == 0)
{
var empty = new GameObject("Empty Node", typeof(RectTransform));
empty.transform.SetParent(Grid.transform);
return empty;
}
var node = NodePrototype.Instantiate<Prototype>().gameObject;
var image = node.GetComponentInChildren<Image>();
image.sprite = NodeTextures[spriteIndex];
var itemData = manager.GetData(item);
if (item == null)
image.color = Color.white * .5f;
else if (itemData is EquippableItemData equippable)
image.color = HardpointData.GetColor(equippable.HardpointType).ToColor();
else
image.color = Color.white;
return node;
});
}

View file

@ -10,7 +10,7 @@ public class PropertiesList : PropertiesPanel
{
public Image FoldoutIcon;
public float FoldoutRotationDamping;
public FlatFlatButton Button;
public Button Button;
public VerticalLayoutGroup LayoutGroup;
public int FoldedPadding = -8;
public int ExpandedPadding = 8;
@ -24,7 +24,7 @@ public class PropertiesList : PropertiesPanel
public new void Awake()
{
Button.OnClick += _ => ToggleExpand();
Button.onClick.AddListener(ToggleExpand);
OnPropertyAdded += go => go.SetActive(_expanded);
//SetExpanded(true, true);
}

View file

@ -16,11 +16,11 @@ public class PropertiesPanel : MonoBehaviour
{
public DropdownMenu Dropdown;
public TextMeshProUGUI Title;
public RectTransform SectionPrefab;
public PropertiesList ListPrefab;
public PropertyButton PropertyPrefab;
public PropertyLabel PropertyLabelPrefab;
public AttributeProperty AttributePrefab;
public RectTransform Section;
public PropertiesList List;
public Property Property;
public PropertyLabel PropertyLabel;
public AttributeProperty Attribute;
public InputField InputField;
public RangedFloatField RangedFloatField;
public RangedFloatField ProgressField;
@ -82,38 +82,21 @@ public class PropertiesPanel : MonoBehaviour
public RectTransform AddSection(string name)
{
var section = Instantiate(SectionPrefab, transform);
var section = Instantiate(Section, transform);
section.GetComponentInChildren<TextMeshProUGUI>().text = name;
Properties.Add(section.gameObject);
OnPropertyAdded?.Invoke(section.gameObject);
return section;
}
public PropertyButton AddProperty(string name, Func<string> read = null, Action<PointerEventData> onClick = null, bool radio = false)
public Property AddProperty(string name, Func<string> read = null)
{
PropertyButton property;
Property property;
if(read != null)
property = Instantiate(PropertyLabelPrefab, transform);
property = Instantiate(PropertyLabel, transform);
else
property = Instantiate(PropertyPrefab, transform);
property = Instantiate(Property, transform);
property.Label.text = name;
if (radio)
{
RadioSelection = true;
Buttons.Add(property.Button);
property.Button.OnClick += data =>
{
if (data.button == PointerEventData.InputButton.Left)
{
if (SelectedChild != null)
SelectedChild.CurrentState = FlatButtonState.Unselected;
SelectedChild = property.Button;
SelectedChild.CurrentState = FlatButtonState.Selected;
}
onClick?.Invoke(data);
};
}
else if(onClick!=null) property.Button.OnClick += onClick;
if (read != null)
RefreshPropertyValues += () => ((PropertyLabel) property).Value.text = read.Invoke();
@ -124,7 +107,7 @@ public class PropertiesPanel : MonoBehaviour
public PropertiesList AddList(string name) //, IEnumerable<(string, Func<string>)> elements)
{
var list = Instantiate(ListPrefab, transform);
var list = Instantiate(List, transform);
list.Context = Context;
list.Dropdown = Dropdown;
list.Title.text = name;
@ -144,7 +127,7 @@ public class PropertiesPanel : MonoBehaviour
public AttributeProperty AddPersonalityProperty(PersonalityAttribute attribute, Func<float> read)
{
var attributeInstance = Instantiate(AttributePrefab, transform);
var attributeInstance = Instantiate(Attribute, transform);
attributeInstance.Title.text = attribute.Name;
attributeInstance.HighLabel.text = attribute.HighName;
attributeInstance.LowLabel.text = attribute.LowName;
@ -154,22 +137,22 @@ public class PropertiesPanel : MonoBehaviour
return attributeInstance;
}
public virtual PropertyButton AddButton(string name, Action<PointerEventData> onClick)
public virtual PropertyButton AddButton(string name, Action onClick)
{
var button = Instantiate(PropertyButton, transform);
button.Label.text = name;
button.Button.OnClick += onClick;
button.Button.onClick.AddListener(() => onClick());
Properties.Add(button.gameObject);
OnPropertyAdded?.Invoke(button.gameObject);
return button;
}
public void AddButton(string name, string label, Action<PointerEventData> onClick)
public void AddButton(string name, string label, Action onClick)
{
var button = Instantiate(ButtonField, transform);
button.Label.text = name;
button.ButtonLabel.text = label;
button.Button.OnClick += onClick;
button.Button.onClick.AddListener(() => onClick());
Properties.Add(button.gameObject);
OnPropertyAdded?.Invoke(button.gameObject);
}
@ -243,8 +226,8 @@ public class PropertiesPanel : MonoBehaviour
{
var field = Instantiate(IncrementField, transform);
field.Label.text = name;
field.Increment.OnClick += data => write(read() + 1);
field.Decrement.OnClick += data => write(read() - 1);
field.Increment.onClick.AddListener(() => write(read() + 1));
field.Decrement.onClick.AddListener(() => write(read() - 1));
RefreshPropertyValues += () =>
{
var val = read();
@ -253,8 +236,8 @@ public class PropertiesPanel : MonoBehaviour
if (val < minval || val > maxval)
write(val = clamp(val, minval, maxval));
field.Value.text = val.ToString(CultureInfo.InvariantCulture);
field.Increment.CurrentState = val == maxval ? FlatButtonState.Disabled : FlatButtonState.Unselected;
field.Decrement.CurrentState = val == minval ? FlatButtonState.Disabled : FlatButtonState.Unselected;
field.Increment.interactable = val == maxval;
field.Decrement.interactable = val == minval;
};
Properties.Add(field.gameObject);
OnPropertyAdded?.Invoke(field.gameObject);

View file

@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Property : MonoBehaviour
{
public TextMeshProUGUI Label;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8c0b005aebd0cd947a04034f1a42e838
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,10 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PropertyButton : MonoBehaviour
public class PropertyButton : Property
{
public TextMeshProUGUI Label;
public FlatFlatButton Button;
public Button Button;
}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8c0b005aebd0cd947a04034f1a42e838
guid: 58ab24f16cf869f4d88cd351417103a6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -4,7 +4,7 @@ using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class PropertyLabel : PropertyButton
public class PropertyLabel : Property
{
public TextMeshProUGUI Value;
}