Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions JM/CF/Defines/CFDefines.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#define CF_GHOSTICONS

#define CF_DebugUI

#ifdef CF_MODULE_LAYOUT_BINDING
#define CF_MODEL_VIEW_BINDING
#endif
34 changes: 34 additions & 0 deletions JM/CF/GUI/layouts/DebugUI_Block.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
WrapSpacerWidgetClass BlockSpacer {
ignorepointer 1
position 0 0
size 500 1
hexactpos 0
vexactpos 0
hexactsize 1
vexactsize 0
Padding 0
Margin 0
"Size To Content H" 1
{
MultilineTextWidgetClass TextField {
ignorepointer 1
position 0 0
size 1 1
hexactpos 0
vexactpos 0
hexactsize 0
vexactsize 0
scriptclass "ViewBinding"
text "AAA"
font "gui/fonts/system"
"exact text" 1
"size to text h" 1
"size to text v" 1
{
ScriptParamsClass {
Binding_Name "TextField"
}
}
}
}
}
13 changes: 13 additions & 0 deletions JM/CF/GUI/layouts/DebugUI_Container.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
WrapSpacerWidgetClass DebugUI_Container {
ignorepointer 1
position 0 0
size 1 1
hexactpos 0
vexactpos 0
hexactsize 0
vexactsize 0
Padding 0
Margin 0
{
}
}
5 changes: 5 additions & 0 deletions JM/CF/Scripts/3_Game/CommunityFramework/CommunityFramework.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CommunityFramework
{
static CF_ObjectManager ObjectManager;
static CF_XML XML;
static ref CF_DebugUI DebugUI;

#ifdef CF_MODULE_PERMISSIONS
static ref CF_Permission_ManagerBase Permission;
Expand All @@ -42,6 +43,8 @@ class CommunityFramework
#ifdef CF_MODULE_PERMISSIONS
CF_Permission_ManagerBase._Init( Permission );
#endif

DebugUI = new CF_DebugUI();
}

