Page 1 of 3

itemInfoPanel for gold

Posted: Sun Sep 15, 2019 9:58 am
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?

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 10:17 am
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.

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 1:43 pm
by pango
The nice thing about creating an item is that the weight was automatically computed too mmmh

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 2:21 pm
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.

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 2:46 pm
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.

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 4:41 pm
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:

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 5:13 pm
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 ;)

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 5:48 pm
by jimfcarroll
No big deal. It was a 1 liner. Glad it helped.

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 6:12 pm
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.

Re: itemInfoPanel for gold

Posted: Sun Sep 15, 2019 6:32 pm
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