Skip to content

Commit 41a441f

Browse files
author
Paul Roman
authored
Merge pull request #20 from paul-roman/dev
Ready for 0.4.1
2 parents 16382d2 + e616e6d commit 41a441f

35 files changed

Lines changed: 1702 additions & 411 deletions

assets/html/components/AddGameModalComponent.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ <h4 class="modal-title">{{ addGameLabel }}</h4>
7979
</div>
8080
<input name="cover" hidden>
8181
<input name="background" hidden>
82+
<input name="source" hidden>
8283
</form>
8384
</div>
8485
</div>

assets/html/components/AddGamesModalComponent.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="modal-content">
44
<div class="modal-header">
55
<button type="button" class="close" data-dismiss="modal">&times;</button>
6-
<h4 class="modal-title">Modal Header</h4>
6+
<h4 class="modal-title">{{ addGames }}</h4>
77
</div>
88
<div class="modal-body">
99
</div>

assets/html/main.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Vitrine</title>
6-
<link href="app.css" rel="stylesheet">
76
</head>
87
<body class="full-height" component="app"></body>
98
</html>

assets/sass/_bootstrapVariables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $headings-line-height: 1.1 !default;
4040
$headings-color: inherit !default;
4141

4242
// Iconography
43-
$icon-font-path: '../node_modules/bootstrap-sass/assets/fonts/bootstrap/' !default;
43+
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/' !default;
4444
$icon-font-name: 'glyphicons-halflings-regular' !default;
4545
$icon-font-svg-id: 'glyphicons_halflingsregular' !default;
4646

assets/sass/main.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/* Bootstrap */
22
@import 'bootstrapVariables';
3-
@import '../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap';
3+
@import '~bootstrap-sass/assets/stylesheets/bootstrap';
44

55
/* Font Awesome */
6-
$fa-font-path: '../node_modules/font-awesome/fonts';
7-
@import '../../node_modules/font-awesome/scss/font-awesome';
6+
$fa-font-path: '~font-awesome/fonts';
7+
@import '~font-awesome/scss/font-awesome';
88

99
/* Animate.css */
10-
@import '../../node_modules/animate.sass/scss/animate';
10+
@import '~animate.sass/scss/animate';
1111

1212
/* jQuery context menu */
13-
@import '../../node_modules/jquery-contextmenu/src/sass/jquery.contextMenu';
13+
$context-menu-icon-font-path: '~jquery-contextmenu/dist/font/';
14+
@import '~jquery-contextmenu/src/sass/jquery.contextMenu';
1415

