public PreviewForm(Scene scn, SceneEd scnEd) { InitializeComponent(); m_renderBuffer.SetScene(scn); if (!m_renderBuffer.InitContext()) { throw new ucore.AppInitError_Fatal("failed to init GL render buffer."); } m_renderBuffer.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl_Paint); ftime = new List <long>(); stopwatch = new Stopwatch(); m_defaultResolution = null; MoonSharp.Interpreter.Table t = LuaRuntime.Instance.BootstrapScript.Globals["Resolutions"] as MoonSharp.Interpreter.Table; foreach (var res in t.Values) { if (res.Type == MoonSharp.Interpreter.DataType.Table) { ResolutionV2 resolution = new ResolutionV2(); resolution.width = Convert.ToInt32(res.Table["w"]); resolution.height = Convert.ToInt32(res.Table["h"]); resolution.category = Convert.ToInt32(res.Table["cat"]); resolution.tag = (string)res.Table["tag"]; Control ctrl = FindButtonByCategory(resolution.category); if (ctrl != null) { ToolStripMenuItem tsi = new ToolStripMenuItem(); if (string.IsNullOrEmpty(resolution.tag)) { tsi.Text = string.Format("{0}x{1}", resolution.width, resolution.height); } else { tsi.Text = string.Format("{0}x{1} ({2})", resolution.width, resolution.height, resolution.tag); } tsi.Tag = resolution; tsi.Click += m_resolutionMenuItemClicked; ctrl.ContextMenuStrip.Items.Add(tsi); if (Convert.ToBoolean(res.Table["default"])) { m_defaultResolution = resolution; m_defaultResolutionMenuItem = tsi; m_defaultResolutionButton = ctrl as ButtonX; } } } } // 如果没有在脚本中正确地设置默认分辨率,这里选择使用桌面分辨率的第一个作为默认分辨率 if (m_defaultResolution == null) { ucore.SysPost.AssertException(m_btResDesktop.ContextMenuStrip.Items.Count > 0, "The context menu of 'Desktop' button is not empty."); ToolStripMenuItem mi = m_btResDesktop.ContextMenuStrip.Items[0] as ToolStripMenuItem; if (mi != null) { ResolutionV2 res = m_btResDesktop.ContextMenuStrip.Items[0].Tag as ResolutionV2; if (res != null) { m_defaultResolution = res; m_defaultResolutionMenuItem = mi; m_defaultResolutionButton = m_btResDesktop; } } } ucore.SysPost.AssertException(m_defaultResolution != null, "The default resolution is not set properly."); SelectResolution(m_defaultResolution, m_defaultResolutionMenuItem, m_defaultResolutionButton); }
public void SetSceneEd(SceneEd scnEd) { m_sceneEd = scnEd; }