Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
  Signup for free on our forum and benefit from new features!

FFDS Home | TIPS Section | Tutorials Section | Resources Section | Utilities Section

Military | FSDS | Jetliners | Real Planes Section | Gmax | Rotorcraft | Business | Civilian

  HomeHelpSearchLoginRegister  
 
 
Page Index Toggle Pages: 1
Send Topic Print
Diagonal mouse areas (Read 1401 times)
8th Aug, 2011 at 12:59pm

Luka   Offline
Polygon Twister

Posts: 92
**
 
For mouse rectangles, instead of vertical and horizontal boundaries, sometimes it would be more convenient to divide areas by their diagonals. One example is the trim switch on the top of the control stick.

Step 1 - is to define the coordinates of the mouse areas.
In this example it is 70 pixels square. To determine the position of the cursor, the most important value is the half of the square width/height (35 in this example).

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register

Current cursor position can be calculated using this simple script; value 35 is used for 70 pix. rectangle from this example:

Code:
(M:X) 35 - d (M:Y) 35 - > r /-/ (M:Y) 35 - > 2 * + ++ (>G:Var1) 



For certain cursor positions, the value of the G:Var1 variable will be:
Cursor pos. G:Var1
S 1
E 2
W 3
N 4


Step 2 - actual gauge code.
G:Var2 animates trim switch. If the mouse is clicked, it is the same as G:Var1, otherwise it is zero.

Code:
<Gauge Name="Stick" Version="1.0">
<Copyright>(c)2011 SMS team</Copyright>
<Size X="165" Y="204"/>
<Image Name="stick_bg.bmp"/>
<Element>
	<Position X="10" Y="73"/>
	<Image Name="stick_trim.bmp"/>
	<Shift><Value>0 -1 1 0 0 5 (G:Var2) case</Value><Scale X="7"/></Shift>
	<Shift><Value>-1 0 0 1 0 5 (G:Var2) case</Value><Scale Y="7"/></Shift>
</Element>
<Mouse>
<Area Left="10" Top="72" Width="70" Height="70">
	<Cursor Type="Hand"/>
	<Tooltip>%('N (4)' 'W (3)' 'E (2)' 'S (1)' ' (0)' 5 (G:Var1) case)%!s!</Tooltip>
	<Click Kind="LeftSingle+Move+Leave">
		(M:X) 35 - d (M:Y) 35 - > r /-/ (M:Y) 35 - > 2 * + ++ (>G:Var1)
		(M:Event) 'Leave' scmp 0 == if{ 0 (>G:Var1) 0 (>G:Var2) }
		(M:Event) 'LeftSingle' scmp 0 == if{ (G:Var1) (>G:Var2) }
		c
	</Click>
</Area>
</Mouse>
</Gauge> 



Step 3 - adding a some code for trim-control, and a useful tooltip.

Code:
<Click Kind="LeftSingle+Move+Leave">
	(M:X) 35 - d (M:Y) 35 - > r /-/ (M:Y) 35 - > 2 * + ++ (>G:Var1)
	(M:Event) 'Leave' scmp 0 == if{ 0 (>G:Var1) 0 (>G:Var2) }
	(M:Event) 'LeftSingle' scmp 0 == if{
		(G:Var1) (>G:Var2)
		(G:Var1) 0 > if{
			2 3 (G:Var1) rng
			if{ (G:Var1) 2 > if{ 0 (>K:AILERON_TRIM_LEFT) } els{ 0 (>K:AILERON_TRIM_RIGHT) } }
			els{ (G:Var1) 2 > if{ 0 (>K:ELEV_TRIM_DN) } els{ 0 (>K:ELEV_TRIM_UP) } }
		}
	}
	c
</Click> 


Code:
<Tooltip>%((G:Var1) 0 >)%{if}%(2 3 (G:Var1) rng)%{if}Aileron Trim %((A:AILERON TRIM, degrees) s0 'LEFT' s1 'RIGHT' s2 'right' s3 'left' s4)%{else}Elevator Trim %((A:ELEVATOR TRIM POSITION, degrees) s0 'DOWN' s1 'UP' s2 'up' s3 'down' s4)%{end}%(l1 l2 (G:Var1) 2 > ?)%!s! (%(l0 abs 0.05 >)%{if}%(l0 abs)%!0.2f! %(l3 l4 l0 0 > ?)%!s!%{else}neutral%{end})%{end}</Tooltip> 



Bitmaps used for this example:

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register


Smiley L.
 
IP Logged
 
Reply #1 - 27th Oct, 2011 at 1:49pm

lionheart   Offline
Inspecteur des Polygonnes
Phoenix Arizona

Gender: male
Posts: 5782
*****
 
You are amazing man!  Great find.  Many thanks for posting this tip Luka.




Bill
 

Multimedia File Viewing and Clickable Links are available for Registered Members only!!  You need to Login or Register
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print