Skip to content

Commit

Permalink
v0.6.4e
Browse files Browse the repository at this point in the history
- Фикс бага с добавлением модов.
- Улучшение документации кода.
  • Loading branch information
VerZsuT committed Sep 21, 2021
1 parent 0f86aa8 commit 0204183
Show file tree
Hide file tree
Showing 18 changed files with 185 additions and 267 deletions.
8 changes: 6 additions & 2 deletions docs/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="h1 red-text">SnowRunner XML Editor Desktop</h1>
</header>

<div class="release">
<h2 class="title">v0.6.4d (новейший)</h2>
<h2 class="title">v0.6.4e (новейший)</h2>
<div class="description">
<ul>
<b>v0.6.4</b>
Expand Down Expand Up @@ -54,9 +54,13 @@ <h2 class="title">v0.6.4d (новейший)</h2>
<li>Фикс бага с пустым экраном если у авто не установлено смещение центра масс.</li>
<li>Горячие клавиши: сохранение (Ctrl + S), назад (Esc), выход (Ctrl + Q).</li>
</ul>
<b>v0.6.4e</b>
<ul>
<li>Фикс бага с добавлением модификаций.</li>
</ul>
</ul>
</div>
<button class="download btn btn-primary" version="v0.6.4d">Скачать</button>
<button class="download btn btn-primary" version="v0.6.4e">Скачать</button>
</div>

<div class="release">
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"snowrunner-xml-editor-desktop","productName":"SnowRunner XML Editor","version":"0.6.4d","description":"Allows you to visually edit the game's XML files.","repository":{"type":"git","url":"https://github.com/VerZsuT/SnowRunner-XML-Editor-Desktop.git"},"main":"src/app/index.js","scripts":{"start":"electron-forge start","build":"node preBuild.js && npm run package && node postBuild.js","package":"electron-forge package --platform=win32 --arch=ia32"},"keywords":[],"author":{"name":"VerZsuT","email":"verzsut@gmail.com"},"license":"MIT","config":{"forge":{"packagerConfig":{"ignore":["node_modules","docs","postBuild.js","preBuild.js",".gitignore"],"icon":"./src/icons/favicon.ico"}}},"devDependencies":{"@electron-forge/cli":"^6.0.0-beta.54","electron":"^12.0.2"},"dependencies":{}}
{"name":"snowrunner-xml-editor-desktop","productName":"SnowRunner XML Editor","version":"0.6.4e","description":"Allows you to visually edit the game's XML files.","repository":{"type":"git","url":"https://github.com/VerZsuT/SnowRunner-XML-Editor-Desktop.git"},"main":"src/app/index.js","scripts":{"start":"electron-forge start","build":"node preBuild.js && npm run package && node postBuild.js","package":"electron-forge package --platform=win32 --arch=ia32"},"keywords":[],"author":{"name":"VerZsuT","email":"verzsut@gmail.com"},"license":"MIT","config":{"forge":{"packagerConfig":{"ignore":["node_modules","docs","postBuild.js","preBuild.js",".gitignore"],"icon":"./src/icons/favicon.ico"}}},"devDependencies":{"@electron-forge/cli":"^6.0.0-beta.54","electron":"^12.0.2"},"dependencies":{}}
19 changes: 16 additions & 3 deletions src/app/Archiver.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
const {execSync, exec} = require('child_process');
const { paths } = require('./service');
const { paths } = require('./service.js');

