itemInfoPanel for gold

Discuss coding questions, pull requests, and implementation details.
User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

itemInfoPanel for gold

Post by pango »

I tried to implement something that was suggested a long time ago, and that I think makes sense: allow to check how much gold you have without going thru the classic trick of attempting to drop gold then retract.
I just update the itemInfoPanel when the mouse is over the GOLD button.

https://github.com/Interkarma/daggerfal ... nel-update

Almost works, except gold stacks have 0 value for some reason, reason being that their parent.value is also 0.
I'm not sure how and where to fix that without side-effects, any idea?
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: itemInfoPanel for gold

Post by Hazelnut »

I think a better approach may be to create a new method to update the info panel with the gold amount without requiring an item to be created and passed. Construct the message tokens and display gold and the value of letters of credit as separate lines. Then just hook up to the mouse enter.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: itemInfoPanel for gold

Post by pango »

The nice thing about creating an item is that the weight was automatically computed too mmmh
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

jimfcarroll
Posts: 102
Joined: Tue Feb 12, 2019 12:55 am

Re: itemInfoPanel for gold

Post by jimfcarroll »

This looks fixable by adding a case statement to ItemHelper.GetItemInfo for ItemGroup.Currency.

[EDIT] Alternatively you could have the ItemBuilder.CreateGoldPieces correctly set the value as well as the stackCount. I'm not sure if this would have other side effects.

[EDIT2] If you set the stackCount to the number of gold pieces you need to set the value to 1 since value is per-item. This works for me.

jimfcarroll
Posts: 102
Joined: Tue Feb 12, 2019 12:55 am

Re: itemInfoPanel for gold

Post by jimfcarroll »

@pango, I submitted a PR against your branch. If you take it it will fix the display issue. I don't know the entire codebase well enough to say whether or not it will have other side effects but it actually seems more correct than it was before.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: itemInfoPanel for gold

Post by pango »

Thanks for the help jimfcarroll!

I made a mess on GitHub though :(
It was displaying me a lot more stuff in your PR than the patch itself; It was probably just a re-merge of master (my branch was late by 3 commits vs master), but I panicked.
Long story short I had to recreate the useful commit. Hopefully I'll do better the next time :oops:
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: itemInfoPanel for gold

Post by Nystul »

pango wrote: Sun Sep 15, 2019 4:41 pm I made a mess on GitHub though :(
It was displaying me a lot more stuff in your PR than the patch itself; It was probably just a re-merge of master (my branch was late by 3 commits vs master), but I panicked.
this happened to me as well several times ;)

jimfcarroll
Posts: 102
Joined: Tue Feb 12, 2019 12:55 am

Re: itemInfoPanel for gold

Post by jimfcarroll »

No big deal. It was a 1 liner. Glad it helped.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: itemInfoPanel for gold

Post by Hazelnut »

pango wrote: Sun Sep 15, 2019 1:43 pm The nice thing about creating an item is that the weight was automatically computed too mmmh
That's pretty easy to do though, and a custom method would allow carried gold, wagon gold and LoC amount all to be displayed. No idea if that will look good, just wanted to suggest it to you as an option. Will leave to your judgement, I'm sure you'll submit a thorough job whichever way you go.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: itemInfoPanel for gold

Post by pango »

Hazelnut wrote: Sun Sep 15, 2019 6:12 pm Will leave to your judgement, I'm sure you'll submit a thorough job whichever way you go.
You're too kind with me :)
They're many subsystem that I barely understand, and I don't have a working debugger so I don't get to see dynamic behaviors, I'm only using source code to understand what's going on.
It could very well be that a solution based on your idea is not that complex to implement, and does not resort to too much code duplication... But macros are still beyond my reach
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Post Reply