Is it possible to use only one line instead of 5 (in my case 24)? If yes, how?
Do this in one line? Sure!
|
Source code
|
1
|
<plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />
|
Just kidding...
Here's how you would do it with variables and actions:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<krpano version="1.0.9" onstart="make_thumbs(thumb2_blah,skin/thumbs/blah,5);" >
<!--make_thumbs name_prefix.str url_prefix.str number.i-->
<action name="make_thumbs">
if (%3 GT 0,
addplugin(%1%3);
set(plugin[%1%3].url,%2%3);
set(plugin[%1%3].keep,true);
set(plugin[%1%3].x,5);
set(plugin[%1%3].y,5);
set(plugin[%1%3].visible,false);
sub(action[%0].tmp,%3,1);
make_thumbs(%1,%2,get(action[%0].tmp));
);
</action>
</krpano>
|
The action make_plugins takes 3 arguments. The name prefix, the url prefix, and the number of plugins to create. The syntax to call it is:
|
Source code
|
1
|
make_plugins(thumb2_blah,skin/thumbs/blah,5);
|
This recursively makes the thumbs thumb2_blah5, thumb2_blah4, thumb2_blah3, thumb2_blah2, thumb2_blah1. I'm assuming that it is okay for the first thumb to be named thumb2_blah
1 rather than thumb2_blah as you showed in your post. If you truly need it to be thumb2_blah (without the 1) simply add an if statement.
Here's a more complex version that uses an array to store the titles for the showtext, and sets the onhover, onout, and onclick values:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<krpano version="1.0.9" onstart="make_thumbs(thumb2_blah,skin/thumbs/blah,5);" >
<title name="title for zeroth pano __ never used because we start with one" />
<title name="title for first pano" />
<title name="title for second pano" />
<title name="title for third pano" />
<title name="title for fourth pano" />
<title name="title for fifth pano" />
<action name="make_thumbs">
if (%3 GT 0,
addplugin(%1%3);
set(plugin[%1%3].url,%2%3);
set(plugin[%1%3].keep,true);
set(plugin[%1%3].align,leftbottom);
set(plugin[%1%3].x,5);
mul(action[%0].tmp,%3,28);
set(plugin[%1%3].y,get(action[%0].tmp));
set(plugin[%1%3].alpha,0.2);
txtadd(action[%0].tmp,"showtext(",get(title[%3].name),");set(plugin[%1%3].alpha,1);");
set(plugin[%1%3].onhover,get(action[%0].tmp));
set(plugin[%1%3].onout,set(plugin[%1%3].alpha,0.2););
set(plugin[%1%3].onclick,loadpano(blah%3.xml););
sub(action[%0].tmp,%3,1);
make_thumbs(%1,%2,get(action[%0].tmp));
);
</action>
</krpano>
|
Hope this helps
steve