Re: [Announce] Angband User Interface Patch



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--
.



Relevant Pages

  • Re: Error when rebuild table index
    ... Since my SQL Server is ... The job command is as follows. ... "Andrew J. Kelly" wrote: ... >> Rebuilding indexes for table 'cliStores' ...
    (microsoft.public.sqlserver.tools)
  • Re: different environment fails to fill a dataset
    ... successfully ran the select command with no problems. ... Andrew J. Kelly SQL MVP ... Is there anything in the environment or SQL Server that could be ...
    (microsoft.public.sqlserver.clients)
  • Re: Are RANGE locks indicative of Serializable isolation level?
    ... Make sure you have (among the normal events) the Existing connections, ... SQL:Stmt Starting events and Login. ... show a command of SET ISOLATION_LEVEL xxxx. ... > Thanks for the response Andrew. ...
    (microsoft.public.sqlserver.server)
  • Re: DBCC DBREINDEX
    ... > Andrew Excellent that is what I wanted to know. ... >> command can be executed the one before it must finish completely. ... >> before the previous DBCC command is completed. ... Or will it loop once issue the dbcc dbreindex ...
    (microsoft.public.sqlserver.dts)
  • Re: [Announce] Angband User Interface Patch
    ... >I use the repeat command variables to get this for 'free' or close to it. ... but floor items were a headache - the various ... If h_item is a valid item in inventory, equipment, or on the floor, the ...
    (rec.games.roguelike.angband)