Thread: 2.2.0 Feature: Custom Pointers
-
September 12th, 2008, 08:29 #1
2.2.0 Feature: Custom Pointers
The 2.2.0 version of Fantasy Grounds allows the definition of custom pointer types in the ruleset. You can create any shape that can be defined using a series of spline curves defined using four control points.
Attachment 488
To accomplish this, you need to include a <pointertypes> element in your imagecontrol definition:
Code:<pointertypes> <arrow> <icon>pointer</icon> <label>Draw Arrow</label> </arrow> <custom name="my_cone"> <icon>pointer_cone</icon> <label>Draw Cone</label> </custom> </pointertypes>
When pointers of a custom type are created or modified, a new script event will be fired to build the list of control points.
Code:function transformSpline(spline, angle, centerx, centery) for segmentindex, segment in ipairs(spline) do for controlpointindex, controlpoint in ipairs(segment) do local x = controlpoint[1]; local y = controlpoint[2]; local nx = (x-centerx) * math.cos(angle) - (y-centery) * math.sin(angle) + centerx; local ny = (x-centerx) * math.sin(angle) + (y-centery) * math.cos(angle) + centery; segment[controlpointindex] = { nx, ny }; end end end function onBuildCustomPointer(startx, starty, endx, endy, type) local segments = {}; local distpos; local drawarrow; local u = 32; if hasGrid() then u = getGridSize(); end local angle = math.atan2(endx - startx, - endy + starty); if type == "my_cone" then -- Build a cone facing in the negative y direction local segment = { { startx, starty }, { startx, starty }, { startx - 1.5*u, starty - 6.5*u }, { startx - 1.5*u, starty - 7.5*u } }; table.insert(segments, segment); local segment = { { startx - 1.5*u, starty - 7.5*u }, { startx - 1.5*u, starty - 8.25*u }, { startx - 0.75*u, starty - 9*u }, { startx, starty - 9*u } }; table.insert(segments, segment); local segment = { { startx, starty }, { startx, starty }, { startx + 1.5*u, starty - 6.5*u }, { startx + 1.5*u, starty - 7.5*u } }; table.insert(segments, segment); local segment = { { startx + 1.5*u, starty - 7.5*u }, { startx + 1.5*u, starty - 8.25*u }, { startx + 0.75*u, starty - 9*u }, { startx, starty - 9*u } }; table.insert(segments, segment); -- Set the distance indicator position (in pixels) distpos = { 30, 30 }; end -- Transform it to match angle transformSpline(segments, angle, startx, starty); return segments, distpos, drawarrow; end
The onBuildCustomPointer event can return three values. The first is the list of spline segments, the second is a table of two values that specify where the length of the pointer should be drawn relative to its origin (given by onMeasurePointer), and the third a boolean value indicating whether to end the pointer with an arrowhead pointing in the direction of the last segment.
Please keep in mind that very complex shapes can cause performance issues on slower computers.
Custom pointers don't support grid shading at this time, we're looking into this possibility.Tero Parvinen
Fantasy Grounds Guru
-
April 13th, 2009, 19:09 #2
- Join Date
- Sep 2008
- Posts
- 11
Unless I'm missing something, this is the ever elusive Savage Worlds Cone. If so, thank you very much (a bit late).
I consider myself relatively PC savvy but I'm no programmer or custom ruleset guy, and delving into enough about XML and LUA to do this would probably just make me very, very dangerous to myself and others.
I was hoping that someone might know if this was going to be appearing in the Savage Worlds ruleset any time soon?
If not, then is there something out there like "An Idiot's Guide to Adding the Savage Worlds Cone Template to FGII"?
If not, I might be willing to take a hack at it, but ideally someone in the know would... well, know
Thanks!
-Grix (the XML villiage idiot)Last edited by Grix; April 13th, 2009 at 19:11.
-
April 14th, 2009, 14:46 #3Originally Posted by Grix
-
April 14th, 2009, 16:08 #4
- Join Date
- Sep 2008
- Posts
- 11
Originally Posted by Thore_Ironrock
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks