|
|
@ -113,13 +113,7 @@ function init()
|
|
|
|
local tab = consoleTabBar:getCurrentTab()
|
|
|
|
local tab = consoleTabBar:getCurrentTab()
|
|
|
|
if not tab then return false end
|
|
|
|
if not tab then return false end
|
|
|
|
|
|
|
|
|
|
|
|
local consoleBuffer = tab.tabPanel:getChildById('consoleBuffer')
|
|
|
|
g_window.setClipboardText(selectioText)
|
|
|
|
if not consoleBuffer then return false end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local consoleLabel = consoleBuffer:getFocusedChild()
|
|
|
|
|
|
|
|
if not consoleLabel then return false end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_window.setClipboardText(getSelection(consoleLabel))
|
|
|
|
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -147,31 +141,12 @@ function init()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function getSelection(widget)
|
|
|
|
function clearSelection(consoleBuffer)
|
|
|
|
if not widget.selection then
|
|
|
|
for _,label in pairs(consoleBuffer:getChildren()) do
|
|
|
|
return widget:getSelection()
|
|
|
|
label:clearSelection()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local text = {}
|
|
|
|
|
|
|
|
for selectionChild = widget.selection.first, widget.selection.last do
|
|
|
|
|
|
|
|
local label = widget:getParent():getChildByIndex(selectionChild)
|
|
|
|
|
|
|
|
table.insert(text, label:getSelection())
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return table.concat(text, '\r\n')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function invalidateSelection(widget)
|
|
|
|
|
|
|
|
local parent = widget:getParent()
|
|
|
|
|
|
|
|
if widget.selection then
|
|
|
|
|
|
|
|
for selectionChild = widget.selection.first, widget.selection.last do
|
|
|
|
|
|
|
|
local label = parent:getChildByIndex(selectionChild)
|
|
|
|
|
|
|
|
if label ~= widget then
|
|
|
|
|
|
|
|
label:clearSelection()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
widget.selection = nil
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
consoleBuffer.selectionText = nil
|
|
|
|
|
|
|
|
consoleBuffer.selection = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function toggleChat()
|
|
|
|
function toggleChat()
|
|
|
@ -604,49 +579,76 @@ function addTabText(text, speaktype, tab, creatureName)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
label.name = creatureName
|
|
|
|
label.name = creatureName
|
|
|
|
|
|
|
|
consoleBuffer.onMouseRelease = function(self, mousePos, mouseButton)
|
|
|
|
|
|
|
|
processMessageMenu(mousePos, mouseButton, nil, nil, nil, tab)
|
|
|
|
|
|
|
|
end
|
|
|
|
label.onMouseRelease = function(self, mousePos, mouseButton)
|
|
|
|
label.onMouseRelease = function(self, mousePos, mouseButton)
|
|
|
|
-- TODO: regain lost selection
|
|
|
|
|
|
|
|
processMessageMenu(mousePos, mouseButton, creatureName, text, self, tab)
|
|
|
|
processMessageMenu(mousePos, mouseButton, creatureName, text, self, tab)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
label.onFocusChange = function(self, focused, reason)
|
|
|
|
|
|
|
|
-- TODO: we are losing focus on context menu and therefore the selection
|
|
|
|
|
|
|
|
if not focused then invalidateSelection(self) end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
label.onMousePress = function(self, mousePos, button)
|
|
|
|
label.onMousePress = function(self, mousePos, button)
|
|
|
|
if button == MouseLeftButton then invalidateSelection(self) end
|
|
|
|
if button == MouseLeftButton then clearSelection(consoleBuffer) end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
label.onMouseMove = function(self, mousePos, mouseMoved)
|
|
|
|
label.onDragEnter = function(self, mousePos)
|
|
|
|
if self:isPressed() then
|
|
|
|
clearSelection(consoleBuffer)
|
|
|
|
local parent = self:getParent()
|
|
|
|
return true
|
|
|
|
local selfIndex = parent:getChildIndex(self)
|
|
|
|
end
|
|
|
|
local child = parent:getChildByPos(mousePos)
|
|
|
|
label.onDragLeave = function(self, droppedWidget, mousePos)
|
|
|
|
local childIndex = parent:getChildIndex(child)
|
|
|
|
local text = {}
|
|
|
|
|
|
|
|
for selectionChild = consoleBuffer.selection.first, consoleBuffer.selection.last do
|
|
|
|
-- remove old selection
|
|
|
|
local label = self:getParent():getChildByIndex(selectionChild)
|
|
|
|
invalidateSelection(self)
|
|
|
|
table.insert(text, label:getSelection())
|
|
|
|
|
|
|
|
end
|
|
|
|
-- choose new selection
|
|
|
|
consoleBuffer.selectionText = table.concat(text, '\r\n')
|
|
|
|
if child and child ~= self then
|
|
|
|
return true
|
|
|
|
self.selection = {first = math.min(selfIndex, childIndex), last = math.max(selfIndex, childIndex)}
|
|
|
|
end
|
|
|
|
for selectionChild = self.selection.first + 1, self.selection.last - 1 do
|
|
|
|
label.onDragMove = function(self, mousePos, mouseMoved)
|
|
|
|
parent:getChildByIndex(selectionChild):selectAll()
|
|
|
|
local parent = self:getParent()
|
|
|
|
end
|
|
|
|
local selfIndex = parent:getChildIndex(self)
|
|
|
|
|
|
|
|
local child = parent:getChildByPos(mousePos)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- find out bounds children
|
|
|
|
|
|
|
|
if not child then
|
|
|
|
|
|
|
|
if mousePos.y >= parent:getLastChild():getY() then
|
|
|
|
|
|
|
|
child = parent:getLastChild()
|
|
|
|
|
|
|
|
elseif mousePos.y <= parent:getFirstChild():getY() then
|
|
|
|
|
|
|
|
child = parent:getFirstChild()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local textPos = child:getTextPos(mousePos)
|
|
|
|
if not child then return false end
|
|
|
|
if childIndex > selfIndex then
|
|
|
|
|
|
|
|
child:setSelection(0, textPos)
|
|
|
|
local childIndex = parent:getChildIndex(child)
|
|
|
|
else
|
|
|
|
|
|
|
|
child:setSelection(string.len(child:getText()), textPos)
|
|
|
|
-- remove old selection
|
|
|
|
end
|
|
|
|
clearSelection(consoleBuffer)
|
|
|
|
elseif not child then
|
|
|
|
|
|
|
|
-- TODO: out of bonding rect selection
|
|
|
|
-- update self selection
|
|
|
|
|
|
|
|
local textBegin = self:getTextPos(self:getLastClickPosition())
|
|
|
|
|
|
|
|
local textPos = self:getTextPos(mousePos)
|
|
|
|
|
|
|
|
self:setSelection(textBegin, textPos)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consoleBuffer.selection = { first = math.min(selfIndex, childIndex), last = math.max(selfIndex, childIndex) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- update siblings selection
|
|
|
|
|
|
|
|
if child ~= self then
|
|
|
|
|
|
|
|
for selectionChild = consoleBuffer.selection.first + 1, consoleBuffer.selection.last - 1 do
|
|
|
|
|
|
|
|
parent:getChildByIndex(selectionChild):selectAll()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local textPos = child:getTextPos(mousePos)
|
|
|
|
|
|
|
|
if childIndex > selfIndex then
|
|
|
|
|
|
|
|
child:setSelection(0, textPos)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
child:setSelection(string.len(child:getText()), textPos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if consoleBuffer:getChildCount() > MAX_LINES then
|
|
|
|
if consoleBuffer:getChildCount() > MAX_LINES then
|
|
|
|
local child = consoleBuffer:getFirstChild()
|
|
|
|
local child = consoleBuffer:getFirstChild()
|
|
|
|
if child.selection then invalidateSelection(child) end
|
|
|
|
clearSelection(consoleBuffer)
|
|
|
|
child:destroy()
|
|
|
|
child:destroy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -709,13 +711,15 @@ function processMessageMenu(mousePos, mouseButton, creatureName, text, label, ta
|
|
|
|
|
|
|
|
|
|
|
|
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
|
|
|
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local selectedText = getSelection(label)
|
|
|
|
local selection = tab.tabPanel:getChildById('consoleBuffer').selectionText
|
|
|
|
if #selectedText > 0 then
|
|
|
|
if selection and #selection > 0 then
|
|
|
|
menu:addOption(tr('Copy'), function() g_window.setClipboardText(selectedText) end, '(Ctrl+C)')
|
|
|
|
menu:addOption(tr('Copy'), function() g_window.setClipboardText(selection) end, '(Ctrl+C)')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if text then
|
|
|
|
|
|
|
|
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
|
|
|
--menu:addOption(tr('Select all'), function() label:selectAll() end)
|
|
|
|
menu:addOption(tr('Select all'), function() label:selectAll() end)
|
|
|
|
if tab.violations and creatureName then
|
|
|
|
if tab.violations then
|
|
|
|
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addOption(tr('Process') .. ' ' .. creatureName, function() processViolation(creatureName, text) end)
|
|
|
|
menu:addOption(tr('Process') .. ' ' .. creatureName, function() processViolation(creatureName, text) end)
|
|
|
|
menu:addOption(tr('Remove') .. ' ' .. creatureName, function() g_game.closeRuleViolation(creatureName) end)
|
|
|
|
menu:addOption(tr('Remove') .. ' ' .. creatureName, function() g_game.closeRuleViolation(creatureName) end)
|
|
|
|