Skip to content

Commit

Permalink
Adjust some empty quiver cycle messaging
Browse files Browse the repository at this point in the history
This gets rid of the vestiges of oldquiver error messages, and rewrites
things to use the newquiver code in a more straightforward way. This
removes some of the hints that the old errors gave about inscriptions
etc, but I think the simplification her targets everything that will be
likely to apply to newer players who need the hints in the first place.
  • Loading branch information
rawlins committed Jan 31, 2021
1 parent 967dceb commit e082b6e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 56 deletions.
16 changes: 12 additions & 4 deletions crawl-ref/source/main.cc
Expand Up @@ -1694,10 +1694,18 @@ static void _do_cycle_quiver(int dir)
you.launcher_action.set(you.quiver_action.get());
quiver::set_needs_redraw();

if (!changed && you.quiver_action.get()->is_valid())
mpr("No other quiver actions available. Use F to throw any item.");
else if (!you.quiver_action.get()->is_valid())
mpr("No quiver actions available. Use F to throw any item.");
const bool valid = you.quiver_action.get()->is_valid();

if (!changed || !valid)
{
const bool others = quiver::menu_size() > (valid ? 1 : 0);
// Things could be excluded from this via inscriptions, custom
// fire_order, or setting fire_items_start.
mprf("No %squiver actions available for cycling.%s",
valid ? "other " : "",
others ? " Use <white>Q</white> to select from all actions."
: "");
}
}

static void _do_list_gold()
Expand Down
75 changes: 25 additions & 50 deletions crawl-ref/source/quiver.cc
Expand Up @@ -1919,11 +1919,7 @@ namespace quiver
{
// Felids have no use for launchers or ammo.
if (you.species == SP_FELID)
{
auto result = make_shared<ammo_action>(-1);
result->error = "You can't grasp things well enough to shoot them.";
return result;
}
return make_shared<ammo_action>(-1);

int slot = -1;

Expand Down Expand Up @@ -1970,34 +1966,6 @@ namespace quiver
? make_shared<launcher_ammo_action>(slot)
: make_shared<ammo_action>(slot);

// if slot is still -1, we have failed, and the fire order is
// empty for some reason. We should therefore populate the `error`
// field for result.
if (slot == -1)
{
vector<int> full_fire_order;
_get_item_fire_order(full_fire_order, true, item, false);

if (full_fire_order.empty())
result->error = "No suitable missiles.";
else
{
const int skipped_item = full_fire_order[0];
if (skipped_item < Options.fire_items_start)
{
result->error = make_stringf(
"Nothing suitable (fire_items_start = '%c').",
index_to_letter(Options.fire_items_start));
}
else
{
result->error = make_stringf(
"Nothing suitable (ignored '=f'-inscribed item on '%c').",
index_to_letter(skipped_item));
}
}
}

return result;
}

Expand Down Expand Up @@ -2379,14 +2347,8 @@ namespace quiver

// is this legacy(?) check needed? Maybe only relevant for fumble throwing?
for (int i = EQ_MIN_ARMOUR; i <= EQ_MAX_WORN; i++)
{
if (you.equip[i] == slot)
{
auto a = make_shared<ammo_action>(-1);
a->error = "You can't toss equipped items.";
return a;
}
}
return make_shared<ammo_action>(-1);

shared_ptr<action> a = nullptr;
if (you.weapon() && is_range_weapon(*you.weapon()))
Expand Down Expand Up @@ -2739,18 +2701,10 @@ namespace quiver
}
}

/**
* Presents an interface for the player to choose an action to quiver from
* a list of options.
* @param cur_quiver a quiver to use for context
* @param allow_empty whether to allow the player to set the empty quiver
*/
void choose(action_cycler &cur_quiver, bool allow_empty)
static vector<shared_ptr<action>> _menu_quiver_order()
{
// should be action_cycler method?
// TODO: dividers or subtitles for each category?
ActionSelectMenu menu(cur_quiver, allow_empty);
vector<shared_ptr<action>> actions;
// TODO: this is kind of ugly
auto tmp = ammo_action(-1).get_menu_fire_order(true);
actions.insert(actions.end(), tmp.begin(), tmp.end());
tmp = launcher_ammo_action(-1).get_menu_fire_order(true);
Expand All @@ -2765,6 +2719,27 @@ namespace quiver
actions.insert(actions.end(), tmp.begin(), tmp.end());
tmp = ability_action(ABIL_NON_ABILITY).get_fire_order();
actions.insert(actions.end(), tmp.begin(), tmp.end());
return actions;
}

int menu_size()
{
return _menu_quiver_order().size();
}

/**
* Presents an interface for the player to choose an action to quiver from
* a list of options.
* @param cur_quiver a quiver to use for context
* @param allow_empty whether to allow the player to set the empty quiver
*/
void choose(action_cycler &cur_quiver, bool allow_empty)
{
// should be action_cycler method?
// TODO: dividers or subtitles for each category?
ActionSelectMenu menu(cur_quiver, allow_empty);

auto actions = _menu_quiver_order();

if (actions.size() == 0 && menu.pointless())
{
Expand Down
5 changes: 3 additions & 2 deletions crawl-ref/source/quiver.h
Expand Up @@ -37,7 +37,7 @@ namespace quiver
struct action : public enable_shared_from_this<action>
{
action()
: target(), error(), default_fire_context(nullptr)
: target(), default_fire_context(nullptr)
{ };
virtual ~action() = default;
void reset();
Expand Down Expand Up @@ -109,7 +109,6 @@ namespace quiver
}

dist target;
string error;
const action_cycler *default_fire_context;
};

Expand All @@ -124,6 +123,8 @@ namespace quiver
shared_ptr<action> get_secondary_action();
void set_needs_redraw();

int menu_size();

// this is roughly a custom not_null wrapper on shared_ptr<action>
struct action_cycler
{
Expand Down

0 comments on commit e082b6e

Please sign in to comment.