* i'm gradually restoring game functionality with the new modules design, though still a lot to do * you can reload all scripts and modules using Ctrl+R shortcut while playing (finally! this is the reason of all this rework) * a bunch of fixes, but new regression too :P * fix performance issue that could lead freezes in the client in older machines * completely new game module with new design * fix crashs in map render * remove uigame.cpp (now every game input is via lua) * enable DEBUG macro by default, with it you are able to view any possible lua leak while runningmaster
Antes Anchura: | Altura: | Tamaño: 932 B |
@ -0,0 +1,24 @@
|
||||
SkullNone = 0
|
||||
SkullYellow = 1
|
||||
SkullGreen = 2
|
||||
SkullWhite = 3
|
||||
SkullRed = 4
|
||||
SkullBlack = 5
|
||||
SkullOrange = 6
|
||||
|
||||
ShieldNone = 0
|
||||
ShieldWhiteYellow = 1
|
||||
ShieldWhiteBlue = 2
|
||||
ShieldBlue = 3
|
||||
ShieldYellow = 4
|
||||
ShieldBlueSharedExp = 5
|
||||
ShieldYellowSharedExp = 6
|
||||
ShieldBlueNoSharedExpBlink = 7
|
||||
ShieldYellowNoSharedExpBlink = 8
|
||||
ShieldBlueNoSharedExp = 9
|
||||
ShieldYellowNoSharedExp = 10
|
||||
|
||||
EmblemNone = 0
|
||||
EmblemGreen = 1
|
||||
EmblemRed = 2
|
||||
EmblemBlue = 3
|
@ -0,0 +1,295 @@
|
||||
GameInterface = {}
|
||||
|
||||
local WALK_AUTO_REPEAT_DELAY = 90
|
||||
local gameRootPanel
|
||||
local gameMapPanel
|
||||
local gameRightPanel
|
||||
local gameLeftPanel
|
||||
local gameBottomPanel
|
||||
local logoutButton
|
||||
|
||||
function GameInterface.init()
|
||||
connect(g_game, { onGameStart = GameInterface.show }, true)
|
||||
connect(g_game, { onGameEnd = GameInterface.hide }, true)
|
||||
|
||||
gameRootPanel = displayUI('gameinterface.otui')
|
||||
gameRootPanel:hide()
|
||||
gameRootPanel:lower()
|
||||
|
||||
gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
|
||||
gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
|
||||
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
|
||||
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
|
||||
|
||||
logoutButton = TopMenu.addRightButton('logoutButton', 'Logout', 'images/logout.png', GameInterface.tryLogout)
|
||||
logoutButton:hide()
|
||||
|
||||
Keyboard.bindKeyPress('Up', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Right', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Down', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Left', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad8', function() g_game.walk(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad9', function() g_game.walk(NorthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad6', function() g_game.walk(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad3', function() g_game.walk(SouthEast) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad2', function() g_game.walk(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad1', function() g_game.walk(SouthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad4', function() g_game.walk(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Numpad7', function() g_game.walk(NorthWest) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
Keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel, WALK_AUTO_REPEAT_DELAY)
|
||||
|
||||
if g_game.isOnline() then
|
||||
GameInterface.show()
|
||||
end
|
||||
end
|
||||
|
||||
function GameInterface.terminate()
|
||||
disconnect(g_game, { onGameStart = GameInterface.show })
|
||||
disconnect(g_game, { onGameEnd = GameInterface.hide })
|
||||
|
||||
logoutButton:destroy()
|
||||
logoutButton = nil
|
||||
gameRootPanel:destroy()
|
||||
gameRootPanel = nil
|
||||
gameMapPanel = nil
|
||||
gameRightPanel = nil
|
||||
gameLeftPanel = nil
|
||||
gameBottomPanel = nil
|
||||
GameInterface = nil
|
||||
end
|
||||
|
||||
function GameInterface.show()
|
||||
g_app.onClose = GameInterface.tryExit
|
||||
logoutButton:show()
|
||||
Background.hide()
|
||||
gameRootPanel:show()
|
||||
gameRootPanel:focus()
|
||||
gameMapPanel:followCreature(g_game.getLocalPlayer())
|
||||
end
|
||||
|
||||
function GameInterface.hide()
|
||||
gameRootPanel:hide()
|
||||
logoutButton:hide()
|
||||
Background.show()
|
||||
g_app.onClose = nil
|
||||
end
|
||||
|
||||
function GameInterface.tryExit()
|
||||
if g_game.isOnline() then
|
||||
g_game.forceLogout()
|
||||
scheduleEvent(exit, 10)
|
||||
end
|
||||
end
|
||||
|
||||
function GameInterface.tryLogout()
|
||||
if g_game.isOnline() then
|
||||
g_game.safeLogout()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
local menu = createWidget('PopupMenu')
|
||||
|
||||
if lookThing then
|
||||
menu:addOption('Look', function() g_game.look(lookThing) end)
|
||||
end
|
||||
|
||||
if useThing then
|
||||
if useThing:isContainer() then
|
||||
if useThing:isInsideContainer() then
|
||||
menu:addOption('Open', function() g_game.open(useThing, useThing:getContainerId()) end)
|
||||
menu:addOption('Open in new window', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
|
||||
else
|
||||
menu:addOption('Open', function() g_game.open(useThing, Containers.getFreeContainerId()) end)
|
||||
end
|
||||
else
|
||||
if useThing:isMultiUse() then
|
||||
menu:addOption('Use with ...', function() g_game.startUseWith(useThing) end)
|
||||
else
|
||||
menu:addOption('Use', function() g_game.use(useThing) end)
|
||||
end
|
||||
end
|
||||
|
||||
if useThing:isRotateable() then
|
||||
menu:addOption('Rotate', function() g_game.rotate(useThing) end)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if lookThing and not lookThing:asCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
|
||||
menu:addSeparator()
|
||||
menu:addOption('Trade with ...', function() print('trade with') end)
|
||||
end
|
||||
|
||||
-- check for move up
|
||||
|
||||
if creatureThing then
|
||||
menu:addSeparator()
|
||||
|
||||
if creatureThing:asLocalPlayer() then
|
||||
menu:addOption('Set Outfit', function() g_game.requestOutfit() end)
|
||||
|
||||
if creatureThing:isPartyMember() --[[and not fighting]] then
|
||||
if creatureThing:isPartyLeader() then
|
||||
if creatureThing:isPartySharedExperienceActive() then
|
||||
menu:addOption('Disable Shared Experience', function() g_game.partyShareExperience(false) end)
|
||||
else
|
||||
menu:addOption('Enable Shared Experience', function() g_game.partyShareExperience(true) end)
|
||||
end
|
||||
end
|
||||
menu:addOption('Leave Party', function() g_game.partyLeave() end)
|
||||
end
|
||||
|
||||
else
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
if localPlayer then
|
||||
if g_game.getAttackingCreature() ~= creatureThing then
|
||||
menu:addOption('Attack', function() g_game.attack(creatureThing) end)
|
||||
else
|
||||
menu:addOption('Stop Attack', function() g_game.cancelAttack() end)
|
||||
end
|
||||
|
||||
if g_game.getFollowingCreature() ~= creatureThing then
|
||||
menu:addOption('Follow', function() g_game.follow(creatureThing) end)
|
||||
else
|
||||
menu:addOption('Stop Follow', function() g_game.cancelFollow() end)
|
||||
end
|
||||
|
||||
if creatureThing:asPlayer() then
|
||||
menu:addSeparator()
|
||||
menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
|
||||
menu:addOption('Add to VIP list', function() g_game.addVip(creatureThing:getName()) end)
|
||||
|
||||
local localPlayerShield = localPlayer:asCreature():getShield()
|
||||
local creatureShield = creatureThing:getShield()
|
||||
|
||||
if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
|
||||
if creatureShield == ShieldWhiteYellow then
|
||||
menu:addOption('Join ' .. creatureThing:getName() .. '\'s Party', function() g_game.partyJoin(creatureThing:getId()) end)
|
||||
else
|
||||
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
|
||||
end
|
||||
elseif localPlayerShield == ShieldWhiteYellow then
|
||||
if creatureShield == ShieldWhiteBlue then
|
||||
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
|
||||
end
|
||||
elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
|
||||
if creatureShield == ShieldWhiteBlue then
|
||||
menu:addOption('Revoke ' .. creatureThing:getName() .. '\'s Invitation', function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
|
||||
elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
|
||||
menu:addOption('Pass Leadership to ' .. creatureThing:getName(), function() g_game.partyPassLeadership(creatureThing:getId()) end)
|
||||
else
|
||||
menu:addOption('Invite to Party', function() g_game.partyInvite(creatureThing:getId()) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
menu:addOption('Copy Name', function() g_window.setClipboardText(creatureThing:getName()) end)
|
||||
|
||||
end
|
||||
|
||||
menu:display(menuPosition)
|
||||
end
|
||||
|
||||
function GameInterface.processMouseAction(menuPosition, mouseButton, autoWalk, lookThing, useThing, creatureThing, multiUseThing)
|
||||
local keyboardModifiers = g_window.getKeyboardModifiers()
|
||||
|
||||
if autoWalk and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
|
||||
-- todo auto walk
|
||||
return true
|
||||
end
|
||||
|
||||
if not Options.classicControl then
|
||||
if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
if useThing:isContainer() then
|
||||
if useThing:isInsideContainer() then
|
||||
g_game.open(useThing, useThing:getContainerId())
|
||||
return true
|
||||
else
|
||||
g_game.open(useThing, Containers.getFreeContainerId())
|
||||
return true
|
||||
end
|
||||
elseif useThing:isMultiUse() then
|
||||
g_game.startUseWith(useThing)
|
||||
return true
|
||||
else
|
||||
g_game.use(useThing)
|
||||
return true
|
||||
end
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
g_game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
else
|
||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
|
||||
if multiUseThing:asCreature() then
|
||||
g_game.attack(multiUseThing:asCreature())
|
||||
return true
|
||||
elseif multiUseThing:isContainer() then
|
||||
if multiUseThing:isInsideContainer() then
|
||||
g_game.open(multiUseThing, multiUseThing:getContainerId())
|
||||
return true
|
||||
else
|
||||
g_game.open(multiUseThing, Containers.getFreeContainerId())
|
||||
return true
|
||||
end
|
||||
elseif multiUseThing:isMultiUse() then
|
||||
g_game.startUseWith(multiUseThing)
|
||||
return true
|
||||
else
|
||||
g_game.use(multiUseThing)
|
||||
end
|
||||
return true
|
||||
elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
g_game.look(lookThing)
|
||||
return true
|
||||
elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
||||
return true
|
||||
elseif creatureThing and keyboardModifiers == KeyboardAltModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
|
||||
g_game.attack(creatureThing)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function GameInterface.getRootPanel()
|
||||
return gameRootPanel
|
||||
end
|
||||
|
||||
function GameInterface.getMapPanel()
|
||||
return gameMapPanel
|
||||
end
|
||||
|
||||
function GameInterface.getRightPanel()
|
||||
return gameRightPanel
|
||||
end
|
||||
|
||||
function GameInterface.getLeftPanel()
|
||||
return gameLeftPanel
|
||||
end
|
||||
|
||||
function GameInterface.getBottomPanel()
|
||||
return gameBottomPanel
|
||||
end
|
@ -0,0 +1,53 @@
|
||||
GameSidePanel < Panel
|
||||
image-source: images/sidepanel.png
|
||||
image-border: 4
|
||||
|
||||
GameBottomPanel < Panel
|
||||
image-source: images/bottompanel.png
|
||||
image-border: 4
|
||||
|
||||
GameMapPanel < UIGameMap
|
||||
padding: 4
|
||||
image-source: images/mappanel.png
|
||||
image-border: 4
|
||||
|
||||
UIWidget
|
||||
id: gameRootPanel
|
||||
anchors.fill: parent
|
||||
anchors.top: topMenu.bottom
|
||||
|
||||
GameSidePanel
|
||||
id: gameRightPanel
|
||||
width: 190
|
||||
layout: verticalBox
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
GameSidePanel
|
||||
id: gameLeftPanel
|
||||
width: 190
|
||||
layout: verticalBox
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
GameBottomPanel
|
||||
id: gameBottomPanel
|
||||
height: 170
|
||||
anchors.left: gameLeftPanel.right
|
||||
anchors.right: gameRightPanel.left
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
GameMapPanel
|
||||
id: gameMapPanel
|
||||
anchors.left: gameLeftPanel.right
|
||||
anchors.right: gameRightPanel.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: gameBottomPanel.top
|
||||
focusable: false
|
||||
|
||||
UIWidget
|
||||
id: mouseGrabber
|
||||
focusable: false
|
||||
visible: false
|
Antes Anchura: | Altura: | Tamaño: 385 B Después Anchura: | Altura: | Tamaño: 385 B |
Antes Anchura: | Altura: | Tamaño: 381 B Después Anchura: | Altura: | Tamaño: 381 B |
Antes Anchura: | Altura: | Tamaño: 386 B Después Anchura: | Altura: | Tamaño: 386 B |
Antes Anchura: | Altura: | Tamaño: 352 B Después Anchura: | Altura: | Tamaño: 352 B |
Antes Anchura: | Altura: | Tamaño: 522 B Después Anchura: | Altura: | Tamaño: 522 B |
Antes Anchura: | Altura: | Tamaño: 516 B Después Anchura: | Altura: | Tamaño: 516 B |
Antes Anchura: | Altura: | Tamaño: 404 B Después Anchura: | Altura: | Tamaño: 404 B |
Antes Anchura: | Altura: | Tamaño: 377 B Después Anchura: | Altura: | Tamaño: 377 B |
Antes Anchura: | Altura: | Tamaño: 512 B Después Anchura: | Altura: | Tamaño: 512 B |
Antes Anchura: | Altura: | Tamaño: 494 B Después Anchura: | Altura: | Tamaño: 494 B |
Antes Anchura: | Altura: | Tamaño: 407 B Después Anchura: | Altura: | Tamaño: 407 B |
Antes Anchura: | Altura: | Tamaño: 482 B Después Anchura: | Altura: | Tamaño: 482 B |
Antes Anchura: | Altura: | Tamaño: 438 B Después Anchura: | Altura: | Tamaño: 438 B |
Antes Anchura: | Altura: | Tamaño: 445 B Después Anchura: | Altura: | Tamaño: 445 B |
Antes Anchura: | Altura: | Tamaño: 421 B Después Anchura: | Altura: | Tamaño: 421 B |
Antes Anchura: | Altura: | Tamaño: 437 B Después Anchura: | Altura: | Tamaño: 437 B |
Antes Anchura: | Altura: | Tamaño: 437 B Después Anchura: | Altura: | Tamaño: 437 B |
Antes Anchura: | Altura: | Tamaño: 28 KiB Después Anchura: | Altura: | Tamaño: 28 KiB |
Antes Anchura: | Altura: | Tamaño: 385 B Después Anchura: | Altura: | Tamaño: 385 B |
Antes Anchura: | Altura: | Tamaño: 37 KiB Después Anchura: | Altura: | Tamaño: 37 KiB |
Antes Anchura: | Altura: | Tamaño: 39 KiB Después Anchura: | Altura: | Tamaño: 39 KiB |
Antes Anchura: | Altura: | Tamaño: 52 KiB Después Anchura: | Altura: | Tamaño: 52 KiB |
@ -0,0 +1,41 @@
|
||||
CountWindow < MainWindow
|
||||
id: countWindow
|
||||
text: Move Staackable Item
|
||||
size: 196 112
|
||||
@onEscape: self:destroy()
|
||||
|
||||
Label
|
||||
text: Amount:
|
||||
width: 64
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin-top: 2
|
||||
|
||||
SpinBox
|
||||
id: spinbox
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
|
||||
HorizontalSeparator
|
||||
id: separator
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin-bottom: 10
|
||||
|
||||
Button
|
||||
id: buttonOk
|
||||
text: Ok
|
||||
width: 64
|
||||
anchors.right: next.left
|
||||
anchors.bottom: parent.bottom
|
||||
margin-right: 10
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
text: Cancel
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: self:getParent():destroy()
|
@ -0,0 +1,20 @@
|
||||
MiniWindow < UIMiniWindow
|
||||
font: verdana-11px-antialised
|
||||
//icon: /core_styles/icons/login.png
|
||||
icon-rect: 4 4 16 16
|
||||
width: 192
|
||||
height: 200
|
||||
text-offset: 26 5
|
||||
text-align: topLeft
|
||||
margin-top: 2
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
move-policy: free updated
|
||||
image-source: /core_styles/styles/images/mini_window.png
|
||||
image-border: 4
|
||||
image-border-top: 23
|
||||
padding: 25 8 2 8
|
||||
|
||||
$on:
|
||||
height: 24
|
||||
image-border-bottom: 1
|
@ -0,0 +1,2 @@
|
||||
UICountWindow = {}
|
||||
|
@ -0,0 +1,64 @@
|
||||
UIGameMap = extends(UIMap)
|
||||
|
||||
function UIGameMap.create()
|
||||
local gameMap = UIGameMap.internalCreate()
|
||||
return gameMap
|
||||
end
|
||||
|
||||
|
||||
function UIGameMap:onDragEnter(mousePos)
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
|
||||
local thing = tile:getTopMoveThing()
|
||||
if not thing then return false end
|
||||
|
||||
self.parsed = false
|
||||
self.currentDragThing = thing
|
||||
Mouse.setTargetCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onDragLeave(droppedWidget, mousePos)
|
||||
if not self.parsed then
|
||||
self.currentDragThing = nil
|
||||
end
|
||||
|
||||
Mouse.restoreCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
|
||||
local count = widget.currentDragThing:getCount()
|
||||
if widget.currentDragThing:isStackable() and count > 1 then
|
||||
widget.parsed = true
|
||||
local moveWindow = createWidget('CountWindow', rootWidget)
|
||||
local spinbox = moveWindow:getChildById('spinbox')
|
||||
spinbox:setMaximum(count)
|
||||
spinbox:setMinimum(1)
|
||||
spinbox:setCurrentIndex(count)
|
||||
|
||||
local okButton = moveWindow:getChildById('buttonOk')
|
||||
okButton.onClick = function()
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), spinbox:getCurrentIndex())
|
||||
okButton:getParent():destroy()
|
||||
widget.currentDragThing = nil
|
||||
end
|
||||
moveWindow.onEnter = okButton.onClick
|
||||
else
|
||||
g_game.move(widget.currentDragThing, tile:getPosition(), 1)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
||||
local tile = self:getTile(mousePosition)
|
||||
if tile and GameInterface.processMouseAction(mousePosition, mouseButton, nil, tile:getTopLookThing(), tile:getTopUseThing(), tile:getTopCreature(), tile:getTopMultiUseThing()) then return true end
|
||||
return false
|
||||
end
|
@ -0,0 +1,17 @@
|
||||
Module
|
||||
name: game
|
||||
description: Create the game interface, where the ingame stuff starts
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
reloadable: true
|
||||
|
||||
dependencies:
|
||||
- game_tibiafiles
|
||||
//- game_shaders
|
||||
|
||||
onLoad: |
|
||||
dofile 'game'
|
||||
dofile 'thing'
|
||||
dofile 'creature'
|
||||
dofile 'player'
|
||||
dofile 'map'
|
@ -1,4 +1,4 @@
|
||||
MainWindow
|
||||
CountWindow < MainWindow
|
||||
text: Move Item
|
||||
size: 196 112
|
||||
@onEscape: self:destroy()
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "container.h"
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "player.h"
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uigame.h"
|
||||
#include <otclient/core/game.h>
|
||||
#include <framework/ui/uilineedit.h>
|
||||
#include <framework/platform/platformwindow.h>
|
||||
|
||||
bool UIGame::onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks)
|
||||
{
|
||||
if(UIWidget::onKeyPress(keyCode, keyboardModifiers, autoRepeatTicks))
|
||||
return true;
|
||||
|
||||
UILineEditPtr chatLineEdit = std::dynamic_pointer_cast<UILineEdit>(getParent()->recursiveGetChildById("consoleLineEdit"));
|
||||
|
||||
//TODO: move this whole shit to lua
|
||||
if(keyboardModifiers == Fw::KeyboardNoModifier) {
|
||||
if(keyCode == Fw::KeyUp || keyCode == Fw::KeyNumpad8) {
|
||||
g_game.walk(Otc::North);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyRight || keyCode == Fw::KeyNumpad6) {
|
||||
g_game.walk(Otc::East);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyDown || keyCode == Fw::KeyNumpad2) {
|
||||
g_game.walk(Otc::South);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyLeft || keyCode == Fw::KeyNumpad4) {
|
||||
g_game.walk(Otc::West);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyNumpad9) {
|
||||
g_game.walk(Otc::NorthEast);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyNumpad3) {
|
||||
g_game.walk(Otc::SouthEast);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyNumpad1) {
|
||||
g_game.walk(Otc::SouthWest);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyNumpad7) {
|
||||
g_game.walk(Otc::NorthWest);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyDelete) {
|
||||
chatLineEdit->removeCharacter(true);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyBackspace) {
|
||||
chatLineEdit->removeCharacter(false);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyRight) {
|
||||
chatLineEdit->moveCursor(true);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyLeft) {
|
||||
chatLineEdit->moveCursor(false);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyHome) {
|
||||
chatLineEdit->setCursorPos(0);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyEnd) {
|
||||
chatLineEdit->setCursorPos(chatLineEdit->getText().length());
|
||||
return true;
|
||||
}
|
||||
} else if(keyboardModifiers == Fw::KeyboardCtrlModifier) {
|
||||
if(keyCode == Fw::KeyUp || keyCode == Fw::KeyNumpad8) {
|
||||
g_game.turn(Otc::North);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyRight || keyCode == Fw::KeyNumpad6) {
|
||||
g_game.turn(Otc::East);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyDown || keyCode == Fw::KeyNumpad2) {
|
||||
g_game.turn(Otc::South);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyLeft || keyCode == Fw::KeyNumpad4) {
|
||||
g_game.turn(Otc::West);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyV) {
|
||||
chatLineEdit->appendText(g_window.getClipboardText());
|
||||
}
|
||||
} else if(keyboardModifiers == Fw::KeyboardShiftModifier) {
|
||||
if(keyCode == Fw::KeyRight || keyCode == Fw::KeyNumpad6) {
|
||||
chatLineEdit->moveCursor(true);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyLeft || keyCode == Fw::KeyNumpad4) {
|
||||
chatLineEdit->moveCursor(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIGame::onKeyText(const std::string& keyText)
|
||||
{
|
||||
if(UIWidget::onKeyText(keyText))
|
||||
return true;
|
||||
|
||||
UILineEditPtr chatLineEdit = std::dynamic_pointer_cast<UILineEdit>(getParent()->recursiveGetChildById("consoleLineEdit"));
|
||||
chatLineEdit->appendText(keyText);
|
||||
return true;
|
||||
}
|