"active" scripting support -- separation of presentation & data

Bug #571072 reported by agamemnus
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Wishlist
Unassigned

Bug Description

Hello,

I would like to make Inkscape the editor for the game I'm making. At the moment, however, it's not very easy to do without a "template" or some sort of variable scripting.

I found out about the SVG "use" tag yesterday, but I need something more powerful. Here's my current setup:

[code]
<defs id="templates">
 <g id="template_area_capital">

   <path id="template_area_capital_crosshair"
    d="m -7.5,0 15,0 -7.5,0 0,-7.5 0,15 0,-7.5"
    style="stroke:#000000;stroke-width:0.05012808;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />

   <circle id="template_area_capital_circle" cx = "0" cy = "0" r = "7.5"
    style="fill:#003f7f;fill-opacity:0.49803922;stroke:#000000;stroke-width:0.05012808;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />

   <rect id="template_area_capital_port" width = ".5" height = ".5" x = "-.25" y = "-.25"
    style="fill:none; stroke:#0000ff; stroke-width:0.025; stroke-miterlimit:4; stroke-opacity:1; stroke-dasharray:none" />
 </g>
</defs>
[/code]

And the use command:
[code]
<use id="city_E_Syracuse_L_Syracusae" xlink:href="#template_area_capital"
x="1145.5" y="1399" height="1" width="1" />
[/code]

---------------

This is the hypothetical ideal:

[code]
<defs id="templates">
 <g id="template_point">
   switch ($subtype) {
   case "empire capital": ("template_point_circle").fill = "red"; // Or use a hex value..
   case "capital": ("template_point_circle").fill = "blue";
   case "city": ("template_point_circle").fill = "green";
   case "fort": ("template_point_circle").fill = "purple";
   }

   <path id="template_point_crosshair"
    d="m -7.5,0 15,0 -7.5,0 0,-7.5 0,15 0,-7.5"
    style="stroke:#000000;stroke-width:0.05012808;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />

   <circle id="template_point_circle" cx = "0" cy = "0" r = $size
    style="fill:#003f7f;fill-opacity:0.49803922;stroke:#000000;stroke-width:0.05012808;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />

   <rect id="template_point_port" width = ".5" height = ".5" x = (-.25+$portx) y = (-.25+$porty)
    style="fill:none; stroke:#0000ff; stroke-width:0.025; stroke-miterlimit:4; stroke-opacity:1; stroke-dasharray:none" />
 </g>
</defs>
[/code]

[code]
<use id="city_E_Syracuse_L_Syracusae" xlink:href="#template_point"
x="1145.5"
y="1399"
size = "7.5"
subtype = "capital"
portx = "5"
porty = "10"
/>
[/code]

I'd also like to be able to move the rectangle (id="template_point_port") using the inkscape GUI move command and have it update portx and porty. Similarly with circle size and color-- if the GUI changes those properties, the subtype and width would be affected as well. Possible Code for this:

======
I had some possible code written for this on those "unofficial" Inkscape forums but it's not approved yet and I didn't save a copy.. when it's approved I'll add a comment to this report.
======

It would be so much easier to do what I've wanted to do with this sort of way to separate content and data ... it would make much easier the parsing of my map data SVG, allow me to add more data to it, and make the eventual users of my game use Inkscape as a viable and powerful game level editor! ...

su_v (suv-lp)
tags: added: extensions-plugins
Changed in inkscape:
importance: Undecided → Wishlist
Revision history for this message
agamemnus (agamemnus) wrote :

OK: An example to how you'd go from inkscape GUI movement to changing the data:

[code]
switch (event) {
case "stretched_evenly": cancel_regular_action(); instance.size = new_size;
case "color_changed":
 switch toInt(color):
 case "red": cancel_regular_action(); subtype = "empire capital";
 case "blue": cancel_regular_action(); subtype = "capital";
 case "green": cancel_regular_action(); subtype = "city";
 case "fort": cancel_regular_action(); subtype = "purple";
}
case "childrenMoved":
 cancel_regular_action();
 portx = dx("template_point_port");
 portx = dy("template_point_port");
[/code]
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.