父節點
ee869bb279
當前提交
060c1cf8e7
@ -0,0 +1,88 @@
|
||||
UIResizeBorder = extends(UIWidget)
|
||||
|
||||
function UIResizeBorder.create()
|
||||
local resizeborder = UIResizeBorder.internalCreate()
|
||||
resizeborder:setFocusable(false)
|
||||
resizeborder.minimum = 0
|
||||
resizeborder.maximum = 1000
|
||||
return resizeborder
|
||||
end
|
||||
|
||||
function UIResizeBorder:onHoverChange(hovered)
|
||||
if hovered then
|
||||
if self:getWidth() > self:getHeight() then
|
||||
Mouse.setVerticalCursor()
|
||||
self.vertical = true
|
||||
else
|
||||
Mouse.setHorizontalCursor()
|
||||
self.vertical = false
|
||||
end
|
||||
if not self:isPressed() then
|
||||
Effects.fadeIn(self)
|
||||
end
|
||||
else
|
||||
if not self:isPressed() then
|
||||
Mouse.restoreCursor()
|
||||
Effects.fadeOut(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:onMouseMove(mousePos, mouseMoved)
|
||||
if self:isPressed() then
|
||||
if self.vertical then
|
||||
local delta = mousePos.y - self:getY() - self:getHeight()/2
|
||||
local parent = self:getParent()
|
||||
local newsize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum)
|
||||
if newsize ~= currentMargin then
|
||||
self.newsize = newsize
|
||||
if not self.event or self.event:isExecuted() then
|
||||
self.event = addEvent(function()
|
||||
parent:setHeight(self.newsize)
|
||||
end)
|
||||
end
|
||||
end
|
||||
else
|
||||
local delta = mousePos.x - self:getX() - self:getWidth()/2
|
||||
local parent = self:getParent()
|
||||
local newsize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
|
||||
if newsize ~= currentMargin then
|
||||
self.newsize = newsize
|
||||
if not self.event or self.event:isExecuted() then
|
||||
self.event = addEvent(function()
|
||||
parent:setWidth(self.newsize)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:onMouseRelease(mousePos, mouseButton)
|
||||
if not self:isHovered() then
|
||||
Mouse.restoreCursor()
|
||||
Effects.fadeOut(self)
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:onStyleApply(styleName, styleNode)
|
||||
for name,value in pairs(styleNode) do
|
||||
if name == 'maximum' then
|
||||
self:setMaximum(tonumber(value))
|
||||
elseif name == 'minimum' then
|
||||
self:setMinimum(tonumber(value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:setMaximum(maximum)
|
||||
self.maximum = maximum
|
||||
end
|
||||
|
||||
function UIResizeBorder:setMinimum(minimum)
|
||||
self.minimum = minimum
|
||||
end
|
||||
|
||||
function UIResizeBorder:getMaximum() return self.maximum end
|
||||
function UIResizeBorder:getMinimum() return self.minimum end
|
@ -0,0 +1,9 @@
|
||||
Splitter < UISplitter
|
||||
size: 4 4
|
||||
opacity: 0
|
||||
background: #ffffff44
|
||||
|
||||
ResizeBorder < UIResizeBorder
|
||||
size: 4 4
|
||||
opacity: 0
|
||||
background: #ffffff44
|
@ -0,0 +1,36 @@
|
||||
UIMiniWindow = extends(UIWindow)
|
||||
|
||||
function UIMiniWindow.create()
|
||||
local miniwindow = UIMiniWindow.internalCreate()
|
||||
return miniwindow
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragEnter(mousePos)
|
||||
local parent = self:getParent()
|
||||
if not parent then return false end
|
||||
|
||||
if parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
local containerParent = parent:getParent()
|
||||
parent:removeChild(self)
|
||||
containerParent:addChild(self)
|
||||
end
|
||||
|
||||
local oldPos = self:getPosition()
|
||||
self.movingReference = { x = mousePos.x - oldPos.x, y = mousePos.y - oldPos.y }
|
||||
self:setPosition(oldPos)
|
||||
return true
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
||||
-- TODO: drop on other interfaces
|
||||
end
|
||||
|
||||
function UIMiniWindow:onFocusChange(focused)
|
||||
-- miniwindows only raises when its outside MiniWindowContainers
|
||||
if not focused then return end
|
||||
local parent = self:getParent()
|
||||
if parent and parent:getClassName() ~= 'UIMiniWindowContainer' then
|
||||
self:raise()
|
||||
end
|
||||
end
|
||||
|
@ -1,111 +1,113 @@
|
||||
BorderlessGameWindow
|
||||
id: inventoryWindow
|
||||
MiniWindow
|
||||
text: Inventory
|
||||
icon: inventory.png
|
||||
width: 192
|
||||
height: 154
|
||||
margin-top: 10
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
|
||||
Item
|
||||
// head
|
||||
id: slot1
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
&position: {x=65535, y=1, z=0}
|
||||
MiniWindowContents
|
||||
id: inventoryWindow
|
||||
|
||||
Item
|
||||
// armor
|
||||
id: slot4
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=4, z=0}
|
||||
Item
|
||||
// head
|
||||
id: slot1
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
&position: {x=65535, y=1, z=0}
|
||||
|
||||
Item
|
||||
// legs
|
||||
id: slot7
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=7, z=0}
|
||||
Item
|
||||
// armor
|
||||
id: slot4
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=4, z=0}
|
||||
|
||||
Item
|
||||
// feet
|
||||
id: slot8
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=8, z=0}
|
||||
Item
|
||||
// legs
|
||||
id: slot7
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=7, z=0}
|
||||
|
||||
Item
|
||||
// necklace
|
||||
id: slot2
|
||||
anchors.top: parent.top
|
||||
anchors.right: slot1.left
|
||||
margin-top: 10
|
||||
margin-right: 5
|
||||
&position: {x=65535, y=2, z=0}
|
||||
Item
|
||||
// feet
|
||||
id: slot8
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
margin-bottom: 10
|
||||
&position: {x=65535, y=8, z=0}
|
||||
|
||||
Item
|
||||
// left
|
||||
id: slot6
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=6, z=0}
|
||||
Item
|
||||
// necklace
|
||||
id: slot2
|
||||
anchors.top: parent.top
|
||||
anchors.right: slot1.left
|
||||
margin-top: 10
|
||||
margin-right: 5
|
||||
&position: {x=65535, y=2, z=0}
|
||||
|
||||
Item
|
||||
// ring
|
||||
id: slot9
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=9, z=0}
|
||||
Item
|
||||
// left
|
||||
id: slot6
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=6, z=0}
|
||||
|
||||
Item
|
||||
// backpack
|
||||
id: slot3
|
||||
anchors.top: parent.top
|
||||
anchors.left: slot1.right
|
||||
margin-top: 10
|
||||
margin-left: 5
|
||||
&position: {x=65535, y=3, z=0}
|
||||
Item
|
||||
// ring
|
||||
id: slot9
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=9, z=0}
|
||||
|
||||
Item
|
||||
// right
|
||||
id: slot5
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=5, z=0}
|
||||
Item
|
||||
// backpack
|
||||
id: slot3
|
||||
anchors.top: parent.top
|
||||
anchors.left: slot1.right
|
||||
margin-top: 10
|
||||
margin-left: 5
|
||||
&position: {x=65535, y=3, z=0}
|
||||
|
||||
Item
|
||||
// ammo
|
||||
id: slot10
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=10, z=0}
|
||||
Item
|
||||
// right
|
||||
id: slot5
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=5, z=0}
|
||||
|
||||
GameLabel
|
||||
id: soul
|
||||
anchors.top: slot9.bottom
|
||||
anchors.bottom: slot8.bottom
|
||||
anchors.left: slot9.left
|
||||
anchors.right: slot9.right
|
||||
margin-top: 5
|
||||
text-align: center
|
||||
image-source: /core_styles/styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
Item
|
||||
// ammo
|
||||
id: slot10
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalCenter: prev.horizontalCenter
|
||||
margin-top: 5
|
||||
&position: {x=65535, y=10, z=0}
|
||||
|
||||
GameLabel
|
||||
id: capacity
|
||||
anchors.top: slot10.bottom
|
||||
anchors.bottom: slot8.bottom
|
||||
anchors.left: slot10.left
|
||||
anchors.right: slot10.right
|
||||
margin-top: 5
|
||||
text-align: center
|
||||
image-source: /core_styles/styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
GameLabel
|
||||
id: soul
|
||||
anchors.top: slot9.bottom
|
||||
anchors.bottom: slot8.bottom
|
||||
anchors.left: slot9.left
|
||||
anchors.right: slot9.right
|
||||
margin-top: 5
|
||||
text-align: center
|
||||
image-source: /core_styles/styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
|
||||
GameLabel
|
||||
id: capacity
|
||||
anchors.top: slot10.bottom
|
||||
anchors.bottom: slot8.bottom
|
||||
anchors.left: slot10.left
|
||||
anchors.right: slot10.right
|
||||
margin-top: 5
|
||||
text-align: center
|
||||
image-source: /core_styles/styles/images/panel_flat.png
|
||||
image-border: 1
|
||||
|
||||
|
Loading…
Reference in new issue