3[
EditorAttribute(
"box",
"GameLib/Scripted",
"Worlds menu",
"-0.25 -0.25 -0.25",
"0.25 0.25 0.25",
"255 0 0 255")]
9WorldsMenuClass WorldsMenuSource;
11class WorldsMenu: GenericEntity
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;
24 Class.CastTo(m_MouseWidget,
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/mouse.layout"));
25 m_MouseWidget.SetSort(1024);
36 array<string> GetWorldList()
41 override void EOnPostFrame(IEntity other,
int extra)
43 InputManager im =
GetGame().GetInputManager();
44 im.ActivateContext(
"MenuContext");
45 bool menuSelect = im.GetActionTriggered(
"MenuSelect");
46 bool menuBack = im.GetActionTriggered(
"MenuBack");
48 DbgUI.Begin(
"Load world", 400, 100);
50 DbgUI.Text(
"Select world to load from worlds directory");
52 if (m_DbgOptions.Count() > 0)
54 DbgUI.List(
"Worlds", m_DbgListSelection, m_DbgOptions);
55 if (DbgUI.Button(
"Start") || menuSelect)
57 string worldToLoad = m_DbgOptions.Get(m_DbgListSelection);
58 GetGame().SetWorldFile(worldToLoad,
true);
61 if (DbgUI.Button(
"Exit") || menuBack)
77 InsertWorldToList(fileName);
81 InsertWorldToList(fileName);
86 m_WorldsCount = m_DbgOptions.Count();
89 void InsertWorldToList(
string fileName)
92 if (
path != DEFAULT_WORLD)
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 "...
EntityEvent
Entity events for event-mask, or throwing event from code.
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)
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)