This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent 9f505a0646
commit c6d9b6f580
8044 changed files with 1853472 additions and 21 deletions

View File

@@ -0,0 +1,47 @@
--[[
| 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/
--]]
net.Receive("RequestMainMenuInfo", function()
local list = net.ReadTable()
local logoData = net.ReadTable()
local buttonColors = net.ReadTable()
if ix.gui.wnMainMenu and IsValid(ix.gui.wnMainMenu) then
if ix.gui.wnMainMenu.CreateMainPanel then
ix.gui.wnMainMenu:CreateMainPanel(logoData, buttonColors)
if ix.gui.wnMainMenu.UpdateChildPanels and ix.gui.wnMainMenu.GetParent then
local parent = ix.gui.wnMainMenu:GetParent()
if parent and IsValid(parent) then
ix.gui.wnMainMenu:UpdateChildPanels(parent)
end
end
end
end
if #list <= 0 then
list = {"city_bg"}
end
ix.gui.background_url = "willardnetworks/backgrounds/"..table.Random(list)..".jpg"
if !ix.gui.mainMenuManager or ix.gui.mainMenuManager and !IsValid(ix.gui.mainMenuManager) then
return
end
if !ix.gui.mainMenuManager.PopulateBackgroundList then return end
if !list or list and !istable(list) then return end
ix.gui.mainMenuManager:PopulateBackgroundList(list)
if !ix.gui.mainMenuManager.PopulateColors then return end
ix.gui.mainMenuManager:PopulateColors(buttonColors)
end)

View File

