Skip to content

Commit

Permalink
fixed both grass current+previous preview maps
Browse files Browse the repository at this point in the history
  • Loading branch information
marcrobledo committed Feb 19, 2017
1 parent e792267 commit d48efa8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 58 deletions.
4 changes: 2 additions & 2 deletions acnl_editor.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# last update 2017-02-18
# last update 2017-02-19
# these belong to the CACHE block
index.html
help.html
Expand All @@ -18,4 +18,4 @@ data/villagers.jpg

# force these files to be loaded in network
NETWORK:
*
*
18 changes: 17 additions & 1 deletion data/acnl_editor.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Animal Crossing:New Leaf RAM Editor v20170103
Animal Crossing:New Leaf RAM Editor v20170219
by Marc Robledo 2015-2017
*/
@font-face{font-family:'Noto Sans';font-style:normal;font-weight:normal;src:local('Noto Sans'),local('NotoSans'),url('./NotoSans.woff2') format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000}
Expand Down Expand Up @@ -338,6 +338,22 @@ span.sprite{display:inline-block;vertical-align:middle}
.room-container .grid{margin-right:10px}


canvas.grass{
width:320px;
border:1px dotted #ccc;
image-rendering:optimizeSpeed;
image-rendering:-moz-crisp-edges;
image-rendering:-webkit-optimize-contrast;
image-rendering:optimize-contrast;
image-rendering:pixelated;
-ms-interpolation-mode:nearest-neighbor;
}
#grass-previous{
width:384px;
}



