Ejemplo n.º 1
0
int context_menu_player(int mx, int my)
{
	menu_type *m;
	rect_region r;
	int selected;
	char *labels;

	cave_type *c_ptr = area(p_ptr->px,p_ptr->py);
	pcave_type *pc_ptr = parea(p_ptr->px,p_ptr->py);
	feature_type *feat;

	m = menu_dynamic_new();
	if (!m) {
		return 0;
	}

	labels = (char*)string_make(lower_case);
	m->selections = labels;

	feat  = &(f_info[c_ptr->feat]);

	menu_dynamic_add_label(m, "Use Item", 'u', 1, labels);
	/* if player can cast, add casting option */
	if (player_is_caster()) {
		if (player_can_cast()) {
			menu_dynamic_add_label(m, "Cast", 'm', 2, labels);
		} else {
			menu_dynamic_add_label(m, "$Cast", 'm', 2, labels);
		}
	}
	/* if player can use racial powers or mutations, add option */
	if (player_has_power()) {
		if (player_can_use_power()) {
			menu_dynamic_add_label(m, "Use Power", 'U', 16, labels);
		} else {
			menu_dynamic_add_label(m, "$Use Power", 'U', 16, labels);
		}
	}
	/* if player is on stairs add option to use them */
	if (feat->flags & FF_EXIT_UP) {
		menu_dynamic_add_label(m, "Go Up", '<', 11, labels);
	}
	if (feat->flags & FF_EXIT_DOWN) {
		menu_dynamic_add_label(m, "Go Down", '>', 12, labels);
	}
	menu_dynamic_add_label(m, "Search", 's', 3, labels);
	menu_dynamic_add_label(m, "Look", 'l', 6, labels);
	menu_dynamic_add_label(m, "Rest", 'R', 4, labels);
	menu_dynamic_add_label(m, "Inventory", 'i', 5, labels);
	/* if object under player add pickup option */
	if (c_ptr->o_idx) {
		object_type *o_ptr = &(o_list[c_ptr->o_idx]);
		//if (!squelch_item_ok(o_ptr)) {
  			menu_dynamic_add_label(m, "Floor", 'i', 13, labels);
			if (inven_carry_okay(o_ptr)) {
  				menu_dynamic_add_label(m, "Pickup", 'g', 14, labels);
			} else {
  				menu_dynamic_add_label(m, "$Pickup", 'g', 14, labels);
			}
		//}
	}
	menu_dynamic_add_label(m, "Character", 'C', 7, labels);
	/* XXX Don't show the keymap line until the keymap list is implemented, to
	 * avoid confusion as to what should be there */
	/*menu_dynamic_add(m, "Keymaps", 10);*/
	if (!OPT(center_player)) {
		menu_dynamic_add_label(m, "^Center Map", 'L', 15, labels);
	}
	menu_dynamic_add_label(m, "Other", ' ', 9, labels);

	/* work out display region */
	r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */
	if (mx > Term->wid - r.width - 1) {
		r.col = Term->wid - r.width - 1;
	} else {
		r.col = mx + 1;
	}
	r.page_rows = m->count;
	if (my > Term->hgt - r.page_rows - 1) {
		if (my - r.page_rows - 1 <= 0) {
			/* menu has too many items, so put in upper right corner */
			r.row = 1;
			r.col = Term->wid - r.width - 1;
		} else {
			r.row = Term->hgt - r.page_rows - 1;
		}
	} else {
		r.row = my + 1;
	}

	/* Hack -- no flush needed */
	msg_flag = FALSE;

	screen_save();
	button_backup_all(TRUE);

	menu_layout(m, &r);
	rect_region_erase_bordered(&r);

	prtf(0, 0, "($UEnter to select$Y\n$V, $UESC$Y%c$V) Command:", ESCAPE);
	selected = menu_dynamic_select(m);

	menu_dynamic_free(m);
	string_free(labels);

	button_restore();
	screen_load();

	switch(selected) {
	case 1:
		{
			/* use an item */
			p_ptr->cmd.cmd = 'u';
			repeat_check();
			do_cmd_use();
		} break;
	case 2:
		{
			/* Cast a spell */
			p_ptr->cmd.cmd = 'm';
			repeat_check();
			do_cmd_cast_wrapper();
		} break;
	case 3:
		{
			/* search */
			p_ptr->cmd.cmd = 's';
			repeat_check();
			do_cmd_search();
		} break;
	case 4:
		{
			/* rest */
			p_ptr->cmd.cmd = 'R';
			repeat_check();
			do_cmd_rest();
		} break;
	case 5:
		{
			/* show inventory screen */
			Term_keypress('i');//,0);
		} break;
	case 6:
		{
			/* look mode */
			if (target_set(TARGET_LOOK)) {
			//if (target_set_interactive(TARGET_LOOK, p_ptr->px, p_ptr->py)) {
				msgf("Target Selected.");
			}
		} break;
	case 7:
		{
			/* show character screen */
			do_cmd_character();
		} break;
	case 9:
		{
			/* show another layer of menu options screen */
			int res;
			while ((res = context_menu_player_2(mx,my)) == 3);
			if (res == 2) return 3;
		} break;
	case 10:
		{
			/* show the commands */
			int res;
			while ((res = context_menu_command(mx,my)) == 3);
			if (res == 2) return 3;
		} break;
	case 11:
		{
			/* go up stairs */
			p_ptr->cmd.cmd = '<';
			repeat_check();
			do_cmd_go_up();
		} break;
	case 12:
		{
			/* go down stairs */
			p_ptr->cmd.cmd = '>';
			repeat_check();
			do_cmd_go_down();
		} break;
	case 13:
		{
			if (c_ptr->o_idx) {
				object_type *o_ptr = &(o_list[c_ptr->o_idx]);
				/* there is an item on the floor, show the inventory screen starting
				 * from the floor */
				if (o_ptr->next_o_idx) {
					do_cmd_inven_floor();
				} else {
					/* if  we only have one item, show the context menu directly */
					if (o_ptr->k_idx) {
						/* Track the object kind */
						object_kind_track(o_ptr->k_idx);

						while (context_menu_object(o_ptr) == 2);
					}
				}
			}
		} break;
	case 14:
		{
			/* pick the item up */
			//cmd_insert(CMD_PICKUP);
			//cmd_set_arg_item(cmd_get_top(), 0, -1);
			carry(TRUE);
		} break;
	case 15:
		{
			/* center the map on the player */
			/*panel_center(p_ptr->px, p_ptr->py);*/
			do_cmd_center_map();
		} break;
	case 16:
		{
			/* use character powers */
			p_ptr->cmd.cmd = 'U';
			repeat_check();
			do_cmd_racial_power();
		} break;

	}

	return 1;
}
Ejemplo n.º 2
0
void commands_angband_keyset(int key_press, bool shift_key, bool alt_key, bool ctrl_key, bool meta_key)
{
    bool using_mods = FALSE;
    if (shift_key || alt_key || ctrl_key || meta_key) using_mods = TRUE;

    // Normal mode
    switch (key_press)
    {
        // ESCAPE
        case Qt::Key_Escape:
        {
            ui_center(p_ptr->py, p_ptr->px);
            break;
        }

        // Move down
        case Qt::Key_2:
        case Qt::Key_Down:
        {
            process_move_key(2, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }

        // Move up
        case Qt::Key_8:
        case Qt::Key_Up:
        {
            process_move_key(8, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }

        // Move left
        case Qt::Key_4:
        case Qt::Key_Left:
        {
            process_move_key(4, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move right
        case Qt::Key_6:
        case Qt::Key_Right:
        {
            process_move_key(6, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally left and up
        case Qt::Key_7:
        case Qt::Key_Home:
        {
            process_move_key(7, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally right and up
        case Qt::Key_9:
        case Qt::Key_PageUp:
        {
            process_move_key(9, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally left and down
        case Qt::Key_1:
        case Qt::Key_End:
        {
            process_move_key(1, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        // Move diagonally right and down
        case Qt::Key_3:
        case Qt::Key_PageDown:
        {
            process_move_key(3, shift_key, alt_key, ctrl_key, meta_key);
            break;
        }
        case Qt::Key_5:
        case Qt::Key_Clear:
        {
            do_cmd_hold();
            break;
        }
        case Qt::Key_A:
        {
            if (alt_key)           do_cmd_wizard_mode();
            else if (shift_key)          do_cmd_activate();
            else if (!using_mods)   do_cmd_aim_wand();
            break;
        }
        case Qt::Key_B:
        {
            if (shift_key)          do_cmd_bash(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_browse(-1);
            break;
        }
        case Qt::Key_C:
        {
            if (shift_key && alt_key) save_character_file();
            else if (shift_key)     do_cmd_character_screen();
            else if (!using_mods)   do_cmd_close(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_D:
        {
            if (shift_key)          do_cmd_disarm(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_drop();
            break;
        }
        case Qt::Key_E:
        {
            if (shift_key)          do_cmd_eat_food();
            else if (!using_mods)   do_cmd_all_objects(TAB_EQUIP);
            break;
        }
        case Qt::Key_F:
        {
            if (ctrl_key)           do_cmd_feeling();
            else if (shift_key)     do_cmd_refuel();
            else if (!using_mods)   do_cmd_fire();
            break;
        }
        case Qt::Key_G:
        {
            if (shift_key)          do_cmd_study(-1);
            else if (!using_mods)   do_cmd_pickup_from_pile(FALSE, TRUE);
            break;
        }
        case Qt::Key_H:
        {
            if (!using_mods)        do_cmd_fire_at_nearest();
            break;
        }
        case Qt::Key_I:
        {
            if (shift_key)          do_cmd_examine();
            else if (!using_mods)   do_cmd_all_objects(TAB_INVEN);
            break;
        }
        case Qt::Key_J:
        {
            if (!using_mods)        do_cmd_spike(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_K:
        {
            if (!using_mods)        do_cmd_destroy();
            break;
        }
        case Qt::Key_L:
        {
            if (shift_key)          ui_center(p_ptr->py, p_ptr->px);
            else if (!using_mods)   do_cmd_look();
            break;
        }
        case Qt::Key_M:
        {
            if (shift_key)          break; // TODO - MAP
            else if (!using_mods)   do_cmd_cast(-1);
            break;
        }
        case Qt::Key_N:
        case Qt::Key_0:
        case Qt::Key_Insert:
        {
            if (!using_mods)        do_cmd_repeat();
            break;
        }
        case Qt::Key_O:
        {
            if (shift_key)          do_cmd_make_trap(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_open(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_P:
        {
            if (ctrl_key)           display_message_log();
            else if (!using_mods)   do_cmd_cast(-1);
            break;
        }
        case Qt::Key_Q:
        {
            if (alt_key)            do_cmd_quest_desc();
            else if (shift_key)     do_cmd_suicide();
            else if (!using_mods)   do_cmd_quaff_potion();
            break;
        }
        case Qt::Key_R:
        {
            if (ctrl_key)           ui_redraw_all();
            else if (shift_key)     do_cmd_rest();
            else if (!using_mods)   do_cmd_read_scroll();
            break;
        }
        case Qt::Key_S:
        {
            if (shift_key)          do_cmd_toggle_search();
            else if (!using_mods)   do_cmd_search();
            break;
        }
        case Qt::Key_T:
        {
            if (shift_key)          do_cmd_tunnel(DIR_UNKNOWN);
            else if (!using_mods)   do_cmd_takeoff();
            break;
        }
        case Qt::Key_U:
        {
            if (!using_mods)        do_cmd_use_staff();
            break;
        }
        case Qt::Key_V:
        {
            if (!using_mods)        do_cmd_throw();
            break;
        }
        case Qt::Key_W:
        {
            if (!using_mods)   do_cmd_wield();
            break;
        }
        case Qt::Key_X:
        {
            if (!using_mods)        do_cmd_swap_weapon();
            break;
        }
        case Qt::Key_Y:
        {
            break;
        }
        case Qt::Key_Z:
        {
            if (!using_mods)        do_cmd_zap_rod();
            break;
        }
        case Qt::Key_Apostrophe:
        case Qt::Key_Asterisk:
        {
            target_set_closest(TARGET_KILL);
            break;
        }
        case Qt::Key_BraceLeft:
        {
            do_cmd_inscribe();
            break;
        }
        case Qt::Key_BraceRight:
        {
            do_cmd_uninscribe();
            break;
        }
        case Qt::Key_Greater:
        {
            do_cmd_go_down();
            break;
        }
        case Qt::Key_Less:
        {
            do_cmd_go_up();
            break;
        }
        case Qt::Key_Period:
        {
            do_cmd_run(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_Plus:
        {
            do_cmd_alter(DIR_UNKNOWN);
            break;
        }
        case Qt::Key_Minus:
        {
            do_cmd_walk(DIR_UNKNOWN, TRUE);
            break;
        }
        case Qt::Key_Underscore:
        case Qt::Key_Comma:
        {
            do_cmd_hold();
            break;
        }
        case Qt::Key_Semicolon:
        {
            do_cmd_walk(DIR_UNKNOWN, FALSE);
            break;
        }
        case Qt::Key_Colon:
        {
            do_cmd_write_note();
            break;
        }
        case Qt::Key_ParenRight:
        {
            save_screenshot(FALSE);
            break;
        }
        case Qt::Key_ParenLeft:
        {
            save_screenshot(TRUE);
            break;
        }
        case Qt::Key_AsciiTilde:
        {
            do_cmd_knowledge_screens();
            break;
        }
        default:
        {
            break;
        }
    }
}