• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Fixed Window

xDyego

Member
Joined
Feb 28, 2012
Messages
83
Solutions
1
Reaction score
16
Location
São Paulo - Brazil
I would like to know how to leave a fixed window, so the player will not be able to drag it

translated from Portuguese​
 
I think you can use draggable: false, if not make a function for that.
 
I would like to know how to leave a fixed window, so the player will not be able to drag it

translated from Portuguese​

Like margoh said, just set the attribute "draggable:false" to the widget you don't want to be draggable.
If via lua, then use:
Code:
widget:setDraggable(false)
 
I could not find widget: setDraggable (false) in .lua file

That was just an example of how you would do it if you want to set a widget to be draggable via a lua function.

To recap, you can do it either in otui or lua, depending on your needs.
In otui, you'd do it by setting draggable: false as an attribute to a widget, in lua you would do it via that function, but you must replace "widget" with the widget object you're trying to set draggable.
 
Last edited:
That was just an example of how you would do it if you want to set a widget to be draggable via a lua function.

To recap, you can do it either in otui or lua, depending on your needs.
In otui, you'd do it by setting draggable: false as an attribute to a widget, in lua you would do it via that function, but you must replace "widget" with the widget object you're trying to set draggable.

I have type, that the minimap is not draggable, that it stays fixed, I do not understand anything of .lua, this function I could for her in minimap.lua?
 
minimapWidget = nil
minimapButton = nil
minimapWindow = nil
otmm = true
preloaded = false
fullmapView = false
oldZoom = nil
oldPos = nil

function init()
minimapButton = modules.client_topmenu.addRightGameToggleButton('minimapButton',
tr('Minimap') .. ' (Ctrl+M)', '/images/topbuttons/minimap', toggle)
minimapButton:setOn(true)

minimapWindow = g_ui.loadUI('minimap', modules.game_interface.getRightPanel())
minimapWindow:setContentMinimumHeight(64)

minimapWidget = minimapWindow:recursiveGetChildById('minimap')

local gameRootPanel = modules.game_interface.getRootPanel()
g_keyboard.bindKeyPress('Alt+Left', function() minimapWidget:move(1,0) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Right', function() minimapWidget:move(-1,0) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Up', function() minimapWidget:move(0,1) end, gameRootPanel)
g_keyboard.bindKeyPress('Alt+Down', function() minimapWidget:move(0,-1) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+M', toggle)
g_keyboard.bindKeyDown('Ctrl+Shift+M', toggleFullMap)

minimapWindow:setup()
minimapWindow:getChildById('closeButton'):hide()
minimapWindow:getChildById('minimizeButton'):hide()
minimapWindow:getChildById('miniwindowTopBar').onDoubleClick = nil

connect(g_game, {
onGameStart = online,
onGameEnd = offline,
})

connect(LocalPlayer, {
onPositionChange = updateCameraPosition
})

if g_game.isOnline() then
online()
end
end

function terminate()
if g_game.isOnline() then
saveMap()
end

disconnect(g_game, {
onGameStart = online,
onGameEnd = offline,
})

disconnect(LocalPlayer, {
onPositionChange = updateCameraPosition
})

local gameRootPanel = modules.game_interface.getRootPanel()
g_keyboard.unbindKeyPress('Alt+Left', gameRootPanel)
g_keyboard.unbindKeyPress('Alt+Right', gameRootPanel)
g_keyboard.unbindKeyPress('Alt+Up', gameRootPanel)
g_keyboard.unbindKeyPress('Alt+Down', gameRootPanel)
g_keyboard.unbindKeyDown('Ctrl+M')
g_keyboard.unbindKeyDown('Ctrl+Shift+M')

minimapWindow:destroy()
minimapButton:destroy()
end

function toggle()
if minimapButton:isOn() then
minimapWindow:close()
minimapButton:setOn(false)
else
minimapWindow:eek:pen()
minimapButton:setOn(true)
end
end

function onMiniWindowClose()
minimapButton:setOn(false)
end

function preload()
loadMap(false)
preloaded = true
end

function online()
loadMap(not preloaded)
updateCameraPosition()
end

function offline()
saveMap()
end

function loadMap(clean)
local clientVersion = g_game.getClientVersion()

if clean then
g_minimap.clean()
end

if otmm then
local minimapFile = '/minimap.otmm'
if g_resources.fileExists(minimapFile) then
g_minimap.loadOtmm(minimapFile)
end
else
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
if g_resources.fileExists(minimapFile) then
g_map.loadOtcm(minimapFile)
end
end
minimapWidget:load()
end

function saveMap()
local clientVersion = g_game.getClientVersion()
if otmm then
local minimapFile = '/minimap.otmm'
g_minimap.saveOtmm(minimapFile)
else
local minimapFile = '/minimap_' .. clientVersion .. '.otcm'
g_map.saveOtcm(minimapFile)
end
minimapWidget:save()
end

function updateCameraPosition()
local player = g_game.getLocalPlayer()
if not player then return end
local pos = player:getPosition()
if not pos then return end
if not fullmapView then
minimapWidget:setCameraPosition(player:getPosition())
end
minimapWidget:setCrossPosition(player:getPosition())
end
end

function toggleFullMap()
if not fullmapView then
fullmapView = true
minimapWindow:hide()
minimapWidget:setParent(modules.game_interface.getRootPanel())
minimapWidget:fill('parent')
minimapWidget:setAlternativeWidgetsVisible(true)
else
fullmapView = false
minimapWidget:setParent(minimapWindow:getChildById('contentsPanel'))
minimapWidget:fill('parent')
minimapWindow:show()
minimapWidget:setAlternativeWidgetsVisible(false)
end

local zoom = oldZoom or 0
local pos = oldPos or minimapWidget:getCameraPosition()
oldZoom = minimapWidget:getZoom()
oldPos = minimapWidget:getCameraPosition()
minimapWidget:setZoom(zoom)
minimapWidget:setCameraPosition(pos)
end

MiniWindow
id: minimapWindow
!text: tr('Minimap')
height: 150
icon: /images/topbuttons/minimap
@onClose: modules.game_minimap.onMiniWindowClose()
&save: true

MiniWindowContents
Minimap
id: minimap
anchors.fill: parent
 
@xDyego

Just replace your otui with this, reload module/or restart client, and try then.
Also, careful with this formatting from otland, it looks like it might be deleting whitespace.
Note that you need to add 2 spaces in front of each attribute to position it properly within the hierarchy in otui.

Code:
MiniWindow
id: minimapWindow
draggable: false
!text: tr('Minimap')
height: 150
icon: /images/topbuttons/minimap
@onClose: modules.game_minimap.onMiniWindowClose()
&save: true

MiniWindowContents
Minimap
id: minimap
anchors.fill: parent
 
Back
Top