mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
some window moving
This commit is contained in:
@@ -15,6 +15,7 @@ end
|
||||
function About.terminate()
|
||||
aboutButton:destroy()
|
||||
aboutButton = nil
|
||||
About = nil
|
||||
end
|
||||
|
||||
function About.openWebpage()
|
||||
|
@@ -15,4 +15,4 @@ Module
|
||||
About.init()
|
||||
|
||||
onUnload: |
|
||||
About.terminate()
|
||||
About.terminate()
|
||||
|
@@ -12,7 +12,7 @@ MainWindow
|
||||
text-align: center
|
||||
text: |-
|
||||
OTClient
|
||||
Version 0.2.0
|
||||
Version 0.4.0
|
||||
Created by edubart
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
|
@@ -12,6 +12,7 @@ end
|
||||
function Background.terminate()
|
||||
background:destroy()
|
||||
background = nil
|
||||
Background = nil
|
||||
end
|
||||
|
||||
function Background.hide()
|
||||
|
@@ -12,4 +12,3 @@ Module
|
||||
|
||||
onUnload: |
|
||||
Background.terminate()
|
||||
|
||||
|
@@ -9,4 +9,3 @@ Panel
|
||||
anchors.bottom: parent.bottom
|
||||
margin-top: 1
|
||||
focusable: false
|
||||
|
||||
|
@@ -63,6 +63,7 @@ function CharacterList.terminate()
|
||||
loadBox:destroy()
|
||||
loadBox = nil
|
||||
end
|
||||
CharacterList = nil
|
||||
end
|
||||
|
||||
function CharacterList.create(characters, premDays)
|
||||
|
@@ -66,4 +66,4 @@ MainWindow
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: CharacterList.destroy()
|
||||
@onClick: CharacterList.destroy()
|
||||
|
@@ -97,6 +97,7 @@ function EnterGame.terminate()
|
||||
enterGameButton = nil
|
||||
motdButton:destroy()
|
||||
motdButton = nil
|
||||
EnterGame = nil
|
||||
end
|
||||
|
||||
function EnterGame.show()
|
||||
@@ -144,4 +145,3 @@ end
|
||||
function EnterGame.displayMotd()
|
||||
displayInfoBox('Message of the day', motdMessage)
|
||||
end
|
||||
|
||||
|
@@ -14,5 +14,3 @@ Module
|
||||
onUnload: |
|
||||
EnterGame.terminate()
|
||||
CharacterList.terminate()
|
||||
|
||||
|
||||
|
@@ -34,4 +34,5 @@ function Client.terminate()
|
||||
Settings.set('window-size', g_window.getUnmaximizedSize())
|
||||
Settings.set('window-pos', g_window.getUnmaximizedPos())
|
||||
Settings.set('window-maximized', g_window.isMaximized())
|
||||
Client = nil
|
||||
end
|
||||
|
@@ -27,6 +27,7 @@ function ModuleManager.terminate()
|
||||
moduleManagerButton:destroy()
|
||||
moduleManagerButton = nil
|
||||
moduleList = nil
|
||||
ModuleManager = nil
|
||||
end
|
||||
|
||||
function ModuleManager.hide()
|
||||
@@ -37,7 +38,6 @@ function ModuleManager.show()
|
||||
moduleManagerWindow:show()
|
||||
moduleManagerWindow:focus()
|
||||
moduleManagerWindow:raise()
|
||||
|
||||
end
|
||||
|
||||
function ModuleManager.toggle()
|
||||
|
@@ -34,6 +34,7 @@ function Options.terminate()
|
||||
optionsWindow = nil
|
||||
optionsButton:destroy()
|
||||
optionsButton = nil
|
||||
Options = nil
|
||||
end
|
||||
|
||||
function Options.toggle()
|
||||
|
@@ -137,6 +137,7 @@ function Terminal.terminate()
|
||||
terminalWidget:destroy()
|
||||
terminalWidget = nil
|
||||
commandEnv = nil
|
||||
Terminal = nil
|
||||
end
|
||||
|
||||
function Terminal.toggle()
|
||||
|
@@ -39,6 +39,8 @@ function TopMenu.terminate()
|
||||
|
||||
disconnect(Game, { onLogin = TopMenu.showGameButtons,
|
||||
onLogout = TopMenu.hideGameButtons })
|
||||
|
||||
TopMenu = nil
|
||||
end
|
||||
|
||||
function TopMenu.addButton(id, description, icon, callback, right)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
function scheduleEvent(func, delay)
|
||||
function scheduleEvent(callback, delay)
|
||||
local event = g_dispatcher.scheduleEvent(callback, delay)
|
||||
|
||||
-- must hold a reference to the callback, otherwise it would be collected
|
||||
|
@@ -1 +1 @@
|
||||
Color = {}
|
||||
Color = {}
|
||||
|
@@ -1 +1 @@
|
||||
Point = {}
|
||||
Point = {}
|
||||
|
@@ -1 +1 @@
|
||||
Rect = {}
|
||||
Rect = {}
|
||||
|
@@ -1 +1 @@
|
||||
Size = {}
|
||||
Size = {}
|
||||
|
@@ -2,4 +2,4 @@ Item < UIItem
|
||||
size: 34 34
|
||||
image-source: /core_styles/images/item.png
|
||||
font: verdana-11px-rounded
|
||||
border-color: white
|
||||
border-color: white
|
||||
|
@@ -10,8 +10,7 @@ TopPanel < Panel
|
||||
image-source: /core_styles/images/top_panel.png
|
||||
image-repeated: true
|
||||
|
||||
InterfacePanel < Panel
|
||||
focusable: false
|
||||
InterfacePanel < UIMiniWindowContainer
|
||||
image-source: /core_styles/images/interface_panel.png
|
||||
image-border: 4
|
||||
|
||||
|
@@ -18,7 +18,7 @@ Window < UIWindow
|
||||
MainWindow < Window
|
||||
anchors.centerIn: parent
|
||||
|
||||
MiniWindow < UIWindow
|
||||
MiniWindow < UIMiniWindow
|
||||
font: verdana-11px-antialised
|
||||
//icon: /core_styles/icons/login.png
|
||||
icon-rect: 4 4 16 16
|
||||
|
@@ -19,12 +19,12 @@ Module
|
||||
dofile 'uitabbar'
|
||||
dofile 'uipopupmenu'
|
||||
dofile 'uiwindow'
|
||||
dofile 'uiminiwindow'
|
||||
dofile 'uiminiwindowcontainer'
|
||||
dofile 'uiitem'
|
||||
dofile 'uimessagebox'
|
||||
|
||||
dofile 'tooltip'
|
||||
--dofile 'messagebox/messagebox'
|
||||
|
||||
ToolTip.init()
|
||||
|
||||
onUnload: |
|
||||
|
@@ -12,7 +12,7 @@ function UIItem:onDragEnter(mousePos)
|
||||
return true
|
||||
end
|
||||
|
||||
function UIItem:onDragLeave(widget, mousePos)
|
||||
function UIItem:onDragLeave(droppedWidget, mousePos)
|
||||
if self:isVirtual() then return false end
|
||||
|
||||
if not self.parsed then
|
||||
@@ -53,8 +53,9 @@ end
|
||||
function UIItem:onHoverChange(hovered)
|
||||
if self:isVirtual() then return end
|
||||
|
||||
if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then
|
||||
if hovered then
|
||||
local dragginWidget = g_ui.getDraggingWidget()
|
||||
if dragginWidget and self ~= dragginWidget then
|
||||
if dragginWidget:getClassName() == 'UIItem' and not dragginWidget:isVirtual() and hovered then
|
||||
self:setBorderWidth(1)
|
||||
else
|
||||
self:setBorderWidth(0)
|
||||
|
30
modules/core_widgets/uiminiwindow.lua
Normal file
30
modules/core_widgets/uiminiwindow.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
UIMiniWindow = extends(UIWindow)
|
||||
|
||||
function UIMiniWindow.create()
|
||||
local miniwindow = UIMiniWindow.internalCreate()
|
||||
return miniwindow
|
||||
end
|
||||
|
||||
function UIMiniWindow:onMousePress(mousePos, mouseButton)
|
||||
local parent = self:getParent()
|
||||
if parent:getClassName() ~= 'UIMiniWindowContainer' then
|
||||
self:raise()
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragEnter(mousePos)
|
||||
local parent = self:getParent()
|
||||
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)
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
|
||||
-- TODO: drop on other interfaces
|
||||
end
|
12
modules/core_widgets/uiminiwindowcontainer.lua
Normal file
12
modules/core_widgets/uiminiwindowcontainer.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
UIMiniWindowContainer = extends(UIWidget)
|
||||
|
||||
function UIMiniWindowContainer.create()
|
||||
local container = UIMiniWindowContainer.internalCreate()
|
||||
container:setFocusable(false)
|
||||
container:setPhantom(true)
|
||||
return container
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:getClassName()
|
||||
return 'UIMiniWindowContainer'
|
||||
end
|
@@ -3,6 +3,7 @@ UIWindow = extends(UIWidget)
|
||||
function UIWindow.create()
|
||||
local window = UIWindow.internalCreate()
|
||||
window:setTextAlign(AlignTopCenter)
|
||||
window:setDragable(true)
|
||||
return window
|
||||
end
|
||||
|
||||
@@ -20,6 +21,17 @@ function UIWindow:onMousePress(mousePos, mouseButton)
|
||||
|
||||
end
|
||||
|
||||
function UIWindow:onGeometryChange(oldRect, newRect)
|
||||
|
||||
function UIWindow:onDragEnter(mousePos)
|
||||
self:breakAnchors()
|
||||
self.movingReference = { x = mousePos.x - self:getX(), y = mousePos.y - self:getY() }
|
||||
end
|
||||
|
||||
function UIWindow:onDragLeave(droppedWidget, mousePos)
|
||||
-- TODO: auto detect and reconnect anchors
|
||||
end
|
||||
|
||||
function UIWindow:onDragMove(mousePos, mouseMoved)
|
||||
local pos = { x = mousePos.x - self.movingReference.x, y = mousePos.y - self.movingReference.y }
|
||||
self:setPosition(pos)
|
||||
self:bindRectToParent()
|
||||
end
|
||||
|
@@ -1,6 +0,0 @@
|
||||
Module
|
||||
name: game_miniwindow
|
||||
description: Manage game miniwindow
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad:
|
Reference in New Issue
Block a user