From 771ced9f733b6c9d884a899800a06a34bc316cd0 Mon Sep 17 00:00:00 2001 From: Scrivener07 Date: Thu, 14 Mar 2019 03:51:22 -0400 Subject: [PATCH] Various bug fixes and changes. --- Data.Sample.Scouter/Scouter Overlay.esp | 4 +- .../FO4_OverlaySamples/Scouter/Overlay.psc | 38 ++-- Data.Test/Console/EnableVertibirds.txt | 5 + Data.Test/OverlaysTest.esp | 4 +- .../Fallout/OverlaysTest/Events.psc | 48 +++++ .../Overlays/OverlayMenu/OverlayLoader.as | 9 +- .../Overlays/OverlayMenu/OverlayMenu.as | 32 +++- .../Overlays/OverlayMenu/OverlayMenu.fla | 4 +- Data/Interface/Source/FO4_Overlays/Readme.md | 3 +- Data/MCM/Config/Overlays/config.json | 52 +++++- Data/Overlays.esp | 4 +- Data/Overlays.esp.md | 9 + .../FO4_Overlays/Fallout/Overlays/Client.psc | 117 ++++++++++++ .../Fallout/Overlays/Configuration.psc | 67 +++++++ .../Fallout/Overlays/Framework.psc | 176 ++++-------------- .../FO4_Overlays/Fallout/Overlays/Menu.psc | 41 ++-- .../FO4_Overlays/Fallout/Overlays/Papyrus.psc | 9 +- Data/Scripts/Source/FO4_Overlays/Readme.md | 0 18 files changed, 423 insertions(+), 199 deletions(-) create mode 100644 Data.Test/Console/EnableVertibirds.txt create mode 100644 Data.Test/Scripts/Source/FO4_Overlays/Fallout/OverlaysTest/Events.psc create mode 100644 Data/Overlays.esp.md create mode 100644 Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Client.psc create mode 100644 Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Configuration.psc create mode 100644 Data/Scripts/Source/FO4_Overlays/Readme.md diff --git a/Data.Sample.Scouter/Scouter Overlay.esp b/Data.Sample.Scouter/Scouter Overlay.esp index fc059e8..a283bf2 100644 --- a/Data.Sample.Scouter/Scouter Overlay.esp +++ b/Data.Sample.Scouter/Scouter Overlay.esp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78f84489a41f2cb160751fcd207c71ea6955b09995cb79fa8f7ed799bbba8cf0 -size 353 +oid sha256:0d0d89eead7116f75ca1e8dce426c50555dae3c217704f74d2f10f029937fb8b +size 437 diff --git a/Data.Sample.Scouter/Scripts/Source/FO4_OverlaySamples/Scouter/Overlay.psc b/Data.Sample.Scouter/Scripts/Source/FO4_OverlaySamples/Scouter/Overlay.psc index a6ec064..6a16315 100644 --- a/Data.Sample.Scouter/Scripts/Source/FO4_OverlaySamples/Scouter/Overlay.psc +++ b/Data.Sample.Scouter/Scripts/Source/FO4_OverlaySamples/Scouter/Overlay.psc @@ -1,14 +1,14 @@ Scriptname Scouter:Overlay extends Quest {Provides advanced overlay interactions for the scouter.} import Scouter:Log -import Fallout:Overlays:Framework +import Fallout:Overlays:Client Actor Player Armor Scouter -Fallout:Overlays:Framework Framework string TextBox4_Label = "" string TextBox4_Value = "" + string TextBox5_Label = "" string TextBox5_Value = "" @@ -32,18 +32,12 @@ Function OnGameReload() If (Plugin.IsInstalled) Scouter = Plugin.GetArmor(Plugin._R_Scouter) If (Scouter) - Framework = OverlayFramework() - If (Framework) - TextBox4_Label = Framework.GetMember("TextBox4.Label") - TextBox4_Value = Framework.GetMember("TextBox4.Value") - TextBox5_Label = Framework.GetMember("TextBox5.Label") - TextBox5_Value = Framework.GetMember("TextBox5.Value") - Framework.RegisterForOpenCloseEvent(self) - - WriteLine(self, "OnGameReload") - Else - WriteUnexpectedValue(self, "OnGameReload", "Framework", "The script object cannot be none.") - EndIf + TextBox4_Label = Client.GetMember("TextBox4.Label") + TextBox4_Value = Client.GetMember("TextBox4.Value") + TextBox5_Label = Client.GetMember("TextBox5.Label") + TextBox5_Value = Client.GetMember("TextBox5.Value") + Client.RegisterForOpenCloseEvent(self) + WriteLine(self, "OnGameReload") Else WriteUnexpectedValue(self, "OnGameReload", "Scouter", "The Armor cannot be none.") EndIf @@ -53,20 +47,19 @@ Function OnGameReload() EndFunction -Event Fallout:Overlays:Framework.OpenCloseEvent(Fallout:Overlays:Framework sender, var[] arguments) - OpenCloseEventArgs e = sender.GetOpenCloseEventArgs(arguments) +Event Fallout:Overlays:Client.OpenCloseEvent(Fallout:Overlays:Client sender, var[] arguments) + OpenCloseEventArgs e = Client.GetOpenCloseEventArgs(arguments) If (e.Opening) - If (sender.Equipped == Scouter) + If (Client.Equipped == Scouter) WriteLine(self, "Invoking AS3 code on the scouter overlay.") Game:PluginInfo info = Plugin.GetInfo() - sender.Set(TextBox4_Label, "Mod") - sender.Set(TextBox4_Value, info.name+" by "+info.author) - - sender.Set(TextBox5_Label, "Player Level") - sender.Set(TextBox5_Value, "The players level is "+Game.GetPlayerLevel()) + Client.Set(TextBox4_Label, "Mod") + Client.Set(TextBox4_Value, info.name+" by "+info.author) + Client.Set(TextBox5_Label, "Player Level") + Client.Set(TextBox5_Value, "The players level is "+Game.GetPlayerLevel()) Else WriteLine(self, "No scouter item is equipped.") EndIf @@ -78,5 +71,6 @@ EndEvent ;--------------------------------------------- Group Properties + Fallout:Overlays:Client Property Client Auto Const Mandatory Scouter:Plugin Property Plugin Auto Const Mandatory EndGroup diff --git a/Data.Test/Console/EnableVertibirds.txt b/Data.Test/Console/EnableVertibirds.txt new file mode 100644 index 0000000..50fe442 --- /dev/null +++ b/Data.Test/Console/EnableVertibirds.txt @@ -0,0 +1,5 @@ +Set BoSFastTravelCanUse To 1 +Set BoSFastTravelPilot To 1 +PRID 1BBC91 +Enable +Player.AddItem 00056917 20 diff --git a/Data.Test/OverlaysTest.esp b/Data.Test/OverlaysTest.esp index 9e66256..c0cdb44 100644 --- a/Data.Test/OverlaysTest.esp +++ b/Data.Test/OverlaysTest.esp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e77f4e8205ee794e7666bb3d76a7561237c72171a12d31d9dad5a99262190f9 -size 280 +oid sha256:2fb109a0fa8aba3ebfbe28cec18a37e8f0f1acb450d236a31cb794bdef53eff0 +size 312 diff --git a/Data.Test/Scripts/Source/FO4_Overlays/Fallout/OverlaysTest/Events.psc b/Data.Test/Scripts/Source/FO4_Overlays/Fallout/OverlaysTest/Events.psc new file mode 100644 index 0000000..ab7a013 --- /dev/null +++ b/Data.Test/Scripts/Source/FO4_Overlays/Fallout/OverlaysTest/Events.psc @@ -0,0 +1,48 @@ +Scriptname Fallout:OverlaysTest:Events extends Fallout:Overlays:Type DebugOnly +import Fallout:Overlays:Papyrus + +Actor Player + +; Events +;--------------------------------------------- + +Event OnQuestInit() + Player = Game.GetPlayer() + RegisterForRemoteEvent(Player, "OnSit") + ; RegisterForRemoteEvent(Player, "OnGetUp") + RegisterForRemoteEvent(Player, "OnPlayerEnterVertibird") + RegisterForRemoteEvent(Player, "OnRaceSwitchComplete") + RegisterForRemoteEvent(Player, "OnPlayerUseWorkBench") + RegisterForRemoteEvent(Player, "OnPlayerModArmorWeapon") + WriteLine(self, "Registered for remote test events.") +EndEvent + + +Event Actor.OnSit(Actor akSender, ObjectReference akFurniture) + WriteLine(self, "Actor.OnSit", "akSender:"+akSender+", akFurniture:"+akFurniture) +EndEvent + + +; Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture) +; WriteLine(self, "Actor.OnGetUp", "akSender:"+akSender+", akFurniture:"+akFurniture) +; EndEvent + + +Event Actor.OnPlayerEnterVertibird(Actor akSender, ObjectReference akVertibird) + WriteLine(self, "Actor.OnPlayerEnterVertibird", "akSender:"+akSender+", akVertibird:"+akVertibird) +EndEvent + + +Event Actor.OnRaceSwitchComplete(Actor akSender) + WriteLine(self, "Actor.OnRaceSwitchComplete", "akSender:"+akSender) +EndEvent + + +Event Actor.OnPlayerUseWorkBench(Actor akSender, ObjectReference akWorkBench) + WriteLine(self, "Actor.OnPlayerUseWorkBench", "akSender:"+akSender+", akWorkBench:"+akWorkBench) +EndEvent + + +Event Actor.OnPlayerModArmorWeapon(Actor akSender, Form akBaseObject, ObjectMod akModBaseObject) + WriteLine(self, "Actor.OnPlayerModArmorWeapon", "akSender:"+akSender+", akBaseObject:"+akBaseObject+", akModBaseObject:"+akModBaseObject) +EndEvent diff --git a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayLoader.as b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayLoader.as index 483ce24..0001cca 100644 --- a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayLoader.as +++ b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayLoader.as @@ -11,13 +11,8 @@ import System.IO.FileSystem; import System.IO.Path; - /** - * This still wont switch from one overlay to another. - * Unloading the entire menu makes it work. (unequipping) - */ public dynamic class OverlayLoader extends LoaderType { - // Initialize //--------------------------------------------- @@ -53,7 +48,7 @@ path = Path.ChangeExtension(filepath, extension); } - if (extension == File.SWF && File.ExistsIn(XSE, FileSystem.Interface, path)) + if (extension == File.SWF && File.ExistsIn(F4SE, FileSystem.Interface, path)) { Debug.WriteLine("[OverlayLoader]", "Found SWF:", "path:"+path); return super.Load(path); @@ -64,7 +59,7 @@ path = Path.ChangeExtension(filepath, extension); } - if (extension == File.DDS && File.ExistsIn(XSE, FileSystem.Textures, path)) + if (extension == File.DDS && File.ExistsIn(F4SE, FileSystem.Textures, path)) { Debug.WriteLine("[OverlayLoader]", "Found DDS:", "path:"+path); return super.Load(path); diff --git a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.as b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.as index 3b8481b..756cedb 100644 --- a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.as +++ b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.as @@ -1,14 +1,24 @@ package { + import com.greensock.*; + import com.greensock.easing.*; + import F4SE.ICodeObject; import flash.display.MovieClip; import System.Diagnostics.Debug; - public class OverlayMenu extends MovieClip + // TODO: Expose the "Client" string variable path to papyrus. + + public class OverlayMenu extends MovieClip implements F4SE.ICodeObject { + // Stage + public var Controller:MovieClip; + + // Loader private var Overlay:OverlayLoader; private const Name:String = "OverlayMenu"; private const MountID:String = "OverlayMenu_ImageMount"; + // Properties public function get Visible():Boolean { return this.visible; } public function set Visible(value:Boolean):void { this.visible = value; } @@ -23,20 +33,34 @@ { System.Diagnostics.Debug.Prefix = "Overlay Framework"; Overlay = new OverlayLoader(Name, MountID); - this.addChild(Overlay); + Controller.addChild(Overlay); Debug.WriteLine("[OverlayMenu]", "(ctor)", "Constructor Code", this.loaderInfo.url); } + // @F4SE.ICodeObject + public function onF4SEObjCreated(codeObject:*):void + { + Overlay.onF4SEObjCreated(codeObject); + } + + // Methods //--------------------------------------------- - public function SetURI(filepath:String):void + public function Load(filepath:String):void { - Debug.WriteLine("[OverlayMenu]", "(SetURI)", "Setting the filepath to '"+filepath+"'"); + Debug.WriteLine("[OverlayMenu]", "(Load)", "Setting the filepath to '"+filepath+"'."); Overlay.Load(filepath); } + public function AlphaTo(value:Number, duration:Number):void + { + Debug.WriteLine("[OverlayMenu]", "(AlphaTo)", "Alpha is tweening from "+alpha+" to "+value+" over "+duration+" seconds."); + TweenMax.to(Controller, duration, {alpha:value}); + } + + } } diff --git a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.fla b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.fla index 89e2c9a..f4037fc 100644 --- a/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.fla +++ b/Data/Interface/Source/FO4_Overlays/Overlays/OverlayMenu/OverlayMenu.fla @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f7c324409f6aa9c3380694eee43f9cfa96268f14b3ad6d71c7742d7c8fc4edb1 -size 400026 +oid sha256:65f0e6bfd72392d7a086d0e8808a6fa375551ca6318d42bdd3e2cd486f16de24 +size 400773 diff --git a/Data/Interface/Source/FO4_Overlays/Readme.md b/Data/Interface/Source/FO4_Overlays/Readme.md index 9fb5ee1..e9f9557 100644 --- a/Data/Interface/Source/FO4_Overlays/Readme.md +++ b/Data/Interface/Source/FO4_Overlays/Readme.md @@ -1,3 +1,4 @@ # Fallout 4 Overlays - This is the root package directory for AS3 imports. + +This library uses an external package [UI Library #c37b191ae21e1a392850a736ed2b09263c577dee](https://github.com/Scrivener07/FO4_Scripting/tree/c37b191ae21e1a392850a736ed2b09263c577dee/Data.UI.Library/Interface/Source/Fallout_Library) diff --git a/Data/MCM/Config/Overlays/config.json b/Data/MCM/Config/Overlays/config.json index 9de7b08..846bfd3 100644 --- a/Data/MCM/Config/Overlays/config.json +++ b/Data/MCM/Config/Overlays/config.json @@ -5,15 +5,15 @@ "content": [ { - "text": "Opacity", + "text": "Transparency", "type": "slider", "help": "Applies transparency to overlays. Range: 0-1, Step: 0.01.", "valueOptions": { "sourceType": "GlobalValue", - "form": "Overlays.esp|5B95", - "min": 0, - "max": 1, + "sourceForm": "Overlays.esp|5B95", + "min": 0.0, + "max": 1.0, "step": 0.01 }, "action": @@ -22,7 +22,49 @@ "form": "Overlays.esp|F99", "function": "SetAlpha", "params": ["{value}"], - "scriptName": "Fallout:Overlays:Menu" + "scriptName": "Fallout:Overlays:Configuration" + } + }, + { + "text": "Transparency Transition Duration", + "type": "slider", + "help": "Transitions the overlay transparency over the given duration in seconds. Range: 0-10, Step: 0.25.", + "valueOptions": + { + "sourceType": "GlobalValue", + "sourceForm": "Overlays.esp|632F", + "min": 0.0, + "max": 5.0, + "step": 0.25 + }, + "action": + { + "type": "CallFunction", + "form": "Overlays.esp|F99", + "function": "SetScopeAlpha", + "params": ["{value}"], + "scriptName": "Fallout:Overlays:Configuration" + } + }, + { + "text": "Scope Menu - Transparency", + "type": "slider", + "help": "Applies transparency to overlays when zoomed in the scope menu. Range: 0-1, Step: 0.01.", + "valueOptions": + { + "sourceType": "GlobalValue", + "sourceForm": "Overlays.esp|7263", + "min": 0.0, + "max": 1.0, + "step": 0.01 + }, + "action": + { + "type": "CallFunction", + "form": "Overlays.esp|F99", + "function": "SetScopeAlpha", + "params": ["{value}"], + "scriptName": "Fallout:Overlays:Configuration" } } ] diff --git a/Data/Overlays.esp b/Data/Overlays.esp index cda4031..ce61d6f 100644 --- a/Data/Overlays.esp +++ b/Data/Overlays.esp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5799557bc8010ee2144d1b77faf0d0da9470b636fb96caa972acbde4b3e7ea14 -size 555 +oid sha256:6aebe96ed70800f7b2716078dca4f40d4dd389d4e26356e7d62f5ccc7e096ad3 +size 944 diff --git a/Data/Overlays.esp.md b/Data/Overlays.esp.md new file mode 100644 index 0000000..65d1b3a --- /dev/null +++ b/Data/Overlays.esp.md @@ -0,0 +1,9 @@ +``` +GLOB + 01005B95 Fallout_Overlays_Alpha + 0100632F Fallout_Overlays_AlphaSpeed + 01007263 Fallout_Overlays_Scope_Alpha + +QUST + 01000F99 Fallout_Overlays +``` diff --git a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Client.psc b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Client.psc new file mode 100644 index 0000000..0b5b112 --- /dev/null +++ b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Client.psc @@ -0,0 +1,117 @@ +Scriptname Fallout:Overlays:Client extends Fallout:Overlays:Type +import Fallout +import Fallout:Overlays +import Fallout:Overlays:Papyrus + +Actor Player +int BipedEyes = 17 const +bool ThirdPerson = false const + + +; Events +;--------------------------------------------- + +Event OnQuestInit() + Player = Game.GetPlayer() +EndEvent + + +; Methods +;--------------------------------------------- + +Actor:WornItem Function GetWorn() + {Scans down the highest slot of an eye slot item.} + int slot = 0 + While (slot <= BipedEyes) + Actor:WornItem worn = Player.GetWornItem(slot, ThirdPerson) + If (Framework.ItemFilter(worn.Item)) + return worn + EndIf + slot += 1 + EndWhile + WriteUnexpectedValue(self, "GetWorn", "value", "No biped slot has a valid eyes item.") + return none +EndFunction + + +string Function GetMember(string member) + {Provides instance member paths the client.} + If (member) + return Menu.GetClientMember(member) + Else + WriteUnexpectedValue(self, "GetMember", "member", "The value cannot be none or empty.") + return "" + EndIf +EndFunction + + +var Function Get(string member) + return UI.Get(Menu.Name, member) +EndFunction + + +bool Function Set(string member, var argument) + return UI.Set(Menu.Name, member, argument) +EndFunction + + +var Function Invoke(string member, var[] arguments = none) + return UI.Invoke(Menu.Name, member, arguments) +EndFunction + + +; Open/Close Event +;--------------------------------------------- + +CustomEvent OpenCloseEvent + +Struct OpenCloseEventArgs + bool Opening = false +EndStruct + + +bool Function RegisterForOpenCloseEvent(ScriptObject script) + If (script) + script.RegisterForCustomEvent(self, "OpenCloseEvent") + return true + Else + WriteUnexpectedValue(self, "RegisterForOpenCloseEvent", "script", "Cannot register a none script for events.") + return false + EndIf +EndFunction + + +bool Function UnregisterForOpenCloseEvent(ScriptObject script) + If (script) + script.UnregisterForCustomEvent(self, "OpenCloseEvent") + return true + Else + WriteUnexpectedValue(self, "UnregisterForOpenCloseEvent", "script", "Cannot unregister a none script for events.") + return false + EndIf +EndFunction + + +OpenCloseEventArgs Function GetOpenCloseEventArgs(var[] arguments) + If (arguments) + return arguments[0] as OpenCloseEventArgs + Else + return none + EndIf +EndFunction + + +; Properties +;--------------------------------------------- + +Group Overlay + Fallout:Overlays:Framework Property Framework Auto Const Mandatory + Fallout:Overlays:Menu Property Menu Auto Const Mandatory +EndGroup + +Armor Property Equipped Hidden + {Returns the equipped eyes item.} + Armor Function Get() + return GetWorn().Item as Armor + EndFunction +EndProperty diff --git a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Configuration.psc b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Configuration.psc new file mode 100644 index 0000000..1a0e979 --- /dev/null +++ b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Configuration.psc @@ -0,0 +1,67 @@ +Scriptname Fallout:Overlays:Configuration extends Fallout:Overlays:Type +import Fallout +import Fallout:Overlays +import Fallout:Overlays:Papyrus + +; Methods +;--------------------------------------------- + +Function SetAlpha(float value) + Fallout_Overlays_Alpha.SetValue(value) + If (Menu.IsOpen) + Menu.SetAlpha(value) + EndIf + WriteLine(self, "SetAlpha", value) +EndFunction + + +Function SetAlphaSpeed(float value) + Fallout_Overlays_AlphaSpeed.SetValue(value) + WriteLine(self, "SetAlphaSpeed", value) +EndFunction + + +Function SetScopeAlpha(float value) + Fallout_Overlays_Scope_Alpha.SetValue(value) + WriteLine(self, "SetScopeAlpha", value) +EndFunction + + +; Properties +;--------------------------------------------- + +Group Properties + Overlays:Menu Property Menu Auto Const Mandatory + GlobalVariable Property Fallout_Overlays_Alpha Auto Const Mandatory + GlobalVariable Property Fallout_Overlays_AlphaSpeed Auto Const Mandatory + GlobalVariable Property Fallout_Overlays_Scope_Alpha Auto Const Mandatory +EndGroup + +Group Settings + float Property Alpha Hidden + float Function Get() + return Fallout_Overlays_Alpha.GetValue() + EndFunction + Function Set(float value) + Fallout_Overlays_Alpha.SetValue(value) + EndFunction + EndProperty + + float Property AlphaSpeed Hidden + float Function Get() + return Fallout_Overlays_AlphaSpeed.GetValue() + EndFunction + Function Set(float value) + Fallout_Overlays_AlphaSpeed.SetValue(value) + EndFunction + EndProperty + + float Property ScopeAlpha Hidden + float Function Get() + return Fallout_Overlays_Scope_Alpha.GetValue() + EndFunction + Function Set(float value) + Fallout_Overlays_Scope_Alpha.SetValue(value) + EndFunction + EndProperty +EndGroup diff --git a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Framework.psc b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Framework.psc index db0070f..5dc7eef 100644 --- a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Framework.psc +++ b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Framework.psc @@ -1,34 +1,27 @@ Scriptname Fallout:Overlays:Framework extends Fallout:Overlays:Type import Fallout import Fallout:Overlays +import Fallout:Overlays:Client import Fallout:Overlays:Papyrus -;| Slot | Hexadecimal | Decimal | -;|------------------------------| -;| 30 | 0x00000001 | 1 | -;| 47 | 0x00020000 | 131072 | - Actor Player ;--------------------------------------------- -string URI +string File string EquippedState = "Equipped" const ;--------------------------------------------- int Invalid = -1 const int BipedEyes = 17 const bool ThirdPerson = false const - +;--------------------------------------------- string ExamineMenu = "ExamineMenu" const +string ScopeMenu = "ScopeMenu" const ; Events ;--------------------------------------------- -Event OnInit() - Player = Game.GetPlayer() -EndEvent - - Event OnQuestInit() + Player = Game.GetPlayer() RegisterForRemoteEvent(Player, "OnItemEquipped") RegisterForRemoteEvent(Player, "OnItemUnequipped") EndEvent @@ -68,7 +61,7 @@ EndFunction bool Function Equipment() - string value = GetURI() + string value = GetFile() If (value) ; Do not allow a change to none/empty value. A none value is valid for TryChange. If (TryChange(value)) return ChangeState(self, EquippedState) @@ -81,8 +74,8 @@ bool Function Equipment() EndFunction -string Function GetURI() - {Gets the URI string for any eye slot armor.} +string Function GetFile() + {Gets the file path for any eye slot armor.} ; #1 Check the Armor's ObjectMods for any associated loose mod with an icon path. ; #2 Check the Armor's world model path. ; #3 Check the Armor's model path. @@ -97,7 +90,7 @@ string Function GetURI() While (index < mods.Length) value = GetLooseMod(mods[index]) If (value) - WriteLine(self, "GetURI", "LooseMod:'"+value+"'") + WriteLine(self, "GetFile", "LooseMod:'"+value+"'") return value EndIf index += 1 @@ -106,11 +99,11 @@ string Function GetURI() ;--------------------------------------------- value = GetWorldModel(worn) If (value) - WriteLine(self, "GetURI", "WorldModel:'"+value+"'") + WriteLine(self, "GetFile", "WorldModel:'"+value+"'") return value Else value = GetModel(worn) - WriteLine(self, "GetURI", "Model:'"+value+"'") + WriteLine(self, "GetFile", "Model:'"+value+"'") return value EndIf EndIf @@ -150,80 +143,17 @@ EndFunction bool Function TryChange(string value) - If (value != URI) - WriteChangedValue(self, "URI", URI, value) - URI = value + If (value != File) + WriteChangedValue(self, "File", File, value) + File = value return true Else - WriteUnexpectedValue(self, "TryChange", "value", "The URI already equals '"+value+"'") + WriteUnexpectedValue(self, "TryChange", "value", "The File already equals '"+value+"'") return false EndIf EndFunction -; Client API -;--------------------------------------------- - -; UNUSED -Armor Property Equipped Hidden - {Returns the equipped eyes item. This may be performance heavy?} - Armor Function Get() - return GetWorn().Item as Armor - EndFunction -EndProperty - - -; UNUSED -Actor:WornItem Function GetWorn() - {Scans down the highest slot of an eye slot item.} - int slot = 0 - While (slot <= BipedEyes) - Actor:WornItem worn = Player.GetWornItem(slot, ThirdPerson) - If (ItemFilter(worn.Item)) - return worn - EndIf - slot += 1 - EndWhile - WriteUnexpectedValue(self, "GetWorn", "value", "No biped slot has a valid eyes item.") - return none -EndFunction - -;--------------------------------------------- - -string Function GetMember(string member) - {Provides instance member paths the client.} - If (member) - return Menu.GetClientMember(member) - Else - WriteUnexpectedValue(self, "GetMember", "member", "The value cannot be none or empty.") - return "" - EndIf -EndFunction - - -var Function Get(string menuName, string member) - return UI.Get(Menu.Name, member) -EndFunction - - -bool Function Set(string member, var argument) - return UI.Set(Menu.Name, member, argument) -EndFunction - - -var Function Invoke(string member, var[] arguments = none) - return UI.Invoke(Menu.Name, member, arguments) -EndFunction - - -; Globals -;--------------------------------------------- - -Overlays:Framework Function OverlayFramework() Global - return Game.GetFormFromFile(0x00000F99, "Overlays.esp") as Overlays:Framework -EndFunction - - ; States ;--------------------------------------------- @@ -232,6 +162,8 @@ State Equipped WriteLine(self, "Equipped.OnBeginState") RegisterForCameraState() RegisterForMenuOpenCloseEvent(Menu.Name) + RegisterForMenuOpenCloseEvent(ExamineMenu) + RegisterForMenuOpenCloseEvent(ScopeMenu) RegisterForGameReload(self) Menu.Open() EndEvent @@ -247,25 +179,32 @@ State Equipped WriteLine(self, "Equipped.OnMenuOpenCloseEvent(menuName="+menuName+", opening="+opening+")") If (menuName == Menu.Name) If (opening) - Menu.SetURI(URI) - Menu.SetAlpha(Fallout_Overlays_Alpha.GetValue()) + Menu.Load(File) + Menu.SetAlpha(Configuration.Alpha) Menu.SetVisible(IsFirstPerson) Else Menu.Open() EndIf - OpenCloseEventArgs e = new OpenCloseEventArgs e.Opening = opening - self.SendOpenCloseEvent(e) + SendOpenCloseEvent(e) + EndIf + + If (menuName == ScopeMenu) + If (opening) + Menu.AlphaTo(Configuration.ScopeAlpha, Configuration.AlphaSpeed) + Else + Menu.AlphaTo(Configuration.Alpha, Configuration.AlphaSpeed) + EndIf EndIf If (menuName == ExamineMenu && !opening) - Menu.SetURI(URI) - EndIF + Menu.Load(File) + EndIf EndEvent Event OnPlayerCameraState(int oldState, int newState) - WriteLine(self, "Equipped.OnPlayerCameraState(oldState="+oldState+", newState="+newState+")") + WriteLine(self, "Equipped.OnPlayerCameraState(oldState="+oldState+", newState="+newState+") -- IsFirstPerson:"+IsFirstPerson) Menu.SetVisible(IsFirstPerson) EndEvent @@ -286,12 +225,12 @@ State Equipped EndEvent bool Function Equipment() - string value = GetURI() + string value = GetFile() If (TryChange(value)) ; ALLOW a change to none/empty If (!value) return ClearState(self) Else - return Menu.SetURI(URI) + return Menu.Load(File) EndIf Else return false @@ -310,54 +249,16 @@ State Equipped EndState -; Open/Close Event +; Client ;--------------------------------------------- -CustomEvent OpenCloseEvent - -Struct OpenCloseEventArgs - bool Opening = false -EndStruct - - Function SendOpenCloseEvent(OpenCloseEventArgs e) If (e) var[] arguments = new var[1] arguments[0] = e - self.SendCustomEvent("OpenCloseEvent", arguments) - Else - WriteLine(self, "SendOpenCloseEvent : e : Cannot be none.") - EndIf -EndFunction - - -bool Function RegisterForOpenCloseEvent(ScriptObject script) - If (script) - script.RegisterForCustomEvent(self, "OpenCloseEvent") - return true - Else - WriteLine(self, "RegisterForOpenCloseEvent : script : Cannot register a none script for events.") - return false - EndIf -EndFunction - - -bool Function UnregisterForOpenCloseEvent(ScriptObject script) - If (script) - script.UnregisterForCustomEvent(self, "OpenCloseEvent") - return true - Else - WriteLine(self, "UnregisterForOpenCloseEvent : script : Cannot unregister a none script for events.") - return false - EndIf -EndFunction - - -OpenCloseEventArgs Function GetOpenCloseEventArgs(var[] arguments) - If (arguments) - return arguments[0] as OpenCloseEventArgs + Client.SendCustomEvent("OpenCloseEvent", arguments) Else - return none + WriteUnexpectedValue(self, "SendOpenCloseEvent", "e", "The argument cannot be none.") EndIf EndFunction @@ -367,17 +268,18 @@ EndFunction Group Properties Keyword Property ArmorBodyPartEyes Auto Const Mandatory - GlobalVariable Property Fallout_Overlays_Alpha Auto Const Mandatory EndGroup Group Overlay Overlays:Menu Property Menu Auto Const Mandatory + Overlays:Client Property Client Auto Const Mandatory + Overlays:Configuration Property Configuration Auto Const Mandatory EndGroup Group Camera bool Property IsFirstPerson Hidden bool Function Get() - return Player.GetAnimationVariableBool("IsFirstPerson") + return Game.GetCameraState() == 0 EndFunction EndProperty EndGroup diff --git a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Menu.psc b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Menu.psc index 7730266..18da933 100644 --- a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Menu.psc +++ b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Menu.psc @@ -57,6 +57,25 @@ bool Function Close() EndFunction +bool Function Load(string value) + If (IsOpen) + If (value) + var[] arguments = new var[1] + arguments[0] = value + UI.Invoke(Name, GetMember("Load"), arguments) + WriteLine(self, "Load:"+value) + return true + Else + WriteUnexpectedValue(self, "Load", "value", "The value cannot be none or empty.") + return false + EndIf + Else + WriteUnexpected(self, "Load", ToString()+" is not open.") + return false + EndIf +EndFunction + + bool Function GetVisible() If (IsOpen) return UI.Get(Name, GetMember("Visible")) as bool @@ -88,20 +107,16 @@ bool Function SetAlpha(float value) EndFunction -bool Function SetURI(string value) +bool Function AlphaTo(float value, float duration) If (IsOpen) - If (value) - var[] arguments = new var[1] - arguments[0] = value - UI.Invoke(Name, GetMember("SetURI"), arguments) - WriteLine(self, "SetURI:"+value) - return true - Else - WriteUnexpectedValue(self, "SetURI", "value", "The value cannot be none or empty.") - return false - EndIf + var[] arguments = new var[2] + arguments[0] = value + arguments[1] = duration + UI.Invoke(Name, GetMember("AlphaTo"), arguments) + WriteLine(self, "AlphaTo", "value:"+value+", duration:"+duration) + return true Else - WriteUnexpected(self, "SetURI", ToString()+" is not open.") + WriteUnexpected(self, "AlphaTo", ToString()+" is not open.") return false EndIf EndFunction @@ -168,7 +183,7 @@ Group Properties string Property Client Hidden string Function Get() {The instance path of the client's display object.} - ; This will change if any display objects are added or removed in the Flash editor. + ; TODO: This will change if any display objects are added or removed in the Flash editor. return "Overlay.instance3" EndFunction EndProperty diff --git a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Papyrus.psc b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Papyrus.psc index 2fbf140..91a65ba 100644 --- a/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Papyrus.psc +++ b/Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Papyrus.psc @@ -3,9 +3,9 @@ ScriptName Fallout:Overlays:Papyrus Const Native Hidden ; Logging ;--------------------------------------------- -; Writes messages as lines in a log file. bool Function Write(string prefix, string text) Global DebugOnly + {Writes text as lines in a log file.} string filename = "Overlays" const text = prefix + " " + text If(Debug.TraceUser(filename, text)) @@ -18,12 +18,14 @@ EndFunction bool Function WriteNotification(string prefix, string text) Global DebugOnly + {Writes notifications as lines in a log file.} Debug.Notification(text) return Write(prefix, text) EndFunction bool Function WriteMessage(string prefix, string title, string text = "") Global DebugOnly + {Writes messages as lines in a log file.} string value If (text) value = title+"\n"+text @@ -35,9 +37,9 @@ EndFunction ; Debug ;--------------------------------------------- -; Writes script messages as lines in a log file. bool Function WriteLine(var script, string member, string text = "") Global DebugOnly + {Writes script info as lines in a log file.} If !(text) return Write(script, member) Else @@ -47,11 +49,13 @@ EndFunction bool Function WriteUnexpected(var script, string member, string text = "") Global DebugOnly + {The script had an unexpected operation.} return Write(script+"["+member+"]", "The member '"+member+"' had an unexpected operation. "+text) EndFunction bool Function WriteUnexpectedValue(var script, string member, string variable, string text = "") Global DebugOnly + {The script had and unexpected value.} return Write(script+"["+member+"."+variable+"]", "The member '"+member+"' with variable '"+variable+"' had an unexpected operation. "+text) EndFunction @@ -64,6 +68,7 @@ EndFunction Function WriteChangedValue(var script, string propertyName, var fromValue, var toValue) Global DebugOnly + {The value has changed from one value to another.} WriteLine(script, "Changing '"+propertyName+"' from '"+fromValue+"' to '"+toValue+"'.") EndFunction diff --git a/Data/Scripts/Source/FO4_Overlays/Readme.md b/Data/Scripts/Source/FO4_Overlays/Readme.md new file mode 100644 index 0000000..e69de29