Use charToKey and clean up logic a bit

Ref #1714
develop
lethosor 2020-11-17 23:33:18 -05:00
parent 2d79052938
commit 53916dbe6b
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
1 changed files with 5 additions and 5 deletions

@ -860,13 +860,13 @@ struct buildingplan_room_hook : public df::viewscreen_dwarfmodest
return false;
auto np = getNoblePositionOfSelectedBuildingOwner();
df::interface_key last_token = get_string_key(input);
if (last_token >= interface_key::STRING_A048
&& last_token <= interface_key::STRING_A058)
if (last_token >= Screen::charToKey('1')
&& last_token <= Screen::charToKey('9'))
{
size_t selection = last_token - interface_key::STRING_A048;
if (np.size() < selection || selection == 0)
size_t index = last_token - Screen::charToKey('1');
if (index >= np.size())
return false;
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code);
roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(index).position->code);
return true;
}