fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
29736a3
GUI
1local memory =require ( "memory.watcher" ) 2 3function PANEL : Initialize () 4self : super () 5 6self . m_pCircle =graphics . newImage ( "textures/circle.png" ) 7 8self . m_fFadeTime =0.5 9self . m_fFadeEnd =0 10 11self : SetSize ( 192 , 256 ) 12end 13 14function PANEL : GetEntityUpdateTime ( entity ) 15return self . m_tLastUpdate [ entity ] or 0 16end 17 18function PANEL : GetPlayer () 19return memory . player [ self : GetPort ()] 20end 21 22function PANEL : Paint ( w , h ) 23local t =timer . getTime () 24 25for i =1 , 4 do 26local player =melee . getPlayer ( i ) 27if ( melee . isEntityActive ( player . entity ) and not melee . isEntityRespawning ( player . entity ) and melee . isEntityOffCamera ( player . entity )) 28or ( melee . isEntityActive ( player . partner ) and not melee . isEntityRespawning ( player . partner ) and melee . isEntityOffCamera ( player . partner )) then 29self . m_fFadeEnd =t + self . m_fFadeTime 30end 31end 32 33if self . m_fFadeEnd < t then return end 34 35local fade =math . max ( 0 , self . m_fFadeEnd - t ) / self . m_fFadeTime 36 37local minimapPosx =w 38local minimapPosY =0 39 40local zone =memory . stage . blastzone 41local stageW =zone . right - zone . left 42local stageH =zone . top - zone . bottom 43 44local camera =memory . camera . limit 45local offset =memory . stage . offset 46 47local cameraW =camera . right - camera . left 48local cameraH =camera . top - camera . bottom 49 50local minimapW =w 51local minimapH =minimapW * ( stageH / stageW ) 52 53local scale =minimapW / stageW 54 55graphics . setColor ( 0 , 0 , 0 , 100 * fade ) 56graphics . rectangle ( "fill" , minimapPosx - minimapW , minimapPosY , minimapW , minimapH ) 57graphics . setColor ( 255 , 255 , 255 , 200 * fade ) 58graphics . innerRectangle ( minimapPosx - minimapW , minimapPosY , minimapW , minimapH ) 59 60local top_x =1 - ( camera . left - zone . left ) / stageW 61local top_y =1 - ( camera . top - zone . bottom ) / stageH 62 63graphics . setColor ( 255 , 255 , 255 , 200 * fade ) 64graphics . rectangle ( "line" , minimapPosx - ( top_x * minimapW ), minimapPosY + ( top_y * minimapH ), cameraW * scale , cameraH * scale ) 65 66for i =4 , 1 , - 1 do 67local player =memory . player [ i ] 68 69local color =melee . getPlayerEntityColor ( player . entity ) 70 71if color then 72graphics . setColor ( color . r , color . g , color . b , 255 * fade ) 73 74if melee . isEntityActive ( player . entity ) then 75local pos =player . position 76 77local x =1 - ( pos . x - offset . x - zone . left ) / stageW 78local y =1 - ( pos . y - offset . y - zone . bottom ) / stageH 79 80graphics . easyDraw ( self . m_pCircle , minimapPosx - ( x * minimapW ), minimapPosY + ( y * minimapH ), 0 , 12 , 12 , 0.5 , 0.5 ) 81end 82if melee . isEntityActive ( player . partner ) then 83local pos =player . partner_position 84 85local x =1 - ( pos . x - offset . x - zone . left ) / stageW 86local y =1 - ( pos . y - offset . y - zone . bottom ) / stageH 87graphics . easyDraw ( self . m_pCircle , minimapPosx - ( x * minimapW ), minimapPosY + ( y * minimapH ), 0 , 12 , 12 , 0.5 , 0.5 ) 88end 89end 90end 91end 92 93gui . register ( "MiniMap" , PANEL , "Base" )