Exemple #1
0
        public void keyHandler(KeyEventArgs k)
        {
            switch (k.KeyCode)
            {
            case Keys.Enter:
                frame.setIsTyping(false);
                break;

            case Keys.LShiftKey:
            case Keys.RShiftKey:
            case Keys.Shift:
            case Keys.ShiftKey:
                break;

            case Keys.Back:
                switch (set)
                {
                case "setlevelname":
                    main.getEditor().backspaceName();
                    break;

                case "setlevelnote":
                    main.getEditor().backspaceNote();
                    break;
                }
                break;

            case Keys.Space:
            case Keys.OemPeriod:
            case Keys.Oemcomma:
            case Keys.OemQuestion:
            case Keys.OemQuotes:
            case Keys.OemSemicolon:
                String code = "";
                if (!k.Shift)
                {
                    switch (k.KeyCode)
                    {
                    case Keys.Space:
                        code = " ";
                        break;

                    case Keys.OemPeriod:
                        code = ".";
                        break;

                    case Keys.Oemcomma:
                        code = ",";
                        break;

                    case Keys.OemQuestion:
                        code = "/";
                        break;

                    case Keys.OemQuotes:
                        code = "'";
                        break;

                    case Keys.OemSemicolon:
                        code = ";";
                        break;
                    }
                }
                else
                {
                    switch (k.KeyCode)
                    {
                    case Keys.Space:
                        code = " ";
                        break;

                    case Keys.OemPeriod:
                        code = ">";
                        break;

                    case Keys.Oemcomma:
                        code = "<";
                        break;

                    case Keys.OemQuestion:
                        code = "?";
                        break;

                    case Keys.OemQuotes:
                        code = "\"";
                        break;

                    case Keys.OemSemicolon:
                        code = ":";
                        break;
                    }
                }

                switch (set)
                {
                case "setlevelname":
                    main.getEditor().addToName(code);
                    break;

                case "setlevelnote":
                    main.getEditor().addToNote(code);
                    break;
                }
                break;

            case Keys.D1:
            case Keys.D2:
            case Keys.D3:
            case Keys.D4:
            case Keys.D5:
            case Keys.D6:
            case Keys.D7:
            case Keys.D8:
            case Keys.D9:
                if (!k.Shift)
                {
                    switch (set)
                    {
                    case "setlevelname":
                        main.getEditor().addToName(
                            k.KeyCode.ToString().Substring(1));
                        break;

                    case "setlevelnote":
                        main.getEditor().addToNote(
                            k.KeyCode.ToString().Substring(1));
                        break;
                    }
                }
                break;

            default:
                String s = k.KeyCode.ToString();
                if (!k.Shift)
                {
                    s = s.ToLower();
                }
                // TODO
                switch (set)
                {
                case "setlevelname":
                    main.getEditor().addToName(s);
                    break;

                case "setlevelnote":
                    main.getEditor().addToNote(s);
                    break;
                }
                break;
            }

            if (main.getMode() == Mode.MENU)
            {
                main.refreshMenuFrame();
            }
            else if (main.getMode() == Mode.PAUSE)
            {
                main.refreshPauseFrame();
            }
        }
