Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcrobledo committed Apr 18, 2022
1 parent 682c4e7 commit 3c0de71
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 53 deletions.
31 changes: 8 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
# RetroArch Playlist Editor
This web app allows you to create and edit .lpl playlist files for RetroArch.
This web app allows you to easily create and edit .lpl playlist files for RetroArch.

**Features:**
* drag and drop existing playlists and/or content
* sort scontent manually or automatically
* filters content
* massive replace content name
* massive edits content path and core
* renames unknown content automatically by opening a .rdb database, useful when creating playlists for MAME or FB Alpha (see below)
* compatible with old LPL (<1.7.5) and new JSON (>1.7.6) formats
* useful for editing playlists for handheld and console RetroArch versions
* sorts playlist content
* edits content path and core massively
* remove region and language tags massively
* internal databases can set correct content names for Arcade playlists (MAME or FB Neo)
* compatible with both LPL formats (JSON and Legacy)
* useful for arranging and editing playlists for handheld and console RetroArch versions
* made in vanilla JS, compatible with all current web browsers

### Usage
RetroArch Playlist Editor interface tries to be as minimalist as possible and it's mostly self-explanatory.

**Import content button:** allows you to browse your files and add content to the current playlist (or just drag and drop them in the window). Alternatively, this button can also be used to open an existing .lpl playlist.

**Selecting items:** multiple selection in the playlist can be done by holding Ctrl or Shift keys

**Edit content button:** lets you edit massively the selected items (set core, content path...)




### Rename content by .rdb database
RetroArch does not identify content names in some systems like MAME or FB Alpha when importing content. e.g.: ```mslug3.zip``` should be named **Metal Slug 3**.
RetroArch Playlist Editor can fix that for you.
1. Open your .lpl playlist file (e.g.: ```MAME.lpl```)
2. Drag and drop the needed .rdb database (e.g.: ```databases/MAME.rdb```)
3. Done!
All content will be identified by its filename and will be renamed correctly (and get the crc tag too). Database files are found in every RetroArch distribution.

**Edit content button:** lets you edit massively the selected items (rename, set core, content path...)
3 changes: 2 additions & 1 deletion _cache_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ caches.keys().then(function(cacheNames){
});

