• 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!

OTClient X to close mod on the top right

sabodden

Member
Joined
Sep 27, 2019
Messages
138
Reaction score
18
How to create a X, to close in the top right window of a mod?

Just like this:
images


main.otui
Code:
MainWindow
  id: tutorialwindow
  width: 625
  height: 160
  !text: tr("Title of MOD")




  Button
    id: Little Button
    !text: tr('First button')
    width: 100
    height: 25
    @onClick: print('test')
 
Use MiniWindow instead.

There is a wiki about it?

How to remove minimize button, let only close?
How to put the title text on the center?
How to the Little Button a little to bottom to dont be in the window?
And last how to put that X to work, to actully close the window?

firstmod.lua
Code:
mainWindow = nil
mainButton = nil


function init()
    mainWindow = g_ui.displayUI('main.otui')
    mainWindow:hide()
    mainButton = modules.client_topmenu.addRightToggleButton('firstmod_button', tr('firstmod OTC'), 'data/imgs/firstmod_icon.png', onoff, true)
end


function terminate()
    mainWindow:hide()
end

function onoff()
    if mainWindow:isVisible() then
        mainWindow:hide()
    else
        mainWindow:show()
    end
end
 
in data\styles\30-miniwindow.otui
Code:
MiniWindow < UIMiniWindow
  font: verdana-11px-antialised
  icon-rect: 4 4 16 16
  width: 192
  height: 200
  text-offset: 24 5
  text-align: topLeft
  image-source: /images/ui/miniwindow
  image-border: 4
  image-border-top: 23
  image-border-bottom: 4
  focusable: false
  &minimizedHeight: 24

  $on:
    image-border-bottom: 2

  UIWidget
    id: miniwindowTopBar
    anchors.top: parent.top
    anchors.right: parent.right
    anchors.left: parent.left
    margin-right: 3
    margin-left: 3
    margin-top: 3
    size: 258 18
    phantom: true

  UIButton
    id: closeButton
    anchors.top: parent.top
    anchors.right: parent.right
    margin-top: 5
    margin-right: 5
    size: 14 14
    image-source: /images/ui/miniwindow_buttons
    image-clip: 28 0 14 14

    $hover:
      image-clip: 28 14 14 14

    $pressed:
      image-clip: 28 28 14 14

  UIButton
    id: minimizeButton
    anchors.top: closeButton.top
    anchors.right: closeButton.left
    margin-right: 3
    size: 14 14
    image-source: /images/ui/miniwindow_buttons
    image-clip: 0 0 14 14

    $hover:
      image-clip: 0 14 14 14

    $pressed:
      image-clip: 0 28 14 14

    $on:
      image-clip: 14 0 14 14

    $on hover:
      image-clip: 14 14 14 14

    $on pressed:
      image-clip: 14 28 14 14

  VerticalScrollBar
    id: miniwindowScrollBar
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    step: 14
    margin-top: 22
    margin-right: 3
    margin-bottom: 3
    pixels-scroll: true

    $!on:
      width: 0

  ResizeBorder
    id: bottomResizeBorder
    anchors.bottom: parent.bottom
    anchors.left: parent.left
    anchors.right: parent.right
    height: 3
    minimum: 48
    margin-left: 3
    margin-right: 3
    background: #ffffff88

MiniWindowContents < ScrollablePanel
  id: contentsPanel
  anchors.fill: parent
  anchors.right: miniwindowScrollBar.left
  margin-left: 3
  margin-bottom: 3
  margin-top: 22
  margin-right: 1
  vertical-scrollbar: miniwindowScrollBar

BorderlessGameWindow < UIWindow
  focusable: false
  margin: 2


i found nothing about none of the 4

1) How to remove minimize button, let only close?
2) How to put the title text on the center?
3) How to the Little Button a little to bottom to dont be in the window?
4) And last how to put that X to work, to actully close the window?
 
Take a look in OTUI files, looks like css
examples in /modules/game_inventory or /modules/...

u guys ever used this function?

the only where i found about miniwindow was miniwindow.otui in otclient | source code search engine (https://searchcode.com/codesearch/view/16066295/)

look how it is: Screenshot-from-2019-09-29-08-09-03 (https://ibb.co/0FgZ0DV)

and there is nothing about none of 6
1) How to remove minimize button, let only close?
2) How to put the title window text on the center?
3) How to the Little Button a little to bottom to dont be in the window?
4) And last how to put that X to work, to actully close the window?
5) how to spawn the window in the center of screen, not top left
6) how to remove scroll bar
 
You can take a lot of examples in OTUI files and also check this:

Label This is a label widget that is used for displaying text in most cases. It is a derivative of UILabel class.

id: This is the id that this commonest will alias itself with for referencing using functions such as widget:getChildById("spellsLabel")
!text: This is the text that will be displayed by the UILabel widget.
width: This is the width size of the Label.
anchors.top/bottom/left/right: Anchors are where the top/bottom/left/right of the Label should be positioned, this is often based on the previous (prev) UI component or the parents anchors.
margin-top/bottom/left/right: Margins are offsets to the anchors, they will allow you to fine-tune the placement of UI components.

More in:

 
Back
Top