EnterGameWindow < MainWindow
  !text: tr('Enter Game')
  size: 236 316


EnterGameButton < Button
  width: 64

ServerListButton < UIButton
  size: 17 17
  image-source: /images/topbuttons/minimap
  image-color: #ffffffff

  $hover !disabled:
    image-color: #ffffff99

  $pressed:
    image-color: #ffffff44

  $disabled:
    image-color: #ffffff55

EnterGameWindow
  id: enterGame
  &authenticatorEnabled: false
  &authenticatorHeight: 44
  &stayLoggedBoxEnabled: false
  &stayLoggedBoxHeight: 24
  size: 280 285
  @onEnter: EnterGame.doLogin()

  Label
    id: emailLabel
    !text: tr('Acc Name:') 
    anchors.left: parent.left
    anchors.top: parent.top

    opacity: 0.8

      
  Label
    id: passwordLabel
    !text: tr('Password:')
    anchors.left: emailLabel.left
    anchors.top: emailLabel.bottom
    margin-top: 10
    opacity: 0.8

  HiddenTextQtToggleEdit
    id: accountNameTextEdit
    anchors.right: accountPasswordTextEdit.right
    anchors.verticalCenter: emailLabel.verticalCenter
    anchors.left: accountPasswordTextEdit.left
    
  HiddenTextQtEdit
    id: accountPasswordTextEdit
    anchors.right: parent.right
    anchors.left: passwordLabel.right
    anchors.verticalCenter: passwordLabel.verticalCenter
    margin-left: 5

  QtCheckBox
    id: rememberEmailBox
    !text: tr('Remember password')
    !tooltip: tr('Remember account and password when starts client')
    anchors.left: passwordLabel.left
    anchors.right: parent.right
    anchors.top: accountPasswordTextEdit.bottom
    margin-top: 10
    opacity: 0.8
    @onCheckChange: |
      self:getParent():getChildById('autoLoginBox'):setEnabled(self:isChecked())
      self:getParent():getChildById('rememberEmailTip'):setOn(self:isChecked())

  UIWidget
    id: rememberEmailTip
    image-source: /images/icons/show_gui_help_grey
    !specialtooltip: 'Be aware that your email address will be stored on your configuration file "config.otml" if you activate this option.'
    anchors.right: accountNameTextEdit.right
    anchors.verticalCenter: rememberEmailBox.verticalCenter
    visible: false

    $on:
      visible: true

    $!on:
      visible: false

  UIButton
    !text: tr('Forgot password and/or email')
    id: Forgot_password_email
    font: verdana-11px-monochrome-underline
    text-align: left
    anchors.left: rememberEmailBox.left
    anchors.right: parent.right
    anchors.top: rememberEmailBox.bottom
    opacity: 0.8
    margin-top: 5
    @onClick: g_platform.openUrl(Services.websites)
    @onSetup: | 
        if Services and Services.websites then
            self:setVisible(true)
        else
            self:setVisible(false)
            self:hide()
        end

  QtCheckBox
    id: stayLoggedBox
    !text: tr('Stay logged during session')
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 6
    margin-top: -16
    visible: false

    $on:
      visible: true
      margin-top: 8

  HorizontalSeparator
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 8

  MenuLabel
    id: serverLabel
    !text: tr('Server')
    anchors.left: prev.left
    anchors.top: prev.bottom
    margin-top: 8
    text-auto-resize: true

  ServerListButton
    id: serverListButton
    !tooltip: tr('Server list')
    anchors.right: parent.right
    anchors.top: serverLabel.bottom
    margin-top: 3
    @onClick: EnterGame.showServerList()

  TextEdit
    id: serverHostTextEdit
    !tooltip: tr('Make sure that your client uses\nthe correct game client version')
    anchors.left: parent.left
    anchors.right: serverListButton.left
    anchors.top: serverLabel.bottom
    margin-top: 2
    margin-right: 4

  MenuLabel
    id: clientLabel
    !text: tr('Client Version')
    anchors.left: parent.left
    anchors.top: serverHostTextEdit.bottom
    text-auto-resize: true
    margin-right: 10
    margin-top: 8

  ComboBox
    id: clientComboBox
    anchors.left: parent.left
    anchors.right: parent.horizontalCenter
    anchors.top: clientLabel.bottom
    margin-top: 2
    margin-right: 3
    width: 90
    menu-scroll: true
    menu-height: 125
    menu-scroll-step: 25

  MenuLabel
    id: portLabel
    !text: tr('Port')
    anchors.left: serverPortTextEdit.left
    anchors.top: serverHostTextEdit.bottom
    margin-top: 8
    text-auto-resize: true

  TextEdit
    id: serverPortTextEdit
    text: 7171
    anchors.right: parent.right
    anchors.left: parent.horizontalCenter
    anchors.top: clientComboBox.top
    margin-left: 3

  QtCheckBox
    id: autoLoginBox
    enabled: false
    !text: tr('Auto login')
    !tooltip: tr('Open charlist automatically when starting client')
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 10

  QtCheckBox
    id: httpLoginBox
    enabled: true
    !text: tr('Enable HTTP login')
    !tooltip: tr('If login fails using HTTPS (encrypted) try with HTTP (unencrypted)')
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 2

  HorizontalSeparator
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 6

  QtButton
    !text: tr('Login')
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 9
    size: 86 20
    @onClick: EnterGame.doLogin()

  QtButton
    id: btnCreateNewAccount
    !text: tr('Create New Account')
    anchors.left: parent.left
    anchors.top: prev.bottom
    margin-top: -17
    size: 109 20
    @onClick: |
      self:disable()
      createWidgetAccount()

    @onSetup: | 
      if Services and Servers_init and table.size(Servers_init) == 1 and Services.createAccount then
        self:setVisible(true)
      else
        self:setVisible(false)
      end

  Label
    id: serverInfoLabel
    font: verdana-11px-rounded
    anchors.top: prev.top
    anchors.left: parent.left
    margin-top: 5
    color: green
    text-auto-resize: true
