This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 8064ba84d8
commit 73479cff9e
7338 changed files with 1718883 additions and 14 deletions

View File

@@ -0,0 +1,202 @@
--[[
| 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:Init()
self:SetSize(ScrW(), ScrH())
self:SetAlpha(0)
self:AlphaTo(255, 0.5, 0)
self.Paint = function(panel, w, h)
surface.SetDrawColor(Color(63, 58, 115, 220))
surface.DrawRect(0, 0, w, h)
Derma_DrawBackgroundBlur(panel, 1)
end
self.innerContent = self:Add("Panel")
self.innerContent:SetSize(SScaleMin(500 / 3), SScaleMin(600 / 3))
self.innerContent:Center()
self.innerContent:MakePopup()
Schema:AllowMessage(self.innerContent)
self.innerContent.Paint = function(_, w, h)
surface.SetDrawColor(0, 0, 0, 130)
surface.DrawRect(0, 0, w, h)
end
self:CreateTopBar()
self:CreateItems()
end
function PANEL:CreateTopBar()
local topbar = self.innerContent:Add("Panel")
topbar:SetSize(self.innerContent:GetWide(), SScaleMin(50 / 3))
topbar:Dock(TOP)
topbar.Paint = function(_, w, h)
surface.SetDrawColor(0, 0, 0, 130)
surface.DrawRect(0, 0, w, h)
end
local titleText = topbar:Add("DLabel")
titleText:SetFont("CharCreationBoldTitleNoClamp")
titleText:Dock(LEFT)
titleText:SetText(L("smugglerSelectPickupItem"))
titleText:DockMargin(SScaleMin(10 / 3), 0, 0, 0)
titleText:SetContentAlignment(4)
titleText:SizeToContents()
local exit = topbar:Add("DImageButton")
exit:SetImage("willardnetworks/tabmenu/navicons/exit.png")
exit:SetSize(SScaleMin(20 / 3), SScaleMin(20 / 3))
exit:DockMargin(0, SScaleMin(15 / 3), SScaleMin(10 / 3), SScaleMin(15 / 3))
exit:Dock(RIGHT)
exit.DoClick = function()
netstream.Start("ClosePickupCache")
LocalPlayer().pickupItems = nil
self:Remove()
surface.PlaySound("helix/ui/press.wav")
end
local function createDivider(parent)
parent:SetSize(1, topbar:GetTall())
parent:Dock(RIGHT)
parent:DockMargin(0, SScaleMin(10 / 3), SScaleMin(SScaleMin(10 / 3) / 3), SScaleMin(10 / 3))
parent.Paint = function(_, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawLine(0, 0, 0, h)
end
end
local divider = topbar:Add("Panel")
createDivider(divider)
end
function PANEL:CreateItems()
local client = LocalPlayer()
if (!client.pickupItems) then
return
end
local character = client:GetCharacter()
local inventory = character:GetInventory()
local tblCount = table.Count(client.pickupItems)
local scrollPanel = self.innerContent:Add("DScrollPanel")
scrollPanel:Dock(TOP)
scrollPanel:SetSize(self.innerContent:GetWide(), self.innerContent:GetTall() - SScaleMin(50 / 3))
for k, v in pairs(client.pickupItems) do
if (!ix.item.list[k]) then
continue
end
local width = ix.item.list[k].width or 1
local height = ix.item.list[k].height or 1
local frame = scrollPanel:Add("Panel")
frame:Dock(TOP)
frame:DockMargin(0, 0, 0, -1)
frame:SetTall(SScaleMin(110 / 3) - 5)
frame.Paint = function(_, w, h)
surface.SetDrawColor(Color(0, 0, 0, 100))
surface.DrawRect(0, 0, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawOutlinedRect(0, 0, w, h)
end
local modelPanel = frame:Add("Panel")
modelPanel:Dock(LEFT)
modelPanel:SetWide(scrollPanel:GetWide() / 3)
modelPanel.Paint = function(_, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawLine(w - 1, SScaleMin(10 / 3), w - 1, h - SScaleMin(10 / 3))
end
local modelIcon = modelPanel:Add("SpawnIcon")
local model = ix.item.list[k].model or "models/props_junk/cardboard_box004a.mdl"
modelIcon:Dock(FILL)
modelIcon:DockMargin(SScaleMin(43 / 3), SScaleMin(10 / 3), SScaleMin(43 / 3), SScaleMin(10 / 3))
modelIcon:SetModel(model)
modelIcon.Paint = nil
modelIcon.PaintOver = nil
modelIcon:SetTooltip(nil)
local textPanel = frame:Add("Panel")
textPanel:Dock(LEFT)
textPanel:DockPadding(SScaleMin(10 / 3), 0, SScaleMin(10 / 3), 0)
textPanel:SetSize(scrollPanel:GetWide() / 2, frame:GetTall())
textPanel.Paint = function(_, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawLine(w - 1, SScaleMin(10 / 3), w - 1, h - SScaleMin(10 / 3))
end
local title = textPanel:Add("DLabel")
local actualTitle = ix.item.list[k].name or "Boîte en carton"
title:Dock(TOP)
title:SetText(actualTitle)
title:SetFont("WNBleedingMinutesBoldNoClamp")
title:SetWrap(true)
title:SetAutoStretchVertical(true)
title.PerformLayout = function(panel)
panel:DockMargin(0, textPanel:GetTall() * 0.5 - panel:GetTall() * 0.5, 0, textPanel:GetTall() * 0.5 - panel:GetTall() * 0.5)
end
local amountPanel = frame:Add("Panel")
amountPanel:Dock(FILL)
amountPanel:SetSize(scrollPanel:GetWide() - modelPanel:GetWide() - textPanel:GetWide(), frame:GetTall())
if (tblCount >= 6) then
amountPanel:SetWide(amountPanel:GetWide() - SScaleMin(15 / 3))
end
local amount = amountPanel:Add("DLabel")
local actualAmount = v or 1
amount:SetContentAlignment(5)
amount:SetText(actualAmount)
amount:SetFont("WNBleedingMinutesBoldNoClamp")
amount:SizeToContents()
amount:Center()
if (!inventory:FindEmptySlot(width, height)) then
amount:SetTextColor(Color(150, 150, 150, 255))
title:SetTextColor(Color(150, 150, 150, 255))
end
local invisibleButton = frame:Add("DButton")
invisibleButton:SetSize(modelPanel:GetWide() + textPanel:GetWide() + amountPanel:GetWide(), frame:GetTall())
invisibleButton:SetText("")
invisibleButton.Paint = function(panel, w, h)
if (panel:IsHovered() and inventory:FindEmptySlot(width, height)) then
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 15)))
surface.DrawOutlinedRect(SScaleMin(4 / 3), SScaleMin(4 / 3), w - SScaleMin(8 / 3), h - SScaleMin(8 / 3))
end
end
invisibleButton.DoClick = function()
if (inventory:FindEmptySlot(width, height)) then
actualAmount = actualAmount - 1
if (actualAmount == 0) then
frame:Remove()
else
amount:SetText(actualAmount)
end
client:NotifyLocalized(L("smugglerPickupItem", actualTitle))
surface.PlaySound("helix/ui/press.wav")
netstream.Start("SmugglingCachePickup", k)
else
client:NotifyLocalized(L("smugglerPickupNoSpace", actualTitle))
end
end
end
end
vgui.Register("PickupCache", PANEL, "EditablePanel")

View File

@@ -0,0 +1,388 @@
--[[
| 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/
--]]
-- luacheck: read globals SMUGGLER_BUY SMUGGLER_SELL SMUGGLER_BOTH SMUGGLER_WELCOME SMUGGLER_LEAVE SMUGGLER_NOTRADE SMUGGLER_PRICE
-- luacheck: read globals SMUGGLER_STOCK SMUGGLER_MODE SMUGGLER_MAXSTOCK SMUGGLER_SELLANDBUY SMUGGLER_SELLONLY SMUGGLER_BUYONLY SMUGGLER_TEXT
local PANEL = {}
local PLUGIN = PLUGIN
AccessorFunc(PANEL, "bReadOnly", "ReadOnly", FORCE_BOOL)
function PANEL:Init()
self:SetSize(ScrW() * 0.45, ScrH() * 0.65)
self:SetTitle("")
self:DockPadding(SScaleMin(10 / 3), SScaleMin(18 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
self:Center()
DFrameFixer(self)
local header = self:Add("Panel")
header:SetTall(SScaleMin(45 / 3))
header:Dock(TOP)
header.Paint = function(this, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawLine(0, h - 1, w, h - 1)
end
self.smugglerName = header:Add("DLabel")
self.smugglerName:Dock(LEFT)
self.smugglerName:SetText("John Doe")
self.smugglerName:SetTextColor(color_white)
self.smugglerName:SetFont("TitlesFontNoBoldNoClamp")
self.smugglerName:SizeToContents()
self.ourName = header:Add("DLabel")
self.ourName:Dock(RIGHT)
self.ourName:SetWide(self:GetWide() * 0.5 - SScaleMin(15 / 3))
self.ourName:SetText(L"you".." ("..ix.currency.Get(LocalPlayer():GetCharacter():GetMoney())..")")
self.ourName:SetTextInset(0, 0)
self.ourName:SetTextColor(color_white)
self.ourName:SetFont("TitlesFontNoBoldNoClamp")
local footer = self:Add("Panel")
footer:SetTall(SScaleMin(34 / 3))
footer:Dock(BOTTOM)
self.smugglerSell = footer:Add("DButton")
self.smugglerSell:SetFont("TitlesFontNoBoldNoClamp")
self.smugglerSell:Dock(LEFT)
self.smugglerSell:SetContentAlignment(5)
self.smugglerSell:DockMargin(0, 0, SScaleMin(10 / 3), 0)
-- The text says purchase but the smuggler is selling it to us.
self.smugglerSell:SetText(L"purchase")
self.smugglerSell:SetTextColor(color_white)
self.smugglerSell:SizeToContents()
self.smugglerSell:SetWide(self.smugglerSell:GetWide() + SScaleMin(20 / 3))
self.smugglerSell.DoClick = function(this)
if (IsValid(self.activeSell)) then
net.Start("ixSmugglerTrade")
net.WriteString(self.activeSell.item)
net.WriteBool(false)
net.WriteBool(false)
net.SendToServer()
end
end
self.smugglerSellDeliver = footer:Add("DButton")
self.smugglerSellDeliver:SetFont("TitlesFontNoBoldNoClamp")
self.smugglerSellDeliver:Dock(FILL)
self.smugglerSellDeliver:SetContentAlignment(5)
-- The text says purchase but the smuggler is selling it to us.
self.smugglerSellDeliver:SetText(L"smugglerSelectDelivery")
self.smugglerSellDeliver:SetTextColor(color_white)
self.smugglerSellDeliver:SizeToContents()
self.smugglerSellDeliver:DockMargin(0, 0, SScaleMin(10 / 3), 0)
self.smugglerSellDeliver.DoClick = function(this)
if (!self.entity.pickupLocation or self.entity.pickupLocation == "") then
local stashList = {}
for k, v in pairs(self.entity.stashList) do
stashList[v] = true
end
local list = {}
for _, v in ipairs(ents.FindByClass("ix_pickupcache")) do
if (stashList[v:GetLocationId()]) then
list[#list + 1] = {text = v:GetDisplayName(), value = v}
end
end
Derma_Select("Sélectionner un emplacement de ramassage", "", list, "Select pickup location", "Select", function(value, text)
net.Start("ixSmugglerChosePickup")
net.WriteEntity(value)
net.SendToServer()
end, "Annuler", function() end)
else
if (IsValid(self.activeSell)) then
net.Start("ixSmugglerTrade")
net.WriteString(self.activeSell.item)
net.WriteBool(false)
net.WriteBool(true)
net.SendToServer()
end
end
end
self.smugglerBuy = footer:Add("DButton")
self.smugglerBuy:SetFont("TitlesFontNoBoldNoClamp")
self.smugglerBuy:SetWide(self:GetWide() * 0.5 - SScaleMin(18 / 3))
self.smugglerBuy:Dock(RIGHT)
self.smugglerBuy:SetContentAlignment(5)
self.smugglerBuy:SetText(L"sell")
self.smugglerBuy:SetTextColor(color_white)
self.smugglerBuy.DoClick = function(this)
if (IsValid(self.activeBuy)) then
net.Start("ixSmugglerTrade")
net.WriteString(self.activeBuy.item)
net.WriteBool(true)
net.SendToServer()
end
end
self.selling = self:Add("DScrollPanel")
self.selling:SetWide(self:GetWide() * 0.5 - 7)
self.selling:Dock(LEFT)
self.selling:DockMargin(0, SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
self.selling.Paint = function(this, w, h)
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
surface.DrawLine(w - 1, 0, w - 1, h)
end
self.sellingItems = self.selling:Add("DListLayout")
self.sellingItems:SetSize(self.selling:GetSize())
self.sellingItems:SetTall(ScrH())
self.buying = self:Add("DScrollPanel")
self.buying:SetWide(self:GetWide() * 0.5 - SScaleMin(7 / 3))
self.buying:Dock(RIGHT)
self.buying:DockMargin(SScaleMin(10 / 3), SScaleMin(10 / 3), 0, SScaleMin(10 / 3))
self.buyingItems = self.buying:Add("DListLayout")
self.buyingItems:SetSize(self.buying:GetSize())
self.buyingItems.rightSide = true
self.sellingList = {}
self.buyingList = {}
end
function PANEL:addItem(uniqueID, listID)
local entity = self.entity
local items = entity.items
local data = items[uniqueID]
if ((!listID or listID == "selling") and !IsValid(self.sellingList[uniqueID])
and ix.item.list[uniqueID] and PLUGIN.itemList[uniqueID] and PLUGIN.itemList[uniqueID].sell) then
if (data and data[SMUGGLER_MODE] and data[SMUGGLER_MODE] != SMUGGLER_BUYONLY) then
local item = self.sellingItems:Add("ixSmugglerItem")
item:Setup(uniqueID)
self.sellingList[uniqueID] = item
self.sellingItems:InvalidateLayout()
end
end
if ((!listID or listID == "buying") and !IsValid(self.buyingList[uniqueID])
and LocalPlayer():GetCharacter():GetInventory():HasItem(uniqueID)
and PLUGIN.itemList[uniqueID] and PLUGIN.itemList[uniqueID].buy) then
if (data and data[SMUGGLER_MODE] and data[SMUGGLER_MODE] != SMUGGLER_SELLONLY) then
local item = self.buyingItems:Add("ixSmugglerItem")
item.isLocal = true
item:Setup(uniqueID)
self.buyingList[uniqueID] = item
self.buyingItems:InvalidateLayout()
end
end
end
function PANEL:removeItem(uniqueID, listID)
if (!listID or listID == "selling") then
if (IsValid(self.sellingList[uniqueID])) then
self.sellingList[uniqueID]:Remove()
self.sellingItems:InvalidateLayout()
end
end
if (!listID or listID == "buying") then
if (IsValid(self.buyingList[uniqueID])) then
self.buyingList[uniqueID]:Remove()
self.buyingItems:InvalidateLayout()
end
end
end
function PANEL:Setup(entity)
self.entity = entity
self:SetTitle(entity:GetDisplayName())
self.lblTitle:SizeToContents()
self.smugglerName:SetText(entity:GetDisplayName()..(entity.money and " ("..ix.currency.Get(entity.money)..")" or "").." (Stock Total : "..entity:GetTotalStock().."/"..entity.maxStock..")")
self.smugglerBuy:SetEnabled(!self:GetReadOnly())
self.smugglerSell:SetEnabled(!self:GetReadOnly())
self.smugglerSellDeliver:SetEnabled(!self:GetReadOnly())
self:SetButtonStatus(self.smugglerBuy, !self:GetReadOnly())
self:SetButtonStatus(self.smugglerSell, !self:GetReadOnly())
self:SetButtonStatus(self.smugglerSellDeliver, !self:GetReadOnly())
if (entity.pickupLocation and entity.pickupLocation != "") then
self.smugglerSellDeliver:SetText(L("smugglerDeliverTo", entity.pickupLocation))
end
for k, _ in SortedPairs(entity.items) do
self:addItem(k, "selling")
end
for _, v in SortedPairs(LocalPlayer():GetCharacter():GetInventory():GetItems()) do
self:addItem(v.uniqueID, "buying")
end
end
function PANEL:OnRemove()
net.Start("ixSmugglerClose")
net.SendToServer()
if (IsValid(ix.gui.smugglerEditor)) then
ix.gui.smugglerEditor:Remove()
end
end
function PANEL:Think()
local entity = self.entity
if (!IsValid(entity)) then
self:Remove()
return
end
if ((self.nextUpdate or 0) < CurTime()) then
self.smugglerName:SetText(entity:GetDisplayName()..(entity.money and " ("..ix.currency.Get(entity.money)..")" or "").." (Stock Total : "..entity:GetTotalStock().."/"..entity.maxStock..")")
self.smugglerName:SizeToContents()
self.ourName:SetText(L"you".." ("..ix.currency.Get(LocalPlayer():GetCharacter():GetMoney())..")")
self.nextUpdate = CurTime() + 0.25
end
end
function PANEL:OnItemSelected(panel)
local price = self.entity:GetPrice(panel.item, panel.isLocal)
if (panel.isLocal) then
self.smugglerBuy:SetText(L"sell".." ("..ix.currency.Get(price)..")")
else
self.smugglerSell:SetText(L"purchase".." ("..ix.currency.Get(price)..")")
self.smugglerSell:SizeToContents()
self.smugglerSell:SetWide(self.smugglerSell:GetWide() + SScaleMin(20 / 3))
end
end
function PANEL:SetButtonStatus(parent, bDisabled)
if (bDisabled) then
parent:SetTextColor(color_white)
else
parent:SetTextColor(Color(255, 255, 255, 30))
end
end
vgui.Register("ixSmuggler", PANEL, "DFrame")
PANEL = {}
function PANEL:Init()
self:SetTall(SScaleMin(36 / 3))
self:DockMargin(self:GetParent().rightSide and SScaleMin(15 / 3) or 0, self:GetParent().firstItem and SScaleMin(4 / 3) or 0, !self:GetParent().rightSide and SScaleMin(10 / 3) or 0, 0)
if !self:GetParent().firstItem then
self:GetParent().firstItem = true
end
self.icon = self:Add("SpawnIcon")
self.icon:SetPos(SScaleMin(2 / 3), SScaleMin(2 / 3))
self.icon:SetSize(SScaleMin(32 / 3), SScaleMin(32 / 3))
self.icon:SetModel("models/error.mdl")
self.name = self:Add("DLabel")
self.name:Dock(FILL)
self.name:DockMargin(SScaleMin(42 / 3), 0, 0, 0)
self.name:SetFont("TitlesFontNoClamp")
self.name:SetTextColor(color_white)
self.click = self:Add("DButton")
self.click:Dock(FILL)
self.click:SetText("")
self.click.Paint = function() end
self.click.DoClick = function(this)
if (self.isLocal) then
ix.gui.smuggler.activeBuy = self
else
ix.gui.smuggler.activeSell = self
end
ix.gui.smuggler:OnItemSelected(self)
end
end
function PANEL:SetCallback(callback)
self.click.DoClick = function(this)
callback()
self.selected = true
end
end
function PANEL:Setup(uniqueID)
local item = ix.item.list[uniqueID]
if (item and PLUGIN.itemList[uniqueID]) then
self.item = uniqueID
self.icon:SetModel(item:GetModel(), item:GetSkin())
self.name:SetText(item:GetName())
self.itemName = item:GetName()
self.click:SetHelixTooltip(function(tooltip)
ix.hud.PopulateItemTooltip(tooltip, item)
local entity = ix.gui.smuggler.entity
if (entity and entity.items[self.item]) then
local stock = tooltip:AddRowAfter("name", "stock")
local stockLvl, maxStock = entity:GetStock(uniqueID)
if (self.isLocal) then
local canBuy = math.min(entity.maxStock - stockLvl, maxStock - stockLvl)
local inventory = LocalPlayer():GetCharacter():GetInventory()
stock:SetText(L("smugglerStock", canBuy, inventory:GetItemCount(uniqueID)))
else
if (stockLvl > 0) then
stock:SetText(L("smugglerAvailable", stockLvl))
else
stock:SetText(L("smugglerAvailableDelivery"))
end
end
stock:SetBackgroundColor(derma.GetColor("Info", self))
stock:SizeToContents()
end
if (PLUGIN.itemList[uniqueID].stackSize) then
local stackSize = tooltip:AddRowAfter("name", "stackSize")
stackSize:SetText(L("smugglerStackSize", PLUGIN.itemList[uniqueID].stackSize))
stackSize:SetBackgroundColor(derma.GetColor("Info", self))
stackSize:SizeToContents()
end
end)
end
end
function PANEL:Think()
if ((self.nextUpdate or 0) < CurTime()) then
local entity = ix.gui.smuggler.entity
if (entity and self.isLocal) then
local count = LocalPlayer():GetCharacter():GetInventory():GetItemCount(self.item)
if (count == 0) then
self:Remove()
end
end
self.nextUpdate = CurTime() + 0.1
end
end
function PANEL:Paint(w, h)
if (ix.gui.smuggler.activeBuy == self or ix.gui.smuggler.activeSell == self) then
surface.SetDrawColor(ix.config.Get("color"))
else
surface.SetDrawColor(0, 0, 0, 100)
end
surface.DrawRect(0, 0, w, h)
end
vgui.Register("ixSmugglerItem", PANEL, "DPanel")

View File

@@ -0,0 +1,286 @@
--[[
| 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/
--]]
-- luacheck: read globals SMUGGLER_BUY SMUGGLER_SELL SMUGGLER_BOTH SMUGGLER_WELCOME SMUGGLER_LEAVE SMUGGLER_NOTRADE SMUGGLER_PRICE
-- luacheck: read globals SMUGGLER_STOCK SMUGGLER_MODE SMUGGLER_MAXSTOCK SMUGGLER_SELLANDBUY SMUGGLER_SELLONLY SMUGGLER_BUYONLY SMUGGLER_TEXT
local PANEL = {}
local PLUGIN = PLUGIN
function PANEL:Init()
local entity = ix.gui.smuggler.entity
self:SetSize(320, ScrH() * 0.65)
self:MoveLeftOf(ix.gui.smuggler, 8)
self:CenterVertical()
self:SetTitle(L"smugglerEditor")
self.lblTitle:SetTextColor(color_white)
DFrameFixer(self, false, true)
self.name = self:Add("DTextEntry")
self.name:Dock(TOP)
self.name:SetText(entity:GetDisplayName())
self.name:SetPlaceholderText(L"name")
self.name.OnEnter = function(this)
if (entity:GetDisplayName() != this:GetText()) then
self:updateSmuggler("name", this:GetText())
if IsValid(ix.gui.smuggler) then
ix.gui.smuggler:SetTitle(this:GetText())
ix.gui.smuggler.lblTitle:SizeToContents()
ix.gui.smuggler.smugglerName:SizeToContents()
end
end
end
self.description = self:Add("DTextEntry")
self.description:Dock(TOP)
self.description:DockMargin(0, 4, 0, 0)
self.description:SetText(entity:GetDescription())
self.description:SetPlaceholderText(L"description")
self.description.OnEnter = function(this)
if (entity:GetDescription() != this:GetText()) then
self:updateSmuggler("description", this:GetText())
end
end
self.model = self:Add("DTextEntry")
self.model:Dock(TOP)
self.model:DockMargin(0, 4, 0, 0)
self.model:SetText(entity:GetModel())
self.model:SetPlaceholderText(L"model")
self.model.OnEnter = function(this)
if (entity:GetModel():lower() != this:GetText():lower()) then
self:updateSmuggler("model", this:GetText():lower())
end
end
local useMoney = tonumber(entity.money) != nil
self.money = self:Add("DTextEntry")
self.money:Dock(TOP)
self.money:DockMargin(0, 4, 0, 0)
self.money:SetText(!useMoney and "" or entity.money)
self.money:SetPlaceholderText(L"money")
self.money:SetDisabled(!useMoney)
self.money:SetEnabled(useMoney)
self.money:SetNumeric(true)
self.money.OnEnter = function(this)
local value = tonumber(this:GetText()) or entity.money
if (value == entity.money) then
return
end
self:updateSmuggler("money", value)
end
self.useMoney = self:Add("DCheckBoxLabel")
self.useMoney:SetText(L"smugglerUseMoney")
self.useMoney:Dock(TOP)
self.useMoney:DockMargin(0, 4, 0, 0)
self.useMoney:SetChecked(useMoney)
self.useMoney.OnChange = function(this, value)
self:updateSmuggler("useMoney")
end
self.maxStock = self:Add("DTextEntry")
self.maxStock:Dock(TOP)
self.maxStock:DockMargin(0, 4, 0, 0)
self.maxStock:SetText(entity.maxStock)
self.maxStock:SetPlaceholderText(L"maxStock")
self.maxStock:SetNumeric(true)
self.maxStock.OnEnter = function(this)
local value = tonumber(this:GetText()) or entity.maxStock
if (value == entity.maxStock) then
return
end
self:updateSmuggler("stockMax", value)
end
self.stashList = self:Add("DListView")
self.stashList:Dock(TOP)
self.stashList:DockMargin(0, 4, 0, 0)
self.stashList:AddColumn("Location Id")
self.stashList:SetTooltip("Laisser la liste vide pour utiliser tous les emplacements et ne pas attribuer de cachettes \nDouble cliquer pour supprimer lentrée")
self.stashList:SetTall(ScrH() * 0.075)
self.stashList:SetSortable(false)
function self.stashList:GetStashList()
local stashes = {}
for k, v in pairs(self:GetLines(1)) do
if (k != 1) then
table.insert(stashes, v:GetValue(1))
end
end
return stashes
end
local addButton = self.stashList:AddLine("Add...")
function addButton:OnSelect()
Derma_StringRequest("Location Id", "Saisir l'identifiant de l'emplacement des réserves qui seront utilisées.", "", function(text)
local stashList = self:GetListView()
text = string.utf8upper(text)
for k, v in pairs(stashList:GetLines()) do
if (v:GetValue(1) == text) then
return
end
end
stashList:AddLine(text)
PANEL:updateSmuggler("stashList", stashList:GetStashList())
end)
end
function self.stashList:DoDoubleClick(lineId, linePanel)
if (lineId == 1) then return end
self:RemoveLine(lineId)
PANEL:updateSmuggler("stashList", self:GetStashList())
end
if (entity.stashList and !table.IsEmpty(entity.stashList)) then
for k, v in pairs(entity.stashList) do
self.stashList:AddLine(v)
end
end
self.searchBar = self:Add("DTextEntry")
self.searchBar:Dock(TOP)
self.searchBar:DockMargin(0, 4, 0, 0)
self.searchBar:SetUpdateOnType(true)
self.searchBar:SetPlaceholderText("Recherche...")
self.searchBar.OnValueChange = function(this, value)
self:ReloadItemList(value)
end
self.items = self:Add("DListView")
self.items:Dock(FILL)
self.items:DockMargin(0, 4, 0, 0)
self.items:AddColumn(L"name").Header:SetTextColor(color_black)
self.items:AddColumn(L"category").Header:SetTextColor(color_black)
self.items:AddColumn(L"mode").Header:SetTextColor(color_black)
self.items:AddColumn(L"stock").Header:SetTextColor(color_black)
self.items:SetMultiSelect(false)
self.items.OnRowRightClick = function(this, index, line)
if (IsValid(self.menu)) then
self.menu:Remove()
end
local uniqueID = line.item
self.menu = DermaMenu()
-- Modes of the item.
local mode, panel = self.menu:AddSubMenu(L"mode")
panel:SetImage("icon16/key.png")
-- Disable buying/selling of the item.
mode:AddOption(L"none", function()
self:updateSmuggler("mode", {uniqueID, nil})
end):SetImage("icon16/cog_error.png")
if (PLUGIN.itemList[uniqueID].buy and PLUGIN.itemList[uniqueID].sell) then
-- Allow the smuggler to sell and buy this item.
mode:AddOption(L"smugglerBoth", function()
self:updateSmuggler("mode", {uniqueID, SMUGGLER_SELLANDBUY})
end):SetImage("icon16/cog.png")
end
if (PLUGIN.itemList[uniqueID].buy) then
-- Only allow the smuggler to buy this item from players.
mode:AddOption(L"smugglerBuy", function()
self:updateSmuggler("mode", {uniqueID, SMUGGLER_BUYONLY})
end):SetImage("icon16/cog_delete.png")
end
if (PLUGIN.itemList[uniqueID].sell) then
-- Only allow the smuggler to sell this item to players.
mode:AddOption(L"smugglerSell", function()
self:updateSmuggler("mode", {uniqueID, SMUGGLER_SELLONLY})
end):SetImage("icon16/cog_add.png")
end
local itemTable = ix.item.list[uniqueID]
-- Only allow the smuggler to sell this item to players.
self.menu:AddOption(L"smugglerEditCurStock", function()
Derma_StringRequest(
itemTable.GetName and itemTable:GetName() or L(itemTable.name),
L"smugglerStockCurReq",
entity:GetStock(uniqueID),
function(text)
self:updateSmuggler("stock", {uniqueID, text})
end
)
end):SetImage("icon16/table_edit.png")
self.menu:Open()
self.menu.Think = function()
if (IsValid(self.menu)) then
self.menu:MoveToFront()
end
end
end
self:ReloadItemList()
end
function PANEL:ReloadItemList(filter)
local entity = ix.gui.smuggler.entity
self.lines = {}
self.items:Clear()
for k, info in SortedPairs(PLUGIN.itemList) do
local v = ix.item.list[k]
local itemName = v.GetName and v:GetName() or L(v.name)
if (filter and !itemName:lower():find(filter:lower(), 1, false)) then
continue
end
local mode = entity.items[k] and entity.items[k][SMUGGLER_MODE]
local current, max = entity:GetStock(k)
local panel = self.items:AddLine(
itemName,
info.cat or v.category or L"none",
mode and L(SMUGGLER_TEXT[mode]) or L"none",
max != entity.maxStock and current.."/"..max or current
)
panel.item = k
self.lines[k] = panel
end
end
function PANEL:OnRemove()
if (IsValid(ix.gui.smuggler)) then
ix.gui.smuggler:Remove()
end
end
function PANEL:updateSmuggler(key, value)
net.Start("ixSmugglerEdit")
net.WriteString(key)
net.WriteType(value)
net.SendToServer()
end
function PANEL:Think()
if (self.menu and !self.menu:IsVisible()) or !self.menu then
self:MoveToFront()
end
end
vgui.Register("ixSmugglerEditor", PANEL, "DFrame")