Example #1
0
        private void m_menuOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();

            diag.Filter = "ui layout files (*.ui_layout)|*.ui_layout|All files (*.*)|*.*";

            diag.InitialDirectory = UDesignApp.Instance.RootPath;

            string lastDir = Properties.Settings.Default.RecentAccessedDir;

            if (!string.IsNullOrEmpty(lastDir) && Directory.Exists(lastDir))
            {
                diag.InitialDirectory = lastDir;
            }
            else
            {
                string testDir = LuaRuntime.GetGlobalString("ResPath_Test");
                if (!string.IsNullOrEmpty(testDir))
                {
                    var testDirFull = SysUtil.NormalizePath(Path.Combine(UDesignApp.Instance.RootPath, testDir));
                    if (Directory.Exists(testDirFull))
                    {
                        diag.InitialDirectory = testDirFull;
                    }
                }
            }

            if (diag.ShowDialog(this) == DialogResult.OK)
            {
                string file = diag.FileName;
                if (File.Exists(file))
                {
                    // 这里重置前,应先提示用户保存
                    if (!ResetScene(file))
                    {
                        Logging.Instance.Message("打开文件失败。");
                    }

                    SetRecentAccessedDirectory(Path.GetDirectoryName(file));
                }
            }
        }
Example #2
0
        private bool ResetScene(string sceneName)
        {
            string        atlasPath         = LuaRuntime.GetGlobalString("ResPath_Atlases");
            string        defaultAtlas      = LuaRuntime.GetGlobalString("ResName_DefaultAtlas");
            List <string> additionalAtlases = LuaRuntime.GetGlobalStringArray("ResName_AdditionalAtlases");

            if (string.IsNullOrEmpty(atlasPath) || string.IsNullOrEmpty(defaultAtlas) || additionalAtlases.Count == 0)
            {
                return(false);
            }

            SceneEd.Instance.Selection.ClearSelection();
            ActionQueue.Instance.ClearActions();

            BootParams bp = new BootParams {
                ReourcePath          = atlasPath,
                DefaultReourceImage  = defaultAtlas,
                ReourceImages        = additionalAtlases,
                ScenePath            = sceneName,
                DesignTimeResolution = GetDefaultResolution()
            };

            if (!Bootstrap.Instance.Init(bp))
            {
                return(false);
            }

            m_glRenderBuffer.SetScene(Scene.Instance);
            m_glRenderBuffer.SetSceneEd(SceneEd.Instance);

            // 不管是 Load 还是 Reset 成功,均需要刷新窗体的标题栏
            UpdateFormTitle();

            SceneEd.Instance.Select(Scene.Instance.Root);
            SceneEdEventNotifier.Instance.Emit_RefreshScene(RefreshSceneOpt.Refresh_All);
            return(true);
        }