DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
WorldsMenu.c
См. документацию.
1#ifdef GAME_TEMPLATE
2
3[EditorAttribute("box", "GameLib/Scripted", "Worlds menu", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
4class WorldsMenuClass
5{
6
7}
8
9WorldsMenuClass WorldsMenuSource;
10
11class WorldsMenu: GenericEntity
12{
13 int m_DbgListSelection = 0;
14 int m_WorldsCount = 0;
15 string DEFAULT_WORLD = "worlds/default.ent";
16 ref array<string> m_DbgOptions = {};
17 ref ImageWidget m_MouseWidget;
18
19 void WorldsMenu(IEntitySource src, IEntity parent)
20 {
21 SetFlags(EntityFlags.ACTIVE, false);
22 SetEventMask(EntityEvent.POSTFRAME);
23
24 Class.CastTo(m_MouseWidget, GetGame().GetWorkspace().CreateWidgets("gui/layouts/mouse.layout"));
25 m_MouseWidget.SetSort(1024);
26 SetCursorWidget(m_MouseWidget);
27
28 LoadWorlds();
29 }
30
31 void ~WorldsMenu()
32 {
33 delete m_MouseWidget;
34 }
35
36 array<string> GetWorldList()
37 {
38 return m_DbgOptions;
39 }
40
41 override void EOnPostFrame(IEntity other, int extra) //EntityEvent.POSTFRAME
42 {
43 InputManager im = GetGame().GetInputManager();
44 im.ActivateContext("MenuContext");
45 bool menuSelect = im.GetActionTriggered("MenuSelect");
46 bool menuBack = im.GetActionTriggered("MenuBack");
47
48 DbgUI.Begin("Load world", 400, 100);
49
50 DbgUI.Text("Select world to load from worlds directory");
51
52 if (m_DbgOptions.Count() > 0)
53 {
54 DbgUI.List("Worlds", m_DbgListSelection, m_DbgOptions);
55 if (DbgUI.Button("Start") || menuSelect)
56 {
57 string worldToLoad = m_DbgOptions.Get(m_DbgListSelection);
58 GetGame().SetWorldFile(worldToLoad, true);
59 }
60 }
61 if (DbgUI.Button("Exit") || menuBack)
62 {
63 GetGame().RequestClose();
64 }
65 DbgUI.End();
66 }
67
68 void LoadWorlds()
69 {
70 string fileName;
71 FileAttr fileAttr;
72 FindFileHandle worlds = FindFile("worlds/*.ent", fileName, fileAttr, 0);
73
74 if (!worlds)
75 return;
76
77 InsertWorldToList(fileName);
78
79 while(FindNextFile(worlds, fileName, fileAttr))
80 {
81 InsertWorldToList(fileName);
82 }
83
84 CloseFindFile(worlds);
85
86 m_WorldsCount = m_DbgOptions.Count();
87 }
88
89 void InsertWorldToList(string fileName)
90 {
91 string path = String("worlds/" + fileName);
92 if (path != DEFAULT_WORLD)
93 m_DbgOptions.Insert(String(path));
94 }
95}
96
97#endif
int[] IEntitySource
Определения EnEntity.c:2
string path
Определения OptionSelectorMultistate.c:142
proto native CGame GetGame()
proto native void SetFlags(ShapeFlags flags)
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
EntityFlags
Entity flags.
Определения EnEntity.c:115
void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2="0 0 0 0", bool visible=true, bool insertable=true, bool dynamicBox=false)
Определения EnEntity.c:854
proto native void CloseFindFile(FindFileHandle handle)
enum FindFileFlags FindFile(string pattern, out string fileName, out FileAttr fileAttributes, FindFileFlags flags)
proto bool FindNextFile(FindFileHandle handle, out string fileName, out FileAttr fileAttributes)
int[] FindFileHandle
Определения EnSystem.c:503
FileAttr
Определения EnSystem.c:506
proto native void SetCursorWidget(Widget cursor)