How tu use the custom drawing?

m4u
27 Nov 2014, 22:43
Not sure how to use the feature Custom Drawing and its functions?

Doest it mean that we can draw something, making lines or what?

A sample file would be nice too.

Thank you!

Avantar
28 Nov 2014, 10:12
I have not tried it myself and agree that an example would be nice, but according to me:
You can draw shapes by inserting points, arrows, lines, squares, etc on the custom layer.
To turn the custom layer on or off, you use Grid ShowCustomLayer (boolean visible)
You've got different commands you can use like:
Grid_AddNewShapePoint (int x, int y)
Grid_DrawGridLines (int x1, int y1, int x2, int y2, string border)
Grid_DrawArrow (string id, int x1, int y1, int x2, int y2, string border, int borderwidth)
And so forth.
To finish drawing the shape, you would use: Grid_DrawShape (string id, string border, string fill, double opacity)

I am not too clued up on the parameters used like 'string id' - sorry.
Somebody more knowledgeable will need to step in here.

jaynabonne
28 Nov 2014, 11:12
Attached is a sample. It doesn't cover everything, but it should give a taste.

You can get the grid to show up just by turning on the game's map feature. However, that will draw the room map in the grid as well. This sample circumvents that by simply making a couple of calls in the game setup script to turn on the grid on its own:

      // Show grid.
JS.ShowGrid(game.mapsize)
Grid_SetScale (game.mapscale)


If you want the room map as well, then you can remove those lines and just enable the map feature.

The ids are used to allow shapes to be updated. For example, if you draw an arrow with id "arrow" and then draw another arrow in a different place with the same id, then the arrow will move there. The old position will be erased. (At least, that is the theory as I see it based on the docs. I haven't tried it myself.)

Color values can be standard HTML color strings (either color names like "red", "blue", etc or more advanced like "'#45FF30").

I suppose this could be added in the Libraries and Samples forum, if it seems an adequate sample.
<!--Saved by Quest 5.5.5328.26617-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="customdrawingsample">
<gameid>757f07bc-23f5-448d-a0c5-0928e4e9abf9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<showtitle type="boolean">false</showtitle>
<start type="script">
// Show grid.
JS.ShowGrid(game.mapsize)
Grid_SetScale (game.mapscale)

// Show the custom layer
Grid_ShowCustomLayer (true)

// Draw some stuff.
Grid_DrawSquare ("asquare", 0, 0, 2, 2, "A Square", "#ff0000")
Grid_DrawArrow ("arrow1", 6, 4, 8, 4, "#c0c0c0", 2)
Grid_DrawArrow ("arrow2", 8, 4, 8, 6, "#ca8642", 2)
// Create and draw a shape.
Grid_AddNewShapePoint(5, 5)
Grid_AddNewShapePoint(6, 8)
Grid_AddNewShapePoint(8, 9)
Grid_AddNewShapePoint(10, 8)
Grid_AddNewShapePoint(11, 5)
Grid_AddNewShapePoint(8, 8)
Grid_DrawShape("shapey", "blue", "yellow", 1)
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="north" to="north room">
<inherit name="northdirection" />
</exit>
</object>
<object name="north room">
<inherit name="editor_room" />
<exit alias="south" to="room">
<inherit name="southdirection" />
</exit>
</object>
</asl>

Avantar
28 Nov 2014, 12:09
I think this example will do nicely in the Script Library - it is easy to follow and clears up many questions I would have had about it.
I do not see any use for it yet, but having the arrow or shape move might spark my interest in doing something with it.
It is just cool being able to do that in a text adventure engine. Almost like putting Blue-tooth in your analog watch - not sure what to do with it, but it is a gadget and pretty cool. :-)

Silver
28 Nov 2014, 12:17
i've got no idea what to do with it that wouldn't be better done with an image file. I'm not really interested in maps anyway. If I did want a map I'd probably incorporate it into an image file too.

jaynabonne
28 Nov 2014, 13:11
I can see it being useful as an extension of the mapping. You might want to change what the player shape looks like, for example, or put little bits of furniture in the rooms (you can also draw images) or whatever strikes you about the map. Of course, I gave a map-less example, but that might be the way it's normally used. I had extended the mapping code myself before this because I wanted the player marker to be something besides a circle. With this, I wouldn't have needed to do that!

Silver
28 Nov 2014, 14:33
I can draw in vectors. Not particularly well but I have a design package (Xara) that does so. It would be useful if I could convert vector images to code because then I could give the rooms a theme rather than them being coloured boxes. If I were to use maps that is.... presently I have no plans to as I'd rather have the option to use that window for image files (and I could draw parts of a map on those).

Avantar
28 Nov 2014, 14:59
jaynabonne wrote:I can see it being useful as an extension of the mapping. You might want to change what the player shape looks like, for example, or put little bits of furniture in the rooms


Now that could be interesting: Does that mean I can 'detail' a room? If so - Could you perhaps have the room zoomed in, your multiple characters icons smaller and just maybe move the character icons around in the room? Almost like a one room story like you have that plays out in a cell. You draw your bed, possible door exit and perhaps a wash basin - almost like rooms in a house - The SIMMS comes to mind. :)

Not sure I will go that far, but if it is possible - I could always give it a bash.