Results 1 to 6 of 6

Thread: Quickmenu without .menu :D

  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts

    Quickmenu without .menu :D

    Hey all,

    I've had a nice idea and maybe somebody wants to do it:

    pseudocode:



    PHP Code:
    while (isDefined(player))
    {
        if (
    player useButtonPressed())
        {
            
    createAllQuickMenuHuds();
            
    mouse getMousePositionFromPlayerAngles();
            
    drawMousePointer(mouse["x"], mouse["y"]);
            
    item findSelectedItem(mouse);
            
    doSomethingWithItem(item);
        } else {
            
    deleteAllQuickMenuHuds();
        }


    The idea is, that if the player is pressing USE, an overlay will appear. To "fake" a mouse-pointer, the player-angles are used. Which item is used, depends on where to release the mouse-pointer on.

    That would work with every weapon, though it could be restricted to a "tool gun".

    I would like such a system to buy Turrets e.g. in the BaseTDM.

    If something is unclear, just ask
    timescale 0.01

  2. The Following 2 Users Say Thank You to kung foo man For This Useful Post:

    EvoloZz (6th April 2013),Jeplaa (5th April 2013)

  3. #2
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts
    Sounds really nice.
    Menu like in Garry's Mod, popping-up while holding key ?

    Good luck with that.

  4. The Following User Says Thank You to Jeplaa For This Useful Post:

    kung foo man (5th April 2013)

  5. #3
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Yea, like gmod, but maybe a bit more dynamic (because of hud limit)

    A tree-like structure, with options in options etc.


    Its just an idea, maybe somebody wants to do it.
    timescale 0.01

  6. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    here, possible findSelectedItem(mouse, items) //added items as it is useful to have a list of items to check against...
    PHP Code:
    findSelectedItem(mouseitems)
    {
        for(
    0items.sizei++)
        {
            if(
    mouse["x"] > items[i]["x"] && mouse["x"] <= items[i]["x"] + items[i]["xsize"])
            {
                if(
    mouse["y"] > items[i]["y"] && mouse["y"] <= items[i]["y"] + items[i]["ysize"])
                {
                    return 
    items[i];
                }
            }
        }
        return 
    undefined;


  7. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (5th April 2013)

  8. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    lol its indeed funny
    i doubt on using huds on my first thougth, but huds arent static like menu.vars!

    you can have alot fun with them, i did a short test, and it works
    nothing big, only to test, how the menu reacts to the mouse...
    i added a treshold, maybe 10 is still too big
    also there is nothing dynamic in it, there are just 4 menus
    maybe, when you choose the menu, on one side the submenu will appear, on the other side a back-menu will appear
    feel free to do it better xD
    but good idea kung!

    >>>WATCH ME<<<

    Code:
    init()
    {
    	level.quickmenu[0] = &"^1Menu 1";	precacheString( level.quickmenu[0] );
    	level.quickmenu[1] = &"^2Menu 2";	precacheString( level.quickmenu[1] );
    	level.quickmenu[2] = &"^3Menu 3";	precacheString( level.quickmenu[2] );
    	level.quickmenu[3] = &"^4Menu 4";	precacheString( level.quickmenu[3] );
    
    	precacheShader( "white" );
    
    	level thread onPlayerConnecting();
    }
    
    onPlayerConnecting()
    {
    	while( true )
    	{
    		level waittill( "connected" , player );
    
    		player thread onPlayerSpawned();
    	}
    }
    
    onPlayerSpawned()
    {
    	self endon( "disconnect" );
    
    	while( true )
    	{
    		self waittill( "spawned_player" );
    
    		self thread quickMenu();
    	}
    }
    
    quickMenu()
    {
    	self endon( "disconnect" );
    	self endon( "killed_player" );
    
    	if( isSubStr( self.name , "bot" ) )
    		return;
    
    	self thread cleanUp();
    
    	menuCount = 4;
    	radius = 100;
    	treshold = 10;
    
    	while( true )
    	{
    		while( !self useButtonPressed() )
    		{
    			wait( 0.5 );
    		}
    
    		oa = self getPlayerAngles();
    		na = oa;
    
    		self.active_menu = 0;
    
    		while( self useButtonPressed() )
    		{
    			if( !isDefined( self.quickhud_string ) )
    			{
    				self.quickhud_string = [];
    				self.quickhud_shader = [];
    
    				for( i = 0 ; i < menuCount ; i++ )
    				{
    					/*
    						Menu2
    					    /		\
    					   / 		 \
    					Menu1		Menu3
    					   \ 		 /
    					    \		/
    						Menu0
    					*/
    
    					deg = 360 / menuCount * i;
    					x = sin( deg ) * radius;
    					y = cos( deg ) * radius;
    
    					self.quickhud_string[i] = newMenuStringHud( self , x , y , i );
    					self.quickhud_shader[i] = newMenuShaderHud( self , x , y );
    				}
    
    				self setActiveMenu( 0 );
    			}
    
    			na = self getPlayerAngles();
    			
    			if( na != oa )
    			{
    				hDiff = angleDiff( na[1] , oa[1] );
    				vDiff = angleDiff( na[0] , oa[0] );
    
    				if( hDiff > treshold )
    				{
    				//	self iPrintLn( "hDiff = " + hDiff + " side = right" );
    					self setActiveMenu( 1 );
    				}
    				else if( hDiff < 0 - treshold )
    				{
    				//	self iPrintLn( "hDiff = " + hDiff + " side = left" );
    					self setActiveMenu( 3 );
    				}
    				else
    				{
    				//	iPrintLn( "hDiff = " + hDiff );
    				}
    
    				if( vDiff > treshold )
    				{
    				//	self iPrintLn( "vDiff = " + vDiff + " side = up" );
    					self setActiveMenu( 2 );
    				}
    				else if( vDiff < 0 - treshold )
    				{
    				//	self iPrintLn( "vDiff = " + vDiff + " side = down" );
    					self setActiveMenu( 0 );
    				}
    				else
    				{
    				//	iPrintLn( "vDiff = " + vDiff );
    				}
    			}
    
    			oa = na;
    
    			wait( 0.5 );
    		}
    
    		if( isDefined( self.quickhud_string ) )
    		{
    			for( i = 0 ; i < self.quickhud_string.size ; i++ )
    			{
    				self.quickhud_string[i] destroy();
    				self.quickhud_shader[i] destroy();
    			}
    
    			self.quickhud_string = undefined;
    			self.quickhud_shader = undefined;
    		}			
    	}
    }
    
    setActiveMenu( menuID )
    {
    	ID = self.active_menu;
    
    	self.quickhud_string[ID].color = ( 1 , 1 , 1 );
    	self.quickhud_string[ID].fontscale = 1.0;
    
    	self.quickhud_shader[ID].color = ( 1 , 1 , 1 );
    	self.quickhud_shader[ID].alpha = 0.2;
    
    	self.active_menu = menuID;
    
    	self.quickhud_string[menuID].color = ( 0 , 0 , 1 );
    	self.quickhud_string[menuID].fontscale = 1.5;
    
    	self.quickhud_shader[menuID].color = ( 0 , 0 , 1 );
    	self.quickhud_shader[menuID].alpha = 0.5;
    }
    
    newMenuStringHud( player , x , y , menuID )
    {
    	hud = newClientHudElem( player );
    	hud.x = x;
    	hud.y = y;
    	hud.horzAlign = "center";
    	hud.vertAlign = "middle";
    	hud.alignX = "center";
    	hud.alignY = "middle";
    	hud setText( level.quickmenu[menuID] );
    
    	return hud;
    }
    
    newMenuShaderHud( player , x , y )
    {
    	w = 50;
    	h = 20;
    
    	hud = newClientHudElem( player );
    	hud.x = x - ( w * 0.5 );
    	hud.y = y - ( h * 0.5 );
    	hud.horzAlign = "center";
    	hud.vertAlign = "middle";
    	hud.alpha = 0.2;
    	hud setShader( "white" , w , h );
    
    	return hud;
    }
    
    cleanUp()
    {
    	self waittill( "killed_player" );
    
    	if( isDefined( self.quickhud_string ) )
    	{
    		for( i = 0 ; i < self.quickhud_string.size ; i++ )
    		{
    			self.quickhud_string[i] destroy();
    			self.quickhud_shader[i] destroy();
    		}
    
    		self.quickhud_string = undefined;
    		self.quickhud_shader = undefined;
    	}
    }
    
    angleDiff( firstAngle , secondAngle )
    {
    /*
    	diff = int( secondAngle - firstAngle );
    	while( diff < -180 )	diff += 360;
    	while( diff > 180 )	diff -= 360;
    */
    	diff = secondAngle - firstAngle;
    
    	if( diff > 180 || diff <= -180 )
    	{
    		diff = ( 360 / 2048 ) * ( int( diff * 2048 / 360 ) & 2047 );
    
    		if( diff >= 180 )
    			diff -= 360;
    	}
    
    	return diff;
    }

  9. The Following 2 Users Say Thank You to serthy For This Useful Post:

    Jeplaa (6th April 2013),kung foo man (6th April 2013)

  10. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Nice PoC (Proof of Concept)
    timescale 0.01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •