mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feature-107] open playlist details from download modal + use new proto format for maps details cache
This commit is contained in:
@@ -4,7 +4,7 @@ import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BSLaunchEventData, LaunchOption } from "shared/models/bs-launch";
|
||||
import { BsvMapDetail } from "shared/models/maps";
|
||||
import { BsmLocalMap, BsmLocalMapsProgress, DeleteMapsProgress } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { BsvPlaylist, PlaylistSearchParams, SearchParams } from "../maps/beat-saver.model";
|
||||
import { BsvPlaylist, BsvPlaylistPage, PlaylistSearchParams, SearchParams } from "../maps/beat-saver.model";
|
||||
import { ImportVersionOptions } from "main/services/bs-local-version.service";
|
||||
import { DownloadInfo, DownloadSteamInfo } from "main/services/bs-version-download/bs-steam-downloader.service";
|
||||
import { DepotDownloaderEvent } from "../bs-version-download/depot-downloader.model";
|
||||
@@ -42,6 +42,7 @@ export interface IpcChannelMapping {
|
||||
"bsv-get-map-details-from-hashs": {request: string[], response: BsvMapDetail[]};
|
||||
"bsv-get-map-details-by-id": {request: string, response: BsvMapDetail};
|
||||
"bsv-search-playlist": {request: PlaylistSearchParams, response: BsvPlaylist[]};
|
||||
"bsv-get-playlist-details-by-id": {request: {id: string, page: number}, response: BsvPlaylistPage};
|
||||
|
||||
/* ** bs-launcher-ipcs ** */
|
||||
"create-launch-shortcut": { request: LaunchOption, response: boolean };
|
||||
|
||||
@@ -3,15 +3,22 @@
|
||||
export interface RawSongDetailsCache {
|
||||
songs: RawSongDetails[];
|
||||
lastUpdated: number;
|
||||
uploaders: UploadersList;
|
||||
difficultyLabels: string[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface UploadersList {
|
||||
names: string[];
|
||||
ids: number[];
|
||||
}
|
||||
|
||||
// SongDetails Message
|
||||
export interface RawSongDetails {
|
||||
idInt: number;
|
||||
hash: string;
|
||||
duration: number;
|
||||
uploader: RawUploader;
|
||||
uploaderRef: UploaderRef;
|
||||
uploadedAt: number;
|
||||
tags: RawMapTag[];
|
||||
ranked: boolean;
|
||||
@@ -31,7 +38,7 @@ export interface RawSongDetails {
|
||||
export interface RawDifficulty {
|
||||
difficulty: RawDifficultyLabel;
|
||||
characteristic: RawDifficultyCharacteristic;
|
||||
label: string;
|
||||
labelIndex: number;
|
||||
starsT100: number;
|
||||
starsBlT100: number;
|
||||
njsT100: number;
|
||||
@@ -47,9 +54,8 @@ export interface RawDifficulty {
|
||||
}
|
||||
|
||||
// Uploader Message
|
||||
export interface RawUploader {
|
||||
name: string;
|
||||
id: number;
|
||||
export interface UploaderRef {
|
||||
uploaderRefIndex: number;
|
||||
verified: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import { MapStyle, MapTag, MapType } from "../beat-saver.model";
|
||||
import { RawDifficulty, RawDifficultyCharacteristic, RawDifficultyLabel, RawMapTag, RawSongDetails, RawUploader } from "./raw-song-details-cache.model";
|
||||
import { RawDifficulty, RawDifficultyCharacteristic, RawDifficultyLabel, RawMapTag, RawSongDetails, UploaderRef, UploadersList } from "./raw-song-details-cache.model";
|
||||
import { SongDetailDiffCharactertistic, SongDetails, SongDiffName, SongDifficulty, SongUploader } from "./song-details-cache.model";
|
||||
|
||||
export abstract class RawSongDetailsDeserializer {
|
||||
|
||||
public static uploaderList: UploadersList = { names: [], ids: [] };
|
||||
public static difficultyLabels: string[] = [];
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static setUploadersList(uploadersList: UploadersList): void {
|
||||
this.uploaderList = uploadersList;
|
||||
}
|
||||
|
||||
public static setDifficultyLabels(difficultyLabels: string[]): void {
|
||||
this.difficultyLabels = difficultyLabels;
|
||||
}
|
||||
|
||||
private static deserializeRawTag(rawTag: RawMapTag): MapTag {
|
||||
switch (rawTag) {
|
||||
case RawMapTag.DANCE: return MapStyle.Dance;
|
||||
@@ -88,7 +99,7 @@ export abstract class RawSongDetailsDeserializer {
|
||||
return {
|
||||
difficulty: this.deserializeRawDifficultyLabel(rawDifficulty.difficulty),
|
||||
characteristic: this.deserializeRawDifficultyCharacteristic(rawDifficulty.characteristic),
|
||||
label: rawDifficulty.label,
|
||||
label: RawSongDetailsDeserializer.difficultyLabels[rawDifficulty.labelIndex],
|
||||
stars: Math.round(rawDifficulty.starsT100) / 100,
|
||||
starsBL: Math.round(rawDifficulty.starsBlT100) / 100,
|
||||
njs: Math.round(rawDifficulty.njsT100) / 100,
|
||||
@@ -108,11 +119,12 @@ export abstract class RawSongDetailsDeserializer {
|
||||
return rawDifficulties.map(rawDifficulty => this.deserializeRawDifficulty(rawDifficulty));
|
||||
}
|
||||
|
||||
private static deserializeRawUploader(rawUploader: RawUploader): SongUploader {
|
||||
private static deserializeRawUploader(uploaderRef: UploaderRef): SongUploader {
|
||||
|
||||
return {
|
||||
name: rawUploader.name,
|
||||
id: rawUploader.id,
|
||||
verified: rawUploader.verified
|
||||
name: RawSongDetailsDeserializer.uploaderList.names[uploaderRef.uploaderRefIndex],
|
||||
id: RawSongDetailsDeserializer.uploaderList.ids[uploaderRef.uploaderRefIndex],
|
||||
verified: uploaderRef.verified
|
||||
};
|
||||
}
|
||||
|
||||
@@ -138,7 +150,7 @@ export abstract class RawSongDetailsDeserializer {
|
||||
id: this.deserializeMapId(rawSongDetails.idInt),
|
||||
hash: rawSongDetails.hash,
|
||||
duration: rawSongDetails.duration,
|
||||
uploader: this.deserializeRawUploader(rawSongDetails.uploader),
|
||||
uploader: this.deserializeRawUploader(rawSongDetails.uploaderRef),
|
||||
uploadedAt: rawSongDetails.uploadedAt,
|
||||
tags: this.deserializeRawTags(rawSongDetails.tags),
|
||||
ranked: rawSongDetails.ranked,
|
||||
|
||||
Reference in New Issue
Block a user