itemInfoPanel for gold

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

itemInfoPanel for gold

Post by pango » Sun Sep 15, 2019 9:58 am

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?
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: itemInfoPanel for gold

Post by Hazelnut » Sun Sep 15, 2019 10:17 am

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.

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

Re: itemInfoPanel for gold

Post by pango » Sun Sep 15, 2019 1:43 pm

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

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

Re: itemInfoPanel for gold

Post by jimfcarroll » Sun Sep 15, 2019 2:21 pm

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: 69
Joined: Tue Feb 12, 2019 12:55 am

Re: itemInfoPanel for gold

Post by jimfcarroll » Sun Sep 15, 2019 2:46 pm

@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: 1614
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: itemInfoPanel for gold

Post by pango » Sun Sep 15, 2019 4:41 pm

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:
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: itemInfoPanel for gold

Post by Nystul » Sun Sep 15, 2019 5:13 pm

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: 69
Joined: Tue Feb 12, 2019 12:55 am

Re: itemInfoPanel for gold

Post by jimfcarroll » Sun Sep 15, 2019 5:48 pm

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

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

Re: itemInfoPanel for gold

Post by Hazelnut » Sun Sep 15, 2019 6:12 pm

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.

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

Re: itemInfoPanel for gold

Post by pango » Sun Sep 15, 2019 6:32 pm

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
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Post Reply