Commit 2b1e0614 authored by ogomez92's avatar ogomez92

relocation completation

parent 3d1673dd
Pipeline #1 canceled with stages
......@@ -4,7 +4,7 @@ let changedLang=false;
export var version ="3.5.0";
export var version2 = '';
export var lang = 0;
module.exports.lang=lang;
export var ttsVoice;
export var ttsRate = 1;
const achs = [
......@@ -49,13 +49,11 @@ export var mangle = new Cryptr('sdf jkl wer uio');
import {KeyboardInput} from './input.js';
export var langs = ['', 'english', 'spanish'];
module.exports.langs=langs;
export var pack = 'default';
let packDirectory = os.homedir() + '/beatpacks/';
module.exports.packDirectory=packDirectory;
export var pack = 'default';
export let packDirectory = os.homedir() + '/beatpacks';
export var data = '';
module.exports.packdir=packdir;
export var packdir =packDirectory + pack + '/';
document.addEventListener('DOMContentLoaded', setup);
async function setup() {
......@@ -135,12 +133,14 @@ return;
data.save = {}; save();
}
const fs = require('fs');
if (!fs.existsSync(packDirectory+'/hashes.db')) {
var error = 0;
const path=require('path');
console.log(path.join(packDirectory,'hashes.db'))
if (!fs.existsSync(path.join(packDirectory,'hashes.db'))) {
var error = "";
if (lang == 1) {
error = new ScrollingText('The packs folder hashes need to be rebuilt to continue. This can take a few seconds...', '\n', (() => {
rebuildHashes();
}));
}));
}
if (lang == 2) {
error = new ScrollingText('Para continuar, debo reconstruir la carpeta de packs. Esto puede tardar unos segundos...', '\n', (() => {
......@@ -150,7 +150,7 @@ return;
return;
}
try {
var packs = JSON.parse(mangle.decrypt(fs.readFileSync(packDirectory+'hashes.db')));
var packs = JSON.parse(mangle.decrypt(fs.readFileSync(packDirectory+'/hashes.db')));
} catch (err) {
var error = 0;
if (lang == 1) {
......@@ -170,7 +170,7 @@ return;
let browsePosition = -1;
if (browsing > 0) {
packs.forEach((i, v) => {
if (fs.existsSync(packDirectory+i.name+'/bpm.txt')) {
if (fs.existsSync(packDirectory+'/'+i.name+'/bpm.txt')) {
if (browsing == 1) {
if (typeof data.unlocks[i.name] === 'undefined') {
browseArray.push(i);
......@@ -487,6 +487,18 @@ callback(answer);
export async function checkPack(changeBoot = true, debug = false) {
editing = false;
const fs = require('fs');
if (window.localStorage.getItem("path")!=null && !fs.existsSync(window.localStorage.getItem("path"))) {
await changeLang();
await new ScrollingText(strings.get("noFindFolder",[window.localStorage.getItem("path")]));
let dir=await changeDir();
if (typeof dir !== 'undefined' && dir != '') {
packDirectory=dir;
window.localStorage.setItem("path",packDirectory);
packdir =packDirectory +"/"+ pack + '/';
}//directory
}
if (window.localStorage.getItem("path")!=null && fs.existsSync(window.localStorage.getItem("path"))) {
console.log("path set to "+window.localStorage.getItem("path"));
packDirectory=window.localStorage.getItem("path");
......@@ -509,8 +521,8 @@ await changeLang();
if (window.localStorage.getItem("path")==null || !fs.existsSync(window.localStorage.getItem("path"))) {
const answer=await questionSync("directoryQuestion");
if (answer) {
packDirectory=os.homedir()+"/beatpacks/";
packdir =packDirectory + pack + '/';
packDirectory=os.homedir()+"/beatpacks";
packdir =packDirectory +'/'+ pack + '/';
window.localStorage.setItem("path",packDirectory);
}//answer
if (!answer) {
......@@ -1621,4 +1633,8 @@ counter++;
resolve();
});
});
}
\ No newline at end of file
}
module.exports.lang=lang;
module.exports.langs=langs;
module.exports.packDirectory=packDirectory;
module.exports.packdir=packdir;
\ No newline at end of file
......@@ -104,8 +104,7 @@ class Menu {
}
}
for (let i = 0; i < this.menuData.length; i++) {
console.log('ran second loop');
if (this.menuData[i].name.toLowerCase().substr(0, 1) == String.fromCharCode(char).toLowerCase()) {
if (this.menuData[i].name.toLowerCase().substr(0, 1) == String.fromCharCode(char).toLowerCase()) {
this.cursor = i;
this.menuData[this.cursor].speak();
this.first = false;
......
......@@ -20,6 +20,7 @@ import {KeyEvent} from './keycodes';
import {Menu} from './menu';
export async function mainMenu() {
console.log("menu thinks pack dir is "+main.packDirectory);
const fs = require('fs');
const items = new Array();
items.push(new MenuItem(0, strings.get('mStart')));
......
......@@ -1159,7 +1159,7 @@ for (let i = 0; i < 10; i++) {
otherOptions++;
}
}
so.directory = packDirectory+ this.songs[i].pack + '/';
so.directory = packDirectory+'/'+ this.songs[i].pack + '/';
const sndd = so.create(this.songs[i].level + 'music');
sndd.volume = 0.4;
sndd.loop = true;
......
......@@ -9,6 +9,7 @@ class Strings {
this.strings = {};
this.strings[1] = {
//New English
noFindFolder:"I can't find your packs folder in %1, you will now be prompted to choose where it is.",
mDir:"Packs folder change (currently %1)",
selectPath:"Please select the path where your packs are saved:",
directoryQuestion:"Wait a second... are you ok with your beatpacks folder being in your user folder? If not, you will be prompted to select a different directory to store your soundpacks. If you already have packs in your user folder and wish to change it, you will need to do that yourself as the game will not do it for you",
......@@ -304,6 +305,7 @@ You can upload your pack via the website by making a zip file of the pack's fold
};
this.strings[2] = {
//new Spanish
noFindFolder:"No puedo encontrar tu carpeta de packs en %1, por favor dime dónde está en el cuadro que se te mostrará ahora.",
mDir:"Cambiar carpeta de packs (ahora %1)",
selectPath:"Por favor dime la carpeta donde guardaremos los packs",
directoryQuestion:"Espera! Está bien que guarde los packs de sonido en la carpeta beatpacks de tu carpeta de usuario? Si no, te pediré que busques otra carpeta para guardar los packs. Si ya tienes packs guardados en la carpeta de usuario y quieres cambiar, deberás moverlos tú ya que el juego no lo hace por sí solo",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment