local maps = {
rp_downtown_evilmelon = {
{2431, 1946, 88, 180, 90, -90, .5},
{-165, -1458, -132, 180, 90, -90, .46},
{-2176, 1820, -158, 180, -90, -90, .5}
},
rp_downtown_v2_fiend = {
{-3348, -2115, 326, 180, -90, -90, 1}
},
rp_downtown = {
{-2943, -2115, 32, 180, -90, -90, 1}
},
rp_xmas_downtown = {
{-2943, -2115, 32, 180, -90, -90, 1}
},
rp_evocity_v2d = {
{435, 3950, 310, 180, 90, -90, 1},
{-5612, -8898, 310, 180, 90, -90, 1}
},
rp_evocity_v4b1 = {
--{-5612, -8898, 350, 180, 90, -90, 1}
{-5411, -10460, 254, 180, -90, -90, .8}
},
rp_townsend_v2 = {
{-957, 4913, 10, 180, 0, -90, .8}
},
rp_simpcity = {
{-3322, -2823, -1460, 180, 0, -90, 1},
{-6703, -1280, -1460, 180, -90, -90, 1}
}
}
local defaulttab = "http://game3.nxserv.eu/widgets/news.htm"
local data
for k, v in pairs(maps) do
if game.GetMap():Left(k:len()) == k then
data = v
break
end
end
if not data then
return
end
vutil = vutil or {}
vutil.planes = {}
local planemt = {__index = {}}
function planemt.__index.AddPanel(self, panel)
if not self.panels then
self.panels = {}
end
table.insert(self.panels, panel)
end
local buttonmt = {__index = {}}
function buttonmt.__index.SetState(self, state)
self.state = state or false
end
function planemt.__index.AddButton(self, x, y, text, func, state, visible)
if not self.buttons then
self.buttons = {}
end
local yer = table.insert(self.buttons, {x = x, y = y, text = text, func = func, state = state or false, visible = visible == nil and true or visible})
yer = self.buttons[yer]
setmetatable(yer, buttonmt)
return yer
end
function planemt.__index.AddHTML(self, hx, hy, x, y, sx, sy, url, scroll)
if not self.htmls then
self.htmls = {}
end
local html = vgui.Create("HTML")
html:SetSize(hx, hy)
html:SetPaintedManually(true)
html:SetMouseInputEnabled(false)
html:OpenURL(url)
table.insert(self.htmls, {x = x, y = y, sx = sx, sy = sy, html = html, scroll = scroll or false})
return html
end
function vutil.CreatePlane(pos, ang, scale)
local yer = table.insert(vutil.planes, {pos = pos, ang = ang, scale = scale or 1})
yer = vutil.planes[yer]
setmetatable(yer, planemt)
return yer
end
hook.Add("PostDrawTranslucentRenderables", "vPanels", function()
for k, v in pairs(vutil.planes) do
cam.Start3D2D(v.pos, v.ang, v.scale)
surface.SetDrawColor(255, 255, 255, 255)
if v.panels then
for k, v in pairs(v.panels) do
if IsValid(v) then
v:SetPaintedManually(false)
v:PaintManual()
v:SetPaintedManually(true)
end
end
end
if v.htmls then
for k, v in pairs(v.htmls) do
v.html:UpdateHTMLTexture()
if v.html:GetHTMLMaterial() then
surface.SetMaterial(v.html:GetHTMLMaterial())
end
surface.DrawTexturedRect(v.x, v.y, v.sx, v.sy)
end
end
if v.buttons then
for k, v in pairs(v.buttons) do
if v.visible then
surface.SetTextPos(v.x + 2, v.y)
surface.SetTextColor(230, 230, 230, 255)
surface.SetFont("Default")
local x, y = surface.GetTextSize(v.text)
local color
if v.state then
color = Color(0, 136, 255, 204)
else
color = Color(136, 136, 136, 204)
end
draw.RoundedBox(4, v.x, v.y, x + 3, y + 2, color)
surface.DrawText(v.text)
end
end
end
cam.End3D2D()
end
end)
local function isin(num, num1, num2)
return (num >= num1 and num <= num2) or (num <= num1 and num >= num2)
end
hook.Add("PlayerBindPress", "vPanels", function(_, cmd, down)
if cmd == "+use" or cmd == "+attack" then
for k, p in pairs(vutil.planes) do
if p.buttons then
local localpos = WorldToLocal(LocalPlayer():GetEyeTrace().HitPos, Angle(), p.pos, p.ang)
for k, v in pairs(p.buttons) do
if v.visible then
surface.SetFont("Default")
local sx, sy = surface.GetTextSize(v.text)
if isin(localpos.x, v.x * p.scale, (v.x + sx + 3) * p.scale) and isin(-localpos.y, v.y * p.scale, (v.y + sy + 2) * p.scale) and isin(localpos.z, -10, 10) then
v.func()
end
end
end
end
end
end
if down and (cmd == "invnext" or cmd == "invprev") then
local found
for k, p in pairs(vutil.planes) do
if p.htmls then
local localpos = WorldToLocal(LocalPlayer():GetEyeTrace().HitPos, Angle(), p.pos, p.ang)
for k, v in pairs(p.htmls) do
if v.scroll and isin(localpos.x, v.x * p.scale, (v.x + v.sx) * p.scale) and isin(-localpos.y, v.y * p.scale, (v.y + v.sy) * p.scale) and isin(localpos.z, -10, 10) then
v.html:RunJavascript("scrollBy(0, " .. (cmd == "invprev" and -100 or 100) .. ");")
found = true
end
end
end
if p.panels then
local localpos = WorldToLocal(LocalPlayer():GetEyeTrace().HitPos, Angle(), p.pos, p.ang)
for k, v in pairs(p.panels) do
if v.VBar and isin(localpos.x, v.x * p.scale, (v.x + v:GetWide()) * p.scale) and isin(-localpos.y, v.y * p.scale, (v.y + v:GetTall()) * p.scale) and isin(localpos.z, -10, 10) then
v.VBar:AddScroll(cmd == "invprev" and -1 or 1)
found = true
end
end
end
end
if found then
return true
end
end
end)
--======--
local url = "http://game3.nxserv.eu/widgets/"
local n = 1
for k, v in pairs(data) do
local p1 = vutil.CreatePlane(Vector(v[1], v[2], v[3]), Angle(v[4], v[5], v[6]), v[7])
local h1 = p1:AddHTML(1024, 720, 0, 0, 256, 256, defaulttab, true)
-- 45 42 44 | 256
local u1 = "news"
local bt1 = {}
local function g1(n)
if tonumber(n) then
for k, v in pairs(bt1) do
v:SetState(k == n)
end
end
h1:OpenURL(url .. u1 .. ".htm")
end
bt1[1] = p1:AddButton(31, 186, "Правила", function()
u1 = "rules"
g1(1)
end)
bt1[2] = p1:AddButton(107, 186, "Новости", function()
u1 = "news"
g1(2)
end, true)
bt1[3] = p1:AddButton(180, 186, "Помощь", function()
u1 = "info"
g1(3)
end)
p1:AddButton(92, 206, "Группа Steam", function()
gui.OpenURL("http://steamcommunity.com/groups/NxServ")
end)
concommand.Add("panels3_reload" .. n, g1)
n = n + 1
end