Exemplo n.º 1
0
        /**
         * Parse and execute the current command
         * Give "Warning" on illegal commands.
         */
        public static void process_command(bool no_request)
        {
            bool     done = true;
            ui_event e;

            /* Reset argument before getting command */
            Misc.p_ptr.command_arg = 0;
            e = TextUI.get_command();

            if (e.type == ui_event_type.EVT_RESIZE)
            {
                Do_Command.redraw();
            }

            else if (e.type == ui_event_type.EVT_MOUSE)
            {
                TextUI.process_click(e);
            }

            else if (e.type == ui_event_type.EVT_KBRD)
            {
                done = TextUI.process_key(e.key);
            }

            if (!done)
            {
                Do_Command.unknown();
            }
        }
Exemplo n.º 2
0
 /* Command dispatcher for curses, etc builds */
 static int default_get_cmd(cmd_context context, bool wait)
 {
     if (context == cmd_context.CMD_INIT)
     {
         return(get_init_cmd());
     }
     else
     {
         return(TextUI.get_cmd(context, wait));
     }
 }
Exemplo n.º 3
0
        public static int get_cmd(cmd_context context, bool wait)
        {
            if (context == cmd_context.CMD_BIRTH)
            {
                return(UIBirth.get_birth_command(wait));
            }
            else if (context == cmd_context.CMD_GAME)
            {
                TextUI.process_command(!wait);
            }

            /* If we've reached here, we haven't got a command. */
            return(1);
        }
