GUI : display a window during the game
From AOW HT Wiki
Here is a example of ndf code which allow you to display a window during the game. There is a caption which gives the time since the game started, and a button to refresh the date. There is another button to hide or not the label and the refresh button, and a last one to close the window.
Just copy/paste this code to <GameDirectory>/DataLight/effet/TestModding/test.ndf :
<ndf>
Test is SEQ with
[
TEffetEugDebugWin32 :
Affichage = 'Lancement du test'
,
// This permits to display the frame during the game (do not use it outside a game, in the main menu for example)
~Push_Screen_TechnoTree~ is Template_PushEcran :
Ecran = MyScreen
Modal = True
KeepContext = True
]
//------------------------------------------------------------------------------
DisplayDate is TEUGBBoolean :
Value = True
//------------------------------------------------------------------------------
// Template_DeclarationEcran is the base class for the window
MyScreen is Template_DeclarationEcran :
CalqueLevel = 20 // to display the window above the HUD
Fils = Panel_Fond is Template_NewPanelWithTexture :
Texture = 'aow\data\imtexture\interface\outgame\Panel_options2.TGA'
X = 300
Y = 100
Fils =
[
// The PageControl will permit to refresh the controls in its
// property "ControlParDefaut"
PageControl_Date is Template_PageControl :
ControlParDefaut = Template_NewPanelVideWithFils :
Fils =
[
// Thoses two controls need to be refresh dynamically :
Label_Date,
Button_DisplayOrNotDate
]
,
Button_Refresh,
Button_Cancel,
]
//------------------------------------------------------------------------------
Label_Date is Template_LabelStatique :
Y = 50
X = 0
W = 400
H = 20
AccesseurCaption = TAccesseurStringFormat :
Caption = 'The game started %1 seconds ago'
ParameterList =
[
TAccesseurStringFromReal :
NbDigit = 2
AccesseurReal = TAccesseurDateEnSecondes()
]
LabelApparence = $/typewarrior/AOW_NewFontIngame_Moyenne_Bold_Centered_VerticalCentered
HintApparence = $/lib/menu/hintapparencepasdehint
// The label will be displayed only if DisplayDate = False
HiddenAccesseur = TConditionNot :
SubCondition = DisplayDate
//------------------------------------------------------------------------------
Button_Refresh is Template_BoutonSimple :
X = 50
Y = 150
W = 325
H = 20
Caption = '|REFRESH'
BoutonApparence = $/lib/menu/NAB_AOW_Interface_MenuBoutonBlanc
TextColor = D3DRGBA[0, 0, 0, 255]
// This is used to refresh a pageControl :
EffetClick = Template_EffetResetPageControl :
PageControl = ~/MyScreen/Panel_Fond/PageControl_Date
ToucheRaccourcis = $/defaultconst/vk_escape
HiddenAccesseur = TConditionNot :
SubCondition = DisplayDate
//------------------------------------------------------------------------------
Button_DisplayOrNotDate is Template_BoutonSimple :
X = 50
Y = 200
W = 325
H = 20
// The caption has to change if the boolean changes
AccesseurCaption = TAccesseurStringTestIfTrueOrFalse :
Condition = DisplayDate
AccesseurStringIfTrue = 'Do not display date'
AccesseurStringIfFalse = 'Display date'
BoutonApparence = $/lib/menu/NAB_AOW_Interface_MenuBoutonBlanc
TextColor = D3DRGBA[0, 0, 0, 255]
EffetClick = SEQ with
[
// First we change the boolean variable
DisplayDate := TConditionNot :
SubCondition = DisplayDate
,
// And we refresh the controls to display the correct caption on this button
Template_EffetResetPageControl :
PageControl = ~/MyScreen/Panel_Fond/PageControl_Date
]
ToucheRaccourcis = $/defaultconst/vk_escape
//------------------------------------------------------------------------------
Button_Cancel is Template_BoutonSimple :
X = 50
Y = 250
W = 325
H = 20
Caption = '|CANCEL'
BoutonApparence = $/lib/menu/NAB_AOW_Interface_MenuBoutonBlanc
TextColor = D3DRGBA[0, 0, 0, 255]
// Use this template to close the window
EffetClick = Template_PopEcran :
Modal = True
ToucheRaccourcis = $/defaultconst/vk_escape
</ndf>
