Skip to content

Commit d48efa8

Browse files
author
Marc Robledo
committed
fixed both grass current+previous preview maps
1 parent e792267 commit d48efa8

File tree

4 files changed

+71
-58
lines changed

4 files changed

+71
-58
lines changed

acnl_editor.appcache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# last update 2017-02-18
2+
# last update 2017-02-19
33
# these belong to the CACHE block
44
index.html
55
help.html
@@ -18,4 +18,4 @@ data/villagers.jpg
1818

1919
# force these files to be loaded in network
2020
NETWORK:
21-
*
21+
*

data/acnl_editor.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Animal Crossing:New Leaf RAM Editor v20170103
2+
Animal Crossing:New Leaf RAM Editor v20170219
33
by Marc Robledo 2015-2017
44
*/
55
@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}
@@ -338,6 +338,22 @@ span.sprite{display:inline-block;vertical-align:middle}
338338
.room-container .grid{margin-right:10px}
339339

340340

341+
canvas.grass{
342+
width:320px;
343+
border:1px dotted #ccc;
344+
image-rendering:optimizeSpeed;
345+
image-rendering:-moz-crisp-edges;
346+
image-rendering:-webkit-optimize-contrast;
347+
image-rendering:optimize-contrast;
348+
image-rendering:pixelated;
349+
-ms-interpolation-mode:nearest-neighbor;
350+
}
351+
#grass-previous{
352+
width:384px;
353+
}
354+
355+
356+
341357
#move-building-overlay{
342358
position:absolute;
343359
background-color:rgba(255,255,255,.25);

