Ejemplo n.º 1
0
        private void RenderMenuBar()
        {
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Open engine.ps3"))
                    {
                        var res = CrossFileDialog.OpenFile(filter: ".ps3");
                        if (res.Length > 0)
                        {
                            openFrames.RemoveAll(FrameIsLevel);
                            LevelFrame lf = new LevelFrame(this);
                            Level      l  = new Level(res);
                            lf.LoadLevel(l);
                            AddFrame(lf);
                        }
                    }

                    if (ImGui.MenuItem("Quit"))
                    {
                        Environment.Exit(0);
                    }
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("About"))
                {
                    if (ImGui.MenuItem("About Replanetizer"))
                    {
                        AddFrame(new AboutFrame(this));
                    }
                    if (ImGui.MenuItem("Open ImGui demo window"))
                    {
                        AddFrame(new DemoWindowFrame(this));
                    }
                    ImGui.EndMenu();
                }

                ImGui.EndMainMenuBar();
            }
        }
        public override void Render(float deltaTime)
        {
            if (level != null)
            {
                ImGui.SetNextItemOpen(true);
                if (ImGui.TreeNode("Mesh mode"))
                {
                    int meshMode = (int)settings.mode;
                    if (ImGui.Combo("Mesh Mode", ref meshMode, enumNameMap, enumNameMap.Length))
                    {
                        settings.mode = (ModelWriter.WriterLevelMode)meshMode;
                    }
                    ImGui.TreePop();
                }

                ImGui.SetNextItemOpen(true);
                if (ImGui.TreeNode("Objects to include"))
                {
                    ImGui.Checkbox("Include Ties", ref settings.writeTies);
                    ImGui.Checkbox("Include Shrubs", ref settings.writeShrubs);
                    ImGui.Checkbox("Include Mobies", ref settings.writeMobies);
                    if (level.terrainChunks.Count == 0)
                    {
                        ImGui.Checkbox("Include Terrain", ref settings.chunksSelected[0]);
                    }
                    ImGui.Checkbox("Include MLT File", ref settings.exportMtlFile);
                    ImGui.TreePop();
                }

                if (level.terrainChunks.Count != 0)
                {
                    ImGui.SetNextItemOpen(true);
                    if (ImGui.TreeNode("Chunk config"))
                    {
                        ImGui.TextDisabled("Use CTRL key to select multiple");
                        for (int i = 0; i < level.terrainChunks.Count; i++)
                        {
                            if (ImGui.Selectable("Chunk " + i, settings.chunksSelected[i]))
                            {
                                settings.chunksSelected[i] = !settings.chunksSelected[i];
                            }
                        }
                        ImGui.TreePop();
                    }
                }

                if (ImGui.Button("Perform export"))
                {
                    var res = CrossFileDialog.SaveFile("Level.obj", "*.obj");
                    if (res.Length > 0)
                    {
                        ModelWriter.WriteObj(res, level, settings);
                        isOpen = false;
                    }
                }
            }
            else
            {
                ImGui.Text("Export unavailable, no level found!");
            }
        }