Some flexibility changes
This commit is contained in:
		
							parent
							
								
									e5df872600
								
							
						
					
					
						commit
						5a367cfe27
					
				| 
						 | 
					@ -143,6 +143,10 @@ function Locales.setLocale(name)
 | 
				
			||||||
  return true
 | 
					  return true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function Locales.getComboBox()
 | 
				
			||||||
 | 
					  return localeComboBox
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- global function used to translate texts
 | 
					-- global function used to translate texts
 | 
				
			||||||
function tr(text, ...)
 | 
					function tr(text, ...)
 | 
				
			||||||
  if currentLocale then
 | 
					  if currentLocale then
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,6 +48,20 @@ function UIComboBox:addOption(text, data)
 | 
				
			||||||
  return index
 | 
					  return index
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function UIComboBox:removeOption(text)
 | 
				
			||||||
 | 
					  for i,v in ipairs(self.options) do
 | 
				
			||||||
 | 
					    if v.text == text then
 | 
				
			||||||
 | 
					      table.remove(self.options, i)
 | 
				
			||||||
 | 
					      if self.currentIndex == i then
 | 
				
			||||||
 | 
					        self:setCurrentIndex(1)
 | 
				
			||||||
 | 
					      elseif self.currentIndex > i then
 | 
				
			||||||
 | 
					        self.currentIndex = self.currentIndex - 1
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      return
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function UIComboBox:onMousePress(mousePos, mouseButton)
 | 
					function UIComboBox:onMousePress(mousePos, mouseButton)
 | 
				
			||||||
  local menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu')
 | 
					  local menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu')
 | 
				
			||||||
  menu:setId(self:getId() .. 'PopupMenu')
 | 
					  menu:setId(self:getId() .. 'PopupMenu')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,11 +13,23 @@ function UIMiniWindowContainer:getClassName()
 | 
				
			||||||
  return 'UIMiniWindowContainer'
 | 
					  return 'UIMiniWindowContainer'
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- TODO: connect to window onResize event
 | 
				
			||||||
 | 
					-- TODO: try to resize another widget?
 | 
				
			||||||
 | 
					-- TODO: try to find another panel?
 | 
				
			||||||
function UIMiniWindowContainer:fitAll(noRemoveChild)
 | 
					function UIMiniWindowContainer:fitAll(noRemoveChild)
 | 
				
			||||||
  if not self:isVisible() then
 | 
					  if not self:isVisible() then
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if not noRemoveChild then
 | 
				
			||||||
 | 
					    local children = self:getChildren()
 | 
				
			||||||
 | 
					    if #children > 0 then
 | 
				
			||||||
 | 
					      noRemoveChild = children[#children]
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      return
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  local sumHeight = 0
 | 
					  local sumHeight = 0
 | 
				
			||||||
  local children = self:getChildren()
 | 
					  local children = self:getChildren()
 | 
				
			||||||
  for i=1,#children do
 | 
					  for i=1,#children do
 | 
				
			||||||
| 
						 | 
					@ -40,10 +52,6 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
 | 
				
			||||||
    addEvent(function() noRemoveChild:setHeight(maximumHeight) end)
 | 
					    addEvent(function() noRemoveChild:setHeight(maximumHeight) end)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- TODO: most likely, minimum and maximum size are not set yet, so code above might not work properly. onSetup event
 | 
					 | 
				
			||||||
  -- TODO: try to resize another widget?
 | 
					 | 
				
			||||||
  -- TODO: try to find another panel?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  -- try to remove no-save widget
 | 
					  -- try to remove no-save widget
 | 
				
			||||||
  for i=#children,1,-1 do
 | 
					  for i=#children,1,-1 do
 | 
				
			||||||
    if sumHeight <= selfHeight then
 | 
					    if sumHeight <= selfHeight then
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -80,7 +80,7 @@ function ProtocolLogin:onRecv(msg)
 | 
				
			||||||
    elseif opcode == LoginServerMotd then
 | 
					    elseif opcode == LoginServerMotd then
 | 
				
			||||||
      self:parseMotd(msg)
 | 
					      self:parseMotd(msg)
 | 
				
			||||||
    elseif opcode == LoginServerUpdateNeeded then
 | 
					    elseif opcode == LoginServerUpdateNeeded then
 | 
				
			||||||
      signalcall(self.onError, self, tr("Client needs update."))
 | 
					      signalcall(self.onError, self, tr("Client needs update. Verify your spr/dat/pic versions."))
 | 
				
			||||||
    elseif opcode == LoginServerCharacterList then
 | 
					    elseif opcode == LoginServerCharacterList then
 | 
				
			||||||
      self:parseCharacterList(msg)
 | 
					      self:parseCharacterList(msg)
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue