DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
InviteMenu.c
Go to the documentation of this file.
1class InviteMenu extends UIScriptedMenu
2{
5 private int m_iTime;
6
7 void InviteMenu()
8 {
9 m_iTime = 15;
10 }
11
12 override Widget Init()
13 {
14 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_invite_dialog.layout");
15
16 m_LogoutTimetext = TextWidget.Cast(layoutRoot.FindAnyWidget("logoutTimeText"));
17 m_Info = TextWidget.Cast(layoutRoot.FindAnyWidget("txtInfo"));
18 m_LogoutTimetext.SetText(m_iTime.ToString());
19
20 layoutRoot.FindAnyWidget("toolbar_bg").Show(true);
21 RichTextWidget toolbar_b = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
22 toolbar_b.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
23
24 // player should sit down if possible
25 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
26 if (player && player.GetEmoteManager() && !player.IsRestrained() && !player.IsUnconscious())
27 {
28 player.GetEmoteManager().CreateEmoteCBFromMenu(EmoteConstants.ID_EMOTE_SITA);
29 player.GetEmoteManager().GetEmoteLauncher().SetForced(EmoteLauncher.FORCE_DIFFERENT);
30 }
31
32 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(UpdateTime, 1000, true);
33 return layoutRoot;
34 }
35
36 override void OnShow()
37 {
38 super.OnShow();
39 }
40
41 override void Update(float timeslice)
42 {
43 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
44 {
45 Cancel();
46 Close();
47 }
48
49 if (m_iTime <= 0)
50 {
52 string ip;
53 int port;
55 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(g_Game.ConnectFromJoin, ip, port);
56 //Close();
57 }
58 }
59
61 {
62 if (m_iTime > 0)
63 {
64 m_iTime -= 1;
65 m_LogoutTimetext.SetText(m_iTime.ToString());
66 }
67 }
68
69 void Cancel()
70 {
72
73 g_Game.SetGameState(DayZGameState.IN_GAME);
74 g_Game.SetLoadState(DayZLoadState.CONNECT_CONTROLLER_SELECT);
75 Close();
76 }
77}
DayZGame g_Game
Definition DayZGame.c:3654
void Close()
PlayerBase GetPlayer()
proto native UAInputAPI GetUApi()
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
proto native WorkspaceWidget GetWorkspace()
static const int FORCE_DIFFERENT
static const float ICON_SCALE_TOOLBAR
Definition InputUtils.c:15
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition InputUtils.c:167
static void GetInviteServerInfo(out string ip, out int port)
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void Remove(func fn)
remove specific call from queue
private int m_iTime
Definition InviteMenu.c:5
override void Update(float timeslice)
Definition InviteMenu.c:41
override void OnShow()
Definition InviteMenu.c:36
private TextWidget m_Info
Definition InviteMenu.c:4
void UpdateTime()
Definition InviteMenu.c:60
override Widget Init()
Definition InviteMenu.c:12
private TextWidget m_LogoutTimetext
Definition InviteMenu.c:3
void InviteMenu()
Definition InviteMenu.c:7
proto native CGame GetGame()
const int ID_EMOTE_SITA
Definition constants.c:347
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.