Loading any tileset file in Windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blue Baron
    Adept
    • Apr 2011
    • 103

    Loading any tileset file in Windows

    Here is a main-win.c - angband.rc pair that does three things.
    1. It removes the bigtile,double tile, and tripple tile options and replaces them with specific tile multipliers.
    2. It uses a graphics_modes array like in the OSX port. However, it is not quite as easy to use as the OSX port because the menu option for the graphics mode has to be added to three places, the array on line 227, a case statement around line 3609, and in the angband.rc file.
    3. Adds the tileset filename and "graf" name to the ini file and adds two static global variables to hold them. This allows an arbitrary tileset file to be used on startup, without having to recompile the program. Changing the graphics mode overwrites this though.

    For 2 and 3, the element size is taken from the filename. The filename needs to start with XxY, for instance 8x16.png or 64x64test.png works.

    Diff patches are included in the zip file, but since I collapsed and reordered the case statements for the graphics modes, I think the diff patch does not reflect that section of the code well.
    Attached Files
  • takkaria
    Veteran
    • Apr 2007
    • 1951

    #2
    Hey, this looks great and is one step towards the goal of not having main-* files hardcode graphics info.

    Do you know if there's any way to add menu items dynamically so that the .rc file doesn't contain the details of any graphics modes (they just get added from the graphics_modes array)?

    Also, in future could you use diff -u instead of just diff? The resulting files are a lot easier to read. Thanks!
    takkaria whispers something about options. -more-

    Comment

    • Blue Baron
      Adept
      • Apr 2011
      • 103

      #3
      Originally posted by takkaria
      Do you know if there's any way to add menu items dynamically so that the .rc file doesn't contain the details of any graphics modes (they just get added from the graphics_modes array)?
      Actually there seems to be a way. setup_menus() already gets a handle to the menu using GetMenu(). The same can happen in init_stuff(), and use some combination of GetSubMenu() and InsertMenuItem() to populate the list. Probably still want to hard code the option for no graphics to anchor the list though.

      Originally posted by takkaria
      Also, in future could you use diff -u instead of just diff? The resulting files are a lot easier to read. Thanks!
      Ok. You're welcome.

      Comment

      • Blue Baron
        Adept
        • Apr 2011
        • 103

        #4
        Originally posted by takkaria
        Do you know if there's any way to add menu items dynamically so that the .rc file doesn't contain the details of any graphics modes (they just get added from the graphics_modes array)?
        Here is a main-win.c that does that and an angband.rc with the graphics modes commented out. However, there still needs a case statement per graohics mode around line 3839. If you know how many graphics modes there are I guess you could add a default area for the switch and test if ((wCmd > IDM_GRAPHICS_OPTION_NONE && ( wCmd < IDM_GRAPHICS_OPTION_NONE+max)), then the area in the case block of line 3840.

        Diff patches are included in the zip file. The diff patches were made with diff -u.

        This main-win.c does a couple other things as well. In the grahpics mode array, you can set a column index, so that when tiles to the right of that index are drawn, it draws the tile above it in the space above it. However, this is a naive approach and I do not think it is appropriate for angband. (it does not clear the top tile, so many manual redraws are necessary.) I left it in because I use the overdraw variable as a flag to decide if to use alpha blending when the tileset is loaded. The AlphaBlend function is supposed to be slow, so I used separate functions to load and use tilesets that need it. (readpng.c in included in the zip.) if the overdraw variable is not set, it will use the normal tile masking.
        Attached Files

        Comment

        • Blue Baron
          Adept
          • Apr 2011
          • 103

          #5
          here is another set of patches. In this set tilesets only have to be added to the graphics_modes array. I removed two of the three functions I added for alpha blending and simplified that code. I also added some hard-coded base tile sizes.

          The main-win.c patch is against the one in my previous post. The angband.rc and readpng.c patches are against the original June 10th nightly files.

          Edit: The AlphaBlend function needs msimg32.lib.
          Attached Files
          Last edited by Blue Baron; June 16, 2011, 18:46.

          Comment

          • Blue Baron
            Adept
            • Apr 2011
            • 103

            #6
            Here is another set of patches and a few additional files. This set does the same thing as the above, except the graphics modes are loaded from a file and the diff patches are against files in the July 3rd nightly.
            Attached Files
            Last edited by Blue Baron; July 7, 2011, 08:46. Reason: Forgot to add the attachment.

            Comment

            • d_m
              Angband Devteam member
              • Aug 2008
              • 1517

              #7
              Originally posted by Blue Baron
              Here is another set of patches and a few additional files. This set does the same thing as the above, except the graphics modes are loaded from a file and the diff patches are against files in the July 3rd nightly.
              Awesome!

              When I get home later tonight I will apply the patches and try it out. I'm definitely excited
              linux->xterm->screen->pmacs

              Comment

              • Pete Mack
                Prophet
                • Apr 2007
                • 6883

                #8
                Originally posted by Blue Baron
                Here is another set of patches and a few additional files. This set does the same thing as the above, except the graphics modes are loaded from a file and the diff patches are against files in the July 3rd nightly.
                Good work! I know how much of a pain this must have been!

                Comment

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