/**
* Предоставляет методы для работы с архивами.
*/
class Archiver {
/**
* Обновляет файлы в архиве.
* @param {string} source - путь до папки с файлами.
* @param {string} direction - путь до архива.
*/
update(source, direction) {
execSync(`WinRAR f -ibck -inul "${direction}" "${source}\\" -r -ep1`, {cwd: paths.winrar});
}

unpack(source, direction) {
/**
* Распаковывает файлы в папку.
* @param {string} source - путь до ахрива.
* @param {string} direction - путь до папки.
*/
unpack(source, direction, fromMod=false) {
return new Promise(resolve => {
exec(`WinRAR x -ibck -inul "${source}" @unpack-list.lst "${direction}\\"`, {cwd: paths.winrar}).once('close', () => {
exec(`WinRAR x -ibck -inul "${source}" @${fromMod?'unpack-mod-list.lst':'unpack-list.lst'} "${direction}\\"`, {cwd: paths.winrar}).once('close', () => {
resolve();
});
});
Expand Down
1 change: 1 addition & 0 deletions src/app/Public.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {ipcMain} = require('electron');

const info = {}

// Данный метод вызывается из renderer-процесса для инициализации mainProcess.
ipcMain.on('getInfo', event => {
event.returnValue = info;
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.6.4d","lang":"EN","buildType":"dev","paths":{"initial":null,"dlc":null,"classes":null,"mods":null},"settings":{"updates":true,"limits":true,"DLC":true,"mods":true,"resetButton":false,"devMode":false},"sums":{"initial":null,"mods":{}},"modsList":{"length":0},"dlcList":[]}
{"version":"0.6.4e","lang":"EN","buildType":"dev","paths":{"initial":null,"dlc":null,"classes":null,"mods":null},"settings":{"updates":true,"limits":true,"DLC":true,"mods":true,"resetButton":false,"devMode":false},"sums":{"initial":null,"mods":{}},"modsList":{"length":0},"dlcList":[]}
157 changes: 51 additions & 106 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function initMain() {
openConsole: () => {openConsole()},

saveBackup: p => {saveBackup(p)},
copyBackup: () => {copyBackup()},
resetConfig: p => {resetConfig(p)},
restoreInitial: () => {restoreInitial()},
saveConfig: () => {saveConfig()},
Expand Down Expand Up @@ -764,7 +765,7 @@ function unpackMod(absolutePath) {
rmSync(modName, {recursive: true});
}
mkdirSync(modName);
archiver.unpack(absolutePath, modName).then(() => resolve());
archiver.unpack(absolutePath, modName, true).then(() => resolve());
});
}

Expand All @@ -784,7 +785,6 @@ function saveBackup(reloadAfter=false) {
}

copyBackup();
showNotification('[SUCCESS]', '[SUCCESS_BACKUP_SAVE]');
if (reloadAfter) {
reload();
}
Expand All @@ -796,6 +796,7 @@ function saveBackup(reloadAfter=false) {
function copyBackup() {
try {
copyFileSync(config.paths.initial, paths.backupInitial);
showNotification('[SUCCESS]', '[SUCCESS_BACKUP_SAVE]');
} catch {
throw new Error('[SAVE_INITIAL_BACKUP_ERROR]');
}
Expand Down Expand Up @@ -923,7 +924,7 @@ function clearTemp() {
}
}

function getText(key, returnKey = true) {
function getText(key, returnKey=true) {
const translation = translations[config.lang];
if (translation) {
return translation[removePars(key)] || (returnKey ? key : undefined);
Expand All @@ -941,122 +942,66 @@ function reload() {
app.quit();
}

function getShortMenu() {
return [
{
label: getText('[FILE_MENU_LABEL]'),
submenu: [
...(() => {
if (config.buildType === 'dev') {
return [
{
label: 'DevTools',
role: 'dev-tools'
},
{
label: 'Reload',
role: 'reload'
}
]
}
return []
})(),

{
label: getText('[EXIT_MENU_ITEM_LABEL]'),
role: 'quit-app'
}
]
},
{
label: getText('[HELP_MENU_LABEL]'),
submenu: [
{
label: getText('[HOW_TO_USE_TITLE]'),
role: 'open-link',
url: 'https://snowrunner.mod.io/guides/snowrunner-xml-editor'
},
{
label: 'GitHub',
role: 'open-link',
url: 'https://github.com/VerZsuT/SnowRunner-XML-Editor-Desktop'
},
{
label: 'YouTube(RU)',
role: 'open-link',
url: 'https://youtube.com/playlist?list=PLDwd4yUwzS2VtWCpC9X6MXm47Kv_s_mq2'
}
]
}
];
}

function getMainMenu() {
function retif(expression, valueToReturn) {
if (expression) return valueToReturn;
else return [];
}

return [
{
label: getText('[FILE_MENU_LABEL]'),
submenu: [
{
label: getText('[SETTINGS_MENU_ITEM_LABEL]'),
role: 'open-settings'
},
{
role: 'separator'
},

...(() => {
if (config.buildType === 'dev' || config.settings.resetButton) {
return [{
label: getText('[RESET_MENU_ITEM_LABEL]'),
role: 'reset-config'
}]
...retif(config.paths.initial, [
{
label: getText('[SETTINGS_MENU_ITEM_LABEL]'),
role: 'open-settings'
},
{ role: 'separator' }
]),
...retif((config.buildType === 'dev' || config.settings.resetButton) && config.paths.initial, [
{
label: getText('[RESET_MENU_ITEM_LABEL]'),
role: 'reset-config'
}
return []
})(),

...(() => {
if (config.buildType === 'dev') {
return [
{
label: 'DevTools',
role: 'dev-tools'
},
{
label: 'Reload',
role: 'reload'
}
]
]),
...retif(config.buildType === 'dev', [
{
label: 'DevTools',
role: 'dev-tools'
},
{
label: 'Reload',
role: 'reload'
}
return []
})(),

]),
{
label: getText('[EXIT_MENU_ITEM_LABEL]'),
role: 'quit-app'
}
]
},
{
label: getText('[BACKUP_MENU_LABEL]'),
submenu: [
{
label: getText('[OPEN_BUTTON]'),
role: 'show-folder',
path: paths.backupFolder
},
{
role: 'separator'
},
{
label: getText('[SAVE_BUTTON]'),
role: 'save-backup'
},
{
label: getText('[RESTORE_MENU_ITEM_LABEL]'),
role: 'restore-initial'
}
]
},
...retif(config.paths.initial, [
{
label: getText('[BACKUP_MENU_LABEL]'),
submenu: [
{
label: getText('[OPEN_BUTTON]'),
role: 'show-folder',
path: paths.backupFolder
},
{ role: 'separator' },
{
label: getText('[SAVE_BUTTON]'),
role: 'save-backup'
},
{
label: getText('[RESTORE_MENU_ITEM_LABEL]'),
role: 'restore-initial'
}
]
}
]),
{
label: getText('[HELP_MENU_LABEL]'),
submenu: [
Expand Down
Loading

0 comments on commit 0204183

Please sign in to comment.