1516
/* Vitrine */
1617
@import 'vitrine';
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
.potential-games-row {
22
padding: 15px 0 15px 50px;
33

4-
.potential-game {
5-
padding: 0 20px;
6-
font-size: 18px;
7-
8-
.potential-game-cover {
9-
width: 200px;
10-
height: 286px;
11-
background-size: cover;
12-
box-shadow: 0 0 15px rgba(0, 0, 0, 0.42);
13-
margin-bottom: 10px;
14-
}
4+
.potential-game-name {
5+
padding-left: 40px;
156
}
7+
168
}

assets/sass/vitrine/_taskBar.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
background-color: $body-bg;
33
width: 100%;
44
height: 40px;
5-
border-top: solid 1px #1F1E1E;
5+
border-top: solid 1px rgba(31, 30, 30, 0.63);
6+
border-bottom: solid 1px rgba(31, 30, 30, 0.63);
67
padding-left: 15px;
8+
box-shadow: 0 0 9px rgba(0, 0, 0, 0.55);
79

810
#update-bar {
911
width: 250px;

assets/ts/client/Language.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { getEnvFolder } from '../server/helpers';
66
class Language {
77
private dict: any;
88

9-
constructor(private lang: string) {
9+
public constructor(private lang: string) {
1010
let filePath: string = path.resolve(getEnvFolder('config'), 'lang', lang + '.json');
1111
this.dict = JSON.parse(fs.readFileSync(filePath).toString());
1212
}
1313

14-
public replaceHtml(key: string, arg?: any) {
14+
public replaceHtml(key: string, arg?: any): string {
1515
let keyArray: string[] = key.split(',');
1616
if (keyArray.length === 1)
1717
return this.dict[key];
@@ -23,7 +23,7 @@ class Language {
2323
return ret;
2424
}
2525

26-
public replaceJs(key: string, arg?: any) {
26+
public replaceJs(key: string, arg?: any): string {
2727
if (!arg)
2828
return this.dict[key];
2929
return this.dict[key].replace('%1', arg);

assets/ts/client/VitrineClient.ts

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ProgressInfo } from 'electron-updater/node_modules/electron-builder-htt
33
import * as dateFormat from 'dateformat';
44

55
import { GamesCollection } from '../models/GamesCollection';
6-
import { PotentialGame } from '../models/PotentialGame';
6+
import { GameSource, PotentialGame } from '../models/PotentialGame';
77
import { PlayableGame } from '../models/PlayableGame';
88
import { languageInstance } from './Language';
99
import { displayRemoveGameModal, formatTimePlayed, urlify } from './helpers';
@@ -12,13 +12,16 @@ export class VitrineClient {
1212
private potentialGames: GamesCollection<PotentialGame>;
1313
private playableGames: GamesCollection<PlayableGame>;
1414
private clickedGame: PlayableGame;
15+
private releaseUrl: string;
1516

16-
constructor() {
17+
public constructor() {
1718
this.potentialGames = new GamesCollection();
1819
this.playableGames = new GamesCollection();
19-
window.onerror = function(error, url, line) {
20+
this.releaseUrl = 'https://github.com/paul-roman/vitrine/releases/tag/v';
21+
22+
window.onerror = function(message: string, filename?: string, line?: number, col?: number, error?: Error) {
2023
let errorHtml: string = '<h4>' + languageInstance.replaceJs('error') + '</h4><hr>'
21-
+ '<pre>' + url + ':' + line + '</pre><p>' + error.replace('Uncaught Error: ', '') + '</p>';
24+
+ '<pre>' + filename + ':' + line + ':' + col + '</pre><p>' + message.replace('Uncaught Error: ', '') + '</p>';
2225
$('#error-message').clear().html(errorHtml);
2326
$('#error-modal').modal('show');
2427
}
@@ -58,9 +61,7 @@ export class VitrineClient {
5861
$('#update-app-disclaimer').html(languageInstance.replaceJs('updateText', version));
5962
$('#app-change-logs').html(changeLogsHtml).click((event) => {
6063
event.preventDefault();
61-
62-
let releaseUrl: string = 'https://github.com/paul-roman/vitrine/releases/tag/v' + version;
63-
shell.openExternal(releaseUrl);
64+
shell.openExternal(this.releaseUrl + version);
6465
});
6566
$('#update-app-btn').click(function() {
6667
$(this).loading();
@@ -70,9 +71,7 @@ export class VitrineClient {
7071
}
7172

7273
private serverError(event: Electron.Event, error: string) {
73-
if (error) {
74-
throw new Error(error);
75-
}
74+
throw new Error(error);
7675
}
7776

7877
private getIgdbGame(event: Electron.Event, error: string, game: any) {
@@ -82,7 +81,7 @@ export class VitrineClient {
8281
$('#submit-igdb-research-btn').html(languageInstance.replaceJs('submitNewGame'));
8382
$('#igdb-research-modal').modal('hide');
8483

85-
let formSelector = $('#add-game-form');
84+
let formSelector: JQuery = $('#add-game-form');
8685

8786
formSelector.find('input[name=name]').val(game.name);
8887
formSelector.find('input[name=series]').val(game.series);
@@ -112,6 +111,12 @@ export class VitrineClient {
112111
'background-image': urlify(game.cover)
113112
});
114113
formSelector.find('input[name=cover]').val(game.cover);
114+
if (!formSelector.find('input[name=source]').val())
115+
formSelector.find('input[name=source]').val(GameSource.LOCAL);
116+
if ($('#add-games-modal').is(':visible'))
117+
$('#add-games-modal').modal('hide');
118+
if (!$('#add-game-modal').is(':visible'))
119+
$('#add-game-modal').modal('show');
115120
}
116121

117122
private getIgdbSearches(event: Electron.Event, error: string, games: any) {
@@ -144,15 +149,15 @@ export class VitrineClient {
144149

145150
private addPotentialGames(event: Electron.Event, games: PotentialGame[]) {
146151
this.potentialGames.games = games;
147-
this.renderPotentialGames();
152+
this.renderPotentialGames(event);
148153
}
149154

150155
private removePotentialGame(event: Electron.Event, gameId: string) {
151156
this.potentialGames.removeGame(gameId, (error, game: PotentialGame) => {
152157
if (error)
153158
throw new Error(error);
154159
else if (game) {
155-
this.renderPotentialGames();
160+
this.renderPotentialGames(event);
156161
}
157162
});
158163
}
@@ -168,10 +173,8 @@ export class VitrineClient {
168173
}
169174

170175
private addPlayableGame(event: Electron.Event, playableGame: PlayableGame) {
171-
if (!playableGame.details.steamId) {
172-
$('#add-game-modal').modal('hide');
173-
$('#add-game-submit-btn').html(languageInstance.replaceJs('submitNewGame'));
174-
}
176+
$('#add-game-modal').modal('hide');
177+
$('#add-game-submit-btn').html(languageInstance.replaceJs('submitNewGame'));
175178
this.playableGames.addGame(playableGame);
176179
this.renderPlayableGames(() => {
177180
this.updateGameUi(playableGame);
@@ -202,31 +205,41 @@ export class VitrineClient {
202205
});
203206
}
204207

205-
private renderPotentialGames() {
208+
private renderPotentialGames(event: Electron.Event) {
206209
if (!this.potentialGames.games.length) {
207210
$('#potential-games-area').clear();
208211
return;
209212
}
210213
this.potentialGames.sort();
211214
let counter: number = 0;
212-
let gamesListHtml: string = '<div class="row potential-games-row">';
215+
let gamesList: JQuery = $('<div class="row potential-games-row"></div>');
213216
this.potentialGames.forEach((potentialGame: PotentialGame) => {
214-
gamesListHtml += '<div class="col-md-3 potential-game">'
215-
+ '<div class="potential-game-cover" style="background-image: url(' + potentialGame.details.cover + ')"></div>'
216-
+ potentialGame.name
217+
let gameHtml: string = '<div class="col-md-3">'
218+
+ '<div class="potential-game-cover"><div class="image" style="background-image: url(' + potentialGame.details.cover + ')"></div>'
219+
+ '<i class="fa fa-plus-circle icon animated"></i></div>'
220+
+ '<span class="potential-game-name">' + potentialGame.name + '</span>'
217221
+ '</div>';
222+
let game: JQuery = $(gameHtml);
223+
game.find('div.potential-game-cover').blurPicture(55, function() {
224+
$(this).find('.image').off().addClass('cover-hovered');
225+
$(this).find('.icon').off().removeClass('fa-plus-circle').addClass('fa-spinner fa-spin cover-hovered');
226+
event.sender.send('client.fill-igdb-game', potentialGame.details.id);
227+
let formSelector: JQuery = $('#add-game-form');
228+
let exePath: string = potentialGame.commandLine.shift();
229+
formSelector.find('input[name=executable]').val(exePath);
230+
formSelector.find('input[name=arguments]').val(potentialGame.commandLine.join(' '));
231+
formSelector.find('input[name=source]').val(potentialGame.source);
232+
$('#fill-with-igdb-btn').prop('disabled', false);
233+
$('#add-game-submit-btn').prop('disabled', false);
234+
});
235+
gamesList.append(game);
218236
counter++;
219-
if (counter % 4 === 0 || counter === this.potentialGames.games.length) {
220-
gamesListHtml += '</div>';
221-
if (counter === this.potentialGames.games.length) {
222-
$('#add-games-modal').find('.modal-body').clear().html(gamesListHtml);
223-
let buttonHtml: string = '<button id="add-potential-games-btn" class="btn btn-primary" data-toggle="modal" data-target="#add-games-modal">' +
224-
languageInstance.replaceJs('potentialGamesAdd', this.potentialGames.games.length) +
225-
'</button>';
226-
$('#potential-games-area').html(buttonHtml);
227-
}
228-
else
229-
gamesListHtml += '<div class="row potential-games-row">';
237+
if (counter === this.potentialGames.games.length) {
238+
$('#add-games-modal').find('.modal-body').clear().append(gamesList);
239+
let buttonHtml: string = '<button id="add-potential-games-btn" class="btn btn-primary" data-toggle="modal" data-target="#add-games-modal">' +
240+
languageInstance.replaceJs('potentialGamesAdd', this.potentialGames.games.length) +
241+
'</button>';
242+
$('#potential-games-area').html(buttonHtml);
230243
}
231244
});
232245
}
@@ -280,6 +293,7 @@ export class VitrineClient {
280293
$('#game-play').addClass('game-infos-visible').find('button').off('click').click(() => {
281294
ipcRenderer.send('client.launch-game', game.uuid);
282295
});
296+
$('#game-play').find('p').clear();
283297
if (game.timePlayed)
284298
$('#game-play').find('p').html(languageInstance.replaceJs('timePlayed') + ' ' + formatTimePlayed(game.timePlayed));
285299
$('#game-desc').addClass('game-infos-visible').html(game.details.summary);

assets/ts/client/bootstrap.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { languageInstance } from './Language';
22

3-
export function adaptComponent() {
3+
import * as css from '../../sass/main.scss';
4+
5+
export function adaptComponent(): string | void {
46
let htmlBody: string = $('body').html().replace(/{{(.*?)}}/g, (match, p1) => {
57
return languageInstance.replaceHtml(p1.trim());
68
});
79
$('body').html(htmlBody);
810
}
11+
12+
export function launchStyling() {
13+
$('<style/>', {
14+
id: 'static-styling',
15+
type: 'text/css',
16+
text: css.toString()
17+
}).appendTo('head');
18+
}

0 commit comments

Comments
 (0)