Hauling Task
Added a control module which enables drones to haul items from colony to colony Added confirmation dialog for actions which require confirmation, can have fields added to it just like a PropertiesPanel Moving items between inventories now displays confirmation dialog
This commit is contained in:
parent
a901a8e829
commit
991d411c91
24 changed files with 1965 additions and 2193 deletions
54
Assets/Scripts/UI/ConfirmationDialog.cs
Normal file
54
Assets/Scripts/UI/ConfirmationDialog.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfirmationDialog : PropertiesPanel
|
||||
{
|
||||
public ClickCatcher CancelClickCatcher;
|
||||
public FlatButton Cancel;
|
||||
public FlatButton Confirm;
|
||||
|
||||
private Action _onCancel;
|
||||
private Action _onConfirm;
|
||||
|
||||
private new void Start()
|
||||
{
|
||||
Cancel.OnClick += () =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
End();
|
||||
};
|
||||
Confirm.OnClick += () =>
|
||||
{
|
||||
_onConfirm?.Invoke();
|
||||
End();
|
||||
};
|
||||
if (CancelClickCatcher != null)
|
||||
CancelClickCatcher.OnClick += data =>
|
||||
{
|
||||
_onCancel?.Invoke();
|
||||
End();
|
||||
};
|
||||
|
||||
OnPropertyAdded += go =>
|
||||
{
|
||||
go.SetActive(true);
|
||||
go.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + 1);
|
||||
};
|
||||
}
|
||||
|
||||
private void End()
|
||||
{
|
||||
CancelClickCatcher.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void Show(Action onConfirm, Action onCancel = null)
|
||||
{
|
||||
_onConfirm = onConfirm;
|
||||
_onCancel = onCancel;
|
||||
transform.position = Input.mousePosition;
|
||||
CancelClickCatcher.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue