From 3e0efec9343f6a63d092e773a9368e43d770e625 Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Wed, 4 Jun 2025 03:50:32 -0500 Subject: [PATCH 01/10] Search for .dat files --- src/Export/Classes/DatListControl.lua | 21 ++++++++++++++++++++- src/Export/Main.lua | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Export/Classes/DatListControl.lua b/src/Export/Classes/DatListControl.lua index 57ceafe00f..17be745728 100644 --- a/src/Export/Classes/DatListControl.lua +++ b/src/Export/Classes/DatListControl.lua @@ -4,9 +4,28 @@ -- Dat list control. -- local DatListClass = newClass("DatListControl", "ListControl", function(self, anchor, rect) - self.ListControl(anchor, rect, 14, "VERTICAL", false, main.datFileList) + self.originalList = main.datFileList + self.searchBuf = "" + self.filteredList = self.originalList + self.ListControl(anchor, rect, 14, "VERTICAL", false, self.filteredList) end) +function DatListClass:BuildFilteredList() + local search = self.searchBuf:lower() + if search == "" then + self.filteredList = self.originalList + else + self.filteredList = {} + for _, file in ipairs(self.originalList) do + if file.name:lower():find(search, 1, true) then + table.insert(self.filteredList, file) + end + end + end + self.list = self.filteredList + --self:SelectIndex(1) +end + function DatListClass:GetRowValue(column, index, datFile) if column == 1 then return "^7"..datFile.name diff --git a/src/Export/Main.lua b/src/Export/Main.lua index a15701eed3..394b1891db 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -222,7 +222,12 @@ function main:Init() end } - self.controls.datList = new("DatListControl", nil, {10, 70, 250, function() return self.screenH - 70 end}) + self.controls.datSearch = new("EditControl", {"TOPLEFT",self.controls.datSource,"BOTTOMLEFT"}, {0, 2, 250, 18}, nil, "^8Search .dat files", nil, nil, function(buf) + self.controls.datList.searchBuf = buf + self.controls.datList:BuildFilteredList() + end) + + self.controls.datList = new("DatListControl", {"TOPLEFT",self.controls.datSearch,"BOTTOMLEFT"}, {0, 2, 250, function() return self.screenH - 100 end}) self.controls.specEditToggle = new("ButtonControl", nil, {270, 10, 100, 18}, function() return self.editSpec and "Done <<" or "Edit >>" end, function() self.editSpec = not self.editSpec From 86804aedd18276668faf3fbb802cab8510b2af1c Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Wed, 4 Jun 2025 07:33:51 -0500 Subject: [PATCH 02/10] Highlight selected column, and sort by clicking column header --- src/Classes/ListControl.lua | 4 +- src/Export/Classes/RowListControl.lua | 166 +++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 4 deletions(-) diff --git a/src/Classes/ListControl.lua b/src/Classes/ListControl.lua index ebc8287c50..34dd0e7f41 100644 --- a/src/Classes/ListControl.lua +++ b/src/Classes/ListControl.lua @@ -346,10 +346,12 @@ function ListClass:OnKeyDown(key, doubleClick) newSelect = index end else + local scrollOffsetH = self.controls.scrollBarH.offset for colIndex, column in ipairs(self.colList) do local relX = cursorX - (x + 2) local relY = cursorY - (y + 2) - local mOver = relX >= column._offset and relX <= column._offset + column._width and relY >= 0 and relY <= 18 + local adjustedRelX = relX + scrollOffsetH + local mOver = adjustedRelX >= column._offset and adjustedRelX <= column._offset + column._width and relY >= 0 and relY <= 18 if self:GetColumnProperty(column, "sortable") and mOver and self.ReSort then self:ReSort(colIndex) end diff --git a/src/Export/Classes/RowListControl.lua b/src/Export/Classes/RowListControl.lua index fe443a6f91..0a5a726c4f 100644 --- a/src/Export/Classes/RowListControl.lua +++ b/src/Export/Classes/RowListControl.lua @@ -44,13 +44,18 @@ end function RowListClass:BuildColumns() wipeTable(self.colList) - self.colList[1] = { width = 50, label = "#", font = "FIXED" } + self.colList[1] = { width = 50, label = "#", font = "FIXED", sortable = true } for _, specCol in ipairs(main.curDatFile.spec) do - t_insert(self.colList, { width = specCol.width, label = specCol.name, font = function() return IsKeyDown("CTRL") and "FIXED" or "VAR" end }) + t_insert(self.colList, { + width = specCol.width, + label = specCol.name, + font = function() return IsKeyDown("CTRL") and "FIXED" or "VAR" end, + sortable = true -- or false, as needed + }) end local short = main.curDatFile.rowSize - main.curDatFile.specSize if short > 0 then - t_insert(self.colList, { width = short * DrawStringWidth(self.rowHeight, "FIXED", "00 "), font = "FIXED" }) + t_insert(self.colList, { width = short * DrawStringWidth(self.rowHeight, "FIXED", "00 "), font = "FIXED", sortable = true }) end end @@ -76,3 +81,158 @@ function RowListClass:GetRowValue(column, index, row) end end end + +function RowListClass:Draw(viewPort) + local x, y = self:GetPos() + local width, height = self:GetSize() + local rowHeight = self.rowHeight + local list = self.list + + local colOffset = 0 + for index, column in ipairs(self.colList) do + column._offset = colOffset + column._width = self:GetColumnProperty(column, "width") or (index == #self.colList and self.scroll and width - 20 or width - colOffset) or 0 + colOffset = colOffset + column._width + end + + local scrollBarV = self.controls.scrollBarV + local rowRegion = self:GetRowRegion() + scrollBarV:SetContentDimension(#list * rowHeight, rowRegion.height) + local scrollOffsetV = scrollBarV.offset + local scrollBarH = self.controls.scrollBarH + local lastCol = self.colList[#self.colList] + scrollBarH:SetContentDimension(lastCol._offset + lastCol._width, rowRegion.width) + local scrollOffsetH = scrollBarH.offset + + local cursorX, cursorY = GetCursorPos() + + local label = self:GetProperty("label") + if label then + DrawString(x + self.labelPositionOffset[1], y - 20 + self.labelPositionOffset[2], "LEFT", 16, self.font, label) + end + if self.hasFocus then + SetDrawColor(1, 1, 1) + else + SetDrawColor(0.5, 0.5, 0.5) + end + DrawImage(nil, x, y, width, height) + SetDrawColor(0, 0, 0) + DrawImage(nil, x + 1, y + 1, width - 2, height - 2) + self:DrawControls(viewPort) + + SetViewport(x + 2, y + 2, self.scroll and width - 20 or width, height - 4 - (self.scroll and self.scrollH and 16 or 0)) + local textOffsetY = self.showRowSeparators and 2 or 0 + local textHeight = rowHeight - textOffsetY * 2 + local minIndex = math.floor(scrollOffsetV / rowHeight + 1) + local maxIndex = math.min(math.floor((scrollOffsetV + height) / rowHeight + 1), #list) + for colIndex, column in ipairs(self.colList) do + local colFont = self:GetColumnProperty(column, "font") or "VAR" + local clipWidth = DrawStringWidth(textHeight, colFont, "...") + colOffset = column._offset - scrollOffsetH + local colWidth = column._width + local relX = cursorX - (x + 2) + local relY = cursorY - (y + 2) + for index = minIndex, maxIndex do + local lineY = rowHeight * (index - 1) - scrollOffsetV + (self.colLabels and 18 or 0) + local value = list[index] + local text = self:GetRowValue(colIndex, index, value) + local textWidth = DrawStringWidth(textHeight, colFont, text) + if textWidth > colWidth - 2 then + local clipIndex = DrawStringCursorIndex(textHeight, colFont, text, colWidth - clipWidth - 2, 0) + text = text:sub(1, clipIndex - 1) .. "..." + textWidth = DrawStringWidth(textHeight, colFont, text) + end + if self.showRowSeparators then + if self.hasFocus and value == self.selValue then + SetDrawColor(1, 1, 1) + else + SetDrawColor(0.5, 0.5, 0.5) + end + DrawImage(nil, colOffset, lineY, not self.scroll and colWidth - 4 or colWidth, rowHeight) + if index % 2 == 0 then + SetDrawColor(0.05, 0.05, 0.05) + else + SetDrawColor(0, 0, 0) + end + DrawImage(nil, colOffset, lineY + 1, not self.scroll and colWidth - 4 or colWidth, rowHeight - 2) + elseif value == self.selValue then + if self.hasFocus and value == self.selValue then + SetDrawColor(1, 1, 1) + else + SetDrawColor(0.5, 0.5, 0.5) + end + DrawImage(nil, colOffset, lineY, not self.scroll and colWidth - 4 or colWidth, rowHeight) + SetDrawColor(0.15, 0.15, 0.15) + DrawImage(nil, colOffset, lineY + 1, not self.scroll and colWidth - 4 or colWidth, rowHeight - 2) + end + if not self.SetHighlightColor or not self:SetHighlightColor(index, value) then + SetDrawColor(1, 1, 1) + end + DrawString(colOffset, lineY + textOffsetY, "LEFT", textHeight, colFont, text) + end + if self.colLabels then + local mOver = relX >= colOffset and relX <= colOffset + colWidth and relY >= 0 and relY <= 18 + + local isSelected = (colIndex - 1) == main.curSpecColIndex + local outerColor + if mOver then + outerColor = {1, 1, 1} + elseif isSelected then + outerColor = {1, 0.3, 0.2} + else + outerColor = {0.5, 0.5, 0.5} + end + local innerColor = isSelected and {0.6, 0.25, 0.2} or (mOver and self:GetColumnProperty(column, "sortable") and {0.33, 0.33, 0.33} or {0.15, 0.15, 0.15}) + + SetDrawColor(unpack(outerColor)) + DrawImage(nil, colOffset, 1, colWidth, 18) + SetDrawColor(unpack(innerColor)) + DrawImage(nil, colOffset + 1, 2, colWidth - 2, 16) + + local label = self:GetColumnProperty(column, "label") + if label and #label > 0 then + SetDrawColor(1, 1, 1) + DrawString(colOffset + colWidth/2, 4, "CENTER_X", 12, "VAR", label) + end + end + end + if #self.list == 0 and self.defaultText then + SetDrawColor(1, 1, 1) + DrawString(2, 2, "LEFT", 14, self.font, self.defaultText) + end + SetViewport() +end + +function RowListClass:ReSort(colIndex) + local asc = true + if self.lastSortedCol == colIndex then + asc = not self.sortAsc + end + + table.sort(self.list, function(a, b) + local valA = self:GetRowValue(colIndex, nil, a) + local valB = self:GetRowValue(colIndex, nil, b) + + local numA = tonumber(valA) + local numB = tonumber(valB) + + if numA and numB then + if asc then + return numA < numB + else + return numA > numB + end + else + valA = tostring(valA or "") + valB = tostring(valB or "") + if asc then + return valA < valB + else + return valA > valB + end + end + end) + + self.lastSortedCol = colIndex + self.sortAsc = asc +end From 6c7bbf30857e2b6452e0be3d716ebd67a3e63f36 Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Wed, 4 Jun 2025 07:43:02 -0500 Subject: [PATCH 03/10] removed comments --- src/Export/Classes/DatListControl.lua | 1 - src/Export/Classes/RowListControl.lua | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Export/Classes/DatListControl.lua b/src/Export/Classes/DatListControl.lua index 17be745728..e1153982d9 100644 --- a/src/Export/Classes/DatListControl.lua +++ b/src/Export/Classes/DatListControl.lua @@ -23,7 +23,6 @@ function DatListClass:BuildFilteredList() end end self.list = self.filteredList - --self:SelectIndex(1) end function DatListClass:GetRowValue(column, index, datFile) diff --git a/src/Export/Classes/RowListControl.lua b/src/Export/Classes/RowListControl.lua index 0a5a726c4f..368bb1bf2a 100644 --- a/src/Export/Classes/RowListControl.lua +++ b/src/Export/Classes/RowListControl.lua @@ -50,7 +50,7 @@ function RowListClass:BuildColumns() width = specCol.width, label = specCol.name, font = function() return IsKeyDown("CTRL") and "FIXED" or "VAR" end, - sortable = true -- or false, as needed + sortable = true }) end local short = main.curDatFile.rowSize - main.curDatFile.specSize From 2be02bcd35db589322bde92a519549cd9e29676a Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Thu, 5 Jun 2025 01:54:54 -0500 Subject: [PATCH 04/10] Resize columns with scroll wheel and middle click when hovering column header --- src/Export/Classes/RowListControl.lua | 112 ++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/src/Export/Classes/RowListControl.lua b/src/Export/Classes/RowListControl.lua index 368bb1bf2a..a79fd6ee58 100644 --- a/src/Export/Classes/RowListControl.lua +++ b/src/Export/Classes/RowListControl.lua @@ -9,6 +9,7 @@ local t_insert = table.insert local RowListClass = newClass("RowListControl", "ListControl", function(self, anchor, rect) self.ListControl(anchor, rect, 14, "HORIZONTAL", false, { }) self.colLabels = true + self._autoSizeToggleState = {} -- internal toggle memory, not saved to spec end) function RowListClass:BuildRows(filter) @@ -48,6 +49,7 @@ function RowListClass:BuildColumns() for _, specCol in ipairs(main.curDatFile.spec) do t_insert(self.colList, { width = specCol.width, + specColRef = specCol, -- Link to the original data label = specCol.name, font = function() return IsKeyDown("CTRL") and "FIXED" or "VAR" end, sortable = true @@ -236,3 +238,113 @@ function RowListClass:ReSort(colIndex) self.lastSortedCol = colIndex self.sortAsc = asc end + +function RowListClass:OnKeyUp(key, doubleClick) + if not self:IsShown() or not self:IsEnabled() then + return + end + + local function isScrollKey(k) + if k == "WHEELUP" then return true, -1, 10 end + if k == "WHEELDOWN" then return true, 1, -10 end + return false, 0, 0 + end + + local mOverControl = self:GetMouseOverControl() + if mOverControl and mOverControl.OnKeyDown then + return mOverControl:OnKeyDown(key) + end + + if not self:IsMouseOver() and key:match("BUTTON") then + return + end + + -- Get cursor info + local x, y = self:GetPos() + local cursorX, cursorY = GetCursorPos() + local scrollOffsetH = self.controls.scrollBarH and self.controls.scrollBarH.offset or 0 + local relX = cursorX - (x + 2) + local relY = cursorY - (y + 2) + local adjustedRelX = relX + scrollOffsetH + + -- Middle-click resets column width + if key == "MIDDLEBUTTON" then + for colIndex, column in ipairs(self.colList) do + local colOffset = column._offset + local colWidth = column.width or column._width + if colOffset and colWidth then + local mOver = adjustedRelX >= colOffset and adjustedRelX <= colOffset + colWidth and relY >= 0 and relY <= 18 + if mOver then + -- Initialize if not present + self._autoSizeToggleState[colIndex] = not self._autoSizeToggleState[colIndex] + + local newWidth + if self._autoSizeToggleState[colIndex] then + -- First toggle: size to contents + local maxWidth = 0 + for _, rowIndex in ipairs(self.list) do + local val = self:GetRowValue(colIndex, nil, rowIndex) + if val ~= nil then + local width = DrawStringWidth(self.rowHeight, "FIXED", tostring(val)) + maxWidth = math.max(maxWidth, width) + end + end + local labelWidth = DrawStringWidth(self.rowHeight, "FIXED", tostring(column.label or "")) + newWidth = math.max(40, math.max(maxWidth, labelWidth) + 10) + else + -- Second toggle: reset to label or 150, whichever is greater + local labelWidth = DrawStringWidth(self.rowHeight, "FIXED", tostring(column.label or "")) + newWidth = math.max(150, labelWidth + 10) + end + + column.width = newWidth + + if column.specColRef then + column.specColRef.width = newWidth + main.curSpecCol = column.specColRef + main.controls.colWidth:SetText(newWidth) + end + + self:BuildColumns() + return self + end + end + end + return self + end + -- Scroll behavior + local isScroll, scrollStep, colDelta = isScrollKey(key) + if isScroll then + local overColumnHeader = false + for _, column in ipairs(self.colList) do + local colOffset = column._offset + local colWidth = column.width or column._width + if colOffset and colWidth then + local mOver = adjustedRelX >= colOffset and adjustedRelX <= colOffset + colWidth and relY >= 0 and relY <= 18 + if mOver then + -- Widen column if hovering over it + overColumnHeader = true + local newWidth = math.max(40, colWidth + colDelta) + column.width = newWidth + if column.specColRef then + column.specColRef.width = newWidth + main.curSpecCol = column.specColRef + main.controls.colWidth:SetText(newWidth) + end + self:BuildColumns() + break + end + end + end + -- Scroll vertically or horizontally if not resizing column + if not overColumnHeader then + if self.scroll and self.scrollH and IsKeyDown("SHIFT") then + self.controls.scrollBarH:Scroll(scrollStep) + else + self.controls.scrollBarV:Scroll(scrollStep) + end + end + return self + end + return self +end From 4f86ea4ebbeee48af84164877201ead309badfa5 Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Fri, 6 Jun 2025 09:22:48 -0500 Subject: [PATCH 05/10] Sort blank items at the bottom --- src/Export/Classes/RowListControl.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Export/Classes/RowListControl.lua b/src/Export/Classes/RowListControl.lua index a79fd6ee58..76e3563429 100644 --- a/src/Export/Classes/RowListControl.lua +++ b/src/Export/Classes/RowListControl.lua @@ -215,6 +215,18 @@ function RowListClass:ReSort(colIndex) local valA = self:GetRowValue(colIndex, nil, a) local valB = self:GetRowValue(colIndex, nil, b) + local isBlankA = valA == nil or valA == "" or tostring(valA):match("^%s*$") + local isBlankB = valB == nil or valB == "" or tostring(valB):match("^%s*$") + + -- Always put blank items at the bottom + if isBlankA and not isBlankB then + return false + elseif not isBlankA and isBlankB then + return true + elseif isBlankA and isBlankB then + return false + end + local numA = tonumber(valA) local numB = tonumber(valB) From 37757e0b1c79ed9273d6781466a214e9908dc2da Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Fri, 6 Jun 2025 10:02:42 -0500 Subject: [PATCH 06/10] Ctrl+f to jump to dat search box --- src/Export/Main.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index 394b1891db..36d301b58e 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -591,6 +591,17 @@ function main:SaveSettings() end end +function main:OnKeyDown(key, doubleClick) + -- Ctrl+F shortcut for focusing dat file Search + if key == "f" and IsKeyDown("CTRL") then + if self.controls and self.controls.datSearch and self.SelectControl then + self:SelectControl(self.controls.datSearch) + end + return + end + t_insert(self.inputEvents, { type = "KeyDown", key = key, doubleClick = doubleClick }) +end + function main:DrawArrow(x, y, width, height, dir) local x1 = x - width / 2 local x2 = x + width / 2 From 6b626395e19d6135611df19fd495ffca8a3cf266 Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Fri, 6 Jun 2025 10:18:37 -0500 Subject: [PATCH 07/10] Switch buttons to ALT for raw data. --- src/Export/Classes/RowListControl.lua | 4 ++-- src/Export/Main.lua | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Export/Classes/RowListControl.lua b/src/Export/Classes/RowListControl.lua index 76e3563429..08d1e344dc 100644 --- a/src/Export/Classes/RowListControl.lua +++ b/src/Export/Classes/RowListControl.lua @@ -51,7 +51,7 @@ function RowListClass:BuildColumns() width = specCol.width, specColRef = specCol, -- Link to the original data label = specCol.name, - font = function() return IsKeyDown("CTRL") and "FIXED" or "VAR" end, + font = function() return IsKeyDown("ALT") and "FIXED" or "VAR" end, sortable = true }) end @@ -65,7 +65,7 @@ function RowListClass:GetRowValue(column, index, row) if column == 1 then return string.format("%5d", row) end - if not main.curDatFile.spec[column - 1] or IsKeyDown("CTRL") then + if not main.curDatFile.spec[column - 1] or IsKeyDown("ALT") then local out = { main.curDatFile:ReadCellRaw(row, column - 1) } for i, b in ipairs(out) do out[i] = string.format("%02X", b) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index 36d301b58e..5b047f5f2b 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -324,6 +324,7 @@ function main:Init() } self.controls.filter.tooltipText = "Takes a Lua expression that returns true or false for a row.\nE.g. `Id:match(\"test\")` or for a key column, `Col and Col.Id:match(\"test\")`" self.controls.filterError = new("LabelControl", {"LEFT",self.controls.filter,"RIGHT"}, {4, 2, 0, 14}, "") + self.controls.showRaw = new("LabelControl", {"LEFT",self.controls.filter,"RIGHT"}, {600, 2, 0, 14}, "^7Hold ALT to show raw data.") self.controls.rowList = new("RowListControl", nil, {270, 0, 0, 0}) { y = function() From 5d02bc605ee9b4098065add608476279bfe4343c Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Sat, 7 Jun 2025 01:35:26 -0500 Subject: [PATCH 08/10] Escape button closes dat view so script output is visible --- src/Export/Main.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index 5b047f5f2b..3ba0a79997 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -599,6 +599,12 @@ function main:OnKeyDown(key, doubleClick) self:SelectControl(self.controls.datSearch) end return + -- ESC key closes Dat window so that the script menu is shown. + elseif key == "ESCAPE" then + if self.controls and self.controls.scripts and self.SelectControl then + self:SetCurrentDat() + end + return end t_insert(self.inputEvents, { type = "KeyDown", key = key, doubleClick = doubleClick }) end From 770bc7e9c29fcd9716b0244d26b5a3a89300a44a Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Sat, 7 Jun 2025 06:02:37 -0500 Subject: [PATCH 09/10] Add clear button to search box --- src/Export/Main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index 3ba0a79997..83070d8c48 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -222,10 +222,10 @@ function main:Init() end } - self.controls.datSearch = new("EditControl", {"TOPLEFT",self.controls.datSource,"BOTTOMLEFT"}, {0, 2, 250, 18}, nil, "^8Search .dat files", nil, nil, function(buf) + self.controls.datSearch = new("EditControl", {"TOPLEFT", self.controls.datSource, "BOTTOMLEFT"}, {0, 2, 250, 18}, nil, "^7Search", nil, nil, function(buf) self.controls.datList.searchBuf = buf self.controls.datList:BuildFilteredList() - end) + end, nil, nil, true) self.controls.datList = new("DatListControl", {"TOPLEFT",self.controls.datSearch,"BOTTOMLEFT"}, {0, 2, 250, function() return self.screenH - 100 end}) From c49acaa4bc4940fdfbf8a2569531c8267192e2ba Mon Sep 17 00:00:00 2001 From: Blitz54 Date: Mon, 9 Jun 2025 08:07:24 -0500 Subject: [PATCH 10/10] Auto clear checkbox for script output --- src/Export/Classes/ScriptListControl.lua | 3 ++ src/Export/Main.lua | 36 +++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Export/Classes/ScriptListControl.lua b/src/Export/Classes/ScriptListControl.lua index d31b9da997..048f02544c 100644 --- a/src/Export/Classes/ScriptListControl.lua +++ b/src/Export/Classes/ScriptListControl.lua @@ -15,6 +15,9 @@ end function ScriptListClass:OnSelClick(index, script, doubleClick) if doubleClick then + if main.controls.clearAutoClearOutput.state then + wipeTable(main.scriptOutput) + end local errMsg = PLoadModule("Scripts/"..script..".lua") if errMsg then print(errMsg) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index 83070d8c48..c565200265 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -208,8 +208,10 @@ function main:Init() return #self.scriptOutput > 0 end } - - self.controls.helpText = new("LabelControl", {"TOPLEFT",self.controls.clearOutput,"BOTTOMLEFT"}, {0, 12, 100, 16}, "Press Ctrl+F5 to re-export\ndata from the game") + self.controls.clearAutoClearOutput = new("CheckBoxControl", { "TOPLEFT", self.controls.clearOutput, "BOTTOMLEFT" }, { 120, 10, 20, 20 }, "Auto Clear Output:", function(state) + self.clearAutoClearOutput = state + end, nil, false) + self.controls.helpText = new("LabelControl", {"TOPLEFT",self.controls.clearOutput,"BOTTOMLEFT"}, {0, 42, 100, 16}, "Press Ctrl+F5 to re-export\ndata from the game") self.controls.scriptList = new("ScriptListControl", nil, {270, 35, 100, 300}) { shown = function() @@ -435,6 +437,19 @@ function main:OnFrame() end function main:OnKeyDown(key, doubleClick) + -- Ctrl+F shortcut for focusing dat file Search + if key == "f" and IsKeyDown("CTRL") then + if self.controls and self.controls.datSearch and self.SelectControl then + self:SelectControl(self.controls.datSearch) + end + return + -- ESC key closes Dat window so that the script menu is shown. + elseif key == "ESCAPE" then + if self.controls and self.controls.scripts and self.SelectControl then + self:SetCurrentDat() + end + return + end t_insert(self.inputEvents, { type = "KeyDown", key = key, doubleClick = doubleClick }) end @@ -592,23 +607,6 @@ function main:SaveSettings() end end -function main:OnKeyDown(key, doubleClick) - -- Ctrl+F shortcut for focusing dat file Search - if key == "f" and IsKeyDown("CTRL") then - if self.controls and self.controls.datSearch and self.SelectControl then - self:SelectControl(self.controls.datSearch) - end - return - -- ESC key closes Dat window so that the script menu is shown. - elseif key == "ESCAPE" then - if self.controls and self.controls.scripts and self.SelectControl then - self:SetCurrentDat() - end - return - end - t_insert(self.inputEvents, { type = "KeyDown", key = key, doubleClick = doubleClick }) -end - function main:DrawArrow(x, y, width, height, dir) local x1 = x - width / 2 local x2 = x + width / 2