var PRECACHE_ID='retroarch-playlist-editor';
var PRECACHE_VERSION='beta2b';
var PRECACHE_VERSION='2beta1';
var PRECACHE_URLS=[
'/retroarch-playlist-editor/','/retroarch-playlist-editor/index.html',

Expand All @@ -47,6 +47,7 @@ var PRECACHE_URLS=[
'/retroarch-playlist-editor/app/assets/icon_select_none.svg',
'/retroarch-playlist-editor/app/assets/icon_select_mixed.svg',
'/retroarch-playlist-editor/app/assets/icon_select_all.svg',
'/retroarch-playlist-editor/app/assets/icon_alert.svg',
'/retroarch-playlist-editor/app/assets/icon_pencil.svg',
'/retroarch-playlist-editor/app/assets/icon_trash.svg'
];
Expand Down
1 change: 1 addition & 0 deletions app/assets/icon_alert.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 41 additions & 28 deletions app/retroarch-playlist-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function rebuildSelectContentPaths(playlist){
contentPaths=['c:\\roms\\', '/home/roms/'];

empty('path-suggestions');
for(var i=0; i<contentPaths.length && i<10; i++){
for(var i=0; i<contentPaths.length && i<20; i++){
var option=document.createElement('option');
option.innerHTML=contentPaths[i];
el('path-suggestions').appendChild(option);
Expand Down Expand Up @@ -629,31 +629,26 @@ var Settings=(function(){

load:function(){
if(typeof localStorage !== 'undefined'){
var item=localStorage.getItem(LOCALSTORAGE_ID);
if(item){
try{
try{
var item=localStorage.getItem(LOCALSTORAGE_ID);
if(item){
var parsedSettings=JSON.parse(item);

if(typeof parsedSettings.version==='number'){
if(parsedSettings.version<=1)
this.version=parsedSettings.version;
}

if(typeof parsedSettings.myCorePaths==='object' && typeof parsedSettings.myCorePaths.length==='number'){
for(var i=0; i<parsedSettings.myCorePaths.length; i++){
if(typeof parsedSettings.myCorePaths[i]==='string' && this.myCorePaths.indexOf(parsedSettings.myCorePaths[i])===-1)
this.myCorePaths.push(parsedSettings.myCorePaths[i]);
}
}

if(typeof parsedSettings.myCorePathIndex==='number' && parsedSettings.myCorePathIndex>0 && parsedSettings.myCorePathIndex<=this.myCorePaths.length){
if(typeof parsedSettings.myCorePathIndex==='number' && parsedSettings.myCorePathIndex>=0 && parsedSettings.myCorePathIndex<=this.myCorePaths.length){
this.myCorePathIndex=parsedSettings.myCorePathIndex;
}

return true;
}catch(err){
console.error('error while parsing JSON settings');
}
}catch(err){
console.error('error while parsing JSON settings');
}
}
return false;
Expand Down Expand Up @@ -783,7 +778,7 @@ function readFiles(playlist, droppedFiles){
if(contentPaths.length)
filePath=contentPaths[0];
else
filePath='/path/to/file/';
filePath='';

var newContent=[];
var mergingPlaylists=[];
Expand Down Expand Up @@ -1041,9 +1036,30 @@ function getPathSystem(path){
function checkIfWindowsSystem(path){
return getPathSystem(path)==='Windows'
}

function refreshCorePathMessage(playlist){
var corePath=el('select-core-path').value;

var invalidContentPath=false;
for(var i=0; i<playlist.content.length && !invalidContentPath; i++){
if(!playlist.content[i].path || playlist.content[i].path==='/' || playlist.content[i].path==='\\')
invalidContentPath=true;
}
if(invalidContentPath){
el('core-path-message').className='warning';
el('core-path-message').innerHTML='<img class="icon" src="app/assets/icon_alert.svg" /> Warning: one or more content has no defined content path.';
}else if(corePath){
el('core-path-message').className='';
el('core-path-message').innerHTML=getPathSystem(corePath);
}else if(Settings.myCorePaths.length){
el('core-path-message').className='warning';
el('core-path-message').innerHTML='<img class="icon" src="app/assets/icon_alert.svg" /> Warning: all content will be set to DETECT core.';
}else{
el('core-path-message').className='warning';
el('core-path-message').innerHTML='<img class="icon" src="app/assets/icon_alert.svg" /> Advice: import any of your existing playlists to detect your device core path.';
}
}
function setCorePath(corePath){
var save=false;
var saveSettings=false;
var oldCorePath=el('select-core-path').value;

/* new core path */
Expand All @@ -1057,7 +1073,7 @@ function setCorePath(corePath){

rebuildSelectCorePath();

save=true;
saveSettings=true;
}
if(corePath && oldCorePath!==corePath){
Settings.myCorePathIndex=Settings.myCorePaths.indexOf(corePath)+1;
Expand All @@ -1066,19 +1082,10 @@ function setCorePath(corePath){
el('select-core-path').value=corePath || '';


if(corePath){
el('core-path-message').className='';
el('core-path-message').innerHTML=getPathSystem(corePath);
}else if(Settings.myCorePaths.length){
el('core-path-message').className='warning';
el('core-path-message').innerHTML='Warning: all content will be set to DETECT core.';
}else{
el('core-path-message').className='warning';
el('core-path-message').innerHTML='Advice: import any of your existing playlists to detect your device core path.';
}
refreshCorePathMessage(currentPlaylist);

/* save settings */
if(save)
if(saveSettings)
Settings.save();
}

Expand All @@ -1096,6 +1103,7 @@ addEvent(window,'load',function(){

/* core path <select> */
rebuildSelectCorePath();
refreshCorePathMessage(currentPlaylist);

/* build database <select> */
rebuildSelects();
Expand All @@ -1115,6 +1123,7 @@ addEvent(window,'load',function(){
});
addEvent(el('button-toolbar-import'), 'click', openImportBrowser);
addEvent(el('button-toolbar-save'), 'click', function(evt){
refreshCorePathMessage(currentPlaylist);
UI.showBalloon('save');
el('input-playlist-name').value=currentPlaylist.name;
el('input-playlist-name').focus();
Expand Down Expand Up @@ -1162,6 +1171,10 @@ addEvent(window,'load',function(){
});
addEvent(el('select-core-path'), 'change', function(evt){
setCorePath(this.value);
if(this.value){
Settings.myCorePathIndex=Settings.myCorePaths.indexOf(this.valu)+1;
Settings.save();
}
});
addEvent(el('button-save'), 'click', function(evt){
currentPlaylist.export(el('checkbox-legacy').checked);
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="app-rows app-fill">
<div id="topbar">
<header>
<h1><img src="app/assets/favicon128.png" id="icon" /> RetroArch Playlist Editor <small class="hide-for-mobile">Beta 2.0</small></h1>
<h1><img src="app/assets/favicon128.png" id="icon" /> RetroArch Playlist Editor <small class="hide-for-mobile">2.0 beta1</small></h1>
<div id="topright">
<h2 class="hide-for-mobile">by <a href="/" tabindex="-1" class="author">Marc Robledo</a></h2>

Expand Down

0 comments on commit 3c0de71

Please sign in to comment.