Fixes to horizontal scrollarea, improve charlist flexibility
This commit is contained in:
		
							parent
							
								
									c517f7b745
								
							
						
					
					
						commit
						18a0d7ab94
					
				| 
						 | 
					@ -78,7 +78,7 @@ local function resendWait()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if charactersWindow then
 | 
					    if charactersWindow then
 | 
				
			||||||
      local selected = charactersWindow:getChildById('characterList'):getFocusedChild()
 | 
					      local selected = characterList:getFocusedChild()
 | 
				
			||||||
      if selected then
 | 
					      if selected then
 | 
				
			||||||
        local charInfo = { worldHost = selected.worldHost,
 | 
					        local charInfo = { worldHost = selected.worldHost,
 | 
				
			||||||
                           worldPort = selected.worldPort,
 | 
					                           worldPort = selected.worldPort,
 | 
				
			||||||
| 
						 | 
					@ -101,19 +101,6 @@ local function onLoginWait(message, time)
 | 
				
			||||||
  resendWaitEvent = scheduleEvent(resendWait, time * 1000)
 | 
					  resendWaitEvent = scheduleEvent(resendWait, time * 1000)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
 | 
					 | 
				
			||||||
  if keyboardModifiers == KeyboardNoModifier then
 | 
					 | 
				
			||||||
    if keyCode == KeyUp then
 | 
					 | 
				
			||||||
      characterList:focusPreviousChild(KeyboardFocusReason)
 | 
					 | 
				
			||||||
      return true
 | 
					 | 
				
			||||||
    elseif keyCode == KeyDown or keyCode == KeyTab then
 | 
					 | 
				
			||||||
      characterList:focusNextChild(KeyboardFocusReason)
 | 
					 | 
				
			||||||
      return true
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
  return false
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function onGameLoginError(message)
 | 
					function onGameLoginError(message)
 | 
				
			||||||
  CharacterList.destroyLoadBox()
 | 
					  CharacterList.destroyLoadBox()
 | 
				
			||||||
  errorBox = displayErrorBox(tr("Login Error"), message)
 | 
					  errorBox = displayErrorBox(tr("Login Error"), message)
 | 
				
			||||||
| 
						 | 
					@ -134,10 +121,6 @@ end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- public functions
 | 
					-- public functions
 | 
				
			||||||
function CharacterList.init()
 | 
					function CharacterList.init()
 | 
				
			||||||
  charactersWindow = g_ui.displayUI('characterlist.otui')
 | 
					 | 
				
			||||||
  charactersWindow:hide()
 | 
					 | 
				
			||||||
  characterList = charactersWindow:getChildById('characterList')
 | 
					 | 
				
			||||||
  charactersWindow.onKeyPress = onCharactersWindowKeyPress
 | 
					 | 
				
			||||||
  connect(g_game, { onLoginError = onGameLoginError })
 | 
					  connect(g_game, { onLoginError = onGameLoginError })
 | 
				
			||||||
  connect(g_game, { onConnectionError = onGameConnectionError })
 | 
					  connect(g_game, { onConnectionError = onGameConnectionError })
 | 
				
			||||||
  connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
 | 
					  connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
 | 
				
			||||||
| 
						 | 
					@ -145,7 +128,7 @@ function CharacterList.init()
 | 
				
			||||||
  connect(g_game, { onGameEnd = CharacterList.showAgain })
 | 
					  connect(g_game, { onGameEnd = CharacterList.showAgain })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if G.characters then
 | 
					  if G.characters then
 | 
				
			||||||
    CharacterList.create(G.characters, G.premDays)
 | 
					    CharacterList.create(G.characters, G.characterAccount)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,9 +138,8 @@ function CharacterList.terminate()
 | 
				
			||||||
  disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox })
 | 
					  disconnect(g_game, { onGameStart = CharacterList.destroyLoadBox })
 | 
				
			||||||
  disconnect(g_game, { onLoginWait = onLoginWait })
 | 
					  disconnect(g_game, { onLoginWait = onLoginWait })
 | 
				
			||||||
  disconnect(g_game, { onGameEnd = CharacterList.showAgain })
 | 
					  disconnect(g_game, { onGameEnd = CharacterList.showAgain })
 | 
				
			||||||
  characterList = nil
 | 
					  CharacterList.destroy()
 | 
				
			||||||
  charactersWindow:destroy()
 | 
					
 | 
				
			||||||
  charactersWindow = nil
 | 
					 | 
				
			||||||
  if loadBox then
 | 
					  if loadBox then
 | 
				
			||||||
    g_game.cancelLogin()
 | 
					    g_game.cancelLogin()
 | 
				
			||||||
    loadBox:destroy()
 | 
					    loadBox:destroy()
 | 
				
			||||||