data/acnl_editor.js

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
A lot of thanks to:
66
* Thulinma for Pattern structure (check out his editor pattern http://www.thulinma.com/acnl/ )
77
* NeoKamek for his work on LeafTools and other help
8+
* jexom for documenting grass deterioration
89
* froggestspirit for extracting acre information and item list
910
* sprungit/shokolad-town for compiling hair style and color thumbnails
1011
*/
@@ -570,25 +571,25 @@ Town.prototype.maxTurnipPrices=function(){
570571
}
571572

572573
Town.prototype.setGrass=function(b){
573-
var MAX_CURRENT=(16*16)*(8*6);
574+
var MAX_CURRENT=(16*16)*(5*4);
574575
for(var i=0; i<MAX_CURRENT; i++){
575-
if(Math.floor(i/64) < (Math.floor(i/(64*16)) + 1) * 16 - 2){
576-
grassCurrent.tiles[i]=~b & 0xff;
577-
savegame.storeByte(Offsets.MAP_GRASS_CURRENT+i, grassCurrent.tiles[i]);
578-
}
576+
grassCurrent.tiles[i]=b & 0x0f;
577+
savegame.storeByte(Offsets.MAP_GRASS_CURRENT+i, grassCurrent.tiles[i]);
579578
}
580-
581-
var MAX=(16*16)*(8*6) ; // *2 ???
582-
for(var i=0; i<MAX; i++)
583-
if(Math.floor(i/64) < (Math.floor(i/(64*16)) + 1) * 16 - 2)
584-
savegame.storeByte(Offsets.MAP_GRASS_PREVIOUS+i, b);
585579
grassCurrent.draw();
586580

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

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

917918

918919

919-
function GrassMapPrevious(offset,canvasId,width,height){
920+
function GrassMapCurrent(offset,canvasId,width,height){
920921
this.offset=offset;
921922
this.canvas=el(canvasId);
922923
this.width=width;
923924
this.height=height;
924925

925-
this.canvas.width=this.width*32*2;
926-
this.canvas.height=this.height*32*2;
926+
this.canvas.width=this.width*16;
927+
this.canvas.height=this.height*16;
927928

928929
this.tiles=new Array(width*height*16*16);
929930
for(var i=0; i<this.tiles.length; i++){
930931
var b=savegame.readByte1(this.offset+i);
931-
this.tiles[i]=b & 0xff;
932+
this.tiles[i]=b & 0x0f;
932933
if(b >> 4){
933934
//alert(b);
934935
}
935936
}
936937

937938
this.draw();
938939
}
939-
GrassMapPrevious.prototype.draw=function(){
940+
GrassMapCurrent.prototype.draw=function(){
940941
var tile=0;
941942
var ctx=this.canvas.getContext('2d');
942-
for(var i=0; i<this.height*2; i++){
943-
for(var j=0; j<this.width*2; j++){
944-
for(var y4=0; y4<2; y4++){
945-
for(var x4=0; x4<2; x4++){
946-
for(var y2=0; y2<2; y2++){
947-
for(var x2=0; x2<2; x2++){
948-
for(var y1=0; y1<2; y1++){
949-
for(var x1=0; x1<2; x1++){
950-
var color=255-this.tiles[tile];
951-
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
952-
ctx.fillRect((j*8+x4*4+x2*2+x1)*4-3, (i*8+y4*4+y2*2+y1)*4-3, 4, 4);
943+
for(var i=0; i<this.height; i++){
944+
for(var j=0; j<this.width; j++){
945+
for(var y=0; y<16; y++){
946+
for(var x=0; x<16; x++){
947+
var color=255-this.tiles[tile]*17;
948+
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
949+
ctx.fillRect(j*16+x, i*16+y, 1, 1);
953950

954-
tile++;
955-
}
956-
}
957-
}
958-
}
951+
tile++;
959952
}
960953
}
961954
}
962955
}
963956
}
964-
GrassMapPrevious.prototype.save=function(){
957+
GrassMapCurrent.prototype.save=function(){
965958
}
966959

967960

968-
function GrassMapCurrent(offset,canvasId,width,height){
961+
function GrassMapPrevious(offset,canvasId,width,height){
969962
this.offset=offset;
970963
this.canvas=el(canvasId);
971964
this.width=width;
@@ -975,32 +968,36 @@ function GrassMapCurrent(offset,canvasId,width,height){
975968
this.canvas.height=this.height*16;
976969

977970
this.tiles=new Array(width*height*16*16);
978-
for(var i=0; i<this.tiles.length; i++){
979-
var b=savegame.readByte1(this.offset+i);
980-
this.tiles[i]=b;
981-
}
971+
for(var i=0; i<this.tiles.length; i++)
972+
this.tiles[i]=savegame.readByte1(this.offset+i);
982973

983974
this.draw();
984975
}
985-
GrassMapCurrent.prototype.draw=function(){
976+
GrassMapPrevious.prototype.draw=function(){
986977
var tile=0;
987978
var ctx=this.canvas.getContext('2d');
988-
for(var i=0; i<this.height; i++){
989-
for(var j=0; j<this.width; j++){
990-
for(var y=0; y<16; y++){
991-
for(var x=0; x<16; x++){
992-
var color=255-this.tiles[tile];
993-
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
994-
ctx.fillRect(j*16+x, i*16+y, 1, 1);
979+
for(var i=0; i<this.height*2; i++){
980+
for(var j=0; j<this.width*2; j++){
981+
for(var y4=0; y4<2; y4++){
982+
for(var x4=0; x4<2; x4++){
983+
for(var y2=0; y2<2; y2++){
984+
for(var x2=0; x2<2; x2++){
985+
for(var y1=0; y1<2; y1++){
986+
for(var x1=0; x1<2; x1++){
987+
var color=this.tiles[tile];
988+
ctx.fillStyle='rgba('+color+','+color+','+color+',1)';
989+
ctx.fillRect((j*8+x4*4+x2*2+x1), (i*8+y4*4+y2*2+y1), 1, 1);
995990

996-
tile++;
991+
tile++;
992+
}
993+
}
994+
}
995+
}
997996
}
998997
}
999998
}
1000999
}
10011000
}
1002-
GrassMapCurrent.prototype.save=function(){
1003-
}
10041001

10051002

10061003

@@ -2830,8 +2827,8 @@ function initializeEverything(){
28302827
island=new ItemGridMap('island');
28312828

28322829
/* Grass */
2833-
grassCurrent=new GrassMapPrevious(Offsets.MAP_GRASS_CURRENT,'grass-current',5,4);
2834-
//new GrassMapCurrent(Offsets.MAP_GRASS_PREVIOUS,'grass-previous',5,4);
2830+
grassCurrent=new GrassMapCurrent(Offsets.MAP_GRASS_CURRENT,'grass-current',5,4);
2831+
grassPrevious=new GrassMapPrevious(Offsets.MAP_GRASS_PREVIOUS,'grass-previous',8,6);
28352832

28362833
/* read player data */
28372834
players=new Array(4);
@@ -3386,4 +3383,4 @@ var saveAs=saveAs||(navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator))|
33863383
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")}}}();
33873384
/* MarcStringCleaner.js */
33883385
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];
3389-
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}
3386+
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}

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<span class="logo"></span>
1919
<h1>Animal Crossing: New Leaf Save Editor</h1>
2020
<div class="author">
21-
by <a href="http://www.marcrobledo.com" target="_blank">Marc Robledo</a> <span class="last-update">(last updated on 3rd Feb 2017)</span>
21+
by <a href="http://www.marcrobledo.com" target="_blank">Marc Robledo</a> <span class="last-update">(last updated on 19th Feb 2017)</span>
2222
</div>
2323

2424
<div id="help">
@@ -128,7 +128,7 @@ <h3>Acres</h3>
128128
<input type="button" value="Export map" onclick="exportMap(map)"/>
129129
</div>
130130

131-
<div class="column column-5 end">
131+
<div class="column column-5">
132132
<h3>Grass</h3>
133133
<canvas id="grass-current" class="grass"></canvas>
134134
<hr/>

0 commit comments

Comments
 (0)