mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore] Add support for mapinfo v3 (which is essentially the same thing as version 2)
(cherry picked from commit 83f23c5c16)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { BsvMapCharacteristic, BsvMapDifficultyType } from "../beat-saver.model";
|
||||
import { RawMapInfoDataV2 } from "./raw-map-info-v2.model";
|
||||
import { RawMapInfoDataV3 } from "./raw-map-info-v3.model";
|
||||
import { RawMapInfoDataV4 } from "./raw-map-info-v4.model";
|
||||
|
||||
export type AnyRawMapInfo = RawMapInfoDataV2 | RawMapInfoDataV4;
|
||||
export type AnyRawMapInfo = RawMapInfoDataV2 | RawMapInfoDataV3 | RawMapInfoDataV4;
|
||||
|
||||
// interfaces/mapInfo.ts
|
||||
export interface MapInfo {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BsvMapCharacteristic, BsvMapDifficultyType } from "../beat-saver.model";
|
||||
|
||||
export interface RawMapInfoDataV2 {
|
||||
_version: string;
|
||||
_version: `2.${number}.${number}`;
|
||||
_songName: string;
|
||||
_songSubName: string;
|
||||
_songAuthorName: string;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { SongDetailDiffCharactertistic, SongDiffName } from "../song-details-cache/song-details-cache.model";
|
||||
|
||||
export interface RawMapInfoDataV3 {
|
||||
_version: `3.${number}.${number}`;
|
||||
_songName: string;
|
||||
_songSubName: string;
|
||||
_songAuthorName: string;
|
||||
_levelAuthorName: string;
|
||||
_beatsPerMinute: number;
|
||||
_songTimeOffset: number;
|
||||
_shuffle: number;
|
||||
_shufflePeriod: number;
|
||||
_previewStartTime: number;
|
||||
_previewDuration: number;
|
||||
_songFilename: string;
|
||||
_coverImageFilename: string;
|
||||
_environmentName: string;
|
||||
_environmentNames?: string[];
|
||||
_allDirectionsEnvironmentName: string;
|
||||
_difficultyBeatmapSets: RawDifficultySetV3[];
|
||||
}
|
||||
|
||||
interface RawDifficultySetV3 {
|
||||
_beatmapCharacteristicName: SongDetailDiffCharactertistic;
|
||||
_difficultyBeatmaps: RawMapDifficultyV3[];
|
||||
}
|
||||
|
||||
interface RawMapDifficultyV3 {
|
||||
_difficulty: SongDiffName;
|
||||
_difficultyRank: number;
|
||||
_beatmapFilename: string;
|
||||
_noteJumpMovementSpeed: number;
|
||||
_noteJumpStartBeatOffset: number;
|
||||
_beatmapColorSchemeIdx?: number;
|
||||
_environmentNameIdx?: number;
|
||||
_customData?: {
|
||||
_difficultyLabel?: string;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { BsvMapCharacteristic, BsvMapDifficultyType } from "../beat-saver.model"
|
||||
|
||||
// interfaces/version4.ts
|
||||
export interface RawMapInfoDataV4 {
|
||||
version: string;
|
||||
version: `4.${number}.${number}`;
|
||||
song: {
|
||||
title: string;
|
||||
subTitle: string;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { MapDifficulty, MapInfo, AnyRawMapInfo } from "shared/models/maps/info/map-info.model";
|
||||
import { RawMapInfoDataV2 } from "shared/models/maps/info/raw-map-info-v2.model";
|
||||
import { RawMapInfoDataV3 } from "shared/models/maps/info/raw-map-info-v3.model";
|
||||
import { RawMapInfoDataV4 } from "shared/models/maps/info/raw-map-info-v4.model";
|
||||
|
||||
function parseVersion2(data: RawMapInfoDataV2): MapInfo {
|
||||
@@ -34,6 +35,11 @@ function parseVersion2(data: RawMapInfoDataV2): MapInfo {
|
||||
};
|
||||
}
|
||||
|
||||
function parseVersion3(data: RawMapInfoDataV3): MapInfo {
|
||||
// It's the same treatment as the version 2
|
||||
return parseVersion2(data as unknown as RawMapInfoDataV2)
|
||||
}
|
||||
|
||||
function parseVersion4(data: RawMapInfoDataV4): MapInfo {
|
||||
return {
|
||||
version: data.version,
|
||||
@@ -64,7 +70,7 @@ function parseVersion4(data: RawMapInfoDataV4): MapInfo {
|
||||
}
|
||||
|
||||
export function parseMapInfoDat(info: AnyRawMapInfo): MapInfo | never {
|
||||
const version = (info as RawMapInfoDataV2)?._version || (info as RawMapInfoDataV4)?.version;
|
||||
const version = (info as RawMapInfoDataV2)?._version || (info as RawMapInfoDataV3)?._version || (info as RawMapInfoDataV4)?.version;
|
||||
|
||||
if(!version) {
|
||||
throw new Error('Cannot determine info.dat version');
|
||||
@@ -74,6 +80,10 @@ export function parseMapInfoDat(info: AnyRawMapInfo): MapInfo | never {
|
||||
return parseVersion2(info as RawMapInfoDataV2);
|
||||
}
|
||||
|
||||
if (version.startsWith('3.')) {
|
||||
return parseVersion3(info as RawMapInfoDataV3);
|
||||
}
|
||||
|
||||
if (version.startsWith('4.')) {
|
||||
return parseVersion4(info as RawMapInfoDataV4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user