| 
						 | 
					@ -182,36 +164,54 @@ function CharacterList.terminate()
 | 
				
			||||||
  CharacterList = nil
 | 
					  CharacterList = nil
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function CharacterList.create(characters, account)
 | 
					function CharacterList.create(characters, account, otui)
 | 
				
			||||||
 | 
					  if not otui then otui = 'characterlist.otui' end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  charactersWindow = g_ui.displayUI(otui)
 | 
				
			||||||
 | 
					  characterList = charactersWindow:getChildById('characters')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -- characters
 | 
				
			||||||
  G.characters = characters
 | 
					  G.characters = characters
 | 
				
			||||||
  G.premDays = account.premDays
 | 
					  G.characterAccount = account
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  characterList:destroyChildren()
 | 
					  characterList:destroyChildren()
 | 
				
			||||||
  local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
 | 
					  local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  local focusLabel
 | 
					  local focusLabel
 | 
				
			||||||
  for i,characterInfo in ipairs(characters) do
 | 
					  for i,characterInfo in ipairs(characters) do
 | 
				
			||||||
    local characterName = characterInfo.name
 | 
					    local widget = g_ui.createWidget('CharacterWidget', characterList)
 | 
				
			||||||
    local worldName = characterInfo.worldName
 | 
					    for key,value in pairs(characterInfo) do
 | 
				
			||||||
    local worldHost = characterInfo.worldIp
 | 
					      local subWidget = widget:getChildById(key)
 | 
				
			||||||
    local worldPort = characterInfo.worldPort
 | 
					      if subWidget then
 | 
				
			||||||
 | 
					        if key == 'outfit' then -- it's an exception
 | 
				
			||||||
 | 
					          subWidget:setOutfit(value)
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          local text = value
 | 
				
			||||||
 | 
					          if subWidget.baseText and subWidget.baseTranslate then
 | 
				
			||||||
 | 
					            text = tr(subWidget.baseText, text)
 | 
				
			||||||
 | 
					          elseif subWidget.baseText then
 | 
				
			||||||
 | 
					            text = string.format(subWidget.baseText, text)
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					          subWidget:setText(text)
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local label = g_ui.createWidget('CharacterListLabel', characterList)
 | 
					    -- these are used by login
 | 
				
			||||||
    label:setText(characterName .. '  (' .. worldName .. ')')
 | 
					    widget.characterName = characterInfo.name
 | 
				
			||||||
    label:setPhantom(false)
 | 
					    widget.worldHost = characterInfo.worldIp
 | 
				
			||||||
    label.characterName = characterName
 | 
					    widget.worldPort = characterInfo.worldPort
 | 
				
			||||||
    label.worldHost = worldHost
 | 
					 | 
				
			||||||
    label.worldPort = worldPort
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect(label, { onDoubleClick = function () CharacterList.doLogin() return true end } )
 | 
					    connect(widget, { onDoubleClick = function () CharacterList.doLogin() return true end } )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if i == 1 or g_settings.get('lastUsedCharacter') == characterName then
 | 
					    if i == 1 or g_settings.get('lastUsedCharacter') == characterName then
 | 
				
			||||||
      focusLabel = label
 | 
					      focusLabel = widget
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  characterList:focusChild(focusLabel, ActiveFocusReason)
 | 
					  characterList:focusChild(focusLabel, ActiveFocusReason)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -- account
 | 
				
			||||||
  if account.premDays > 0 then
 | 
					  if account.premDays > 0 then
 | 
				
			||||||
    accountStatusLabel:setText(tr("Account Status:\nPremium Account (%s) days left", account.premDays))
 | 
					    accountStatusLabel:setText(tr("Account Status:\nPremium Account (%s) days left", account.premDays))
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
| 
						 | 
					@ -219,13 +219,14 @@ function CharacterList.create(characters, account)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function CharacterList.hide()
 | 
					 | 
				
			||||||
  charactersWindow:hide()
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function CharacterList.destroy()
 | 
					function CharacterList.destroy()
 | 
				
			||||||
  CharacterList.hide()
 | 
					  if charactersWindow then
 | 
				
			||||||
  if not g_game.isOnline() then
 | 
					    characterList = nil
 | 
				
			||||||
 | 
					    charactersWindow:destroy()
 | 
				
			||||||
 | 
					    charactersWindow = nil
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if EnterGame and not g_game.isOnline() then
 | 
				
			||||||
    EnterGame.show()
 | 
					    EnterGame.show()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -238,6 +239,10 @@ function CharacterList.show()
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function CharacterList.hide()
 | 
				
			||||||
 | 
					  charactersWindow:hide()
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function CharacterList.showAgain()
 | 
					function CharacterList.showAgain()
 | 
				
			||||||
  if characterList:hasChildren() then
 | 
					  if characterList:hasChildren() then
 | 
				
			||||||
    CharacterList.show()
 | 
					    CharacterList.show()
 | 
				
			||||||
