Esempio n. 1
0
	static int keypress_itemlist_handler(window_info *win, int mx, int my, Uint32 key, Uint32 unikey)
	{
		char keychar = tolower(key_to_char(unikey));
		if ((keychar == '`') || (key & ELW_CTRL) || (key & ELW_ALT))
			return 0;
		return Vars::win()->keypress(keychar);
	}
Esempio n. 2
0
/*	Add shortcut keypresses for search
*/
int keypress_encyclopedia_handler(window_info *win, int mx, int my, Uint32 key, Uint32 unikey)
{
	char keychar = tolower(key_to_char(unikey));
	if ((key == K_MARKFILTER) || (keychar=='/'))
	{
		cm_encycl_handler(win, -1, mx, my, CM_ENCYCL_SEARCH);
		return 1;
	}
	return 0;
}
Esempio n. 3
0
/* key presses in the window used for a recipe name search string */
static int keypress_recipe_handler(window_info *win, int mx, int my, Uint32 key, Uint32 unikey)
{
	char keychar = tolower(key_to_char(unikey));
	last_recipe_key_time = SDL_GetTicks();
	if ((keychar == SDLK_RETURN) && (key & ELW_CTRL))
	{
		select_recipe(cur_recipe);
		return 1;
	}
	if ((keychar == '`') || (key & ELW_CTRL) || (key & ELW_ALT))
		return 0;
	if (keychar == SDLK_ESCAPE)
	{
		clear_recipe_filter();
		return 1;
	}
	if (string_input(recipe_name_filter, sizeof(recipe_name_filter), keychar) || (keychar == SDLK_RETURN))
	{
		if (strlen(recipe_name_filter))
		{
			size_t i;
			for (i=cur_recipe+1; i<cur_recipe+num_recipe_entries; i++)
			{
				size_t check = i % num_recipe_entries;
				if (recipes_store[check].name != NULL &&
					safe_strcasestr(recipes_store[check].name, strlen(recipes_store[check].name),
						recipe_name_filter, strlen(recipe_name_filter)) != NULL)
				{
					/* have matching name so set as the current and make sure visible */
					int first_displayed_recipe = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id);
					int new_pos = first_displayed_recipe;
					cur_recipe = check;
					if (cur_recipe < first_displayed_recipe)
						new_pos = cur_recipe;
					else if (cur_recipe >= (first_displayed_recipe+num_displayed_recipes))
						new_pos = cur_recipe - (num_displayed_recipes - 1);
					else
						break;
					vscrollbar_set_pos(win->window_id, recipe_win_scroll_id, new_pos);
					break;
				}
			}
		}
		return 1;
	}
	return 0;
}
Esempio n. 4
0
static int keypress_storage_handler(window_info *win, int mx, int my, Uint32 key, Uint32 unikey)
{
	char keychar = tolower(key_to_char(unikey));
	if (disable_storage_filter || (keychar == '`') || (key & ELW_CTRL) || (key & ELW_ALT))
		return 0;
	if (keychar == SDLK_ESCAPE)
	{
		filter_item_text[0] = '\0';
		filter_item_text_size = 0;
		return 1;
	}
	item_info_help_if_needed();
	if (string_input(filter_item_text, sizeof(filter_item_text), keychar))
	{
		filter_item_text_size = strlen(filter_item_text);
		if (filter_item_text_size > 0)
			filter_items_by_description(storage_items_filter, storage_items, filter_item_text, no_storage);
		return 1;
	}
	return 0;
}