Commit 96b0c21e authored by Oriol Gómez's avatar Oriol Gómez

fixing fixing fixing

parent bbda9572
export var gameID = 'beat';
export var newPath="";
let changedLang=false;
export var version ="3.5.0";
export var version2 = '';
......@@ -48,8 +49,11 @@ import {KeyboardInput} from './input.js';
export var langs = ['', 'english', 'spanish'];
export var pack = 'default';
export var packDirectory = os.homedir() + '/beatpacks/';
let packDirectory = os.homedir() + '/beatpacks/';
module.exports.packDirectory=packDirectory;
export var data = '';
module.exports.packdir=packdir;
export var packdir =packDirectory + pack + '/';
document.addEventListener('DOMContentLoaded', setup);
async function setup() {
......@@ -481,7 +485,8 @@ 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"))) {
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");
try {
data = JSON.parse(mangle.decrypt(fs.readFileSync(packDirectory+'save.dat')));
......@@ -507,8 +512,8 @@ await changeLang();
window.localStorage.setItem("path",packDirectory);
}//answer
if (!answer) {
let dir=await changeDir();
if (typeof dir !== 'undefined' && path != '') {
let dir=await changeDir();
if (typeof dir !== 'undefined' && dir != '') {
packDirectory=dir;
window.localStorage.setItem("path",packDirectory);
packdir =packDirectory + pack + '/';
......@@ -568,6 +573,7 @@ counter++;
}
pack = data.pack;
lang = data.lang;
save();
if (typeof data.rate !== 'undefined') {
speech.rate = data.rate;
}
......@@ -584,7 +590,7 @@ counter++;
save();
if (!fs.existsSync(packdir + 'bpm.txt')) {
pack = 'default';
packdir = os.homedir() + '/beatpacks/' + pack + '/';
packdir = packDirectory+ pack + '/';
}
if (!fs.existsSync(packdir + 'bpm.txt')) {
const text = new ScrollingText(strings.get('packError'), '\n', (() => {
......@@ -927,12 +933,12 @@ require('async').eachOfLimit(toDownload, threads, (fileUrl, index, next) => {
}
export function save() {
const fs = require('fs');
if (!fs.existsSync(os.homedir() + '/beatpacks')) {
fs.mkdirSync(os.homedir() + '/beatpacks');
if (!fs.existsSync(packDirectory)) {
fs.mkdirSync(packDirectory);
}
let write = JSON.stringify(data);
write = mangle.encrypt(write);
fs.writeFileSync(os.homedir() + '/beatpacks/save.dat', write);
fs.writeFileSync(packDirectory+'save.dat', write);
}
export function listenPack() {
const fs = require('fs');
......
......@@ -7,7 +7,7 @@ import {so} from './soundObject.js';
import {MenuTypes, MenuItem} from './menuItem';
import {KeyEvent} from './keycodes';
import {KeyboardInput} from './input';
import {packDirectory} from './main';
class Menu {
constructor(name, menuData, music) {
this.menuData = menuData;
......
'use strict';
var main=require('./main');
const {dialog} = require('electron').remote;
const electron = require('electron');
......@@ -8,7 +9,7 @@ import {utils} from './utilities';
import {ScrollingText} from './scrollingText';
import {speech} from './tts';
import {so} from './soundObject';
import {checkPack,packDirectory,version, version2, save, data, browseAch, editPack, minituts, minigames, buySafeguards} from './main';
import {checkPack,version, version2, save, data, browseAch, editPack, minituts, minigames, buySafeguards} from './main';
import {langs, lang} from './main';
import {st} from './stateMachine';
import {strings} from './strings';
......@@ -49,7 +50,7 @@ items.push(new MenuItem(4, strings.get('mDownload')));
items.push(new MenuItem(6, strings.get('mUnlocked', [data.unlocks[pack].level])));
items.push(new MenuItem(10, strings.get('mGameTuts',)));
items.push(new MenuItem(1234, strings.get('mLang',)));
items.push(new MenuItem(69, strings.get('mDir',[packDirectory])));
items.push(new MenuItem(69, strings.get('mDir',[main.packDirectory])));
items.push(new MenuItem(3, strings.get('mHashes')));
so.directory = './sounds/';
const mainMenu = new Menu(strings.get('mainmenu'), items);
......@@ -98,12 +99,15 @@ if (fs.existsSync(packdir + 'select.ogg')) {
case 9: minigames(); break;
case 10: minituts(); break;
case 69:
let dir=await changeDir();
console.log(dir);
let dir=await changeDir();
console.log("dir"+dir);
if (typeof dir !== 'undefined' && dir != '') {
packDirectory=dir+"/";
packdir =packDirectory + pack + '/';
window.localStorage.setItem("path",packDirectory);
main.packDirectory=dir+"/";
main.packdir =main.packDirectory + pack + '/';
window.localStorage.setItem("path",main.packDirectory);
}
else {
console.log("fuck you error.");
}
checkPack();
break;
......@@ -173,12 +177,12 @@ counter++;
});
}
export async function changeDir() {
await new Promise((resolve,reject)=> {
return new Promise((resolve,reject)=> {
const stuff = dialog.showOpenDialog({
title: strings.get('selectPath'),
properties: ['openDirectory']
}, path => {
resolve(path);
}, path=> {
resolve(String(path));
});
});
}
\ No newline at end of file
......@@ -7,8 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "parcel watch ./client/js/main.js -d ./client --target=electron --no-hmr",
"build": "parcel build ./client/js/main.js -d ./client --target=electron",
"start-client": "electron ./client",
"start": "http-server ./client"
"start": "electron ./client"
},
"repository": {
"type": "git",
......
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