Changes between Initial Version and Version 1 of InputRework


Ignore:
Timestamp:
11/17/10 12:09:28 (9 years ago)
Author:
takkaria
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InputRework

    v1 v1  
     1One day, takkaria got bored of Angband's hacky input layer and started thinking about something better.  A few years later... 
     2 
     3== Current situation == 
     4 
     5There are keymaps and macros. 
     6* Macros are mostly used by the game to port platform-specific keycodes to keycodes the game can understand.  They are always active. 
     7* Keymaps are used to map keys to other key sequences, and are active only when the game expects a command. 
     8 
     9So, generally, input goes something like this: keycode (-> macro)? (-> keymap)? -> string of characters -> C command. 
     10 
     11Macros end up looking like: 
     12{{{ 
     13'2' => { ";2" } 
     14'^E' => { "\e\e\er1q4" } 
     15}}} 
     16 
     17This is a bit horrible. 
     18 
     19== Proposed situation == 
     20 
     21Keys are mapped (in pref files) to a set of function calls, such as: 
     22 
     23{{{ 
     24(simple) 
     25'z' => { zap() } 
     26'm' => { cast() } 
     27';' => { walk() } 
     28 
     29(more macro-like) 
     30'2' => { walk(DOWN) } 
     31'M' => { cast("Magic Missile") } 
     32 
     33(chained commands) 
     34'^E' => { read("Phase Door"), quaff("Healing") } 
     35}}} 
     36 
     37The functions thus called then check what paramaters they have: 
     38* pointer to an object_type: (internal use) just use that object 
     39* strings: search to find the relevant item, in inventory or on floor 
     40* nothing: prompt for the right item 
     41 
     42To map some across, we might need macros like NEAREST_MONSTER or DEFAULT_AMMO, e.g. 
     43 
     44{{ 
     45'f' => { fire() } 
     46'\'' => { fire(DEFAULT_AMMO, NEAREST_MONSTER) } 
     47}} 
     48 
     49The relevant frontend UI code should be dealing with the platform keycode -> angband keycode mapping, so the game will just get a key, find the relevant command chain, and run it. 
     50 
     51= Other uses = 
     52 
     53Apart from being a lot nicer conceptually, it would make writing testing scripts pretty easy. 
     54 
     55There could be a macro wizard which records the actions you take and then sets them to happen on a given keypress.  (The game would record quaff("Cure Light Wounds") rather than 'q0').  That would be a lot nicer.  (We'd need to keep a distinction between user-defined key mappings and game-defined ones, though.)