static void select_items(int n) { int fsel = 0; while (42) { if (n > 0) print_item(fsel, STATUS_BG, STATUS_FG); switch (wait_any_key()) { case KEY_ENTER: setvar(V_sel_item, intobj[fsel]); goto exit_select; case KEY_ESCAPE: setvar(V_sel_item, 0xff); goto exit_select; case KEY_UP: if (fsel >= 2) fsel -= 2; break; case KEY_DOWN: if (fsel + 2 < n) fsel += 2; break; case KEY_LEFT: if (fsel % 2 == 1) fsel--; break; case KEY_RIGHT: if (fsel % 2 == 0 && fsel + 1 < n) fsel++; break; case BUTTON_LEFT:{ int i = find_item(); if (i >= 0 && i < n) { setvar(V_sel_item, intobj[fsel = i]); debugC(6, kDebugLevelInventory, "item found: %d", fsel); show_items(); print_item(fsel, STATUS_BG, STATUS_FG); do_update(); goto exit_select; } break; } default: break; } show_items(); do_update(); } exit_select: debugC(6, kDebugLevelInventory, "selected: %d", fsel); }
/** * Display inventory items. */ void inventory () { int old_fg, old_bg; int n; /* screen is white with black text */ old_fg = game.color_fg; old_bg = game.color_bg; game.color_fg = 0; game.color_bg = 15; clear_screen (game.color_bg); print_text (YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG); /* FIXME: doesn't check if objects overflow off screen... */ intobj = malloc (4 + game.num_objects); memset(intobj, 0, (4 + game.num_objects)); n = show_items (); if (getflag (F_status_selects_items)) { print_text (SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG); } else { print_text (ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG); } flush_screen (); /* If flag 13 is set, we want to highlight & select an item. * opon selection, put objnum in var 25. Then on esc put in * var 25 = 0xff. */ if (getflag (F_status_selects_items)) select_items (n); free (intobj); if (!getflag (F_status_selects_items)) wait_any_key(); clear_screen (0); write_status (); show_pic (); game.color_fg = old_fg; game.color_bg = old_bg; game.has_prompt = 0; flush_lines (game.line_user_input, 24); }
void tunit_create::filter_text_changed(ttext_* textbox, const std::string& text) { twindow& window = *textbox->get_window(); tlistbox& list = find_widget<tlistbox>(&window, "unit_type_list", false); const std::vector<std::string> words = utils::split(text, ' '); if(words == last_words_) return; last_words_ = words; boost::dynamic_bitset<> show_items(list.get_item_count(), true); if(!text.empty()) { for(unsigned int i = 0; i < list.get_item_count(); i++) { tgrid* row = list.get_row_grid(i); tgrid::iterator it = row->begin(); tlabel& type_label = find_widget<tlabel>(*it, "unit_type", false); bool found = false; for(const auto & word : words) { found = std::search(type_label.label().str().begin(), type_label.label().str().end(), word.begin(), word.end(), chars_equal_insensitive) != type_label.label().str().end(); if(!found) { // one word doesn't match, we don't reach words.end() break; } } show_items[i] = found; } } list.set_row_shown(show_items); }
void inventaire() { stats_arme(); my_putstr(" =========================\n"); my_putstr(" EQUIPEMENT"); my_putstr("\n =========================\n"); show_equip(); my_putstr("\n"); my_putstr(" =========================\n"); my_putstr(" AUTRES"); my_putstr("\n =========================\n"); show_items(); my_putstr("\n"); my_putstr(" =========================\n"); my_putstr(" MEDICAMENTS"); my_putstr("\n =========================\n"); printf(" Possédés : %d\n\n", jena.medicaments); my_putstr("\n"); }
void tunit_recall::filter_text_changed(ttext_* textbox, const std::string& text) { twindow& window = *textbox->get_window(); tlistbox& list = find_widget<tlistbox>(&window, "recall_list", false); const std::vector<std::string> words = utils::split(text, ' '); if(words == last_words_) return; last_words_ = words; boost::dynamic_bitset<> show_items(list.get_item_count(), true); if(!text.empty()) { for(unsigned int i = 0; i < list.get_item_count(); i++) { bool found = false; for(const auto & word : words) { found = std::search(filter_options_[i].begin(), filter_options_[i].end(), word.begin(), word.end(), chars_equal_insensitive) != filter_options_[i].end(); if(!found) { // one word doesn't match, we don't reach words.end() break; } } show_items[i] = found; } } list.set_row_shown(show_items); }
static void show_items(char* result, hero& player, const char* title, stat_s g1, stat_s g2) { deck items; player.select(items, g1); player.select(items, g2); show_items(result, items, title); }