r3005 - in trunk/data/qcsrc/menu: . custom

black at icculus.org black at icculus.org
Thu Dec 6 12:22:52 EST 2007


Author: black
Date: 2007-12-06 12:22:52 -0500 (Thu, 06 Dec 2007)
New Revision: 3005

Added:
   trunk/data/qcsrc/menu/custom/gecko.qm
Modified:
   trunk/data/qcsrc/menu/mbuiltin.qc
   trunk/data/qcsrc/menu/msys.qc
   trunk/data/qcsrc/menu/progs.src
Log:
Add a gecko control to the scmenu, too.

Added: trunk/data/qcsrc/menu/custom/gecko.qm
===================================================================
--- trunk/data/qcsrc/menu/custom/gecko.qm	                        (rev 0)
+++ trunk/data/qcsrc/menu/custom/gecko.qm	2007-12-06 17:22:52 UTC (rev 3005)
@@ -0,0 +1,55 @@
+// Andreas Kirsch 2007
+// Im putting it into custom because its not really engineered but simply hacked together
+.string targetURL;
+
+var float _gecko_instanceNumber;
+
+void() Item_Gecko_Draw = {
+	Menu_DrawPicture( self.pos, self.picture, self.size, self.color, self.alpha, self.drawFlag );
+};
+
+void() Item_Gecko_Destroy =
+{
+	if( self.picture ) {
+		gecko_destroy( self.picture );
+	}
+
+	String_EntityFree( self, picture );
+};
+
+void() Item_Gecko_Update = {
+	// "normalize" the mouse position
+	local vector lNormalizedPosition;
+	lNormalizedPosition_x = (Menu_Cursor_Position_x - self.pos_x) / self.size_x;
+	lNormalizedPosition_y = (Menu_Cursor_Position_y - self.pos_y) / self.size_y;
+	lNormalizedPosition_z = 0.0;
+
+	print( vtos( Menu_Cursor_Position ), " ", vtos( lNormalizedPosition ), "\n" );
+
+	if( Util_InRect( lNormalizedPosition, '0 0 0', '1 1 0' ) ) {
+		gecko_mousemove( self.picture, lNormalizedPosition_x, lNormalizedPosition_y );
+	}
+};
+
+bool( float pKey, float pAscii ) Item_Gecko_Key = {
+	if( pKey == K_ESCAPE ) {
+		return false;
+	}
+	return gecko_keyevent( self.picture, pKey, GECKO_BUTTON_PRESS );
+};
+
+void() Item_Gecko_Spawn = {
+	// targetURL wont be changed anyway...
+	self.picture = String_Zone( strcat( "_dynamic/gecko/menu/", ftos( _gecko_instanceNumber ) ) );
+	_gecko_instanceNumber += 1;
+
+	gecko_create( self.picture );
+	gecko_navigate( self.picture, self.targetURL );
+
+	self._destroy = Item_Gecko_Destroy;
+	self._key = Item_Gecko_Key;
+	self._draw = Item_Gecko_Draw;
+	self._update = Item_Gecko_Update;
+};
+
+

Modified: trunk/data/qcsrc/menu/mbuiltin.qc
===================================================================
--- trunk/data/qcsrc/menu/mbuiltin.qc	2007-12-06 14:25:02 UTC (rev 3004)
+++ trunk/data/qcsrc/menu/mbuiltin.qc	2007-12-06 17:22:52 UTC (rev 3005)
@@ -240,6 +240,13 @@
 void	addwantedhostcachekey(string key) = #623;
 string	getextresponse(void) = #624;
 
+// AK the builtin numbers may change - the code might be removed again
+float gecko_create( string name ) = #487;
+void gecko_destroy( string name ) = #488;
+void gecko_navigate( string name, string URI ) = #489;
+float gecko_keyevent( string name, float key, float eventtype ) = #490;
+void gecko_mousemove( string name, float x, float y ) = #491;
+
 #ifdef FIXEDFOPEN
 float 	fopen( string filename, float mode ) =
 {

Modified: trunk/data/qcsrc/menu/msys.qc
===================================================================
--- trunk/data/qcsrc/menu/msys.qc	2007-12-06 14:25:02 UTC (rev 3004)
+++ trunk/data/qcsrc/menu/msys.qc	2007-12-06 17:22:52 UTC (rev 3005)
@@ -275,6 +275,13 @@
 //float ERR_BADSIZE			= ERR_BADSCALE;
 float ERR_NOTCACHED			= -4;
 
+float GECKO_BUTTON_DOWN 		= 0;
+float GECKO_BUTTON_UP 			= 1;
+// either use down and up or just press but not all of them!
+float GECKO_BUTTON_PRESS 		= 2;
+// use this for mouse events if needed?
+float GECKO_BUTTON_DOUBLECLICK 	= 3;
+
 /* not supported at the moment
 ///////////////////////////
 // os constants

Modified: trunk/data/qcsrc/menu/progs.src
===================================================================
--- trunk/data/qcsrc/menu/progs.src	2007-12-06 14:25:02 UTC (rev 3004)
+++ trunk/data/qcsrc/menu/progs.src	2007-12-06 17:22:52 UTC (rev 3005)
@@ -91,6 +91,8 @@
 custom/joingame.qm
 custom/credits.qm
 
+custom/gecko.qm
+
 custom/player/avatar.qc
 custom/player/color.qc
 




More information about the nexuiz-commits mailing list