#move-building-overlay{
position:absolute;
background-color:rgba(255,255,255,.25);
Expand Down
103 changes: 50 additions & 53 deletions data/acnl_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
A lot of thanks to:
* Thulinma for Pattern structure (check out his editor pattern http://www.thulinma.com/acnl/ )
* NeoKamek for his work on LeafTools and other help
* jexom for documenting grass deterioration
* froggestspirit for extracting acre information and item list
* sprungit/shokolad-town for compiling hair style and color thumbnails
*/
Expand Down Expand Up @@ -570,25 +571,25 @@ Town.prototype.maxTurnipPrices=function(){
}

Town.prototype.setGrass=function(b){
var MAX_CURRENT=(16*16)*(8*6);
var MAX_CURRENT=(16*16)*(5*4);
for(var i=0; i<MAX_CURRENT; i++){
if(Math.floor(i/64) < (Math.floor(i/(64*16)) + 1) * 16 - 2){
grassCurrent.tiles[i]=~b & 0xff;
savegame.storeByte(Offsets.MAP_GRASS_CURRENT+i, grassCurrent.tiles[i]);
}
grassCurrent.tiles[i]=b & 0x0f;
savegame.storeByte(Offsets.MAP_GRASS_CURRENT+i, grassCurrent.tiles[i]);
}

var MAX=(16*16)*(8*6) ; // *2 ???
for(var i=0; i<MAX; i++)
if(Math.floor(i/64) < (Math.floor(i/(64*16)) + 1) * 16 - 2)
savegame.storeByte(Offsets.MAP_GRASS_PREVIOUS+i, b);
grassCurrent.draw();

var MAX=(8*8)*(8*6)*4;
for(var i=0; i<MAX; i++){
grassPrevious.tiles[i]=~b & 0xff;
savegame.storeByte(Offsets.MAP_GRASS_PREVIOUS+i, grassPrevious.tiles[i]);
}
grassPrevious.draw();


MarcDialogs.close();
}
Town.prototype.fillGrass=function(){MarcDialogs.confirm('Do you want to revive all grass?',function(){town.setGrass(0xff)})};
Town.prototype.fillDesert=function(){MarcDialogs.confirm('Do you want to kill all grass?',function(){town.setGrass(0x00)})};
Town.prototype.fillGrass=function(){MarcDialogs.confirm('Do you want to revive all grass?',function(){town.setGrass(0x00)})};
Town.prototype.fillDesert=function(){MarcDialogs.confirm('Do you want to kill all grass?',function(){town.setGrass(0xff)})};
Town.prototype.fillStrippedGrass=function(){
MarcDialogs.confirm('Do you want to strip all grass?', function(){
var MAX_CURRENT=(16*16)*(5*4);
Expand Down Expand Up @@ -916,56 +917,48 @@ ItemGridMap.prototype.save=function(){



function GrassMapPrevious(offset,canvasId,width,height){
function GrassMapCurrent(offset,canvasId,width,height){
this.offset=offset;
this.canvas=el(canvasId);
this.width=width;
this.height=height;

this.canvas.width=this.width*32*2;
this.canvas.height=this.height*32*2;
this.canvas.width=this.width*16;
this.canvas.height=this.height*16;

this.tiles=new Array(width*height*16*16);
for(var i=0; i<this.tiles.length; i++){
var b=savegame.readByte1(this.offset+i);
this.tiles[i]=b & 0xff;
this.tiles[i]=b & 0x0f;
if(b >> 4){
//alert(b);
}
}

this.draw();
}
GrassMapPrevious.prototype.draw=function(){
GrassMapCurrent.prototype.draw=function(){
var tile=0;
var ctx=this.canvas.getContext('2d');
for(var i=0; i<this.height*2; i++){
for(var j=0; j<this.width*2; j++){
for(var y4=0; y4<2; y4++){
for(var x4=0; x4<2; x4++){
for(var y2=0; y2<2; y2++){
for(var x2=0; x2<2; x2++){
for(var y1=0; y1<2; y1++){
for(var x1=0; x1<2; x1++){
var color=255-this.tiles[tile];
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
ctx.fillRect((j*8+x4*4+x2*2+x1)*4-3, (i*8+y4*4+y2*2+y1)*4-3, 4, 4);
for(var i=0; i<this.height; i++){
for(var j=0; j<this.width; j++){
for(var y=0; y<16; y++){
for(var x=0; x<16; x++){
var color=255-this.tiles[tile]*17;
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
ctx.fillRect(j*16+x, i*16+y, 1, 1);

tile++;
}
}
}
}
tile++;
}
}
}
}
}
GrassMapPrevious.prototype.save=function(){
GrassMapCurrent.prototype.save=function(){
}


function GrassMapCurrent(offset,canvasId,width,height){
function GrassMapPrevious(offset,canvasId,width,height){
this.offset=offset;
this.canvas=el(canvasId);
this.width=width;
Expand All @@ -975,32 +968,36 @@ function GrassMapCurrent(offset,canvasId,width,height){
this.canvas.height=this.height*16;

this.tiles=new Array(width*height*16*16);
for(var i=0; i<this.tiles.length; i++){
var b=savegame.readByte1(this.offset+i);
this.tiles[i]=b;
}
for(var i=0; i<this.tiles.length; i++)
this.tiles[i]=savegame.readByte1(this.offset+i);

this.draw();
}
GrassMapCurrent.prototype.draw=function(){
GrassMapPrevious.prototype.draw=function(){
var tile=0;
var ctx=this.canvas.getContext('2d');
for(var i=0; i<this.height; i++){
for(var j=0; j<this.width; j++){
for(var y=0; y<16; y++){
for(var x=0; x<16; x++){
var color=255-this.tiles[tile];
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
ctx.fillRect(j*16+x, i*16+y, 1, 1);
for(var i=0; i<this.height*2; i++){
for(var j=0; j<this.width*2; j++){
for(var y4=0; y4<2; y4++){
for(var x4=0; x4<2; x4++){
for(var y2=0; y2<2; y2++){
for(var x2=0; x2<2; x2++){
for(var y1=0; y1<2; y1++){
for(var x1=0; x1<2; x1++){
var color=this.tiles[tile];
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
ctx.fillRect((j*8+x4*4+x2*2+x1), (i*8+y4*4+y2*2+y1), 1, 1);

tile++;
tile++;
}
}
}
}
}
}
}
}
}
GrassMapCurrent.prototype.save=function(){
}



Expand Down Expand Up @@ -2830,8 +2827,8 @@ function initializeEverything(){
island=new ItemGridMap('island');

/* Grass */
grassCurrent=new GrassMapPrevious(Offsets.MAP_GRASS_CURRENT,'grass-current',5,4);
//new GrassMapCurrent(Offsets.MAP_GRASS_PREVIOUS,'grass-previous',5,4);
grassCurrent=new GrassMapCurrent(Offsets.MAP_GRASS_CURRENT,'grass-current',5,4);
grassPrevious=new GrassMapPrevious(Offsets.MAP_GRASS_PREVIOUS,'grass-previous',8,6);

/* read player data */
players=new Array(4);
Expand Down Expand Up @@ -3386,4 +3383,4 @@ var saveAs=saveAs||(navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator))|
MarcDialogs=function(){function e(e,t,n){a?e.attachEvent("on"+t,n):e.addEventListener(t,n,!1)}function t(){s&&(o?history.go(-1):(c.className="dialog-overlay",s.className=s.className.replace(/ active/g,""),s=null))}function n(e){for(var t=0;t<s.dialogElements.length;t++){var n=s.dialogElements[t];if("INPUT"===n.nodeName&&"hidden"!==n.type||"INPUT"!==n.nodeName)return n.focus(),!0}return!1}function l(){s&&(s.style.marginLeft="-"+s.offsetWidth/2+"px",s.style.marginTop="-"+s.offsetHeight/2-30+"px")}var a=/MSIE 8/.test(navigator.userAgent),o=navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i)&&"function"==typeof history.pushState,i=["Cancel","Accept"],s=null,c=document.createElement("div");c.className="dialog-overlay",c.style.position="fixed",c.style.top="0",c.style.left="0",c.style.width="100%",c.style.height="100%",c.style.zIndex=8e3,e(c,"click",t),e(window,"load",function(){document.body.appendChild(c),o&&history.replaceState({myDialog:!1},null,null)}),e(window,"resize",l),o&&e(window,"popstate",function(e){e.state.myDialog?(s=e.state.myDialog,MarcDialogs.open(e.state.myDialog)):e.state.myDialog===!1&&s&&(c.className="dialog-overlay",s.className=s.className.replace(/ active/g,""),s=null)}),e(document,"keydown",function(e){s&&(27==e.keyCode?(e.preventDefault?e.preventDefault():e.returnValue=!1,t()):9==e.keyCode&&s.dialogElements[s.dialogElements.length-1]==document.activeElement&&(e.preventDefault?e.preventDefault():e.returnValue=!1,n()))});var d=null,u=null,m=null;return{open:function(e){s&&(s.className=s.className.replace(/ active/g,"")),o&&(s?history.replaceState({myDialog:e},null,null):(console.log("a"),history.pushState({myDialog:e},null,null))),c.className="dialog-overlay active",s="string"==typeof e?document.getElementById("dialog-"+e):e,s.className+=" active",s.style.position="fixed",s.style.top="50%",s.style.left="50%",s.style.zIndex=8001,s.dialogElements||(s.dialogElements=s.querySelectorAll("input,textarea,select")),n(),l(s),l(s)},close:t,alert:function(t){if(!d){d=document.createElement("div"),d.id="dialog-quick-alert",d.className="dialog",d.msg=document.createElement("div"),d.msg.style.textAlign="center",d.appendChild(d.msg),d.buttons=document.createElement("div"),d.buttons.className="buttons";var n=document.createElement("input");n.type="button",n.className="button button-accept",n.value=i[1],e(n,"click",this.close),d.buttons.appendChild(n),d.appendChild(d.buttons),document.body.appendChild(d)}d.msg.innerHTML=t,MarcDialogs.open("quick-alert")},confirm:function(t,n){if(!u){u=document.createElement("div"),u.id="dialog-quick-confirm",u.className="dialog",u.msg=document.createElement("div"),u.msg.style.textAlign="center",u.appendChild(u.msg),u.buttons=document.createElement("div"),u.buttons.className="buttons";var l=document.createElement("input");l.type="button",l.className="button button-accept",l.value=i[1],e(l,"click",function(){m()}),u.buttons.appendChild(l);var a=document.createElement("input");a.type="button",a.className="button",a.value=i[0],e(a,"click",this.close),u.buttons.appendChild(a),u.appendChild(u.buttons),document.body.appendChild(u)}m=n,u.msg.innerHTML=t,MarcDialogs.open("quick-confirm")}}}();
/* MarcStringCleaner.js */
var _STR_CLEAN=['a',/[\xc0\xc1\xc2\xc4\xe0\xe1\xe2\xe4]/g,'e',/[\xc8\xc9\xca\xcb\xe8\xe9\xea\xeb]/g,'i',/[\xcc\xcd\xce\xcf\xec\xed\xee\xef]/g,'o',/[\xd2\xd3\xd4\xd6\xf2\xf3\xf4\xf6]/g,'u',/[\xd9\xda\xdb\xdc\xf9\xfa\xfb\xfc]/g,'n',/[\xd1\xf1]/g,'c',/[\xc7\xe7]/g,'ae',/[\xc6\xe6]/g,'and',/\x26/g,'euro',/\u20ac/g,'',/[^\w- ]/g,'_',/( |-)/g,'_',/_+/g,'',/^_|_$/g];
if(!String.prototype.clean)String.prototype.clean=function(){var s=this.toLowerCase();for(var i=0;i<_STR_CLEAN.length;i+=2)s=s.replace(_STR_CLEAN[i+1],_STR_CLEAN[i]);return s}
if(!String.prototype.clean)String.prototype.clean=function(){var s=this.toLowerCase();for(var i=0;i<_STR_CLEAN.length;i+=2)s=s.replace(_STR_CLEAN[i+1],_STR_CLEAN[i]);return s}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<span class="logo"></span>
<h1>Animal Crossing: New Leaf Save Editor</h1>
<div class="author">
by <a href="http://www.marcrobledo.com" target="_blank">Marc Robledo</a> <span class="last-update">(last updated on 3rd Feb 2017)</span>
by <a href="http://www.marcrobledo.com" target="_blank">Marc Robledo</a> <span class="last-update">(last updated on 19th Feb 2017)</span>
</div>

<div id="help">
Expand Down Expand Up @@ -128,7 +128,7 @@ <h3>Acres</h3>
<input type="button" value="Export map" onclick="exportMap(map)"/>
</div>

<div class="column column-5 end">
<div class="column column-5">
<h3>Grass</h3>
<canvas id="grass-current" class="grass"></canvas>
<hr/>
Expand Down

0 comments on commit d48efa8

Please sign in to comment.