Refactor, Beatify and EndRound hook fix
parent
0877e8a03d
commit
777ffcacbd
@ -1,4 +1,4 @@
|
|||||||
if (SERVER) then
|
if SERVER then
|
||||||
include("d3stats/init.lua")
|
include("d3stats/init.lua")
|
||||||
else
|
else
|
||||||
include("d3stats/cl_init.lua")
|
include("d3stats/cl_init.lua")
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
d3stats = d3stats or {}
|
D3stats = D3stats or {}
|
||||||
|
|
||||||
-- Includes
|
-- Includes
|
||||||
include( "sh_settings.lua" )
|
include("sh_settings.lua")
|
||||||
include( "sh_level.lua" )
|
include("sh_level.lua")
|
||||||
include( "sh_concommand.lua" )
|
include("sh_concommand.lua")
|
||||||
|
|
||||||
include( "cl_network.lua" )
|
include("cl_network.lua")
|
||||||
include( "cl_hud.lua" )
|
include("cl_hud.lua")
|
||||||
|
|
||||||
include( "vgui/overlay.lua" )
|
include("vgui/overlay.lua")
|
||||||
|
|
||||||
-- Initialisation
|
-- Initialization
|
||||||
hook.Add( "Initialize", "D3Stats_Init", function ()
|
hook.Add("Initialize", "D3stats_Init", function ()
|
||||||
d3stats.Overlay_Init()
|
D3stats.Overlay_Init()
|
||||||
end )
|
end)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
net.Receive( "D3Stats_UpdateXP", function()
|
net.Receive("D3stats_UpdateXP", function()
|
||||||
local XP = net.ReadUInt( 32 )
|
local XP = net.ReadUInt(32)
|
||||||
|
|
||||||
--print( "XP update: " .. tostring(XP))
|
--print("XP update: " .. tostring(XP))
|
||||||
|
|
||||||
if d3stats and d3stats.D3StatsOverlay then
|
if D3stats and D3stats.D3statsOverlay then
|
||||||
d3stats.D3StatsOverlay:StatsUpdate( XP, d3stats.CalculateLevel( XP ) )
|
D3stats.D3statsOverlay:StatsUpdate(XP, D3stats.CalculateLevel(XP))
|
||||||
end
|
end
|
||||||
end )
|
end)
|
@ -1,7 +1,7 @@
|
|||||||
if SERVER then
|
if SERVER then
|
||||||
|
|
||||||
concommand.Add( "d3stats_clearall", function( ply, cmd, args )
|
concommand.Add("D3stats_clearall", function(ply, cmd, args, argsString)
|
||||||
print( "What the hell are you doing?" )
|
print("What the hell are you doing? Not implemented yet!")
|
||||||
end )
|
end)
|
||||||
|
|
||||||
end
|
end
|
@ -1,35 +1,35 @@
|
|||||||
function d3stats.Map_Message( roundend, ply )
|
function D3stats.Map_Message(roundend, ply)
|
||||||
local map = game.GetMap()
|
local map = game.GetMap()
|
||||||
local count, wins, avg_players = d3stats.Storage.Map_Get( map )
|
local count, wins, avg_players = D3stats.Storage.Map_Get(map)
|
||||||
|
|
||||||
local Message
|
local Message
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
if roundend == true then
|
if roundend == true then
|
||||||
Message = string.format( d3stats.Message.MapStats_End, map, wins, count, wins / count * 100 )
|
Message = string.format(D3stats.Message.MapStats_End, map, wins, count, wins / count * 100)
|
||||||
else
|
else
|
||||||
Message = string.format( d3stats.Message.MapStats, map, wins, count, wins / count * 100 )
|
Message = string.format(D3stats.Message.MapStats, map, wins, count, wins / count * 100)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Message = string.format( d3stats.Message.MapStats_Zero, map )
|
Message = string.format(D3stats.Message.MapStats_Zero, map)
|
||||||
end
|
end
|
||||||
|
|
||||||
if ply then
|
if ply then
|
||||||
ply:ChatPrint( Message )
|
ply:ChatPrint(Message)
|
||||||
else
|
else
|
||||||
PrintMessage( HUD_PRINTTALK, Message )
|
PrintMessage(HUD_PRINTTALK, Message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function d3stats.Map_End( won )
|
function D3stats.Map_End(won)
|
||||||
local map = game.GetMap()
|
local map = game.GetMap()
|
||||||
local players = #player.GetAll()
|
local players = #player.GetAll()
|
||||||
|
|
||||||
if players > 0 then
|
if players > 0 then
|
||||||
d3stats.Storage.Map_AddOutcome( map, won, players )
|
D3stats.Storage.Map_AddOutcome(map, won, players)
|
||||||
d3stats.Map_Message( true )
|
D3stats.Map_Message(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--d3stats.Map_End( false )
|
--D3stats.Map_End(false)
|
||||||
|
|
||||||
--d3stats.Map_Message( false, player.GetByID(1) )
|
--D3stats.Map_Message(false, player.GetByID(1))
|
@ -1,11 +1,11 @@
|
|||||||
util.AddNetworkString( "D3Stats_UpdateXP" )
|
util.AddNetworkString("D3stats_UpdateXP")
|
||||||
|
|
||||||
local meta = FindMetaTable( "Player" )
|
local meta = FindMetaTable("Player")
|
||||||
if not meta then return end
|
if not meta then return end
|
||||||
|
|
||||||
-- Send the XP of this (self) player to itself
|
-- Send the XP of this (self) player to itself
|
||||||
function meta:D3Stats_Net_UpdateXP()
|
function meta:D3stats_Net_UpdateXP()
|
||||||
net.Start( "D3Stats_UpdateXP" )
|
net.Start("D3stats_UpdateXP")
|
||||||
net.WriteUInt( self:D3Stats_GetXP(), 32 )
|
net.WriteUInt(self:D3stats_GetXP(), 32)
|
||||||
net.Send( self )
|
net.Send(self)
|
||||||
end
|
end
|
||||||
|
@ -1,62 +1,59 @@
|
|||||||
local PANEL = {}
|
local PANEL = {}
|
||||||
|
|
||||||
function PANEL:Init()
|
function PANEL:Init()
|
||||||
|
self.Progress = vgui.Create("DProgress", self)
|
||||||
self.Progress = vgui.Create( "DProgress", self )
|
self.Progress:SetPos(10, 10)
|
||||||
self.Progress:SetPos( 10, 10 )
|
self.Progress:SetSize(200, 20)
|
||||||
self.Progress:SetSize( 200, 20 )
|
|
||||||
|
self.Label_XP = vgui.Create("DLabel", self)
|
||||||
self.Label_XP = vgui.Create( "DLabel", self )
|
self.Label_XP:SetTextColor(color_black)
|
||||||
self.Label_XP:SetTextColor( color_black )
|
self.Label_XP:SetFont(D3stats.Font_Overlay_XP)
|
||||||
self.Label_XP:SetFont( d3stats.Font_Overlay_XP )
|
self.Label_XP:SetSize(200, 20)
|
||||||
self.Label_XP:SetSize( 200, 20 )
|
self.Label_XP:SetPos(10, 10) -- Set the position of the label
|
||||||
self.Label_XP:SetPos( 10, 10 ) -- Set the position of the label
|
self.Label_XP:SetContentAlignment(5)
|
||||||
self.Label_XP:SetContentAlignment( 5 )
|
|
||||||
|
self.Label_Level = vgui.Create("DLabel", self)
|
||||||
self.Label_Level = vgui.Create( "DLabel", self )
|
self.Label_Level:SetFont(D3stats.Font_Overlay_Level)
|
||||||
self.Label_Level:SetFont( d3stats.Font_Overlay_Level )
|
self.Label_Level:SetPos(10, 35) -- Set the position of the label
|
||||||
self.Label_Level:SetPos( 10, 35 ) -- Set the position of the label
|
self.Label_Level:SetSize(200, 20)
|
||||||
self.Label_Level:SetSize( 200, 20 )
|
self.Label_Level:SetContentAlignment(5)
|
||||||
self.Label_Level:SetContentAlignment( 5 )
|
|
||||||
|
self:StatsUpdate(0, 1)
|
||||||
self:StatsUpdate( 0, 1 )
|
--self.Label:SetDark(1) -- Set the colour of the text inside the label to a darker one
|
||||||
--self.Label:SetDark( 1 ) -- Set the colour of the text inside the label to a darker one
|
|
||||||
|
--timer.Create("D3statsOverlay_Timer", 0.1, 0, function() self.Progress:SetFraction(math.random()) end)
|
||||||
--timer.Create( "D3StatsOverlay_Timer", 0.1, 0, function() self.Progress:SetFraction( math.random() ) end )
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function PANEL:Paint( aWide, aTall )
|
function PANEL:Paint(aWide, aTall)
|
||||||
-- Nothing for now
|
-- Nothing for now
|
||||||
end
|
end
|
||||||
|
|
||||||
function PANEL:StatsUpdate( XP, Level )
|
function PANEL:StatsUpdate(XP, Level)
|
||||||
local Text_XP
|
local Text_XP
|
||||||
local Text_Level
|
local Text_Level
|
||||||
local Fraction
|
local Fraction
|
||||||
|
|
||||||
if d3stats.Levels[Level+1] then
|
if D3stats.Levels[Level+1] then
|
||||||
Text_XP = "XP: " .. tostring( XP ) .. " / " .. d3stats.Levels[Level+1].XP_needed
|
Text_XP = "XP: " .. tostring(XP) .. " / " .. D3stats.Levels[Level+1].XP_needed
|
||||||
Fraction = ( XP - d3stats.Levels[Level].XP_needed ) / ( d3stats.Levels[Level+1].XP_needed - d3stats.Levels[Level].XP_needed )
|
Fraction = (XP - D3stats.Levels[Level].XP_needed) / (D3stats.Levels[Level+1].XP_needed - D3stats.Levels[Level].XP_needed)
|
||||||
else
|
else
|
||||||
Text_XP = "XP: " .. tostring( XP )
|
Text_XP = "XP: " .. tostring(XP)
|
||||||
Fraction = 1
|
Fraction = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
Text_Level = "Level: " .. tostring( Level ) .. " \"" .. d3stats.Levels[Level].Name .. "\""
|
Text_Level = "Level: " .. tostring(Level) .. " \"" .. D3stats.Levels[Level].Name .. "\""
|
||||||
|
|
||||||
self.Label_XP:SetText( Text_XP ) -- Set the text of the label
|
self.Label_XP:SetText(Text_XP) -- Set the text of the label
|
||||||
--self.Label_XP:SizeToContents() -- Size the label to fit the text in it
|
--self.Label_XP:SizeToContents() -- Size the label to fit the text in it
|
||||||
|
|
||||||
self.Label_Level:SetText( Text_Level ) -- Set the text of the label
|
self.Label_Level:SetText(Text_Level) -- Set the text of the label
|
||||||
--self.Label_Level:SizeToContents() -- Size the label to fit the text in it
|
--self.Label_Level:SizeToContents() -- Size the label to fit the text in it
|
||||||
|
|
||||||
self.Progress:SetFraction( Fraction )
|
self.Progress:SetFraction(Fraction)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function PANEL:SetText( aText ) self.Text = tostring( aText ) end
|
function PANEL:SetText(aText) self.Text = tostring(aText) end
|
||||||
function PANEL:GetText() return self.Text or "" end
|
function PANEL:GetText() return self.Text or "" end
|
||||||
|
|
||||||
vgui.Register( "D3StatsOverlay", PANEL, "DPanel" )
|
vgui.Register("D3statsOverlay", PANEL, "DPanel")
|
Loading…
Reference in New Issue