MediaWiki:Gadget-ReferenceTooltips.js and Help:Creating mods: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>Leoetlino
m (1 revision imported)
 
imported>BravelyPeculiar
 
Line 1: Line 1:
// See [[mw:Reference Tooltips]]
Welcome, modders! This page is intended to be a collection of useful information for anybody who wants to create mods. If you want to simply use other people's mods, see [[Help:Playing with mods]].
// Source https://en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js


$( function () {
== Getting set up ==
var settings, settingsString, $footer, enabled, delay, isTouchscreen, settingsMenu;
To make mods, you'll need to start by dumping the unedited game files from your copy of BotW.
* [[Help:Playing with mods#Wii U/Cemu|Dumping the game files (Wii U)]]
* [[Help:Dumping games|Dumping the game files (Switch)]]


if ( window.pg ) {
== Files, Tools and Tutorials ==
return;
Since BotW uses a lot of Nintendo's own file formats, you'll need tools to be able to edit them. To use leoetlino's tools, you need to install the latest version of Python (64 bit version), and tick the "Add to PATH" / "Add to environment variables" box in the installer. Then, to install the tool, run <code>pip install TOOL_NAME</code> in the command line.
}


function toggleRT( enable ) {
If you're not sure which tool to use on a file, search for its extension on this wiki to find what file format that extension is used for.
mw.loader.using( 'jquery.cookie', function () {
$.cookie( 'RTsettings', ( enable ? '1' : '0' ) + '|' + settings[ 1 ] + '|' + settings[ 2 ], { path: '/', expires: 90 } );
location.reload();
} );
}


// Make sure we are in article, project, or help namespace
=== Yaz0 compression ===
if ( [ '', 'Project', 'Help', 'Draft' ].indexOf( mw.config.get( 'wgCanonicalNamespace' ) ) > -1 ) {
Many files in the game are compressed with [[Yaz0]] compression. Compressed files generally have the letter <code>s</code> prefixed to their file extension. To decompress and recompress these files, use '''wszst''' (install with <code>pip install wszst-yaz0</code>).
mw.messages.set( {
* <code>wszst decompress INPUT_FILE.sbactorpack OUTPUT_FILE.bactorpack</code>
'RT-enable': 'Enable Reference Tooltips',
* <code>wszst compress INPUT_FILE.bfres OUTPUT_FILE.sbfres</code>
'RT-disable': 'Disable Reference Tooltips',
'RT-disablenote': 'Once disabled, Reference Tooltips can be re-enabled using a link in the footer of the page.',
'RT-delay': 'Delay before the tooltip appears (in milliseconds): ',
'RT-activationmethod': 'Tooltip is activated by:',
'RT-hovering': 'hovering',
'RT-clicking': 'clicking',
'RT-options': 'Reference Tooltips options',
'RT-options-save': 'Save settings',
'RT-settings': 'Tooltip settings'
} );
settingsString = document.cookie.split( 'RTsettings=' )[ 1 ];
if ( settingsString ) {
settings = settingsString.split( ';' )[ 0 ].split( '%7C' );
enabled = !!+settings[ 0 ];
delay = +settings[ 1 ];
isTouchscreen = !!+settings[ 2 ];
} else {
enabled = true;
delay = 200;
isTouchscreen = 'ontouchstart' in document.documentElement;
}
if ( !enabled ) {
$footer = $( '#footer-places, #f-list' );
if ( !$footer.length ) {
$footer = $( '#footer li' ).parent();
}
$footer.append( $( '<li>' ).append(
$( '<a>' )
.text( mw.msg( 'RT-enable' ) )
.attr( 'href', '' )
.on( 'click', function ( e ) {
e.preventDefault();
toggleRT( true );
} )
) );
return;
}


$( '.reference' ).each( function () {
=== SARC archives ===
var tooltipNode, hideTimer, showTimer, checkFlip = false;
[[SARC]] archives contain collections of other files and folders, like .zip folders. Unpack, edit and re-pack them with leoetlino's [https://pypi.org/project/sarc/ <code>sarc</code> tool]. This tool automatically decompresses Yaz0-encoded archives, and re-compresses them when you repack if the extension starts with an <code>s</code>.
function findRef( h ) {
* <code>sarc extract INPUT_FILE.pack</code>
h = h.firstChild; h = h && h.getAttribute && h.getAttribute( 'href' ); h = h && h.split( '#' ); h = h && h[ 1 ];
* <code>sarc create [-b] INPUT_FOLDER OUTPUT_FILE.sbactorpack</code> (Use <code>-b</code>for Wii U only).
h = h && document.getElementById( h );
 
h = h && h.nodeName === 'LI' && h;
=== BYML files ===
return h;
[[BYML]] files contain game parameters. Convert them to an editable format (and back) with leoetlino's [https://pypi.org/project/byml/ <code>byml</code> tool]. This tool automatically decompresses Yaz0-encoded files, and re-compresses them if the extension starts with an <code>s</code>.
}
* <code>byml_to_yml INPUT_FILE.byml OUTPUT_FILE.yml</code>
function hide( refLink ) {
* <code>yml_to_byml [-b] INPUT_FILE.yml OUTPUT_FILE.sbyml</code> (Use <code>-b</code> for Wii U only).
if ( tooltipNode && tooltipNode.parentNode === document.body ) {
 
hideTimer = setTimeout( function () {
=== AAMP files ===
$( tooltipNode ).animate( { opacity: 0 }, 100, function () { document.body.removeChild( tooltipNode ); } );
[[AAMP]] files also contain game parameters. Convert them to an editable format (and back) with leoetlino's [https://pypi.org/project/aamp/ <code>aamp</code> tool]. Unlike most other files, AAMP files are exactly the same on both Wii U and Switch.
}, isTouchscreen ? 16 : 100 );
* <code>aamp_to_yml INPUT_FILE.bxml OUTPUT_FILE.yml</code>
} else {
* <code>yml_to_aamp INPUT_FILE.yml OUTPUT_FILE.bgparamlist</code>
$( findRef( refLink ) ).removeClass( 'RTTarget' );
 
}
=== BFRES files ===
}
[[BFRES]] files contain the game's models and textures. Tutorials on how to edit these for Wii U can be found in [https://drive.google.com/drive/folders/1Z1_A3w0VvPHp22H_Yh_dSdzI5hr4OAv9 Fooni's Tutorials].
function show() {
* <code>.sbfres</code> files contain models.
if ( !tooltipNode.parentNode || tooltipNode.parentNode.nodeType === 11 ) {
* <code>.Tex1.sbfres</code> files contain textures (Wii U).
document.body.appendChild( tooltipNode );
* <code>.Tex2.sbfres</code> files contain mipmaps for textures (Wii U). Since we can't edit these on Wii U yet, they need to be disabled.
checkFlip = true;
* <code>.Tex.sbfres</code> files contain both textures and mipmaps (Switch). Unlike on Wii U, mipmaps don't cause any problems here.
}
 
$( tooltipNode ).stop().animate( { opacity: 1 }, 100 );
== Rules ==
clearTimeout( hideTimer );
 
}
=== The RSTB file ===
function openSettingsMenu() {
The file [[ResourceSizeTable.product.rsizetable]] (referred to as the RSTB file) contains a list of size limits for almost every file in the game (calculated from the non-Yaz0-compressed file sizes). If you edit a file to make its filesize bigger, you'll need to edit this file to prevent errors. For details, see [[Help:Editing the RSTB]].
if ( settingsMenu ) {
 
settingsMenu.dialog( 'open' );
=== File names and caching ===
} else {
The game assumes that any 2 files with the exact same filename also have the exact same contents. If you don't follow this rule when editing files, the game might load the wrong version of the file, leading to errors.
settingsMenu = $( '<form>' )
.append(
$( '<button>' )
.css( 'width', '100%' )
.text( mw.msg( 'RT-disable', mw.user ) )
.button()
.on( 'click', function ( e ) {
e.preventDefault();
toggleRT( false );
} ),
$( '<br>' ),
$( '<small>' ).text( mw.msg( 'RT-disablenote' ) ),
$( '<hr>' ),
$( '<label>' ).text( mw.msg( 'RT-delay' ) ).append( $( '<input>' ).attr( {
type: 'number',
value: delay,
step: 50,
min: 0,
max: 5000
} ) ),
$( '<br>' ),
$( '<span>' ).text( mw.msg( 'RT-activationmethod', mw.user ) ),
$( '<label>' ).append(
$( '<input>' ).attr( {
type: 'radio',
name: 'RTActivate',
checked: !isTouchscreen ? 'checked' : undefined,
disabled: 'ontouchstart' in document.documentElement ? 'disabled' : undefined
} ),
mw.msg( 'RT-hovering', mw.user )
),
$( '<label>' ).append(
$( '<input>' ).attr( {
type: 'radio',
name: 'RTActivate',
checked: isTouchscreen ? 'checked' : undefined
} ),
mw.msg( 'RT-clicking', mw.user )
)
)
.submit( function ( e ) { e.preventDefault(); } )
.dialog( {
modal: true,
width: 500,
title: mw.msg( 'RT-options' ),
buttons: [ {
text: mw.msg( 'RT-options-save', mw.user ),
click: function () {
var inputs = this.getElementsByTagName( 'input' ),
newDelay = +inputs[ 0 ].value;
$.cookie( 'RTsettings',
'1|' +
( newDelay > -1 && newDelay < 5001 ? newDelay : delay ) +
'|' +
// hover/click
( inputs[ 1 ].checked ? '0' : '1' ),
{ path: '/', expires: 90 }
);
location.reload();
}
} ]
} );
}
}
function onStartEvent( e ) {
var onBodyClick, self = this;
if ( window.pg ) {
return;
}
if ( isTouchscreen ) {
e.preventDefault();
if ( !( tooltipNode && tooltipNode.parentNode === document.body ) ) {
onBodyClick = function ( e ) {
e = e.target;
for ( ; e && !$( e ).hasClass( 'referencetooltip' ); ) { e = e.parentNode; }
if ( !e ) {
clearTimeout( showTimer );
hide( self );
$( document.body ).off( 'click touchstart', onBodyClick );
}
};
setTimeout( function () {
$( document.body ).on( 'click touchstart', onBodyClick );
} );
}
}
if ( hideTimer ) { clearTimeout( hideTimer ); }
if ( showTimer ) { clearTimeout( showTimer ); }
showTimer = setTimeout( function () {
var windowTop, hOffsetTop, c, o, oH,
h = findRef( self );
if ( !h ) { return; }
windowTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
hOffsetTop = $( h ).offset().top;
if ( !isTouchscreen && windowTop < hOffsetTop && windowTop + $( window ).height() > hOffsetTop + h.offsetHeight ) {
$( h ).addClass( 'RTTarget' );
return;
}
if ( !tooltipNode ) {
tooltipNode = document.createElement( 'ul' );
tooltipNode.className = 'referencetooltip';
c = tooltipNode.appendChild( $( h ).clone( true )[ 0 ] );
try {
if ( c.firstChild.nodeName !== 'A' ) {
while ( c.childNodes[ 1 ].nodeName === 'A' && c.childNodes[ 1 ].getAttribute( 'href' ).indexOf( '#cite_ref-' ) !== -1 ) {
do { c.removeChild( c.childNodes[ 1 ] ); } while ( c.childNodes[ 1 ].nodeValue === ' ' );
}
}
} catch ( err ) { mw.log( err ); }
c.removeChild( c.firstChild );
$( tooltipNode.firstChild.insertBefore( document.createElement( 'span' ), tooltipNode.firstChild.firstChild ) ).addClass( 'RTsettings' )
.attr( 'title', mw.msg( 'RT-settings' ) )
.on( 'click', function () {
mw.loader.using( [ 'jquery.cookie', 'jquery.ui.dialog' ], openSettingsMenu );
} );
tooltipNode.appendChild( document.createElement( 'li' ) );
if ( !isTouchscreen ) {
$( tooltipNode ).on( { mouseenter: show, mouseleave: hide } );
}
}
show();
o = $( self ).offset();
oH = tooltipNode.offsetHeight;
$( tooltipNode ).css( { top: o.top - oH, left: o.left - 7 } );
if ( tooltipNode.offsetHeight > oH ) { // is it squished against the right side of the page?
$( tooltipNode ).css( { left: 'auto', right: 0 } );
tooltipNode.lastChild.style.marginLeft = ( o.left - tooltipNode.offsetLeft ) + 'px';
}
if ( checkFlip ) {
if ( o.top < tooltipNode.offsetHeight + ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop ) ) { // is part of it above the top of the screen?
$( tooltipNode ).addClass( 'RTflipped' ).css( { top: o.top + 12 } );
} else if ( tooltipNode.className === 'referencetooltip RTflipped' ) { // cancel previous
$( tooltipNode ).removeClass( 'RTflipped' );
}
checkFlip = false;
}
}, isTouchscreen ? 0 : delay );
}
function onEndEvent() {
clearTimeout( showTimer ); hide( this );
}
$( this ).on( isTouchscreen ? { click: onStartEvent } : { mouseenter: onStartEvent, mouseleave: onEndEvent } );
} );
}
} );

