Sign in to follow this  
Guest ridgell

thottle gauge; need help with mouse drag please

Recommended Posts

Could someone please help me with an XML throttle? The more I mess with it the more ridiculous my results!I need to move a bitmap (1) size 111x 63 through the

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

here is an example of what does not work ! i did not use registers and G:Vars so i could see this drag/shift process better, and to plug L:Vars into a test gauge to see the results of each action. the problem is that the mouse area is fixed on the background image.the cursor is only "hot" over the smaller image that is being shifted. when you slide the smaller bitmap below the mid point, you are stuck on that side. either at the top1/2 or the bottom1/2i need to use the smaller shifted bitmap as the mouse target area.if i delete the background image the gauge dies....and i do ot know how to specify the handle image as the target ( mouse drag on top 1/2 of handle image the thing drags up, bottom1/2 drags down.) (L:K2,enum) 2 == if{ (L:handle_t,enum) ++ (>L:handle_t,enum) 1 } (L:handle_t,enum) 100 > if{ 100 (>L:handle_t,enum) } (L:K2,enum) 1 == if{ (L:handle_t,enum) -- (>L:handle_t,enum) 1 } (L:handle_t,enum) 0 < if{ 0 (>L:handle_t,enum) } (L:handle_t, enum) (M:Event) 'Leave' scmp 0 == if{ 0 (>L:dragger, enum) 0 (>L:K2,enum) } (M:Event) 'LeftDrag' scmp 0 == if{ (M:Y) (>L:dragger, enum) (L:dragger, enum) 0 > (L:dragger, enum) 90 < && if{ 1 (>L:K2,enum) } (L:dragger, enum) 91 > (L:dragger, enum) 180 < && if{ 2 (>L:K2,enum) } i do not care about the actual (>K:THROTTLE1_SET) part of the gauge at this point...piece of cake one the animation works.

Share this post


Link to post
Share on other sites

Ridgell,I've done something similar with my throttles, and even the code is rather complex, I'll try to explain the way it works.To start, you have a background bmp for the throttle range, say 117 pixels high (forget wide for the moment). And you have a lever bitmap that is 32 pixels high.The goal is to let the levers move only when dragged from a range that lies between the height of the lever bitmap.Now, to start a drag you will have a click event first, that you need to detect whether it is within the lever bmp range or not.An example for the left throttle:@Eng1T is "(L:Eng1 Throttle Lever Position,percent)"@Eng1TC is "(L:Left Throttle Center, number)"@BothThrtRange is "@Eng1TC s0 @Eng2TC - s1 abs s2 32 <= (M:Y) l0 - abs 16 <= (M:Y) l1 - abs 16 <= or and", which test that the click is in the lever's range. Note that I left here the right lever part to show that using this method you can move both levers together even if they are splitted!.then,..etc (M:Event) 'LeftSingle' scmp 0 == if{ @BothThrtRange (>L:Eng Throttle enabled,bool) (M:Y) (>L:Eng Throttle Count,number) }...(M:Event) 'LeftDrag' scmp 0 == if{ (M:Y) (L:Eng Throttle Count, number) - sp0 (L:Eng Throttle enabled) if{ @Eng1TC l0 + 117 min 17 max s1 (>L:Left Throttle Center, number) 117 l1 - 0 max 100 min d 163.84 * (>K:THROTTLE1_SET) (>L:Eng1 Throttle Lever Position,percent) } }In the section, register the current Throttle center position : 117 @Eng1T 0 max - int (>L:Left Throttle Center, number)etc...My code is a bit more complex because I also control each lever individually using right drag, and manage the reverse thrust within the same strucuture.Hope this helpsTom

Share this post


Link to post
Share on other sites

since TOM lite the way, why make things easy?OK here is what does work....it is only concerned with the animation of the mouse drag....but that is what was kicking my behind! no more,not sure it was a secret to anyone but me, but the way to drag is by checking the direction of the drag, not by divideing the area into sections and waiting for the mouse to cross some boundry line. that works for small movements, but with a large field the mouse cursor gets very removed from the object being moved, and causes the drag to move in the wrong direction at the edges of its range, mouse in the top part makes the drag go up, when you have the mouse up there to drag it down...and vice versa. this exampe can be made more effecient with registers and G:Vars, but here was my humble solution. the scale=5 moves the object of the drag at a speed equal to the mouse speed, setting the drag2 var to 73 at the end was just to give it a middle of the area start range,( that would be dependent up the area size. the gauge cycles fast enough that there is no hoping upon initialization. (L:K2,enum) 2 == if{ (L:handle_t,enum) ++ (>L:handle_t,enum) 1 } (L:handle_t,enum) 30 > if{ 30 (>L:handle_t,enum) } (L:K2,enum) 1 == if{ (L:handle_t,enum) -- (>L:handle_t,enum) 1 } (L:handle_t,enum) 0 < if{ 0 (>L:handle_t,enum) } (L:handle_t, enum) (M:Event) 'Leave' scmp 0 == if{ 73 (>L:drag2, enum) 0 (>L:K2,enum) } (M:Event) 'LeftDrag' scmp 0 == if{ (M:Y) (>L:drag1, enum) (L:drag1,enum) (L:drag2,enum) > if{ 2 (>L:K2,enum) (L:drag1,enum) (>L:drag2,enum) } (L:drag1,enum) (L:drag2,enum) < if{ 1 (>L:K2,enum) (L:drag1,enum) (>L:drag2,enum) } the mouse stays right on top of the drag object through out its rangenow to do the throttle set you use the L:handle_t (1-30 in my example) transposed to 0 - 16384, the -16384 setting will just be a /-/ function when the buckets are deployed.you could use this for double throttles as well by adding dividing the X areas into 3 parts left / both / right with the mouse over both it drags both. even a blind Squirrel finds the occasional nut~!

Share this post


Link to post
Share on other sites

oops! couple of amendments, to keep the mouse from continuing to move when the mouse cursor is being held stationary, but the left button is still depressd; basically reset the L:K2 var to zero each pass (L:K2,enum) 2 == if{ 0 (>L:K2,enum) (L:handle_t,enum) ++ (>L:handle_t,enum) 1 } (L:handle_t,enum) 30 > if{ 30 (>L:handle_t,enum) } in the mouse area;(L:drag1,enum) (L:drag2,enum) == if{ 0 (>L:K2,enum) }

Share this post


Link to post
Share on other sites

Ridgell,I know that you must have thought of this, anyway I remember you that the levers move not only by user drag but also by keyboard/joystick input, hence the actual coordinates of the lever bitmap must be taken into account at any time :-)Saludos!Tom

Share this post


Link to post
Share on other sites

yes, i am sorting through that now, that and finding out why this plane, goes to 50% with 0 (>K:AXIS_THROTTLE1_SET) not aware of something like that built into FS, so am sorting thru the air file and config.so far the only way i can update my throttle to key or joystick is to put the update out side of my throttle gauge. i did not think of that until i tried to do it. in my example i generated a lot of L:Vars to accertain the throttle position. but you are right, steps and math can be saved by a cleaverly sized area.oh and the 50% is AXIS_THROTTLE1_SET vs THROTTLE1_SET, i was useing the AXIS... becuase the SDK said the range was (-16383 - +16383) vs (0 - 16383) for THROTTLE1_SET, so i might have to use both...have not gotten to the reverser part yet.

Share this post


Link to post
Share on other sites

cleaned it up some, and it follows inputs from mouse KB or joystick, the G:Vars will end up as registers (most) what is the best way to set the throttle when useing reversers ?(A:Sim On Ground, bool) (L:reverse, bool) &&some math trick added in the mouse click? or do i take the (>K:THROTTLE1_SET,number) outside of the mouse click and work on it as a seperate element? since you have done this ( forward throttle for both positive and negative ) i would love to get your insight, or heck you can just come out and tell me how! (A:general eng1 throttle lever position,part) (A:Throttle lower limit,part) /-/ + b 1 + / (M:Event) 'Leave' scmp 0 == if{ (G:Var1) (>G:Var2) } (M:Event) 'LeftDrag' scmp 0 == if{ (M:Y) (>G:Var1) (G:Var1) (G:Var2) > (L:handle_t,enum) 30 < && if{ (L:handle_t,enum) ++ (>L:handle_t,enum) 1 (L:handle_t,enum) 30 - /-/ 546 * (>K:THROTTLE1_SET,number) } (G:Var1) (G:Var2) < (L:handle_t,enum) 0 > && if{ (L:handle_t,enum) -- (>L:handle_t,enum) 1 (L:handle_t,enum) 30 - /-/ 546 * (>K:THROTTLE1_SET,number) } (G:Var1) (>G:Var2)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this