diff --git a/JM/CF/Defines/CFDefines.c b/JM/CF/Defines/CFDefines.c index cd2eefe9..b7b04210 100644 --- a/JM/CF/Defines/CFDefines.c +++ b/JM/CF/Defines/CFDefines.c @@ -1,9 +1,4 @@ -#define CF_MODULE_LAYOUT_BINDING #define CF_MODULE_CONFIG //#define CF_MODULE_PERMISSIONS -#define CF_GHOSTICONS - -#ifdef CF_MODULE_LAYOUT_BINDING -#define CF_MODEL_VIEW_BINDING -#endif +#define CF_GHOSTICONS \ No newline at end of file diff --git a/JM/CF/GUI/layouts/sample_mvc.layout b/JM/CF/GUI/layouts/sample_mvc.layout deleted file mode 100644 index 5602d6b6..00000000 --- a/JM/CF/GUI/layouts/sample_mvc.layout +++ /dev/null @@ -1,688 +0,0 @@ -FrameWidgetClass root { - position 0 0 - size 0.6 0.7 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - draggable 0 - scriptclass "SampleController" - { - WrapSpacerWidgetClass root_spacer { - ignorepointer 1 - color 0.3843 0.3843 0.3843 1 - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - style OutlineFilled - Padding 5 - Margin 5 - "Size To Content H" 1 - content_halign center - { - SliderWidgetClass slider { - position 0 0 - size 1 0.05 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - { - TextWidgetClass slider_text { - ignorepointer 1 - size 0.1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - "text halign" center - "text valign" center - { - ScriptParamsClass { - Debug_Logging 1 - Binding_Name "slider_value" - } - } - } - } - { - ScriptParamsClass { - Debug_Logging 1 - Binding_Name "slider_value" - Two_Way_Binding 1 - } - } - } - ProgressBarWidgetClass progress_bar { - ignorepointer 1 - size 1 0.05 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - { - ScriptParamsClass { - Binding_Name "progress_value" - } - } - } - WrapSpacerWidgetClass sub_controlled_root { - clipchildren 1 - ignorepointer 1 - position 0 0 - size 1 0 - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "SampleSubController" - Padding 20 - Margin 5 - "Size To Content V" 1 - content_halign center - content_valign center - { - ButtonWidgetClass sample_class_button { - position 0 0 - size 50 50 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - text "+" - font "gui/fonts/Metron-Bold58" - { - ScriptParamsClass { - Relay_Command "SampleClassButtonExecute" - } - } - } - TextWidgetClass sample_class_value { - ignorepointer 1 - position 0 0 - size 150 50 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - "text halign" center - "text valign" center - { - ScriptParamsClass { - Debug_Logging 1 - Binding_Name "m_SampleControllerClass.value" - Two_Way_Binding 0 - } - } - } - ButtonWidgetClass button { - visible 1 - size 150 50 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - style Colorable - "no focus" 1 - switch toggle - { - TextWidgetClass button_text { - ignorepointer 1 - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - "text halign" center - "text valign" center - { - ScriptParamsClass { - Binding_Name "button_state" - } - } - } - } - { - ScriptParamsClass { - Binding_Name "button_state" - Two_Way_Binding 1 - } - } - } - XComboBoxWidgetClass combo_box { - clipchildren 1 - position 0 0 - size 250 50 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - { - ScriptParamsClass { - Debug_Logging 1 - Binding_Name "observable_combo_box" - Selected_Item "observable_combo_selection" - Two_Way_Binding 0 - } - } - } - CheckBoxWidgetClass check_box { - clipchildren 0 - position 0 0 - size 50 50 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - text "Test" - font "gui/fonts/Metron28" - checked 0 - { - ScriptParamsClass { - Binding_Name "inverted_button_state" - Selected_Item "inverted_button_state" - Two_Way_Binding 1 - } - } - } - } - } - PanelWidgetClass text_list_buttons { - ignorepointer 1 - position 0 0 - size 1 0.1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - { - PanelWidgetClass text_list_swap_panel { - ignorepointer 1 - position 0.35 0 - size 0.2 1 - valign center_ref - hexactpos 0 - vexactpos 0 - hexactsize 0 - vexactsize 0 - style blank - { - WrapSpacerWidgetClass text_list_swap_spacer { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - Padding 5 - Margin 0 - content_halign center - content_valign bottom - { - PanelWidgetClass counter_frame_0 { - visible 1 - ignorepointer 1 - position 0 0 - size 0.11 1 - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - style rover_sim_black_2 - { - GridSpacerWidgetClass counter_0 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - Padding 0 - Margin 0 - Columns 1 - { - ButtonWidgetClass counter_increment_0 { - visible 1 - position 0 0 - size 1 1 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - style Default - { - ImageWidgetClass counter_increment_icon_0 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scaled 1 - image0 "set:dayz_gui image:icon_minus" - mode blend - "src alpha" 1 - "no wrap" 0 - stretch 0 - "flip u" 0 - "flip v" 0 - filter 0 - nocache 0 - } - } - { - ScriptParamsClass { - Relay_Command "LeftCounterIncrementExecute" - } - } - } - TextWidgetClass counter_value_0 { - ignorepointer 1 - position 10 10 - size 48 48 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - "text halign" center - "text valign" center - { - ScriptParamsClass { - Binding_Name "counter_left_value" - } - } - } - ButtonWidgetClass counter_decrement_0 { - visible 1 - position 0 0 - size 1 1 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - style Default - { - ImageWidgetClass counter_increment_icon_1 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scaled 1 - image0 "set:dayz_gui image:icon_minus" - mode blend - "src alpha" 1 - "no wrap" 0 - stretch 0 - "flip u" 0 - "flip v" 1 - filter 0 - nocache 0 - } - } - { - ScriptParamsClass { - Relay_Command "LeftCounterDecrementExecute" - } - } - } - } - } - } - } - PanelWidgetClass text_list_swap_button_panel { - ignorepointer 1 - position 0 0 - size 0.65 1 - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - { - PanelWidgetClass text_list_swap_button_frame { - ignorepointer 1 - size 150 0.5 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 0 - style rover_sim_black_2 - { - ButtonWidgetClass text_list_swap { - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - style Default - { - WrapSpacerWidgetClass text_list_swap_content { - ignorepointer 1 - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - content_halign center - content_valign center - { - ImageWidgetClass text_list_swap_icon { - ignorepointer 1 - size 25 25 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - image0 "set:dayz_gui image:icon_refresh" - mode blend - "src alpha" 1 - } - TextWidgetClass text_list_swap_text { - ignorepointer 1 - position 0 0 - size 0 25 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - text "Swap Items" - "exact text" 0 - "size to text h" 1 - "text halign" center - "text valign" center - } - } - } - } - { - ScriptParamsClass { - Relay_Command "SwapItemsExecute" - } - } - } - } - } - } - } - PanelWidgetClass counter_frame_1 { - ignorepointer 1 - position 0 0 - size 0.11 1 - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - style rover_sim_black_2 - { - GridSpacerWidgetClass counter_1 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - style Empty - Padding 0 - Margin 0 - Columns 1 - { - ButtonWidgetClass counter_increment_1 { - visible 1 - position 0 0 - size 1 1 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - style Default - { - ImageWidgetClass counter_increment_icon_2 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scaled 1 - image0 "set:dayz_gui image:icon_minus" - mode blend - "src alpha" 1 - "no wrap" 0 - stretch 0 - "flip u" 0 - "flip v" 0 - filter 0 - nocache 0 - } - } - { - ScriptParamsClass { - Relay_Command "RightCounterIncrementExecute" - } - } - } - TextWidgetClass counter_value_1 { - ignorepointer 1 - position 10 10 - size 48 48 - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - scriptclass "ViewBinding" - "text halign" center - "text valign" center - { - ScriptParamsClass { - Binding_Name "counter_right_value" - } - } - } - ButtonWidgetClass counter_decrement_1 { - visible 1 - position 0 0 - size 1 1 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - style Default - { - ImageWidgetClass counter_increment_icon_3 { - ignorepointer 1 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scaled 1 - image0 "set:dayz_gui image:icon_minus" - mode blend - "src alpha" 1 - "no wrap" 0 - stretch 0 - "flip u" 0 - "flip v" 1 - filter 0 - nocache 0 - } - } - { - ScriptParamsClass { - Relay_Command "RightCounterDecrementExecute" - } - } - } - } - } - } - } - } - } - } - } - PanelWidgetClass text_list_add_panel { - ignorepointer 1 - position 0.1 0 - size 150 0.5 - valign center_ref - hexactpos 0 - vexactpos 1 - hexactsize 1 - vexactsize 0 - style rover_sim_black_2 - { - ButtonWidgetClass text_list_add { - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - { - WrapSpacerWidgetClass text_list_add_content { - ignorepointer 1 - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - Padding 5 - Margin 0 - content_halign center - content_valign center - { - ImageWidgetClass text_list_add_icon { - ignorepointer 1 - position 0 0 - size 25 25 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - image0 "set:dayz_gui image:iconHealth0" - mode blend - "src alpha" 1 - } - TextWidgetClass text_list_add_text { - visible 1 - ignorepointer 1 - size 120 25 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 1 - vexactsize 1 - text "Add Item" - "size to text h" 1 - "size to text v" 0 - "text halign" center - "text valign" center - } - } - } - } - } - } - } - } - } - TextListboxWidgetClass text_list_box { - ignorepointer 1 - position 0 0 - size 1 0.6 - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - colums "1" - font "gui/fonts/Metron28" - { - ScriptParamsClass { - Debug_Logging 0 - Binding_Name "observable_list_box" - Two_Way_Binding 0 - } - } - } - } - } - } - { - ScriptParamsClass { - Debug_Logging 1 - } - } -} \ No newline at end of file diff --git a/JM/CF/GUI/layouts/sample_mvc2.layout b/JM/CF/GUI/layouts/sample_mvc2.layout deleted file mode 100644 index 234fc9ad..00000000 --- a/JM/CF/GUI/layouts/sample_mvc2.layout +++ /dev/null @@ -1,88 +0,0 @@ -FrameWidgetClass root { - position 0 0 - size 0.5 0.5 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "SampleScriptViewController" - { - WrapSpacerWidgetClass root_spacer { - ignorepointer 1 - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - Padding 0 - Margin 0 - content_halign center - { - PanelWidgetClass button_back { - ignorepointer 1 - color 0.502 0 0.3765 1 - position 0 0 - size 0.26 0.09 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - style rover_sim_colorable - { - ButtonWidgetClass button { - position 0 0 - size 1 1 - halign center_ref - valign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - "no focus" 1 - text "Toggle" - font "gui/fonts/Metron-Bold28" - switch toggle - { - ScriptParamsClass { - Debug_Logging 0 - Relay_Command "SampleRelayCommand" - } - } - } - } - } - WrapSpacerWidgetClass content_host { - ignorepointer 1 - position 0 0 - size 1 1 - halign center_ref - hexactpos 1 - vexactpos 1 - hexactsize 0 - vexactsize 0 - scriptclass "ViewBinding" - content_halign center - { - ScriptParamsClass { - Debug_Logging 1 - Binding_Name "script_view" - } - } - } - } - } - } - { - ScriptParamsClass { - Debug_Logging 1 - } - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/1_Core/CommunityFramework/cf_mvc.c b/JM/CF/Scripts/1_Core/CommunityFramework/cf_mvc.c deleted file mode 100644 index 09753ae8..00000000 --- a/JM/CF/Scripts/1_Core/CommunityFramework/cf_mvc.c +++ /dev/null @@ -1 +0,0 @@ -static LogLevel LBMLogLevel; \ No newline at end of file diff --git a/JM/CF/Scripts/1_Core/CommunityFramework/cf_types.c b/JM/CF/Scripts/1_Core/CommunityFramework/cf_types.c deleted file mode 100644 index a68a246b..00000000 --- a/JM/CF/Scripts/1_Core/CommunityFramework/cf_types.c +++ /dev/null @@ -1,9 +0,0 @@ -// Enum for LogLevel. Utility for plugins and loggers -enum LogLevel { - TRACE, // Logs at beginning of each method - DEBUG, // Debug info within conditionals etc... - INFO, // Helpful info within conditionals etc... (likely more user friendly) - WARNING, // Warnings back to the user. unlikely to be mission critical - ERROR, // Fatal errors. Mission critical - NONE -}; diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Controller.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Controller.c deleted file mode 100644 index c32192fa..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Controller.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - -Controller Class Example: - -class TestController: Controller -{ - // "TextBox1" goes into Binding_Name - string TextBox1 = "TextBox1Text"; - - // "TextBox2" goes into Binding_Name - int TextBox2; - - // "WindowButton1" goes into Binding_Name - bool WindowButton1; - - - // If WindowButton1 is bound to a button, - // call this function and it will - // set the state of the button on your UI - void SetWindowButton1(bool state) - { - WindowButton1 = state; - NotifyPropertyChanged("WindowButton1"); - } - - // Gets called whenever a property was changed in the controller - override void PropertyChanged(string propertyName) - { - switch (propertyName) - { - case "WindowButton1": { - Print("WindowButton1 " + WindowButton1); - break; - } - } - } -} -*/ - -// Abstract Class -class Controller : ScriptedViewBase -{ - // All View Bindings - [NonSerialized()] - protected autoptr ViewBindingHashMap m_ViewBindingHashMap = new ViewBindingHashMap(); - ViewBindingHashMap GetViewBindings() - { - return m_ViewBindingHashMap; - } - - ViewBinding GetViewBinding(Widget source) - { - return m_ViewBindingHashMap[source]; - } - - // View Bindings indexed by their Binding_Name - [NonSerialized()] - protected autoptr DataBindingHashMap m_DataBindingHashMap = new DataBindingHashMap(); - DataBindingHashMap GetDataBindings() - { - return m_DataBindingHashMap; - } - - // Hashmap of all properties in the Controller - [NonSerialized()] - protected autoptr PropertyTypeHashMap m_PropertyTypeHashMap = PropertyTypeHashMap.FromType(Type()); - typename GetPropertyType(string property_name) - { - return m_PropertyTypeHashMap[property_name]; - } - - override void OnWidgetScriptInit(Widget w) - { - super.OnWidgetScriptInit(w); - - //m_PropertyTypeHashMap.RemoveType(Controller); crashing? - - // Load all child Widgets and obtain their DataBinding class - int binding_count = LoadDataBindings(m_LayoutRoot); - Log("%1: %2 DataBindings found!", m_LayoutRoot.GetName(), binding_count.ToString()); - } - - /* - * Example: - * NotifyPropertyChanged("slider_value"); - * - * Call this when you update a Controller property (variable) - * Do NOT call this when using arrays / collections. Use ObservableCollection! - * - * Calling this with No Parameters will update ALL properties in the Controller. - * This is NOT recommended because it is VERY resource intensive - * - */ - - void NotifyPropertyChanged(string property_name = "", bool notify_controller = true) - { - // Did you know that when the compiler checks for ambiguous types, it uses string.Contains() - // instead of string.Match()? PropertyChanged and NotifyPropertyChanged need to be distinct or - // the whole damn thing breaks. Thanks BI - Trace("NotifyPropertyChanged %1", property_name); - - if (property_name == string.Empty) - { - Log("Updating all properties in View, this is NOT recommended as it is performance intensive"); - foreach (ViewBindingArray viewArray : m_DataBindingHashMap) - { - foreach (ViewBinding viewBinding : viewArray) - { - Trace("NotifyPropertyChanged %1", viewBinding.Binding_Name); - viewBinding.UpdateView(this); - if (notify_controller) - { - PropertyChanged(viewBinding.Binding_Name); - } - } - } - - return; - } - - ViewBindingArray views = m_DataBindingHashMap[property_name]; - if (views) - { - foreach (ViewBinding view : views) - { - view.UpdateView(this); - } - } - - if (notify_controller) - { - PropertyChanged(property_name); - } - } - - // Do NOT call this. ObservableCollection does this for you - void NotifyCollectionChanged(CollectionChangedEventArgs args) - { - Trace("NotifyCollectionChanged %1", args.Source.ToString()); - - string collection_name = GetVariableName(args.Source); - if (collection_name == string.Empty) - { - Error("NotifyCollectionChanged could not find variable %1 in %2", args.Source.ToString(), string.ToString(this)); - return; - } - - ViewBindingArray views = m_DataBindingHashMap[collection_name]; - - if (views) - { - foreach (ViewBinding view : views) - { - view.UpdateViewFromCollection(args); - } - } - - CollectionChanged(collection_name, args); - } - - // Gets called every time a property is changed. - // Override this when you want to have an event AFTER property is changed - void PropertyChanged(string property_name); - - // Gets called every time an observable collection is changed. - // Override this when you want to have an event AFTER collection is changed - void CollectionChanged(string collection_name, CollectionChangedEventArgs args); - - private int LoadDataBindings(Widget w) - { - ScriptedViewBase viewBase; - w.GetScript(viewBase); - - // If we find a ViewBinding - if (viewBase && viewBase.IsInherited(ViewBinding)) - { - ViewBinding viewBinding = ViewBinding.Cast(viewBase); - viewBinding.SetParent(this); - m_ViewBindingHashMap.Insert(w, viewBinding); - m_DataBindingHashMap.InsertView(viewBinding); - - viewBinding.SetProperties(GetControllerProperty(viewBinding.Binding_Name), GetControllerProperty(viewBinding.Selected_Item)); - - // todo find a way to define these on ScriptView aswell - // Load RelayCommand - if (viewBinding.Relay_Command != string.Empty) - { - - RelayCommand relayCommand = LoadRelayCommand(viewBinding); - // Success! One of the two options were found - if (relayCommand) - { - Log("%2: RelayCommand %1 succesfully acquired. Assigning...", viewBinding.Relay_Command, viewBinding.GetLayoutRoot().GetName()); - relayCommand.SetController(this); - viewBinding.SetRelayCommand(relayCommand); - } else // Must be a function on the controller - { - Log("%2: RelayCommand %1 not found - Assuming its a function on the Controller / ScriptView!", viewBinding.Relay_Command, viewBinding.GetLayoutRoot().GetName()); - } - } - - // Load property for the first time - if (viewBinding.Binding_Name != string.Empty) - { - NotifyPropertyChanged(viewBinding.Binding_Name, false); - } - } - - // really wish i had XOR here - bool b1 = (w.GetChildren() != null); - bool b2 = (viewBase && viewBase.IsInherited(Controller) && viewBase != this); - - // scuffed XOR - // Makes it stop loading when it finds another controller - // needs to be looked at - if (b1 && (b1 || b2) && !(b1 && b2)) - { - LoadDataBindings(w.GetChildren()); - } else if (b2) // Sets parent of the child controller - { - Controller childController = Controller.Cast(viewBase); - if (childController) - { - childController.SetParent(this); - } - } - - // w != m_LayoutRoot is so we dont bleed into siblings - if (w.GetSibling() != null && w != m_LayoutRoot) - { - LoadDataBindings(w.GetSibling()); - } - - return m_DataBindingHashMap.Count(); - } - - private typename GetControllerProperty(string property_name) - { - if (m_PropertyTypeHashMap[property_name]) - { - return m_PropertyTypeHashMap[property_name]; - } - - // Searches properties for Sub properties - Class context = this; - return GetControllerProperty(context, property_name); - } - - private typename GetControllerProperty(out Class context, string property_name) - { - PropertyInfo propertyInfo = GetSubScope(context, property_name); - if (propertyInfo) - { - return propertyInfo.Type; - } - - typename t; - return t; - } - - private string GetVariableName(Class targetVariable) - { - typename type = Type(); - for (int i = 0; i < type.GetVariableCount(); i++) - { - typename variableType = type.GetVariableType(i); - string variableName = type.GetVariableName(i); - - if (!variableType.IsInherited(targetVariable.Type())) - continue; - - Class result; - EnScript.GetClassVar(this, variableName, 0, result); - if (result == targetVariable) - { - return variableName; - } - } - - return string.Empty; - } - - private RelayCommand LoadRelayCommand(ViewBinding view_binding) - { - string relayCommandName = view_binding.Relay_Command; - RelayCommand relayCommand; - - // Attempt to load instance of Variable from Controller - Class context = this; - PropertyInfo relayCommandProperty = GetSubScope(context, relayCommandName); - if (relayCommandProperty) - { - typename relayCommandType = relayCommandProperty.Type; - relayCommandName = relayCommandProperty.Name; - - // If we find the variable on the Controller - if (relayCommandType && relayCommandType.IsInherited(RelayCommand)) - { - Log("RelayCommand Property %1 found on Controller!", relayCommandName); - EnScript.GetClassVar(context, relayCommandName, 0, relayCommand); - - // If that property isnt initialized, but exists - if (!relayCommand) - { - Log("RelayCommand Property %1 was not initialized! Initializing...", relayCommandName); - Class.CastTo(relayCommand, relayCommandType.Spawn()); - EnScript.SetClassVar(context, relayCommandName, 0, relayCommand); - return relayCommand; - } - } - } else // If we DONT find the variable on the controller, attempt to create an instance of it - { - Log("RelayCommand Property %1 not found on Controller", relayCommandName); - relayCommandType = relayCommandName.ToType(); - - if (relayCommandType && relayCommandType.IsInherited(RelayCommand)) - { - Log("RelayCommand type found %1", relayCommandName); - Class.CastTo(relayCommand, relayCommandType.Spawn()); - return relayCommand; - } - } - - return relayCommand; - } - - // Update Controller on action from ViewBinding - override bool OnClick(Widget w, int x, int y, int button) - { - ViewBinding view_binding = m_ViewBindingHashMap.Get(w); - if (view_binding) - { - view_binding.UpdateController(this); - } - - return super.OnClick(w, x, y, button); - } - - override bool OnChange(Widget w, int x, int y, bool finished) - { - ViewBinding view_binding = m_ViewBindingHashMap.Get(w); - if (view_binding) - { - view_binding.UpdateController(this); - } - - return super.OnChange(w, x, y, finished); - } - - // Two way binding interfaces - // Specifically for SpacerBaseWidget - /* - override bool OnDropReceived(Widget w, int x, int y, Widget reciever) - { - ViewBinding reciever_view; - reciever.GetScript(reciever_view); - //ScriptedViewBase.FindScriptedRoot(reciever_view); - if (reciever_view) { - - ScriptedViewBase scripted_view; - w.GetScript(scripted_view); - ScriptedViewBase.FindScriptedRoot(scripted_view); - if (scripted_view) { - reciever_view.HandleDropReceived(scripted_view, this); - } - } - - return super.OnDropReceived(w, x, y, reciever); - } - */ - - void DebugPrint() - { - m_DataBindingHashMap.DebugPrint(); - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Inputs/RelayCommand.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Inputs/RelayCommand.c deleted file mode 100644 index 91f9edfa..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Inputs/RelayCommand.c +++ /dev/null @@ -1,40 +0,0 @@ -// Abstract Class -class RelayCommand -{ - private bool m_CanExecute = true; - - protected Controller m_Controller; - void SetController(Controller controller) - { - m_Controller = controller; - } - - protected ViewBinding m_ViewBinding; - void SetViewBinding(ViewBinding viewBinding) - { - m_ViewBinding = viewBinding; - } - - // returns bool defining whether or not the Execute can be called - bool CanExecute() - { - return m_CanExecute; - } - - // sets whether or not RelayCommand can be executed - // depreciate if BI ever adds property Getters and Setters - void SetCanExecute(bool state) - { - m_CanExecute = state; - thread CanExecuteChanged(m_CanExecute); - } - - /* Abstract Methods */ - - // called when type is Clicked, Selected, or Changed - // Return: Handled (if false, will continue to execute up the tree) - bool Execute(Class sender, CommandArgs args); - - // Abstract function called when execution ability is changed - void CanExecuteChanged(bool state); -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/MVC.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/MVC.c deleted file mode 100644 index 309117b0..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/MVC.c +++ /dev/null @@ -1,137 +0,0 @@ -static ref LayoutBindingManager g_LayoutBindingManager; - -class LayoutBindingManager -{ - static int LBMLogLevel; - - private static void CheckLayoutBindingManager() - { - if (!g_LayoutBindingManager) - { - g_LayoutBindingManager = new LayoutBindingManager(); - } - } - - protected static ref TypenameHashMap m_WidgetControllerHashMap; - static WidgetController GetWidgetController(Widget data) - { - CheckLayoutBindingManager(); - - WidgetController widgetController = WidgetController.Cast(m_WidgetControllerHashMap.Get(data.Type()).Spawn()); - g_Script.Call(widgetController, "SetWidget", data); - return widgetController; - } - - protected static ref TypeConversionHashMap m_TypeConverterHashMap; - static TypeConverter GetTypeConversion(typename type) - { - CheckLayoutBindingManager(); - - return TypeConverter.Cast(m_TypeConverterHashMap[type].Spawn()); - } - - void LayoutBindingManager() - { - Log("LayoutBindingManager"); - - if (!m_TypeConverterHashMap) - { - m_TypeConverterHashMap = new TypeConversionHashMap(); - RegisterConversionTemplates(m_TypeConverterHashMap); - } - - if (!m_WidgetControllerHashMap) - { - m_WidgetControllerHashMap = new TypenameHashMap(); - RegisterWidgetControllers(m_WidgetControllerHashMap); - } - } - - void ~LayoutBindingManager() - { - Log("~LayoutBindingManager"); - } - - // Override THIS to add your own Custom Conversion Templates - // this determines how data is represented in the UI itself - // i.e. you can assign a TextWidget to float, due to the TypeConversion's GetString() - void RegisterConversionTemplates(out TypeConversionHashMap type_conversions) - { - Log("LayoutBindingManager::RegisterConversionTemplates"); - type_conversions.Insert(bool, TypeConversionBool); - type_conversions.Insert(int, TypeConversionInt); - type_conversions.Insert(float, TypeConversionFloat); - type_conversions.Insert(string, TypeConversionString); - type_conversions.Insert(vector, TypeConversionVector); - type_conversions.Insert(Widget, TypeConversionWidget); - type_conversions.Insert(Object, TypeConversionObject); - type_conversions.Insert(Observable, TypeConversionObservable); - type_conversions.Insert(ScriptedViewBase, TypeConversionScriptView); - } - - // Override THIS to add your own Widget widget_controllers - // this determins how the Widget controls the data sent to it - // Great for prefabs - void RegisterWidgetControllers(out TypenameHashMap widget_controllers) - { - Log("LayoutBindingManager::RegisterWidgetwidget_controllers"); - - widget_controllers.Insert(Widget, WidgetBaseController); - widget_controllers.Insert(SpacerBaseWidget, SpacerBaseWidgetController); - widget_controllers.Insert(WrapSpacerWidget, SpacerBaseWidgetController); - widget_controllers.Insert(GridSpacerWidget, SpacerBaseWidgetController); - widget_controllers.Insert(ScrollWidget, SpacerBaseWidgetController); - - widget_controllers.Insert(ButtonWidget, ButtonWidgetController); - widget_controllers.Insert(CheckBoxWidget, CheckBoxWidgetController); - widget_controllers.Insert(EditBoxWidget, EditBoxWidgetController); - widget_controllers.Insert(SliderWidget, SliderWidgetController); - widget_controllers.Insert(ProgressBarWidget, ProgressBarController); - widget_controllers.Insert(TextWidget, TextWidgetController); - widget_controllers.Insert(MultilineEditBoxWidget, MultilineEditBoxWidgetController); - widget_controllers.Insert(XComboBoxWidget, XComboBoxWidgetController); - widget_controllers.Insert(ImageWidget, ImageWidgetController); - widget_controllers.Insert(TextListboxWidget, TextListboxController); - widget_controllers.Insert(RichTextWidget, TextWidgetController); - widget_controllers.Insert(ItemPreviewWidget, ItemPreviewWidgetController); - widget_controllers.Insert(PlayerPreviewWidget, PlayerPreviewWidgetController); - widget_controllers.Insert(HtmlWidget, HtmlWidgetController); - } - - static void Trace(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - if (LBMLogLevel <= 0) - PrintFormat("LayoutBindingManagerLog::Trace %1", string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9)); - } - - static void Log(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - if (LBMLogLevel <= 1) - PrintFormat("LayoutBindingManagerLog::Log %1", string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9)); - } - - static void Error(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - string msg = string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9); - //PrintFormat("LayoutBindingManagerLog::Error %1", msg); - Error2("LayoutBindingManager Error", msg); - -#ifdef COMPONENT_SYSTEM - Workbench.Dialog("LayoutBindingManager Error", msg); -#endif - } -}; - -// Workbench safe variant of GetGame() -// https://feedback.bistudio.com/T153287 -DayZGame GetWorkbenchGame() -{ - // dont want to call this while actually in game -#ifdef COMPONENT_SYSTEM - if (!g_Game) { - g_Game = new DayZGame(); - } -#endif - - return g_Game; -} \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/Observable.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/Observable.c deleted file mode 100644 index 87922d0f..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/Observable.c +++ /dev/null @@ -1,32 +0,0 @@ - -// Base class for all Observable Types (ObservableCollection, ObservableSet, ObservableDictionary) -class Observable -{ - // Assigned on Constructor of super - private typename m_Type; - - protected Controller m_Controller; - - void Observable(Controller controller) - { - m_Controller = controller; - } - - protected void CollectionChanged(CollectionChangedEventArgs args) - { - m_Controller.NotifyCollectionChanged(args); - } - - typename GetType() - { - return m_Type; - } - - TypeConverter GetTypeConverter() - { - return LayoutBindingManager.GetTypeConversion(m_Type); - } - - // Abstract - int Count(); -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableCollection.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableCollection.c deleted file mode 100644 index 76fbcd18..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableCollection.c +++ /dev/null @@ -1,137 +0,0 @@ - -/* - - Base class for Observable Types - The design behind them is you wont need to use NotifyPropertyChanged() upon setting a variable - They are current used to support Collections (array, set, map) - -Example: - - -class TestController: Controller -{ - // "LeftList" goes into Binding_Name - ref ObservableCollection LeftList; - - // "LeftListSelection" goes into Selected_Item - string LeftListSelection; - - void TestController() - { - LeftList = new ObservableCollection("LeftList", this); - LeftList.Insert("Line1"); - } - - override void PropertyChanged(string propertyName) - { - switch (propertyName) - { - case "LeftListSelection": { - Print("LeftList selection changed: " + LeftListSelection); - break; - } - } - } -} - -*/ - -class ObservableCollection : Observable -{ - private ref array _data = {}; - - void ObservableCollection(Controller controller) - { - m_Type = TemplateType.GetType(); - } - - void ~ObservableCollection() - { - delete _data; - } - - int Insert(TValue value) - { - int index = _data.Insert(value); - if (index != -1) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Insert, index, new Param1(value))); - } - - return index; - } - - int InsertAt(TValue value, int index) - { - int new_index = _data.InsertAt(value, index); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.InsertAt, index, new Param1(value))); - return new_index; - } - - // 0: TValue value - // 1: int index - int InsertAtEx(TypeConverter typeConverter, int index) - { - TValue value; // scoofed - g_Script.CallFunction(typeConverter, "GetData", value, null); - Print(value); - int new_index = _data.InsertAt(value, index); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.InsertAt, index, new Param1(value))); - return new_index; - } - - void Remove(int index) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, index, new Param1(_data.Get(index)))); - _data.Remove(index); - } - - void Remove(TValue value) - { - int index = _data.Find(value); - if (index != -1) - Remove(index); - } - - void Set(int index, TValue value) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Replace, index, new Param1(value))); - _data.Set(index, value); - } - - int MoveIndex(int index, int moveIndex) - { - TValue value = _data.Get(index); - int new_index = _data.MoveIndex(index, moveIndex); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Move, new_index, new Param1(value))); - return new_index; - } - - void SwapItems(int itemA, int itemB) - { - _data.SwapItems(itemA, itemB); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Swap, -1, new CollectionSwapArgs(itemA, itemB))); - } - - void Clear() - { - _data.Clear(); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Clear, -1, null)); - } - - TValue Get(int index) - { - return _data.Get(index); - } - - override int Count() - { - return _data.Count(); - } - - int Find(TValue value) - { - Print(value); - return _data.Find(value); - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableDictionary.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableDictionary.c deleted file mode 100644 index a9209a83..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableDictionary.c +++ /dev/null @@ -1,57 +0,0 @@ -class ObservableDictionary : Observable -{ - private ref map _data = new map(); - - bool Insert(TKey key, TValue value) - { - if (_data.Insert(key, value)) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Add, new Param2(key, value))); - return true; - } - - return false; - } - - void Remove(TKey key) - { - if (_data.Contains(key)) - { - TValue value = _data.Get(key); - _data.Remove(key); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, new Param2(key, value))); - } - } - - void Clear() - { - _data.Clear(); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Clear, null)); - } - - void Set(TKey key, TValue value) - { - _data.Set(key, value); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Set, new Param2(key, value))); - } - - TValue Get(TKey key) - { - return _data.Get(key); - } - - TKey GetKey(int index) - { - return _data.GetKey(index); - } - - override int Count() - { - return _data.Count(); - } - - override typename GetType() - { - return TValue; - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableSet.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableSet.c deleted file mode 100644 index 6cb76286..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Observables/ObservableSet.c +++ /dev/null @@ -1,80 +0,0 @@ -class ObservableSet : Observable -{ - private ref set _data = new set(); - - int Insert(TValue value) - { - int index = _data.Insert(value); - if (index != -1) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Add, index, new Param1(value))); - } - - return index; - } - - int InsertAt(TValue value, int index) - { - int new_index = _data.InsertAt(value, index); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Set, index, new Param1(value))); - return new_index; - } - - void Remove(int index) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Remove, index, new Param1(_data.Get(index)))); - _data.Remove(index); - } - - void Remove(TValue value) - { - int index = _data.Find(value); - if (index != -1) - Remove(index); - } - - void Set(int index, TValue value) - { - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Set, index, new Param1(value))); - _data.Set(index, value); - } - - int Move(int index, int moveindex) - { - int new_index = _data.MoveIndex(index, moveindex); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Move, index, new Param1(new_index))); - return new_index; - } - - void Clear() - { - _data.Clear(); - CollectionChanged(new CollectionChangedEventArgs(this, NotifyCollectionChangedAction.Clear, -1, null)); - } - - TValue Get(int index) - { - TValue v = _data.Get(index); - if (!v) - { - LayoutBindingManager.Error(string.Format("ObservableCollection.Get returned null! Index: %1 Name: %2", index, m_VariableName)); - } - - return v; - } - - override int Count() - { - return _data.Count(); - } - - int Find(TValue value) - { - return _data.Find(value); - } - - override typename GetType() - { - return TValue; - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptView.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptView.c deleted file mode 100644 index 13392257..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptView.c +++ /dev/null @@ -1,127 +0,0 @@ - -// Abstract Class -// Inherit from this if you want to create UI elements with 100% script -/* - -Example: - -class CustomDialogWindow: ScriptView -{ - override string GetLayoutFile() { - return "MyMod/gui/Layouts/dialogs/Dialog.layout"; - } -} - - CustomDialogWindow window = new CustomDialogWindow(); - window.Show(); - .... - .... - window.Close(); - -*/ - -class ScriptView : ScriptedViewBase -{ - protected ref Controller m_Controller; - Controller GetController() - { - return m_Controller; - } - - // Maybe one day we'll get constructor overloading :) - void ScriptView() - { - m_LayoutRoot = CreateWidget(null); - - LoadViewProperties(this, PropertyTypeHashMap.FromType(Type()), m_LayoutRoot); - - m_LayoutRoot.GetScript(m_Controller); - - // If no Controller is specified in the WB Root - if (!m_Controller || !m_Controller.IsInherited(Controller)) - { - - Log("Controller not found on %1, creating...", m_LayoutRoot.GetName()); - if (!GetControllerType().IsInherited(Controller)) - { - Error("%1 is invalid. Must inherit from Controller!", GetControllerType().ToString()); - return; - } - - if (!Class.CastTo(m_Controller, GetControllerType().Spawn())) - { - Error("Could not create Controller %1", GetControllerType().ToString()); - return; - } - - // Since its not loaded in the WB, needs to be called here - LoadViewProperties(m_Controller, PropertyTypeHashMap.FromType(GetControllerType()), m_LayoutRoot); - m_Controller.OnWidgetScriptInit(m_LayoutRoot); - } - - m_Controller.Debug_Logging = Debug_Logging; - m_Controller.SetParent(this); - m_LayoutRoot.SetUserData(this); - //m_LayoutRoot.SetHandler(this); - } - - void ~ScriptView() - { - delete m_Controller; - - if (m_LayoutRoot) - { - Log("~" + m_LayoutRoot.GetName()); - m_LayoutRoot.Unlink(); - } - } - - void SetParent(Widget parent) - { - m_LayoutRoot = CreateWidget(parent); - } - - private Widget CreateWidget(Widget parent) - { - Widget result; - if (!GetLayoutFile()) - { - Error("Layout file not found! Are you overriding GetLayoutFile?"); - return result; - } - - WorkspaceWidget workspace = GetWorkbenchGame().GetWorkspace(); - if (!workspace) - { - Error("Workspace was null, try reloading Workbench"); - return result; - } - - Log("Loading %1", GetLayoutFile()); - result = workspace.CreateWidgets(GetLayoutFile(), parent); - if (!result) - { - Error("Invalid layout file %1", GetLayoutFile()); - return result; - } - - return result; - } - - // Useful if you want to set to an existing controller - void SetController(Controller controller) - { - m_Controller = controller; - m_Controller.Debug_Logging = Debug_Logging; - m_Controller.OnWidgetScriptInit(m_LayoutRoot); - m_Controller.SetParent(this); - } - - // Virtual Methods - protected string GetLayoutFile(); - - protected typename GetControllerType() - { - return Controller; - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptViewTemplate.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptViewTemplate.c deleted file mode 100644 index 27a73247..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptViewTemplate.c +++ /dev/null @@ -1,25 +0,0 @@ - -// Essentially the same as ScriptView except GetType is now a Template -class ScriptViewTemplate : ScriptView -{ - protected T m_TemplateController; - - T GetTemplateController() - { - return m_TemplateController; - } - - void ScriptViewTemplate() - { - if (!Class.CastTo(m_TemplateController, m_Controller)) - { - Error("Error in casting of Template Controller %1", T.ToString()); - return; - } - } - - private override typename GetControllerType() - { - return T; - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBase.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBase.c deleted file mode 100644 index 5d1eeb29..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBase.c +++ /dev/null @@ -1,450 +0,0 @@ - -// Base type for all primary view Types (ScriptView, Controller, ViewBinding) -class ScriptedViewBase : Managed -{ - // Enable verbose logging - [NonSerialized()] - reference bool Debug_Logging; - - // Source Widget - [NonSerialized()] - protected Widget m_LayoutRoot; - Widget GetLayoutRoot() - { - return m_LayoutRoot; - } - - // Source Widget Controller - [NonSerialized()] - protected autoptr WidgetController m_WidgetController; - WidgetController GetWidgetController() - { - return m_WidgetController; - } - - // ScriptedViewBase Type Converter - [NonSerialized()] - protected autoptr TypeConverter m_TypeConverter; - TypeConverter GetTypeConversion() - { - return m_TypeConverter; - } - - // ScriptedViewBase parent - [NonSerialized()] - protected ScriptedViewBase m_ParentScriptedViewBase; - ScriptedViewBase GetParent() - { - if (!m_ParentScriptedViewBase && m_LayoutRoot) - { - // Experimental update for trying to recursively find a root... causes Stackoverflow - //m_ParentScriptedViewBase = GetParentScriptView(m_LayoutRoot); - } - - return m_ParentScriptedViewBase; - } - - [NonSerialized()] - protected autoptr ScriptedViewBaseHandler m_ScriptedViewBaseHandler; - ScriptedViewBaseHandler GetHandler() - { - return m_ScriptedViewBaseHandler; - } - - void SetParent(ScriptedViewBase parent) - { - m_ParentScriptedViewBase = parent; - - // Propagates debug logging even if disabled locally - Debug_Logging = Debug_Logging || m_ParentScriptedViewBase.Debug_Logging; - } - - void ScriptedViewBase() - { - if (Debug_Logging) - PrintFormat("[Log] %1", this); - - m_TypeConverter = LayoutBindingManager.GetTypeConversion(Type()); - if (!m_TypeConverter) - { - Error("Could not generate TypeConverter on %1", Type().ToString()); - return; - } - - m_ScriptedViewBaseHandler = new ScriptedViewBaseHandler(this); - m_TypeConverter.Set(this); - } - - void ~ScriptedViewBase() - { - if (Debug_Logging) - PrintFormat("[Log] ~%1", this); - } - - void OnWidgetScriptInit(Widget w) - { - Trace("OnWidgetScriptInit %1", w.ToString()); - m_LayoutRoot = w; - m_LayoutRoot.SetHandler(m_ScriptedViewBaseHandler); - - m_WidgetController = LayoutBindingManager.GetWidgetController(m_LayoutRoot); - if (!m_WidgetController) - { - Error("Could not find WidgetController for type %1\n\nOverride LayoutBindingManager.RegisterWidgetControllers to register custom WidgetControllers", m_LayoutRoot.GetTypeName()); - return; - } - } - - ScriptedViewBase GetScriptedRoot() - { - ScriptedViewBase viewBase = this; - FindScriptedRoot(viewBase); - return viewBase; - } - - static void FindScriptedRoot(out ScriptedViewBase viewBase) - { - if (viewBase && viewBase.GetParent()) - { - viewBase = viewBase.GetParent(); - FindScriptedRoot(viewBase); - } - } - - // recursive function searches up the tree for the first available script view - private static ScriptedViewBase GetParentScriptView(Widget widget) - { - if (!widget) - { - return null; - } - - ScriptedViewBase scripted_view; - widget.GetScript(scripted_view); - - if (scripted_view) - { - return scripted_view; - } - - widget = widget.GetParent(); - return GetParentScriptView(widget); - } - - void Trace(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - //#ifdef COMPONENT_SYSTEM - if (Debug_Logging) // || LBMLogLevel >= LogLevel.TRACE - PrintFormat("[Trace] %1 - %2 ", Type(), string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9)); - //#endif - } - - void Log(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - //#ifdef COMPONENT_SYSTEM - if (Debug_Logging) // || LBMLogLevel >= LogLevel.INFO - PrintFormat("[Log] %1 - %2", Type(), string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9)); - //#endif - } - - void Error(string message, string param1 = "", string param2 = "", string param3 = "", string param4 = "", string param5 = "", string param6 = "", string param7 = "", string param8 = "", string param9 = "") - { - string msg = string.Format(message, param1, param2, param3, param4, param5, param6, param7, param8, param9); - string header = string.Format("[Error] %1", Type()); - Error2(header, msg); - -#ifdef COMPONENT_SYSTEM - Workbench.Dialog(header, msg); -#endif - } - - bool OnClick(Widget w, int x, int y, int button) - { - Trace("OnClick: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnClick(w, x, y, button); - } - - return false; - } - - bool OnModalResult(Widget w, int x, int y, int code, int result) - { - Trace("OnModalResult: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnModalResult(w, x, y, code, result); - } - - return false; - } - - bool OnDoubleClick(Widget w, int x, int y, int button) - { - Trace("OnDoubleClick: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDoubleClick(w, x, y, button); - } - - return false; - } - - bool OnSelect(Widget w, int x, int y) - { - Trace("OnSelect: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnSelect(w, x, y); - } - - return false; - } - - bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn) - { - Trace("OnItemSelected: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnItemSelected(w, x, y, row, column, oldRow, oldColumn); - } - - return false; - } - - bool OnFocus(Widget w, int x, int y) - { - Trace("OnFocus: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnFocus(w, x, y); - } - - return false; - } - - bool OnFocusLost(Widget w, int x, int y) - { - Trace("OnFocusLost: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnFocusLost(w, x, y); - } - - return false; - } - - bool OnMouseEnter(Widget w, int x, int y) - { - Trace("OnMouseEnter: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnMouseEnter(w, x, y); - } - - return false; - } - - bool OnMouseLeave(Widget w, Widget enterW, int x, int y) - { - Trace("OnMouseLeave: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnMouseLeave(w, enterW, x, y); - } - - return false; - } - - bool OnMouseWheel(Widget w, int x, int y, int wheel) - { - Trace("OnMouseWheel: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnMouseWheel(w, x, y, wheel); - } - - return false; - } - - bool OnMouseButtonDown(Widget w, int x, int y, int button) - { - Trace("OnMouseButtonDown: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnMouseButtonDown(w, x, y, button); - } - - return false; - } - - bool OnMouseButtonUp(Widget w, int x, int y, int button) - { - Trace("OnMouseButtonUp: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnMouseButtonUp(w, x, y, button); - } - - return false; - } - - bool OnController(Widget w, int control, int value) - { - Trace("OnController: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnController(w, control, value); - } - - return false; - } - - bool OnKeyDown(Widget w, int x, int y, int key) - { - Trace("OnKeyDown: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnKeyDown(w, x, y, key); - } - - return false; - } - - bool OnKeyUp(Widget w, int x, int y, int key) - { - Trace("OnKeyUp: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnKeyUp(w, x, y, key); - } - - return false; - } - - bool OnKeyPress(Widget w, int x, int y, int key) - { - Trace("OnKeyPress: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnKeyPress(w, x, y, key); - } - - return false; - } - - bool OnChange(Widget w, int x, int y, bool finished) - { - Trace("OnChange: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnChange(w, x, y, finished); - } - - return false; - } - - bool OnDrag(Widget w, int x, int y) - { - Trace("OnDrag: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDrag(w, x, y); - } - - return false; - } - - bool OnDragging(Widget w, int x, int y, Widget reciever) - { - // Disabled bc it wont stfu - //Trace("OnDragging: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDragging(w, x, y, reciever); - } - - return false; - } - - bool OnDraggingOver(Widget w, int x, int y, Widget reciever) - { - // Disabled bc it wont stfu - //Trace("OnDraggingOver: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDraggingOver(w, x, y, reciever); - } - - return false; - } - - bool OnDrop(Widget w, int x, int y, Widget reciever) - { - Trace("OnDrop: %1 - Reciever: %2", w.GetName(), reciever.ToString()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDrop(w, x, y, reciever); - } - - return false; - } - - bool OnDropReceived(Widget w, int x, int y, Widget reciever) - { - Trace("OnDropReceived: %1 - Reciever: %2", w.GetName(), reciever.ToString()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnDropReceived(w, x, y, reciever); - } - - return false; - } - - bool OnResize(Widget w, int x, int y) - { - // Disabled bc it wont stfu - //Trace("OnResize: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnResize(w, x, y); - } - - return false; - } - - bool OnChildAdd(Widget w, Widget child) - { - Trace("OnChildAdd: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnChildAdd(w, child); - } - - return false; - } - - bool OnChildRemove(Widget w, Widget child) - { - Trace("OnChildRemove: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnChildRemove(w, child); - } - - return false; - } - - bool OnUpdate(Widget w) - { - // Disabled bc it wont stfu - //Trace("OnUpdate: %1", w.GetName()); - if (m_ParentScriptedViewBase) - { - return m_ParentScriptedViewBase.OnUpdate(w); - } - - return false; - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBaseHandler.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBaseHandler.c deleted file mode 100644 index 88f6c415..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ScriptedViewBaseHandler.c +++ /dev/null @@ -1,140 +0,0 @@ - -class ScriptedViewBaseHandler : ScriptedWidgetEventHandler -{ - protected ScriptedViewBase m_ScriptedViewBase; - - void ScriptedViewBaseHandler(ScriptedViewBase viewBase) - { - m_ScriptedViewBase = viewBase; - } - - override bool OnClick(Widget w, int x, int y, int button) - { - return m_ScriptedViewBase.OnClick(w, x, y, button); - } - - override bool OnModalResult(Widget w, int x, int y, int code, int result) - { - return m_ScriptedViewBase.OnModalResult(w, x, y, code, result); - } - - override bool OnDoubleClick(Widget w, int x, int y, int button) - { - return m_ScriptedViewBase.OnDoubleClick(w, x, y, button); - } - - override bool OnSelect(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnSelect(w, x, y); - } - - override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn) - { - return m_ScriptedViewBase.OnItemSelected(w, x, y, row, column, oldRow, oldColumn); - } - - override bool OnFocus(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnFocus(w, x, y); - } - - override bool OnFocusLost(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnFocusLost(w, x, y); - } - - override bool OnMouseEnter(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnMouseEnter(w, x, y); - } - - override bool OnMouseLeave(Widget w, Widget enterW, int x, int y) - { - return m_ScriptedViewBase.OnMouseLeave(w, enterW, x, y); - } - - override bool OnMouseWheel(Widget w, int x, int y, int wheel) - { - return m_ScriptedViewBase.OnMouseWheel(w, x, y, wheel); - } - - override bool OnMouseButtonDown(Widget w, int x, int y, int button) - { - return m_ScriptedViewBase.OnMouseButtonDown(w, x, y, button); - } - - override bool OnMouseButtonUp(Widget w, int x, int y, int button) - { - return m_ScriptedViewBase.OnMouseButtonUp(w, x, y, button); - } - - override bool OnController(Widget w, int control, int value) - { - return m_ScriptedViewBase.OnController(w, control, value); - } - - override bool OnKeyDown(Widget w, int x, int y, int key) - { - return m_ScriptedViewBase.OnKeyDown(w, x, y, key); - } - - override bool OnKeyUp(Widget w, int x, int y, int key) - { - return m_ScriptedViewBase.OnKeyUp(w, x, y, key); - } - - override bool OnKeyPress(Widget w, int x, int y, int key) - { - return m_ScriptedViewBase.OnKeyPress(w, x, y, key); - } - - override bool OnChange(Widget w, int x, int y, bool finished) - { - return m_ScriptedViewBase.OnChange(w, x, y, finished); - } - - override bool OnDrag(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnDrag(w, x, y); - } - - override bool OnDragging(Widget w, int x, int y, Widget reciever) - { - return m_ScriptedViewBase.OnDragging(w, x, y, reciever); - } - - override bool OnDraggingOver(Widget w, int x, int y, Widget reciever) - { - return m_ScriptedViewBase.OnDraggingOver(w, x, y, reciever); - } - - override bool OnDrop(Widget w, int x, int y, Widget reciever) - { - return m_ScriptedViewBase.OnDrop(w, x, y, reciever); - } - - override bool OnDropReceived(Widget w, int x, int y, Widget reciever) - { - return m_ScriptedViewBase.OnDropReceived(w, x, y, reciever); - } - - override bool OnResize(Widget w, int x, int y) - { - return m_ScriptedViewBase.OnResize(w, x, y); - } - - override bool OnChildAdd(Widget w, Widget child) - { - return m_ScriptedViewBase.OnChildAdd(w, child); - } - - override bool OnChildRemove(Widget w, Widget child) - { - return m_ScriptedViewBase.OnChildRemove(w, child); - } - - override bool OnUpdate(Widget w) - { - return m_ScriptedViewBase.OnUpdate(w); - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/TypeConverter.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/TypeConverter.c deleted file mode 100644 index f2bc9931..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/TypeConverter.c +++ /dev/null @@ -1,422 +0,0 @@ -// Used for Converting Data within LayoutBindingManager. -// Register your own with LayoutBindingManager.RegisterConversionTemplates -class TypeConverter -{ - // Main Setter and Getter - void Set(Class value) - { - g_Script.Call(this, "SetData", value); - } - - Class Get() - { - Class result; - g_Script.CallFunction(this, "GetData", result, null); - return result; - } - - typename GetType(); - - bool GetBool(); - int GetInt(); - float GetFloat(); - string GetString(); - vector GetVector(); - Widget GetWidget(); - Object GetObject(); - Param GetParam(); - - void SetBool(bool value); - void SetInt(int value); - void SetFloat(float value); - void SetString(string value); - void SetVector(vector value); - void SetWidget(Widget value); - void SetObject(Object value); - void SetParam(Param value); - - void SetToController(Class context, string name, int index); - void GetFromController(Class context, string name, int index); - - static func GetterFromType(typename type) - { - switch (type) - { - case bool: - return GetBool; - case int: - return GetInt; - case float: - return GetFloat; - case string: - return GetString; - case vector: - return GetVector; - case Widget: - return GetWidget; - case Object: - return GetObject; - case Param: - return GetParam; - } - - return __NULL_FUNCT; - } - - static func SetterFromType(typename type) - { - switch (type) - { - case bool: - return SetBool; - case int: - return SetInt; - case float: - return SetFloat; - case string: - return SetString; - case vector: - return SetVector; - case Widget: - return SetWidget; - case Object: - return SetObject; - case Param: - return SetParam; - } - - return __NULL_FUNCT; - } -}; - -// Inherit from THIS for creating Custom TypeConversions -class TypeConversionTemplate : TypeConverter -{ - protected T m_Value; - - protected void SetData(T value) - { - m_Value = value; - } - - protected T GetData() - { - return m_Value; - } - - // This throws warnings cause casting in Enforce is stupid - // Can't do Param1.Cast(value) or Class.CastTo() because inheritence doesnt - // work properly with Template Casting - - // UPDATE: Using SetClassVar is a safe way of doing this without warnings - - // This is meant to be an anonymous data setter - // string, int, etc... dont inherit from Class :) - - // UPDATE 2: I could have just used the inverse and done GetClassVar the other way around - override void SetParam(Param value) - { - EnScript.GetClassVar(value, "param1", 0, m_Value); - } - - override Param GetParam() - { - return new Param1(m_Value); - } - - override typename GetType() - { - return TemplateType.GetType(); - } - - override void SetToController(Class context, string name, int index) - { - PropertyInfo propertyInfo = GetSubScope(context, name); - EnScript.SetClassVar(context, propertyInfo.Name, index, m_Value); - } - - override void GetFromController(Class context, string name, int index) - { - PropertyInfo propertyInfo = GetSubScope(context, name); - EnScript.GetClassVar(context, propertyInfo.Name, index, m_Value); - } -}; - -class TypeConversionBool : TypeConversionTemplate -{ - override bool GetBool() - { - return m_Value; - } - - override void SetBool(bool value) - { - m_Value = value; - } - - override int GetInt() - { - return m_Value; - } - - override void SetInt(int value) - { - m_Value = value; - } - - override float GetFloat() - { - return m_Value; - } - - override void SetFloat(float value) - { - m_Value = value; - } - - override string GetString() - { - return m_Value.ToString(); - } - - override void SetString(string value) - { - m_Value = (value == "1"); - } -}; - -class TypeConversionInt : TypeConversionTemplate -{ - override bool GetBool() - { - return m_Value; - } - - override void SetBool(bool value) - { - m_Value = value; - } - - override int GetInt() - { - return m_Value; - } - - override void SetInt(int value) - { - m_Value = value; - } - - override float GetFloat() - { - return m_Value; - } - - override void SetFloat(float value) - { - m_Value = value; - } - - override string GetString() - { - return string.ToString(m_Value, false, false, false); - } - - override void SetString(string value) - { - m_Value = value.ToInt(); - } -}; - -class TypeConversionFloat : TypeConversionTemplate -{ - override bool GetBool() - { - return m_Value; - } - - override void SetBool(bool value) - { - m_Value = value; - } - - override int GetInt() - { - return m_Value; - } - - override void SetInt(int value) - { - m_Value = value; - } - - override float GetFloat() - { - return m_Value; - } - - override void SetFloat(float value) - { - m_Value = value; - } - - override string GetString() - { - return string.ToString(m_Value, false, false, false); - } - - override void SetString(string value) - { - m_Value = value.ToFloat(); - } -}; - -class TypeConversionString : TypeConversionTemplate -{ - override bool GetBool() - { - return string.ToString(m_Value, false, false, false) == "1"; - } - - override void SetBool(bool value) - { - m_Value = string.ToString(value, false, false, false); - } - - override int GetInt() - { - return m_Value.ToInt(); - } - - override void SetInt(int value) - { - m_Value = string.ToString(value, false, false, false); - } - - override float GetFloat() - { - return m_Value.ToFloat(); - } - - override void SetFloat(float value) - { - m_Value = string.ToString(value, false, false, false); - } - - override vector GetVector() - { - return m_Value.ToVector(); - } - - override void SetVector(vector value) - { - m_Value = value.ToString(false); - } - - override string GetString() - { - return m_Value; - } - - override void SetString(string value) - { - m_Value = value; - } -}; - -class TypeConversionVector : TypeConversionTemplate -{ - override vector GetVector() - { - return m_Value; - } - - override void SetVector(vector value) - { - m_Value = value; - } - - override string GetString() - { - return m_Value.ToString(false); - } - - override void SetString(string value) - { - m_Value = value.ToVector(); - } -}; - -class TypeConversionWidget : TypeConversionTemplate -{ - - override void SetString(string value) - { - m_Value = GetWorkbenchGame().GetWorkspace().CreateWidgets(value); - } - - override void SetWidget(Widget value) - { - m_Value = value; - } - - override Widget GetWidget() - { - return m_Value; - } -}; - -class TypeConversionObservable : TypeConversionTemplate -{ - override int GetInt() - { - return m_Value.Count(); - } - - override string GetString() - { - return m_Value.Count().ToString(); - } -}; - -class TypeConversionObject : TypeConversionTemplate -{ - override string GetString() - { - return m_Value.GetType(); - } - - override void SetString(string value) - { - m_Value = GetGame().CreateObjectEx(value, vector.Zero, ECE_NONE); - } - - override void SetObject(Object value) - { - m_Value = value; - } - - override Object GetObject() - { - return m_Value; - } -}; - -class TypeConversionScriptView : TypeConversionTemplate -{ - override Widget GetWidget() - { - // Todo: why can this be null? not sure - if (m_Value) - { - return m_Value.GetLayoutRoot(); - } - - return null; - } - - override void SetWidget(Widget value) - { - m_Value.OnWidgetScriptInit(value); - } -}; diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/CommandArgs.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/CommandArgs.c deleted file mode 100644 index 037fb776..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/CommandArgs.c +++ /dev/null @@ -1,79 +0,0 @@ - -// Base class for all CommandArgs -class CommandArgs -{ - ScriptedViewBase Context; -}; - -class CommandArgsT: CommandArgs -{ - T Source; - - void CommandArgsT(T source) - { - Source = source; - } -}; - -// 0: Source Widget -// 1: Mouse Button -class ButtonCommandArgs: CommandArgsT -{ - private int m_MouseButton; - - void ButtonCommandArgs(ButtonWidget source, int mouseButton) - { - m_MouseButton = mouseButton; - } - - int GetMouseButton() - { - return m_MouseButton; - } - - bool GetButtonState() - { - return Source.GetState(); - } -}; - - -// 0: Source Widget -// 1: CheckBox State -class CheckBoxCommandArgs: CommandArgsT -{ - bool GetCheckBoxState() - { - return Source.IsChecked(); - } -}; - -// 0: Source Widget -// 1: Selected Item -class XComboBoxCommandArgs: Param2 -{ - XComboBoxWidget GetComboBoxWidget() - { - return param1; - } - - int GetSelectedIndex() - { - return param2; - } -}; - -// 0: Source Widget -// 1: Selected Widget -class WrapSpacerCommandArgs: Param2 -{ - WrapSpacerWidget GetWrapSpacerWidget() - { - return param1; - } - - Widget GetSelectedWidget() - { - return param2; - } -}; diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/EventArgs.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/EventArgs.c deleted file mode 100644 index 63c904f1..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/EventArgs.c +++ /dev/null @@ -1,36 +0,0 @@ - -enum NotifyCollectionChangedAction -{ - Insert, - InsertAt, - Remove, - Replace, - Move, - Swap, - Clear -}; - -// 0: Start Index -// 1: Finish Index -typedef Param2 CollectionSwapArgs; - -// Event Args for Collection Changed -// 0: Collection that was changed -// 1: Collection Changed Action -// 2: Collection Changed Index -// 3: Collection Changed Value -class CollectionChangedEventArgs -{ - Observable Source; - NotifyCollectionChangedAction ChangedAction; - int ChangedIndex; - Param ChangedValue; - - void CollectionChangedEventArgs(Observable source, NotifyCollectionChangedAction changedAction, int changedIndex, Param changedValue) - { - Source = source; - ChangedAction = changedAction; - ChangedIndex = changedIndex; - ChangedValue = changedValue; - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/Types.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/Types.c deleted file mode 100644 index 7be78b6e..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Types/Types.c +++ /dev/null @@ -1,161 +0,0 @@ - -class PropertyInfo -{ - string Name; - typename Type; - - void PropertyInfo(string name, typename type) - { - Name = name; - Type = type; - } - - static PropertyInfo GetFromClass(Class context, string name) - { - if (!context) - return null; - - PropertyTypeHashMap hash_map = PropertyTypeHashMap.FromType(context.Type()); - if (hash_map[name]) - { - return new PropertyInfo(name, hash_map[name]); - } - - return null; - } - - static PropertyInfo GetFromType(typename parent_type, string name) - { - PropertyTypeHashMap hash_map = PropertyTypeHashMap.FromType(parent_type); - if (hash_map[name]) - { - return new PropertyInfo(name, hash_map[name]); - } - - return null; - } -} - - -// 0: Property Name -// 1: Property Type -class PropertyTypeHashMap: map -{ - static PropertyTypeHashMap FromType(typename type) - { - PropertyTypeHashMap hash_map = new PropertyTypeHashMap(); - for (int i = 0; i < type.GetVariableCount(); i++) - { - hash_map.Insert(type.GetVariableName(i), type.GetVariableType(i)); - } - - return hash_map; - } - - void RemoveType(typename removed_type) - { - PropertyTypeHashMap hash_map = FromType(removed_type); - foreach (string name, typename type: hash_map) - Remove(name); - } -} - - -// 0: Source Widget -// 1: View Binding -typedef map ViewBindingHashMap; - -// 0: View Binding -typedef set ViewBindingArray; - -// 0: Property Name -// 1: View Binding Set -class DataBindingHashMap: map -{ - void DebugPrint() - { - foreach (string name, ViewBindingArray viewSet: this) - { - LayoutBindingManager.Log("[%1]:", name); - foreach (ViewBinding view: viewSet) - { - LayoutBindingManager.Log(" %1", view.GetLayoutRoot().GetName()); - } - } - } - - void InsertView(ViewBinding view) - { - ViewBindingArray viewSet = Get(view.Binding_Name); - if (!viewSet) - { - viewSet = new ViewBindingArray(); - viewSet.Insert(view); - Insert(view.Binding_Name, viewSet); - Insert(view.Selected_Item, viewSet); - } else - { - viewSet.Insert(view); - } - } -} - -// 0: Relay_Command parameter -// 1: Command Value -typedef map RelayCommandHashMap - -// 0: Source Type -// 1: Conversion Type -typedef map TypenameHashMap; - -// 0: Source Type -// 1: Conversion Type -class TypeConversionHashMap -{ - private autoptr map value = new map(); - - - typename Get(typename conversionType) - { - typename result = value.Get(conversionType); - - if (!result) - { - foreach (typename type, typename conversion: value) - { - if (conversionType.IsInherited(type)) - { - return conversion; - } - } - } - - return result; - } - - void Remove(typename conversionType) { - value.Remove(conversionType); - } - - void Set(typename conversionType, typename conversionClass) - { - if (!conversionClass.IsInherited(TypeConversionTemplate)) - { - LayoutBindingManager.Error(string.Format("TypeConverterHashMap: %1 must inherit from type TypeConversionTemplate", conversionClass.ToString())); - return; - } - - value.Set(conversionType, conversionClass); - } - - bool Insert(typename conversionType, typename conversionClass) - { - if (!conversionClass.IsInherited(TypeConversionTemplate)) - { - LayoutBindingManager.Error(string.Format("TypeConverterHashMap: %1 must inherit from type TypeConversionTemplate", conversionClass.ToString())); - return false; - } - - return value.Insert(conversionType, conversionClass); - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Utilities.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Utilities.c deleted file mode 100644 index 13e19f3a..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/Utilities.c +++ /dev/null @@ -1,83 +0,0 @@ - - -// Loads .layout file Widgets into Properties of context (when they are the same name) -/* - -Example: - -.layout file: -MenuBarRoot FrameWidget - MenuBarFile ButtonWidget - MenuBarFileLabel TextWidget - - -.c file: -class TestClass -{ - ButtonWidget MenuBarFile; //<-- these properties will be assigned - private TextWidget MenuBarFileLabel; -} - -*/ -static void LoadViewProperties(Class context, PropertyTypeHashMap property_map, Widget root_widget) -{ - foreach (string propertyName, typename property_type : property_map) - { - - if (!property_type.IsInherited(Widget)) - continue; - - Widget target = root_widget.FindAnyWidget(propertyName); - - // fixes bug that breaks everything - if (target && root_widget.GetName() != propertyName) - { - EnScript.SetClassVar(context, propertyName, 0, target); - continue; - } - - // Allows you to define the layout root aswell within it - if (!target && root_widget.GetName() == propertyName) - { - EnScript.SetClassVar(context, propertyName, 0, root_widget); - continue; - } - } -} - -// 0: Context of Start Scope, out is context of final scope -// 1: Name of variable string Ex: m_Binding.Value.Root -// return: Final variable name -static PropertyInfo GetSubScope(out Class context, string name) -{ - if (name == string.Empty) - return null; - - TStringArray variable_scope = {}; - name.Split(".", variable_scope); - - for (int i = 0; i < variable_scope.Count() - 1; i++) - { - EnScript.GetClassVar(context, variable_scope[i], 0, context); - } - - if (variable_scope.Count() == 1) - { - return PropertyInfo.GetFromClass(context, name); - } - - return PropertyInfo.GetFromClass(context, variable_scope[variable_scope.Count() - 1]); -} - -// Gets typename from Templated type -// This is useful when getting this error... -// 'Can't get typename from forward declaration 'Class'. Use Type("name") instead....' -class TemplateType -{ - T value; - - static typename GetType() - { - return (new TemplateType()).Type().GetVariableType(0); - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ViewBinding.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ViewBinding.c deleted file mode 100644 index b4d781f8..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/ViewBinding.c +++ /dev/null @@ -1,325 +0,0 @@ -class ViewBinding : ScriptedViewBase -{ - // Name of Variable to bind to - reference string Binding_Name; - - // Name of Variable to bind "selected item" to - reference string Selected_Item; - - // If true, Bindings go both ways. Otherwise the controller is the master - reference bool Two_Way_Binding; - - // Type of RelayCommand class that is controlled by ViewBinding - reference string Relay_Command; - - // Strong reference to Relay Command - protected autoptr RelayCommand m_RelayCommand; - void SetRelayCommand(RelayCommand relayCommand) - { - m_RelayCommand = relayCommand; - m_RelayCommand.SetViewBinding(this); - } - - RelayCommand GetRelayCommand() - { - return m_RelayCommand; - } - - protected autoptr TypeConverter m_PropertyConverter; - TypeConverter GetPropertyConverter() - { - return m_PropertyConverter; - } - - protected autoptr TypeConverter m_SelectedConverter; - TypeConverter GetSelectedConverter() - { - return m_SelectedConverter; - } - - override void OnWidgetScriptInit(Widget w) - { - super.OnWidgetScriptInit(w); - - Log("Loaded from Widget: %1", m_LayoutRoot.GetName()); - - // Check for two way binding support - if (Two_Way_Binding && !m_WidgetController.CanTwoWayBind()) - { - Error("Two Way Binding for %1 is not supported!", m_LayoutRoot.Type().ToString()); - } - } - - void SetProperties(typename binding_type, typename selected_type) - { - Trace("SetProperties"); - // Were not trying to data bind to empty Binding_Name - if (binding_type && Binding_Name != string.Empty) - { - Log("Loading TypeConverter for Variable: %1 of Type: %2", Binding_Name, binding_type.ToString()); - m_PropertyConverter = LayoutBindingManager.GetTypeConversion(binding_type); - if (!m_PropertyConverter) - { - Error("Could not find TypeConverter for type %1 in %2\n\nMod LayoutBindingManager.RegisterConversionTemplates to register custom TypeConverters", binding_type.ToString(), Binding_Name); - } - } - - // Were not trying to data bind to empty Selected_Item - if (selected_type && Selected_Item != string.Empty) - { - Log("Loading TypeConverter for Variable: %1 of Type: %2", Selected_Item, selected_type.ToString()); - m_SelectedConverter = LayoutBindingManager.GetTypeConversion(selected_type); - if (!m_SelectedConverter) - { - Error("Could not find TypeConverter for type %1 in %2\n\nMod LayoutBindingManager.RegisterConversionTemplates to register custom TypeConverters", selected_type.ToString(), Selected_Item); - } - } - } - - // Controller -> view - void UpdateView(Controller controller) - { - Trace("UpdateView"); - if (!m_WidgetController) - return; - - // Binding_Name handler - if (m_PropertyConverter) - { - Log("Updating %1 to the value of %2", m_LayoutRoot.GetName(), Binding_Name); - m_PropertyConverter.GetFromController(controller, Binding_Name, 0); - m_WidgetController.Set(m_PropertyConverter); - } - - // Selected_Item handler - if (m_SelectedConverter) - { - Log("Updating %1 to the value of %2", m_LayoutRoot.GetName(), Selected_Item); - m_SelectedConverter.GetFromController(controller, Selected_Item, 0); - m_WidgetController.SetSelection(m_SelectedConverter); - } - } - - // View -> Controller - void UpdateController(Controller controller) - { - Trace("UpdateController"); - if (!m_WidgetController) - return; - - // Binding_Name handler - if (m_PropertyConverter && Two_Way_Binding && m_WidgetController.CanTwoWayBind()) - { - Log("Setting %1 to the value of %2", Binding_Name, m_LayoutRoot.GetName()); - m_WidgetController.Get(m_PropertyConverter); - m_PropertyConverter.SetToController(controller, Binding_Name, 0); - controller.NotifyPropertyChanged(Binding_Name); - } - - // Selected_Item handler - if (m_SelectedConverter) - { - Log("Setting Selection of %1 with value of %2", Selected_Item, m_LayoutRoot.GetName()); - m_WidgetController.GetSelection(m_SelectedConverter); - m_SelectedConverter.SetToController(controller, Selected_Item, 0); - controller.NotifyPropertyChanged(Selected_Item); - } - } - - // Collection -> view - void UpdateViewFromCollection(CollectionChangedEventArgs args) - { - Trace("UpdateViewFromCollection"); - - if (!m_WidgetController) - return; - - Log("Updating Collection View: %1", m_LayoutRoot.Type().ToString()); - - // We dont want to work with type Observable for everything - TypeConverter collectionConverter = args.Source.GetTypeConverter(); - if (!collectionConverter) - { - Error("Type Converter not found for Collection %1", args.Source.ToString()); - return; - } - - // Anonymous Data Setter - if (args.ChangedValue && args.ChangedIndex != -1) - { - collectionConverter.SetParam(args.ChangedValue); - } - - switch (args.ChangedAction) - { - case NotifyCollectionChangedAction.Insert: - { - m_WidgetController.Insert(collectionConverter); - break; - } - - case NotifyCollectionChangedAction.InsertAt: - { - m_WidgetController.InsertAt(args.ChangedIndex, collectionConverter); - break; - } - - case NotifyCollectionChangedAction.Remove: - { - m_WidgetController.Remove(args.ChangedIndex, collectionConverter); - break; - } - - case NotifyCollectionChangedAction.Replace: - { - m_WidgetController.Replace(args.ChangedIndex, collectionConverter); - break; - } - - case NotifyCollectionChangedAction.Move: - { - m_WidgetController.Move(args.ChangedIndex, collectionConverter); - break; - } - - case NotifyCollectionChangedAction.Swap: - { - CollectionSwapArgs swap_args = CollectionSwapArgs.Cast(args.ChangedValue); - m_WidgetController.Swap(swap_args.param1, swap_args.param2); - break; - } - - case NotifyCollectionChangedAction.Clear: - { - m_WidgetController.Clear(); - break; - } - - default: - { - Error("Invalid NotifyCollectionChangedAction Type %1", args.ChangedAction.ToString()); - } - } - } - - // View -> Collection - void UpdateCollectionFromView(ref CollectionChangedEventArgs args) - { - Trace("UpdateCollectionFromView"); - - if (!m_WidgetController) - return; - - Log("Updating Collection from View: %1", m_LayoutRoot.Type().ToString()); - } - - private bool InvokeCommand(ScriptedViewBase context, CommandArgs args) - { - Trace("InvokeCommand"); - - bool handled; - args.Context = this; - if (m_RelayCommand && m_RelayCommand.CanExecute()) - { - Log("Attempting to execute RelayCommand %1", Relay_Command); - handled = m_RelayCommand.Execute(context, args); - } else if (!m_RelayCommand && Relay_Command != string.Empty) - { - Log("Attempting to call function %1 on %2", Relay_Command, context.ToString()); - g_Script.CallFunction(context, Relay_Command, handled, args); - } - - if (!handled && context && context.GetParent()) - { - handled = InvokeCommand(context.GetParent(), args); - } - - if (!context) - { - handled = true; - } - - return handled; - } - - // Command interfaces - override bool OnClick(Widget w, int x, int y, int button) - { - Trace("OnClick"); - switch (w.Type()) - { - case ButtonWidget: - { // only thing that isnt called in OnChange for some reason - if (InvokeCommand(this, new ButtonCommandArgs(ButtonWidget.Cast(w), button))) - { - // Weird situation but I need to call UpdateController from Controller without calling OnClick - // if (w) is just an edge case if the object is deleted inside of the Command - if (w) - super.OnClick(w, x, y, button); - - return true; - } - - break; - } - } - - return super.OnClick(w, x, y, button); - } - - override bool OnChange(Widget w, int x, int y, bool finished) - { - Trace("OnChange"); - switch (w.Type()) - { - case CheckBoxWidget: - { - if (InvokeCommand(this, new CheckBoxCommandArgs(CheckBoxWidget.Cast(w)))) - { - // Weird situation but I need to call UpdateController from Controller without calling OnChange - // if (w) is just an edge case if the object is deleted inside of the Command - if (w) - super.OnChange(w, x, y, finished); - return true; - } - - break; - } - } - - return super.OnChange(w, x, y, finished); - } - - /* - void HandleDropReceived(ScriptedViewBase drop_target, Controller controller) - { - EditorLog.Trace("ViewBinding::HandleDropReceived"); - Print(drop_target); - Print(m_WidgetController); - if (!m_WidgetController || !m_WidgetController.CanTwoWayBind() || !Two_Way_Binding) return; - - - - Observable collection; - EnScript.GetClassVar(controller, Binding_Name, 0, collection); - Print(collection); - if (collection) { - - //g_Script.CallFunction(collection, "Remove", null, drop_target); - - if (false) { // reciever_view && reciever != m_LayoutRoot - - int find;// = m_WidgetController.Find(reciever_view.GetTypeConversion()); - - g_Script.CallFunction(collection, "Find", find, this); - if (find != -1) { - Print(drop_target); - //m_WidgetController.InsertAt(find + 1, drop_target.GetTypeConversion()); - g_Script.CallFunctionParams(collection, "InsertAtEx", null, new Param2(GetTypeConversion(), find + 1)); - } - } else { - g_Script.Call(collection, "Insert", drop_target); - } - } - }*/ -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/WidgetController.c b/JM/CF/Scripts/3_Game/CommunityFramework/MVC/WidgetController.c deleted file mode 100644 index e4109990..00000000 --- a/JM/CF/Scripts/3_Game/CommunityFramework/MVC/WidgetController.c +++ /dev/null @@ -1,630 +0,0 @@ -Widget GetChildAtIndex(Widget widget, int index) -{ - Widget result = widget.GetChildren(); - while (index > 0) - { - result = result.GetSibling(); - index--; - } - - return result; -} - -bool IsWidgetChild(Widget widget, Widget child) -{ - Widget result = widget.GetChildren(); - while (result != null) - { - if (result == child) - return true; - result = result.GetSibling(); - } - - return false; -} - -class WidgetController -{ - bool CanTwoWayBind() - { - return false; - } - - // Base Controller Stuff - void Set(TypeConverter typeConverter); - void Get(out TypeConverter typeConverter); - - // Collection Stuff - void SetSelection(TypeConverter typeConverter) - { - NotImplementedError("SetSelection"); - } - - void GetSelection(out TypeConverter typeConverter) - { - NotImplementedError("GetSelection"); - } - - void Insert(TypeConverter typeConverter) - { - NotImplementedError("Insert"); - } - - void InsertAt(int index, TypeConverter typeConverter) - { - NotImplementedError("InsertAt"); - } - - void Remove(int index, TypeConverter typeConverter) - { - NotImplementedError("Remove"); - } - - void Replace(int index, TypeConverter typeConverter) - { - NotImplementedError("Replace"); - } - - void Move(int index, TypeConverter typeConverter) - { - NotImplementedError("Move"); - } - - void Swap(int indexA, int indexB) - { - NotImplementedError("Swap"); - } - - void Clear() - { - NotImplementedError("Clear"); - } - - int Find(TypeConverter typeConverter) - { - NotImplementedError("Find"); - return -1; - } - - int Count() - { - NotImplementedError("Count"); - return -1; - } - - private void NotImplementedError(string function) - { - Error(string.Format("%1 does not support function %2", Type(), function)); - } -}; - -class WidgetControllerTemplate : WidgetController -{ - protected T m_Widget; - - void SetWidget(T w) - { - Class.CastTo(m_Widget, w); - } -}; - -class WidgetBaseController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - if (!m_Widget) - return; - - Widget parent = m_Widget.GetParent(); - int sort = m_Widget.GetSort(); - if (typeConverter.GetWidget()) - { - m_Widget = typeConverter.GetWidget(); - - if (parent) - { - parent.AddChild(m_Widget, false); - } - - m_Widget.SetSort(sort); - } - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetWidget(m_Widget); - } -}; - -class ButtonWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetState(typeConverter.GetBool()); - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetBool(m_Widget.GetState()); - } - - override void SetSelection(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } - - override void GetSelection(out TypeConverter typeConverter) - { - // Since SetSelection is being used. This needs to override to avoid errors - } -}; - -class EditBoxWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetString(m_Widget.GetText()); - } -}; - -class CheckBoxWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetChecked(typeConverter.GetBool()); - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetBool(m_Widget.IsChecked()); - } - - override void SetSelection(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } - - override void GetSelection(out TypeConverter typeConverter) - { - // Since SetSelection is being used. This needs to override to avoid errors - } -}; - -class SliderWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetCurrent(typeConverter.GetFloat()); - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetFloat(m_Widget.GetCurrent()); - } -}; - -class ProgressBarController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetCurrent(typeConverter.GetFloat()); - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.SetFloat(m_Widget.GetCurrent()); - } -}; - -class TextWidgetController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } -}; - -class ImageWidgetController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - if (typeConverter.GetString()) - { - m_Widget.LoadImageFile(0, typeConverter.GetString()); - m_Widget.SetImage(0); - } - } -}; - -class MultilineEditBoxWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void Set(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } - - override void Get(out TypeConverter typeConverter) - { - string out_text; - m_Widget.GetText(out_text); - typeConverter.SetString(out_text); - } - - override void Insert(TypeConverter typeConverter) - { - m_Widget.SetLine(m_Widget.GetLinesCount(), typeConverter.GetString()); - } - - override void InsertAt(int index, TypeConverter typeConverter) - { - m_Widget.SetLine(index, typeConverter.GetString()); - } - - override void Replace(int index, TypeConverter typeConverter) - { - InsertAt(index, typeConverter); - } - - override void Remove(int index, TypeConverter typeConverter) - { - m_Widget.SetLine(index, string.Empty); - } - - override void Clear() - { - for (int i = 0; i < m_Widget.GetLinesCount(); i++) - m_Widget.SetLine(i, string.Empty); - } -}; - -class SpacerBaseWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void SetSelection(TypeConverter typeConverter) - { - if (typeConverter.GetWidget()) - { - SetFocus(typeConverter.GetWidget()); - } - } - - override void GetSelection(out TypeConverter typeConverter) - { - if (IsWidgetChild(m_Widget, GetFocus())) - { - typeConverter.SetWidget(GetFocus()); - } - } - - override void Insert(TypeConverter typeConverter) - { - if (typeConverter.GetWidget()) - { - m_Widget.AddChild(typeConverter.GetWidget()); - } - } - - override void InsertAt(int index, TypeConverter typeConverter) - { - if (index == Count()) - { - Insert(typeConverter); - } else if (typeConverter.GetWidget()) - { - Widget widgetA = GetChildAtIndex(m_Widget, index); - m_Widget.AddChildAfter(typeConverter.GetWidget(), widgetA); - } - } - - override void Replace(int index, TypeConverter typeConverter) - { - if (typeConverter.GetWidget()) - { - Widget widgetA = GetChildAtIndex(m_Widget, index); - m_Widget.AddChildAfter(typeConverter.GetWidget(), widgetA); - m_Widget.RemoveChild(widgetA); - } - } - - override void Remove(int index, TypeConverter typeConverter) - { - if (typeConverter.GetWidget()) - { - m_Widget.RemoveChild(typeConverter.GetWidget()); - } - } - - override void Move(int index, TypeConverter typeConverter) - { - Widget widgetA = GetChildAtIndex(m_Widget, index - 1); - if (typeConverter.GetWidget() && widgetA) - { - m_Widget.RemoveChild(typeConverter.GetWidget()); - m_Widget.AddChildAfter(typeConverter.GetWidget(), widgetA); - } - } - - override void Swap(int indexA, int indexB) - { - if (indexA == indexB || indexA < 0 || indexB < 0) - return; - - if (indexA > indexB) - { - int temp = indexA; - indexA = indexB; - indexB = temp; - } - - Widget widgetA = GetChildAtIndex(m_Widget, indexA); - Widget widgetB = GetChildAtIndex(m_Widget, indexB); - Widget widgetC = GetChildAtIndex(m_Widget, indexB - 1); - - m_Widget.RemoveChild(widgetA); - m_Widget.AddChildAfter(widgetA, widgetB); - m_Widget.RemoveChild(widgetB); - m_Widget.AddChildAfter(widgetB, widgetC); - } - - override void Clear() - { - Widget widgetA = m_Widget.GetChildren(); - while (widgetA != null) - { - m_Widget.RemoveChild(widgetA); - widgetA = widgetA.GetSibling(); - } - } - - override int Find(TypeConverter typeConverter) - { - Widget widgetA = m_Widget.GetChildren(); - int result; - while (widgetA != null) - { - - if (widgetA == typeConverter.GetWidget()) - { - return result; - } - - widgetA = widgetA.GetSibling(); - result++; - } - - return -1; - } - - override int Count() - { - Widget widgetA = m_Widget.GetChildren(); - int result; - while (widgetA != null) - { - widgetA = widgetA.GetSibling(); - result++; - } - - return result; - } -}; - -class XComboBoxWidgetController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void SetSelection(TypeConverter typeConverter) - { - m_Widget.SetCurrentItem(typeConverter.GetInt()); - } - - override void GetSelection(out TypeConverter typeConverter) - { - typeConverter.SetInt(m_Widget.GetCurrentItem()); - } - - override void Insert(TypeConverter typeConverter) - { - m_Widget.AddItem(typeConverter.GetString()); - } - - override void InsertAt(int index, TypeConverter typeConverter) - { - m_Widget.SetItem(index, typeConverter.GetString()); - } - - override void Replace(int index, TypeConverter typeConverter) - { - InsertAt(index, typeConverter); - } - - override void Remove(int index, TypeConverter typeConverter) - { - m_Widget.RemoveItem(index); - } - - override void Clear() - { - m_Widget.ClearAll(); - } - - override int Count() - { - return m_Widget.GetNumItems(); - } -}; - -class TextListboxController : WidgetControllerTemplate -{ - override bool CanTwoWayBind() - { - return true; - } - - override void SetSelection(TypeConverter typeConverter) - { - for (int i = 0; i < m_Widget.GetNumItems(); i++) - { - string row_text; - m_Widget.GetItemText(i, 0, row_text); - if (row_text == typeConverter.GetString()) - { - m_Widget.SelectRow(i); - return; - } - } - } - - override void GetSelection(out TypeConverter typeConverter) - { - string selection; - m_Widget.GetItemText(m_Widget.GetSelectedRow(), 0, selection); - typeConverter.SetString(selection); - } - - override void Insert(TypeConverter typeConverter) - { - m_Widget.AddItem(typeConverter.GetString(), typeConverter, 0); - } - - override void InsertAt(int index, TypeConverter typeConverter) - { - m_Widget.SetItem(index, typeConverter.GetString(), typeConverter, 0); - } - - override void Remove(int index, TypeConverter typeConverter) - { - m_Widget.SetItem(index, string.Empty, typeConverter, 0); - } - - override void Swap(int indexA, int indexB) - { - string textA, textB; - Class dataA, dataB; - - if (indexA < 0 || indexA > m_Widget.GetNumItems() || indexB < 0 || indexB > m_Widget.GetNumItems()) - { - return; - } - - m_Widget.GetItemText(indexA, 0, textA); - m_Widget.GetItemData(indexA, 0, dataA); - - m_Widget.GetItemText(indexB, 0, textB); - m_Widget.GetItemData(indexB, 0, dataB); - - m_Widget.SetItem(indexB, textA, dataA, 0); - m_Widget.SetItem(indexA, textB, dataB, 0); - } - - override void Clear() - { - m_Widget.ClearItems(); - } - - override int Count() - { - return m_Widget.GetNumItems(); - } -}; - -class ItemPreviewWidgetController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - EntityAI entity; - if (Class.CastTo(entity, typeConverter.GetObject())) - { - m_Widget.SetView(0); - m_Widget.SetItem(entity); - m_Widget.SetModelPosition(vector.Zero); - } - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.Set(m_Widget.GetItem()); - } -}; - -class PlayerPreviewWidgetController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - DayZPlayer player; - if (Class.CastTo(player, typeConverter.GetObject())) - { - m_Widget.SetPlayer(player); - m_Widget.SetModelPosition(vector.Zero); - } - } - - override void Get(out TypeConverter typeConverter) - { - typeConverter.Set(m_Widget.GetDummyPlayer()); - } - - override void SetSelection(TypeConverter typeConverter) - { - m_Widget.UpdateItemInHands(EntityAI.Cast(typeConverter.GetObject())); - } - - override void GetSelection(out TypeConverter typeConverter) - { - DayZPlayer player; - if (Class.CastTo(player, m_Widget.GetDummyPlayer())) - { - typeConverter.SetObject(player.GetHumanInventory().GetEntityInHands()); - } - } -}; - -class HtmlWidgetController : WidgetControllerTemplate -{ - override void Set(TypeConverter typeConverter) - { - m_Widget.SetText(typeConverter.GetString()); - } -}; \ No newline at end of file diff --git a/JM/CF/Scripts/3_Game/CommunityFramework/ObjectManager/ObjectManager.c b/JM/CF/Scripts/3_Game/CommunityFramework/ObjectManager/ObjectManager.c index b019eea4..3e7453c7 100644 --- a/JM/CF/Scripts/3_Game/CommunityFramework/ObjectManager/ObjectManager.c +++ b/JM/CF/Scripts/3_Game/CommunityFramework/ObjectManager/ObjectManager.c @@ -14,6 +14,8 @@ class CF_ObjectManager protected static const ref map m_HiddenObjects = new map(); + protected static const ref array m_HiddenObjectsArray = new array(); + /** * @brief Hides a static map object (Houses, Vegetation, etc.) visually and physically. * @code @@ -38,10 +40,11 @@ class CF_ObjectManager link.flags = object.GetFlags(); link.eventMask = object.GetEventMask(); - object.ClearFlags( link.flags, true ); - object.ClearEventMask( link.eventMask ); + object.ClearFlags(link.flags, true); + object.ClearEventMask(link.eventMask); m_HiddenObjects.Set(object, link); + m_HiddenObjectsArray.Insert(link); vector tm[4]; object.GetTransform(tm); @@ -150,6 +153,9 @@ class CF_ObjectManager if (!link) return NULL; //Object not known as hidden m_HiddenObjects.Remove(object); + + auto arrayIdx = m_HiddenObjectsArray.Find(link); + if(arrayIdx >= 0) m_HiddenObjectsArray.Remove(arrayIdx); vector tm[4]; object.GetTransform(tm); @@ -238,18 +244,18 @@ class CF_ObjectManager */ static array UnhideAllMapObjects(bool updatePathGraph = true) { - array unhidden(); + //Expected result would be all the hidden objects + auto unhidden = GetHiddenMapObjects(); - for (int nObject = 0; nObject < m_HiddenObjects.Count(); nObject++) - { - auto object = m_HiddenObjects.GetKey(nObject); - + for(int nObject = 0; nObject < unhidden.Count(); nObject++) + { //Todo potential improvement -> s. HideMapObjects - if (UnhideMapObject(object, updatePathGraph)) + if (!UnhideMapObject(unhidden[nObject], updatePathGraph)) { - unhidden.Insert(object); + //If - for what ever reason - the object was not unhidden, remove it from the result collection. + unhidden.RemoveOrdered(nObject--); } - } + } return unhidden; } @@ -264,7 +270,14 @@ class CF_ObjectManager */ static array GetHiddenMapObjects() { - return m_HiddenObjects.GetKeyArray(); + array objects(); + + foreach(auto link : m_HiddenObjectsArray) + { + objects.Insert(link.Ptr()); + } + + return objects; } /** @@ -278,7 +291,7 @@ class CF_ObjectManager */ static bool IsMapObjectHidden(Object object) { - return m_HiddenObjects.Contains(object)); + return m_HiddenObjects.Contains(object); } /** @@ -296,7 +309,7 @@ class CF_ObjectManager // Added via p3d in TB with no config. // Inherits from House in Cfg class -> Building, House, Wreck, Well, Tree, Bush, etc. - return ((object.GetType() == string.Empty) && (object.Type() == Object)) || object.IsKindOf("House") || object.IsTree() || object.IsBush(); + return ((object.GetType() == string.Empty) && (object.Type() == Object)) || object.IsKindOf("House") || object.IsTree() || object.IsBush() || object.IsRock(); } /** @@ -309,5 +322,8 @@ class CF_ObjectManager //Cleanup hidden object allocation m_HiddenObjects.Clear(); delete m_HiddenObjects; + + m_HiddenObjectsArray.Clear(); + delete m_HiddenObjectsArray; } } diff --git a/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleMVC.c b/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleMVC.c deleted file mode 100644 index f316d9c5..00000000 --- a/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleMVC.c +++ /dev/null @@ -1,188 +0,0 @@ - -static bool ShowedTutorialMessage; - -class SampleSubSubSubControllerClass -{ - int valueSmile = 25; -} - -class SampleControllerClass -{ - float value = 15; - - ref SampleSubSubSubControllerClass c = new SampleSubSubSubControllerClass(); -} - -// Check JM/CF/GUI/layouts/sample_LayoutBindingManager.layout -class SampleController: Controller -{ - // Properties - float slider_value = 25; // default value will be 25 - float progress_value = 75; // default value will be 75 - - ButtonWidget text_list_add; - ref ObservableCollection observable_list_box = new ObservableCollection(this); - - int counter_left_value = 0; - int counter_right_value = 3; - - void SampleController() - { - // This is just to get you into this file. Ignore it :) - if (!ShowedTutorialMessage) - Workbench.Dialog("Welcome to LayoutBindingManager!", "Check \"SampleController\" class for an example on how to use this utility!"); - - ShowedTutorialMessage = true; - } - - override void PropertyChanged(string property_name) - { - switch (property_name) { - - case "slider_value": { - - // sets progress_value to any value you want - progress_value = Math.AbsFloat(slider_value - 100); - - // MUST be called when changing a property, notifies the UI that something changed! - NotifyPropertyChanged("progress_value"); - break; - } - - case "counter_right_value": { - if (counter_right_value <= 0) { - counter_right_value = 0; - NotifyPropertyChanged("counter_right_value", false); - } - break; - } - - case "counter_left_value": { - if (counter_left_value <= 0) { - counter_left_value = 0; - NotifyPropertyChanged("counter_left_value", false); - } - - break; - } - } - } - - bool SwapItemsExecute(ButtonCommandArgs args) - { - observable_list_box.SwapItems(counter_left_value, counter_right_value); - - return true; - } - - bool LeftCounterIncrementExecute(ButtonCommandArgs args) - { - counter_left_value++; - NotifyPropertyChanged("counter_left_value"); - return true; - } - - bool LeftCounterDecrementExecute(ButtonCommandArgs args) - { - counter_left_value--; - NotifyPropertyChanged("counter_left_value"); - return true; - } - - bool RightCounterIncrementExecute(ButtonCommandArgs args) - { - counter_right_value++; - NotifyPropertyChanged("counter_right_value"); - return true; - } - - bool RightCounterDecrementExecute(ButtonCommandArgs args) - { - counter_right_value--; - NotifyPropertyChanged("counter_right_value"); - return true; - } - - - // You also dont HAVE to use RelayCommands. normal Scripted Events work fine - override bool OnClick(Widget w, int x, int y, int button) - { - if (w == text_list_add) { - observable_list_box.Insert("Hello World! #" + observable_list_box.Count()); - } - - return false; - } -} - -// You can have sub controllers within windows for organization -// they wont interfere with each other -class SampleSubController: Controller -{ - // Note: Selected_Item on CheckBoxWidgets & ButtonWidgets binds the Text of a widget. - bool button_state = true; - bool inverted_button_state = !button_state; - - // Dont use FindAnyWidget - Enfusion will automatically asign it if its the same name as the Widget name - ButtonWidget button; - - // You can also bind do sub properties... using m_SampleControllerClass.sub_value - ref SampleControllerClass m_SampleControllerClass = new SampleControllerClass(); - - int observable_combo_selection; - ref ObservableCollection observable_combo_box = new ObservableCollection(this); - - static const int COLOR_ON = COLOR_GREEN; - static const int COLOR_OFF = COLOR_RED; - - override void OnWidgetScriptInit(Widget w) - { - super.OnWidgetScriptInit(w); - - observable_combo_box.Insert("Item1"); - observable_combo_box.Insert("Item2"); - observable_combo_box.Insert("Item3"); - } - - override void PropertyChanged(string property_name) - { - switch (property_name) - { - case "button_state": { - if (button_state) { - button.SetColor(COLOR_ON); - } else { - button.SetColor(COLOR_OFF); - } - - inverted_button_state = !button_state; - - // Calling false here will NOT call PropertyChanged again - // Otherwise we'd have a stack overflow between button_state and inverted_button_state - NotifyPropertyChanged("inverted_button_state", false); - - break; - } - - case "inverted_button_state": { - - button_state = !inverted_button_state; - NotifyPropertyChanged("button_state"); - break; - } - - - case "observable_combo_selection": { - Print("Combo Box Selection = " + observable_combo_box.Get(observable_combo_selection)); - break; - } - } - } - - bool SampleClassButtonExecute(ButtonCommandArgs args) - { - m_SampleControllerClass.value++; - NotifyPropertyChanged("m_SampleControllerClass.value"); - return true; - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleScriptView.c b/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleScriptView.c deleted file mode 100644 index 2f16d631..00000000 --- a/JM/CF/Scripts/5_Mission/CommunityFramework/GUI/SampleScriptView.c +++ /dev/null @@ -1,39 +0,0 @@ - -// Check JM/CF/GUI/layouts/sample_LayoutBindingManager2.layout -class SampleScriptViewController: Controller -{ - Widget content_host; - ref ObservableCollection script_view = new ObservableCollection(this); -} - -class SampleRelayCommand: RelayCommand -{ - override bool Execute(Class sender, CommandArgs args) - { - Print("SampleRelayCommand Execute!"); - SampleScriptViewController controller = SampleScriptViewController.Cast(m_Controller); - - ButtonCommandArgs commandArgs = ButtonCommandArgs.Cast(args); - if (commandArgs.GetButtonState()) { - controller.script_view.Insert(new SampleScriptView()); - } else { - delete controller.script_view; - controller.script_view = new ObservableCollection(controller); - } - - return true; // We dont want to keep calling up the Execution tree - } -} - - -// This is just a wrapper for JM/CF/GUI/layouts/sample_mvc2.layout -class SampleScriptView: ScriptView -{ - override string GetLayoutFile() { - return "JM/CF/GUI/layouts/sample_mvc.layout"; - } - - override typename GetControllerType() { - return SampleScriptViewController; - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/Data/Credits.json b/JM/CF/Scripts/Data/Credits.json index 4fc6ab5d..2061d051 100644 --- a/JM/CF/Scripts/Data/Credits.json +++ b/JM/CF/Scripts/Data/Credits.json @@ -10,7 +10,8 @@ "Arkensor", "DaOne", "AWOL", - "DirtySanchez" + "DirtySanchez", + "MarioE" ] }, { @@ -18,11 +19,12 @@ "SectionLines": [ "Kegan Hollern", "DannyDog", - "Sumrak", + "Sumrak - Adam Francu", "Epoch Mod Team", "Expansion Mod Team", "GravityWolf", - "wrdg" + "wrdg", + "Steve Aka Salutesh" ] } ] diff --git a/JM/CF/Scripts/Editor/Plugins/CommunityFramework/CreateNewFile.c b/JM/CF/Scripts/Editor/Plugins/CommunityFramework/CreateNewFile.c deleted file mode 100644 index b5ddac38..00000000 --- a/JM/CF/Scripts/Editor/Plugins/CommunityFramework/CreateNewFile.c +++ /dev/null @@ -1,65 +0,0 @@ -[WorkbenchPluginAttribute("New File", "Creates new file", "Ctrl+N", "", {"ScriptEditor"})] -class CreateNewFilePlugin: WorkbenchPlugin -{ - [Attribute("", "editbox", "File Name")] - string FileName; - - string current_file; - string absolute_path; - - override void Run() - { - ScriptEditor module = Workbench.GetModule("ScriptEditor"); - if (!module) { - PluginErrorMessage.Show("Module was null!"); - return; - } - - if (module.GetCurrentFile(current_file) && Workbench.GetAbsolutePath(current_file, absolute_path)) { - - absolute_path.Replace("\\", "/"); - int index = absolute_path.IndexOf("/"); - int last_index = index; - - while (index != -1) { - last_index = index; - index = absolute_path.IndexOfFrom(last_index + 1, "/"); - } - - absolute_path = absolute_path.Substring(0, last_index); - - Workbench.ScriptDialog("Create new file...", "File Name", this); - } - } - - [ButtonAttribute("Create")] - void Create() - { - if (FileName.Length() == 0) { - PluginErrorMessage.Show("File name is empty!"); - return; - } - - TStringArray split_file = {}; - FileName.Split(".", split_file); - if (split_file.Count() != 0) { - FileName += ".c"; - } - - string file = absolute_path + "/" + FileName; - string command = string.Format("cmd /c copy NUL \"%1\"", file); - - - PrintFormat("Creating new file %1", file); - - Workbench.RunCmd(command); - - FileName = string.Empty; - } - - [ButtonAttribute("Cancel")] - void Cancel() - { - FileName = string.Empty; - } -} \ No newline at end of file diff --git a/JM/CF/Scripts/Editor/Plugins/CommunityFramework/MVCManager.c b/JM/CF/Scripts/Editor/Plugins/CommunityFramework/MVCManager.c deleted file mode 100644 index 4f53a2f4..00000000 --- a/JM/CF/Scripts/Editor/Plugins/CommunityFramework/MVCManager.c +++ /dev/null @@ -1,24 +0,0 @@ -[WorkbenchPluginAttribute("LayoutBindingManager Settings", "Edit LayoutBindingManager Settings", "", "", {"ResourceManager", "ScriptEditor"})] -class LayoutBindingManagerPlugin: WorkbenchPlugin -{ - [Attribute("", "combobox", "", "", ParamEnumArray.FromEnum(LogLevel))] - int Log_Level; - - override void Run() - { - Log_Level = LBMLogLevel; - Workbench.ScriptDialog("Edit LayoutBindingManager Settings", "", this); - } - - [ButtonAttribute("OK")] - void DialogOk() - { - LBMLogLevel = Log_Level; - } - - [ButtonAttribute("Cancel")] - void DialogCancel() - { - - } -}; \ No newline at end of file