Loading

Paste #p3a42tfzm

  1. diff --git a/CorsixTH/Lua/game_ui.lua b/CorsixTH/Lua/game_ui.lua
  2. index 9bb0a4a..c09d1bd 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,29 @@ 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 refx, refy = self.cursor_x or scr_w / 2, self.cursor_y or scr_h / 2
  29. -  local cx, cy = self:ScreenToWorld(refx, refy)
  30. -  self.zoom_factor = factor
  31.    self.visible_diamond = self:makeVisibleDiamond(scr_w / factor, scr_h / factor)
  32.    if self.visible_diamond.w < 0 or self.visible_diamond.h < 0 then
  33. -    self:setZoom(old_factor)
  34.      return false
  35. -  else
  36. -    cx, cy = self.app.map:WorldToScreen(cx, cy)
  37. -    self:scrollMap(cx - self.screen_offset_x - refx / factor,
  38. -                   cy - self.screen_offset_y - refy / factor)
  39. -    return true
  40.    end
  41. +
  42. +  local refx, refy = self.cursor_x or scr_w / 2, self.cursor_y or scr_h / 2
  43. +  local cx, cy = self:ScreenToWorld(refx, refy)
  44. +  self.zoom_factor = factor
  45. +
  46. +  cx, cy = self.app.map:WorldToScreen(cx, cy)
  47. +  cx = cx - self.screen_offset_x - refx / factor
  48. +  cy = cy - self.screen_offset_y - refy / factor
  49. +  self:scrollMap(cx, cy)
  50. +  return true
  51.  end
  52.  
  53.  function GameUI:draw(canvas)

Comments