Various Fixes

Newly created drones now register their origin colony correctly
Hauling behavior fixed for multiple items
Buttons can't be dragged unless explicitly enabled
Inspecting a colony with lots of compound commodities no longer sets your computer on fire
This commit is contained in:
hyperion51 2020-07-03 01:33:42 +01:00
commit 1e2b474fc1
11 changed files with 133 additions and 47 deletions

View file

@ -88,7 +88,7 @@ public class ColonyTab : MonoBehaviour
foreach (var attribute in entity.Personality.Keys)
personalityList.AddPersonalityProperty(Context.Cache.Get<PersonalityAttribute>(attribute),
() => entity.Personality[attribute]);
personalityList.SetExpanded(false, true);
// personalityList.SetExpanded(false, true);
var childList = General.AddList("Children");
childList.InspectChildren(entity, child =>
@ -96,7 +96,7 @@ public class ColonyTab : MonoBehaviour
_selectedChild = child;
UpdateInventory(child, ChildInventory);
});
childList.SetExpanded(false, true);
// childList.SetExpanded(false, true);
General.RefreshValues();
}
@ -357,7 +357,7 @@ public class ColonyTab : MonoBehaviour
{
entity.RemoveCargo(gear);
var ship = Context.CreateShip(gear.ID, Enumerable.Empty<Guid>(),
Enumerable.Empty<Guid>(), entity.Zone, entity.Corporation, gear.Name);
Enumerable.Empty<Guid>(), entity.Zone, entity.Corporation, _parentEntity.ID, gear.Name);
_context.SetParent(ship, entity);
}
else // Equip Item
@ -412,7 +412,7 @@ public class ColonyTab : MonoBehaviour
button.DisableClickWhenSelected = false;
button.DragSuccess = data => dragSuccess(data, item);
}
instanceList.SetExpanded(false, true);
// instanceList.SetExpanded(false, true);
}
}
}
@ -443,7 +443,7 @@ public class ColonyTab : MonoBehaviour
});
blueprintList.RefreshValues();
blueprintList.SetExpanded(false, true);
// blueprintList.SetExpanded(false, true);
}
Details.RefreshValues();
}

View file

@ -56,7 +56,11 @@ public class FlatFlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitH
public void OnBeginDrag(PointerEventData eventData)
{
if (DragSuccess == null || DragObject == null) return;
if (DragSuccess == null || DragObject == null)
{
eventData.pointerDrag = null;
return;
}
var canvas = gameObject.FindInParents<Canvas>();
if (canvas == null)

View file

@ -14,12 +14,15 @@ public class PropertiesList : PropertiesPanel
public VerticalLayoutGroup LayoutGroup;
public int FoldedPadding = -8;
public int ExpandedPadding = 8;
public event Action<bool> OnExpand;
private bool _expanded = false;
private float _targetFoldoutRotation = 0;
private float _foldoutRotation = 0;
public void Start()
public bool Expanded => _expanded;
public new void Awake()
{
Button.OnClick += _ => ToggleExpand();
OnPropertyAdded += go => go.SetActive(_expanded);
@ -49,6 +52,7 @@ public class PropertiesList : PropertiesPanel
_foldoutRotation = _targetFoldoutRotation;
FoldoutIcon.transform.localRotation = Quaternion.Euler(0,0, _foldoutRotation);
}
OnExpand?.Invoke(_expanded);
}
// public override PropertyLabel AddProperty(string name, Func<string> read = null, Action<PointerEventData> onClick = null, bool radio = false)

View file

