Skip to content

Commit

Permalink
added missing icons for 1.4 items
Browse files Browse the repository at this point in the history
fixed a bug that could potentially break savegames
added max hearts and stamina editor
added horse checker that avois adding special horses to stable
changed the way adding/editing items work, hopefully making it easier
and clearer
  • Loading branch information
marcrobledo committed May 17, 2018
1 parent 9df1abc commit c9694b5
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 49 deletions.
26 changes: 13 additions & 13 deletions zelda-botw/_cache_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ limitations under the License.
mod by marcrobledo, original from: https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
*/

const PRECACHE_ID='v20180512';
const PRECACHE_ID='v20180517c';
const PRECACHE_FILES=[
'index.html','./',
'zelda-botw.css',
'zelda-botw.js',
'zelda-botw.data.js',
'zelda-botw.icons.js',
'zelda-botw.locations.js',
'favicon.png',
'assets/_blank.png',
'assets/logo.png',
'assets/bg_black.jpg',
'assets/bg_white.jpg',
'../savegame-editor.js'
'zelda-botw/index.html','./',
'zelda-botw/zelda-botw.css',
'zelda-botw/zelda-botw.js',
'zelda-botw/zelda-botw.data.js',
'zelda-botw/zelda-botw.icons.js',
'zelda-botw/zelda-botw.locations.js',
'zelda-botw/favicon.png',
'zelda-botw/assets/_blank.png',
'zelda-botw/assets/logo.png',
'zelda-botw/assets/bg_black.jpg',
'zelda-botw/assets/bg_white.jpg',
'savegame-editor.js'
];

self.addEventListener('install',event=>{event.waitUntil(caches.open(PRECACHE_ID).then(cache=>cache.addAll(PRECACHE_FILES)).then(self.skipWaiting()))});self.addEventListener('activate',event=>{const currentCaches=[PRECACHE_ID,'runtime'];event.waitUntil(caches.keys().then(cacheNames=>{return cacheNames.filter(cacheName=>!currentCaches.includes(cacheName));}).then(cachesToDelete=>{return Promise.all(cachesToDelete.map(cacheToDelete=>{return caches.delete(cacheToDelete);}))}).then(()=>self.clients.claim()))});self.addEventListener('fetch',event=>{if(event.request.url.startsWith(self.location.origin))event.respondWith(caches.match(event.request).then(cachedResponse=>{if(cachedResponse)return cachedResponse;return caches.open('runtime').then(cache=>{return fetch(event.request).then(response=>{return cache.put(event.request,response.clone()).then(()=>{return response})})})}))})
Binary file modified zelda-botw/assets/Armor_Head.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified zelda-botw/assets/Armor_Lower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified zelda-botw/assets/Armor_Upper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified zelda-botw/assets/Other.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified zelda-botw/assets/Weapon_Sword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 57 additions & 11 deletions zelda-botw/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<script type="text/javascript" src="./zelda-botw.data.js"></script>
<script type="text/javascript" src="./zelda-botw.locations.js"></script>
<script type="text/javascript" src="./zelda-botw.icons.js"></script>
<!-- <script type="text/javascript" src="./zelda-botw.hashes.js"></script> -->
</head>
<body>

