[Legacy] Toggle buttons: my way 2

Post Reply
User avatar
Dave
Site Admin
Posts: 82
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

[Legacy] Toggle buttons: my way 2

Post by Dave » Sun Dec 20, 2015 9:43 pm

Original post by: A Petrovic

Hi again.
Let's see how I managed to resolve the second case: one single button for a single action, but two images needed.
Same example: the landing gear lever image doesn't show the real position in the game.
1 Create two images of the lever, one in the up position ( "Lever_up.png") and another in the down position( "Lever_down.png"). Add those button images to the applicarion. (I made a buttons pack called " DCSbuttons" ).
2 Again, create a Label called "Lever" (or whatever you want).Place it in the layout and bind it to an image of the lever in the down position ("Lever_down.png"). Right click on it and hit "layout" and "send to back".
3 Create a hotkey button. Do not check the "feedback option" . Let's call it " Gear_lever". Assign the correspondant keystroke ( the "g" key). Check the "post-script" box an write the following (or copy paste):


if (_local.dcs == undefined) {
_local.dcs = 1;
}
if (_local.dcs == 1) {
_local.dcs = 2;
return 'Lever^[@]DCSbuttons/Lever_up.png';
} else
if (_local.dcs == 2) {
_local.dcs = 1;
return 'Lever^[@]DCSbuttons/Lever_down.png';
} else {
return 'Lever^no';
}
The "_local.dcs is a local variable that can have the name you wish and the " 'Lever^[@]DCSbuttons/Lever_down.png' " expression should match your actual buttonpack name and button's image name.
(I got that code from somwhere in this forum and adapted it to my needs. I will try to write down a link to this thread so you can get the most of it and thank/idolatrate the real guy who made it). the link: http://www.touchapptech.com/apps/forums ... dynamicly-
4 Place the hotkey button in the layout as a "hotspot", wherever you want. Right click on it and hit "layout" and "bring to front". Drag and drop this button OVER the Label named "Lever".
Done! Now, when you hit the image of the lever, the image will turn into the other position image and the keystroke will be sent to the PC and do it's job.
As in my other post, there will be some synchronisation problems again, but same solution.
If you are flying a multiplayer session and pause is not an option, you can always slow down to a safe speed an hit the keyboard key and inmediately hit the hotspot in the Ipad to raise the gear and the think should now be OK.

Post Reply