Skip to content

Commit

Permalink
- Fixed scaling bug when loading a tactic
Browse files Browse the repository at this point in the history
  • Loading branch information
karellodewijk committed Aug 17, 2016
1 parent c92d0d5 commit 067c556
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion public/javascripts/combined.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/javascripts/combined.js.map

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions public/javascripts/planner.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,6 @@ function paste() {
}

function zoom(amount, isZoomIn, e) {
var old_zoom_level = zoom_level;

var direction = isZoomIn ? 1 : -1;
var factor = (1 + amount * direction);

Expand All @@ -445,11 +443,16 @@ function emit_pan_zoom() {
}

function pan_zoom(new_zoom_level, x, y) {
var zoom_amount = zoom_level / new_zoom_level - 1;
zoom(Math.abs(zoom_amount), zoom_amount > 0);
var zoom_factor = zoom_level / new_zoom_level;

objectContainer.scale.x *= zoom_factor;
objectContainer.scale.y *= zoom_factor;

objectContainer.x = to_x_local_vect(x);
objectContainer.y = to_y_local_vect(y);
correct();

zoom_level = size_y / (background_sprite.height * objectContainer.scale.y);
render_scene();
}

function correct() {
Expand Down Expand Up @@ -716,7 +719,7 @@ function get_video_type(path) {
}

function reset_background() {
//pan_zoom(1,0,0);
pan_zoom(1,0,0);
video_ready = false;
if (video_media) {
video_media.setCurrentTime(0);
Expand Down
7 changes: 3 additions & 4 deletions views/planner2.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@
<script defer src="<%=static_host%>/javascripts/lib/curve.js"></script>
<%}%>


<%if (false) {%>
<script defer src="<%=static_host%>/javascripts/combined_mini.js"></script>
<script defer src="<%=static_host%>/javascripts/planner.js"></script>

<%if (false) {%>
<script defer src="<%=static_host%>/javascripts/combined.js"></script>
<%}%>

<script defer src="<%=static_host%>/javascripts/combined.js"></script>

<title><%=game.toUpperCase()%> <%=l('Tactics')%> - <%=l('Planner')%></title>
<meta name="description" content="<%=game.toUpperCase()%> <%=l('strategy')%>">
<script id="sid" data-sid="<%=sid%>"></script>
Expand Down

0 comments on commit 067c556

Please sign in to comment.