mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-08 19:15:09 +00:00
Difficulty info and source folder links
This commit is contained in:
18
src/electron/ipc/OpenURLHandler.ipc.ts
Normal file
18
src/electron/ipc/OpenURLHandler.ipc.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { IPCEmitHandler } from '../shared/IPCHandler'
|
||||
import { shell } from 'electron'
|
||||
|
||||
/**
|
||||
* Handles the 'open-url' event.
|
||||
*/
|
||||
class OpenURLHandler implements IPCEmitHandler<'open-url'> {
|
||||
event: 'open-url' = 'open-url'
|
||||
|
||||
/**
|
||||
* Opens `url` in the default browser.
|
||||
*/
|
||||
handler(url: string) {
|
||||
shell.openExternal(url)
|
||||
}
|
||||
}
|
||||
|
||||
export const openURLHandler = new OpenURLHandler()
|
||||
@@ -115,7 +115,7 @@ class APIFileDownloader {
|
||||
if (this.wasCanceled) { return }
|
||||
this.startDownloadStream()
|
||||
} else {
|
||||
console.log(err)
|
||||
console.log(JSON.stringify(err))
|
||||
this.failDownload(downloadErrors.responseError(err ? (err.code ?? 'unknown') : 'unknown'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getSettingsHandler, setSettingsHandler } from '../ipc/SettingsHandler.i
|
||||
import { googleLoginHandler, getAuthStatusHandler, googleLogoutHandler } from '../ipc/google/GoogleLoginHandler.ipc'
|
||||
import { UpdateProgress, getCurrentVersionHandler, downloadUpdateHandler, quitAndInstallHandler, getUpdateAvailableHandler } from '../ipc/UpdateHandler.ipc'
|
||||
import { UpdateInfo } from 'electron-updater'
|
||||
import { openURLHandler } from '../ipc/OpenURLHandler.ipc'
|
||||
|
||||
/**
|
||||
* To add a new IPC listener:
|
||||
@@ -95,7 +96,8 @@ export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[] {
|
||||
downloadHandler,
|
||||
setSettingsHandler,
|
||||
downloadUpdateHandler,
|
||||
quitAndInstallHandler
|
||||
quitAndInstallHandler,
|
||||
openURLHandler
|
||||
]
|
||||
}
|
||||
|
||||
@@ -114,6 +116,7 @@ export type IPCEmitEvents = {
|
||||
'update-downloaded': undefined
|
||||
'download-update': undefined
|
||||
'quit-and-install': undefined
|
||||
'open-url': string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,12 +83,28 @@ export interface ChartData {
|
||||
is120: boolean
|
||||
hasBrokenNotes: boolean
|
||||
noteCounts: {
|
||||
[instrument: string]: {
|
||||
[difficulty: string]: number
|
||||
[instrument in Instrument]: {
|
||||
[difficulty in ChartedDifficulty]: number
|
||||
}
|
||||
}
|
||||
/** number of seconds */
|
||||
length: number
|
||||
/** number of seconds */
|
||||
effectiveLength: number
|
||||
}
|
||||
|
||||
export type Instrument = 'guitar' | 'bass' | 'rhythm' | 'keys' | 'drums' | 'guitarghl' | 'bassghl' | 'vocals'
|
||||
export type ChartedDifficulty = 'x' | 'h' | 'm' | 'e'
|
||||
|
||||
export function getInstrumentIcon(instrument: Instrument) {
|
||||
switch(instrument) {
|
||||
case 'guitar': return 'guitar.png'
|
||||
case 'bass': return 'bass.png'
|
||||
case 'rhythm': return 'guitar.png' // TODO: get unique icon
|
||||
case 'keys': return 'keys.png'
|
||||
case 'drums': return 'drums.svg'
|
||||
case 'guitarghl': return 'guitarghl.png'
|
||||
case 'bassghl': return 'bassghl.png'
|
||||
case 'vocals': return 'guitar.png' // TODO: get unique icon
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user