Trade Menu

Implemented Trade Menu
Item Filtering by size, hardpoint, behavior
Buying from trade menu on double click
This commit is contained in:
Reinier Vens 2021-01-14 23:47:08 +00:00
commit f4ee26e96c
22 changed files with 631 additions and 73 deletions

View file

@ -120,10 +120,12 @@ public class ContextMenu : MonoBehaviour
pivot.x = mousePosition.x > Screen.width - rect.sizeDelta.x * canvas.scaleFactor ? 1 : 0;
var scaleFactor = canvas.scaleFactor;
_dropdownRight = mousePosition.x < Screen.width - rect.sizeDelta.x * scaleFactor * 2;
var pivotTop = (Parent==null ? mousePosition.y : ForcePosition.y) > (PaddingHeight + _options.Count * OptionHeight) * scaleFactor;
pivot.y = pivotTop ? 1 : 0;
var pos = Parent==null ? mousePosition.y : ForcePosition.y;
var space = (PaddingHeight + _options.Count * OptionHeight) * scaleFactor;
var deltaY = pos < space ? space - pos : PaddingHeight / 2 * scaleFactor;
pivot.y = 1;//pivotTop ? 1 : 0;
rect.pivot = pivot;
rect.position = Parent!=null ? ForcePosition - (pivotTop ? Vector3.zero : Vector3.up * (OptionHeight * scaleFactor)) : (Vector3)mousePosition;
rect.position = (Parent != null ? ForcePosition : (Vector3) mousePosition) + Vector3.up * deltaY;
if (Parent==null)
CancelClickCatcher.gameObject.SetActive(true);
}

View file

@ -94,10 +94,8 @@ public class InventoryPanel : MonoBehaviour
else ContextMenu.AddOption(ship.Name, () => Display(ship));
}
foreach (var bay in GameManager.AvailableCargoBays())
{
ContextMenu.AddOption(bay.Name, () => Display(bay));
}
if(GameManager.DockingBay!=null)
ContextMenu.AddOption(GameManager.DockingBay.Name, () => Display(GameManager.DockingBay));
ContextMenu.Show();
});

View file

@ -403,6 +403,13 @@ public class PropertiesPanel : MonoBehaviour
AddProperty("Durability", () => gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits));
foreach (var behavior in gearData.Behaviors)
{
if (behavior is StatModifierData statMod)
{
if(Math.Abs(statMod.Modifier.Min - statMod.Modifier.Max) < .001f)
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
else
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}-{statMod.Modifier.Max.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
}
var type = behavior.GetType();
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
{