mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
Updated Top Menu, Health Info, Combat Controls, Console (Channels), Game Toggle Buttons, Minimap Layout, Game Interface Prompts, and Creature Draw Info.
* Added new left and right game button panels. * Relocated main game toggle buttons to the right side of the screen to make it easier to toggle miniwindows. * Added table.empty(t) function to table lib. * Renamed module game_healthbar to game_healthinfo. * Combat controls now save per character (e.g. Fight mode, chase mode, safe fight mode) * Last channels open now save per character. * Fixed typo in containers.lua. * Added logout prompting window message when you logout via the logout button. * Added exit promting window message when you attempt to exit the client. * Repositioned some minimap buttons. * Fixed so when creatures health percent is < 1 it will not draw the creature information. Known Issues: * If you move a container widget into the map rect if you move an item onto itself it will allow this to execute still dropping the item on the ground. * The server is calling to open channels after onGameStart is executed causing it to focus the last tab opened. Fix: Don't save channels to the settings that are opened by the server.
This commit is contained in:
@@ -20,6 +20,8 @@ end
|
||||
|
||||
function GameInterface.init()
|
||||
g_ui.importStyle('styles/countwindow.otui')
|
||||
g_ui.importStyle('styles/logoutwindow.otui')
|
||||
g_ui.importStyle('styles/exitwindow.otui')
|
||||
|
||||
connect(g_game, { onGameStart = GameInterface.show }, true)
|
||||
connect(g_game, { onGameEnd = GameInterface.hide }, true)
|
||||
@@ -63,8 +65,8 @@ function GameInterface.init()
|
||||
g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel, 250)
|
||||
g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel, 250)
|
||||
g_keyboard.bindKeyDown('Ctrl+Q', GameInterface.tryLogout, gameRootPanel)
|
||||
g_keyboard.bindKeyDown('Ctrl+L', GameInterface.tryLogout, gameRootPanel)
|
||||
g_keyboard.bindKeyDown('Ctrl+Q', GameInterface.logout, gameRootPanel)
|
||||
g_keyboard.bindKeyDown('Ctrl+L', GameInterface.logout, gameRootPanel)
|
||||
g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() TextMessage.clearMessages() end, gameRootPanel)
|
||||
|
||||
g_keyboard.bindKeyDown('Ctrl+.', function()
|
||||
@@ -114,7 +116,7 @@ function GameInterface.hide()
|
||||
g_app.onClose = nil
|
||||
end
|
||||
|
||||
function GameInterface.tryExit()
|
||||
function GameInterface.exit()
|
||||
if g_game.isOnline() then
|
||||
g_game.forceLogout()
|
||||
scheduleEvent(exit, 10)
|
||||
@@ -122,13 +124,47 @@ function GameInterface.tryExit()
|
||||
end
|
||||
end
|
||||
|
||||
function GameInterface.tryLogout()
|
||||
function GameInterface.tryExit()
|
||||
local exitWindow = g_ui.createWidget('ExitWindow', rootWidget)
|
||||
local exitButton = exitWindow:getChildById('buttonExit')
|
||||
local logoutButton = exitWindow:getChildById('buttonLogout')
|
||||
|
||||
local exitFunc = function()
|
||||
GameInterface.exit()
|
||||
exitButton:getParent():destroy()
|
||||
end
|
||||
|
||||
local logoutFunc = function()
|
||||
GameInterface.logout()
|
||||
logoutButton:getParent():destroy()
|
||||
end
|
||||
|
||||
exitWindow.onEnter = logoutFunc
|
||||
exitButton.onClick = exitFunc
|
||||
logoutButton.onClick = logoutFunc
|
||||
return true -- signal closing
|
||||
end
|
||||
|
||||
function GameInterface.logout()
|
||||
if g_game.isOnline() then
|
||||
g_game.safeLogout()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function GameInterface.tryLogout()
|
||||
local logoutWindow = g_ui.createWidget('LogoutWindow', rootWidget)
|
||||
local yesButton = logoutWindow:getChildById('buttonYes')
|
||||
|
||||
local logoutFunc = function()
|
||||
GameInterface.logout()
|
||||
yesButton:getParent():destroy()
|
||||
end
|
||||
|
||||
logoutWindow.onEnter = logoutFunc
|
||||
yesButton.onClick = logoutFunc
|
||||
end
|
||||
|
||||
function GameInterface.onMouseGrabberRelease(self, mousePosition, mouseButton)
|
||||
if GameInterface.selectedThing == nil then return false end
|
||||
if mouseButton == MouseLeftButton then
|
||||
|
54
modules/game_interface/styles/exitwindow.otui
Normal file
54
modules/game_interface/styles/exitwindow.otui
Normal file
@@ -0,0 +1,54 @@
|
||||
ExitWindow < MainWindow
|
||||
id: exitWindow
|
||||
!text: tr('Exit')
|
||||
size: 550 135
|
||||
@onEscape: self:destroy()
|
||||
|
||||
Label
|
||||
!text: tr('If you shut down the program, you character might stay in the game.')
|
||||
width: 550
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin-left: 10
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
!text: tr('Click on "Logout" to ensure that you character leaves the game property.')
|
||||
width: 550
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
!text: tr('Click on "Exit" if you want to exit the program without logging out your character.')
|
||||
width: 550
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 2
|
||||
|
||||
Button
|
||||
id: buttonExit
|
||||
!text: tr('Exit')
|
||||
width: 64
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 155
|
||||
|
||||
Button
|
||||
id: buttonLogout
|
||||
!text: tr('Logout')
|
||||
width: 64
|
||||
anchors.left: prev.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 5
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
!text: tr('Cancel')
|
||||
width: 64
|
||||
anchors.left: prev.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 5
|
||||
@onClick: self:getParent():destroy()
|
30
modules/game_interface/styles/logoutwindow.otui
Normal file
30
modules/game_interface/styles/logoutwindow.otui
Normal file
@@ -0,0 +1,30 @@
|
||||
LogoutWindow < MainWindow
|
||||
id: logoutWindow
|
||||
!text: tr('Logout')
|
||||
size: 300 100
|
||||
@onEscape: self:destroy()
|
||||
|
||||
Label
|
||||
!text: tr('Are you sure you want to logout?')
|
||||
width: 300
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin-left: 30
|
||||
margin-top: 2
|
||||
|
||||
Button
|
||||
id: buttonYes
|
||||
!text: tr('Yes')
|
||||
width: 64
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 65
|
||||
|
||||
Button
|
||||
id: buttonNo
|
||||
!text: tr('No')
|
||||
width: 64
|
||||
anchors.left: prev.right
|
||||
anchors.bottom: parent.bottom
|
||||
margin-left: 5
|
||||
@onClick: self:getParent():destroy()
|
@@ -35,8 +35,8 @@ function UIGameMap:onDrop(widget, mousePos)
|
||||
local thing = widget.currentDragThing
|
||||
local toPos = tile:getPosition()
|
||||
|
||||
local itemPos = thing:getPosition()
|
||||
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
||||
local thingPos = thing:getPosition()
|
||||
if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then return false end
|
||||
|
||||
if thing:asItem() and thing:getCount() > 1 then
|
||||
GameInterface.moveStackableItem(thing, toPos)
|
||||
|
@@ -23,16 +23,16 @@ function UIItem:onDrop(widget, mousePos)
|
||||
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local item = widget.currentDragThing
|
||||
local thing = widget.currentDragThing
|
||||
local toPos = self.position
|
||||
|
||||
local itemPos = item:getPosition()
|
||||
if itemPos.x == self.position.x and itemPos.y == self.position.y and itemPos.z == self.position.z then return false end
|
||||
local thingPos = thing:getPosition()
|
||||
if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then return false end
|
||||
|
||||
if item:getCount() > 1 then
|
||||
GameInterface.moveStackableItem(item, toPos)
|
||||
if thing:getCount() > 1 then
|
||||
GameInterface.moveStackableItem(thing, toPos)
|
||||
else
|
||||
g_game.move(item, toPos, 1)
|
||||
g_game.move(thing, toPos, 1)
|
||||
end
|
||||
|
||||
self:setBorderWidth(0)
|
||||
|
Reference in New Issue
Block a user