/**
Expand All @@ -51,6 +54,8 @@ class CommunityFramework
*/
static void _Cleanup()
{
delete DebugUI;

ObjectManager._Cleanup();
XML._Cleanup();

Expand Down
28 changes: 28 additions & 0 deletions JM/CF/Scripts/3_Game/CommunityFramework/DebugUI/CF_DebugUI.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class CF_DebugUI
{
CF_DebugUI_Type Types;

private ref set<Class> m_Classes = new set<Class>();

void Show(Class cls)
{
m_Classes.Insert(cls);
}

void Hide(Class cls)
{
int idx = m_Classes.Find(cls);
if (idx != -1) m_Classes.Remove(idx);
}

void Update(inout array<ref CF_DebugUI_Instance> instances)
{
instances.Clear();
for (int i = 0; i < m_Classes.Count(); i++)
{
CF_DebugUI_Instance instance = new CF_DebugUI_Instance();
instance.Add(m_Classes[i]);
instances.Insert(instance);
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class CF_DebugUI_Instance
{
private string m_Data = "";
private int m_TabDepth = -1;

private string Tab()
{
string tab = "";
for (int i = 0; i < m_TabDepth; i++) tab += " ";
return tab;
}

private string NewLine()
{
return "\n" + Tab();
}

/**
* @brief Adds the value to the string. Formatted as "value"
*/
void Add(string value)
{
m_Data += NewLine() + value;
}

/**
* @brief Adds the name and value to the string. Formatted as "name: value"
*/
void Add(string name, int value)
{
m_Data += NewLine() + name + ": " + value;
}

/**
* @brief Adds the name and value to the string. Formatted as "name: value"
*/
void Add(string name, bool value)
{
m_Data += NewLine() + name + ": " + value;
}

/**
* @brief Adds the name and value to the string. Formatted as "name: value"
*/
void Add(string name, float value)
{
m_Data += NewLine() + name + ": " + value;
}

/**
* @brief Adds the name and value to the string. Formatted as "name: value"
*/
void Add(string name, string value)
{
m_Data += NewLine() + name + ": " + value;
}

/**
* @brief Calls the 'CF_DebugUI' method for the target Class
*/
void Add(Class value)
{
m_TabDepth++;
GetGame().GameScript.CallFunctionParams(value, "CF_DebugUI", null, new Param2<CF_DebugUI_Instance, CF_DebugUI_Type>(this, CF.DebugUI.Types));
m_TabDepth--;
}

/**
* @brief Converts the 'Object' to a string, adds it to the string. Formatted as "name: object (network id)"
*/
void AddObject(string name, Object value)
{
string _value = "" + value;
if (value) _value += "(" + value.GetNetworkIDString() + ")";
Add(name, _value);
}
};
27 changes: 27 additions & 0 deletions JM/CF/Scripts/3_Game/CommunityFramework/DebugUI/CF_DebugUI_Type.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class CF_DebugUI_Type
{
private ref map<string, bool> m_Types = new map<string, bool>();

void Register(string type, bool enabled = false)
{
Set(type, enabled);
}

void Set(string type, bool enabled)
{
if (m_Types.Contains(type))
{
m_Types[type] = enabled;
return;
}

m_Types.Insert(type, enabled);
}

bool Get(string type)
{
if (!m_Types.Contains(type)) return false;

return m_Types[type];
}
};
1 change: 1 addition & 0 deletions JM/CF/Scripts/3_Game/CommunityFramework/MVC/MVC.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class LayoutBindingManager
widget_controllers.Insert(SliderWidget, SliderWidgetController);
widget_controllers.Insert(ProgressBarWidget, ProgressBarController);
widget_controllers.Insert(TextWidget, TextWidgetController);
widget_controllers.Insert(MultilineTextWidget, TextWidgetController);
widget_controllers.Insert(MultilineEditBoxWidget, MultilineEditBoxWidgetController);
widget_controllers.Insert(XComboBoxWidget, XComboBoxWidgetController);
widget_controllers.Insert(ImageWidget, ImageWidgetController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ class ObservableCollection<Class TValue> : Observable
_data.Remove(index);
}

void RemoveRange(int start, int end)
{
for (int i = start; i < end; i++)
{
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, start, new Param1<TValue>(_data.Get(start))));
_data.RemoveOrdered(start);
}
}

void Remove(TValue value)
{
int index = _data.Find(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,108 @@
class ObservableDictionary<Class TKey, Class TValue> : Observable
{
private ref map<TKey, TValue> _data = new map<TKey, TValue>();
private ref map<TKey, ref TValue> _data = new map<TKey, ref TValue>();
private ref array<TValue> _dataArray = {};

bool Insert(TKey key, TValue value)
void ObservableDictionary(Controller controller)
{
m_Type = TemplateType<TValue>.GetType();
}

void ~ObservableDictionary()
{
delete _data;
delete _dataArray;
}

int Insert(TKey key, TValue value)
{
if (_data.Insert(key, value))
{
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Add, new Param2<TKey, TValue>(key, value)));
return true;
int index = _dataArray.Insert(value);
if (index == -1)
{
Error("Inserted into map but failed to insert into array so FML.");
return -1;
}

CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Insert, index, new Param1<TValue>(value)));
return index;
}

return false;
return -1;
}

void Remove(TKey key)
{
if (_data.Contains(key))
{
TValue value = _data.Get(key);

int remove_index = _dataArray.Find(value);
if (remove_index >= 0) _dataArray.RemoveOrdered(remove_index);

CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, remove_index, new Param1<TValue>(value)));

_data.Remove(key);
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, new Param2<TKey, TValue>(key, value)));
}
}

void Remove(int index)
{
TValue value = _dataArray.Get(index);
_dataArray.Remove(index);

CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, index, new Param1<TValue>(value)));

_data.Remove(_data.GetKeyByValue(value));
}

void RemoveRange(int start, int end)
{
for (int i = start; i < end; i++)
{
int index = start;

TValue value = _dataArray.Get(index);
_dataArray.Remove(index);

CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, index, new Param1<TValue>(value)));

_data.Remove(_data.GetKeyByValue(value));
}
}

void Clear()
{
_data.Clear();
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Clear, null));
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Clear, -1, null));
}

void Set(TKey key, TValue value)
{
int remove_index = -1;

if (_data.Contains(key))
{
remove_index = _dataArray.Find(_data.Get(key));
if (remove_index >= 0) _dataArray.Set(remove_index, value);
}

_data.Set(key, value);
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Set, new Param2<TKey, TValue>(key, value)));
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Replace, remove_index, new Param1<TValue>(value)));
}

int MoveIndex(int index, int moveIndex)
{
if (moveIndex == index)
return index;

TValue value = _dataArray.Get(index);
int new_index = _dataArray.MoveIndex(index, moveIndex);
if (new_index != index)
CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Move, new_index, new Param1<TValue>(value)));

return new_index;
}

TValue Get(TKey key)
Expand All @@ -45,13 +115,13 @@ class ObservableDictionary<Class TKey, Class TValue> : Observable
return _data.GetKey(index);
}

override int Count()
bool Contains(TKey key)
{
return _data.Count();
return _data.Contains(key);
}

override typename GetType()
override int Count()
{
return TValue;
return _data.Count();
}
};
Loading