PDA

View Full Version : Token frames and overlays



joshuha
August 16th, 2011, 04:30
Figured I would start a new thread on this as I get closer to a release date. This thread will be for suggestions/ideas/feedback on 2 sets of functionality I am trying to added to tokens on the map.


Token frames. Essentially this is just a set of tokens that advance to the next in a series by either using the right click menu option for Advance Frame or Ctrl+left click. The naming convention of the tokens are tokenname[1o6].png, tokenname[2o6].png, etc. These can be used to simulate different character states (alive, dead, shapeshifted) or things like open/closed doors & chests, breaking furniture, etc.
Token overlays. These are other tokens that will act as non-interactive overlays to a token. I am working on implementing two types. The first is your regular overlay that sits centered on the token and can be used for things like light sources, cloaked fields, turrets, etc. The second is what I am calling a slotted overlay. These will be used for smaller overlays to denote conditions in games like blinded, wounded, etc. and will stack intelligently around a token as they are added. Ultimate would like to synch them with the combat tracker but that will be ruleset specific so will just provide the functions for designers for that.



I will update this thread with videos/progress as I get closer.

--------------
Update - 08/15/2011

https://bitsbyteswords.com/token_states/token_states.html

Newest update to my token states Fantasy Grounds code. I completely started over today as I decided to do it with additional tokens as opposed to dynamic runtime genericcontrols. The end idea here is you will have two types of overlays. Slotted overlays that will stacks around the border of a token and regular overlays that will cover a token from the centerpoint. This way you can use one set of overlays for things like light sources or stealth fields or what not (regular) and another set to represent conditions (slotted). The script will know what to do based on the token name. Still a bit to do but getting closer.

joshuha
August 17th, 2011, 22:29
Update - 08/17/2011

Ok I am having some issue that when an imagecontrol is zooming in my slot_overlay is no longer anchoring in lower corner. It seems the zoom factor plays a role in how these tokens will stay linked but I can't figure out the exact relationship so having trouble coming up with a formula.

So first some terminology that I am using:

Token - The target token you are dropping the overlay token on.
Overlay - The overlay token being dropped to anchor on the target token.
Viewpoint - The image viewpoint include x,y offset and zoom level
Token/overlay scale - The individual scale value of the target token/overlay token.
Token/overlay imageSize - The original size in pixels of the target token/overlay image.
Token/overlay x,y position - What Fantasy Grounds is reporting as the centered position of the token


With that above at a default zoom level of 1 I am calculating the placement of the overlaytoken (to get it to the closest bottom left of the image) as follows:


overlay.x = tokenx-tokenw/2*tokenscale+overlay.w/2
overlay.y = tokeny+tokenh/2*tokenscale-overlay.h/2
overlaytoken = addToken(overlay.tokenimage, overlay.x, overlay.y)
overlaytoken.setScale(overlay.scale)


This works perfectly right now. Assume for formula purposes a tokenscale of 1 and a token size (w,h) of 100x100 and overlay size (w,h) of 50,50 and it puts in the bottom left taking up about a quarter of the image. However when zooming the following occurs: Avi video (bitsbyteswords.com/zoom_issue.avi). Sorry for the quality not at home PC to upload super hi-rez version.

So you will notice that at higher zooms the overlay is being shifter further down and to the left (-x,+y). In that demo video I am not updating the position of the overlay as it zooms as I am trying to test. Using the following formula I am able to get it to not shift as bad but the issue becomes at higher zoom values it shift towards the center:


newx = tokenx-tokenw/(2*vzoom)*tokenscale+overlay.w/(1+vzoom)
newy = tokeny+tokenh/(2*vzoom)*tokenscale-overlay.h/(1+vzoom)
overlay.x=newx
overlay.y=newy
overlay.selflink.setPosition(newx,newy)


Its a closer approximation to what I am looking for but still not perfect. Anyone better at this graphics mapping stuff that could help me with a formula?

joshuha
August 17th, 2011, 22:40
Well think I found it but swore I tried it earlier and discarded it:



newx = tokenx-tokenw/(2*vzoom)*tokenscale+overlay.w/(2*vzoom)
newy = tokeny+tokenh/(2*vzoom)*tokenscale-overlay.h/(2*vzoom)
overlay.x=newx
overlay.y=newy
overlay.selflink.setPosition(newx,newy)


Went all the way up to zoom level 30x and it generally stays in the lower left but has some minor shifts. I am guessing the shifts are some interation between floating points and rounding to nearest whole number pixel or something but its workable.

joshuha
August 18th, 2011, 04:12
Another update.

Trying to work through an issue with token stacking order on the client side. I don't see the issue on GM side and from what I have tried there is no way to control the Z order of tokens (no bringToFront or similar). Re-sharing the window works which is strange as that must trigger a redraw that does it in the proper way that updating a token via setPosition() doesn't.

In this vid the GM is on the left.
https://bitsbyteswords.com/client_stacking/client_stacking.html

VenomousFiligree
August 18th, 2011, 06:59
Looks great! :D

Whilst I can't help in anyway with code, rest assured that I will give moral support in whatever way I can!

mfitzi
August 18th, 2011, 12:47
I agree with MurghBpurn it looks great! I've been waiting for something like this!!

joshuha
August 19th, 2011, 04:45
Update - 08/18/11

Slotted token overlays now working

https://www.bitsbyteswords.com/token_slots/token_slots.html

Got my slot overlays working almost exactly the way I want them. I just need to add a UI to remove a token from a slot and will be set there.

psicodelix
August 19th, 2011, 09:01
awesome! great work!