Expand Down Expand Up @@ -76,6 +77,61 @@ <h3 class="border-red">Stats</h3>
<div class="ten columns"><label for="number-playtime">Playtime</label></div>
<div class="two columns"><input type="text" id="number-playtime" class="text-right full-width" disabled /></div>
</div>
<div class="row">
<div class="ten columns"><label for="select-max-hearts">Max. hearts</label></div>
<div class="two columns">
<select id="select-max-hearts" class="full-width">
<option value="4">1</option>
<option value="8">2 hearts</option>
<option value="12">3 hearts</option>
<option value="16">4 hearts</option>
<option value="20">5 hearts</option>
<option value="24">6 hearts</option>
<option value="28">7 hearts</option>
<option value="32">8 hearts</option>
<option value="36">9 hearts</option>
<option value="40">10 hearts</option>
<option value="44">11 hearts</option>
<option value="48">12 hearts</option>
<option value="52">13 hearts</option>
<option value="56">14 hearts</option>
<option value="60">15 hearts</option>
<option value="64">16 hearts</option>
<option value="68">17 hearts</option>
<option value="72">18 hearts</option>
<option value="76">19 hearts</option>
<option value="80">20 hearts</option>
<option value="84">21 hearts</option>
<option value="88">22 hearts</option>
<option value="92">23 hearts</option>
<option value="96">24 hearts</option>
<option value="100">25 hearts</option>
<option value="104">26 hearts</option>
<option value="108">27 hearts</option>
<option value="112">28 hearts</option>
<option value="116">29 hearts</option>
<option value="120">30 hearts</option>
</select>
</div>
</div>
<div class="row">
<div class="ten columns"><label for="select-max-stamina">Max. stamina </label></div>
<div class="two columns">
<select id="select-max-stamina" class="full-width">
<option value="1148846080">1 wheel</option>
<option value="1150681088">1 wheel+1/5</option>
<option value="1152319488">1 wheel+2/5</option>
<option value="1153957888">1 wheel+3/5</option>
<option value="1155596288">1 wheel+4/5</option>
<option value="1157234688">2 wheels</option>
<option value="1158250496">2 wheels+1/5</option>
<option value="1159069696">2 wheels+2/5</option>
<option value="1159888896">2 wheels+3/5</option>
<option value="1160708096">2 wheels+4/5</option>
<option value="1161527296">3 wheels</option>
</select>
</div>
</div>

<!-- Coordinates (Requires a memory editor) -->
<h3 class="border-green">Coordinates</h3>
Expand Down Expand Up @@ -180,15 +236,6 @@ <h3 class="border-green">Completionism</h3>
</div>

<!-- DIALOGS -->
<div id="dialog-item" class="dialog">
<div class="text-center">
<select id="select-item"></select>
</div>
<div class="buttons">
<button onclick="SavegameEditor.editItem2(currentEditingItem, getValue('item'));MarcDialogs.close();">Save changes</button>
</div>
</div>

<div id="dialog-horse" class="dialog">
<div id="row-tamed-horse">
<div class="row">
Expand All @@ -213,7 +260,6 @@ <h3 class="border-green">Completionism</h3>
</div>
</div>