Revision as of 15:56, 15 October 2018

Welcome, modders! This page is intended to be a collection of useful information for anybody who wants to create mods. If you want to simply use other people's mods, see Help:Using mods.

Getting set up

To make mods, you'll need to start by dumping the unedited game files from your copy of BotW.

Files, Tools and Tutorials

Since BotW uses a lot of Nintendo's own file formats, you'll need tools to be able to edit them. To use leoetlino's tools, you need to install the latest version of Python (64 bit version), and tick the "Add to PATH" / "Add to environment variables" box in the installer. Then, to install the tool, run pip install TOOL_NAME in the command line.

If you're not sure which tool to use on a file, search for its extension on this wiki to find what file format that extension is used for.

Yaz0 compression

Many files in the game are compressed with Yaz0 compression. Compressed files generally have the letter s prefixed to their file extension. To decompress and recompress these files, use wszst (install with pip install wszst-yaz0).

  • wszst decompress INPUT_FILE.sbactorpack OUTPUT_FILE.bactorpack
  • wszst compress INPUT_FILE.bfres OUTPUT_FILE.sbfres

SARC archives

SARC archives contain collections of other files and folders, like .zip folders. Unpack, edit and re-pack them with leoetlino's sarc tool. This tool automatically decompresses Yaz0-encoded archives, and re-compresses them when you repack if the extension starts with an s.

  • sarc extract INPUT_FILE.pack
  • sarc create [-b] INPUT_FOLDER OUTPUT_FILE.sbactorpack (Use -bfor Wii U only).

