mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
init menu
This commit is contained in:
@@ -31,6 +31,10 @@ function UI.display(arg1, options)
|
||||
widget:lock()
|
||||
elseif option == 'visible' then
|
||||
widget:setVisible(value)
|
||||
elseif option == 'x' then
|
||||
widget:setX(value)
|
||||
elseif option == 'y' then
|
||||
widget:setY(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -16,4 +16,5 @@ Module
|
||||
importStyles 'styles/items.otui'
|
||||
importStyles 'styles/creatures.otui'
|
||||
importStyles 'styles/comboboxes.otui'
|
||||
importStyles 'styles/popupmenus.otui'
|
||||
return true
|
||||
|
BIN
modules/core_styles/images/menubox.png
Normal file
BIN
modules/core_styles/images/menubox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 227 B |
@@ -51,17 +51,3 @@ TopButton < UIButton
|
||||
$disabled:
|
||||
background-color: #ffffff66
|
||||
|
||||
MenuButton < UIButton
|
||||
color: white
|
||||
size: 40 18
|
||||
text-align: center
|
||||
border-image:
|
||||
source: /core_styles/images/menu.png
|
||||
size: 64 24
|
||||
|
||||
$hover:
|
||||
border-image:
|
||||
source: /core_styles/images/menu.png
|
||||
offset: 0 24
|
||||
size: 64 24
|
||||
color: black
|
||||
|
@@ -7,7 +7,7 @@ RectPanel < UIWidget
|
||||
FlatPanel < Panel
|
||||
border-image:
|
||||
source: /core_styles/images/panel_flat.png
|
||||
border: 4
|
||||
border: 1
|
||||
|
||||
TopPanel < Panel
|
||||
height: 36
|
||||
|
40
modules/core_styles/styles/popupmenus.otui
Normal file
40
modules/core_styles/styles/popupmenus.otui
Normal file
@@ -0,0 +1,40 @@
|
||||
PopupMenuButton < UIButton
|
||||
font: verdana-11px-antialised
|
||||
background-color: alpha
|
||||
color: #aaaaaa
|
||||
height: 18
|
||||
margin-left: 3
|
||||
margin-right: 3
|
||||
|
||||
image:
|
||||
source: /core_styles/images/empty_rect.png
|
||||
repeated: true
|
||||
|
||||
$hover:
|
||||
color: #ffffff
|
||||
background-color: #ffffff44
|
||||
|
||||
$disabled:
|
||||
color: #555555
|
||||
|
||||
PopupMenuFirstButton < PopupMenuButton
|
||||
margin-top: 3
|
||||
|
||||
PopupMenuLastButton < PopupMenuButton
|
||||
margin-bottom: 3
|
||||
|
||||
PopupMenuSeparator < UIWidget
|
||||
margin-left: 2
|
||||
margin-right: 2
|
||||
image:
|
||||
source: /core_styles/images/menubox.png
|
||||
repeated: true
|
||||
coords: 3 0 26 3
|
||||
height: 3
|
||||
phantom: true
|
||||
|
||||
PopupMenu < UIPopupMenu
|
||||
width: 100
|
||||
border-image:
|
||||
source: /core_styles/images/menubox.png
|
||||
border: 3
|
@@ -7,5 +7,6 @@ Module
|
||||
onLoad: |
|
||||
require 'tooltip/tooltip'
|
||||
require 'messagebox/messagebox'
|
||||
require 'uicombobox/uicombobox'
|
||||
require 'uicombobox'
|
||||
require 'uipopupmenu'
|
||||
return true
|
34
modules/core_widgets/uipopupmenu.lua
Normal file
34
modules/core_widgets/uipopupmenu.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- extends UIWidget
|
||||
UIPopupMenu = extends(UIWidget)
|
||||
|
||||
-- public functions
|
||||
function UIPopupMenu.create()
|
||||
local menu = UIPopupMenu.internalCreate()
|
||||
local layout = UIVerticalLayout.create(menu)
|
||||
layout:setFitParent(true)
|
||||
menu:setLayout(layout)
|
||||
return menu
|
||||
end
|
||||
|
||||
function UIPopupMenu.display(otui, pos)
|
||||
local menu = UI.display(otui, {x = pos.x, y = pos.y})
|
||||
return menu
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
local function onWidgetStyleApply(widget, style)
|
||||
if style and style.popupmenu then
|
||||
widget.popupmenu = style.popupmenu
|
||||
end
|
||||
end
|
||||
|
||||
local function onWidgetMousePress(widget, mousePos, mouseButton)
|
||||
if widget.popupmenu and mouseButton == MouseRightButton then
|
||||
UIPopupMenu.display(widget.popupmenu, mousePos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
connect(UIWidget, { onStyleApply = onWidgetStyleApply,
|
||||
onMousePress = onWidgetMousePress })
|
@@ -1,3 +1,6 @@
|
||||
InvetoryItem < Item
|
||||
popupmenu: /game_inventory/itempopupmenu.otui
|
||||
|
||||
UIWindow
|
||||
width: 192
|
||||
margin-top: 10
|
||||
@@ -5,63 +8,62 @@ UIWindow
|
||||
margin-right: 6
|
||||
move-policy: free updated
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: head
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
popup menu: /inventory/itempopupmenu.otui
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: armor
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: legs
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: feet
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: necklace
|
||||
anchors.top: parent.top
|
||||
anchors.right: head.left
|
||||
margin-top: 10
|
||||
margin-right: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: left
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: ring
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: backpack
|
||||
anchors.top: parent.top
|
||||
anchors.left: head.right
|
||||
margin-top: 10
|
||||
margin-left: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: right
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
|
||||
Item
|
||||
InvetoryItem
|
||||
id: ammo
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
|
@@ -1,10 +1,5 @@
|
||||
Panel
|
||||
layout: verticalBox
|
||||
size: 64 48
|
||||
|
||||
MenuButton
|
||||
text: Foo
|
||||
|
||||
MenuButton
|
||||
text: Quit
|
||||
@onClick: exit()
|
||||
PopupMenu
|
||||
PopupMenuFirstButton
|
||||
text: Look
|
||||
PopupMenuLastButton
|
||||
text: Use
|
Reference in New Issue
Block a user