diff --git a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.as b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.as index 977865d..f4895a9 100644 --- a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.as +++ b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.as @@ -10,13 +10,12 @@ public function Library() { - Debug.WriteLine("Library", "(ctor)", "Constructor Code"); + Debug.WriteLine("[MCM]", "[Library]", "(ctor)", "Constructor Code"); } public function onLibLoaded(mcmCodeObject:*, f4seCodeObject:*):void { - Debug.WriteLine("Library", "(onLibLoaded)", "MCM scaleform callback has been received."); - f4seCodeObject.SendExternalEvent("ODST_TestEvent"); + Debug.WriteLine("[MCM]", "[Library]", "(onLibLoaded)", "MCM scaleform callback has been received."); Debug.TraceObject(f4seCodeObject); Debug.TraceObject(mcmCodeObject); EmblemPreview.onLibLoaded(mcmCodeObject, f4seCodeObject); diff --git a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.fla b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.fla index e27006a..db7be99 100644 Binary files a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.fla and b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Library.fla differ diff --git a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Preview.as b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Preview.as index defd6ec..4ea8a01 100644 --- a/Data.Prototype/Interface/Source/ODST/ODST/MCM/Preview.as +++ b/Data.Prototype/Interface/Source/ODST/ODST/MCM/Preview.as @@ -3,11 +3,23 @@ import flash.display.MovieClip; import flash.events.Event; import flash.events.IOErrorEvent; + import flash.events.TimerEvent; + import flash.utils.*; import AS3.*; import MCM.*; public class Preview extends MovieClip implements IMCMLibrary { + private var mcm:*; + + private var sEmblem_PreviewPrimary:String; + private var sEmblem_PreviewSecondary:String; + private var sEmblem_PreviewBackground:String; + + private var iEmblem_PreviewPrimaryColor:int; + private var iEmblem_PreviewSecondaryColor:int; + private var iEmblem_PreviewBackgroundColor:int; + public static const MenuName:String = "PauseMenu"; // use root menu? public var PrimaryTexture:TextureLoader; @@ -22,24 +34,83 @@ public function Preview() { - Debug.WriteLine("Preview", "ctor", "Constructor Code", "Hello"); + Debug.WriteLine("[MCM]", "[Preview]", "(ctor)", "Constructor Code"); + // var timer:Timer = new Timer(3000); // rip + // timer.addEventListener(TimerEvent.TIMER, OnTimer); + // timer.start(); } + + // private function OnTimer(e:TimerEvent):void + // { + // Debug.WriteLine("[MCM]", "[Preview]", "OnTimer", e); + // GetModSettings(); + // } + + public function onLibLoaded(mcmCodeObject:*, f4seCodeObject:*):void { - Debug.WriteLine("Preview", "(onLibLoaded)", "MCM scaleform callback has been received."); + Debug.WriteLine("[MCM]", "[Preview]", "(onLibLoaded)", "MCM scaleform callback has been received."); + mcm = mcmCodeObject; - PrimaryTexture.onF4SEObjCreated(f4seCodeObject); - PrimaryTexture.ImageMountID = PrimaryMountID; - PrimaryTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Primary\\Spartan1.dds"); + try + { + PrimaryTexture.onF4SEObjCreated(f4seCodeObject); + PrimaryTexture.ImageMountID = PrimaryMountID; + // PrimaryTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Primary\\Spartan1.dds"); - SecondaryTexture.onF4SEObjCreated(f4seCodeObject); - SecondaryTexture.ImageMountID = SecondaryMountID; - SecondaryTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Secondary\\Spartan2.dds"); + SecondaryTexture.onF4SEObjCreated(f4seCodeObject); + SecondaryTexture.ImageMountID = SecondaryMountID; + // SecondaryTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Secondary\\Spartan2.dds"); - BackgroundTexture.onF4SEObjCreated(f4seCodeObject); - BackgroundTexture.ImageMountID = BackgroundMountID; - BackgroundTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Background\\Shield.dds"); + BackgroundTexture.onF4SEObjCreated(f4seCodeObject); + BackgroundTexture.ImageMountID = BackgroundMountID; + // BackgroundTexture.Load("ProjectHelljumper\\H3ODST\\1Decals\\Decals\\Background\\Shield.dds"); + + } + catch (error:Error) + { + Debug.WriteLine("[MCM]", "[Preview]", "(onLibLoaded)", "ERROR:", error.toString()); + } + + GetModSettings(mcmCodeObject); + } + + + private function GetModSettings(mcmCodeObject:*):void + { + if(mcm != null) + { + try + { + sEmblem_PreviewPrimary = mcm.GetModSettingString("ODST", "sEmblem_PreviewPrimary:Settings"); + sEmblem_PreviewSecondary = mcm.GetModSettingString("ODST", "sEmblem_PreviewSecondary:Settings"); + sEmblem_PreviewBackground = mcm.GetModSettingString("ODST", "sEmblem_PreviewBackground:Settings"); + iEmblem_PreviewPrimaryColor = mcm.GetModSettingInt("ODST", "iEmblem_PreviewPrimaryColor:Settings"); + iEmblem_PreviewSecondaryColor = mcm.GetModSettingInt("ODST", "iEmblem_PreviewSecondaryColor:Settings"); + iEmblem_PreviewBackgroundColor = mcm.GetModSettingInt("ODST", "iEmblem_PreviewBackgroundColor:Settings"); + Debug.WriteLine("[MCM]", "[Preview]", "(GetModSettings) Path", sEmblem_PreviewPrimary, sEmblem_PreviewSecondary, sEmblem_PreviewBackground); + Debug.WriteLine("[MCM]", "[Preview]", "(GetModSettings) Color", String(iEmblem_PreviewPrimaryColor), String(iEmblem_PreviewSecondaryColor), String(iEmblem_PreviewBackgroundColor)); + } + catch (error:Error) + { + Debug.WriteLine("[MCM]", "[Preview]", "(GetModSettings::GetModSetting)", "ERROR:", error.toString()); + } + try + { + PrimaryTexture.Load(sEmblem_PreviewPrimary); + PrimaryTexture.Load(sEmblem_PreviewSecondary); + PrimaryTexture.Load(sEmblem_PreviewBackground); + } + catch (error:Error) + { + Debug.WriteLine("[MCM]", "[Preview]", "(GetModSettings::Load)", "ERROR:", error.toString()); + } + } + else + { + Debug.WriteLine("[MCM]", "[Preview]", "(GetModSettings)", "ERROR: The mcm object is null."); + } } diff --git a/Data.Prototype/Interface/Source/ODST/ODST/MCM/TextureLoader.as b/Data.Prototype/Interface/Source/ODST/ODST/MCM/TextureLoader.as index b1057d3..abdc09f 100644 --- a/Data.Prototype/Interface/Source/ODST/ODST/MCM/TextureLoader.as +++ b/Data.Prototype/Interface/Source/ODST/ODST/MCM/TextureLoader.as @@ -12,7 +12,8 @@ package public dynamic class TextureLoader extends MovieClip implements IExtensions { - public var ImageMountID:String; // must set from Preview.as + public var MenuName:String; + public var ImageMountID:String; private var f4se:*; // Files @@ -39,7 +40,7 @@ package ContentLoader = new Loader(); Info.addEventListener(Event.COMPLETE, this.OnLoadComplete); Info.addEventListener(IOErrorEvent.IO_ERROR, this.OnLoadError); - Debug.WriteLine("[TextureLoader]", "(ctor)", "Constructor Code"); + Debug.WriteLine("[MCM]", "[TextureLoader]", "(ctor)", "Constructor Code"); } @@ -48,11 +49,11 @@ package if(codeObject != null) { f4se = codeObject; - Debug.WriteLine(toString(), "(onF4SEObjCreated)", "Received F4SE code object."); + Debug.WriteLine("[MCM]", toString(), "(onF4SEObjCreated)", "Received F4SE code object."); } else { - Debug.WriteLine(toString(), "(onF4SEObjCreated)", "The f4se object is null."); + Debug.WriteLine("[MCM]", toString(), "(onF4SEObjCreated)", "The f4se object is null."); } } @@ -65,16 +66,16 @@ package Unload(); if(GetTextureExists(filepath)) { - F4SE.Extensions.MountImage(f4se, Preview.MenuName, filepath, ImageMountID); + F4SE.Extensions.MountImage(f4se, MenuName, filepath, ImageMountID); var urlRequest:URLRequest = new URLRequest("img://"+ImageMountID); ContentLoader.load(urlRequest); FilePath = filepath; - Debug.WriteLine(toString(), "(Load)", "'"+urlRequest.url+"' as '"+filepath+"' to "+Preview.MenuName+" with resource ID "+ImageMountID); + Debug.WriteLine("[MCM]", toString(), "(Load)", "'"+urlRequest.url+"' as '"+filepath+"' to "+MenuName+" with resource ID "+ImageMountID); return true; } else { - Debug.WriteLine(toString(), "(Load)", "'"+filepath+"' does not exist."); + Debug.WriteLine("[MCM]", toString(), "(Load)", "'"+filepath+"' does not exist."); return false; } } @@ -89,15 +90,16 @@ package private function OnLoadComplete(e:Event):void { - Debug.WriteLine(toString(), "(OnLoadComplete)", e.toString()+"\n"+toString()); + Debug.WriteLine("[MCM]", toString(), "(OnLoadComplete)", e.toString()+"\n"+toString()); addChild(Content); + Utility.ScaleToHeight(this, 75); this.visible = true; } private function OnLoadError(e:IOErrorEvent):void { - Debug.WriteLine(toString(), "(OnLoadError)", e.toString()+"\n"+toString()); + Debug.WriteLine("[MCM]", toString(), "(OnLoadError)", e.toString()+"\n"+toString()); Unload(); } @@ -111,8 +113,8 @@ package if (FilePath != null) { - F4SE.Extensions.UnmountImage(f4se, Preview.MenuName, FilePath); - Debug.WriteLine(toString(), "(Unload)", "Unmounted the image '"+FilePath+"' from "+Preview.MenuName+" with resource ID "+ImageMountID); + F4SE.Extensions.UnmountImage(f4se, MenuName, FilePath); + Debug.WriteLine("[MCM]", toString(), "(Unload)", "Unmounted the image '"+FilePath+"' from "+MenuName+" with resource ID "+ImageMountID); } if (Content) @@ -120,7 +122,7 @@ package this.visible = false; removeChild(Content); Content.loaderInfo.loader.unload(); - Debug.WriteLine(toString(), "(Unload)", "Unloaded content from loader."); + Debug.WriteLine("[MCM]", toString(), "(Unload)", "Unloaded content from loader."); } } diff --git a/Data.Prototype/MCM/Config/ODST/settings.ini b/Data.Prototype/MCM/Config/ODST/settings.ini index 5145a9a..557c0b3 100644 --- a/Data.Prototype/MCM/Config/ODST/settings.ini +++ b/Data.Prototype/MCM/Config/ODST/settings.ini @@ -1,5 +1,11 @@ [Settings] iEmblem_Selected=0 +sEmblem_PreviewPrimary="" +iEmblem_PreviewPrimaryColor=0 +sEmblem_PreviewSecondary="" +iEmblem_PreviewSecondaryColor=0 +sEmblem_PreviewBackground="" +iEmblem_PreviewBackgroundColor=0 [Emblem001] iEmblem_Foreground=0 diff --git a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Editor.psc b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Editor.psc index 4a382ea..8cc647b 100644 --- a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Editor.psc +++ b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Editor.psc @@ -38,8 +38,11 @@ EndEvent Event OnGameReload() WriteLine(self, "OnGameReload") - Deserialize() - Update() + + If (Deserialize() > Invalid) + Update() + UseMaterial(self, Game.GetPlayer()) + EndIf EndEvent @@ -48,16 +51,10 @@ Event ODST:MCM:Menu.OnMenuState(MCM:Menu sender, var[] arguments) If (arguments) MCM:Menu:MenuStateEventArgs e = sender.GetMenuStateEventArgs(arguments) WriteLine(self, "ODST:MCM:Menu.OnMenuState", e) - If (e.MenuState == sender.MenuOpened) Deserialize() sender.RefreshMenu() EndIf - - ; If (e.MenuState == sender.MenuClosed) - ; ; TODO: Call `Update` here for material change? - ; EndIf - Else WriteUnexpectedValue(self, "ODST:MCM:Menu.OnMenuState", "arguments", "The arguments are none or empty.") EndIf @@ -76,7 +73,7 @@ Event ODST:MCM:Menu.OnOption(MCM:Menu sender, var[] arguments) sender.RefreshMenu() Else Emblems:Preset preset = GetPreset(Selected) - preset.OnChangeValue(ConfigurationMenu, e) + preset.SetValue(ConfigurationMenu, e) Preview.Update(self, preset) Update() sender.RefreshMenu() @@ -116,7 +113,7 @@ Function Update() While (index < Presets.Length) Emblems:Preset preset = Presets[index] preset.Condition = (Selected == preset.Option) - preset.Update(self) + preset.Remap(self) index += 1 EndWhile WriteLine(self, "Update:"+ToString()) @@ -193,7 +190,7 @@ EndFunction bool Function UseMaterial(Emblems:Editor editor, Actor user) Global If (user) - int BipedBody = 3 ; const + int BipedBody = 3 ;const ObjectMod[] omods = user.GetWornItemMods(BipedBody) If (omods) int index = 0 @@ -202,36 +199,47 @@ bool Function UseMaterial(Emblems:Editor editor, Actor user) Global If (omod.GetLooseMod() == editor.miscmod_mod_ODST_Emblems) If (omod) MatSwap material = GetMaterial(omod) - return ApplyMaterial(user, material) + If (material) + user.SetMaterialSwap(Material) + If (user.ApplyMaterialSwap(material)) + WriteLine("[ODST:Emblems:Editor]", "UseMaterial", "Material remapping was successful. "+material.GetRemapData()) + return true + Else + WriteUnexpected("[ODST:Emblems:Editor]", "UseMaterial", "No source/target pairs succeeded in swapping. "+material.GetRemapData()) + return false + EndIf + Else + WriteUnexpectedValue("[ODST:Emblems:Editor]", "UseMaterial", "material", "The value cannot be none.") + return false + EndIf Else - WriteUnexpectedValue("ODST:Emblems:Editor", "UseMaterial", "omod", "The value cannot be none.") + WriteUnexpectedValue("[ODST:Emblems:Editor]", "UseMaterial", "omod", "The value cannot be none.") return false EndIf EndIf - index += 1 EndWhile - WriteUnexpected("ODST:Emblems:Editor", "UseMaterial", "No valid object mod was found.") return false Else - WriteUnexpectedValue("ODST:Emblems:Editor", "UseMaterial", "omods", "The array cannot be none or empty.") + WriteUnexpectedValue("[ODST:Emblems:Editor]", "UseMaterial", "omods", "The array cannot be none or empty.") return false EndIf Else - WriteUnexpectedValue("ODST:Emblems:Editor", "UseMaterial", "user", "The argument Actor cannot be none.") + WriteUnexpectedValue("[ODST:Emblems:Editor]", "UseMaterial", "user", "The argument Actor cannot be none.") return false EndIf EndFunction MatSwap Function GetMaterial(ObjectMod omod) Global + {Gets the material that is applied by an object mod.} ObjectMod:PropertyModifier[] modifiers = omod.GetPropertyModifiers() If (modifiers) int index = 0 While (index < modifiers.Length) MatSwap material = modifiers[index].Object as MatSwap If (material) - WriteLine("ODST:Emblems:Editor", "GetMaterial", "omod:"+omod+", material:"+material) + WriteLine("[ODST:Emblems:Editor]", "GetMaterial", "omod:"+omod+", material:"+material) return material EndIf index += 1 @@ -241,28 +249,6 @@ MatSwap Function GetMaterial(ObjectMod omod) Global EndFunction -bool Function ApplyMaterial(Actor user, MatSwap material) Global - If (user) - If (material) - user.SetMaterialSwap(Material) - If (user.ApplyMaterialSwap(material)) - WriteLine("ODST:Emblems:Editor", "ApplyMaterial", "Material remapping was successful. "+material.GetRemapData()) - return true - Else - WriteUnexpected("ODST:Emblems:Editor", "ApplyMaterial", "No source/target pairs succeeded in swapping. "+material.GetRemapData()) - return false - EndIf - Else - WriteUnexpectedValue("ODST:Emblems:Editor", "ApplyMaterial", "material", "The value cannot be none.") - return false - EndIf - Else - WriteUnexpectedValue("ODST:Emblems:Editor", "ApplyMaterial", "user", "The value cannot be none.") - return false - EndIf -EndFunction - - ; Properties ;--------------------------------------------- diff --git a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preset.psc b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preset.psc index 11bcf92..3684b4c 100644 --- a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preset.psc +++ b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preset.psc @@ -77,7 +77,7 @@ bool Function Deserialize(MCM:Menu sender) EndFunction -bool Function OnChangeValue(MCM:Menu sender, MCM:Menu:OptionEventArgs e) +bool Function SetValue(MCM:Menu sender, MCM:Menu:OptionEventArgs e) {@`Editor` Changes the given preset value.} If (sender) If (e) @@ -116,8 +116,8 @@ bool Function OnChangeValue(MCM:Menu sender, MCM:Menu:OptionEventArgs e) EndFunction -bool Function Update(Emblems:Editor editor) - {@`Editor` Updates the material remappings.} +bool Function Remap(Emblems:Editor editor) + {Remaps the material to the current preset values. This does not provide a visual update.} If (Material) MatSwap:RemapData[] remapping = new MatSwap:RemapData[0] @@ -137,24 +137,23 @@ bool Function Update(Emblems:Editor editor) remapping.Add(remapBackground) string sForeground = editor.Symbol.ForegroundToFolder(Foreground) - string sForegroundColorPrimary = editor.Color.OptionToFolder(ForegroundColorPrimary) - string sForegroundColorSecondary = editor.Color.OptionToFolder(ForegroundColorSecondary) - string sBackground = editor.Symbol.BackgroundToFolder(Background) - string sBackgroundColor = editor.Color.OptionToFolder(BackgroundColor) - If (sForeground != editor.Symbol.Blank) + string sForegroundColorPrimary = editor.Color.OptionToFolder(ForegroundColorPrimary) + string sForegroundColorSecondary = editor.Color.OptionToFolder(ForegroundColorSecondary) remapPrimary.Target = editor.ToMaterialPath(editor.PrimaryLayer, sForegroundColorPrimary, sForeground) remapSecondary.Target = editor.ToMaterialPath(editor.SecondaryLayer, sForegroundColorSecondary, sForeground) EndIf + string sBackground = editor.Symbol.BackgroundToFolder(Background) If (sBackground != editor.Symbol.Blank) + string sBackgroundColor = editor.Color.OptionToFolder(BackgroundColor) remapBackground.Target = editor.ToMaterialPath(editor.BackgroundLayer, sBackgroundColor, sBackground) EndIf Material.SetRemapData(remapping) - UseMaterial(editor, Player) + return true Else - WriteUnexpectedValue(self, "Update", "Material", "The material cannot be none.") + WriteUnexpectedValue(self, "Remap", "Material", "The material cannot be none.") return false EndIf EndFunction diff --git a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preview.psc b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preview.psc index 77e1368..abb98f4 100644 --- a/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preview.psc +++ b/Data.Prototype/Scripts/Source/ODST/ODST/Emblems/Preview.psc @@ -54,7 +54,7 @@ EndEvent ;--------------------------------------------- bool Function Update(Emblems:Editor editor, Emblems:Preset preset) - {@`Editor` Updates the preview user interface.} + {Updates the preview user interface.} string sLayerPrimary = editor.Symbol.ForegroundToFolder(preset.Foreground) string sTexturePathPrimary = editor.ToTexturePath(editor.PrimaryLayer, sLayerPrimary) @@ -62,7 +62,7 @@ bool Function Update(Emblems:Editor editor, Emblems:Preset preset) SetPrimary(sTexturePathPrimary, iColorPrimary) string sTexturePathSecondary = editor.ToTexturePath(editor.SecondaryLayer, sLayerPrimary) - int iColorSecondary =editor.Color.OptionToHex(preset.ForegroundColorSecondary) + int iColorSecondary = editor.Color.OptionToHex(preset.ForegroundColorSecondary) SetSecondary(sTexturePathSecondary, iColorSecondary) string sLayerBackground = editor.Symbol.BackgroundToFolder(preset.Background) @@ -70,6 +70,13 @@ bool Function Update(Emblems:Editor editor, Emblems:Preset preset) int iColorBackground = editor.Color.OptionToHex(preset.BackgroundColor) SetBackground(sTexturePathBackground, iColorBackground) + MCM.SetModSettingString(editor.Properties.PluginName, "sEmblem_PreviewPrimary:Settings", sTexturePathPrimary) + MCM.SetModSettingInt(editor.Properties.PluginName, "iEmblem_PreviewPrimaryColor:Settings", iColorPrimary) + MCM.SetModSettingString(editor.Properties.PluginName, "sEmblem_PreviewSecondary:Settings", sTexturePathSecondary) + MCM.SetModSettingInt(editor.Properties.PluginName, "iEmblem_PreviewSecondaryColor:Settings", iColorSecondary) + MCM.SetModSettingString(editor.Properties.PluginName, "sEmblem_PreviewBackground:Settings", sTexturePathBackground) + MCM.SetModSettingInt(editor.Properties.PluginName, "iEmblem_PreviewBackgroundColor:Settings", iColorBackground) + WriteLine(self, "Update:"+ToString()) EndFunction @@ -192,7 +199,7 @@ EndFunction string Function ToString() - {The string representation of this UI type.} + {The string representation of this type.} return "[Menu:"+Menu+", Asset:"+Asset+", Root:"+Root+"]" EndFunction