public bool InitFromFile(string path, bool rebuild = true, bool cache = true) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if(path == string.Empty) { return false; } _loading = true; if((rebuild == true) || (_desktop == null)) { _desktop = new idWindow(this, idE.UIManager.Context); } _sourceFile = path; _state.Set("text", "Test Text!"); // load the timestamp so reload guis will work correctly byte[] data = idE.FileSystem.ReadFile(path, out _timeStamp); string content = UTF8Encoding.UTF8.GetString(data); idScriptParser parser = null; if(content != null) { parser = new idScriptParser(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.AllowMultiCharacterLiterals | LexerOptions.AllowBackslashStringConcatination); parser.LoadMemory(content, path); } if((parser != null) && (parser.IsLoaded == true)) { idToken token; while((token = parser.ReadToken()) != null) { if(token.ToString().Equals("windowDef", StringComparison.OrdinalIgnoreCase) == true) { if(_desktop.Parse(parser, rebuild) == true) { _desktop.Flags = WindowFlags.Desktop; _desktop.FixupParameters(); } } } _state.Set("name", path); } else { _desktop.Name = "Desktop"; _desktop.Flags = WindowFlags.Desktop; _desktop.Text = string.Format("Invalid GUI: {0}", path); _desktop.Rectangle = new idRectangle(0, 0, 640, 480); _desktop.DrawRectangle = _desktop.Rectangle; _desktop.ForeColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); _desktop.BackColor = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); _desktop.SetupFromState(); idConsole.Warning("Couldn't load gui: '{0}'", path); } _interactive = _desktop.IsInteractive; if(idE.UIManager.FindInternalInterface(this) == null) { idE.UIManager.AddInternalInterface(this); } _loading = false; return true; }