This commit is contained in:
2024-10-16 00:03:41 +08:00
commit 897058435c
5033 changed files with 1009728 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
namespace IcecreamView
{
public class EventArg
{
private List<object> values;
public EventArg(params object[] values)
{
if (values == null)
{
this.values = null;
return;
}
this.values = new List<object>(values);
}
public T GetValue<T>(int index = 0)
{
if (this.values == null || index >= this.values.Count)
{
return default;
}
return (T)this.values[index];
}
public bool IsNotNull(int index = 0) { return this.values.Count > index && this.values[index] != null; }
public int Count => values.Count;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3730f8fe0134456fb3385744fd4da4d4
timeCreated: 1565254674

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace IcecreamView
{
public class IC_UIEventManager
{
private Dictionary<int, List<Action<EventArg>>> eventDict = new Dictionary<int, List<Action<EventArg>>>();
public void BindEvent(int code , Action<EventArg> eventCallback)
{
if (this.eventDict.ContainsKey(code))
{
if (!this.eventDict[code].Contains(eventCallback))
this.eventDict[code].Add(eventCallback);
}
else
{
this.eventDict[code] = new List<Action<EventArg>>();
this.eventDict[code].Add(eventCallback);
}
}
public void UnBindEvent(int code , Action<EventArg> eventCallback)
{
if (this.eventDict.ContainsKey(code))
{
this.eventDict[code].Remove(eventCallback);
}
}
public void SendEvent(int code , params object[] values)
{
this.SendEvent(code, new EventArg(values));
}
public void SendEvent(int code , EventArg eventArg)
{
if (this.eventDict.ContainsKey(code))
{
for (int i = 0; i < this.eventDict[code].Count; i++)
{
this.eventDict[code][i].Invoke(eventArg);
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8449cc0e1f354e27a86a1168c100e3c7
timeCreated: 1565241933