Skip to content

Instantly share code, notes, and snippets.

@Scrivener07
Created December 21, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Scrivener07/360c6970d159cb802aefc369fb728370 to your computer and use it in GitHub Desktop.
Save Scrivener07/360c6970d159cb802aefc369fb728370 to your computer and use it in GitHub Desktop.
[FO4] MyWidget for HUD Framework
package
{
import flash.display.MovieClip;
import flash.text.TextField;
import hudframework.IHUDWidget;
public class ContextWidget extends MovieClip implements IHUDWidget
{
public var title_tf:TextField;
public var version_tf:TextField;
public var authors_tf:TextField;
private static const WIDGET_IDENTIFIER:String = "ContextWidget.swf";
private static const Command_UpdateTitle:String = "UpdateTitle";
private static const Command_UpdateVersion:String = "UpdateVersion";
private static const Command_UpdateAuthors:int = 100;
public function ContextWidget()
{
super();
}
public function processMessage(command:String, params:Array):void
{
switch(command)
{
case String(Command_UpdateTitle):
title_tf.text = String(params[0]);
break;
case String(Command_UpdateVersion):
version_tf.text = String(params[0]);
break;
case String(Command_UpdateAuthors):
authors_tf.text = String(params[0]);
break;
}
}
}
}
http://i1268.photobucket.com/albums/jj569/Scrivener07/ContextWidget.png
Scriptname FO2287:GasMask:ContextWidget extends ReferenceAlias
import FO2287:Shared:Compatibility
import FO2287:Shared:Log
UserLog Log
HUDFramework HUD
string WidgetID = "ContextWidget.swf" const
string Command_UpdateTitle = "UpdateTitle" const
string Command_UpdateVersion = "UpdateVersion" const
int Command_UpdateAuthors = 100 const
; Events
;---------------------------------------------
Event OnInit()
Log = new UserLog
Log.Caller = self
Log.FileName = Context.Title
EndEvent
Event OnAliasInit()
HUD = HUDFramework.GetInstance()
If (HUD)
HUD.RegisterWidget(self, WidgetID, 10, 70, abLoadNow = true, abAutoLoad = true)
WriteLine(Log, "Registered widget "+WidgetID)
Else
WriteMessage(Log, "HUDFramework is not installed!")
EndIf
EndEvent
Function HUD_WidgetLoaded(string asWidget)
WriteLine(Log, "Loaded widget "+asWidget)
If (asWidget == WidgetID)
Utility.Wait(1)
string sTitle = Context.Title
HUD.SendMessageString(WidgetID, Command_UpdateTitle, sTitle)
WriteLine(Log, "Sent value to widget equals '"+sTitle+"'.")
Utility.Wait(1)
string sVersion = VersionToString(Context.Release)
HUD.SendMessageString(WidgetID, Command_UpdateVersion, sVersion)
WriteLine(Log, "Sent value to widget equals '"+sVersion+"'.")
Utility.Wait(1)
int iAuthorCount = Context.Authors.Length
HUD.SendMessage(WidgetID, Command_UpdateAuthors, iAuthorCount)
WriteLine(Log, "Sent value to widget equals '"+iAuthorCount+"'.")
EndIf
EndFunction
; Properties
;---------------------------------------------
Group Context
FO2287:GasMask:Context Property Context Auto Const Mandatory
EndGroup
[12/20/2016 - 09:32:07PM] Gas Masks of the Wasteland log opened (PC-64)
[12/20/2016 - 09:32:07PM] [FO2287:GasMask:Context <GasMask_Context (0C006381)>] OnQuestInit
[12/20/2016 - 09:32:07PM] [FO2287:GasMask:Context <GasMask_Context (0C006381)>] Gas Masks of the Wasteland is starting..
[12/20/2016 - 09:32:07PM] [FO2287:GasMask:ContextSetup <alias Setup on quest GasMask_Context (0C006381)>] Added a holotape to the player.
[12/20/2016 - 09:32:07PM] [FO2287:GasMask:ContextWidget <alias hud on quest GasMask_Context (0C006381)>] Registered widget ContextWidget.swf
[12/20/2016 - 09:32:07PM] [FO2287:GasMask:ContextWidget <alias hud on quest GasMask_Context (0C006381)>] Loaded widget ContextWidget.swf
[12/20/2016 - 09:32:08PM] [FO2287:GasMask:ContextWidget <alias hud on quest GasMask_Context (0C006381)>] Sent value to widget equals 'Gas Masks of the Wasteland'.
[12/20/2016 - 09:32:21PM] [FO2287:GasMask:ContextWidget <alias hud on quest GasMask_Context (0C006381)>] Sent value to widget equals '1.0.5.0 [DEV]'.
[12/20/2016 - 09:32:23PM] [FO2287:GasMask:ContextWidget <alias hud on quest GasMask_Context (0C006381)>] Sent value to widget equals '4'.
[12/20/2016 - 09:32:59PM] Log closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment