|
1 |
| -// Copyright 2017-2018, Earthfiredrake |
| 1 | +// Copyright 2017-2020, Earthfiredrake |
2 | 2 | // Released under the terms of the MIT License
|
3 | 3 | // https://github.com/Earthfiredrake/SWL-FrameworkMod
|
4 | 4 |
|
5 |
| -// Mod Framework v1.1.2 |
| 5 | +// Mod Framework v1.1.3 |
6 | 6 | // Revision numbers are for internal merge tracking only, and do not require an upgrade notification
|
7 | 7 | // See ConfigManager for notification format for major/minor upgrades
|
8 | 8 |
|
|
35 | 35 | // Config (ConfigManager.as):
|
36 | 36 | // Setting serialization and change notification
|
37 | 37 | // Versioning and upgrade detection
|
38 |
| -// Configuration window |
| 38 | +// Configuration window or DistributedValue exposure for changing settings |
39 | 39 | // Icon (ModIcon.as): Icon display with topbar integration and GEM layout options
|
40 | 40 | // VTIOHelper: Integration with VTIO compatible mod containers and topbars
|
41 | 41 | // Window: Interface window management
|
42 |
| -// AutoReport: Mail based reporting system for errors or other information |
| 42 | +// AutoReport: DEPRECATED Mail based reporting system for errors or other information |
43 | 43 | // Subclass is responsible for:
|
44 | 44 | // Initialization data, including subsystems and their dependencies
|
45 | 45 | // Additional setting definitions
|
@@ -109,14 +109,10 @@ import com.Utils.Signal;
|
109 | 109 | SignalLoadCompleted = new Signal();
|
110 | 110 | SystemsLoaded = { LocalizedText: false };
|
111 | 111 | if (modInfo.Subsystems.Config != undefined) { SystemsLoaded.Config = false; }
|
112 |
| - ModLoadedDV = DistributedValue.Create(ModLoadedVarName); |
113 |
| - ModLoadedDV.SetValue(false); |
114 |
| - ModEnabledDV = DistributedValue.Create(ModEnabledVarName); |
115 |
| - ModEnabledDV.SetValue(undefined); |
116 |
| - ModEnabledDV.SignalChanged.Connect(ModEnabledChanged, this); |
| 112 | + ModLoadedDV = CreateModDV("Loaded", false); |
| 113 | + ModEnabledDV = CreateModDV("Enabled", undefined, ModEnabledChanged, this); |
117 | 114 |
|
118 |
| - ModListDV = DistributedValue.Create("emfListMods"); |
119 |
| - ModListDV.SignalChanged.Connect(ReportVersion, this); |
| 115 | + ModListDV = CreateFrameworkDV("ListMods", false, ReportVersion, this); |
120 | 116 |
|
121 | 117 | LocaleManager.Initialize();
|
122 | 118 | LocaleManager.SignalStringsLoaded.Connect(StringsLoaded, this);
|
@@ -196,7 +192,7 @@ import com.Utils.Signal;
|
196 | 192 | for (var key:String in SystemsLoaded) {
|
197 | 193 | if (!SystemsLoaded[key]) { Debug.ErrorMsg("Missing: " + key, { noHeader : true }); }
|
198 | 194 | }
|
199 |
| - } |
| 195 | + } |
200 | 196 | dv.SetValue(false);
|
201 | 197 | return;
|
202 | 198 | }
|
@@ -238,6 +234,22 @@ import com.Utils.Signal;
|
238 | 234 | if (dv.GetValue()) { dv.SetValue(false); }
|
239 | 235 | }
|
240 | 236 |
|
| 237 | +/// DistributedValue Utility Functions |
| 238 | + public function CreateFrameworkDV(dvName:String, initialValue:Object, callback:Function, callbackContext:Object):DistributedValue { |
| 239 | + return CreateDV("emf" + dvName, initialValue, callback, callbackContext); |
| 240 | + } |
| 241 | + |
| 242 | + public function CreateModDV(dvName:String, initialValue:Object, callback:Function, callbackContext:Object):DistributedValue { |
| 243 | + return CreateDV(DVPrefix + ModName + dvName, initialValue, callback, callbackContext); |
| 244 | + } |
| 245 | + |
| 246 | + public static function CreateDV(dvName:String, initialValue:Object, callback:Function, callbackContext:Object):DistributedValue { |
| 247 | + var dv:DistributedValue = DistributedValue.Create(dvName); |
| 248 | + dv.SetValue(initialValue); |
| 249 | + if (callback != undefined) { dv.SignalChanged.Connect(callback, callbackContext); } |
| 250 | + return dv; |
| 251 | + } |
| 252 | + |
241 | 253 | /// Configuration Settings
|
242 | 254 | private function ConfigLoaded():Void {
|
243 | 255 | Config.SignalValueChanged.Connect(ConfigChanged, this);
|
@@ -345,13 +357,11 @@ import com.Utils.Signal;
|
345 | 357 | public static var DevName:String = "Peloprata";
|
346 | 358 | public static var DVPrefix:String = "efd";
|
347 | 359 |
|
348 |
| - public function get ModLoadedVarName():String { return DVPrefix + ModName + "Loaded"; } |
349 | 360 | public var ModLoadedDV:DistributedValue; // Locks-out interface when mod fails to load, may also be used for basic cross-mod integration
|
350 | 361 | public var SystemsLoaded:Object; // Tracks asynchronous data loads so that functions aren't called without proper data, removed once loading complete
|
351 | 362 | public var FatalError:String;
|
352 | 363 | public var SignalLoadCompleted:Signal;
|
353 | 364 |
|
354 |
| - public function get ModEnabledVarName():String { return DVPrefix + ModName + "Enabled"; } |
355 | 365 | private var ModEnabledDV:DistributedValue; // Doesn't reflect game toggles, only the player or internal mod disabling
|
356 | 366 | private var EnabledByGame:Boolean = false;
|
357 | 367 | private var Enabled:Boolean = false; // PlayerEnabled && GameEnabled
|
|
0 commit comments