Beispiel #1
0
        public static void toggleEditor(bool make)
        {
            if (((GuiCanvas)"Canvas").isFullscreen())
            {
                messageBox.MessageBoxOK("Windowed Mode Required", "Please switch to windowed mode to access the Mission Editor.");
                return;
            }
            editor editor = "editor";

            if (make)
            {
                string timerID = omni.console.Call("startPrecisionTimer");
                if (omni.bGlobal["$InGuiEditor"])
                {
                    //omni.console.Call("GuiEdit");
                    GuiEditorGui.GuiEdit("");
                }

                if (!omni.bGlobal["$missionRunning"])
                {
                    // Flag saying, when level is chosen, launch it with the editor open.
                    ((GuiControl)"ChooseLevelDlg")["launchInEditor"] = true.AsString();
                    //((GuiCanvas) "canvas").pushDialog("ChooseLevelDlg");
                    MenuHandlers.EditorNewLevel("");
                }
                else
                {
                    omni.Util.pushInstantGroup();
                    if (!"Editor".isObject())
                    {
                        create();

                        ((SimGroup)"MissionCleanup").add(editor);
                        ((SimGroup)"MissionCleanup").add(editor.getUndoManager());
                    }

                    if (Extendable.GuiCanvas.EditorIsActive())
                    {
                        if (((LevelInfo)"theLevelInfo")["Type"] == "DemoScene")
                        {
                            omni.console.commandToServer("dropPlayerAtCamera");
                            editor.close("SceneGui");
                        }
                        else
                        {
                            editor.close("PlayGui");
                        }
                    }
                    else
                    {
                        if (!omni.bGlobal["$GuiEditorBtnPressed"])
                        {
                            ((GuiCanvas)"Canvas").pushDialog("EditorLoadingGui");
                            ((GuiCanvas)"Canvas").repaint(0);
                        }
                        else
                        {
                            omni.bGlobal["$GuiEditorBtnPressed"] = false;
                        }

                        editor.open();

                        // Cancel the scheduled event to prevent
                        // the level from cycling after it's duration
                        // has elapsed.

                        omni.Util.cancel(omni.iGlobal["$Game::Schedule"]);

                        if (((LevelInfo)"theLevelInfo")["type"] == "DemoScene")
                        {
                            omni.console.commandToServer("dropCameraAtPlayer", new string[] { "true" });
                        }

                        ((GuiCanvas)"Canvas").popDialog("EditorLoadingGui");
                    }

                    omni.Util.popInstantGroup();
                }

                string elapsed = omni.console.Call("stopPrecisionTimer", new string[] { timerID });

                omni.Util._warn("Time spent in toggleEditor() : " + (elapsed.AsFloat() / 1000.0) + " s");
            }
        }