| 
						 | 
					@ -252,7 +257,7 @@ function CharacterList.isVisible()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function CharacterList.doLogin()
 | 
					function CharacterList.doLogin()
 | 
				
			||||||
  local selected = charactersWindow:getChildById('characterList'):getFocusedChild()
 | 
					  local selected = characterList:getFocusedChild()
 | 
				
			||||||
  if selected then
 | 
					  if selected then
 | 
				
			||||||
    local charInfo = { worldHost = selected.worldHost,
 | 
					    local charInfo = { worldHost = selected.worldHost,
 | 
				
			||||||
                       worldPort = selected.worldPort,
 | 
					                       worldPort = selected.worldPort,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,22 +1,45 @@
 | 
				
			||||||
CharacterListLabel < Label
 | 
					CharacterWidget < UIWidget
 | 
				
			||||||
  font: verdana-11px-monochrome
 | 
					  height: 14
 | 
				
			||||||
  background-color: alpha
 | 
					 | 
				
			||||||
  text-offset: 2 0
 | 
					 | 
				
			||||||
  focusable: true
 | 
					  focusable: true
 | 
				
			||||||
 | 
					  background-color: alpha
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $focus:
 | 
					  $focus:
 | 
				
			||||||
    background-color: #ffffff22
 | 
					    background-color: #ffffff22
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Label
 | 
				
			||||||
 | 
					    id: name
 | 
				
			||||||
    color: #ffffff
 | 
					    color: #ffffff
 | 
				
			||||||
 | 
					    anchors.top: parent.top
 | 
				
			||||||
 | 
					    anchors.left: parent.left
 | 
				
			||||||
 | 
					    font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					    text-auto-resize: true
 | 
				
			||||||
 | 
					    background-color: alpha
 | 
				
			||||||
 | 
					    text-offset: 2 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Label
 | 
				
			||||||
 | 
					    id: worldName
 | 
				
			||||||
 | 
					    color: #ffffff
 | 
				
			||||||
 | 
					    anchors.top: parent.top
 | 
				
			||||||
 | 
					    anchors.right: parent.right
 | 
				
			||||||
 | 
					    margin-right: 5
 | 
				
			||||||
 | 
					    font: verdana-11px-monochrome
 | 
				
			||||||
 | 
					    text-auto-resize: true
 | 
				
			||||||
 | 
					    background-color: alpha
 | 
				
			||||||
 | 
					    &baseText: '(%s)'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MainWindow
 | 
					MainWindow
 | 
				
			||||||
  id: charactersWindow
 | 
					  id: charactersWindow
 | 
				
			||||||
  !text: tr('Character List')
 | 
					  !text: tr('Character List')
 | 
				
			||||||
  size: 250 248
 | 
					  size: 250 248
 | 
				
			||||||
 | 
					  visible: false
 | 
				
			||||||
  @onEnter: CharacterList.doLogin()
 | 
					  @onEnter: CharacterList.doLogin()
 | 
				
			||||||
  @onEscape: CharacterList.destroy()
 | 
					  @onEscape: CharacterList.destroy()
 | 
				
			||||||
 | 
					  @onSetup: |
 | 
				
			||||||
 | 
					    g_keyboard.bindKeyPress('Up', function() self:getChildById('characters'):focusPreviousChild(KeyboardFocusReason) end, self)
 | 
				
			||||||
 | 
					    g_keyboard.bindKeyPress('Down', function() self:getChildById('characters'):focusNextChild(KeyboardFocusReason) end, self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  TextList
 | 
					  TextList
 | 
				
			||||||
    id: characterList
 | 
					    id: characters
 | 
				
			||||||
    anchors.top: parent.top
 | 
					    anchors.top: parent.top
 | 
				
			||||||
    anchors.left: parent.left
 | 
					    anchors.left: parent.left
 | 
				
			||||||
    anchors.right: characterListScrollBar.left
 | 
					    anchors.right: characterListScrollBar.left
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ local function onMotd(protocol, motd)
 | 
				
			||||||
  motdButton:show()
 | 
					  motdButton:show()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function onCharacterList(protocol, characters, account)
 | 
					local function onCharacterList(protocol, characters, account, otui)
 | 
				
			||||||
  if enterGame:getChildById('rememberPasswordBox'):isChecked() then
 | 
					  if enterGame:getChildById('rememberPasswordBox'):isChecked() then
 | 
				
			||||||
    g_settings.set('account', g_crypt.encrypt(G.account))
 | 
					    g_settings.set('account', g_crypt.encrypt(G.account))
 | 
				
			||||||
    g_settings.set('password', g_crypt.encrypt(G.password))
 | 
					    g_settings.set('password', g_crypt.encrypt(G.password))
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@ local function onCharacterList(protocol, characters, account)
 | 
				
			||||||
  loadBox:destroy()
 | 
					  loadBox:destroy()
 | 
				
			||||||
  loadBox = nil
 | 
					  loadBox = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CharacterList.create(characters, account)
 | 
					  CharacterList.create(characters, account, otui)
 | 
				
			||||||
  CharacterList.show()
 | 
					  CharacterList.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  local lastMotdNumber = g_settings.getNumber("motd")
 | 
					  local lastMotdNumber = g_settings.getNumber("motd")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,6 +86,7 @@ locale = {
 | 
				
			||||||
    ["Copy message"] = "Copiar mensagem",
 | 
					    ["Copy message"] = "Copiar mensagem",
 | 
				
			||||||
    ["Copy name"] = "Copiar nome",
 | 
					    ["Copy name"] = "Copiar nome",
 | 
				
			||||||
    ["Copy Name"] = "Copiar Nome",
 | 
					    ["Copy Name"] = "Copiar Nome",
 | 
				
			||||||
 | 
					    ["Create"] = "Criar",
 | 
				
			||||||
    ["Create New Offer"] = "Criar nova oferta",
 | 
					    ["Create New Offer"] = "Criar nova oferta",
 | 
				
			||||||
    ["Create Offer"] = "Criar oferta",
 | 
					    ["Create Offer"] = "Criar oferta",
 | 
				
			||||||
    ["Current hotkeys:"] = "Atalhos atuais",
 | 
					    ["Current hotkeys:"] = "Atalhos atuais",
 | 
				
			||||||
| 
						 | 
					@ -310,6 +311,7 @@ locale = {
 | 
				
			||||||
    ["Weight:"] = "Peso",
 | 
					    ["Weight:"] = "Peso",
 | 
				
			||||||
    ["Will detect when to use diagonal step based on the\nkeys you are pressing"] = "Detectar quando usar o passo diagonal\nbaseado nas teclas pressionadas",
 | 
					    ["Will detect when to use diagonal step based on the\nkeys you are pressing"] = "Detectar quando usar o passo diagonal\nbaseado nas teclas pressionadas",
 | 
				
			||||||
    ["With crosshair"] = "Com mira",
 | 
					    ["With crosshair"] = "Com mira",
 | 
				
			||||||
 | 
					    ["World"] = "Mundo",
 | 
				
			||||||
    ["Yes"] = "Sim",
 | 
					    ["Yes"] = "Sim",
 | 
				
			||||||
    ["You are bleeding"] = "Você está sangrando",
 | 
					    ["You are bleeding"] = "Você está sangrando",
 | 
				
			||||||
    ["You are burning"] = "Você está queimando",
 | 
					    ["You are burning"] = "Você está queimando",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,3 +3,9 @@ TextList < UIScrollArea
 | 
				
			||||||
  border-width: 1
 | 
					  border-width: 1
 | 
				
			||||||
  border-color: #1d222b
 | 
					  border-color: #1d222b
 | 
				
			||||||
  background-color: #222833
 | 
					  background-color: #222833
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					HorizontalList < UIScrollArea
 | 
				
			||||||
 | 
					  layout: horizontalBox
 | 
				
			||||||
 | 
					  border-width: 1
 | 
				
			||||||
 | 
					  border-color: #1d222b
 | 
				
			||||||
 | 
					  background-color: #222833
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,9 @@ function UIScrollArea:updateScrollBars()
 | 
				
			||||||
  if scrollbar then
 | 
					  if scrollbar then
 | 
				
			||||||
    if self.inverted then
 | 
					    if self.inverted then
 | 
				
			||||||
      scrollbar:setMinimum(-scrollWidth)
 | 
					      scrollbar:setMinimum(-scrollWidth)
 | 
				
			||||||
 | 
					      scrollbar:setMaximum(0)
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
 | 
					      scrollbar:setMinimum(0)
 | 
				
			||||||
      scrollbar:setMaximum(scrollWidth)
 | 
					      scrollbar:setMaximum(scrollWidth)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					@ -75,6 +77,11 @@ end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function UIScrollArea:setHorizontalScrollBar(scrollbar)
 | 
					function UIScrollArea:setHorizontalScrollBar(scrollbar)
 | 
				
			||||||
  self.horizontalScrollBar = scrollbar
 | 
					  self.horizontalScrollBar = scrollbar
 | 
				
			||||||
 | 
					  self.horizontalScrollBar.onValueChange = function(scrollbar, value)
 | 
				
			||||||
 | 
					    local virtualOffset = self:getVirtualOffset()
 | 
				
			||||||
 | 
					    virtualOffset.x = value
 | 
				
			||||||
 | 
					    self:setVirtualOffset(virtualOffset)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
  self:updateScrollBars()
 | 
					  self:updateScrollBars()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,6 +104,12 @@ function UIScrollArea:onMouseWheel(mousePos, mouseWheel)
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      self.verticalScrollBar:increment()
 | 
					      self.verticalScrollBar:increment()
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					  elseif self.horizontalScrollBar then
 | 
				
			||||||
 | 
					    if mouseWheel == MouseWheelUp then
 | 
				
			||||||
 | 
					      self.horizontalScrollBar:increment()
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      self.horizontalScrollBar:decrement()
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  return true
 | 
					  return true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -104,14 +117,26 @@ end
 | 
				
			||||||
function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason)
 | 
					function UIScrollArea:onChildFocusChange(focusedChild, oldFocused, reason)
 | 
				
			||||||
  if focusedChild and (reason == MouseFocusReason or reason == KeyboardFocusReason) then
 | 
					  if focusedChild and (reason == MouseFocusReason or reason == KeyboardFocusReason) then
 | 
				
			||||||
    local paddingRect = self:getPaddingRect()
 | 
					    local paddingRect = self:getPaddingRect()
 | 
				
			||||||
    local delta = paddingRect.y - focusedChild:getY()
 | 
					    if self.verticalScrollBar then
 | 
				
			||||||
    if delta > 0 then
 | 
					      local deltaY = paddingRect.y - focusedChild:getY()
 | 
				
			||||||
      self.verticalScrollBar:decrement(delta)
 | 
					      if deltaY > 0 then
 | 
				
			||||||
 | 
					        self.verticalScrollBar:decrement(deltaY)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    delta = (focusedChild:getY() + focusedChild:getHeight()) - (paddingRect.y + paddingRect.height)
 | 
					      deltaY = (focusedChild:getY() + focusedChild:getHeight()) - (paddingRect.y + paddingRect.height)
 | 
				
			||||||
    if delta > 0 then
 | 
					      if deltaY > 0 then
 | 
				
			||||||
      self.verticalScrollBar:increment(delta)
 | 
					        self.verticalScrollBar:increment(deltaY)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      local deltaX = paddingRect.x - focusedChild:getX()
 | 
				
			||||||
 | 
					      if deltaX > 0 then
 | 
				
			||||||
 | 
					        self.horizontalScrollBar:decrement(deltaX)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      deltaX = (focusedChild:getX() + focusedChild:getWidth()) - (paddingRect.x + paddingRect.width)
 | 
				
			||||||
 | 
					      if deltaX > 0 then
 | 
				
			||||||
 | 
					        self.horizontalScrollBar:increment(deltaX)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ local function calcValues(self)
 | 
				
			||||||
  else -- horizontal
 | 
					  else -- horizontal
 | 
				
			||||||
    pxrange = (self:getWidth() - decrementButton:getWidth() - decrementButton:getMarginLeft() - decrementButton:getMarginRight()
 | 
					    pxrange = (self:getWidth() - decrementButton:getWidth() - decrementButton:getMarginLeft() - decrementButton:getMarginRight()
 | 
				
			||||||
                               - incrementButton:getWidth() - incrementButton:getMarginLeft() - incrementButton:getMarginRight())
 | 
					                               - incrementButton:getWidth() - incrementButton:getMarginLeft() - incrementButton:getMarginRight())
 | 
				
			||||||
    center = self:getX() + self:getWidth() / 2
 | 
					    center = self:getX() + math.floor(self:getWidth() / 2)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  local range = self.maximum - self.minimum + 1
 | 
					  local range = self.maximum - self.minimum + 1
 | 
				
			||||||
| 
						 | 
					@ -83,6 +83,7 @@ local function parseSliderPos(self, pos)
 | 
				
			||||||
  offset = math.min(math.max(point - center, -pxrange/2), pxrange/2)
 | 
					  offset = math.min(math.max(point - center, -pxrange/2), pxrange/2)
 | 
				
			||||||
  local newvalue = math.floor(((offset / (pxrange - px)) + 0.5) * (range - 1)) + self.minimum
 | 
					  local newvalue = math.floor(((offset / (pxrange - px)) + 0.5) * (range - 1)) + self.minimum
 | 
				
			||||||
  self:setValue(newvalue)
 | 
					  self:setValue(newvalue)
 | 
				
			||||||
 | 
					  -- this function must be reworked, scroll is not that good based on center
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +123,8 @@ end
 | 
				
			||||||
function ProtocolLogin:parseExtendedCharacterList(msg)
 | 
					function ProtocolLogin:parseExtendedCharacterList(msg)
 | 
				
			||||||
  local characters = msg:getTable()
 | 
					  local characters = msg:getTable()
 | 
				
			||||||
  local account = msg:getTable()
 | 
					  local account = msg:getTable()
 | 
				
			||||||
  signalcall(self.onCharacterList, self, characters, account)
 | 
					  local otui = msg:getString()
 | 
				
			||||||
 | 
					  signalcall(self.onCharacterList, self, characters, account, otui)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ProtocolLogin:parseOpcode(opcode, msg)
 | 
					function ProtocolLogin:parseOpcode(opcode, msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -462,6 +462,7 @@ void OTClient::registerLuaFunctions()
 | 
				
			||||||
    g_lua.registerClass<UICreature, UIWidget>();
 | 
					    g_lua.registerClass<UICreature, UIWidget>();
 | 
				
			||||||
    g_lua.bindClassStaticFunction<UICreature>("create", []{ return UICreaturePtr(new UICreature); } );
 | 
					    g_lua.bindClassStaticFunction<UICreature>("create", []{ return UICreaturePtr(new UICreature); } );
 | 
				
			||||||
    g_lua.bindClassMemberFunction<UICreature>("setCreature", &UICreature::setCreature);
 | 
					    g_lua.bindClassMemberFunction<UICreature>("setCreature", &UICreature::setCreature);
 | 
				
			||||||
 | 
					    g_lua.bindClassMemberFunction<UICreature>("setOutfit", &UICreature::setOutfit);
 | 
				
			||||||
    g_lua.bindClassMemberFunction<UICreature>("setFixedCreatureSize", &UICreature::setFixedCreatureSize);
 | 
					    g_lua.bindClassMemberFunction<UICreature>("setFixedCreatureSize", &UICreature::setFixedCreatureSize);
 | 
				
			||||||
    g_lua.bindClassMemberFunction<UICreature>("getCreature", &UICreature::getCreature);
 | 
					    g_lua.bindClassMemberFunction<UICreature>("getCreature", &UICreature::getCreature);
 | 
				
			||||||
    g_lua.bindClassMemberFunction<UICreature>("isFixedCreatureSize", &UICreature::isFixedCreatureSize);
 | 
					    g_lua.bindClassMemberFunction<UICreature>("isFixedCreatureSize", &UICreature::isFixedCreatureSize);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,14 @@ void UICreature::drawSelf(Fw::DrawPane drawPane)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UICreature::setOutfit(const Outfit& outfit)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if(!m_creature)
 | 
				
			||||||
 | 
					        m_creature = CreaturePtr(new Creature);
 | 
				
			||||||
 | 
					    m_creature->setDirection(Otc::South);
 | 
				
			||||||
 | 
					    m_creature->setOutfit(outfit);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void UICreature::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
 | 
					void UICreature::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    UIWidget::onStyleApply(styleName, styleNode);
 | 
					    UIWidget::onStyleApply(styleName, styleNode);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void setCreature(const CreaturePtr& creature) { m_creature = creature; }
 | 
					    void setCreature(const CreaturePtr& creature) { m_creature = creature; }
 | 
				
			||||||
    void setFixedCreatureSize(bool fixed) { m_fixedCreatureSize = fixed; }
 | 
					    void setFixedCreatureSize(bool fixed) { m_fixedCreatureSize = fixed; }
 | 
				
			||||||
 | 
					    void setOutfit(const Outfit& outfit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    CreaturePtr getCreature() { return m_creature; }
 | 
					    CreaturePtr getCreature() { return m_creature; }
 | 
				
			||||||
    bool isFixedCreatureSize() { return m_fixedCreatureSize; }
 | 
					    bool isFixedCreatureSize() { return m_fixedCreatureSize; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue