Skip to content

Commit dd054c3

Browse files
Update clock.js
1 parent 8806fc6 commit dd054c3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

modules/clock.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ export class Clock {
3434
//throw "Lancer Clock Direrctory Error: No valid directories for base themes."; //Enabling this Breaks Things. Only enable when debugging or developing this area.
3535
};
3636

37-
this._themes = newDirs;
38-
this._themePaths = tempDirs;
37+
this._baseThemes = newDirs;
38+
this._baseThemePaths = tempDirs;
3939

4040
}).catch(err => {
4141
error(err)
42-
ui.notifications.error("The following error occurred when generating the clock themes: "+err)
42+
//ui.notifications.error("The following error occurred when generating the clock themes: "+err) //It now fails more elegantly.
4343
});
4444
let extraPath = game.settings.get("lancer-clocks","extraPaths")
4545
if (!(extraPath.endsWith("/"))) {
@@ -67,16 +67,22 @@ export class Clock {
6767
};
6868
this._extraThemePaths = newExtraPaths;
6969
this._extraThemes = newExtraDirs;
70+
this._themes = (this._baseThemes ?? []).concat(this._extraThemes)
71+
this._themePaths = (this._baseThemePaths ?? []).concat(this._extraThemePaths)
72+
if (this._themes?.length < 1) {
73+
throw("This user doesn't have access to modules/lancer-clocks/themes and there are no custom clocks installed. Please annoy your GM to add custom themes to "+extraPath+".")
74+
}
7075
}).catch(err => {
7176
error(err)
77+
ui.notifications.error(err)
7278
});
7379
const isSupportedSize = size && Clock.sizes.indexOf(parseInt(size)) >= 0;
7480
this._size = isSupportedSize ? parseInt(size) : Clock.sizes[0];
7581

7682
const p = (!progress || progress < 0) ? 0 : progress < this._size ? progress : this._size;
7783
this._progress = p || 0;
7884

79-
this._theme = theme || this._themes?.[0] || "lancer_wallflower_green";
85+
this._theme = theme || this._themes?.[0] || this._extraThemes?.[0] || "lancer_wallflower_green";
8086
//let testingThemes = FilePicker.browse("data", "modules/lancer-clocks/themes").then(data => {console.log(data)});
8187
//console.log(testingThemes);
8288
}

0 commit comments

Comments
 (0)