| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | public class ActionListview : ListView<BuildInWorldCompleteAction> |
| | 6 | | { |
| | 7 | | public ActionAdapter adapter; |
| | 8 | |
|
| | 9 | | public System.Action<BuildInWorldCompleteAction> OnActionSelected; |
| | 10 | |
|
| 0 | 11 | | List<ActionAdapter> actionList = new List<ActionAdapter>(); |
| | 12 | | public override void AddAdapters() |
| | 13 | | { |
| 0 | 14 | | base.AddAdapters(); |
| | 15 | |
|
| 0 | 16 | | foreach (BuildInWorldCompleteAction action in contentList) |
| | 17 | | { |
| 0 | 18 | | CreateAdapter(action); |
| | 19 | | } |
| 0 | 20 | | } |
| | 21 | |
|
| 0 | 22 | | public void ActionSelected(BuildInWorldCompleteAction action, ActionAdapter adapter) { OnActionSelected?.Invoke(acti |
| | 23 | |
|
| | 24 | | public override void RemoveAdapters() |
| | 25 | | { |
| 0 | 26 | | base.RemoveAdapters(); |
| 0 | 27 | | actionList.Clear(); |
| 0 | 28 | | } |
| | 29 | |
|
| | 30 | | public void AddAdapter(BuildInWorldCompleteAction action) |
| | 31 | | { |
| 0 | 32 | | if (contentList == null) |
| 0 | 33 | | contentList = new List<BuildInWorldCompleteAction>(); |
| 0 | 34 | | contentList.Add(action); |
| 0 | 35 | | CreateAdapter(action); |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public void RefreshInfo() |
| | 39 | | { |
| 0 | 40 | | foreach (ActionAdapter adapter in actionList) |
| | 41 | | { |
| 0 | 42 | | adapter.RefreshIsDone(); |
| | 43 | | } |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | void CreateAdapter(BuildInWorldCompleteAction action) |
| | 47 | | { |
| 0 | 48 | | ActionAdapter instanciatedAdapter = Instantiate(adapter, contentPanelTransform).GetComponent<ActionAdapter>(); |
| 0 | 49 | | instanciatedAdapter.SetContent(action); |
| 0 | 50 | | instanciatedAdapter.OnActionSelected += ActionSelected; |
| 0 | 51 | | actionList.Add(instanciatedAdapter); |
| 0 | 52 | | } |
| | 53 | | } |