@@ -0,0 +1,231 @@
--[[
| 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()
ix.gui.mainMenuManager = self
self:SetSize(SScaleMin(600 / 3), SScaleMin(500 / 3))
self:Center()
self:SetTitle("Main Menu Manager")
DFrameFixer(self)
self:CreateMain()
end
function PANEL:CreateMain()
if !self.mainPanel or self.mainPanel and !IsValid(self.mainPanel) then
self.mainPanel = self:Add("Panel")
self.mainPanel:Dock(FILL)
end
for _, v in pairs(self.mainPanel:GetChildren()) do
if IsValid(v) then
v:Remove()
end
end
self.backgrounds = self.mainPanel:Add("DButton")
self:CreateButton(self.backgrounds, "Backgrounds")
self.backgrounds.DoClick = function()
surface.PlaySound("helix/ui/press.wav")
self.buttonOptions:Remove()
self.logoOptions:Remove()
self.backgrounds:Remove()
self:CreateBackgroundsPanel()
end
local infoText1 = "Relative to materials/willardnetworks/, must be png, only write the name of the file "
local infoText2 = "without .png extension. e.g. 'wn_logo_base'."
local infoText = infoText1..infoText2
self.logoOptions = self.mainPanel:Add("DButton")
self:CreateButton(self.logoOptions, "Logo Options")
self.logoOptions.DoClick = function()
surface.PlaySound("helix/ui/press.wav")
Derma_Query("Set Logo Options", "Width/Height/Path",
"Use Standard WN Logo", function()
net.Start("SetMainMenuLogo")
net.SendToServer()
end,
"Set Custom Logo", function ()
Derma_StringRequest("Set Custom Logo Path", infoText, "", function(path)
Derma_StringRequest("Set Custom Logo Width", "In pixels.", "", function(width)
Derma_StringRequest("Set Custom Logo Height", "In pixels.", "", function(height)
local logoTable = { path, width, height }
net.Start("SetMainMenuLogo")
net.WriteTable(logoTable)
net.SendToServer()
end)
end)
end)
end,
"Cancel"
)
end
local options = {
"Font Color",
"Font Hover Color",
"Font Locked Button Color"
}
self.buttonOptions = self.mainPanel:Add("DButton")
self:CreateButton(self.buttonOptions, "Button Options")
self.buttonOptionList = {}
self.buttonOptions.DoClick = function()
surface.PlaySound("helix/ui/press.wav")
self.buttonOptions:Remove()
self.logoOptions:Remove()
self.backgrounds:Remove()
self:CreateBackButton()
for _, v in pairs(options) do
local buttonOption = self.mainPanel:Add("DButton")
self:CreateButton(buttonOption, v)
buttonOption.colorPicker = buttonOption:Add("ixSettingsRowColor")
buttonOption.colorPicker:Dock(RIGHT)
buttonOption.colorPicker:DockMargin(0, 0, SScaleMin(10 / 3), 0)
buttonOption.colorPicker:SetText("")
buttonOption.colorPicker.OnValueChanged = function(panel, color)
self:UpdateButtonColorsToServer()
end
net.Start("RequestMainMenuInfo")
net.SendToServer()
buttonOption.DoClick = function()
buttonOption.colorPicker:OpenPicker()
end
self.buttonOptionList[v] = buttonOption
end
end
end
function PANEL:UpdateButtonColorsToServer()
local colorTable = {
["Font Color"] = self.buttonOptionList["Font Color"].colorPicker:GetValue(),
["Font Hover Color"] = self.buttonOptionList["Font Hover Color"].colorPicker:GetValue(),
["Font Locked Button Color"] = self.buttonOptionList["Font Locked Button Color"].colorPicker:GetValue()
}
net.Start("SetMainMenuButtonColors")
net.WriteTable(colorTable)
net.SendToServer()
end
function PANEL:PopulateColors(colors)
for type, color in pairs(colors) do
if !self.buttonOptionList[type] then continue end
if !self.buttonOptionList[type].colorPicker then continue end
self.buttonOptionList[type].colorPicker:SetValue(color)
end
end
function PANEL:CreateBackgroundsPanel()
self:CreateBackButton()
local addBackground = self.mainPanel:Add("DButton")
self:CreateButton(addBackground, "Add Background")
local infoText1 = "Relative to materials/willardnetworks/backgrounds/, must be jpg, only write the name of the file without "
local infoText2 = ".jpg extension. e.g. 'city_bg'."
local infoText = infoText1..infoText2
addBackground.DoClick = function()
Derma_StringRequest("Add background", infoText, "", function(text)
net.Start("AddMainMenuBackground")
net.WriteString(text)
net.SendToServer()
end)
end
self:CreateNote("Path relative to materials/willardnetworks/backgrounds/")
self.backgroundList = self.mainPanel:Add("DListView")
self.backgroundList:Dock(FILL)
self.backgroundList:DockMargin(4, 4, 4, 4)
self.backgroundList:AddColumn("Path (right click on rows for options)")
self.backgroundList:SetHeaderHeight(SScaleMin(16 / 3))
self.backgroundList:SetDataHeight(SScaleMin(17 / 3))
net.Start("RequestMainMenuInfo")
net.SendToServer()
self.backgroundList.OnRowRightClick = function(list, lineId, line)
local dmenu = DermaMenu()
dmenu:MakePopup()
dmenu:SetPos(input.GetCursorPos())
dmenu:AddOption("Remove", function()
net.Start("RemoveMainMenuBackground")
net.WriteString(line:GetValue(1))
net.SendToServer()
end)
for _, v in pairs(dmenu:GetChildren()[1]:GetChildren()) do
v:SetFont("MenuFontNoClamp")
end
end
end
function PANEL:PopulateBackgroundList(table)
if !self.backgroundList then return end
if self.backgroundList and !IsValid(self.backgroundList) then return end
self.backgroundList:Clear()
for _, name in pairs(table) do
self.backgroundList:AddLine(name)
end
end
function PANEL:CreateNote(text)
local note = self.mainPanel:Add("DLabel")
note:SetFont("TitlesFontNoClamp")
note:Dock(TOP)
note:DockMargin(SScaleMin(10 / 3), SScaleMin(10 / 3), 0, SScaleMin(10 / 3))
note:SetText(text)
note:SetContentAlignment(4)
note:SizeToContents()
return note
end
function PANEL:CreateBackButton()
self.back = self.mainPanel:Add("DButton")
self:CreateButton(self.back, "Back")
self.back.DoClick = function()
surface.PlaySound("helix/ui/press.wav")
self:CreateMain()
end
end
function PANEL:CreateButton(name, text)
name:SetSize(SScaleMin(480 / 3), SScaleMin(46 / 3))
name:SetContentAlignment(4)
name:SetTextInset(SScaleMin(20 / 3), 0)
name:Dock(TOP)
name:SetFont("TitlesFontNoClamp")
name:DockMargin(0, 0, 0, SScaleMin(9 / 3))
name:SetText(text)
end
vgui.Register("MainMenuManager", PANEL, "DFrame")

View File

@@ -0,0 +1,88 @@
--[[
| 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("RequestMainMenuInfo")
util.AddNetworkString("AddMainMenuBackground")
util.AddNetworkString("RemoveMainMenuBackground")
util.AddNetworkString("SetMainMenuLogo")
util.AddNetworkString("SetMainMenuButtonColors")
function PLUGIN:UpdateMainMenu(client)
net.Start("RequestMainMenuInfo")
net.WriteTable(PLUGIN.menuBackgrounds)
net.WriteTable(PLUGIN.logoData)
net.WriteTable(PLUGIN.buttonColors)
net.Send(client)
end
net.Receive("RequestMainMenuInfo", function(_, client)
PLUGIN:UpdateMainMenu(client)
end)
net.Receive("AddMainMenuBackground", function(_, client)
if (!client:IsAdmin()) then return end
local backgroundName = net.ReadString()
PLUGIN.menuBackgrounds[#PLUGIN.menuBackgrounds + 1] = backgroundName
PLUGIN:SaveData()
PLUGIN:UpdateMainMenu(client)
end)
net.Receive("RemoveMainMenuBackground", function(_, client)
if (!client:IsAdmin()) then return end
local toRemove = net.ReadString()
for key, name in pairs(PLUGIN.menuBackgrounds) do
if name == toRemove then
table.remove(PLUGIN.menuBackgrounds, key)
break
end
end
PLUGIN:SaveData()
PLUGIN:UpdateMainMenu(client)
end)
net.Receive("SetMainMenuLogo", function(_, client)
if (!client:IsAdmin()) then return end
local newLogo = net.ReadTable()
if #newLogo == 0 then
PLUGIN.logoData = {bDefault = true}
return
end
local path = newLogo[1]
local width = tonumber(newLogo[2])
local height = tonumber(newLogo[3])
if !isnumber(width) then return end
if !isnumber(height) then return end
if !isstring(path) then return end
PLUGIN.logoData = {path = path, width = width, height = height}
PLUGIN:SaveData()
end)
net.Receive("SetMainMenuButtonColors", function(_, client)
if (!client:IsAdmin()) then return end
local newColors = net.ReadTable()
PLUGIN.buttonColors = newColors
PrintTable(PLUGIN.buttonColors)
PLUGIN:SaveData()
end)