Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to strip advanced copy paste info out #8344

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@
if not slot.nodeId then
t_insert(child, { elem = "Slot", attrib = { name = slotName, itemId = tostring(itemSet[slotName].selItemId), itemPbURL = itemSet[slotName].pbURL or "", active = itemSet[slotName].active and "true" }})
else
if self.build.spec.allocNodes[slot.nodeId] then

Check warning on line 1101 in src/Classes/ItemsTab.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (alloc)
t_insert(child, { elem = "SocketIdURL", attrib = { name = slotName, nodeId = tostring(slot.nodeId), itemPbURL = itemSet[slot.nodeId] and itemSet[slot.nodeId].pbURL or ""}})
end
end
Expand Down Expand Up @@ -1170,13 +1170,28 @@
if event.type == "KeyDown" then
if event.key == "v" and IsKeyDown("CTRL") then
local newItem = Paste()
if newItem:find("{ ", 0, true) then
main:OpenConfirmPopup("Warning", "\"Advanced Item Descriptions\" (Ctrl+Alt+c) are unsupported.\n\nAbort paste?", "OK", function()
self:SetDisplayItem()
end)
end
if newItem then
self:CreateDisplayItemFromRaw(newItem, true)
if newItem:find("{ ", 0, true) then
local controls = { }
controls.label = new("LabelControl", nil, {0, 40, 0, 16}, "^7\"Advanced Item Descriptions\" (Ctrl+Alt+c) are unsupported.")
-- \n\nIf this is not an advanced item copy paste or if you wish to proceed anyway click proceed.\n\nOr you can remove the advanced info from the item and paste as a normal item.
controls.close = new("ButtonControl", nil, {-175, 90, 150, 20}, "^7Proceed Anyway", function()
self:CreateDisplayItemFromRaw(newItem, true)
main:ClosePopup()
end)
controls.strip = new("ButtonControl", nil, {0, 90, 150, 20}, "^7Remove Advanced Info", function()
newItem = itemLib.stripAdvancedCopyPaste(newItem)
self:CreateDisplayItemFromRaw(newItem, true)
main:ClosePopup()
end)
controls.abort = new("ButtonControl", nil, {175, 90, 150, 20}, "^7Abort", function()
self:SetDisplayItem()
main:ClosePopup()
end)
main:OpenPopup(560, 120, "Warning", controls)
else
self:CreateDisplayItemFromRaw(newItem, true)
end
end
elseif event.key == "e" then
local mOverControl = self:GetMouseOverControl()
Expand Down Expand Up @@ -1346,7 +1361,7 @@
-- Build a list of active sockets
local activeSocketList = { }
for nodeId, slot in pairs(self.sockets) do
if self.build.spec.allocNodes[nodeId] then

Check warning on line 1364 in src/Classes/ItemsTab.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (alloc)
t_insert(activeSocketList, nodeId)
slot.inactive = false
else
Expand Down Expand Up @@ -1492,10 +1507,10 @@
-- Deallocate all nodes that required this jewel
if spec.nodes[nodeId] then
for depNodeId, depNode in ipairs(spec.nodes[nodeId].depends) do
depNode.alloc = false

Check warning on line 1510 in src/Classes/ItemsTab.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (alloc)
spec.allocNodes[depNodeId] = nil

Check warning on line 1511 in src/Classes/ItemsTab.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (alloc)
end
spec.nodes[nodeId].alloc = false

Check warning on line 1513 in src/Classes/ItemsTab.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (alloc)
spec.allocNodes[nodeId] = nil
end
end
Expand Down
31 changes: 31 additions & 0 deletions src/Modules/ItemTools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,37 @@ function itemLib.formatModLine(modLine, dbMode)
return colorCode..line
end

function itemLib.stripAdvancedCopyPaste(rawItem)
local rawLines = {}
for line in rawItem:gmatch("%s*([^\n]*%S)") do
t_insert(rawLines, line)
end
local line = 1
local newItem = ""
while rawLines[line] do
if rawLines[line]:match("^{ .*}") and rawLines[line+1] then
local line2 = line + 1
while rawLines[line2] and not rawLines[line2]:match("^{ .*}") and not (rawLines[line2] == "--------") do
if rawLines[line2]:match("^%(.*%)") then
rawLines[line2] = ""
else
rawLines[line2] = rawLines[line2]:gsub(" — Unscalable Value", ""):gsub(" %- Unscalable Value", "")
local val, range = rawLines[line2]:gsub("%-","%%%-"):match("(.*)%((.*)%)[ %%]")
while range do
rawLines[line2] = rawLines[line2]:gsub("%("..range.."%)","")
val, range = rawLines[line2]:gsub("%-","%%%-"):match("(.*)%((.*)%)[ %%]")
end
end
line2 = line2 + 1
end
else
newItem = newItem..rawLines[line]..(rawLines[line+1] and "\n" or "")
end
line = line + 1
end
return newItem
end

itemLib.wiki = {
key = "F1",
openGem = function(gemData)
Expand Down
Loading