Loading

Paste #ptd7mteod

  1. diff --git a/CorsixTH/Lua/game_ui.lua b/CorsixTH/Lua/game_ui.lua
  2. index 9bb0a4a..207eea6 100644
  3. --- a/CorsixTH/Lua/game_ui.lua
  4. +++ b/CorsixTH/Lua/game_ui.lua
  5. @@ -102,7 +102,7 @@ function GameUI:makeVisibleDiamond(scr_w, scr_h)
  6.  
  7.    -- The visible diamond is the region which the top-left corner of the screen
  8.    -- is limited to, and ensures that the map always covers all of the screen.
  9. -  -- Its verticies are at (x + w, y), (x - w, y), (x, y + h), (x, y - h).
  10. +  -- Its vertices are at (x + w, y), (x - w, y), (x, y + h), (x, y - h).
  11.    return {
  12.      x = - scr_w / 2,
  13.      y = 16 * map_h - scr_h / 2,
  14. @@ -113,27 +113,30 @@ end
  15.  
  16.  function GameUI:setZoom(factor)
  17.    if factor <= 0 then
  18. -    return
  19. +    return false
  20.    end
  21.    local old_factor = self.zoom_factor
  22.    if not factor or math.abs(factor - 1) < 0.001 then
  23.      factor = 1
  24.    end
  25. +
  26.    local scr_w = self.app.config.width
  27.    local scr_h = self.app.config.height
  28. +  local new_diamond = self:makeVisibleDiamond(scr_w / factor, scr_h / factor)
  29. +  if new_diamond.w < 0 or new_diamond.h < 0 then
  30. +    return false
  31. +  end
  32. +
  33. +  self.visible_diamond = new_diamond
  34.    local refx, refy = self.cursor_x or scr_w / 2, self.cursor_y or scr_h / 2
  35.    local cx, cy = self:ScreenToWorld(refx, refy)
  36.    self.zoom_factor = factor
  37. -  self.visible_diamond = self:makeVisibleDiamond(scr_w / factor, scr_h / factor)
  38. -  if self.visible_diamond.w < 0 or self.visible_diamond.h < 0 then
  39. -    self:setZoom(old_factor)
  40. -    return false
  41. -  else
  42. -    cx, cy = self.app.map:WorldToScreen(cx, cy)
  43. -    self:scrollMap(cx - self.screen_offset_x - refx / factor,
  44. -                   cy - self.screen_offset_y - refy / factor)
  45. -    return true
  46. -  end
  47. +
  48. +  cx, cy = self.app.map:WorldToScreen(cx, cy)
  49. +  cx = cx - self.screen_offset_x - refx / factor
  50. +  cy = cy - self.screen_offset_y - refy / factor
  51. +  self:scrollMap(cx, cy)
  52. +  return true
  53.  end
  54.  
  55.  function GameUI:draw(canvas)

Comments