BYML files

BYML files contain game parameters. Convert them to an editable format (and back) with leoetlino's byml tool. This tool automatically decompresses Yaz0-encoded files, and re-compresses them if the extension starts with an s.

  • byml_to_yml INPUT_FILE.byml OUTPUT_FILE.yml
  • yml_to_byml [-b] INPUT_FILE.yml OUTPUT_FILE.sbyml (Use -b for Wii U only).

AAMP files

AAMP files also contain game parameters. Convert them to an editable format (and back) with leoetlino's aamp tool. Unlike most other files, AAMP files are exactly the same on both Wii U and Switch.

  • aamp_to_yml INPUT_FILE.bxml OUTPUT_FILE.yml
  • yml_to_aamp INPUT_FILE.yml OUTPUT_FILE.bgparamlist

BFRES files

BFRES files contain the game's models and textures. Tutorials on how to edit these for Wii U can be found in Fooni's Tutorials.

  • .sbfres files contain models.
  • .Tex1.sbfres files contain textures (Wii U).
  • .Tex2.sbfres files contain mipmaps for textures (Wii U). Since we can't edit these on Wii U yet, they need to be disabled.
  • .Tex.sbfres files contain both textures and mipmaps (Switch). Unlike on Wii U, mipmaps don't cause any problems here.

Rules

The RSTB file

The file ResourceSizeTable.product.rsizetable (referred to as the RSTB file) contains a list of size limits for almost every file in the game (calculated from the non-Yaz0-compressed file sizes). If you edit a file to make its filesize bigger, you'll need to edit this file to prevent errors. For details, see Help:Editing the RSTB.

File names and caching

The game assumes that any 2 files with the exact same filename also have the exact same contents. If you don't follow this rule when editing files, the game might load the wrong version of the file, leading to errors.