@ -40,8 +40,10 @@ public class PropertiesPanel : MonoBehaviour
protected event Action<GameObject> OnPropertyAdded;
protected IChangeSource ChangeSource;
protected Action OnPropertiesChanged;
public int Children => Properties.Count + Buttons.Count;
public void Start()
public void Awake()
{
OnPropertyAdded += go => go.SetActive(true);
}
@ -357,11 +359,11 @@ public class PropertiesPanel : MonoBehaviour
var hardpointList = AddList("Gear");
hardpointList.InspectHardpoints(entity);
hardpointList.SetExpanded(false,true);
//hardpointList.SetExpanded(false,true);
var cargoList = AddList("Cargo");
cargoList.InspectCargo(entity);
cargoList.SetExpanded(false,true);
//cargoList.SetExpanded(false,true);
RefreshValues();
}
@ -373,7 +375,18 @@ public class PropertiesPanel : MonoBehaviour
ChangeSource = entity.GearEvent;
OnPropertiesChanged = InspectGearInternal;
ChangeSource.OnChanged += OnPropertiesChanged;
InspectGearInternal();
if (this is PropertiesList list)
{
if (list.Expanded)
InspectGearInternal();
else
list.OnExpand += b =>
{
if (b) InspectGearInternal();
};
}
else
InspectGearInternal();
void InspectGearInternal()
{
@ -383,7 +396,7 @@ public class PropertiesPanel : MonoBehaviour
{
var propertyList = AddList(hardpoint.Gear.Name);
propertyList.Inspect(entity, hardpoint);
propertyList.SetExpanded(false,true);
//propertyList.SetExpanded(false,true);
}
RefreshValues();
}
@ -396,7 +409,18 @@ public class PropertiesPanel : MonoBehaviour
ChangeSource = entity.CargoEvent;
OnPropertiesChanged = InspectCargoInternal;
ChangeSource.OnChanged += OnPropertiesChanged;
InspectCargoInternal();
if (this is PropertiesList list)
{
if (list.Expanded)
InspectCargoInternal();
else
list.OnExpand += b =>
{
if (b) InspectCargoInternal();
};
}
else
InspectCargoInternal();
void InspectCargoInternal()
{
@ -408,7 +432,7 @@ public class PropertiesPanel : MonoBehaviour
var propertiesList = AddList($"{simpleCommodity.Quantity.ToString()} {data.Name}");
propertiesList.AddItemProperties(entity, simpleCommodity);
propertiesList.RefreshValues();
propertiesList.SetExpanded(false, true);
//propertiesList.SetExpanded(false, true);
}
foreach (var group in entity.Cargo
@ -429,19 +453,21 @@ public class PropertiesPanel : MonoBehaviour
var propertiesList = AddList(item.Name);
propertiesList.AddItemProperties(entity, item);
propertiesList.RefreshValues();
propertiesList.SetExpanded(false, true);
//propertiesList.SetExpanded(false, true);
}
else
{
var instanceList = AddList($"{group.Count().ToString()} {group.Key.Name}");
foreach (var item in group)
instanceList.OnExpand += b =>
{
var propertiesList = instanceList.AddList(item.Name);
propertiesList.AddItemProperties(entity, item);
propertiesList.RefreshValues();
propertiesList.SetExpanded(false, true);
}
instanceList.SetExpanded(false, true);
if (!b || instanceList.Children > 0) return;
foreach (var item in group)
{
var propertiesList = instanceList.AddList(item.Name);
propertiesList.AddItemProperties(entity, item);
propertiesList.RefreshValues();
}
};
}
}
@ -527,7 +553,6 @@ public class PropertiesPanel : MonoBehaviour
AddProperty(childEntity.Name, null, data => onSelect(childEntity), true);
}
}
}
public void Inspect(Entity entity, Hardpoint hardpoint)
@ -539,7 +564,18 @@ public class PropertiesPanel : MonoBehaviour
return;
OnPropertiesChanged = InspectGearInternal;
ChangeSource.OnChanged += OnPropertiesChanged;
InspectGearInternal();
if (this is PropertiesList list)
{
if (list.Expanded)
InspectGearInternal();
else
list.OnExpand += b =>
{
if (b) InspectGearInternal();
};
}
else
InspectGearInternal();
void InspectGearInternal()
{
@ -598,7 +634,7 @@ public class PropertiesPanel : MonoBehaviour
var itemData = Context.Cache.Get<ItemData>(ingredient.Key);
ingredientsList.AddProperty(itemData.Name, () => ingredient.Value.ToString());
}
ingredientsList.SetExpanded(false, true);
// ingredientsList.SetExpanded(false, true);
ingredientsList.RefreshValues();
}
}