Re: [Announce] Angband User Interface Patch
- From: Andrew Doull <andrewdoull@xxxxxxxxxxx>
- Date: Thu, 24 Nov 2005 21:18:14 +0000 (UTC)
On 2005-11-23 00:56:37, Hugo Kornelis <Angband@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, 21 Nov 2005 19:27:08 +0000 (UTC), Andrew Doull wrote:
>
> >On 2005-11-20 23:57:09, Hugo Kornelis wrote:
> >
> >> On Sat, 19 Nov 2005 11:02:36 +0000 (UTC), Andrew Doull wrote:
> >>
> >> >On 2005-11-18 23:45:53, Hugo Kornelis wrote:
> >> >
> >> (snip)
> >> >> - Added a "handle" command (aka "unified use" or "generic use").
> >> >> Type 'h' (original keyset) or Ctrl-G (both keysets) and select an
> >> >> object from your equipment, inventory, or the floor. The game will
> >> >> automatically perform the "logical" action for that kind of object.
> >> >
> >> >Can you include a change to allow users to inscribe an object with '%x' to
> >> >override the logical action with 'x' instead?
> >>
> >> Hi Andrew,
> >>
> >> Great idea! And I think that it should be possible to implement. But it
> >> will require some redesign and cleanup here and there, unless I'm
> >> prepared to use an ugly hack (which I'm not).
> >>
> >
> >This is how the Unangband implementation does it. How are you resolving the
> >default?
> >
> >I use the repeat command variables to get this for 'free' or close to it. e.g.
> >setting p_ptr->command_rep equal to 'x' in the above example...
>
> Hi Andrew,
>
> I downloaded the Unangband sources today to check how you do it and
> steal your ideas, but I couldn't find where you don this. This obviously
> means that I didn't look long enough, and in the wrong location :-)
>
> Can you give me a pointer where to look?
>
Um. I'm a little embarrassed here. I could have sworn that I did in fact code
this; however I can't for the life of me find it in either the source or CVS
either. I'm going to have to re-implement it (which shouldn't be too hard) and
will let you know when I committ the change. A couple of quick comments below:
>
> For my implementation, I considered a similar approach, but I discarded
> the idea because I thought that setting p_ptr->command to the proper
> command would result in the user being prompted to select an item to
> (read / quaff / zap / aim / whatever). As the user has already selected
> an item when issuing the handle command, I didn't want that.
>
This is the way, I in fact did it. And this is the first issue I confronted: I
then extended the repeat functionality by adding p_ptr->command_obj to allow
repeating object selection, which not only gives you the handle functionality,
but allows you to, for instance, repeatedly shoot a non-moving monster with a
single command. It got a little uglier for Unangband, because there are
commands that take two objects (such as filling an empty bottle with a potion)
but as far as I recall, this isn't the case for Angband.
> I also considered another way to get it for 'free' - pushing the default
> command on the inkey buffer. This would probably work for items in
> inventory and equipment, but floor items were a headache - the various
> options for handling floor items meant that I had to do lots of coding
> to find the proper sequence of key presses to re-select the same item.
>
> I ended up adding a parameter to various do_cmd_xxx functions. For
> instance,
> void do_cmd_eat_food()
> is now
> void do_cmd_eat_food(int h_item)
>
> If h_item is a valid item in inventory, equipment, or on the floor, the
> code to select an item is bypassed. If it's a special value (currently
> INVEN_TOTAL, which is a hack - I plan to introduce a new precompiler
> constant for the next version), the user will be prompted. Like this:
Computer science class 101 - don't overload a variable this way. Create a
separate boolean.
Of course, doing that contravenes Angband coding style...
> Finally, the resolving of the default is handled by a switch command
> with lots of cases. Fairly straightforward.
>
Yeah. I don't think there's any way of avoiding the 'big bunch of cases'; unless
you create an even less space efficient table lookup on item tval. My preference
would be to only allow items that are inscribed with %x to be selectable: this
of course, counters the whole 'universal use' command approach...
Andrew
--
Unangband L:C E+ T- R- P+ D-- G+(+) F:Sangband RL-- RLA-- W:F Q++
AI+(++) GFX++ SFX++ RN+++(+) PO++ Hp+++ Re--(+) S++ C- O* KG--
.
- Follow-Ups:
- Re: [Announce] Angband User Interface Patch
- From: Hugo Kornelis
- Re: [Announce] Angband User Interface Patch
- References:
- [Announce] Angband User Interface Patch
- From: Hugo Kornelis
- Re: [Announce] Angband User Interface Patch
- From: Andrew Doull
- Re: [Announce] Angband User Interface Patch
- From: Hugo Kornelis
- Re: [Announce] Angband User Interface Patch
- From: Andrew Doull
- Re: [Announce] Angband User Interface Patch
- From: Hugo Kornelis
- [Announce] Angband User Interface Patch
- Prev by Date: Re: There the loot is!
- Next by Date: Re: There the loot is!
- Previous by thread: Re: [Announce] Angband User Interface Patch
- Next by thread: Re: [Announce] Angband User Interface Patch
- Index(es):
Relevant Pages
|