mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
95
gamemodes/ixhl2rp/plugins/notes/cl_plugin.lua
Normal file
95
gamemodes/ixhl2rp/plugins/notes/cl_plugin.lua
Normal file
@@ -0,0 +1,95 @@
|
||||
--[[
|
||||
| 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
|
||||
|
||||
function PLUGIN:F1MenuCreated(panel, mainFrame, leftFrame, rightFrame)
|
||||
local notes = vgui.Create("DButton", rightFrame)
|
||||
notes:SetFont("MenuFontNoClamp")
|
||||
notes:SetText("Notatki Osobiste")
|
||||
notes:Dock(TOP)
|
||||
notes:DockMargin(0, 0, 0, 0 - SScaleMin(1 / 3))
|
||||
notes:SetSize(rightFrame:GetWide(), SScaleMin(30 / 3))
|
||||
notes.Paint = function(self, w, h)
|
||||
surface.SetDrawColor(Color(0, 0, 0, 50))
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
|
||||
surface.SetDrawColor(Color(100, 100, 100, 150))
|
||||
surface.DrawOutlinedRect(0, 0, w, h)
|
||||
end
|
||||
|
||||
notes.DoClick = function (btn)
|
||||
PLUGIN:CreateNotesTab()
|
||||
end
|
||||
|
||||
mainFrame:SetTall(mainFrame:GetTall() + notes:GetTall())
|
||||
end
|
||||
|
||||
function PLUGIN:CreateNotesTab(characterId, charNotes)
|
||||
local maxLen = ix.config.Get("notesMaxLen")
|
||||
local dataKey = "notes-"..string.gsub(game.GetIPAddress(), "%p", "").."-"..LocalPlayer():GetCharacter():GetID()
|
||||
|
||||
local frame = vgui.Create("DFrame")
|
||||
frame:SetSize(ScrW() * 0.4, ScrH() * 0.4)
|
||||
frame:SetTitle(characterId != nil and "Notatki Admina" or "Notatki Osobiste")
|
||||
frame:Center()
|
||||
frame:MakePopup()
|
||||
|
||||
local textEntry = vgui.Create("DTextEntry", frame)
|
||||
textEntry:Dock(FILL)
|
||||
textEntry:SetMultiline(true)
|
||||
|
||||
textEntry.OnTextChanged = function(self)
|
||||
local txt = self:GetValue()
|
||||
local amt = string.utf8len(txt)
|
||||
|
||||
if amt > maxLen then
|
||||
self:SetText(self.oldText)
|
||||
self:SetValue(self.oldText)
|
||||
else
|
||||
self.oldText = txt
|
||||
end
|
||||
end
|
||||
|
||||
local text
|
||||
|
||||
if (characterId != nil) then
|
||||
text = charNotes
|
||||
else
|
||||
text = ix.data.Get(dataKey, "", true, true)
|
||||
end
|
||||
|
||||
if (!text) then
|
||||
frame:Remove()
|
||||
LocalPlayer():Notify("Nie można otworzyć notatek postaci")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
textEntry:SetValue(text)
|
||||
|
||||
local submitButton = vgui.Create("DButton", frame)
|
||||
submitButton:Dock(BOTTOM)
|
||||
submitButton:SetText("Zapisz")
|
||||
submitButton.DoClick = function(self)
|
||||
if (characterId) then
|
||||
netstream.Start("ixNotesSet", characterId, utf8.sub(textEntry:GetValue(), 1, maxLen))
|
||||
else
|
||||
ix.data.Set(dataKey, textEntry:GetValue(), true, true)
|
||||
|
||||
LocalPlayer():Notify("Notatki zostały pomyślnie zapisane.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
netstream.Hook("ixNotes", function(characterId, charNotes)
|
||||
PLUGIN:CreateNotesTab(characterId, charNotes)
|
||||
end)
|
||||
Reference in New Issue
Block a user