mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-13 22:34:53 +02:00
fix items, map, protocls
This commit is contained in:
1188
800OTClient/modules/game_interface/gameinterface.lua
Normal file
1188
800OTClient/modules/game_interface/gameinterface.lua
Normal file
File diff suppressed because it is too large
Load Diff
208
800OTClient/modules/game_interface/gameinterface.otui
Normal file
208
800OTClient/modules/game_interface/gameinterface.otui
Normal file
@@ -0,0 +1,208 @@
|
||||
GameSidePanel < UIMiniWindowContainer
|
||||
image-source: /images/ui/panel_side
|
||||
image-border: 4
|
||||
padding: 3
|
||||
padding-top: 0
|
||||
width: 198
|
||||
focusable: false
|
||||
on: true
|
||||
layout:
|
||||
type: verticalBox
|
||||
$mobile:
|
||||
padding: 0
|
||||
width: 200
|
||||
|
||||
|
||||
GameMapPanel < UIGameMap
|
||||
padding: 4
|
||||
image-source: /images/ui/panel_map
|
||||
image-border: 4
|
||||
|
||||
$on:
|
||||
padding: 0
|
||||
|
||||
GameAction < UIButton
|
||||
size: 64 64
|
||||
phantom: false
|
||||
|
||||
UIButton
|
||||
id: image
|
||||
size: 48 48
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
phantom: true
|
||||
$checked:
|
||||
opacity: 1.0
|
||||
background: #00FF0033
|
||||
$!checked:
|
||||
opacity: 0.6
|
||||
background: alpha
|
||||
|
||||
|
||||
UIWidget
|
||||
id: gameRootPanel
|
||||
anchors.fill: parent
|
||||
|
||||
GameMapPanel
|
||||
id: gameMapPanel
|
||||
anchors.left: gameLeftPanels.right
|
||||
anchors.right: gameRightPanels.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: gameBottomPanel.top
|
||||
focusable: false
|
||||
|
||||
Panel
|
||||
id: gameLeftActions
|
||||
focusable: false
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: 64
|
||||
|
||||
$!mobile:
|
||||
visible: false
|
||||
width: 0
|
||||
|
||||
layout:
|
||||
type: verticalBox
|
||||
fit-children: true
|
||||
|
||||
GameAction
|
||||
id: use
|
||||
@onSetup: self.image:setImageSource("/images/game/mobile/use")
|
||||
GameAction
|
||||
id: attack
|
||||
@onSetup: self.image:setImageSource("/images/game/mobile/attack")
|
||||
GameAction
|
||||
id: follow
|
||||
@onSetup: self.image:setImageSource("/images/game/mobile/follow")
|
||||
GameAction
|
||||
id: look
|
||||
@onSetup: self.image:setImageSource("/images/game/mobile/look")
|
||||
GameAction
|
||||
id: chat
|
||||
@onSetup: self.image:setImageSource("/images/game/mobile/chat")
|
||||
|
||||
Panel
|
||||
id: gameLeftPanels
|
||||
focusable: false
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
$!mobile:
|
||||
anchors.left: parent.left
|
||||
$mobile:
|
||||
anchors.left: gameLeftActions.right
|
||||
|
||||
layout:
|
||||
type: horizontalBox
|
||||
fit-children: true
|
||||
spacing: -1
|
||||
|
||||
Panel
|
||||
id: gameLeftActionPanel
|
||||
phantom: true
|
||||
focusable: false
|
||||
anchors.top: gameTopBar.bottom
|
||||
anchors.left: gameLeftPanels.right
|
||||
anchors.bottom: bottomSplitter.top
|
||||
margin-top: 3
|
||||
|
||||
$mobile:
|
||||
visible: false
|
||||
|
||||
layout:
|
||||
type: horizontalBox
|
||||
fit-children: true
|
||||
|
||||
Panel
|
||||
id: gameRightPanels
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
focusable: false
|
||||
layout:
|
||||
type: horizontalBox
|
||||
fit-children: true
|
||||
spacing: -1
|
||||
|
||||
Panel
|
||||
id: gameRightActionPanel
|
||||
phantom: true
|
||||
focusable: false
|
||||
anchors.top: gameTopBar.bottom
|
||||
anchors.right: gameRightPanels.left
|
||||
anchors.bottom: bottomSplitter.top
|
||||
margin-top: 3
|
||||
|
||||
$mobile:
|
||||
visible: false
|
||||
|
||||
layout:
|
||||
type: horizontalBox
|
||||
fit-children: true
|
||||
|
||||
Splitter
|
||||
id: bottomSplitter
|
||||
anchors.left: gameLeftPanels.right
|
||||
anchors.right: gameRightPanels.left
|
||||
anchors.bottom: parent.bottom
|
||||
height: 5
|
||||
relative-margin: bottom
|
||||
margin-bottom: 150
|
||||
@canUpdateMargin: function(self, newMargin) if modules.client_options.getOption('dontStretchShrink') then return self:getMarginBottom() end return math.max(math.min(newMargin, self:getParent():getHeight() - 150), 80) end
|
||||
@onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 150, 80), self:getMarginBottom())) end
|
||||
|
||||
$mobile:
|
||||
visible: false
|
||||
|
||||
Panel
|
||||
id: gameBottomActionPanel
|
||||
phantom: true
|
||||
focusable: false
|
||||
|
||||
$!mobile:
|
||||
anchors.left: bottomSplitter.left
|
||||
anchors.right: bottomSplitter.right
|
||||
anchors.top: bottomSplitter.top
|
||||
margin-top: 3
|
||||
|
||||
$mobile:
|
||||
anchors.left: gameLeftPanels.right
|
||||
anchors.right: gameRightPanels.left
|
||||
anchors.bottom: gameBottomPanel.top
|
||||
|
||||
layout:
|
||||
type: verticalBox
|
||||
fit-children: true
|
||||
|
||||
Panel
|
||||
id: gameBottomPanel
|
||||
$!mobile:
|
||||
anchors.left: gameBottomActionPanel.left
|
||||
anchors.right: gameBottomActionPanel.right
|
||||
anchors.top: gameBottomActionPanel.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
$mobile:
|
||||
anchors.left: gameLeftPanels.right
|
||||
anchors.right: gameRightPanels.left
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
UIWidget
|
||||
id: mouseGrabber
|
||||
focusable: false
|
||||
visible: false
|
||||
|
||||
Panel
|
||||
id: gameTopBar
|
||||
image-source: /images/ui/panel_bottom2
|
||||
anchors.top: parent.top
|
||||
anchors.left: gameBottomActionPanel.left
|
||||
anchors.right: gameBottomActionPanel.right
|
||||
focusable: false
|
||||
|
||||
$mobile:
|
||||
height: 0
|
||||
|
||||
layout:
|
||||
type: verticalBox
|
||||
fit-children: true
|
46
800OTClient/modules/game_interface/interface.otmod
Normal file
46
800OTClient/modules/game_interface/interface.otmod
Normal file
@@ -0,0 +1,46 @@
|
||||
Module
|
||||
name: game_interface
|
||||
description: Create the game interface, where the ingame stuff starts
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
sandboxed: true
|
||||
scripts: [ widgets/uigamemap, gameinterface ]
|
||||
load-later:
|
||||
- game_buttons
|
||||
- game_hotkeys
|
||||
- game_questlog
|
||||
- game_textmessage
|
||||
- game_console
|
||||
- game_outfit
|
||||
- game_healthinfo
|
||||
- game_skills
|
||||
- game_inventory
|
||||
- game_containers
|
||||
- game_viplist
|
||||
- game_battle
|
||||
- game_minimap
|
||||
- game_npctrade
|
||||
- game_textwindow
|
||||
- game_playertrade
|
||||
- game_bugreport
|
||||
- game_playerdeath
|
||||
- game_playermount
|
||||
- game_ruleviolation
|
||||
- game_market
|
||||
- game_spelllist
|
||||
- game_cooldown
|
||||
- game_modaldialog
|
||||
- game_unjustifiedpoints
|
||||
- game_walking
|
||||
- game_shop
|
||||
- game_itemselector
|
||||
- client_textedit
|
||||
- client_profiles
|
||||
- game_actionbar
|
||||
- game_prey
|
||||
- game_imbuing
|
||||
- game_stats
|
||||
- game_shaders
|
||||
- game_bot
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
53
800OTClient/modules/game_interface/styles/countwindow.otui
Normal file
53
800OTClient/modules/game_interface/styles/countwindow.otui
Normal file
@@ -0,0 +1,53 @@
|
||||
CountWindow < MainWindow
|
||||
id: countWindow
|
||||
!text: tr('Move Stackable Item')
|
||||
size: 196 90
|
||||
|
||||
SpinBox
|
||||
id: spinBox
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
width: 1
|
||||
height: 1
|
||||
phantom: true
|
||||
margin-top: 2
|
||||
focusable: true
|
||||
|
||||
Item
|
||||
id: item
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
margin-top: 2
|
||||
margin-left: -4
|
||||
focusable: false
|
||||
virtual: true
|
||||
|
||||
HorizontalScrollBar
|
||||
id: countScrollBar
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin-left: 10
|
||||
margin-top: -2
|
||||
focusable: false
|
||||
|
||||
Button
|
||||
id: buttonCancel
|
||||
!text: tr('Cancel')
|
||||
height: 20
|
||||
anchors.left: countScrollBar.horizontalCenter
|
||||
anchors.right: countScrollBar.right
|
||||
anchors.top: countScrollBar.bottom
|
||||
margin-top: 7
|
||||
focusable: false
|
||||
|
||||
Button
|
||||
id: buttonOk
|
||||
!text: tr('Ok')
|
||||
height: 20
|
||||
anchors.right: countScrollBar.horizontalCenter
|
||||
anchors.left: countScrollBar.left
|
||||
anchors.top: countScrollBar.bottom
|
||||
margin-top: 7
|
||||
margin-right: 6
|
||||
focusable: false
|
196
800OTClient/modules/game_interface/widgets/uigamemap.lua
Normal file
196
800OTClient/modules/game_interface/widgets/uigamemap.lua
Normal file
@@ -0,0 +1,196 @@
|
||||
UIGameMap = extends(UIMap, "UIGameMap")
|
||||
|
||||
function UIGameMap.create()
|
||||
local gameMap = UIGameMap.internalCreate()
|
||||
gameMap:setKeepAspectRatio(true)
|
||||
gameMap:setVisibleDimension({width = 15, height = 11})
|
||||
gameMap:setDrawLights(true)
|
||||
gameMap.markedThing = nil
|
||||
gameMap.blockNextRelease = 0
|
||||
gameMap:updateMarkedCreature()
|
||||
return gameMap
|
||||
end
|
||||
|
||||
function UIGameMap:onDestroy()
|
||||
if self.updateMarkedCreatureEvent then
|
||||
removeEvent(self.updateMarkedCreatureEvent)
|
||||
end
|
||||
end
|
||||
|
||||
function UIGameMap:markThing(thing, color)
|
||||
if self.markedThing == thing then
|
||||
return
|
||||
end
|
||||
if self.markedThing then
|
||||
self.markedThing:setMarked('')
|
||||
end
|
||||
|
||||
self.markedThing = thing
|
||||
if self.markedThing and g_settings.getBoolean('highlightThingsUnderCursor') then
|
||||
self.markedThing:setMarked(color)
|
||||
end
|
||||
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.currentDragThing = thing
|
||||
|
||||
g_mouse.pushCursor('target')
|
||||
self.allowNextRelease = false
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onDragLeave(droppedWidget, mousePos)
|
||||
self.currentDragThing = nil
|
||||
self.hoveredWho = nil
|
||||
g_mouse.popCursor('target')
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onDrop(widget, mousePos)
|
||||
if not self:canAcceptDrop(widget, mousePos) then return false end
|
||||
|
||||
local tile = self:getTile(mousePos)
|
||||
if not tile then return false end
|
||||
|
||||
local thing = widget.currentDragThing
|
||||
local toPos = tile:getPosition()
|
||||
|
||||
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:isItem() and thing:getCount() > 1 then
|
||||
modules.game_interface.moveStackableItem(thing, toPos)
|
||||
else
|
||||
g_game.move(thing, toPos, 1)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function UIGameMap:onMouseMove(mousePos, mouseMoved)
|
||||
self.mousePos = mousePos
|
||||
return false
|
||||
end
|
||||
|
||||
function UIGameMap:onDragMove(mousePos, mouseMoved)
|
||||
self.mousePos = mousePos
|
||||
return false
|
||||
end
|
||||
|
||||
function UIGameMap:updateMarkedCreature()
|
||||
self.updateMarkedCreatureEvent = scheduleEvent(function() self:updateMarkedCreature() end, 100)
|
||||
if self.mousePos and g_game.isOnline() then
|
||||
self.markingMouseRelease = true
|
||||
self:onMouseRelease(self.mousePos, MouseRightButton)
|
||||
self.markingMouseRelease = false
|
||||
end
|
||||
end
|
||||
|
||||
function UIGameMap:onMousePress()
|
||||
if not self:isDragging() and self.blockNextRelease < g_clock.millis() then
|
||||
self.allowNextRelease = true
|
||||
self.markingMouseRelease = false
|
||||
end
|
||||
end
|
||||
|
||||
function UIGameMap:blockNextMouseRelease(postAction)
|
||||
self.allowNextRelease = false
|
||||
if postAction then
|
||||
self.blockNextRelease = g_clock.millis() + 150
|
||||
else
|
||||
self.blockNextRelease = g_clock.millis() + 250
|
||||
end
|
||||
end
|
||||
|
||||
function UIGameMap:onMouseRelease(mousePosition, mouseButton)
|
||||
if not self.allowNextRelease and not self.markingMouseRelease then
|
||||
return true
|
||||
end
|
||||
local autoWalkPos = self:getPosition(mousePosition)
|
||||
local positionOffset = self:getPositionOffset(mousePosition)
|
||||
|
||||
-- happens when clicking outside of map boundaries
|
||||
if not autoWalkPos then
|
||||
if self.markingMouseRelease then
|
||||
self:markThing(nil)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local localPlayerPos = g_game.getLocalPlayer():getPosition()
|
||||
if autoWalkPos.z ~= localPlayerPos.z then
|
||||
local dz = autoWalkPos.z - localPlayerPos.z
|
||||
autoWalkPos.x = autoWalkPos.x + dz
|
||||
autoWalkPos.y = autoWalkPos.y + dz
|
||||
autoWalkPos.z = localPlayerPos.z
|
||||
end
|
||||
|
||||
local lookThing
|
||||
local useThing
|
||||
local creatureThing
|
||||
local multiUseThing
|
||||
local attackCreature
|
||||
|
||||
local tile = self:getTile(mousePosition)
|
||||
if tile then
|
||||
lookThing = tile:getTopLookThingEx(positionOffset)
|
||||
useThing = tile:getTopUseThing()
|
||||
creatureThing = tile:getTopCreatureEx(positionOffset)
|
||||
end
|
||||
|
||||
local autoWalkTile = g_map.getTile(autoWalkPos)
|
||||
if autoWalkTile then
|
||||
attackCreature = autoWalkTile:getTopCreatureEx(positionOffset)
|
||||
end
|
||||
|
||||
if self.markingMouseRelease then
|
||||
if attackCreature then
|
||||
self:markThing(attackCreature, 'yellow')
|
||||
elseif creatureThing then
|
||||
self:markThing(creatureThing, 'yellow')
|
||||
elseif useThing and not useThing:isGround() then
|
||||
self:markThing(useThing, 'yellow')
|
||||
elseif lookThing and not lookThing:isGround() then
|
||||
self:markThing(lookThing, 'yellow')
|
||||
else
|
||||
self:markThing(nil, '')
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local ret = modules.game_interface.processMouseAction(mousePosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature, self.markingMouseRelease)
|
||||
if ret then
|
||||
self.allowNextRelease = false
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function UIGameMap:onTouchRelease(mousePosition, mouseButton)
|
||||
if mouseButton ~= MouseTouch then
|
||||
return self:onMouseRelease(mousePosition, mouseButton)
|
||||
end
|
||||
end
|
||||
|
||||
function UIGameMap:canAcceptDrop(widget, mousePos)
|
||||
if not widget or not widget.currentDragThing then return false end
|
||||
|
||||
local children = rootWidget:recursiveGetChildrenByPos(mousePos)
|
||||
for i=1,#children do
|
||||
local child = children[i]
|
||||
if child == self then
|
||||
return true
|
||||
elseif not child:isPhantom() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
error('Widget ' .. self:getId() .. ' not in drop list.')
|
||||
return false
|
||||
end
|
Reference in New Issue
Block a user