mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 21:08:35 +02:00
- few Adjustments in Application class for Script editor
- Shortkey for script editor (Alt+S) - highlighter: bold true/false , single line comments - Run scripts from the editor works - More icons from Maximillian, Thanks - Run on the fly checkbox, works if the script is running. - Load/save features
This commit is contained in:
parent
d2d3937e08
commit
c016d6557e
15 changed files with 1163 additions and 51 deletions
557
interface/resources/icons/start-script.svg
Normal file
557
interface/resources/icons/start-script.svg
Normal file
|
@ -0,0 +1,557 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="45"
|
||||
height="45"
|
||||
id="svg3827"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.1 r9760"
|
||||
sodipodi:docname="start-script.svg">
|
||||
<defs
|
||||
id="defs3829">
|
||||
<radialGradient
|
||||
r="15.645"
|
||||
cy="36.421"
|
||||
cx="24.837"
|
||||
gradientTransform="matrix(1.1302,0,0,-0.40769251,48.062716,1046.2254)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="radialGradient3253"
|
||||
xlink:href="#radialGradient8668"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
gradientTransform="translate(51.972416,1005.3761)"
|
||||
y2="36.437"
|
||||
x2="28.061"
|
||||
y1="31.431"
|
||||
x1="28.061"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3239"
|
||||
xlink:href="#linearGradient6971"
|
||||
inkscape:collect="always" />
|
||||
<radialGradient
|
||||
id="radialGradient5031"
|
||||
xlink:href="#linearGradient5060"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="486.65"
|
||||
cx="605.71"
|
||||
gradientTransform="matrix(-2.7744,0,0,1.9697,112.76,-872.89)"
|
||||
r="117.14" />
|
||||
<linearGradient
|
||||
id="linearGradient5060">
|
||||
<stop
|
||||
id="stop5062"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop5064"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="radialGradient5029"
|
||||
xlink:href="#linearGradient5060"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="486.65"
|
||||
cx="605.71"
|
||||
gradientTransform="matrix(2.7744,0,0,1.9697,-1891.6,-872.89)"
|
||||
r="117.14" />
|
||||
<linearGradient
|
||||
id="linearGradient5027"
|
||||
x1="302.86"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="366.65"
|
||||
gradientTransform="matrix(2.7744,0,0,1.9697,-1892.2,-872.89)"
|
||||
x2="302.86"
|
||||
y2="609.51">
|
||||
<stop
|
||||
id="stop5050"
|
||||
stop-opacity="0"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop5056"
|
||||
offset=".5" />
|
||||
<stop
|
||||
id="stop5052"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="radialGradient4997"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="6.4577"
|
||||
cx="23.447"
|
||||
gradientTransform="matrix(-1.3145,-0.010063,-0.01023,1.3362,46.221,-4.9099)"
|
||||
r="19.062">
|
||||
<stop
|
||||
id="stop4993"
|
||||
stop-color="#fff"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4995"
|
||||
stop-color="#fff"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="linearGradient1764"
|
||||
x1="33.06"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="27.394"
|
||||
gradientTransform="matrix(0.91411,0,0,0.91411,-3.8687,-2.7069)"
|
||||
x2="12.624"
|
||||
y2="12.584">
|
||||
<stop
|
||||
id="stop2189"
|
||||
stop-color="#fff"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2191"
|
||||
stop-color="#fff"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="radialGradient8668"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="36.421"
|
||||
cx="24.837"
|
||||
gradientTransform="matrix(1,0,0,0.53672,0,16.873)"
|
||||
r="15.645">
|
||||
<stop
|
||||
id="stop8664"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop8666"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4209"
|
||||
x1="7.0625"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="24.688"
|
||||
gradientTransform="translate(0.79549,3.7992)"
|
||||
y1="35.281"
|
||||
y2="35.281">
|
||||
<stop
|
||||
id="stop4186"
|
||||
stop-color="#838383"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4188"
|
||||
stop-color="#bbb"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4234"
|
||||
x1="7.6046"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="36.183"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
y1="28.481"
|
||||
y2="40.944">
|
||||
<stop
|
||||
id="stop4230"
|
||||
stop-color="#bbb"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4232"
|
||||
stop-color="#9f9f9f"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4242"
|
||||
x1="12.277"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="12.222"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
y1="37.206"
|
||||
y2="33.759">
|
||||
<stop
|
||||
id="stop4238"
|
||||
stop-color="#eee"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4240"
|
||||
stop-color="#eee"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id="radialGradient4250"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cy="2.9585"
|
||||
cx="15.571"
|
||||
gradientTransform="matrix(1.2862,0.7817,-0.71078,1.1696,-2.3543,0.24814)"
|
||||
r="20.936">
|
||||
<stop
|
||||
id="stop4246"
|
||||
stop-color="#e4e4e4"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4248"
|
||||
stop-color="#d3d3d3"
|
||||
offset="1" />
|
||||
</radialGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4260"
|
||||
x1="12.378"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="44.096"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
y1="4.4331"
|
||||
y2="47.621">
|
||||
<stop
|
||||
id="stop4256"
|
||||
stop-color="#fff"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4258"
|
||||
stop-color="#fff"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4272"
|
||||
x1="23.688"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x2="23.688"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
y1="11.319"
|
||||
y2="26.357">
|
||||
<stop
|
||||
id="stop4276"
|
||||
stop-color="#fff"
|
||||
stop-opacity=".2549"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4278"
|
||||
stop-color="#fff"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient2553"
|
||||
y2="11.781"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="31.965"
|
||||
x2="21.748"
|
||||
x1="33.431">
|
||||
<stop
|
||||
id="stop2557"
|
||||
stop-color="#fff"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop2561"
|
||||
stop-color="#e6e6e6"
|
||||
offset=".5" />
|
||||
<stop
|
||||
id="stop2563"
|
||||
stop-color="#fff"
|
||||
offset=".75" />
|
||||
<stop
|
||||
id="stop2565"
|
||||
stop-color="#e1e1e1"
|
||||
offset=".84167" />
|
||||
<stop
|
||||
id="stop2559"
|
||||
stop-color="#fff"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient6907"
|
||||
y2="16.743"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="15.868"
|
||||
x2="8.8953"
|
||||
x1="14.752">
|
||||
<stop
|
||||
id="stop6903"
|
||||
stop-color="#3465a4"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop6905"
|
||||
stop-color="#3465a4"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient6931"
|
||||
y2="21.118"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="18.25"
|
||||
x2="7"
|
||||
x1="12.25">
|
||||
<stop
|
||||
id="stop6927"
|
||||
stop-color="#204a87"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop6929"
|
||||
stop-color="#204a87"
|
||||
stop-opacity="0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient6971"
|
||||
y2="36.437"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
y1="31.431"
|
||||
x2="28.061"
|
||||
x1="28.061">
|
||||
<stop
|
||||
id="stop6967"
|
||||
stop-color="#ddd"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop6969"
|
||||
stop-color="#fdfdfd"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5027"
|
||||
id="linearGradient3248"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(2.7744,0,0,1.9697,-1892.2,-872.89)"
|
||||
x1="302.86"
|
||||
y1="366.65"
|
||||
x2="302.86"
|
||||
y2="609.51" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5060"
|
||||
id="radialGradient3250"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(2.7744,0,0,1.9697,-1891.6,-872.89)"
|
||||
cx="605.71"
|
||||
cy="486.65"
|
||||
r="117.14" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient5060"
|
||||
id="radialGradient3252"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-2.7744,0,0,1.9697,112.76,-872.89)"
|
||||
cx="605.71"
|
||||
cy="486.65"
|
||||
r="117.14" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4234"
|
||||
id="linearGradient3254"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
x1="7.6046"
|
||||
y1="28.481"
|
||||
x2="36.183"
|
||||
y2="40.944" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#radialGradient4250"
|
||||
id="radialGradient3256"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.2862,0.7817,-0.71078,1.1696,-2.3543,0.24814)"
|
||||
cx="15.571"
|
||||
cy="2.9585"
|
||||
r="20.936" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4209"
|
||||
id="linearGradient3258"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0.79549,3.7992)"
|
||||
x1="7.0625"
|
||||
y1="35.281"
|
||||
x2="24.688"
|
||||
y2="35.281" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4242"
|
||||
id="linearGradient3260"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
x1="12.277"
|
||||
y1="37.206"
|
||||
x2="12.222"
|
||||
y2="33.759" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4272"
|
||||
id="linearGradient3262"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
x1="23.688"
|
||||
y1="11.319"
|
||||
x2="23.688"
|
||||
y2="26.357" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4260"
|
||||
id="linearGradient3264"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0,5.125)"
|
||||
x1="12.378"
|
||||
y1="4.4331"
|
||||
x2="44.096"
|
||||
y2="47.621" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient2553"
|
||||
id="linearGradient3266"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="33.431"
|
||||
y1="31.965"
|
||||
x2="21.748"
|
||||
y2="11.781" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#radialGradient8668"
|
||||
id="radialGradient3268"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.1302,0,0,-0.40769251,48.062716,1046.2254)"
|
||||
cx="24.837"
|
||||
cy="36.421"
|
||||
r="15.645" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient6971"
|
||||
id="linearGradient3270"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(51.972416,1005.3761)"
|
||||
x1="28.061"
|
||||
y1="31.431"
|
||||
x2="28.061"
|
||||
y2="36.437" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6"
|
||||
inkscape:cx="76.804753"
|
||||
inkscape:cy="13.198134"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1028"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata3832">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Maximillian Merlin</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1007.3622)">
|
||||
<g
|
||||
id="layer1-7"
|
||||
transform="matrix(-0.25019951,0,0,0.28877175,123.44112,917.40972)"
|
||||
style="fill:#696969">
|
||||
<g
|
||||
id="g3257"
|
||||
transform="matrix(1.9175,0,0,1.9175,-607.19,-179.09)"
|
||||
style="fill:#696969">
|
||||
<path
|
||||
id="path3224"
|
||||
d="m 563.06,260.72 -1.25,0.16 -40.15,4.87 -1.66,0.22 0.38,1.62 c 3.78,16.93 -0.59,34.07 -2.88,51.57 l -0.22,1.84 1.81,-0.16 42,-3 1.25,-0.06 0.16,-1.25 c 2.13,-17.86 6.92,-36.12 0.94,-54.62 l -0.38,-1.19 z m -2.18,3.28 c 4.96,16.72 -1.56,33.17 -3.72,50.47 l -35.63,2.78 c 2.25,-16.14 7.03,-29.55 3.78,-46.19 L 560.88,264 z"
|
||||
style="fill:#696969;fill-rule:evenodd"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3237"
|
||||
d="m 531.39,275.61 23.34,-4.6"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3243"
|
||||
d="m 532.1,280.91 22.27,-2.83"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3247"
|
||||
d="m 531.92,285.86 22.89,-1.95"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3249"
|
||||
d="m 530.15,292.84 24.22,-2.12"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3251"
|
||||
d="m 529.45,297.53 22.98,-0.8"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3253"
|
||||
d="m 528.65,304.24 22.45,-2.56"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3255"
|
||||
d="m 527.5,309.37 22.81,-1.77"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<rect
|
||||
style="color:#000000;fill:#00ffff;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:0.42527184;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3032"
|
||||
width="44.57473"
|
||||
height="44.57473"
|
||||
x="0.18852967"
|
||||
y="1007.5989" />
|
||||
<rect
|
||||
style="color:#000000;fill:#00ffff;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:0.42527184;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3032-4"
|
||||
width="44.57473"
|
||||
height="44.57473"
|
||||
x="84.498352"
|
||||
y="1050.0748" />
|
||||
<g
|
||||
id="g3322"
|
||||
transform="translate(-46.607143,-3.5714285)">
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
width="744.09448"
|
||||
height="1052.3622"
|
||||
transform="translate(0.5864354,0.4607839)"
|
||||
xlink:href="#rect899"
|
||||
id="use1503" />
|
||||
<path
|
||||
d="m 75.506508,1023.3478 1.372845,5.4631 -14.094975,-1.152 2.35e-4,7.2772 14.094975,-1.152 -1.372845,5.1249 13.761293,-7.6113 -13.761293,-7.9499 z"
|
||||
id="rect899"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#d3d3d3;fill-opacity:0.75;fill-rule:evenodd;stroke:#000000;stroke-width:0.77974033;stroke-linecap:round;stroke-linejoin:round" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 16 KiB |
163
interface/resources/icons/stop-script.svg
Normal file
163
interface/resources/icons/stop-script.svg
Normal file
|
@ -0,0 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="45"
|
||||
height="45"
|
||||
id="svg3827"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.1 r9760"
|
||||
sodipodi:docname="stop-script.svg">
|
||||
<defs
|
||||
id="defs3829" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6"
|
||||
inkscape:cx="15.598703"
|
||||
inkscape:cy="22.861751"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1028"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata3832">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Maximillian Merlin</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1007.3622)">
|
||||
<g
|
||||
id="layer1-7"
|
||||
transform="matrix(-0.25019951,0,0,0.28877175,123.44112,917.40972)"
|
||||
style="fill:#696969">
|
||||
<g
|
||||
id="g3257"
|
||||
transform="matrix(1.9175,0,0,1.9175,-607.19,-179.09)"
|
||||
style="fill:#696969">
|
||||
<path
|
||||
id="path3224"
|
||||
d="m 563.06,260.72 -1.25,0.16 -40.15,4.87 -1.66,0.22 0.38,1.62 c 3.78,16.93 -0.59,34.07 -2.88,51.57 l -0.22,1.84 1.81,-0.16 42,-3 1.25,-0.06 0.16,-1.25 c 2.13,-17.86 6.92,-36.12 0.94,-54.62 l -0.38,-1.19 z m -2.18,3.28 c 4.96,16.72 -1.56,33.17 -3.72,50.47 l -35.63,2.78 c 2.25,-16.14 7.03,-29.55 3.78,-46.19 L 560.88,264 z"
|
||||
style="fill:#696969;fill-rule:evenodd"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3237"
|
||||
d="m 531.39,275.61 23.34,-4.6"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3243"
|
||||
d="m 532.1,280.91 22.27,-2.83"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3247"
|
||||
d="m 531.92,285.86 22.89,-1.95"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3249"
|
||||
d="m 530.15,292.84 24.22,-2.12"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3251"
|
||||
d="m 529.45,297.53 22.98,-0.8"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3253"
|
||||
d="m 528.65,304.24 22.45,-2.56"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3255"
|
||||
d="m 527.5,309.37 22.81,-1.77"
|
||||
style="fill:#696969;stroke:#000000;stroke-width:1px"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<rect
|
||||
style="color:#000000;fill:#00ffff;fill-opacity:0;fill-rule:nonzero;stroke:none;stroke-width:0.42527184;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
|
||||
id="rect3032"
|
||||
width="44.57473"
|
||||
height="44.57473"
|
||||
x="0.18852967"
|
||||
y="1007.5989" />
|
||||
<g
|
||||
id="stop"
|
||||
transform="matrix(0.08804464,0,0,0.0856179,29.060719,1033.5397)">
|
||||
<g
|
||||
id="g3004">
|
||||
<path
|
||||
d="M 0,-150 H 62.132 L 150,-62.132 V 62.128 L 62.132,150 H -62.128 L -149,62.132 V -62.128 L -61.132,-150 H 1 0 z"
|
||||
id="stop_octagon"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#e81108" />
|
||||
</g>
|
||||
<g
|
||||
id="g3007"
|
||||
transform="scale(0.95,0.95)">
|
||||
<path
|
||||
d="M 0,-142.5 H 59.025 L 142.5,-59.025 V 59.025 L 59.025,142.5 H -59.025 L -141.549,59.025 V -59.025 L -58.074,-142.5 H 0.951 0.001 z"
|
||||
id="stop_octagon_1_"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none;stroke:#ffffff;stroke-width:5" />
|
||||
</g>
|
||||
<g
|
||||
id="g3010"
|
||||
transform="scale(1,1.45)">
|
||||
<g
|
||||
id="g3012"
|
||||
style="fill:#ffffff;enable-background:new">
|
||||
<path
|
||||
id="path3014"
|
||||
d="m -124.2,12.152 8.489,-0.742 c 0.401,3.402 1.337,6.192 2.806,8.373 1.469,2.18 3.75,3.943 6.842,5.288 3.092,1.345 6.571,2.018 10.437,2.018 3.433,0 6.463,-0.51 9.092,-1.53 2.628,-1.021 4.584,-2.42 5.868,-4.198 1.283,-1.778 1.925,-3.718 1.925,-5.821 0,-2.134 -0.619,-3.997 -1.855,-5.59 -1.237,-1.592 -3.278,-2.93 -6.123,-4.013 -1.825,-0.711 -5.861,-1.816 -12.107,-3.317 -6.247,-1.5 -10.623,-2.914 -13.127,-4.244 -3.247,-1.7 -5.667,-3.811 -7.26,-6.332 -1.593,-2.52 -2.389,-5.342 -2.389,-8.465 0,-3.433 0.974,-6.641 2.922,-9.625 1.948,-2.984 4.793,-5.249 8.535,-6.796 3.741,-1.546 7.901,-2.319 12.478,-2.319 5.04,0 9.486,0.812 13.336,2.435 3.85,1.623 6.811,4.012 8.883,7.167 2.071,3.154 3.185,6.726 3.34,10.715 l -8.628,0.65 c -0.464,-4.298 -2.034,-7.545 -4.708,-9.741 -2.675,-2.195 -6.626,-3.293 -11.852,-3.293 -5.443,0 -9.409,0.997 -11.898,2.992 -2.489,1.995 -3.734,4.4 -3.734,7.213 0,2.443 0.881,4.453 2.644,6.03 1.731,1.577 6.254,3.194 13.568,4.847 7.313,1.655 12.331,3.101 15.053,4.337 3.958,1.825 6.88,4.136 8.767,6.935 1.886,2.799 2.83,6.023 2.83,9.672 0,3.618 -1.037,7.028 -3.108,10.228 -2.072,3.201 -5.049,5.69 -8.93,7.468 -3.881,1.778 -8.25,2.667 -13.104,2.667 -6.154,0 -11.311,-0.897 -15.47,-2.691 -4.159,-1.793 -7.422,-4.492 -9.788,-8.094 -2.37,-3.604 -3.62,-7.678 -3.74,-12.224 z"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3016"
|
||||
d="m -40.473,34 v -59.978 h -22.405 v -8.025 h 53.901 v 8.025 H -31.475 V 34 h -8.998 z"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3018"
|
||||
d="m -4.198,0.88 c 0,-11.287 3.03,-20.124 9.092,-26.51 6.061,-6.385 13.885,-9.579 23.472,-9.579 6.277,0 11.937,1.5 16.978,4.5 5.04,3 8.883,7.182 11.527,12.547 2.644,5.366 3.966,11.45 3.966,18.253 0,6.896 -1.392,13.066 -4.175,18.508 -2.783,5.443 -6.726,9.564 -11.829,12.362 -5.103,2.799 -10.607,4.198 -16.514,4.198 -6.401,0 -12.123,-1.546 -17.163,-4.639 C 6.115,27.428 2.296,23.207 -0.302,17.856 -2.899,12.508 -4.198,6.848 -4.198,0.88 z m 9.277,0.139 c 0,8.195 2.203,14.651 6.61,19.366 4.407,4.716 9.934,7.074 16.583,7.074 6.772,0 12.346,-2.381 16.722,-7.143 4.376,-4.762 6.564,-11.519 6.564,-20.271 0,-5.535 -0.936,-10.367 -2.807,-14.496 -1.871,-4.129 -4.608,-7.329 -8.21,-9.602 -3.603,-2.273 -7.646,-3.41 -12.13,-3.41 -6.371,0 -11.852,2.188 -16.444,6.564 -4.592,4.377 -6.888,11.682 -6.888,21.918 z"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
id="path3020"
|
||||
d="m 72.433,34 v -68.003 h 25.652 c 4.515,0 7.962,0.217 10.344,0.65 3.34,0.557 6.138,1.616 8.396,3.178 2.257,1.562 4.074,3.75 5.45,6.564 1.376,2.815 2.064,5.907 2.064,9.277 0,5.783 -1.84,10.677 -5.52,14.681 -3.681,4.005 -10.329,6.007 -19.946,6.007 H 81.431 V 34 h -8.999 z m 8.999,-35.672 h 17.581 c 5.813,0 9.942,-1.082 12.385,-3.247 2.442,-2.164 3.665,-5.21 3.665,-9.138 0,-2.845 -0.719,-5.28 -2.157,-7.306 -1.438,-2.025 -3.333,-3.363 -5.682,-4.012 -1.516,-0.401 -4.314,-0.603 -8.396,-0.603 H 81.436 v 24.306 z"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 8 KiB |
|
@ -797,6 +797,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
if (activeWindow() == _window) {
|
||||
bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
|
||||
bool isOption = event->modifiers().testFlag(Qt::AltModifier);
|
||||
switch (event->key()) {
|
||||
break;
|
||||
case Qt::Key_BracketLeft:
|
||||
|
@ -839,9 +840,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
break;
|
||||
|
||||
case Qt::Key_S:
|
||||
if (isShifted && isMeta) {
|
||||
if (isShifted && isMeta && !isOption) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
|
||||
} else if (!isShifted && isMeta) {
|
||||
} else if (isOption && !isShifted && !isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::ScriptEditor);
|
||||
} else if (!isOption && !isShifted && isMeta) {
|
||||
takeSnapshot();
|
||||
} else {
|
||||
_myAvatar->setDriveKeys(BACK, 1.f);
|
||||
|
@ -3299,13 +3302,14 @@ void Application::stopAllScripts() {
|
|||
bumpSettings();
|
||||
}
|
||||
|
||||
void Application::stopScript(const QString &scriptName)
|
||||
{
|
||||
_scriptEnginesHash.value(scriptName)->stop();
|
||||
qDebug() << "stopping script..." << scriptName;
|
||||
_scriptEnginesHash.remove(scriptName);
|
||||
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
||||
bumpSettings();
|
||||
void Application::stopScript(const QString &scriptName) {
|
||||
if (_scriptEnginesHash.contains(scriptName)) {
|
||||
_scriptEnginesHash.value(scriptName)->stop();
|
||||
qDebug() << "stopping script..." << scriptName;
|
||||
_scriptEnginesHash.remove(scriptName);
|
||||
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
||||
bumpSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::reloadAllScripts() {
|
||||
|
@ -3366,7 +3370,10 @@ void Application::uploadSkeleton() {
|
|||
uploadFST(false);
|
||||
}
|
||||
|
||||
void Application::loadScript(const QString& scriptName) {
|
||||
ScriptEngine* Application::loadScript(const QString& scriptName, bool focusMainWindow) {
|
||||
if(_scriptEnginesHash.contains(scriptName) && !_scriptEnginesHash[scriptName]->isFinished()){
|
||||
return _scriptEnginesHash[scriptName];
|
||||
}
|
||||
|
||||
// start the script on a new thread...
|
||||
ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface);
|
||||
|
@ -3374,7 +3381,7 @@ void Application::loadScript(const QString& scriptName) {
|
|||
|
||||
if (!scriptEngine->hasScript()) {
|
||||
qDebug() << "Application::loadScript(), script failed to load...";
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
_runningScriptsWidget->setRunningScripts(getRunningScripts());
|
||||
|
||||
|
@ -3422,8 +3429,12 @@ void Application::loadScript(const QString& scriptName) {
|
|||
workerThread->start();
|
||||
|
||||
// restore the main window's active state
|
||||
_window->activateWindow();
|
||||
if (focusMainWindow) {
|
||||
_window->activateWindow();
|
||||
}
|
||||
bumpSettings();
|
||||
|
||||
return scriptEngine;
|
||||
}
|
||||
|
||||
void Application::loadDialog() {
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
~Application();
|
||||
|
||||
void restoreSizeAndPosition();
|
||||
void loadScript(const QString& fileNameString);
|
||||
ScriptEngine* loadScript(const QString& fileNameString, bool focusMainWindow = true);
|
||||
void loadScripts();
|
||||
void storeSizeAndPosition();
|
||||
void clearScriptsBeforeRunning();
|
||||
|
|
|
@ -195,7 +195,7 @@ Menu::Menu() :
|
|||
|
||||
QMenu* toolsMenu = addMenu("Tools");
|
||||
addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
|
||||
addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::CTRL | Qt::SHIFT | Qt::Key_S, this, SLOT(showScriptEditor()));
|
||||
addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::ALT | Qt::Key_S, this, SLOT(showScriptEditor()));
|
||||
|
||||
#ifdef HAVE_QXMPP
|
||||
_chatAction = addActionToQMenuAndActionHash(toolsMenu,
|
||||
|
@ -1125,7 +1125,7 @@ void Menu::showMetavoxelEditor() {
|
|||
}
|
||||
|
||||
void Menu::showScriptEditor() {
|
||||
if(!_ScriptEditor) {
|
||||
if(!_ScriptEditor || !_ScriptEditor->isVisible()) {
|
||||
_ScriptEditor = new ScriptEditorWindow();
|
||||
}
|
||||
_ScriptEditor->raise();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
|
||||
#include "ScriptHighlighting.h"
|
||||
#include <QTextDocument>
|
||||
|
||||
ScriptHighlighting::ScriptHighlighting(QTextDocument* parent) :
|
||||
QSyntaxHighlighter(parent)
|
||||
|
@ -19,13 +20,16 @@ ScriptHighlighting::ScriptHighlighting(QTextDocument* parent) :
|
|||
multiLineCommentBegin = QRegExp("/\\*");
|
||||
multiLineCommentEnd = QRegExp("\\*/");
|
||||
numberRegex = QRegExp("[0-9]+(\\.[0-9]+){0,1}");
|
||||
singleLineComment = QRegExp("//[^\n]*");
|
||||
truefalseRegex = QRegExp("\\b(true|false)\\b");
|
||||
}
|
||||
|
||||
void ScriptHighlighting::highlightBlock(const QString &text) {
|
||||
this->highlightKeywords(text);
|
||||
this->formatComments(text);
|
||||
this->formatQoutedText(text);
|
||||
this->formatNumbers(text);
|
||||
this->formatTrueFalse(text);
|
||||
this->formatQoutedText(text);
|
||||
this->formatComments(text);
|
||||
}
|
||||
|
||||
void ScriptHighlighting::highlightKeywords(const QString &text) {
|
||||
|
@ -50,6 +54,13 @@ void ScriptHighlighting::formatComments(const QString &text) {
|
|||
start = text.indexOf(multiLineCommentBegin, start + length);
|
||||
if (end == -1) setCurrentBlockState(BlockStateInMultiComment);
|
||||
}
|
||||
|
||||
int index = singleLineComment.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = singleLineComment.matchedLength();
|
||||
setFormat(index, length, Qt::lightGray);
|
||||
index = singleLineComment.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptHighlighting::formatQoutedText(const QString &text){
|
||||
|
@ -69,3 +80,14 @@ void ScriptHighlighting::formatNumbers(const QString &text){
|
|||
index = numberRegex.indexIn(text, index + length);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptHighlighting::formatTrueFalse(const QString text){
|
||||
int index = truefalseRegex.indexIn(text);
|
||||
while (index >= 0) {
|
||||
int length = truefalseRegex.matchedLength();
|
||||
QFont* font = new QFont(this->document()->defaultFont());
|
||||
font->setBold(true);
|
||||
setFormat(index, length, *font);
|
||||
index = truefalseRegex.indexIn(text, index + length);
|
||||
}
|
||||
}
|
|
@ -26,11 +26,12 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString &text);
|
||||
void highlightKeywords(const QString &text);
|
||||
void formatComments(const QString &text);
|
||||
void formatQoutedText(const QString &text);
|
||||
void formatNumbers(const QString &text);
|
||||
void highlightBlock(const QString& text);
|
||||
void highlightKeywords(const QString& text);
|
||||
void formatComments(const QString& text);
|
||||
void formatQoutedText(const QString& text);
|
||||
void formatNumbers(const QString& text);
|
||||
void formatTrueFalse(const QString text);
|
||||
|
||||
private:
|
||||
QRegExp keywordRegex;
|
||||
|
@ -38,6 +39,8 @@ private:
|
|||
QRegExp multiLineCommentBegin;
|
||||
QRegExp multiLineCommentEnd;
|
||||
QRegExp numberRegex;
|
||||
QRegExp singleLineComment;
|
||||
QRegExp truefalseRegex;
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptHighlighting_h
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QFrame>
|
||||
#include <QLayoutItem>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QPalette>
|
||||
#include <QScrollBar>
|
||||
#include <QSizePolicy>
|
||||
|
@ -30,13 +31,126 @@ ScriptEditorWidget::ScriptEditorWidget() :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
scriptEngine = NULL;
|
||||
|
||||
connect(ui->scriptEdit->document(), SIGNAL(modificationChanged(bool)), this, SIGNAL(scriptModified()));
|
||||
connect(ui->scriptEdit->document(), SIGNAL(contentsChanged()), this, SLOT(onScriptModified()));
|
||||
|
||||
// remove the title bar (see the Qt docs on setTitleBarWidget)
|
||||
setTitleBarWidget(new QWidget());
|
||||
QFontMetrics fm(this->ui->scriptEdit->font());
|
||||
this->ui->scriptEdit->setTabStopWidth(fm.width('0') * 4);
|
||||
ScriptHighlighting* highlighting = new ScriptHighlighting(this->ui->scriptEdit->document());
|
||||
QTimer::singleShot(0, this->ui->scriptEdit, SLOT(setFocus()));
|
||||
}
|
||||
|
||||
ScriptEditorWidget::~ScriptEditorWidget() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ScriptEditorWidget::onScriptModified() {
|
||||
if(ui->onTheFlyCheckBox->isChecked() && isRunning()) {
|
||||
setRunning(false);
|
||||
setRunning(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::isModified() {
|
||||
return ui->scriptEdit->document()->isModified();
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::isRunning() {
|
||||
return (scriptEngine != NULL) ? scriptEngine->isRunning() : false;
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::setRunning(bool run) {
|
||||
if (run && !save()) {
|
||||
return false;
|
||||
}
|
||||
// Clean-up old connections.
|
||||
disconnect(this, SLOT(onScriptError(const QString&)));
|
||||
disconnect(this, SLOT(onScriptPrint(const QString&)));
|
||||
|
||||
if (run) {
|
||||
scriptEngine = Application::getInstance()->loadScript(this->currentScript, false);
|
||||
connect(scriptEngine, SIGNAL(runningStateChanged()), this, SIGNAL(runningStateChanged()));
|
||||
|
||||
// Make new connections.
|
||||
connect(scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(onScriptError(const QString&)));
|
||||
connect(scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(onScriptPrint(const QString&)));
|
||||
} else {
|
||||
Application::getInstance()->stopScript(this->currentScript);
|
||||
scriptEngine = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::saveFile(const QString &scriptPath) {
|
||||
QFile file(scriptPath);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, tr("Interface"), tr("Cannot write script %1:\n%2.").arg(scriptPath).arg(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream out(&file);
|
||||
out << ui->scriptEdit->toPlainText();
|
||||
|
||||
setScriptFile(scriptPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptEditorWidget::loadFile(const QString &scriptPath) {
|
||||
QFile file(scriptPath);
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QMessageBox::warning(this, tr("Interface"), tr("Cannot read script %1:\n%2.").arg(scriptPath).arg(file.errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
ui->scriptEdit->setPlainText(in.readAll());
|
||||
|
||||
setScriptFile(scriptPath);
|
||||
|
||||
disconnect(this, SLOT(onScriptError(const QString&)));
|
||||
disconnect(this, SLOT(onScriptPrint(const QString&)));
|
||||
|
||||
scriptEngine = Application::getInstance()->getScriptEngine(scriptPath);
|
||||
if (scriptEngine != NULL) {
|
||||
connect(scriptEngine, SIGNAL(runningStateChanged()), this, SIGNAL(runningStateChanged()));
|
||||
connect(scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(onScriptError(const QString&)));
|
||||
connect(scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(onScriptPrint(const QString&)));
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::save() {
|
||||
return currentScript.isEmpty() ? saveAs() : saveFile(currentScript);
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::saveAs() {
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save script"), QString(), tr("Javascript (*.js)"));
|
||||
return !fileName.isEmpty() ? saveFile(fileName) : false;
|
||||
}
|
||||
|
||||
void ScriptEditorWidget::setScriptFile(const QString& scriptPath) {
|
||||
currentScript = scriptPath;
|
||||
ui->scriptEdit->document()->setModified(false);
|
||||
setWindowModified(false);
|
||||
|
||||
emit scriptnameChanged();
|
||||
}
|
||||
|
||||
bool ScriptEditorWidget::questionSave() {
|
||||
if (ui->scriptEdit->document()->isModified()) {
|
||||
QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Interface"), tr("The script has been modified.\nDo you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
|
||||
return button == QMessageBox::Save ? save() : (button == QMessageBox::Cancel ? false : true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptEditorWidget::onScriptError(const QString& message) {
|
||||
ui->debugText->appendPlainText("ERROR: "+ message);
|
||||
}
|
||||
|
||||
void ScriptEditorWidget::onScriptPrint(const QString& message) {
|
||||
ui->debugText->appendPlainText("> "+message);
|
||||
}
|
|
@ -27,8 +27,30 @@ public:
|
|||
ScriptEditorWidget();
|
||||
~ScriptEditorWidget();
|
||||
|
||||
bool isModified();
|
||||
bool isRunning();
|
||||
bool setRunning(bool run);
|
||||
bool saveFile(const QString& scriptPath);
|
||||
void loadFile(const QString& scriptPath);
|
||||
void setScriptFile(const QString& scriptPath);
|
||||
bool save();
|
||||
bool saveAs();
|
||||
bool questionSave();
|
||||
const QString getScriptName() const { return currentScript; };
|
||||
signals:
|
||||
void runningStateChanged();
|
||||
void scriptnameChanged();
|
||||
void scriptModified();
|
||||
|
||||
private slots:
|
||||
void onScriptError(const QString& message);
|
||||
void onScriptPrint(const QString& message);
|
||||
void onScriptModified();
|
||||
|
||||
private:
|
||||
Ui::ScriptEditorWidget* ui;
|
||||
ScriptEngine* scriptEngine;
|
||||
QString currentScript;
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptEditorWidget_h
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
#include <QFrame>
|
||||
#include <QLayoutItem>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox.h>
|
||||
#include <QPalette>
|
||||
#include <QScrollBar>
|
||||
#include <QShortcut>
|
||||
#include <QSizePolicy>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
@ -31,32 +33,158 @@ ScriptEditorWindow::ScriptEditorWindow() :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
show();
|
||||
addScriptEditorWidget("New script");
|
||||
loadMenu = new QMenu();
|
||||
connect(loadMenu, SIGNAL(aboutToShow()), this, SLOT(loadMenuAboutToShow()));
|
||||
ui->loadButton->setMenu(loadMenu);
|
||||
|
||||
saveMenu = new QMenu();
|
||||
saveMenu->addAction("Save as..", this, SLOT(saveScriptAsClicked()), Qt::CTRL|Qt::SHIFT|Qt::Key_S);
|
||||
|
||||
ui->saveButton->setMenu(saveMenu);
|
||||
|
||||
connect(new QShortcut(QKeySequence("Ctrl+N"), this), SIGNAL(activated()), this, SLOT(newScriptClicked()));
|
||||
connect(new QShortcut(QKeySequence("Ctrl+S"), this), SIGNAL(activated()), this, SLOT(saveScriptClicked()));
|
||||
connect(new QShortcut(QKeySequence("Ctrl+O"), this), SIGNAL(activated()), this, SLOT(loadScriptClicked()));
|
||||
connect(new QShortcut(QKeySequence("F5"), this), SIGNAL(activated()), this, SLOT(toggleRunScriptClicked()));
|
||||
}
|
||||
|
||||
ScriptEditorWindow::~ScriptEditorWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::loadScriptClicked(){
|
||||
|
||||
void ScriptEditorWindow::setRunningState(bool run) {
|
||||
if (ui->tabWidget->currentIndex() != -1) {
|
||||
((ScriptEditorWidget*)ui->tabWidget->currentWidget())->setRunning(run);
|
||||
}
|
||||
this->updateButtons();
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::newScriptClicked(){
|
||||
addScriptEditorWidget(QString("new Script"));
|
||||
void ScriptEditorWindow::updateButtons() {
|
||||
ui->toggleRunButton->setEnabled(ui->tabWidget->currentIndex() != -1);
|
||||
ui->toggleRunButton->setIcon(ui->tabWidget->currentIndex() != -1 && ((ScriptEditorWidget*)ui->tabWidget->currentWidget())->isRunning() ? QIcon("../resources/icons/stop-script.svg"):QIcon("../resources/icons/start-script.svg"));
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::toggleRunScriptClicked(){
|
||||
|
||||
void ScriptEditorWindow::loadScriptMenu(const QString& scriptName) {
|
||||
addScriptEditorWidget("loading...")->loadFile(scriptName);
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::saveScriptClicked(){
|
||||
|
||||
void ScriptEditorWindow::loadScriptClicked() {
|
||||
QString scriptName = QFileDialog::getOpenFileName(this, tr("Interface"), QString(), tr("Javascript (*.js)"));
|
||||
if (!scriptName.isEmpty()) {
|
||||
addScriptEditorWidget("loading...")->loadFile(scriptName);
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::addScriptEditorWidget(QString title){
|
||||
ScriptEditorWidget* newScriptEditorWidget = new ScriptEditorWidget();//ScriptEditorWidget();
|
||||
void ScriptEditorWindow::loadMenuAboutToShow() {
|
||||
loadMenu->clear();
|
||||
QStringList runningScripts = Application::getInstance()->getRunningScripts();
|
||||
if (runningScripts.count() > 0) {
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
foreach (const QString& runningScript, runningScripts) {
|
||||
QAction* runningScriptAction = new QAction(runningScript, loadMenu);
|
||||
connect(runningScriptAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
signalMapper->setMapping(runningScriptAction, runningScript);
|
||||
loadMenu->addAction(runningScriptAction);
|
||||
}
|
||||
connect(signalMapper, SIGNAL(mapped(const QString &)), this, SLOT(loadScriptMenu(const QString &)));
|
||||
} else {
|
||||
QAction* naAction = new QAction("(no running scripts)",loadMenu);
|
||||
naAction->setDisabled(true);
|
||||
loadMenu->addAction(naAction);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::newScriptClicked() {
|
||||
addScriptEditorWidget(QString("New script"));
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::toggleRunScriptClicked() {
|
||||
this->setRunningState(!(ui->tabWidget->currentIndex() !=-1 && ((ScriptEditorWidget*)ui->tabWidget->currentWidget())->isRunning()));
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::saveScriptClicked() {
|
||||
if (ui->tabWidget->currentIndex() != -1) {
|
||||
ScriptEditorWidget* currentScriptWidget = (ScriptEditorWidget*)ui->tabWidget->currentWidget();
|
||||
currentScriptWidget->save();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::saveScriptAsClicked() {
|
||||
if (ui->tabWidget->currentIndex() != -1) {
|
||||
ScriptEditorWidget* currentScriptWidget = (ScriptEditorWidget*)ui->tabWidget->currentWidget();
|
||||
currentScriptWidget->saveAs();
|
||||
}
|
||||
}
|
||||
|
||||
ScriptEditorWidget* ScriptEditorWindow::addScriptEditorWidget(QString title) {
|
||||
ScriptEditorWidget* newScriptEditorWidget = new ScriptEditorWidget();
|
||||
connect(newScriptEditorWidget, SIGNAL(scriptnameChanged()), this, SLOT(updateScriptNameOrStatus()));
|
||||
connect(newScriptEditorWidget, SIGNAL(scriptModified()), this, SLOT(updateScriptNameOrStatus()));
|
||||
connect(newScriptEditorWidget, SIGNAL(runningStateChanged()), this, SLOT(updateButtons()));
|
||||
ui->tabWidget->addTab(newScriptEditorWidget, title);
|
||||
ui->tabWidget->setCurrentWidget(newScriptEditorWidget);
|
||||
newScriptEditorWidget->setUpdatesEnabled(true);
|
||||
newScriptEditorWidget->adjustSize();
|
||||
return newScriptEditorWidget;
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::tabSwitched(int tabIndex) {
|
||||
this->updateButtons();
|
||||
if (ui->tabWidget->currentIndex() != -1) {
|
||||
ScriptEditorWidget* currentScriptWidget = (ScriptEditorWidget*)ui->tabWidget->currentWidget();
|
||||
QString modifiedStar = (currentScriptWidget->isModified()?"*":"");
|
||||
if (currentScriptWidget->getScriptName().length() > 0) {
|
||||
this->setWindowTitle("Script Editor ["+currentScriptWidget->getScriptName()+modifiedStar+"]");
|
||||
} else {
|
||||
this->setWindowTitle("Script Editor [New script"+modifiedStar+"]");
|
||||
}
|
||||
} else {
|
||||
this->setWindowTitle("Script Editor");
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::tabCloseRequested(int tabIndex) {
|
||||
ScriptEditorWidget* closingScriptWidget = (ScriptEditorWidget*)ui->tabWidget->widget(tabIndex);
|
||||
if(closingScriptWidget->questionSave()) {
|
||||
ui->tabWidget->removeTab(tabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::closeEvent(QCloseEvent *event) {
|
||||
bool unsaved_docs_warning = false;
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++ && !unsaved_docs_warning){
|
||||
if(((ScriptEditorWidget*)ui->tabWidget->widget(i))->isModified()){
|
||||
unsaved_docs_warning = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsaved_docs_warning || QMessageBox::warning(this, tr("Interface"), tr("There are some unsaved scripts, are you sure you want to close the editor? Changes will be lost!"), QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Discard) {
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorWindow::updateScriptNameOrStatus() {
|
||||
ScriptEditorWidget* source = (ScriptEditorWidget*)QObject::sender();
|
||||
QString modifiedStar = (source->isModified()?"*":"");
|
||||
if (source->getScriptName().length() > 0) {
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++){
|
||||
if (ui->tabWidget->widget(i) == source) {
|
||||
ui->tabWidget->setTabText(i,modifiedStar+QFileInfo(source->getScriptName()).fileName());
|
||||
ui->tabWidget->setTabToolTip(i, source->getScriptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->tabWidget->currentWidget() == source) {
|
||||
if (source->getScriptName().length() > 0) {
|
||||
this->setWindowTitle("Script Editor ["+source->getScriptName()+modifiedStar+"]");
|
||||
} else {
|
||||
this->setWindowTitle("Script Editor [New script"+modifiedStar+"]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_ScriptEditorWindow_h
|
||||
|
||||
#include <Application.h>
|
||||
#include "ScriptEditorWidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ScriptEditorWindow;
|
||||
|
@ -25,15 +26,29 @@ public:
|
|||
ScriptEditorWindow();
|
||||
~ScriptEditorWindow();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
private:
|
||||
Ui::ScriptEditorWindow* ui;
|
||||
void addScriptEditorWidget(QString title);
|
||||
QMenu* loadMenu;
|
||||
QMenu* saveMenu;
|
||||
ScriptEditorWidget* addScriptEditorWidget(QString title);
|
||||
void setRunningState(bool run);
|
||||
void setScriptName(const QString& scriptName);
|
||||
|
||||
private slots:
|
||||
void loadScriptMenu(const QString& scriptName);
|
||||
void loadScriptClicked();
|
||||
void newScriptClicked();
|
||||
void toggleRunScriptClicked();
|
||||
void saveScriptClicked();
|
||||
void saveScriptAsClicked();
|
||||
void loadMenuAboutToShow();
|
||||
void tabSwitched(int tabIndex);
|
||||
void tabCloseRequested(int tabIndex);
|
||||
void updateScriptNameOrStatus();
|
||||
void updateButtons();
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptEditorWindow_h
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>702</width>
|
||||
<height>543</height>
|
||||
<width>691</width>
|
||||
<height>549</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -18,7 +18,7 @@
|
|||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<width>541</width>
|
||||
<height>238</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -91,6 +91,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="onTheFlyCheckBox">
|
||||
<property name="text">
|
||||
<string>Run on the fly (Careful: Any valid change made to the code will run immediately)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="text">
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>474</width>
|
||||
<height>638</height>
|
||||
<width>706</width>
|
||||
<height>682</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -20,7 +20,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Script editor []</string>
|
||||
<string>Script Editor</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font-family: Helvetica, Arial, sans-serif;</string>
|
||||
|
@ -58,7 +58,7 @@
|
|||
<item>
|
||||
<widget class="QToolButton" name="newButton">
|
||||
<property name="toolTip">
|
||||
<string>New Script</string>
|
||||
<string>New Script (Ctrl+N)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>../resources/icons/new-script.svg</normaloff>
|
||||
<normalon>../resources/images/pinned.svg</normalon>../resources/icons/new-script.svg</iconset>
|
||||
<normalon>../resources/icons/new-script.svg</normalon>../resources/icons/new-script.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -91,7 +91,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Load Script</string>
|
||||
<string>Load Script (Ctrl+O)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
|
@ -119,11 +119,17 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="saveButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
|
@ -132,7 +138,7 @@
|
|||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Script</string>
|
||||
<string>Save Script (Ctrl+S)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
|
@ -150,19 +156,22 @@
|
|||
<property name="autoRepeatDelay">
|
||||
<number>316</number>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toggleRunButton">
|
||||
<property name="toolTip">
|
||||
<string>Toggle Run Script</string>
|
||||
<string>Toggle Run Script (F5)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run/Stop</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>../resources/images/plus.svg</normaloff>../resources/images/plus.svg</iconset>
|
||||
<normaloff>../resources/icons/start-script.svg</normaloff>../resources/icons/start-script.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -286,5 +295,37 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>tabWidget</sender>
|
||||
<signal>currentChanged(int)</signal>
|
||||
<receiver>ScriptEditorWindow</receiver>
|
||||
<slot>tabSwitched(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>352</x>
|
||||
<y>360</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>352</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>tabWidget</sender>
|
||||
<signal>tabCloseRequested(int)</signal>
|
||||
<receiver>ScriptEditorWindow</receiver>
|
||||
<slot>tabCloseRequested(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>352</x>
|
||||
<y>360</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>352</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
@ -43,6 +43,11 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
|
|||
return soundScriptValue;
|
||||
}
|
||||
|
||||
static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
|
||||
qDebug() << "script:print()<<" << context->argument(0).toString();
|
||||
engine->evaluate("Script.print('"+context->argument(0).toString()+"')");
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
||||
|
@ -115,6 +120,7 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL,
|
|||
_scriptContents = in.readAll();
|
||||
} else {
|
||||
qDebug() << "ERROR Loading file:" << fileName;
|
||||
emit errorMessage("ERROR Loading file:" + fileName);
|
||||
}
|
||||
} else {
|
||||
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
|
||||
|
@ -200,6 +206,9 @@ void ScriptEngine::init() {
|
|||
qScriptRegisterSequenceMetaType<QVector<glm::quat> >(&_engine);
|
||||
qScriptRegisterSequenceMetaType<QVector<QString> >(&_engine);
|
||||
|
||||
QScriptValue printConstructorValue = _engine.newFunction(debugPrint);
|
||||
_engine.globalObject().setProperty("print", printConstructorValue);
|
||||
|
||||
QScriptValue soundConstructorValue = _engine.newFunction(soundConstructor);
|
||||
QScriptValue soundMetaObject = _engine.newQMetaObject(&Sound::staticMetaObject, soundConstructorValue);
|
||||
_engine.globalObject().setProperty("Sound", soundMetaObject);
|
||||
|
@ -246,6 +255,7 @@ void ScriptEngine::evaluate() {
|
|||
if (_engine.hasUncaughtException()) {
|
||||
int line = _engine.uncaughtExceptionLineNumber();
|
||||
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
|
||||
emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,11 +276,14 @@ void ScriptEngine::run() {
|
|||
init();
|
||||
}
|
||||
_isRunning = true;
|
||||
emit runningStateChanged();
|
||||
|
||||
QScriptValue result = _engine.evaluate(_scriptContents);
|
||||
if (_engine.hasUncaughtException()) {
|
||||
int line = _engine.uncaughtExceptionLineNumber();
|
||||
|
||||
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
|
||||
emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
|
||||
}
|
||||
|
||||
timeval startTime;
|
||||
|
@ -401,6 +414,7 @@ void ScriptEngine::run() {
|
|||
if (_engine.hasUncaughtException()) {
|
||||
int line = _engine.uncaughtExceptionLineNumber();
|
||||
qDebug() << "Uncaught exception at line" << line << ":" << _engine.uncaughtException().toString();
|
||||
emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + _engine.uncaughtException().toString());
|
||||
}
|
||||
}
|
||||
emit scriptEnding();
|
||||
|
@ -436,10 +450,12 @@ void ScriptEngine::run() {
|
|||
emit finished(_fileNameString);
|
||||
|
||||
_isRunning = false;
|
||||
emit runningStateChanged();
|
||||
}
|
||||
|
||||
void ScriptEngine::stop() {
|
||||
_isFinished = true;
|
||||
emit runningStateChanged();
|
||||
}
|
||||
|
||||
void ScriptEngine::timerFired() {
|
||||
|
@ -510,6 +526,10 @@ QUrl ScriptEngine::resolveInclude(const QString& include) const {
|
|||
return url;
|
||||
}
|
||||
|
||||
void ScriptEngine::print(const QString& message) {
|
||||
emit printedMessage(message);
|
||||
}
|
||||
|
||||
void ScriptEngine::include(const QString& includeFile) {
|
||||
QUrl url = resolveInclude(includeFile);
|
||||
QString includeContents;
|
||||
|
@ -523,6 +543,7 @@ void ScriptEngine::include(const QString& includeFile) {
|
|||
includeContents = in.readAll();
|
||||
} else {
|
||||
qDebug() << "ERROR Loading file:" << fileName;
|
||||
emit errorMessage("ERROR Loading file:" + fileName);
|
||||
}
|
||||
} else {
|
||||
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
|
||||
|
@ -538,5 +559,6 @@ void ScriptEngine::include(const QString& includeFile) {
|
|||
if (_engine.hasUncaughtException()) {
|
||||
int line = _engine.uncaughtExceptionLineNumber();
|
||||
qDebug() << "Uncaught exception at (" << includeFile << ") line" << line << ":" << result.toString();
|
||||
emit errorMessage("Uncaught exception at (" + includeFile + ") line" + QString::number(line) + ":" + result.toString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,6 +80,9 @@ public:
|
|||
|
||||
bool hasScript() const { return !_scriptContents.isEmpty(); }
|
||||
|
||||
bool isFinished() const { return _isFinished; }
|
||||
bool isRunning() const { return _isRunning; }
|
||||
|
||||
public slots:
|
||||
void stop();
|
||||
|
||||
|
@ -88,12 +91,16 @@ public slots:
|
|||
void clearInterval(QObject* timer) { stopTimer(reinterpret_cast<QTimer*>(timer)); }
|
||||
void clearTimeout(QObject* timer) { stopTimer(reinterpret_cast<QTimer*>(timer)); }
|
||||
void include(const QString& includeFile);
|
||||
void print(const QString& message);
|
||||
|
||||
signals:
|
||||
void update(float deltaTime);
|
||||
void scriptEnding();
|
||||
void finished(const QString& fileNameString);
|
||||
void cleanupMenuItem(const QString& menuItemString);
|
||||
void printedMessage(const QString& message);
|
||||
void errorMessage(const QString& message);
|
||||
void runningStateChanged();
|
||||
|
||||
protected:
|
||||
QString _scriptContents;
|
||||
|
|
Loading…
Reference in a new issue