parent
835adfb4ce
commit
7e01306fc6
|
@ -1,18 +1,10 @@
|
||||||
PopupMenuButton < UIButton
|
PopupMenuButton < UIButton
|
||||||
height: 18
|
height: 18
|
||||||
margin-left: 5
|
|
||||||
margin-right: 5
|
|
||||||
margin-top: 1
|
|
||||||
margin-bottom: 1
|
|
||||||
size: 0 21
|
size: 0 21
|
||||||
text-offset: 0 0
|
text-offset: 4 0
|
||||||
|
text-align: left
|
||||||
font: verdana-11px-antialised
|
font: verdana-11px-antialised
|
||||||
|
|
||||||
image-source: /images/ui/button_popupmenu
|
|
||||||
image-color: white
|
|
||||||
image-clip: 0 0 20 20
|
|
||||||
image-border: 2
|
|
||||||
|
|
||||||
color: #aaaaaa
|
color: #aaaaaa
|
||||||
background-color: alpha
|
background-color: alpha
|
||||||
|
|
||||||
|
@ -24,6 +16,13 @@ PopupMenuButton < UIButton
|
||||||
$disabled:
|
$disabled:
|
||||||
color: #555555
|
color: #555555
|
||||||
|
|
||||||
|
PopupMenuShortcutLabel < Label
|
||||||
|
font: verdana-11px-antialised
|
||||||
|
text-align: right
|
||||||
|
anchors.fill: parent
|
||||||
|
margin-right: 2
|
||||||
|
margin-left: 5
|
||||||
|
|
||||||
PopupMenuSeparator < UIWidget
|
PopupMenuSeparator < UIWidget
|
||||||
margin-left: 2
|
margin-left: 2
|
||||||
margin-right: 2
|
margin-right: 2
|
||||||
|
@ -39,5 +38,4 @@ PopupMenu < UIPopupMenu
|
||||||
width: 50
|
width: 50
|
||||||
image-source: /images/ui/menubox
|
image-source: /images/ui/menubox
|
||||||
image-border: 3
|
image-border: 3
|
||||||
padding-top: 3
|
padding: 3
|
||||||
padding-bottom: 3
|
|
||||||
|
|
|
@ -33,11 +33,23 @@ function UIPopupMenu:display(pos)
|
||||||
currentMenu = self
|
currentMenu = self
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIPopupMenu:onGeometryChange()
|
function UIPopupMenu:onGeometryChange(oldRect, newRect)
|
||||||
|
local parent = self:getParent()
|
||||||
|
if not parent then return end
|
||||||
|
local ymax = parent:getY() + parent:getHeight()
|
||||||
|
local xmax = parent:getX() + parent:getWidth()
|
||||||
|
if newRect.y + newRect.height > ymax then
|
||||||
|
local newy = newRect.y - newRect.height
|
||||||
|
if newy > 0 and newy + newRect.height < ymax then self:setY(newy) end
|
||||||
|
end
|
||||||
|
if newRect.x + newRect.width > xmax then
|
||||||
|
local newx = newRect.x - newRect.width
|
||||||
|
if newx > 0 and newx + newRect.width < xmax then self:setX(newx) end
|
||||||
|
end
|
||||||
self:bindRectToParent()
|
self:bindRectToParent()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIPopupMenu:addOption(optionName, optionCallback)
|
function UIPopupMenu:addOption(optionName, optionCallback, shortcut)
|
||||||
local optionWidget = g_ui.createWidget(self:getStyleName() .. 'Button', self)
|
local optionWidget = g_ui.createWidget(self:getStyleName() .. 'Button', self)
|
||||||
local lastOptionWidget = self:getLastChild()
|
local lastOptionWidget = self:getLastChild()
|
||||||
optionWidget.onClick = function(self)
|
optionWidget.onClick = function(self)
|
||||||
|
@ -46,6 +58,13 @@ function UIPopupMenu:addOption(optionName, optionCallback)
|
||||||
end
|
end
|
||||||
optionWidget:setText(optionName)
|
optionWidget:setText(optionName)
|
||||||
local width = optionWidget:getTextSize().width + optionWidget:getMarginLeft() + optionWidget:getMarginRight() + 15
|
local width = optionWidget:getTextSize().width + optionWidget:getMarginLeft() + optionWidget:getMarginRight() + 15
|
||||||
|
|
||||||
|
if shortcut then
|
||||||
|
local shortcutLabel = g_ui.createWidget(self:getStyleName() .. 'ShortcutLabel', optionWidget)
|
||||||
|
shortcutLabel:setText(shortcut)
|
||||||
|
width = width + shortcutLabel:getTextSize().width + shortcutLabel:getMarginLeft() + shortcutLabel:getMarginRight()
|
||||||
|
end
|
||||||
|
|
||||||
self:setWidth(math.max(self:getWidth(), width))
|
self:setWidth(math.max(self:getWidth(), width))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,7 @@ function addTabText(text, speaktype, tab, creatureName)
|
||||||
end
|
end
|
||||||
|
|
||||||
label.onMouseRelease = function (self, mousePos, mouseButton)
|
label.onMouseRelease = function (self, mousePos, mouseButton)
|
||||||
processMessageMenu(mousePos, mouseButton, creatureName, text)
|
processMessageMenu(mousePos, mouseButton, creatureName, text, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if consoleBuffer:getChildCount() > MAX_LINES then
|
if consoleBuffer:getChildCount() > MAX_LINES then
|
||||||
|
@ -460,7 +460,7 @@ function processChannelTabMenu(tab, mousePos, mouseButton)
|
||||||
menu:display(mousePos)
|
menu:display(mousePos)
|
||||||
end
|
end
|
||||||
|
|
||||||
function processMessageMenu(mousePos, mouseButton, creatureName, text)
|
function processMessageMenu(mousePos, mouseButton, creatureName, text, label)
|
||||||
if mouseButton == MouseRightButton then
|
if mouseButton == MouseRightButton then
|
||||||
local menu = g_ui.createWidget('PopupMenu')
|
local menu = g_ui.createWidget('PopupMenu')
|
||||||
if creatureName then
|
if creatureName then
|
||||||
|
@ -481,20 +481,18 @@ function processMessageMenu(mousePos, mouseButton, creatureName, text)
|
||||||
end
|
end
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
end
|
end
|
||||||
--TODO select all
|
|
||||||
menu:addOption(tr('Copy message'), function () g_window.setClipboardText(text) end)
|
|
||||||
|
|
||||||
if modules.game_ruleviolation.hasWindowAccess() then
|
if modules.game_ruleviolation.hasWindowAccess() then
|
||||||
menu:addSeparator()
|
|
||||||
menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureName, text:match('.+%:%s(.+)')) end)
|
menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureName, text:match('.+%:%s(.+)')) end)
|
||||||
|
menu:addSeparator()
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:addSeparator()
|
|
||||||
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
||||||
else
|
|
||||||
--TODO select all
|
|
||||||
menu:addOption(tr('Copy message'), function () g_window.setClipboardText(text) end)
|
|
||||||
end
|
end
|
||||||
|
if label:hasSelection() then
|
||||||
|
menu:addOption(tr('Copy'), function() g_window.setClipboardText(label:getSelection()) end, '(Ctrl+C)')
|
||||||
|
end
|
||||||
|
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
||||||
|
menu:addOption(tr('Select all'), function() label:selectAll() end)
|
||||||
menu:display(mousePos)
|
menu:display(mousePos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -344,24 +344,28 @@ end
|
||||||
function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||||
if not g_game.isOnline() then return end
|
if not g_game.isOnline() then return end
|
||||||
local menu = g_ui.createWidget('PopupMenu')
|
local menu = g_ui.createWidget('PopupMenu')
|
||||||
|
local classic = modules.client_options.getOption('classicControl')
|
||||||
|
local shortcut = nil
|
||||||
|
|
||||||
|
if not classic then shortcut = '(Shift)' else shortcut = nil end
|
||||||
if lookThing then
|
if lookThing then
|
||||||
menu:addOption(tr('Look'), function() g_game.look(lookThing) end)
|
menu:addOption(tr('Look'), function() g_game.look(lookThing) end, shortcut)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not classic then shortcut = '(Ctrl)' else shortcut = nil end
|
||||||
if useThing then
|
if useThing then
|
||||||
if useThing:isContainer() then
|
if useThing:isContainer() then
|
||||||
if useThing:getParentContainer() then
|
if useThing:getParentContainer() then
|
||||||
menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end)
|
menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end, shortcut)
|
||||||
menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
|
menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
|
||||||
else
|
else
|
||||||
menu:addOption(tr('Open'), function() g_game.open(useThing) end)
|
menu:addOption(tr('Open'), function() g_game.open(useThing) end, shortcut)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if useThing:isMultiUse() then
|
if useThing:isMultiUse() then
|
||||||
menu:addOption(tr('Use with ...'), function() startUseWith(useThing) end)
|
menu:addOption(tr('Use with ...'), function() startUseWith(useThing) end, shortcut)
|
||||||
else
|
else
|
||||||
menu:addOption(tr('Use'), function() g_game.use(useThing) end)
|
menu:addOption(tr('Use'), function() g_game.use(useThing) end, shortcut)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -410,10 +414,11 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
if not classic then shortcut = '(Alt)' else shortcut = nil end
|
||||||
if g_game.getAttackingCreature() ~= creatureThing then
|
if g_game.getAttackingCreature() ~= creatureThing then
|
||||||
menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end)
|
menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end, shortcut)
|
||||||
else
|
else
|
||||||
menu:addOption(tr('Stop Attack'), function() g_game.cancelAttack() end)
|
menu:addOption(tr('Stop Attack'), function() g_game.cancelAttack() end, shortcut)
|
||||||
end
|
end
|
||||||
|
|
||||||
if g_game.getFollowingCreature() ~= creatureThing then
|
if g_game.getFollowingCreature() ~= creatureThing then
|
||||||
|
@ -472,7 +477,6 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||||
|
|
||||||
menu:addSeparator()
|
menu:addSeparator()
|
||||||
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
|
menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
menu:display(menuPosition)
|
menu:display(menuPosition)
|
||||||
|
|
Loading…
Reference in New Issue