Exemplo n.º 4
0
        /**
         * Process a textui keypress.
         */
        static bool process_key(keypress kp)
        {
            Command_Info cmd;

            /* XXXmacro this needs rewriting */
            char c = (char)kp.code;

            if (c == '\n' || c == '\r')
            {
                c = TextUI.action_menu_choose();
            }

            if (c == '\0' || c == (char)keycode_t.ESCAPE || c == ' ' || c == '\a')
            {
                return(true);
            }

            cmd = Command.converted_list[c];
            if (cmd == null)
            {
                return(false);
            }

            if (Command.key_confirm_command(c) && (cmd.prereq == null || cmd.prereq()))
            {
                if (cmd.hook != null)
                {
                    cmd.hook();
                }
                else if (cmd.cmd != Command_Code.NULL)
                {
                    Game_Command.insert_repeated(cmd.cmd, Misc.p_ptr.command_arg);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        /*
         * Request a command from the user.
         *
         * Note that "caret" ("^") is treated specially, and is used to
         * allow manual input of control characters.  This can be used
         * on many machines to request repeated tunneling (Ctrl-H) and
         * on the Macintosh to request "Control-Caret".
         *
         * Note that "backslash" is treated specially, and is used to bypass any
         * keymap entry for the following character.  This is useful for macros.
         */
        static ui_event get_command()
        {
            int mode = (int)(Option.rogue_like_commands.value ? Keymap.Mode.ROGUE : Keymap.Mode.ORIG);

            keypress[] tmp = new keypress[2] {
                new keypress(), new keypress()
            };

            ui_event ke = new ui_event();

            //ui_event ret = ke;

            keypress[] act = null;



            /* Get command */
            while (true)
            {
                /* Hack -- no flush needed */
                Term.msg_flag = false;

                /* Activate "command mode" */
                Utilities.inkey_flag = true;

                /* Get a command */
                ke = Utilities.inkey_ex();

                if (ke.type == ui_event_type.EVT_KBRD)
                {
                    bool keymap_ok = true;
                    switch ((char)ke.key.code)
                    {
                    case '0': {
                        int count = TextUI.get_count();

                        throw new NotImplementedException();
                        //if (count == -1 || !get_com_ex("Command: ", &ke))
                        //    continue;
                        //else
                        //    p_ptr.command_arg = count;
                        //break;
                    }

                    case '\\': {
                        /* Allow keymaps to be bypassed */
                        throw new NotImplementedException();
                        //(void)get_com_ex("Command: ", &ke);
                        //keymap_ok = false;
                        //break;
                    }

                    case '^': {
                        throw new NotImplementedException();
                        ///* Allow "control chars" to be entered */
                        //if (get_com("Control: ", &ke.key))
                        //    ke.key.code = KTRL(ke.key.code);
                        //break;
                    }
                    }

                    /* Find any relevant keymap */
                    if (keymap_ok)
                    {
                        act = Keymap.find(mode, ke.key);
                        //if (act == null) {
                        //    ret = ke;
                        //}
                    }
                }

                /* Erase the message line */
                Utilities.prt("", 0, 0);

                if (ke.type == ui_event_type.EVT_BUTTON)
                {
                    /* Buttons are always specified in standard keyset */
                    act    = tmp;
                    tmp[0] = ke.key;
                }

                /* Apply keymap if not inside a keymap already */
                if (ke.key.code != (keycode_t)0 && act != null && Utilities.inkey_next == null)
                {
                    //int n = 0;
                    //while (n < act.Length && act[n] != null)//act[n].type
                    //    n++;

                    ///* Make room for the terminator */
                    //n += 1;

                    /* Install the keymap */
                    for (int q = 0; q < act.Length; q++)              //It used to check for q < n instead
                    {
                        request_command_buffer[q] = act[q];
                        //memcpy(request_command_buffer, act, n);
                    }

                    /* Start using the buffer */
                    Utilities.inkey_next = new List <keypress>(request_command_buffer);

                    /* Continue */
                    //ret.type = ke.type;
                    //ret.mouse = ke.mouse;
                    //ret.key = act[0];
                    continue;
                }

                /* Done */
                break;
            }

            return(ke);
        }
Exemplo n.º 6
0
        /*
         * Initialize some other arrays
         */
        static Parser.Error init_other()
        {
            /*** Prepare the various "bizarre" arrays ***/

            /* Initialize the "quark" package */
            Quark.Init();

            /* Initialize squelch things */
            Squelch.Init();
            TextUI.knowledge_init();

            /* Initialize the "message" package */
            Message.Init();

            /*** Prepare grid arrays ***/

            /* Array of grids */
            Misc.temp_g = new ushort[Misc.TEMP_MAX];

            Cave.instance = new Cave();

            /* Array of stacked monster messages */
            Monster_Message.mon_msg          = new Monster_Race_Message[Misc.MAX_STORED_MON_MSG];
            Monster_Message.mon_message_hist = new Monster_Message_History[Misc.MAX_STORED_MON_CODES];

            /*** Prepare "vinfo" array ***/

            /* Used by "update_view()" */
            Cave.vinfo_init();


            /*** Prepare entity arrays ***/

            /* Objects */
            Object.Object.Init();

            /*** Prepare lore array ***/

            /* Lore */
            Misc.l_list = new Monster_Lore[Misc.z_info.r_max];


            /*** Prepare mouse buttons ***/
            Button.Init(Button.add_text, Button.kill_text);


            /*** Prepare quest array ***/

            /* Quests */
            Misc.q_list = new Quest[Misc.MAX_Q_IDX];


            /*** Prepare the inventory ***/

            /* Allocate it */
            Player.Player.instance.inventory = new Object.Object[Misc.ALL_INVEN_TOTAL];
            for (int i = 0; i < Player.Player.instance.inventory.Count(); i++)
            {
                Player.Player.instance.inventory[i] = new Object.Object();
            }


            /*** Prepare the options ***/
            Option.set_defaults();

            /* Initialize the window flags */
            for (int i = 0; i < Misc.ANGBAND_TERM_MAX; i++)
            {
                /* Assume no flags */
                Player_Other.instance.window_flag[i] = (uint)0L;             //God damn it, who wrote that?!?! -werror should be on!!!
            }


            /*** Pre-allocate space for the "format()" buffer ***/             //Nick: Not needed in C#
            /* Hack -- Just call the "format()" function */
            //format("I wish you could swim, like dolphins can swim...");

            /* Success */
            return(0);
        }