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
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|