-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add detailed descriptions plugin (#71)
- Loading branch information
Showing
3 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
net.Receive("ixOpenDetailedDescriptions", function() | ||
local client = net.ReadEntity() | ||
local textEntryData = net.ReadString() | ||
local textEntryDataURL = net.ReadString() | ||
|
||
local Frame = vgui.Create("DFrame") | ||
Frame:Center() | ||
Frame:SetPos(Frame:GetPos() - 150, 250, 0) | ||
Frame:SetSize(350, 500) | ||
Frame:SetTitle("Detailed Description - " .. client:Name()) | ||
Frame:MakePopup() | ||
|
||
local List = vgui.Create("DListView", Frame) | ||
List:Dock( FILL ) | ||
List:DockMargin( 0, 0, 0, 5 ) | ||
List:SetMultiSelect(false) | ||
|
||
local textEntry = vgui.Create("DTextEntry", List) | ||
textEntry:Dock( FILL ) | ||
textEntry:DockMargin( 0, 0, 0, 0 ) | ||
textEntry:SetMultiline(true) | ||
textEntry:SetVerticalScrollbarEnabled(true) | ||
|
||
textEntry:SetText(textEntryData) | ||
|
||
local DButton = vgui.Create("DButton", List) | ||
if (textEntryDataURL == "No detailed description found.") then | ||
DButton:SetDisabled(true) | ||
else | ||
DButton:SetTextColor(Color(0, 0, 0, 255)) | ||
end | ||
DButton:SetText("View Reference Picture") | ||
DButton:Dock( BOTTOM ) | ||
DButton:DockMargin( 0, 0, 0, 0 ) | ||
|
||
DButton.DoClick = function() | ||
gui.OpenURL(textEntryDataURL) | ||
end | ||
end) | ||
|
||
net.Receive("ixSetDetailedDescriptions", function() | ||
local callingClientSteamName = net.ReadString() | ||
|
||
local Frame = vgui.Create("DFrame") | ||
Frame:Center() | ||
Frame:SetPos(Frame:GetPos() - 150, 250, 0) | ||
Frame:SetSize(350, 500) | ||
Frame:SetTitle("Edit Detailed Description") | ||
Frame:MakePopup() | ||
|
||
local List = vgui.Create("DListView", Frame) | ||
List:Dock( FILL ) | ||
List:DockMargin( 0, 0, 0, 5 ) | ||
List:SetMultiSelect(false) | ||
|
||
local textEntry = vgui.Create("DTextEntry", List) | ||
textEntry:Dock( FILL ) | ||
textEntry:DockMargin( 0, 0, 0, 0 ) | ||
textEntry:SetMultiline(true) | ||
textEntry:SetVerticalScrollbarEnabled(true) | ||
|
||
if (LocalPlayer():GetCharacter():GetData("textDetDescData")) then | ||
textEntry:SetText(LocalPlayer():GetCharacter():GetData("textDetDescData")) | ||
end | ||
|
||
local DButton = vgui.Create("DButton", List) | ||
DButton:DockMargin( 0, 0, 0, 0 ) | ||
DButton:Dock( BOTTOM ) | ||
DButton:SetText("Edit") | ||
DButton:SetTextColor(Color(0, 0, 0, 255)) | ||
|
||
local textEntryURL = vgui.Create("DTextEntry", List) | ||
textEntryURL:Dock( BOTTOM ) | ||
textEntryURL:DockMargin( 0, 0, 0, 0 ) | ||
textEntryURL:SetValue("Reference Image URL") | ||
|
||
if (LocalPlayer():GetCharacter():GetData("textDetDescDataURL")) then | ||
textEntryURL:SetValue(LocalPlayer():GetCharacter():GetData("textDetDescDataURL")) | ||
textEntryURL:SetText(LocalPlayer():GetCharacter():GetData("textDetDescDataURL")) | ||
end | ||
|
||
DButton.DoClick = function() | ||
net.Start("ixEditDetailedDescriptions") | ||
net.WriteString(textEntryURL:GetValue()) | ||
net.WriteString(textEntry:GetValue()) | ||
net.WriteString(callingClientSteamName) | ||
net.SendToServer() | ||
Frame:Remove() | ||
end | ||
end) | ||
|
||
function PLUGIN:GetPlayerEntityMenu(client, options) | ||
options["Examine"] = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
local PLUGIN = PLUGIN | ||
|
||
PLUGIN.name = "Detailed Descriptions" | ||
PLUGIN.author = "Zoephix" | ||
PLUGIN.description = "Adds the ability for players to create detailed descriptions, which can be examined." | ||
PLUGIN.license = [[ | ||
This script is part of the "Detailed Descriptions" plugin by Zoephix. | ||
© Copyright 2020: Zoephix. | ||
You are allowed to use, modify and redistribute this script. | ||
However, you are not allowed to sell this script nor profit from this script in any way. | ||
You are not allowed to claim this script as being your own work, do not remove the credits. ]] | ||
|
||
ix.util.Include("cl_plugin.lua") | ||
ix.util.Include("sv_plugin.lua") | ||
|
||
ix.lang.AddTable("english", { | ||
cmdCharDetDesc = "Sets your detailed description.", | ||
cmdSelfExamine = "Examines your detailed description.", | ||
}) | ||
|
||
ix.lang.AddTable("dutch", { | ||
cmdCharDetDesc = "Stelt je gedetailleerde beschrijving in.", | ||
cmdSelfExamine = "Examineert je gedetailleerde beschrijving.", | ||
}) | ||
|
||
ix.command.Add("SelfExamine", { | ||
description = "@cmdSelfExamine", | ||
adminOnly = true, | ||
OnRun = function(self, client, text, scale) | ||
local textEntryData = client:GetCharacter():GetData("textDetDescData", nil) or "No detailed description found." | ||
local textEntryDataURL = client:GetCharacter():GetData("textDetDescDataURL", nil) or "No detailed description found." | ||
|
||
net.Start("ixOpenDetailedDescriptions") | ||
net.WriteEntity(client) | ||
net.WriteString(textEntryData) | ||
net.WriteString(textEntryDataURL) | ||
net.Send(client) | ||
end | ||
}) | ||
|
||
ix.command.Add("CharDetDesc", { | ||
description = "@cmdCharDetDesc", | ||
adminOnly = true, | ||
OnRun = function(self, client, text, scale) | ||
net.Start("ixSetDetailedDescriptions") | ||
net.WriteString(client:SteamName()) | ||
net.Send(client) | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
util.AddNetworkString("ixOpenDetailedDescriptions") | ||
util.AddNetworkString("ixSetDetailedDescriptions") | ||
util.AddNetworkString("ixEditDetailedDescriptions") | ||
|
||
net.Receive("ixEditDetailedDescriptions", function() | ||
local textEntryURL = net.ReadString() | ||
local text = net.ReadString() | ||
local callingClientSteamName = net.ReadString() | ||
|
||
for key, client in pairs(player.GetAll()) do | ||
if client:SteamName() == callingClientSteamName then | ||
client:GetCharacter():SetData("textDetDescData", text) | ||
client:GetCharacter():SetData("textDetDescDataURL", textEntryURL) | ||
end | ||
end | ||
end) | ||
|
||
function PLUGIN:OnPlayerOptionSelected(client, callingClient, option) | ||
if (option == "Examine") then | ||
local textEntryData = client:GetCharacter():GetData("textDetDescData", nil) or "No detailed description found." | ||
local textEntryDataURL = client:GetCharacter():GetData("textDetDescDataURL", nil) or "No detailed description found." | ||
|
||
net.Start("ixOpenDetailedDescriptions") | ||
net.WriteEntity(client) | ||
net.WriteString(textEntryData) | ||
net.WriteString(textEntryDataURL) | ||
net.Send(callingClient) | ||
end | ||
end |