Skip to main content

flatland_client_ui/
keybindings.rs

1//! Play-client keybindings — shared by in-game help overlay and `flatland3 keys`.
2
3use crate::map_presentation::format_map_legend_plain;
4
5pub struct KeyBinding {
6    pub keys: &'static str,
7    pub description: &'static str,
8}
9
10pub struct KeyBindingCategory {
11    pub name: &'static str,
12    pub bindings: &'static [KeyBinding],
13}
14
15pub const CATEGORIES: &[KeyBindingCategory] = &[
16    KeyBindingCategory {
17        name: "Movement",
18        bindings: &[
19            KeyBinding {
20                keys: "WASD / arrows",
21                description: "Move (cardinals; hold two for diagonal)",
22            },
23            KeyBinding {
24                keys: "Click map",
25                description: "Auto-walk to clicked cell (A* path); right-click cancels",
26            },
27            KeyBinding {
28                keys: "Shift (hold)",
29                description: "Sprint while moving",
30            },
31            KeyBinding {
32                keys: "x",
33                description: "Toggle sprint mode (faster move, stamina drain)",
34            },
35            KeyBinding {
36                keys: "Shift+Space",
37                description: "Lunge forward (~8.5 m, high stamina)",
38            },
39            KeyBinding {
40                keys: "m",
41                description: "Map target mode — mouse/WASD place X, Enter to auto-walk",
42            },
43            KeyBinding {
44                keys: "u / j",
45                description: "Climb / descend",
46            },
47            KeyBinding {
48                keys: "Alt + WASD / arrows",
49                description: "Directional jump — leap one cell over a medium cliff (~2 m rise)",
50            },
51            KeyBinding {
52                keys: "Space",
53                description: "Stop movement / cancel auto-walk",
54            },
55        ],
56    },
57    KeyBindingCategory {
58        name: "Combat",
59        bindings: &[
60            KeyBinding {
61                keys: "Tab",
62                description: "Cycle T1 target (hostile)",
63            },
64            KeyBinding {
65                keys: "Shift+Tab",
66                description: "Cycle T2 target (allies, then monsters)",
67            },
68            KeyBinding {
69                keys: "0 / Shift+0",
70                description: "Clear T1 / T2 target",
71            },
72            KeyBinding {
73                keys: "1–9",
74                description: "Hotbar — cast bound ability or use bound consumable",
75            },
76            KeyBinding {
77                keys: "r / Shift+r",
78                description: "Toggle auto rotation for T1 / T2",
79            },
80            KeyBinding {
81                keys: "c",
82                description: "Dodge (i-frames, stamina)",
83            },
84            KeyBinding {
85                keys: "q",
86                description: "Toggle block (melee damage reduction)",
87            },
88            KeyBinding {
89                keys: "l",
90                description: "Loadout — assign rotation preset to T1/T2",
91            },
92            KeyBinding {
93                keys: "o",
94                description: "Rotation editor — create/edit/delete presets",
95            },
96            KeyBinding {
97                keys: "(auto)",
98                description: "T1 auto pursues into weapon range when idle",
99            },
100        ],
101    },
102    KeyBindingCategory {
103        name: "World",
104        bindings: &[
105            KeyBinding {
106                keys: "f",
107                description: "Use nearest — interact, then pickup loot/chest, then harvest/butcher",
108            },
109            KeyBinding {
110                keys: "v",
111                description: "Quest log / withdraw menu",
112            },
113            KeyBinding {
114                keys: "h",
115                description: "Hired workers — hire, dismiss, give items (g), teach recipes (t), toggle companion/job loop",
116            },
117        ],
118    },
119    KeyBindingCategory {
120        name: "Inventory & crafting",
121        bindings: &[
122            KeyBinding {
123                keys: "b",
124                description: "Inventory (worn items by body slot, on-you items, nearby open chests)",
125            },
126            KeyBinding {
127                keys: "p",
128                description: "Equip paperdoll — body slots, hands, mitigation / resists",
129            },
130            KeyBinding {
131                keys: "n",
132                description: "Craft menu (Enter to craft, Esc to close)",
133            },
134            KeyBinding {
135                keys: ",",
136                description: "Keychain — stow/retrieve chest keys (zero carry mass when stowed)",
137            },
138            KeyBinding {
139                keys: "i",
140                description: "Character stats overlay",
141            },
142            KeyBinding {
143                keys: "↑↓ / jk",
144                description: "Move selection in craft or inventory menus",
145            },
146            KeyBinding {
147                keys: "Enter",
148                description: "Inventory: equip/wear/use selected item, or move it",
149            },
150            KeyBinding {
151                keys: "m / d / x / l",
152                description: "Inventory: move to… picker / drop on ground / destroy permanently / lock nearby chest",
153            },
154        ],
155    },
156    KeyBindingCategory {
157        name: "Chat",
158        bindings: &[
159            KeyBinding {
160                keys: "t",
161                description: "Nearby chat — focus CHAT column input",
162            },
163            KeyBinding {
164                keys: "g",
165                description: "Whisper-stone contacts in CHAT",
166            },
167            KeyBinding {
168                keys: "f (on player)",
169                description: "Whisper or Trade with nearest player",
170            },
171            KeyBinding {
172                keys: "Y / N",
173                description: "Accept / decline inbound trade request",
174            },
175            KeyBinding {
176                keys: "Enter",
177                description: "Send chat line",
178            },
179            KeyBinding {
180                keys: "Tab",
181                description: "While whispering: return to Nearby speech",
182            },
183            KeyBinding {
184                keys: "Esc",
185                description: "Unfocus chat / cancel trade / close overlay",
186            },
187        ],
188    },
189    KeyBindingCategory {
190        name: "Session & HUD",
191        bindings: &[
192            KeyBinding {
193                keys: "? or /",
194                description: "Help & keybindings",
195            },
196            KeyBinding {
197                keys: ".",
198                description: "Cycle HUD — normal → compact (keeps CHAT) → map",
199            },
200            KeyBinding {
201                keys: "'",
202                description: "Hide / show the bottom LOG panel",
203            },
204            KeyBinding {
205                keys: "F2",
206                description: "Connection settings (server host / ports)",
207            },
208            KeyBinding {
209                keys: "Ctrl+Q",
210                description: "Quit client",
211            },
212            KeyBinding {
213                keys: "Ctrl+C",
214                description: "Interrupt / force quit",
215            },
216        ],
217    },
218    KeyBindingCategory {
219        name: "Dev / debug",
220        bindings: &[
221            KeyBinding {
222                keys: "-",
223                description: "Test damage (25 HP) — dev only",
224            },
225            KeyBinding {
226                keys: ";",
227                description: "Toggle harvest / use radius overlay",
228            },
229        ],
230    },
231];
232
233/// Plain-text reference for `flatland3 keys` and similar CLIs.
234pub fn format_keybindings_plain() -> String {
235    let mut out = String::from("Flatland3 play — keybindings\n\n");
236    for cat in CATEGORIES {
237        out.push_str(cat.name);
238        out.push_str("\n");
239        for b in cat.bindings {
240            out.push_str(&format!("  {:<16} {}\n", b.keys, b.description));
241        }
242        out.push('\n');
243    }
244    out.push_str(&format_map_legend_plain());
245    out.push_str("Wildlife: rabbits north meadow (~95,195); wolves bog (~118,122).\n");
246    out
247}