diff --git a/game/engines/default/engine/ui/Slider.lua b/game/engines/default/engine/ui/Slider.lua index fe674d53ad3fc5a0c3870603e04c8f62dda01b79..6f4947d5f61b9b58de7a78e5abcdd35fa2243606 100644 --- a/game/engines/default/engine/ui/Slider.lua +++ b/game/engines/default/engine/ui/Slider.lua @@ -46,11 +46,11 @@ function _M:display(x, y) self.top.t:toScreenFull(x, y, self.top.w, self.top.h, self.top.tw, self.top.th) self.bottom.t:toScreenFull(x, y + self.h - self.bottom.h, self.bottom.w, self.bottom.h, self.bottom.tw, self.bottom.th) self.middle.t:toScreenFull(x, y + self.top.h, self.middle.w, self.h - self.top.h - self.bottom.h, self.middle.tw, self.middle.th) - self.pos = util.minBound(self.pos, 0, self.max) + self.pos = util.minBound(self.pos, 1, self.max) if self.inverse then - y = y + self.h - (self.pos / self.max) * (self.h - self.bottom.h - self.top.h - self.sel.h) - self.bottom.h - self.sel.h + y = y + self.h - ((self.pos - 1) / (self.max - 1)) * (self.h - self.bottom.h - self.top.h - self.sel.h) - self.bottom.h - self.sel.h else - y = y + (self.pos / self.max) * (self.h - self.bottom.h - self.top.h - self.sel.h) + self.top.h + y = y + ((self.pos - 1) / (self.max - 1)) * (self.h - self.bottom.h - self.top.h - self.sel.h) + self.top.h end self.sel.t:toScreenFull(x - (self.sel.w - self.top.w) * 0.5, y, self.sel.w, self.sel.h, self.sel.tw, self.sel.th) end diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua index 8ce2dddd6dfcdebe34e64d93ed1bdf3802902b2a..ce65ca1900b22ba673ede58f818de7e10ea13c78 100644 --- a/game/engines/default/engine/utils.lua +++ b/game/engines/default/engine/utils.lua @@ -861,10 +861,11 @@ local word_size_cache = {} local fontoldsize = getmetatable(tmps).__index.size getmetatable(tmps).__index.simplesize = fontoldsize local fontcachewordsize = function(font, fstyle, v) - if not word_size_cache[font][fstyle][v] then - word_size_cache[font][fstyle][v] = {fontoldsize(font, v)} + local cache = table.getTable(word_size_cache, font, fstyle) + if not cache[v] then + cache[v] = {fontoldsize(font, v)} end - return unpack(word_size_cache[font][fstyle][v]) + return unpack(cache[v]) end getmetatable(tmps).__index.size = function(font, str) local tstr = str:toTString()