Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 273dfc5

Browse files
committed
autostart
1 parent 5ceaf10 commit 273dfc5

9 files changed

Lines changed: 72 additions & 16 deletions

File tree

src/src/components/Home/PopupIconCreate.vue

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<template v-if="popup_opened">
1818
<form role="form">
1919
<Form :fields="getFields()" :item.sync="item"
20-
:styles="{left: 'col-sm-8', right: 'col-sm-3'}" ref="form"/>
20+
:styles="{left: 'col-sm-7', right: 'col-sm-4'}" ref="form"/>
2121

2222
<div class="form-group text-center m-t-40">
2323
<button type="button" class="btn btn-default waves-effect waves-light" @click="save">
@@ -54,13 +54,20 @@
5454
return {
5555
id: action.id,
5656
games: this.$store.state.games,
57-
item: {},
57+
item: {
58+
menu: false,
59+
desktop: false,
60+
autostart: false,
61+
mode: 'standard',
62+
},
5863
};
5964
},
6065
methods: {
6166
open() {
62-
this.item.menu = false;
63-
this.item.desktop = true;
67+
this.item.menu = false;
68+
this.item.desktop = true;
69+
this.item.autostart = false;
70+
this.item.mode = 'standard';
6471
6572
new Custombox.modal({
6673
content: {
@@ -89,18 +96,29 @@
8996
let fields = {};
9097
9198
return Object.assign(fields, {
92-
'menu': {
99+
'menu': {
93100
name: this.$t('game.add-menu'),
94101
type: 'bool',
95102
required: false,
96103
validators: 'or:desktop',
97104
},
98-
'desktop': {
105+
'desktop': {
99106
name: this.$t('game.add-desktop'),
100107
type: 'bool',
101108
required: false,
102109
validators: 'or:menu',
103110
},
111+
'autostart': {
112+
name: this.$t('game.autostart'),
113+
type: 'bool',
114+
required: false,
115+
},
116+
'mode': {
117+
name: this.$t('game.launch-mode'),
118+
type: 'modes',
119+
required: true,
120+
relations: 'require:autostart',
121+
},
104122
});
105123
},
106124
},
@@ -113,7 +131,7 @@
113131
}
114132
115133
.modal-demo {
116-
width: 400px;
134+
width: 500px;
117135
}
118136
119137
.custom-modal-text {

src/src/components/Home/PopupPlay.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@
8080
mode: 'standard',
8181
};
8282
},
83+
mounted() {
84+
if (!window['autostart']) {
85+
window['autostart'] = {};
86+
}
87+
88+
if (window['autostart'][this.config.code]) {
89+
return;
90+
}
91+
92+
let args = window.app.getCommand().getArguments();
93+
let game = (args['game'] || []);
94+
let autostart = args['autostart'];
95+
96+
if (autostart && !Object.keys(Collects.modes).includes(autostart)) {
97+
autostart = 'standard';
98+
}
99+
100+
if (game.length > 0 && autostart && this.config.code === game[0]) {
101+
window['autostart'][this.config.code] = true;
102+
this.mode = autostart;
103+
this.open();
104+
this.save();
105+
}
106+
},
83107
methods: {
84108
open() {
85109
if (this.config.launched) {

src/src/components/Patches/PopupCommand.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<div class="form-group text-center m-t-40">
2323
<button type="button" class="btn btn-default waves-effect waves-light" @click="save">
24-
{{ $t('labels.save') }}
24+
{{ $t('labels.execute') }}
2525
</button>
2626
<button type="button" class="btn btn-danger waves-effect waves-light m-l-10"
2727
@click="cancel">

src/src/components/UI/FormItems.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<OnlySelect v-else-if="has(field, 'mangoHudPosition')" class="m-b-0"
5252
:selected.sync="item[key]"
5353
:items="getMangoHudPosition()"/>
54+
<OnlySelect v-else-if="has(field, 'modes')" class="m-b-0"
55+
:selected.sync="item[key]"
56+
:items="getModes()"/>
5457
<OnlySelect v-else-if="has(field, 'select')" class="m-b-0"
5558
:selected.sync="item[key]"
5659
:items="field.items"/>
@@ -187,6 +190,9 @@
187190
getMangoHudPosition() {
188191
return collects.getToSelect('mangoHudPosition');
189192
},
193+
getModes() {
194+
return collects.getToSelect('modes');
195+
},
190196
},
191197
computed: {
192198
leftClass() {

src/src/locales/en.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default {
2828
'loading': 'Loading...',
2929
'edit': 'Edit',
3030
'save': 'Save',
31+
'execute': 'Execute',
3132
'yes': 'Yes',
3233
'no': 'No',
3334
'cancel': 'Cancel',
@@ -88,6 +89,7 @@ export default {
8889
'add-desktop': 'Add to desktop',
8990
'icon-load': 'Add icons in games',
9091
'icon-load-desc': 'You need to load icons in games to use this functionality',
92+
'autostart': 'Autostart',
9193
},
9294
pack: {
9395
'unpack': 'Unpack',

src/src/locales/ru.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default {
2828
'loading': 'Загрузка...',
2929
'edit': 'Изменить',
3030
'save': 'Сохранить',
31+
'execute': 'Выполнить',
3132
'yes': 'Да',
3233
'no': 'Нет',
3334
'cancel': 'Отмена',
@@ -88,6 +89,7 @@ export default {
8889
'add-desktop': 'Добавить на "Рабочий стол"',
8990
'icon-load': 'Добавьте в играх иконки',
9091
'icon-load-desc': 'Необходимо загрузить в играх иконки для использования данного функционала',
92+
'autostart': 'Автозапуск',
9193
},
9294
pack: {
9395
'unpack': 'Распаковать',

src/src/modules/icon.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ export default class Icon {
9898

9999
/**
100100
* @param {string} png
101+
* @param {string|null} autostart
101102
* @return {string}
102103
*/
103-
getTemplate(png) {
104-
let binDir = this.prefix.getBinDir();
104+
getTemplate(png, autostart= null) {
105+
let binDir = this.prefix.getBinDir();
106+
let startBy = null === autostart ? '' : ` --autostart ${autostart}`;
105107

106108
return `[Desktop Entry]
107109
Version=1.0
108-
Exec="${binDir}/start" --game ${this.code}
110+
Exec="${binDir}/start" --game ${this.code}${startBy}
109111
Path=${binDir}
110112
Icon=${png}
111113
Name=${this.title}
@@ -180,17 +182,18 @@ Categories=Game`;
180182
/**
181183
* @param {boolean} menu
182184
* @param {boolean} desktop
185+
* @param {string|null} autostart
183186
* @return {boolean}
184187
*/
185-
create(menu = true, desktop = true) {
188+
create(menu = true, desktop = true, autostart = null) {
186189
let png = this.getIcon();
187190

188191
if (!png) {
189192
return false;
190193
}
191194

192195
let result = false;
193-
let template = this.getTemplate(png);
196+
let template = this.getTemplate(png, autostart);
194197
let appsDir = this.findApplicationsDir();
195198
let iconsDir = this.findIconsDir();
196199

src/src/modules/update.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import _ from "lodash";
2-
import Utils from "./utils";
32
import Prefix from "./prefix";
43
import FileSystem from "./file-system";
54
import Network from "./network";
@@ -9,7 +8,7 @@ const fs = require('fs');
98

109
export default class Update {
1110

12-
version = '1.4.18';
11+
version = '1.4.19';
1312

1413
/**
1514
* @type {string}

src/src/store/games.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export default {
129129
},
130130
[action.APPEND]({ commit, dispatch }, { config, item }) {
131131

132-
config.getIcon().create(item.menu, item.desktop);
132+
let startBy = item.autostart && item.mode ? item.mode : null;
133+
134+
config.getIcon().create(item.menu, item.desktop, startBy);
133135

134136
commit(action.CLEAR);
135137
return dispatch(action.LOAD);

0 commit comments

Comments
 (0)