mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
function PANEL:CreateDivider(parent, dock)
|
||||
local divider = parent:Add("Panel")
|
||||
divider:Dock(dock)
|
||||
divider:SetHeight(SScaleMin(10 / 3))
|
||||
divider.Paint = function(s, w, h)
|
||||
surface.SetDrawColor(111, 111, 136, 76)
|
||||
surface.DrawLine(0, h * 0.5, w, h * 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
function PANEL:AddShop(parent, shopName, shopTenants)
|
||||
local shopPnl = parent:Add("Panel")
|
||||
shopPnl:Dock(TOP)
|
||||
shopPnl:SetHeight(SScaleMin(128 / 3))
|
||||
shopPnl:DockMargin(SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
|
||||
shopPnl.Paint = function(s, w, h)
|
||||
surface.SetDrawColor(111, 111, 136, 76)
|
||||
surface.DrawOutlinedRect(0, 0, w, h, 1)
|
||||
end
|
||||
|
||||
local nameLabel = shopPnl:Add("DLabel")
|
||||
nameLabel:SetContentAlignment(5)
|
||||
nameLabel:SetFont("TitlesFont")
|
||||
nameLabel:SetText(string.upper(shopName))
|
||||
nameLabel:Dock(TOP)
|
||||
nameLabel:SizeToContents()
|
||||
nameLabel:DockMargin(0, SScaleMin(6 / 3), 0, 0)
|
||||
|
||||
local shopOwners = shopPnl:Add("DLabel")
|
||||
shopOwners:SetContentAlignment(5)
|
||||
shopOwners:SetFont("MenuFontLargerBoldNoFix")
|
||||
shopOwners:SetText("OWNERS")
|
||||
shopOwners:Dock(TOP)
|
||||
shopOwners:SizeToContents()
|
||||
|
||||
local concatOwners = table.concat(shopTenants, ", ")
|
||||
|
||||
local ownersLabel = shopPnl:Add("DLabel")
|
||||
ownersLabel:SetFont("MenuFontLargerBoldNoFix")
|
||||
ownersLabel:SetText(concatOwners)
|
||||
ownersLabel:Dock(FILL)
|
||||
ownersLabel:DockMargin(SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
|
||||
ownersLabel:SetWrap(true)
|
||||
ownersLabel:SetAutoStretchVertical(true)
|
||||
ownersLabel.PaintOver = function(s, w, h)
|
||||
surface.SetDrawColor(111, 111, 136, 76)
|
||||
DisableClipping(true)
|
||||
surface.DrawOutlinedRect(-2, 0, w, h, 1)
|
||||
DisableClipping(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Populate(shopTbl)
|
||||
for k, v in pairs(shopTbl) do
|
||||
self:AddShop(self.shopScroller, v.shopName, !table.IsEmpty(v.tenants) and v.tenants or {"NO OWNERS"})
|
||||
end
|
||||
end
|
||||
|
||||
function PANEL:Init()
|
||||
if (ix.gui.shopOverwiew and ix.gui.shopOverwiew != self) then
|
||||
ix.gui.shopOverwiew:Remove()
|
||||
end
|
||||
|
||||
ix.gui.shopOverwiew = self
|
||||
|
||||
self:SetSize(ScrW(), ScrH())
|
||||
self:SetAlpha(0)
|
||||
|
||||
self.innerContent = self:Add("Panel")
|
||||
self.innerContent:SetSize(SScaleMin(900 / 3), SScaleMin(640 / 3))
|
||||
self.innerContent:Center()
|
||||
self.innerContent:MakePopup()
|
||||
self.innerContent.Paint = function(s, w, h)
|
||||
surface.SetDrawColor(0, 0, 0, 130)
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
end
|
||||
|
||||
self.topbar = self.innerContent:Add("Panel")
|
||||
self.topbar:SetHeight(SScaleMin(40 / 3))
|
||||
self.topbar:Dock(TOP)
|
||||
self.topbar.Paint = function(s, width, height)
|
||||
surface.SetDrawColor(8, 8, 8, 130)
|
||||
surface.DrawRect(0, 0, width, height)
|
||||
|
||||
surface.SetDrawColor(111, 111, 136, 76)
|
||||
surface.DrawLine(0, height * 0.95, width, height * 0.95)
|
||||
end
|
||||
|
||||
local exit = self.topbar:Add("DImageButton")
|
||||
exit:SetMaterial(Material("willardnetworks/tabmenu/navicons/exit.png", "smooth"))
|
||||
exit:SetSize(SScaleMin(25 / 3), SScaleMin(20 / 3))
|
||||
exit:DockMargin(0, SScaleMin(6 / 3), SScaleMin(6 / 3), SScaleMin(6 / 3))
|
||||
exit:Dock(RIGHT)
|
||||
exit.DoClick = function()
|
||||
self:Remove()
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
end
|
||||
|
||||
local titleText = self.topbar:Add("DLabel")
|
||||
titleText:SetFont("CharCreationBoldTitleNoClamp")
|
||||
titleText:Dock(LEFT)
|
||||
titleText:SetText("Shop overview")
|
||||
titleText:DockMargin(SScaleMin(10 / 3), 0, 0, 0)
|
||||
titleText:SetContentAlignment(4)
|
||||
titleText:SizeToContents()
|
||||
|
||||
self.shopScroller = self.innerContent:Add("DScrollPanel")
|
||||
self.shopScroller:Dock(FILL)
|
||||
self.shopScroller:DockMargin(SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
|
||||
self.shopScroller.Paint = function(s, w, h)
|
||||
surface.SetDrawColor(111, 111, 136, 76)
|
||||
surface.DrawOutlinedRect(0, 0, w, h, 2)
|
||||
end
|
||||
self:AlphaTo(255, 0.5)
|
||||
end
|
||||
|
||||
function PANEL:Paint(w, h)
|
||||
surface.SetDrawColor(63, 58, 115, 220)
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
|
||||
Derma_DrawBackgroundBlur(self, 1)
|
||||
end
|
||||
|
||||
vgui.Register("ixShopOverview", PANEL, "Panel")
|
||||
37
gamemodes/ixhl2rp/plugins/shop_viewowners/sh_plugin.lua
Normal file
37
gamemodes/ixhl2rp/plugins/shop_viewowners/sh_plugin.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
PLUGIN.name = "Willard Shop Overview"
|
||||
PLUGIN.author = "Naast"
|
||||
PLUGIN.description = "Simple shop overview panel for CCA."
|
||||
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
|
||||
ix.command.Add("ViewShops", {
|
||||
description = "Tworzy panel z listą wszystkich sklepów i ich właścicieli.",
|
||||
OnRun = function(self, client)
|
||||
PLUGIN:OpenShopInfo(client)
|
||||
end,
|
||||
OnCheckAccess = function(self, client)
|
||||
return client:IsCombine() or client:GetCharacter():HasFlags("U")
|
||||
end,
|
||||
bNoIndicator = true
|
||||
})
|
||||
|
||||
if CLIENT then
|
||||
net.Receive("ix.shopOverview.createPanel", function(len)
|
||||
local shopsInfo = net.ReadString()
|
||||
shopsInfo = util.JSONToTable(shopsInfo)
|
||||
|
||||
local viewOwners = vgui.Create("ixShopOverview")
|
||||
viewOwners:Populate(shopsInfo)
|
||||
end)
|
||||
end
|
||||
78
gamemodes/ixhl2rp/plugins/shop_viewowners/sv_plugin.lua
Normal file
78
gamemodes/ixhl2rp/plugins/shop_viewowners/sv_plugin.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
util.AddNetworkString("ix.shopOverview.createPanel")
|
||||
|
||||
function PLUGIN:OpenShopInfo(client)
|
||||
if (!client:IsCombine() and !client:GetCharacter():HasFlags("U")) then
|
||||
return
|
||||
end
|
||||
|
||||
local housing = ix.plugin.Get("housing")
|
||||
local housingApartments = housing.apartments
|
||||
local requiredInfo = {}
|
||||
|
||||
for k, v in pairs(housingApartments) do
|
||||
if v.type == "shop" then
|
||||
requiredInfo[#requiredInfo + 1] = {
|
||||
shopName = v.name,
|
||||
tenants = table.GetKeys(v.tenants)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in pairs(requiredInfo) do
|
||||
for tKey, tenant in pairs(v.tenants) do
|
||||
housing:LookUpCardItemIDByCID(tostring(tenant), function(result)
|
||||
local idCardID = result[1].idcard or false
|
||||
local charID
|
||||
if !result then return end
|
||||
if !ix.item.instances[idCardID] then
|
||||
ix.item.LoadItemByID(idCardID, false, function(card)
|
||||
if !card then return end
|
||||
charID = card:GetData("owner")
|
||||
end)
|
||||
else
|
||||
charID = ix.item.instances[idCardID]:GetData("owner")
|
||||
end
|
||||
local character = ix.char.loaded[charID]
|
||||
if character then
|
||||
requiredInfo[k]["tenants"][tKey] = character:GetName()
|
||||
else
|
||||
local query = mysql:Select("ix_characters_data")
|
||||
query:Where("key", "genericdata")
|
||||
query:Where("id", tostring(charID))
|
||||
query:Select("data")
|
||||
query:Callback(function(genResult)
|
||||
if (!istable(genResult) or #genResult == 0) then
|
||||
return
|
||||
end
|
||||
local genericData = util.JSONToTable(genResult[1]["data"])
|
||||
|
||||
requiredInfo[k]["tenants"][tKey] = genericData.name
|
||||
end)
|
||||
query:Execute()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
timer.Simple(0.25, function()
|
||||
if !IsValid(client) then
|
||||
return
|
||||
end
|
||||
|
||||
net.Start("ix.shopOverview.createPanel")
|
||||
net.WriteString(util.TableToJSON(requiredInfo))
|
||||
net.Send(client)
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user