-#include "window/display-sub-windows.h"
-#include "core/window-redrawer.h"
+#include "window/display-sub-windows.h"
#include "flavor/flavor-describer.h"
#include "floor/cave.h"
#include "game-option/option-flags.h"
#include "game-option/text-display-options.h"
#include "grid/feature.h"
#include "inventory/inventory-describer.h"
-#include "inventory/inventory-slot-types.h"
#include "inventory/inventory-util.h"
#include "locale/japanese.h"
#include "main/sound-of-music.h"
#include "mind/mind-sniper.h"
#include "mind/mind-types.h"
#include "monster-race/monster-race.h"
-#include "monster-race/race-flags1.h"
-#include "monster/monster-flag-types.h"
-#include "monster/monster-info.h"
-#include "monster/monster-status.h"
+#include "monster/monster-describer.h"
+#include "monster/monster-description-types.h"
#include "object/item-tester-hooker.h"
#include "object/object-info.h"
-#include "object/object-mark-types.h"
#include "player-base/player-class.h"
#include "player-info/class-info.h"
#include "player/player-status-flags.h"
#include "player/player-status-table.h"
#include "player/player-status.h"
#include "realm/realm-names-table.h"
-#include "spell-kind/magic-item-recharger.h"
#include "spell/spells-execution.h"
-#include "spell/technic-info-table.h"
-#include "system/baseitem-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
#include "system/monster-race-info.h"
-#include "system/player-type-definition.h"
#include "system/terrain-type-definition.h"
-#include "target/target-describer.h"
#include "target/target-preparation.h"
-#include "target/target-setter.h"
-#include "target/target-types.h"
#include "term/gameterm.h"
#include "term/screen-processor.h"
-#include "term/term-color-types.h"
-#include "term/z-form.h"
#include "timed-effect/player-hallucination.h"
#include "timed-effect/player-stun.h"
#include "timed-effect/timed-effects.h"
-#include "util/bit-flags-calculator.h"
#include "util/int-char-converter.h"
#include "view/display-lore.h"
#include "view/display-map.h"
* @param pw_flag 描画を行うフラグ
* @param display_func 描画を行う関数
*/
-static void display_sub_windows(window_redraw_type pw_flag, std::invocable auto display_func)
+static void display_sub_windows(SubWindowRedrawingFlag pw_flag, std::invocable auto display_func)
{
auto current_term = game_term;
continue;
}
- if (none_bits(window_flag[i], pw_flag)) {
+ if (!g_window_flags[i].has(pw_flag)) {
continue;
}
*/
void fix_inventory(PlayerType *player_ptr)
{
- display_sub_windows(PW_INVENTORY,
+ display_sub_windows(SubWindowRedrawingFlag::INVENTORY,
[player_ptr] {
display_inventory(player_ptr, *fix_item_tester);
});
MonsterRaceId r_idx = m_ptr->ap_r_idx;
auto *r_ptr = &monraces_info[r_idx];
- term_erase(0, y, 255);
+ term_erase(0, y);
term_gotoxy(x, y);
if (!r_ptr) {
return;
}
for (; line < max_lines; line++) {
- term_erase(0, line, 255);
+ term_erase(0, line);
+ }
+}
+
+static void print_pet_list_oneline(PlayerType *player_ptr, const MonsterEntity &monster, TERM_LEN x, TERM_LEN y, TERM_LEN width)
+{
+ const auto &monrace = monraces_info[monster.ap_r_idx];
+ const auto name = monster_desc(player_ptr, &monster, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE | MD_NO_OWNER);
+ const auto &[bar_color, bar_len] = monster.get_hp_bar_data();
+ const auto is_visible = monster.ml && !player_ptr->effects()->hallucination()->is_hallucinated();
+
+ term_erase(0, y);
+ if (is_visible) {
+ term_putstr(x, y, -1, TERM_WHITE, "[----------]");
+ term_putstr(x + 1, y, bar_len, bar_color, "**********");
+ }
+
+ term_gotoxy(x + 13, y);
+ term_add_bigch(monrace.x_attr, monrace.x_char);
+ term_addstr(-1, TERM_WHITE, " ");
+ term_addstr(-1, TERM_WHITE, name);
+
+ if (width >= 50) {
+ const auto location = format(" (X:%3d Y:%3d)", monster.fx, monster.fy);
+ prt(is_visible ? location : "", y, width - location.length());
+ }
+}
+
+static void print_pet_list(PlayerType *player_ptr, const std::vector<MONSTER_IDX> &pets, TERM_LEN x, TERM_LEN y, TERM_LEN width, TERM_LEN height)
+{
+ for (auto n = 0U; n < pets.size(); ++n) {
+ const auto &monster = player_ptr->current_floor_ptr->m_list[pets[n]];
+ const int line = y + n;
+
+ print_pet_list_oneline(player_ptr, monster, x, line, width);
+
+ if ((line == height - 2) && (n < pets.size() - 2)) {
+ term_erase(0, line + 1);
+ term_putstr(x, line + 1, -1, TERM_WHITE, "-- and more --");
+ break;
+ }
+ }
+
+ for (int n = pets.size(); n < height; ++n) {
+ term_erase(0, y + n);
}
}
static std::vector<MONSTER_IDX> monster_list;
std::once_flag once;
- display_sub_windows(PW_SIGHT_MONSTERS,
+ display_sub_windows(SubWindowRedrawingFlag::SIGHT_MONSTERS,
[player_ptr, &once] {
- int w, h;
- term_get_size(&w, &h);
+ const auto &[wid, hgt] = term_get_size();
std::call_once(once, target_sensing_monsters_prepare, player_ptr, monster_list);
- print_monster_list(player_ptr->current_floor_ptr, monster_list, 0, 0, h);
+ print_monster_list(player_ptr->current_floor_ptr, monster_list, 0, 0, hgt);
});
if (use_music && has_monster_music) {
}
/*!
+ * @brief 視界内のペットのリストをサブウィンドウに表示する
+ */
+void fix_pet_list(PlayerType *player_ptr)
+{
+ display_sub_windows(SubWindowRedrawingFlag::PETS,
+ [player_ptr] {
+ const auto &[wid, hgt] = term_get_size();
+ const auto pets = target_pets_prepare(player_ptr);
+ print_pet_list(player_ptr, pets, 0, 0, wid, hgt);
+ });
+}
+
+/*!
* @brief 装備アイテム一覧を表示する /
* Choice window "shadow" of the "show_equip()" function
*/
return;
}
- TERM_LEN wid, hgt;
- term_get_size(&wid, &hgt);
+ const auto &[wid, hgt] = term_get_size();
byte attr = TERM_WHITE;
for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
int cur_row = i - INVEN_MAIN_HAND;
}
int cur_col = 3;
- term_erase(cur_col, cur_row, 255);
+ term_erase(cur_col, cur_row);
term_putstr(0, cur_row, cur_col, TERM_WHITE, tmp_val);
std::string item_name;
}
for (int i = INVEN_TOTAL - INVEN_MAIN_HAND; i < hgt; i++) {
- term_erase(0, i, 255);
+ term_erase(0, i);
}
}
*/
void fix_equip(PlayerType *player_ptr)
{
- display_sub_windows(PW_EQUIPMENT,
+ display_sub_windows(SubWindowRedrawingFlag::EQUIPMENT,
[player_ptr] {
display_equipment(player_ptr, *fix_item_tester);
});
void fix_player(PlayerType *player_ptr)
{
update_playtime();
- display_sub_windows(PW_PLAYER,
+ display_sub_windows(SubWindowRedrawingFlag::PLAYER,
[player_ptr] {
display_player(player_ptr, 0);
});
*/
void fix_message(void)
{
- display_sub_windows(PW_MESSAGE,
+ display_sub_windows(SubWindowRedrawingFlag::MESSAGE,
[] {
- TERM_LEN w, h;
- term_get_size(&w, &h);
- for (int i = 0; i < h; i++) {
- term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((int16_t)i));
+ const auto &[wid, hgt] = term_get_size();
+ for (short i = 0; i < hgt; i++) {
+ term_putstr(0, (hgt - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), *message_str(i));
TERM_LEN x, y;
term_locate(&x, &y);
- term_erase(x, y, 255);
+ term_erase(x, y);
}
});
}
*/
void fix_overhead(PlayerType *player_ptr)
{
- display_sub_windows(PW_OVERHEAD,
+ display_sub_windows(SubWindowRedrawingFlag::OVERHEAD,
[player_ptr] {
- TERM_LEN wid, hgt;
- term_get_size(&wid, &hgt);
+ const auto &[wid, hgt] = term_get_size();
if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
int cy, cx;
display_map(player_ptr, &cy, &cx);
*/
void fix_dungeon(PlayerType *player_ptr)
{
- display_sub_windows(PW_DUNGEON,
+ display_sub_windows(SubWindowRedrawingFlag::DUNGEON,
[player_ptr] {
display_dungeon(player_ptr);
});
if (!MonsterRace(player_ptr->monster_race_idx).is_valid()) {
return;
}
- display_sub_windows(PW_MONSTER_LORE,
+ display_sub_windows(SubWindowRedrawingFlag::MONSTER_LORE,
[player_ptr] {
display_roff(player_ptr);
});
*/
void fix_object(PlayerType *player_ptr)
{
- display_sub_windows(PW_ITEM_KNOWLEDGTE,
+ display_sub_windows(SubWindowRedrawingFlag::ITEM_KNOWLEDGE,
[player_ptr] {
display_koff(player_ptr);
});
*/
static void display_floor_item_list(PlayerType *player_ptr, const int y, const int x)
{
- // Term の行数を取得。
- TERM_LEN term_h;
- {
- TERM_LEN term_w;
- term_get_size(&term_w, &term_h);
- }
- if (term_h <= 0) {
+ const auto &[wid, hgt] = term_get_size();
+ if (hgt <= 0) {
return;
}
}
// 途中で行数が足りなくなったら最終行にその旨追記して終了。
- if (term_y >= term_h) {
+ if (term_y >= hgt) {
term_addstr(-1, TERM_WHITE, "-- more --");
break;
}
*/
void fix_floor_item_list(PlayerType *player_ptr, const int y, const int x)
{
- display_sub_windows(PW_FLOOR_ITEMS,
+ display_sub_windows(SubWindowRedrawingFlag::FLOOR_ITEMS,
[player_ptr, y, x] {
display_floor_item_list(player_ptr, y, x);
});
*/
static void display_found_item_list(PlayerType *player_ptr)
{
- // Term の行数を取得。
- TERM_LEN term_h;
- TERM_LEN term_w;
- term_get_size(&term_w, &term_h);
-
- if (term_h <= 0) {
+ const auto &[wid, hgt] = term_get_size();
+ if (hgt <= 0) {
return;
}
// ItemKindTypeがGOLD
std::vector<ItemEntity *> found_item_list;
for (auto &item : floor_ptr->o_list) {
- auto item_entity_ptr = &item;
- if (item_entity_ptr->is_valid() && item_entity_ptr->marked.has(OmType::FOUND) && item_entity_ptr->bi_key.tval() != ItemKindType::GOLD) {
- found_item_list.push_back(item_entity_ptr);
+ const auto is_item_to_display =
+ item.is_valid() && (item.number > 0) &&
+ item.marked.has(OmType::FOUND) && (item.bi_key.tval() != ItemKindType::GOLD);
+
+ if (is_item_to_display) {
+ found_item_list.push_back(&item);
}
}
TERM_LEN term_y = 1;
for (auto item : found_item_list) {
// 途中で行数が足りなくなったら終了。
- if (term_y >= term_h) {
+ if (term_y >= hgt) {
break;
}
// アイテムシンボル表示
const auto symbol_code = item->get_symbol();
- const std::string symbol = format(" %c ", symbol_code);
+ const auto symbol = format(" %c ", symbol_code);
const auto color_code_for_symbol = item->get_color();
- term_addstr(-1, color_code_for_symbol, symbol.data());
+ term_addstr(-1, color_code_for_symbol, symbol);
const auto item_name = describe_flavor(player_ptr, item, 0);
const auto color_code_for_item = tval_to_attr[enum2i(item->bi_key.tval()) % 128];
term_addstr(-1, color_code_for_item, item_name);
// アイテム座標表示
- const std::string item_location = format("(X:%3d Y:%3d)", item->ix, item->iy);
- prt(item_location.data(), term_y, term_w - item_location.length() - 1);
+ const auto item_location = format("(X:%3d Y:%3d)", item->ix, item->iy);
+ prt(item_location, term_y, wid - item_location.length() - 1);
++term_y;
}
*/
void fix_found_item_list(PlayerType *player_ptr)
{
- display_sub_windows(PW_FOUND_ITEMS,
+ display_sub_windows(SubWindowRedrawingFlag::FOUND_ITEMS,
[player_ptr] {
display_found_item_list(player_ptr);
});
*/
void fix_spell(PlayerType *player_ptr)
{
- display_sub_windows(PW_SPELL,
+ display_sub_windows(SubWindowRedrawingFlag::SPELL,
[player_ptr] {
display_spell_list(player_ptr);
});
}
/*!
- * @brief サブウィンドウに所持品、装備品リストの表示を行う /
- * Flip "inven" and "equip" in any sub-windows
+ * @brief サブウィンドウに所持品、装備品リストの表示を行う
*/
-void toggle_inventory_equipment(PlayerType *player_ptr)
+void toggle_inventory_equipment()
{
+ auto &rfu = RedrawingFlagsUpdater::get_instance();
for (auto i = 0U; i < angband_terms.size(); ++i) {
if (!angband_terms[i]) {
continue;
}
- if (window_flag[i] & (PW_INVENTORY)) {
- window_flag[i] &= ~(PW_INVENTORY);
- window_flag[i] |= (PW_EQUIPMENT);
- player_ptr->window_flags |= (PW_EQUIPMENT);
+ if (g_window_flags[i].has(SubWindowRedrawingFlag::INVENTORY)) {
+ g_window_flags[i].reset(SubWindowRedrawingFlag::INVENTORY);
+ g_window_flags[i].set(SubWindowRedrawingFlag::EQUIPMENT);
+ rfu.set_flag(SubWindowRedrawingFlag::EQUIPMENT);
continue;
}
- if (window_flag[i] & PW_EQUIPMENT) {
- window_flag[i] &= ~(PW_EQUIPMENT);
- window_flag[i] |= PW_INVENTORY;
- player_ptr->window_flags |= PW_INVENTORY;
+ if (g_window_flags[i].has(SubWindowRedrawingFlag::EQUIPMENT)) {
+ g_window_flags[i].reset(SubWindowRedrawingFlag::EQUIPMENT);
+ g_window_flags[i].set(SubWindowRedrawingFlag::INVENTORY);
+ rfu.set_flag(SubWindowRedrawingFlag::INVENTORY);
}
}
}