Skip to content

Commit

Permalink
feat(port): UI, accessibility updates, tweaks (#4713)
Browse files Browse the repository at this point in the history
* feat(port): UI, accessibility updates, tweaks (#4636)

* Port UI, accessibility updates, tweaks

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

* Misc tweaks update

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

---------

Co-Authored-By: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>

Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>

Co-Authored-By: Coolthulhu <Coolthulhu@gmail.com>

[ui] Properly render control characters in keybindings list (#54350)

fix

Merge pull request #57361 from Qrox/ui-fixes

Some UI fixes

Merge pull request #59035 from Qrox/cursor

Allow setting terminal cursor for screen readers and IME preview using ui_adaptor

Display vehicle interaction UI keybindings according to settings (#47229)

Info panel fixes and adding scrollbars (#50892)

Change item list highlight color to white (#51447)

* Change item list highlight color to white

* Position the cursor on the selected item in the item list [Not done in this port, cause based on the PR discussion after the merge, it doesn't work]

Merge pull request #58609 from ZeroInternalReflection/CraftingFilterSmallWindowFix

Allow scrolling of string_input_popup descriptions

Merge pull request #47585 from Qrox/crafting-gui-recp-info

Implement scrolling for recipe info in crafting gui

Merge pull request #47584 from Qrox/crafting-gui-keybind

Display actual bound keys in crafting gui

Merge pull request #57266 from Qrox/string-input-context

Allow customization of text input UI hotkeys

Add max length to worldname input length (#55152)

Made a constant to manage this attribute so it is easy to change
if the current max is deemed too short in the future.
fixes #55148

Merge pull request #46796 from Qrox/string-input-popup

Fix cursor movement of string input popup

Merge pull request #56212 from Qrox/queue

Properly fix conflicting `uilist` keys

Merge pull request #47263 from Qrox/paste

Allow pasting into input popup on tiles build

Merge pull request #40961 from ZhilkinSerg/sa-2020-05-29

Code optimizations reported by static code analysis (2020-05-29)

Co-Authored-By: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-Authored-By: Chaosvolt <chaosvolt@users.noreply.github.com>
Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-Authored-By: Rob Kuijper <robkuijper@live.nl>
Co-Authored-By: Brambor <13402666+Brambor@users.noreply.github.com>
Co-Authored-By: eltank <8000047+eltank@users.noreply.github.com>
Co-Authored-By: David Seguin <davidseguin@live.ca>
Co-Authored-By: ZeroInternalReflection <89038572+zerointernalreflection@users.noreply.github.com>
Co-Authored-By: martinrhan <53336429+martinrhan@users.noreply.github.com>
Co-Authored-By: Mark Langsdorf <mlangsdo@redhat.com>
Co-Authored-By: BevapDin <5095435+bevapdin@users.noreply.github.com>

Co-Authored-By: Olanti <olanti-p@yandex.ru>
Co-Authored-By: Coolthulhu <Coolthulhu@gmail.com>

style(autofix.ci): automated formatting

Co-Authored-By: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-Authored-By: Chaosvolt <chaosvolt@users.noreply.github.com>
Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-Authored-By: Rob Kuijper <robkuijper@live.nl>
Co-Authored-By: Brambor <13402666+Brambor@users.noreply.github.com>
Co-Authored-By: eltank <8000047+eltank@users.noreply.github.com>
Co-Authored-By: David Seguin <davidseguin@live.ca>
Co-Authored-By: ZeroInternalReflection <89038572+zerointernalreflection@users.noreply.github.com>
Co-Authored-By: martinrhan <53336429+martinrhan@users.noreply.github.com>
Co-Authored-By: Mark Langsdorf <mlangsdo@redhat.com>
Co-Authored-By: BevapDin <5095435+bevapdin@users.noreply.github.com>
Co-Authored-By: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-Authored-By: Olanti <olanti-p@yandex.ru>
Co-Authored-By: Coolthulhu <Coolthulhu@gmail.com>
Co-Authored-By: Kenan Mamedov <43505148+Kenan2000@users.noreply.github.com>

* Update Keybinds

Delete key now properly shows up and is usable. Remove KEYPAD_ENTER which doesn't seem to do anything.

* style(autofix.ci): automated formatting

* Add check in keybind loading for NULL input cases

They'll now throw an error instead of loading silently as Ctrl + @

---------

Co-authored-by: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-authored-by: Chaosvolt <chaosvolt@users.noreply.github.com>
Co-authored-by: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-authored-by: Rob Kuijper <robkuijper@live.nl>
Co-authored-by: Brambor <13402666+Brambor@users.noreply.github.com>
Co-authored-by: eltank <8000047+eltank@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
Co-authored-by: ZeroInternalReflection <89038572+zerointernalreflection@users.noreply.github.com>
Co-authored-by: martinrhan <53336429+martinrhan@users.noreply.github.com>
Co-authored-by: Mark Langsdorf <mlangsdo@redhat.com>
Co-authored-by: BevapDin <5095435+bevapdin@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Olanti <olanti-p@yandex.ru>
Co-authored-by: Coolthulhu <Coolthulhu@gmail.com>
Co-authored-by: Kenan Mamedov <43505148+Kenan2000@users.noreply.github.com>
  • Loading branch information
16 people committed Jun 5, 2024
1 parent f4aaffd commit 4286fd9
Show file tree
Hide file tree
Showing 79 changed files with 2,255 additions and 1,421 deletions.
142 changes: 139 additions & 3 deletions data/raw/keybindings/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,17 @@
},
{
"type": "keybinding",
"id": "CYCLE_MODE",
"id": "SCROLL_RECIPE_INFO_UP",
"category": "CRAFTING",
"name": "Cycle display mode",
"bindings": [ { "input_method": "keyboard", "key": "m" } ]
"name": "Scroll recipe info up",
"bindings": [ { "input_method": "keyboard", "key": "[" } ]
},
{
"type": "keybinding",
"id": "SCROLL_RECIPE_INFO_DOWN",
"category": "CRAFTING",
"name": "Scroll recipe info down",
"bindings": [ { "input_method": "keyboard", "key": "]" } ]
},
{
"type": "keybinding",
Expand Down Expand Up @@ -3351,5 +3358,134 @@
"name": "Scroll to the bottom",
"category": "LUA_CONSOLE",
"bindings": [ { "input_method": "keyboard", "key": "END" } ]
},
{
"type": "keybinding",
"id": "TEXT.QUIT",
"name": "Cancel text input",
"bindings": [ { "input_method": "keyboard", "key": "ESC" } ]
},
{
"type": "keybinding",
"id": "TEXT.CONFIRM",
"name": "Confirm text input",
"bindings": [ { "input_method": "keyboard", "key": "RETURN" } ]
},
{
"type": "keybinding",
"id": "TEXT.UP",
"name": "Move cursor up",
"bindings": [ { "input_method": "keyboard", "key": "UP" } ]
},
{
"type": "keybinding",
"id": "TEXT.DOWN",
"name": "Move cursor down",
"bindings": [ { "input_method": "keyboard", "key": "DOWN" } ]
},
{
"type": "keybinding",
"id": "TEXT.LEFT",
"name": "Move cursor left",
"bindings": [ { "input_method": "keyboard", "key": "LEFT" } ]
},
{
"type": "keybinding",
"id": "TEXT.RIGHT",
"name": "Move cursor right",
"bindings": [ { "input_method": "keyboard", "key": "RIGHT" } ]
},
{
"type": "keybinding",
"id": "TEXT.PAGE_UP",
"name": "Move cursor to previous page",
"bindings": [ { "input_method": "keyboard", "key": "PPAGE" } ]
},
{
"type": "keybinding",
"id": "TEXT.PAGE_DOWN",
"name": "Move cursor to next page",
"bindings": [ { "input_method": "keyboard", "key": "NPAGE" } ]
},
{
"type": "keybinding",
"id": "TEXT.CLEAR",
"name": "Clear text",
"bindings": [ { "input_method": "keyboard", "key": "CTRL+U" } ]
},
{
"type": "keybinding",
"id": "TEXT.BACKSPACE",
"name": "Remove previous character",
"bindings": [ { "input_method": "keyboard", "key": "BACKSPACE" } ]
},
{
"type": "keybinding",
"id": "TEXT.HOME",
"name": "Move cursor to start",
"bindings": [ { "input_method": "keyboard", "key": "HOME" } ]
},
{
"type": "keybinding",
"id": "TEXT.END",
"name": "Move cursor to end",
"bindings": [ { "input_method": "keyboard", "key": "END" } ]
},
{
"type": "keybinding",
"id": "TEXT.DELETE",
"name": "Remove current character",
"bindings": [ { "input_method": "keyboard", "key": "DELETE" } ]
},
{
"type": "keybinding",
"id": "TEXT.PASTE",
"name": "Paste from clipboard",
"bindings": [ { "input_method": "keyboard", "key": "CTRL+V" } ]
},
{
"type": "keybinding",
"id": "TEXT.INPUT_FROM_FILE",
"name": "Input text from file",
"bindings": [ { "input_method": "keyboard", "key": "F2" } ]
},
{
"type": "keybinding",
"id": "HISTORY_UP",
"name": "Show previous history",
"category": "STRING_INPUT",
"bindings": [ { "input_method": "keyboard", "key": "UP" } ]
},
{
"type": "keybinding",
"id": "HISTORY_DOWN",
"name": "Show next history",
"category": "STRING_INPUT",
"bindings": [ { "input_method": "keyboard", "key": "DOWN" } ]
},
{
"type": "keybinding",
"id": "HELP_KEYBINDINGS",
"name": "Display keybindings menu",
"category": "STRING_INPUT",
"//": "'?' is treated as text input, so a different key is used.",
"bindings": [ { "input_method": "keyboard", "key": "F1" } ]
},
{
"type": "keybinding",
"id": "TEXT.CONFIRM",
"name": "Confirm text input",
"category": "STRING_EDITOR",
"//": "RETURN is treated as text input, so use a different keybinding",
"//2": "CTRL+S is not available on curses, so add CTRL+Y as an alternative",
"bindings": [ { "input_method": "keyboard", "key": "CTRL+S" }, { "input_method": "keyboard", "key": "CTRL+Y" } ]
},
{
"type": "keybinding",
"id": "HELP_KEYBINDINGS",
"name": "Display keybindings menu",
"category": "STRING_EDITOR",
"//": "'?' is treated as text input, so a different key is used.",
"bindings": [ { "input_method": "keyboard", "key": "F1" } ]
}
]
45 changes: 11 additions & 34 deletions doc/src/content/docs/en/dev/explanation/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@
title: Compatibility with screen readers
---

There are people who uses screen readers to play Cataclysm DDA. In order for screen readers to
announce the most important information in a UI, the terminal cursor has to be placed at the correct
location. This information may be text such as selected item names in a list, etc, and the cursor
has to be placed exactly at the beginning of the text for screen readers to announce it.

`wmove` in `output.h|cpp` is the function to move the cursor to a specific location. After calling
`wmove` with the target `catacurses::window` and cursor position, `wrefresh` needs to be called
immediately afterwards for `wmove` to take effect.

Here is an example of placing the cursor explicitly at the beginning of a piece of text:

```cpp
catacurses::window win = ...; // target window

...

// display code
point cursor_position = ...; // default cursor position

...

cursor_position = point_zero; // record the start position of the text
fold_and_print( win, cursor_position, getmaxx( win ), c_white, _( "This text is important" ) );

...

// at the end of display code
wmove( win, cursor_position );
wrefresh( win );
// no output code should follow as they might change the cursor position
```
As shown in the above example, it is preferable to record the intended cursor position in a variable
when the text is printed, and move the cursor later using the variable to ensure consisitency.
There are people who use screen readers to play Cataclysm Bright Nights. In order for screen readers
to announce the most important information in a UI, the terminal cursor has to be placed at the
correct location. This information may be text such as selected item names in a list, etc, and the
cursor has to be placed exactly at the beginning of the text for screen readers to announce it.

The recommended way to place the cursor is to use `ui_adaptor`. This ensures the desired cursor
position is preserved when subsequent output code changes the cursor position. You can call
`ui_adaptor::set_cursor` and similar methods at any position in a redrawing callback, and the last
cursor position of the topmost UI set via the call will be used as the final cursor position. You
can also call `ui_adaptor::disable_cursor` to prevent a UI's cursor from being used as the final
cursor position.
2 changes: 1 addition & 1 deletion src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::vector<char> keys_bound_to( action_id act, const bool restrict_to_printable
action_id action_from_key( char ch )
{
input_context ctxt = get_default_mode_input_context();
const input_event event( ch, CATA_INPUT_KEYBOARD );
const input_event event( ch, input_event_t::keyboard );
const std::string &action = ctxt.input_to_action( event );
return look_up_action( action );
}
Expand Down
30 changes: 17 additions & 13 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
#include "vehicle_part.h"
#include "vpart_position.h"

enum creature_size : int;

static const activity_id ACT_ADV_INVENTORY( "ACT_ADV_INVENTORY" );
static const activity_id ACT_ARMOR_LAYERS( "ACT_ARMOR_LAYERS" );
static const activity_id ACT_ATM( "ACT_ATM" );
Expand Down Expand Up @@ -595,7 +597,7 @@ butchery_setup consider_butchery( const item &corpse_item, player &u, butcher_ty
inv.has_amount( itype_hd_tow_cable, 1 ) ||
inv.has_amount( itype_vine_30, 1 ) ||
inv.has_amount( itype_grapnel, 1 );
const bool big_corpse = corpse.size >= MS_MEDIUM;
const bool big_corpse = corpse.size >= creature_size::medium;

if( big_corpse ) {
if( has_rope && !has_tree_nearby && !b_rack_present ) {
Expand Down Expand Up @@ -635,7 +637,7 @@ butchery_setup consider_butchery( const item &corpse_item, player &u, butcher_ty
}

if( action == QUARTER ) {
if( corpse.size == MS_TINY ) {
if( corpse.size == creature_size::tiny ) {
not_this_one( _( "This corpse is too small to quarter without damaging." ),
butcherable_rating::too_small );
}
Expand Down Expand Up @@ -721,22 +723,22 @@ static void set_up_butchery_activity( player_activity &act, player &u, const but
act.index = false;
}

static int size_factor_in_time_to_cut( m_size size )
static int size_factor_in_time_to_cut( creature_size size )
{
switch( size ) {
// Time (roughly) in turns to cut up the corpse
case MS_TINY:
case creature_size::tiny:
return 150;
case MS_SMALL:
case creature_size::small:
return 300;
case MS_MEDIUM:
case creature_size::medium:
return 450;
case MS_LARGE:
case creature_size::large:
return 600;
case MS_HUGE:
case creature_size::huge:
return 1800;
default:
debugmsg( "Invalid m_size value for butchering corpse: %d", static_cast<int>( size ) );
debugmsg( "Invalid creature_size value for butchering corpse: %d", static_cast<int>( size ) );
break;
}
return 0;
Expand Down Expand Up @@ -950,7 +952,7 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player &
roll = roll / 4;
} else if( entry.type == "bone" ) {
roll /= 2;
} else if( corpse_item->get_mtype()->size >= MS_MEDIUM && ( entry.type == "skin" ) ) {
} else if( corpse_item->get_mtype()->size >= creature_size::medium && ( entry.type == "skin" ) ) {
roll /= 2;
} else if( entry.type == "offal" ) {
roll /= 5;
Expand Down Expand Up @@ -1094,7 +1096,8 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player &
// 20% of the original corpse weight is not an item, but liquid gore

if( action != DISSECT ) {
p.practice( skill_survival, std::max( 0, practice ), std::max( mt.size - MS_MEDIUM, 0 ) + 4 );
p.practice( skill_survival, std::max( 0, practice ), std::max( mt.size - creature_size::medium,
0 ) + 4 );
}
}

Expand Down Expand Up @@ -1252,8 +1255,9 @@ void activity_handlers::butcher_finish( player_activity *act, player *p )
extract_or_wreck_cbms( cbms, roll, *p );
// those lines are for XP gain with dissecting. It depends on the size of the corpse, time to dissect the corpse and the amount of bionics you would gather.
int time_to_cut = size_factor_in_time_to_cut( corpse->size );
int level_cap = std::min<int>( MAX_SKILL, ( corpse->size + ( cbms.size() * 2 + 1 ) ) );
int size_mult = corpse->size > MS_MEDIUM ? ( corpse->size * corpse->size ) : 8;
int level_cap = std::min<int>( MAX_SKILL,
( static_cast<int>( corpse->size ) + ( cbms.size() * 2 + 1 ) ) );
int size_mult = corpse->size > creature_size::medium ? ( corpse->size * corpse->size ) : 8;
int practice_amt = ( size_mult + 1 ) * ( ( time_to_cut / 150 ) + 1 ) *
( cbms.size() * cbms.size() / 2 + 1 );
p->practice( skill_firstaid, practice_amt, level_cap );
Expand Down
4 changes: 2 additions & 2 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe
// make sure nobody else is working on that corpse right now
if( i->is_corpse() && !i->has_var( "activity_var" ) ) {
const mtype corpse = *i->get_mtype();
if( corpse.size >= MS_MEDIUM ) {
if( corpse.size >= creature_size::medium ) {
big_count += 1;
} else {
small_count += 1;
Expand Down Expand Up @@ -2140,7 +2140,7 @@ static bool butcher_corpse_activity( player &p, const tripoint &src_loc,
for( auto &elem : items ) {
if( elem->is_corpse() && !elem->has_var( "activity_var" ) ) {
const mtype corpse = *elem->get_mtype();
if( corpse.size >= MS_MEDIUM && reason != do_activity_reason::NEEDS_BIG_BUTCHERING ) {
if( corpse.size >= creature_size::medium && reason != do_activity_reason::NEEDS_BIG_BUTCHERING ) {
continue;
}
elem->set_var( "activity_var", p.name );
Expand Down
4 changes: 2 additions & 2 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void show_armor_layers_ui( Character &who )
int leftListSize = 0;
int rightListSize = 0;

ui.on_redraw( [&]( const ui_adaptor & ) {
ui.on_redraw( [&]( ui_adaptor & ui ) {
draw_grid( w_sort_armor, left_w, middle_w );

werase( w_sort_cat );
Expand Down Expand Up @@ -638,7 +638,7 @@ void show_armor_layers_ui( Character &who )
}

mvwprintz( w_encumb, point_east, c_white, _( "Encumbrance and Warmth" ) );
character_display::print_encumbrance( w_encumb, who, -1,
character_display::print_encumbrance( ui, w_encumb, who, -1,
( leftListSize > 0 ) ? *access_tmp_worn( leftListIndex ) : nullptr );

// Right header
Expand Down
6 changes: 3 additions & 3 deletions src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ static void drop_or_embed_projectile( dealt_projectile_attack &attack )
!proj.has_effect( ammo_effect_TANGLE );
// Don't embed in small creatures
if( embed ) {
const m_size critter_size = mon->get_size();
const creature_size critter_size = mon->get_size();
const units::volume vol = drop_item.volume();
embed = embed && ( critter_size > MS_TINY || vol < 250_ml );
embed = embed && ( critter_size > MS_SMALL || vol < 500_ml );
embed = embed && ( critter_size > creature_size::tiny || vol < 250_ml );
embed = embed && ( critter_size > creature_size::small || vol < 500_ml );
// And if we deal enough damage
// Item volume bumps up the required damage too
embed = embed &&
Expand Down
2 changes: 1 addition & 1 deletion src/catalua_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void cata::detail::reg_enums( sol::state &lua )
reg_enum<mf_attitude>( lua );
reg_enum<m_flag>( lua );
reg_enum<monster_attitude>( lua );
reg_enum<m_size>( lua );
reg_enum<creature_size>( lua );
reg_enum<npc_attitude>( lua );
reg_enum<npc_need>( lua );
reg_enum<sfx::channel>( lua );
Expand Down
2 changes: 1 addition & 1 deletion src/catalua_bindings_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void cata::detail::reg_creature( sol::state &lua )
SET_FX_T( get_hit, float() const );

SET_FX_T( get_speed, int() const );
SET_FX_T( get_size, m_size() const );
SET_FX_T( get_size, creature_size() const );
luna::set_fx( ut, "get_hp", []( const Creature & cr,
sol::optional<const bodypart_id &> bpid ) -> int {
if( bpid.has_value() )
Expand Down
4 changes: 2 additions & 2 deletions src/catalua_luna_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum color_id : int;
enum damage_type : int;
enum game_message_type : int;
enum m_flag : int;
enum m_size : int;
enum creature_size : int;
enum mf_attitude : int;
enum monster_attitude : int;
enum npc_attitude : int;
Expand Down Expand Up @@ -164,7 +164,7 @@ LUNA_ENUM( game_message_type, "MsgType" )
LUNA_ENUM( mf_attitude, "MonsterFactionAttitude" )
LUNA_ENUM( m_flag, "MonsterFlag" )
LUNA_ENUM( monster_attitude, "MonsterAttitude" )
LUNA_ENUM( m_size, "MonsterSize" )
LUNA_ENUM( creature_size, "MonsterSize" )
LUNA_ENUM( npc_attitude, "NpcAttitude" )
LUNA_ENUM( npc_need, "NpcNeed" )
LUNA_ENUM( sfx::channel, "SfxChannel" )
Expand Down
Loading

0 comments on commit 4286fd9

Please sign in to comment.