<ul id="caca">
</ul>
<ul id="caca"></ul>
</body>
</html>
4 changes: 2 additions & 2 deletions zelda-botw/zelda-botw.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body{
padding:10px;
}
.row-items img{max-width:100%}
.row-items img:hover{background-color:#222}
.row-items .item-name:hover{text-decoration:underline}
.item-number{position:absolute;top:0;left:0; color:#444;font-family:monospace;font-size:80%}
.tiles span{display:block}

Expand Down Expand Up @@ -260,7 +260,7 @@ input[type=text].error,input[type=number].error,select.error{
input[type=text].small,input[type=number].small,select.small{width:70px}
input[type=text].medium,input[type=number].medium,select.medium{width:130px}
.full-width{width:100% !important;max-width:100% !important}

optgroup{background-color:black}

#the-editor input[type=text],#the-editor input[type=number],#the-editor select{
border:1px solid #444;
Expand Down
13 changes: 8 additions & 5 deletions zelda-botw/zelda-botw.icons.js

Large diffs are not rendered by default.

63 changes: 45 additions & 18 deletions zelda-botw/zelda-botw.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
The legend of Zelda: Breath of the wild v20180512
The legend of Zelda: Breath of the wild v20180517
by Marc Robledo 2017-2018
*/
var currentEditingItem=0;
Expand Down Expand Up @@ -29,6 +29,8 @@ SavegameEditor={
/* hash v1.0 v1.1 v1.2 v1.3 v1.3.3 v1.4 v1.5 */
RUPEES: [0x23149bf8, 0x00e0a0, 0x00e110, 0x00e110, 0x00e678, 0x00e730, 0x00eaf8, 0x00eaf8],
MONS: [0xce7afed3, 0x0bc480, 0x0bc558, 0x0bc538, 0x0be728, 0x0d6ac8, 0x0d7fa8, 0x0d7fa8],
MAX_HEARTS: [0x2906f327, 0x00fd28, 0x00fdb8, 0x00fdb8, 0x010438, 0x010508, 0x010970, 0x010970],
MAX_STAMINA: [0x3adff047, 0x043208, 0x0432c0, 0x0432c0, 0x043c98, 0x04fdb0, 0x0503c8, 0x0503c8],
ITEMS: [0x5f283289, 0x052828, 0x0528d8, 0x0528c0, 0x053890, 0x05fa48, 0x060408, 0x060408],
ITEMS_QUANTITY: [0x6a09fc59, 0x063340, 0x0633f0, 0x0633d8, 0x064550, 0x070730, 0x0711c8, 0x0711c8],

Expand Down Expand Up @@ -150,6 +152,14 @@ SavegameEditor={
}
return txt
},
_readStringShort:function(offset){
var txt='';
for(var j=0; j<8; j++){
txt+=tempFile.readString(offset,4);
offset+=8;
}
return txt
},

_loadItemName:function(i){
return this._readString(this.Offsets.ITEMS+i*0x80);
Expand All @@ -174,21 +184,17 @@ SavegameEditor={
_getItemQuantityOffset:function(i){
return this.Offsets.ITEMS_QUANTITY+i*0x08;
},
_getItemRow(i){
_getItemRow:function(i){
return getField('number-item'+i).parentElement.parentElement
},
_createItemRow(i,itemCat){
_createItemRow:function(i,itemCat){
var itemNameId=this._loadItemName(i);
var itemVal=itemCat===false?1:tempFile.readInt(this._getItemQuantityOffset(i));

var img=new Image();
img.id='icon'+i;
img.className='clickable';
img.src=BOTW_Icons.getBlankIcon();

img.addEventListener('click', function(){
SavegameEditor.editItem(i);
}, false);
/*img.addEventListener('error', function(){
img.src=BOTW_Icons.getBlankIcon();
}, false);*/
Expand All @@ -198,8 +204,12 @@ SavegameEditor={
itemNumber.innerHTML='#'+i;

var span=document.createElement('span');
span.className='item-name clickable';
span.id='item-name'+i;
span.innerHTML=this._getItemTranslation(itemNameId);
span.addEventListener('click', function(){
SavegameEditor.editItem(i);
}, false);


var input;
Expand Down Expand Up @@ -232,22 +242,23 @@ SavegameEditor={
i++;
}
if(i<this.Constants.MAX_ITEMS){
getField('select-item').selectedIndex++;
var itemNameId=getValue('select-item');
this.selectItem.selectedIndex++;
var itemNameId=this.selectItem.value;
this._writeItemName(i,itemNameId);
var row=this._createItemRow(i, false);
document.getElementById('container-'+this._getItemCategory(itemNameId)).appendChild(row);

(row.previousElementSibling || row).scrollIntoView({block:'start', behavior:'smooth'});
//this.editItem(i);
this.editItem(i);
}
},

editItem:function(i){
currentEditingItem=i;
document.getElementById('select-item').value=this._loadItemName(i);

MarcDialogs.open('item');
this.selectItem.value=this._loadItemName(i);
document.getElementById('item-name'+i).innerHTML='';
document.getElementById('item-name'+i).parentElement.appendChild(this.selectItem);
this.selectItem.focus();
},
editItem2:function(i,nameId){
var oldCat=this._getItemCategory(this._loadItemName(i));
Expand Down Expand Up @@ -296,11 +307,15 @@ SavegameEditor={
MarcDialogs.alert('Error: this will only work if your savegame has Link on an untamed horse.');
return false;
}
getField('horse-type').children[27].disabled=false;
getField('horse-type').children[28].disabled=false;
}else{
show('row-tamed-horse');
setValue('horse-name',this._readString(this.Offsets.HORSE_NAMES+this.Constants.STRING_SIZE*i));
setValue('horse-saddles',this._readString(this.Offsets.HORSE_SADDLES+this.Constants.STRING_SIZE*i));
setValue('horse-reins',this._readString(this.Offsets.HORSE_REINS+this.Constants.STRING_SIZE*i));
getField('horse-type').children[27].disabled=true;
getField('horse-type').children[28].disabled=true;
}
setValue('horse-type',this._readString(this.Offsets.HORSE_TYPES+this.Constants.STRING_SIZE*i));
MarcDialogs.open('horse');
Expand Down Expand Up @@ -352,6 +367,14 @@ SavegameEditor={


preload:function(){
this.selectItem=document.createElement('select');
this.selectItem.addEventListener('blur', function(){
//console.log('blur');
SavegameEditor.editItem2(currentEditingItem, this.value);
this.parentElement.removeChild(this);
currentEditingItem=null;
}, false);

setNumericRange('rupees', 0, 999999);
setNumericRange('mons', 0, 999999);
setNumericRange('relic-gerudo', 0, 99);
Expand All @@ -369,9 +392,9 @@ SavegameEditor={
opt.innerHTML=BOTW_Data.Translations[i].items[item];
optGroup.appendChild(opt);
}
get('select-item').appendChild(optGroup);
this.selectItem.appendChild(optGroup);
}
setValue('select-item','Armor_180_Lower');
this.selectItem.value='Armor_180_Lower';

/* map position selectors */
select(
Expand Down Expand Up @@ -444,6 +467,8 @@ SavegameEditor={
/* prepare editor */
setValue('rupees', tempFile.readInt(this.Offsets.RUPEES));
setValue('mons', tempFile.readInt(this.Offsets.MONS));
setValue('max-hearts', tempFile.readInt(this.Offsets.MAX_HEARTS));
setValue('max-stamina', tempFile.readInt(this.Offsets.MAX_STAMINA));

setValue('relic-gerudo', tempFile.readInt(this.Offsets.RELIC_GERUDO));
setValue('relic-goron', tempFile.readInt(this.Offsets.RELIC_GORON));
Expand All @@ -470,8 +495,8 @@ SavegameEditor={
setValue('pos-y', tempFile.readFloat32(this.Offsets.PLAYER_POSITION+8));
setValue('pos-z', tempFile.readFloat32(this.Offsets.PLAYER_POSITION+16));

var map=this._readString(this.Offsets.MAP);
var mapType=this._readString(this.Offsets.MAPTYPE);
var map=this._readStringShort(this.Offsets.MAP);
var mapType=this._readStringShort(this.Offsets.MAPTYPE);
getField('pos-map').children[0].value=map;
getField('pos-map').children[0].innerHTML='* '+map+' *';
getField('pos-maptype').children[0].value=mapType;
Expand Down Expand Up @@ -554,6 +579,8 @@ SavegameEditor={
/* STATS */
tempFile.writeInt(this.Offsets.RUPEES, getValue('rupees'));
tempFile.writeInt(this.Offsets.MONS, getValue('mons'));
tempFile.writeInt(this.Offsets.MAX_HEARTS, getValue('max-hearts'));
tempFile.writeInt(this.Offsets.MAX_STAMINA, getValue('max-stamina'));

tempFile.writeInt(this.Offsets.RELIC_GERUDO, getValue('relic-gerudo'));
tempFile.writeInt(this.Offsets.RELIC_GORON, getValue('relic-goron'));
Expand Down Expand Up @@ -937,7 +964,7 @@ window.addEventListener('load',function(){
if(location.protocol==='http:')
location.href=window.location.href.replace('http:','https:');
if('serviceWorker' in navigator)
navigator.serviceWorker.register('_cache_service_worker.js');
navigator.serviceWorker.register('zelda-botw/_cache_service_worker.js');

window.addEventListener('scroll',onScroll,false);
}, false);

0 comments on commit c9694b5

Please sign in to comment.