Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
missionloader.c
Go to the documentation of this file.
2{
3 ref TStringArray MissionPaths;
4
5 static JsonMissionLoaderData GetData()
6 {
8
9 string path;
10 string errorMessage;
11
12 if (GetCLIParam("missionLoaderPath", path) == false)
13 {
15 }
16
17 if (!FileExist(path))
18 {
19 DayZGame dzg = GetDayZGame();
20
21 data = new JsonMissionLoaderData();
22 data.MissionPaths = {dzg.GetMissionFolderPath()};
23 if (!JsonFileLoader<JsonMissionLoaderData>.SaveFile(path, data, errorMessage))
24 ErrorEx(errorMessage);
25 }
26 else
27 {
28 if (!JsonFileLoader<JsonMissionLoaderData>.LoadFile(path, data, errorMessage))
29 ErrorEx(errorMessage);
30 }
31
32 return data;
33 }
34}
35
36class MissionLoader : UIScriptedMenu
37{
38
39 protected TextListboxWidget m_WgtLstMsnList;
40 protected ButtonWidget m_WgtBtnMsnPlay;
41 protected ButtonWidget m_WgtBtnMsnClose;
44
45 override Widget Init()
46 {
48
49 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_mission_loader.layout");
50
51 m_WgtLstMsnList = TextListboxWidget.Cast( layoutRoot.FindAnyWidget("wgt_lst_missions") );
52 m_WgtBtnMsnPlay = ButtonWidget.Cast( layoutRoot.FindAnyWidget("wgt_btn_mission_play") );
53 m_WgtBtnMsnClose = ButtonWidget.Cast( layoutRoot.FindAnyWidget("wgt_btn_mission_close") );
54
55 foreach (string path:m_MissionData.MissionPaths)
56 {
57 m_WgtLstMsnList.AddItem(path, NULL, 0);
58 }
59
60 return layoutRoot;
61 }
62
63 override bool OnClick(Widget w, int x, int y, int button)
64 {
65 super.OnClick(w, x, y, button);
66
67 if ( w == m_WgtBtnMsnClose )
68 {
69 Close();
70
71 return true;
72 }
73 else if ( w == m_WgtBtnMsnPlay )
74 {
75 int rowIndex = m_WgtLstMsnList.GetSelectedRow();
76 string missionPath = m_MissionData.MissionPaths.Get(rowIndex);
77 GetGame().PlayMission(missionPath);
78 return true;
79 }
80 return false;
81 }
82
83
84 override bool OnDoubleClick(Widget w, int x, int y, int button)
85 {
86 super.OnClick(w, x, y, button);
87
88 if (w == m_WgtLstMsnList)
89 {
90 int rowIndex = m_WgtLstMsnList.GetSelectedRow();
91 string missionPath = m_MissionData.MissionPaths.Get(rowIndex);
92 GetGame().PlayMission(missionPath);
93 }
94 return false;
95 }
96
97 override bool OnKeyDown(Widget w, int x, int y, int key)
98 {
99 super.OnKeyDown(w,x,y,key);
100 switch (key)
101 {
102 case KeyCode.KC_ESCAPE:
103 {
104 Close();
105 return true;
106 }
107 }
108 return false;
109 }
110
111}
override bool OnKeyDown(Widget w, int x, int y, int key)
override Widget Init()
Definition bookmenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Definition bookmenu.c:34
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame GetDayZGame()
Definition dayzgame.c:3870
proto native CGame GetGame()
const string CFG_FILE_MISSION_LIST
Definition constants.c:250
enum ShapeType ErrorEx
proto bool FileExist(string name)
Check existence of file.
KeyCode
Definition ensystem.c:157
proto bool GetCLIParam(string param, out string val)
Returns command line argument.
Icon x
Icon y
void Close()
override bool OnDoubleClick(Widget w, int x, int y, int button)
ref JsonMissionLoaderData m_MissionData
ButtonWidget m_WgtBtnMsnPlay
ref TStringArray m_ListMissionsNames
ButtonWidget m_WgtBtnMsnClose
class JsonMissionLoaderData m_WgtLstMsnList