Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
36 class 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 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
Init
override Widget Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: missionloader.c:45
GetCLIParam
proto bool GetCLIParam(string param, out string val)
Returns command line argument.
OnKeyDown
override bool OnKeyDown(Widget w, int x, int y, int key)
Definition: missionloader.c:97
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
KeyCode
KeyCode
Definition: ensystem.c:156
Close
void Close()
y
Icon y
FileExist
proto bool FileExist(string name)
Check existence of file.
OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition: missionloader.c:63
m_MissionData
protected ref JsonMissionLoaderData m_MissionData
Definition: missionloader.c:43
ErrorEx
enum ShapeType ErrorEx
OnDoubleClick
override bool OnDoubleClick(Widget w, int x, int y, int button)
Definition: missionloader.c:84
m_WgtLstMsnList
class JsonMissionLoaderData m_WgtLstMsnList
array< string >
x
Icon x
m_WgtBtnMsnClose
protected ButtonWidget m_WgtBtnMsnClose
Definition: missionloader.c:41
CFG_FILE_MISSION_LIST
const string CFG_FILE_MISSION_LIST
Definition: constants.c:240
Widget
Definition: enwidgets.c:189
m_ListMissionsNames
protected ref TStringArray m_ListMissionsNames
Definition: missionloader.c:42
JsonMissionLoaderData
Definition: missionloader.c:1
m_WgtBtnMsnPlay
protected ButtonWidget m_WgtBtnMsnPlay
Definition: missionloader.c:40
path
string path
Definition: optionselectormultistate.c:135