Jonny Tenebrous
August 20th, 2011, 12:57
Very nice work. This is exactly what I needed when I ran my last 4E Dark Sun campaign. I made all the status tokens and a variety of effects tokens which looked good and were stackable by using transparency.... but obviously moving them all around with the PCs proved to be quite cumbersome. This looks like a nice solution, and I can see it working very well along with DrZeuss's Enhanced Images extension.

joshuha
August 30th, 2011, 16:35
Update - 08/30/11

Been a little distract by some other games but back to it. Coded the right click menu so you can remove a token at a certain slot and it will fill the next available slot (up to 8). After 8 it won't accept any more tokens.

This is pretty much ready to be released once 2.8.1 comes out but still have the issue on the player side that tokens updated using setPosition fall behind the z order of the other tokens until a share is issued. Its kind of annoying and am trying a few things to see if I can resolve it.

Also, integrations of Dr. Zeuss' layers extension into this code (since both touch the same files) is being looked at as well but that is another whole batch of testing that would need to be done.

joshuha
September 8th, 2011, 03:40
Man, had an issue with the way I was version controlling stuff and lost a bunch of work I did on the file which is going to set me back a few days.

Herodian
September 8th, 2011, 15:29
Sorry to hear about the setback :( This will be an incredibly useful feature. What are you using (or switching to) for version control?

joshuha
September 8th, 2011, 16:11
Sorry to hear about the setback :( This will be an incredibly useful feature. What are you using (or switching to) for version control?

I mostly use dropbox as it does have some basic versioning built in but it still relies on uploading your changes. I sometimes work on my work laptop on stuff when I am on lunch break and had made most of my changes there in the last couple of weeks. Issue was that I forgot to upload it to dropbox and yesterday and replaced what was on my laptop with whats was on dropbox thinking that it was the newest version. However, I emptied my recycle bin at some point during the day before I realize what I had done. I haven't lost any core code it was mostly polish with some menu items and a little organization of how I was storing some internal arrays.

VenomousFiligree
September 10th, 2011, 11:06
How easy would it be to have specific images appear in the slot overlays depending on the values of items on the PCs sheet. In particular if a Savage Worlds PC took one wound could you have an appropriate image appear on the token?

joshuha
September 10th, 2011, 23:11
How easy would it be to have specific images appear in the slot overlays depending on the values of items on the PCs sheet. In particular if a Savage Worlds PC took one wound could you have an appropriate image appear on the token?

Going to eventually add some functions to be able to do that by token name. So it would still be up to ruleset developers but would be a bit easier.

VenomousFiligree
September 11th, 2011, 01:41
Going to eventually add some functions to be able to do that by token name. So it would still be up to ruleset developers but would be a bit easier.
*prods phantomwhale* :D

phantomwhale
September 12th, 2011, 13:04
*hrumph* whaaaaat ? ...reads thread... Put in on the wishlist *back to sleep*

joshuha
September 13th, 2011, 07:13
Code caught up and also refactored to be slightly more readable. Although I eventually want to include comments but haven't this go around. My imagewindow_image.lua file is already up to 1050 lines.

I am going to submit newest build to a few people I have doing some testing than maybe by end of week release the new core foundations that also has the token extensions code. I still want to merge with Dr Z's layer extension but figure that could come after the first release.

VenomousFiligree
September 13th, 2011, 08:19
Good to hear! :)

Will the token overlays be a separate extension, or just included with Core Foundation?

joshuha
September 14th, 2011, 15:57
Good to hear! :)

Will the token overlays be a separate extension, or just included with Core Foundation?

Just include with the Core. I could break it out into an extension if needed. Just would conflict with any others that modify the imagewindow files.

On a seperate note I could use a few testers to work out any bugs. Need 2-3 people who want to mess around with the Token Extensions stuff. Just send me a PM and I will send you a link to the file.

demonsbane
September 14th, 2011, 18:12
On a seperate note I could use a few testers to work out any bugs. Need 2-3 people who want to mess around with the Token Extensions stuff. Just send me a PM and I will send you a link to the file.

This is great and seems pretty finished!

Here is a small recording (https://dl.dropbox.com/u/12554407/Token%20Frames%20Overlays%20Status%20Icons.mp4) that I did while testing these new features covering token frames, status icons and overlays.

VenomousFiligree
September 14th, 2011, 20:09
Using overlays for Savage Worlds wounds.... me likes :)

Herodian
September 14th, 2011, 20:18
Looking good!

Blue Haven
September 19th, 2011, 19:02
Wow!!! is this on for the other rulesets? i mean the 3,5 and 4th edition...so cool :D

Jonny Tenebrous
September 19th, 2011, 20:05
Oh yeah.... will definitely be wanting to use this with my Pathfinder campaign when it's ready. Keep up the good work!

joshuha
September 19th, 2011, 21:19
Sent out hopefully the final build for this for testing. If no major bugs will release it in the next day or two. First as part of the foundations_core and then possible as an extension.

psicodelix
October 14th, 2011, 10:13
Hi guys,

is there any news about this project?

VenomousFiligree
October 14th, 2011, 10:24
It's been realised in Foundation Core here (https://www.fantasygrounds.com/forums/showthread.php?t=15391&highlight=foundation), but not as a separate extension.

psicodelix
October 14th, 2011, 10:29
Ok, thank you.

Gigermann
November 7th, 2011, 06:00
Just tried this out with the newest GURPS ruleset, and I've run into a problem: The tokens I use have a larger coverage area than is apparent, and it looks like I need to be able to fine-tune the positioning of the slots—right now, it looks weird, as the slotted icon sits a hex or two away from the "effective" base (as opposed to the "actual" base, that is invisible)