PDA

View Full Version : Redrawing pointers on an imagecontrol



phantomwhale
April 13th, 2013, 13:46
Is there a way to programatically get pointers to redraw on an imagecontrol ?

The use I have for this is the new version of SavageWorlds will offer map scaling (e.g. set the scale of a grid square to be greater than 1").
So as the scale rises, it would be good to reduce the size of the various custom burst templates.

Currently they will not resize until I move one of them, at which point onBuildCustomPointer() is called, which is where the sizing / scaling code gets called.

Oddly enough, changing the value of this numberfield (which is part of the same window as the imagecontrol) does seem to be triggering onMeasureVector(), which means pointers ARE getting correctly resized immediately when the scaling number is changed; this might be something we've done, but I can't see that right now.

Moon Wizard
April 20th, 2013, 00:28
The onMeasureVector call just determines the number to show next to the pointer for "length" or "radius" of the pointer.

Looking at the code, it looks like the onBuildCustomPointer handler is only called when the pointer is "dirty" in order to prevent constant calls on every redraw. The pointer is marked dirty at creation, and when the ends are adjusted.

Can you give me a before and after image? I think I need to see it to fully understand the issue, then I can think how to address.

Regards,
JPG

phantomwhale
April 20th, 2013, 01:55
Ok, here it is with images (using the latest build of the SavageWorlds ruleset - not released yet, but you should be able to do the same with SavageWorlds v3.3 and Ikeal's Savage Worlds Feature Improvements extension, I suspect)

(1) Belinda Warmheart has walked into a room and see's two Orcs ! She opts to throw a flask of greek fire (range 3/6/12, Medium Burst Template). The player draws the pointer, showing the range is 4", and draws a Medium Burst Template (2" radius circle) pointer at the location the Greek Fire will hopefully land

https://i.imgur.com/kju5Xlu.jpg (https://imgur.com/kju5Xlu)

(2) "Wait" cries the GM - the range on this map is 2" per square ! Those orcs are actually a bit further away (and very large... but let's gloss over that). He moves his cursor up to the new measurement scale tool, clicks into the numberfield and edits the number from 1 to 2.

https://i.imgur.com/lLFvBml.jpg (https://imgur.com/lLFvBml)

Note that this has automatically updated the pointer measurement (not sure how currently - could it be triggered by the numberfield's databaseNode update ? Can't find any code to explain it yet)

"So it's a range 8 shot now..." grumbles the player, "Fine, I'll go for it"...

(3) "Wait" cries the GM again, "That burst template is now too big - it should be half the size. So he moves the cursor up to either the middle or "end point" of the pointer (note that adjusting the end point of any burst template cursor doesn't do anything - it remains a fixed circle around the pointer's starting point)

https://i.imgur.com/gNmZAK0.jpg (https://imgur.com/gNmZAK0)

(4) Then, moving the pointer end (or start) point forces a pointer redraw, casuing the burst template to correctly resize

https://i.imgur.com/gHlrvdF.jpg (https://imgur.com/gHlrvdF)

"Looks like they are too far apart for a single Greek Fire flask" the GM says to a now very grumpy player...

So in conclusion, I'm not sure what is triggering the pointer to update it's measured length automatically, and I wish that it was able to also effect the custom pointers being redrawn too !

Moon Wizard
April 21st, 2013, 02:40
OK, that helps. I see what you mean about the pointers being dependent on scaling factor. Just for completeness, are you calling the setTokenScale function when your numbercontrol is changed?

I'm trying to decide if it makes sense to just invalidate all custom pointers on a scale change, or make a specific invalidation function.

Thanks,
JPG

phantomwhale
April 21st, 2013, 12:18
There are no calls to setTokenScale in the Savage Worlds codebase, so I'm pretty sure that's not called !

Moon Wizard
April 22nd, 2013, 06:34
Given that, I'm assuming that the number is used for the custom pointer radius build and all measurement calculations. Since the value changing does not trigger any function calls, I'm assuming it's only used reactively. I believe the measurements are done on every draw of the image control, which is why they are correct.

So, one solution is to provide a function call to force pointers to redraw, which is what you were asking for originally. :)

One other option I just thought of is to allow the grid distance to be defined on a per image basis, and to be able to query the image grid distance. (Default to ruleset distance setting or 1 if not set.). This is the value used for te grid distance calculations that are built-in v2.9.x.

I think the second option would be better long term, and could automatically mark custom pointers dirty to force a redraw. Plus you could use the built-in measurement code then.

Thoughts?

JPG

phantomwhale
April 25th, 2013, 14:23
Well - either works for me - the former seems easier (and is only required for this edge case of custom pointers) - but I must admit the "set scale" option on the map looks very useful and I wonder if other rulesets would enjoy having access to it.

In any case, it's not going to be a show stopper for v3.4 of SW - people shouldn't be changing the map scale THAT often !

S Ferguson
May 13th, 2013, 17:29
I'm still having trouble glossing over the fact that those Orcs were a little large for my liking....

phantomwhale
May 14th, 2013, 01:07
Well yes - the token scaling is handled different to the grid scaling !

Once you are outside a 1 square = 1" scale map, correctly sized tokens get a little tiny...

... and besides these were Dire Orcs. Obviously.

S Ferguson
May 14th, 2013, 01:18
Well yes - the token scaling is handled different to the grid scaling !

Once you are outside a 1 square = 1" scale map, correctly sized tokens get a little tiny...

... and besides these were Dire Orcs. Obviously.

Ooooh, Dire Orcs. Never encountered them. I'd assumed they'd died out with most of the Fiend Folio Creatures which I never got around to converting to SW...:)

Yeah, the token scaling can be awkward. It would be easier if there was a "cross-function" that scaled the tokens automatically to the grid size. and if you could zoom in on those tiny tokens it would be a neat addition. That way moving 6" looks more like a challenging feat befitting of a Wild Card character. It would also make suppression fire and multiple targeting a lot easier, Now the maps on the other hand....