Code snippet to use character class as default filename when saving macros/keymaps

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Max Stats
    Swordsman
    • Jun 2010
    • 324

    Code snippet to use character class as default filename when saving macros/keymaps

    When saving macros and keymaps, I find that it is much more useful to save them to a class pref file instead of one named for my character. This is because macros and keymaps tend to have references to spells, like 'maa' or 'm1a' to cast Magic Missile for mages. I decided to change the default filename when saving macros or keymaps to use the character class.

    Here is the change I made. I edited function dump_pref_file in ui-options.c and changed the line:
    Code:
           strnfmt(ftmp, sizeof ftmp, "%s.prf", op_ptr->base_name);
    to this:
    Code:
            if (strcmp(title,"Dump macros")==0 || strcmp(title,"Dump keymaps")==0)
                    strnfmt(ftmp, sizeof ftmp, "%s.prf", cp_ptr->name);
            else
                    strnfmt(ftmp, sizeof ftmp, "%s.prf", op_ptr->base_name);
    This is kind of quick-and-dirty. There might be a more elegant way to test for dumping macros or keymaps, but I didn't want to change more than necessary. Would this be a useful change to make? Do most experienced users do like I do and save macros/keymaps to class-specific pref files?
    If beauty is in the eye of the beholder, then why are beholders so freaking ugly?
  • d_m
    Angband Devteam member
    • Aug 2008
    • 1517

    #2
    Originally posted by Max Stats
    When saving macros and keymaps, I find that it is much more useful to save them to a class pref file instead of one named for my character. This is because macros and keymaps tend to have references to spells, like 'maa' or 'm1a' to cast Magic Missile for mages.
    I have a (possibly wrong) idea that there was consensus on this point awhile ago and that Magnate was working on it. I just asked him and Takkaria what they think. It seems like a good idea to me.

    If anyone thinks this is a bad idea please speak up.
    linux->xterm->screen->pmacs

    Comment

    • takkaria
      Veteran
      • Apr 2007
      • 1951

      #3
      Originally posted by d_m
      I have a (possibly wrong) idea that there was consensus on this point awhile ago and that Magnate was working on it. I just asked him and Takkaria what they think. It seems like a good idea to me.

      If anyone thinks this is a bad idea please speak up.
      Seems like a pretty sensible change. Another useful change to make this more future-proof would be to add some kind of marker to the individual keymaps on whether they came from a game pref file or from the user, and then only dump user keymaps to file... kind of independent of the class change, but it would make the pref files a lot cleaner.
      takkaria whispers something about options. -more-

      Comment

      • Magnate
        Angband Devteam member
        • May 2007
        • 5110

        #4
        Originally posted by d_m
        I have a (possibly wrong) idea that there was consensus on this point awhile ago and that Magnate was working on it. I just asked him and Takkaria what they think. It seems like a good idea to me.

        If anyone thinks this is a bad idea please speak up.
        It seems like an excellent idea in the meantime. I have collected a bunch of tickets about pref files and deem them connected with the whole savefile/knowledge file issue, which is my 2nd highest priority for my dev time - a piece of work which cleans up and organises what gets saved where and when. Unfortunately my highest priority is getting to the rewrite of obj-power.c and that seems to be more important at the moment - though I am willing to reconsider that view.
        "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