init menu

This commit is contained in:
Eduardo Bart
2012-01-02 18:46:40 -02:00
parent a52ff707fe
commit 43c16a1643
21 changed files with 217 additions and 78 deletions

View File

@@ -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

View File

@@ -16,4 +16,5 @@ Module
importStyles 'styles/items.otui'
importStyles 'styles/creatures.otui'
importStyles 'styles/comboboxes.otui'
importStyles 'styles/popupmenus.otui'
return true

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -7,5 +7,6 @@ Module
onLoad: |
require 'tooltip/tooltip'
require 'messagebox/messagebox'
require 'uicombobox/uicombobox'
require 'uicombobox'
require 'uipopupmenu'
return true

View 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 })

View File

@@ -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

View File

@@ -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