1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[SDK MODCOMP] Binary Yield Display (31 max yield displayed)

Discussion in 'Civ4 - Mod Components' started by Quornix, Feb 18, 2007.

  1. Quornix

    Quornix Warlord

    Joined:
    Dec 27, 2006
    Messages:
    134
    [EDIT] I decided to link to this in my signature, and figured I'd mention that there's a version that looks mostly normal in post #25, uses the "big" image every five, and handles up to 19 points per yield. Hopefully this workaround won't be needed in BTS.[/EDIT]


    Heh. My first modcomp. Originally, I wasn't even going to post this, because it's harder to see what the yield is at a glance. But since it works, and I haven't seen any solution to the display limit of 9 of a yield, I figured I might as well. A picture is worth a thousand words, so:


    Each small slice/hammer/coin represents 1 yield, each large slice/hammer/coin represents 4 yield, and each loaf/anvil/bag represents 16 yield. So the pastured sheep is 16/4/4, while the windmill on the tundra hill is 6/6/10.

    This actually works quite nicely if you set the food consumption to 4, as that means that every large slice feeds 1 person. It brings back a bit of the intuitiveness that gets lost when you leave base5 for base4.

    Not sure what else to put here, except the files. I'll post the code changes if requested, but it's pretty simple, so I haven't included them. Actually, they're in this post.

    And Binary_Yields_for_2.08.zip is now available. It includes the CivGameCoreDLL.dll and the VerticalSymbols.dds files, in their appropriate folders.

    Let me know what you guys think!
     
  2. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    I think it would be even better with numbers for 4, 8 and 16. A nice addition would be a third artstyle for each yield representing 16 : a chcken leg for food, a safe for commerce, ....
     
  3. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    This is great, why 4 and not 5 though? 5 seems a little more evenly spread? Can it be changed to 5? Either way, great job, I have been looking for something exactly like this.
     
  4. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    it's said in title : binary yield display
     
  5. Quornix

    Quornix Warlord

    Joined:
    Dec 27, 2006
    Messages:
    134
    Yeah. Unfortunately, I wasn't able to get an expanded image selection, so I had to work with the five images for each yield (1,2,3,4,5) plus the generic zero. I made them 1,2,4,8,16, set them to overlap nicely, and changed the logic behind which image was displayed -- which is possible in the SDK. I could have done 5, but then I'd have had to do 1,2,4,5,10 for a max of 19. Hardly the end of the world, but this is at least vaguely more elegant -- although they way I wound up writing the code means that the code wouldn't have been any sloppier.

    As for different graphics, well... I really suck at drawing. I'll see what I can do.
     
  6. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Sorry, I understand. This is still pretty great. I will work on some graphics for this...thank you for this.
     
  7. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Hey what files were the code changes made too?
     
  8. Quornix

    Quornix Warlord

    Joined:
    Dec 27, 2006
    Messages:
    134
    CvPlot.cpp

    Search for MAX_YIELD_STACK to find the proper location for the changes.
     
  9. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    Would you mind to do the aternative 1, 2, 4, 5, 10 version because I think to have choice is always better. Don't worry for graphics, you just have to ask in the graphic request thread and someone could do it for you !
     
  10. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Okay great thanks, I'll probably write instructions and then post them here, I'll probably, also do the 1, 2, 4, 5, 10 for you and post that with the instructions.
     
  11. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    I was thinking of something like these to represent the others. My only issue with this system is that it is hard to read some of the bigger numbers. Could do two fours for an 8 or even just another 8.

    Bare with me as I am at work and only had paint brush to work with.

    EDIT: Forgot to crop them.
     

    Attached Files:

    • 4.PNG
      4.PNG
      File size:
      2.9 KB
      Views:
      839
    • 16.PNG
      16.PNG
      File size:
      2.8 KB
      Views:
      834
  12. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    Try to work with PaintDotNet or The Gimp and play with layers and transparency.
     
  13. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Oh don't worry, I'll do that at home, just wanted to know what peoples thoughts are on this type of a format.
     
  14. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Hmm, not sure what I am doing wrong, but it doesn't compile, gives a bunch of illegal local definitions or something like that.
     
  15. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Well I messed with it until I got it to compile, but it shows everything as max..., what exactly am I supposed ot replace with your code, I thought it was obvious, but apparently I was mistaken. :)
     
  16. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Nevermind, I started over this morning and now everythign works, must have dorked something up.

    Thanks.
     
  17. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    OKay now I feel stupid. I altered the graphics...still generic and made everythign slightly larger. But when I convert it to DDS and try it in game everything has a black background. I am sure I am forgetting something as I have alter the graphics before, it just has been a long time.
    Spoiler :



    I made them larger because I am using the 3 city tile mod also and that makes everything slightly smaller.
     
  18. snipperrabbit!!

    snipperrabbit!! Deity

    Joined:
    Nov 23, 2006
    Messages:
    3,396
    I think it is related to the alpha mask :

    - you forgot to import your alpha mask

    or

    - you save it to dds dxt1 (no alpha )
     
  19. Elucidus

    Elucidus King

    Joined:
    Mar 3, 2002
    Messages:
    983
    Location:
    USA
    Great thanks. BTW, you aren't gonna believe this. I FOUND IT!

    To change the way civ reads the graphics for the yields goto globaldefines.xml

    <Define>
    <DefineName>MAX_YIELD_STACK</DefineName>
    <iDefineIntVal>5</iDefineIntVal>
    </Define>

    THis controls how far down the file civ will go before it starts stacking.

    I changed it to 10 and did a test run, a farm that gave me 9 food showed 4 hammers for food.

    SO we can make it anythign we want. Now, how do I import the alpha mask again...
     
  20. Quornix

    Quornix Warlord

    Joined:
    Dec 27, 2006
    Messages:
    134
    Yes, you can tell it go to MAX_YIELD_STACK + 1 for the second yield type, and 2 * MAX_YIELD_STACK + 1 for the third type. Unfortunately, there are some rules to the drawing of the images that, so far as I can tell, you just can't get around.

    0) The 16th pulled image is always used for 0, regardless of the size of the file.
    1) The drawn picture will always be square.
    2) The distance it skips down to get the next image is equal to the width of the Vertical_Symbols.dds file.
    3) The image it pulls from Vertical_Symbols.dds is always one 16th the height of the total file.

    Composite rule from the first three rules:
    4) (1 + 3) If the image pulled from VerticalSymbols.dds is rectangular, it will shrink the image in one dimension until it is square, then display the square picture.

    So, in order to increase MAX_YIELD_STACK to, say, 10 (which I wanted to do on my first attempt), you would have to double the height of VerticalImages.dds, making it 64x2048 pixels. From rule 2, you can pull 32 different images, as it skips down 64 pixels for each successive image. Unfortunately, each of those images would be 128 pixels tall (1/16th of 2048). These will then be squished into 64x64 pixel pictures to be displayed.

    I did try to do another workaround, which should be possible. Basically, I quadrupled the height of the Vertical_Symbols.dds file, then (I'll display this horizontally, and only for food) drew the following images:

    00011110005555000

    So, since it will pull four of those images for each picture (by rule 3), and step down by one image (by rule 2), the "one food" picture is 0001, the "two food" picture is 0011, 3F = 0111, 4F = 1111, then the logic of the draw calls can jump the 5F picture to 0005.

    However, I never got the logic to work fully, and the output was quite ugly. I had to stretch the initial images 4x vertically, which meant that I had to keep each one quite narrow to fit them into their 64x64 "box". And it would display 14 food as:

    1F
    1F
    1F 5FOOD
    1F 5FOOD

    with no overlap. It just wasn't that nice. Actually, my failure to do that workaround well is the reason I posted this when I did. I thought I might have had a better solution, but it just wasn't that hot.

    I haven't worked on modding much of anything since my initial post, so I'm going to get around to some of the requests this weekend. Thanks for all the feedback. I'd expected this to sink like a stone (as much as anything does in this forum with some January posts still being on the first page).
     

Share This Page