Exemple #2
0
        public static MenuFrame fromString(String s, main main)
        {
            MenuObject[] pauseObjs;

            // for ordered stuff
            int mid    = 360;
            int unit   = 80;
            int offset = 30;

            // for two column setups
            int lc = 480;
            int rc = 800;

            switch (s.ToLower())
            {
            case "main":
                mid  = 360;
                unit = 100;
                MenuObject[] menuObjs = new MenuObject[] {
                    new MenuObject(new Point(640, 100),
                                   Resources.t3logo_664_164, main),
                    new MenuObject(true, "PLAY", 4, new Point(640, mid - unit),
                                   MenuObject.Task.SET_MODE, "GAME", main),
                    new MenuObject(true, "MY CONTENT", 4, new Point(640, mid),
                                   MenuObject.Task.SET_MENU, "my-content", main),
                    new MenuObject(true, "<TODO>", 4, new Point(640, mid + unit),
                                   MenuObject.Task.SET_MENU, "settings-main", main),
                    new MenuObject(true, "QUIT", 4, new Point(640, mid + (2 * unit)),
                                   MenuObject.Task.CLOSE, null, main)
                };
                return(new MenuFrame(menuObjs, main));

            case "my-content":
                mid      = 360;
                unit     = 100;
                menuObjs = new MenuObject[] {
                    new MenuObject(false, "MY CONTENT", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "CAMPAIGNS", 4, new Point(640, mid - unit),
                                   MenuObject.Task.SET_MENU, "my-campaigns", main),
                    new MenuObject(true, "LEVELS", 4, new Point(640, mid),
                                   MenuObject.Task.SET_MENU, "my-levels", main),
                    new MenuObject(true, "LEVEL EDITOR", 4, new Point(640, mid + unit),
                                   MenuObject.Task.SET_MODE, "EDITOR", main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "main", main)
                };
                return(new MenuFrame(menuObjs, main));

            case "editor-level-finish":
                lc       = 320;
                rc       = 960;
                mid      = 360;
                unit     = 100;
                offset   = 20;
                menuObjs = new MenuObject[] {
                    new MenuObject(false, "LEVEL INFO", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LEVEL NAME:", 4, new Point(640,
                                                                      mid - unit - offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "\"" + main.getEditor().getName() + "\"",
                                   4, new Point(640, mid - unit + offset),
                                   MenuObject.Task.TYPE, "setlevelname", main),
                    new MenuObject(false, "LEVEL NOTE:", 4, new Point(640,
                                                                      mid - offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "\"" + main.getEditor().getNote() + "\"",
                                   2, new Point(640, mid + offset),
                                   MenuObject.Task.TYPE, "setlevelnote", main),
                    new MenuObject(true, "SAVE TO FILE", 4, new Point(lc, 660),
                                   MenuObject.Task.SAVE_EDITOR, null, main),
                    new MenuObject(true, "FINISH", 4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "my-content", main),
                    new MenuObject(true, "BACK", 4, new Point(rc, 660),
                                   MenuObject.Task.SET_MODE, "EDITOR", main)
                };
                return(new MenuFrame(menuObjs, main));

            case "pause":
                String levelName = main.getLevel().getName().ToUpper();
                String levelNote = main.getLevel().getNote().ToUpper();

                if (levelName != "")
                {
                    if (levelNote == "")
                    {
                        levelNote = " ";
                    }
                    pauseObjs = new MenuObject[] {
                        new MenuObject(false, levelName, 8, new Point(640, 100),
                                       MenuObject.Task.NULL, null, main),
                        new MenuObject(false, levelNote, 2, new Point(640, 150),
                                       MenuObject.Task.NULL, null, main),
                        new MenuObject(true, "RESUME", 4, new Point(640, 260),
                                       MenuObject.Task.UNPAUSE, null, main),
                        new MenuObject(true, "SETTINGS", 4, new Point(640, 360),
                                       MenuObject.Task.SET_PAUSE, "settings-pause", main),
                        new MenuObject(true, "MAIN MENU", 4, new Point(640, 460),
                                       MenuObject.Task.SET_MENU, "main", main),
                        new MenuObject(true, "QUIT", 4, new Point(640, 560),
                                       MenuObject.Task.SET_PAUSE, "are-you-sure", main)
                    };
                    return(new MenuFrame(pauseObjs, main));
                }
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "PAUSED", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "RESUME", 4, new Point(640, 260),
                                   MenuObject.Task.UNPAUSE, null, main),
                    new MenuObject(true, "SETTINGS", 4, new Point(640, 360),
                                   MenuObject.Task.SET_PAUSE, "settings-pause", main),
                    new MenuObject(true, "MAIN MENU", 4, new Point(640, 460),
                                   MenuObject.Task.SET_MENU, "main", main),
                    new MenuObject(true, "QUIT", 4, new Point(640, 560),
                                   MenuObject.Task.SET_PAUSE, "are-you-sure", main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "are-you-sure":
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "Are you sure you want to quit?",
                                   4, new Point(640, 310),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(540, 410),
                                   MenuObject.Task.SET_PAUSE, "pause", main),
                    new MenuObject(true, "YES", 4, new Point(740, 410),
                                   MenuObject.Task.CLOSE, null, main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "settings-pause":
                GameSettings stgs = main.getSettings();
                mid       = 360;
                unit      = 80;
                offset    = 30;
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "SETTINGS", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_PAUSE, "pause", main),
                    new MenuObject(false, "CAMERA FOLLOW MODE", 3,
                                   new Point(640, mid - (2 * unit)),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getFollowMode().ToString(), 3,
                                   new Point(640, mid - (2 * unit) + offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "<", 3,
                                   new Point(520, mid - (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_FOLLOW, "-1", main),
                    new MenuObject(true, ">", 3,
                                   new Point(760, mid - (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_FOLLOW, "1", main),
                    new MenuObject(false, "WINDOW MODE", 3,
                                   new Point(640, mid - unit),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getWindowMode().ToString(),
                                   3, new Point(640, mid - unit + offset),
                                   MenuObject.Task.SET_PAUSE, null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid - unit + offset),
                                   MenuObject.Task.SWITCH_WINDOW, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid - unit + offset),
                                   MenuObject.Task.SWITCH_WINDOW, null, main),
                    new MenuObject(false, "HUD", 3, new Point(640, mid),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getHUDStatus().ToString(),
                                   3, new Point(640, mid + offset), MenuObject.Task.NULL,
                                   null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid + offset),
                                   MenuObject.Task.SWITCH_HUD, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid + offset),
                                   MenuObject.Task.SWITCH_HUD, null, main),
                    new MenuObject(false, "CONTROL MODE", 3, new Point(640, mid + unit),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, stgs.getControlMode().ToString(),
                                   3, new Point(640, mid + unit + offset), MenuObject.Task.SET_PAUSE,
                                   "controls-pause", main),
                    new MenuObject(true, "<", 3, new Point(520, mid + unit + offset),
                                   MenuObject.Task.SWITCH_CONTROLS, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid + unit + offset),
                                   MenuObject.Task.SWITCH_CONTROLS, null, main),
                    new MenuObject(false, "GAME SPEED", 3, new Point(640, mid + (2 * unit)),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.gameSpeed(), 3,
                                   new Point(640, mid + (2 * unit) + offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid + (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_PERIOD, "1", main),
                    new MenuObject(true, ">", 3, new Point(760, mid + (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_PERIOD, "-1", main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "controls-pause":
                Keys[] controls = main.getSettings().getControls();
                lc        = 480;
                rc        = 800;
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "CONTROLS", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_PAUSE, "settings-pause", main),
                    new MenuObject(false, "JUMP", 4, new Point(lc, 200),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[0].ToString(), 4,
                                   new Point(rc, 200), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "DROP", 4, new Point(lc, 240),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[1].ToString(), 4,
                                   new Point(rc, 240), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LEFT", 4, new Point(lc, 280),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[2].ToString(), 4,
                                   new Point(rc, 280), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "RIGHT", 4, new Point(lc, 320),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[3].ToString(), 4,
                                   new Point(rc, 320), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "SAVE LOCATION", 4, new Point(lc, 360),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[4].ToString(), 4,
                                   new Point(rc, 360), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LOAD LOCATION", 4, new Point(lc, 400),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[5].ToString(), 4,
                                   new Point(rc, 400), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "TELEPORT", 4, new Point(lc, 440),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[6].ToString(), 4,
                                   new Point(rc, 440), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "CAMERA ZOOM", 4, new Point(lc, 480),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[7].ToString(), 4,
                                   new Point(rc, 480), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "PAUSE", 4, new Point(lc, 520),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[8].ToString(), 4,
                                   new Point(rc, 520), MenuObject.Task.NULL, null, main)
                };
                return(new MenuFrame(pauseObjs, main));

            default:
                return(new MenuFrame(new MenuObject[] {
                    new MenuObject(false, "THIS DOES NOT EXIST",
                                   8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "(Yet.)",
                                   16, new Point(640, 360),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "RETURN TO MAIN MENU",
                                   4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "main", main)
                }, main));
            }
        }