Skip to content

Commit

Permalink
bugfix && config delete game files
Browse files Browse the repository at this point in the history
  • Loading branch information
hitman249 committed Feb 25, 2021
1 parent eb8d096 commit 74f3dc5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 18 deletions.
34 changes: 23 additions & 11 deletions src/src/components/Home/PopupRemoveConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
<span>&times;</span><span class="sr-only">{{ $t('labels.close') }}</span>
</button>
<h4 class="custom-modal-title">
{{ $t('game.delete') }}
{{ $t('labels.delete') }} "{{ config.name }}"?
</h4>
<div class="custom-modal-text text-left">
<form role="form">
<div class="form-group m-b-30 text-center">
<h4 class="m-t-20">
<b>
{{ $t('labels.delete') }} "{{ config.name }}"?
</b>
</h4>
</div>
<br>
<Form :fields="getFields()" :item.sync="item"
:styles="{left: 'col-sm-8', right: 'col-sm-2'}" ref="form"/>

<div class="form-group text-center m-t-40">
<button type="button" class="btn btn-default waves-effect waves-light" @click="save">
Expand All @@ -39,21 +35,27 @@

<script>
import action from '../../store/action';
import Form from "../UI/Form";
export default {
components: {},
components: {
Form,
},
name: "PopupRemoveConfig",
props: {
config: Object,
},
data() {
return {
id: action.id,
id: action.id,
item: {
'remove.files': false,
},
};
},
methods: {
remove() {
this.config.config.delete();
this.config.config.delete(this.item['remove.files']);
return this.reload();
},
open() {
Expand All @@ -76,6 +78,16 @@ export default {
reload() {
return this.$store.dispatch(action.get('games').RELOAD);
},
getFields() {
let fields = {};
return Object.assign(fields, {
'remove.files': {
name: this.$t('game.remove-files'),
type: 'bool',
required: false,
},
});
},
},
computed: {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default {
'icon-load': 'Add icons in games',
'icon-load-desc': 'You need to load icons in games to use this functionality',
'autostart': 'Autostart',
'delete': 'Deleting a game',
'remove-files': 'Delete game files',
},
pack: {
'unpack': 'Unpack',
Expand Down Expand Up @@ -275,7 +275,7 @@ This application interferes with the proper operation of
<code>AppImage</code> applications.
<br>
<br>
Remove AppImageLauncher!
Remove AppImageLauncher and reboot system!
`,
},
update: {
Expand Down
4 changes: 2 additions & 2 deletions src/src/locales/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default {
'icon-load': 'Добавьте в играх иконки',
'icon-load-desc': 'Необходимо загрузить в играх иконки для использования данного функционала',
'autostart': 'Автозапуск',
'delete': 'Удаление игры',
'remove-files': 'Удалить файлы игры',
},
pack: {
'unpack': 'Распаковать',
Expand Down Expand Up @@ -275,7 +275,7 @@ export default {
<code>AppImage</code> приложений.
<br>
<br>
Удалите AppImageLauncher!
Удалите AppImageLauncher и перезагрузитесь!
`,
},
update: {
Expand Down
30 changes: 29 additions & 1 deletion src/src/modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,25 @@ export default class Config {
return _.get(this.config, path, null);
}

/**
* @return {string|null}
*/
getGameDir() {
let path = this.getConfigValue('app.path');

if (!path) {
return null;
}

path = _.trim(path, '\\/').split('/')[0].split('\\')[0];

if (!path) {
return null;
}

return this.prefix.getGamesDir() + `/${path}`;
}

/**
* @return {boolean}
*/
Expand All @@ -524,9 +543,10 @@ export default class Config {
}

/**
* @param {boolean} andFiles
* @return {boolean}
*/
delete() {
delete(andFiles = false) {
if (!this.path || !this.fs.exists(this.path)) {
return false;
}
Expand All @@ -539,6 +559,14 @@ export default class Config {
this.fs.rm(dir);
}

if (true === andFiles) {
let gameDir = this.getGameDir();

if (gameDir && this.fs.exists(gameDir)) {
this.fs.rm(gameDir);
}
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/src/modules/prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default class Prefix {
[ lib, libWine, lib64, lib64Wine ].forEach((path) => {
if (this.fs.exists(path)) {
this.command.run(`objdump -T "${path}"/*.so* | grep GLIBC_`).split("\n").forEach((line) => {
let lineVersion = line.split('GLIBC_')[1].split(' ')[0];
let lineVersion = _.get(line.split('GLIBC_'), '[1]', '').split(' ')[0];

if (!value) {
value = lineVersion;
Expand Down
2 changes: 1 addition & 1 deletion src/src/modules/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs');

export default class Update {

version = '1.4.46';
version = '1.4.47';

/**
* @type {string}
Expand Down

0 comments on commit 74f3dc5

Please sign in to comment.