Skip to content

Commit

Permalink
Gmod Repo Mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
Centrix committed May 28, 2020
1 parent 1b96609 commit f14f773
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
3 changes: 2 additions & 1 deletion html/js/menu/control.Servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ function AddServer( type, id, ping, name, desc, map, players, maxplayers, botpla

data.hasmap = DoWeHaveMap( data.map );

data.recommended = data.ping;
data.recommended = 40;
if(data.ping >= 60) data.recommended = data.ping;
if ( data.players == 0 ) data.recommended += 75; // Server is empty
if ( data.players >= data.maxplayers ) data.recommended += 100; // Server is full, can't join it
if ( data.pass ) data.recommended += 300; // Password protected, can't join it
Expand Down
55 changes: 50 additions & 5 deletions lua/menu2/openurl2.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
local PANEL_Browser = {}

PANEL_Browser.Base = "DFrame"

function PANEL_Browser:Init()
self.HTML = vgui.Create( "HTML", self )

if ( !self.HTML ) then
print( "SteamOverlayReplace: Failed to create HTML element" )
self:Remove()
return
end

self.HTML:Dock( FILL )
self.HTML:SetOpenLinksExternally( true )

self:SetTitle( "Steam overlay replacement" )
self:SetSize( ScrW() * 0.75, ScrH() * 0.75 )
self:SetSizable( true )
self:Center()
self:MakePopup()
end

function PANEL_Browser:SetURL( url )
self.HTML:OpenURL( url )
end

----------------------------------------------

local PANEL = {}
local PanelInst = nil

PANEL.Base = "DFrame"

function PANEL:Init()
self:SetTitle( "Do you want to open this website ?" )
self:SetTitle( "#openurl.title" )

self.Garble = vgui.Create( "DLabel", self )
self.Garble:SetText( "" )
self.Garble:SetText( "#openurl.text" )
self.Garble:SetContentAlignment( 5 )
self.Garble:Dock( TOP )

Expand All @@ -19,12 +48,12 @@ function PANEL:Init()
self.Buttons:Dock( BOTTOM )

self.Nope = vgui.Create( "DButton", self.Buttons )
self.Nope:SetText( "No" )
self.Nope:SetText( "#openurl.nope" )
self.Nope.DoClick = function() self:DoNope() end
self.Nope:Dock( RIGHT )

self.Yes = vgui.Create( "DButton", self.Buttons )
self.Yes:SetText( "Yes" )
self.Yes:SetText( "#openurl.yes" )
self.Yes.DoClick = function() self:DoYes() end
self.Yes:DockMargin( 0, 0, 8, 0 )
self.Yes:Dock( RIGHT )
Expand Down Expand Up @@ -67,12 +96,28 @@ function PANEL:DoYes()
gui.HideGameUI()
end

-- Called from the engine
function RequestOpenURL( url )
if IsValid( PanelInst ) then
PanelInst:Remove()
end

PanelInst = vgui.CreateFromTable( PANEL )
PanelInst:SetURL( url )
gui.ActivateGameUI()

timer.Simple( 0, function()
gui.ActivateGameUI()
end )
end


function GMOD_OpenURLNoOverlay( url )

local BrowserInst = vgui.CreateFromTable( PANEL_Browser )
BrowserInst:SetURL( url )

timer.Simple( 0, function()
gui.ActivateGameUI()
end )

end

0 comments on commit f14f773

Please sign in to comment.