diff --git a/src/app/api/api-client.service.ts b/src/app/api/api-client.service.ts index e932907..ebe446f 100644 --- a/src/app/api/api-client.service.ts +++ b/src/app/api/api-client.service.ts @@ -185,6 +185,13 @@ export class ApiClient { }); } + public SetLevelHashAsOverride(hash: string): void { + this.apiRequestCreator.makeRequest("POST", `levels/hash/${hash}/setAsOverride`) + .subscribe(_ => { + this.bannerService.pushSuccess("Check your game!", `In LBP, head to 'Lucky Dip' (or any category) and that level will show up!`); + }); + } + public UploadImageAsset(hash: string, data: ArrayBuffer): Observable { return this.apiRequestCreator.makeRequest("POST", `assets/${hash}`, data); } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 40b0d5f..637484f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -34,6 +34,7 @@ import {StatisticsComponent} from "./pages/statistics/statistics.component"; import {ContestsComponent} from "./pages/contests/contests.component"; import {ManageContestComponent} from "./pages/manage-contest/manage-contest.component"; import {ContestComponent} from "./pages/contest/contest.component"; +import {PlayHashComponent} from "./pages/play-hash/play-hash.component"; const routes: Routes = [ {path: "", component: MainComponent}, @@ -85,6 +86,8 @@ const routes: Routes = [ {path: "contests", component: ContestsComponent}, {path: "contests/:id", component: ContestComponent}, {path: "contests/:id/manage", component: ManageContestComponent}, + + {path: "playhash", component: PlayHashComponent, canActivate: [authenticationGuard]}, ]; if (isDevMode()) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0f58077..7422b30 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -105,6 +105,7 @@ import {MarkdownModule, MarkedOptions} from "ngx-markdown"; import {markedOptionsFactory} from "./markdown.config"; import {ContestPreviewComponent} from "./components/contest-preview/contest-preview.component"; import {ContestLabelComponent} from "./components/contest-label/contest-label.component"; +import { PlayHashComponent } from './pages/play-hash/play-hash.component'; @NgModule({ declarations: [ @@ -177,6 +178,7 @@ import {ContestLabelComponent} from "./components/contest-label/contest-label.co ContestBannerComponent, ContestPreviewComponent, ContestLabelComponent, + PlayHashComponent, ], imports: [ BrowserModule, diff --git a/src/app/markdown.config.ts b/src/app/markdown.config.ts index 397c112..7e9aca6 100644 --- a/src/app/markdown.config.ts +++ b/src/app/markdown.config.ts @@ -24,8 +24,8 @@ export function markedOptionsFactory(): MarkedOptions { return `${text}`; } - renderer.link = (href, title) => { - return `${title ?? href}`; + renderer.link = (href, title, text) => { + return `${text}`; } renderer.list = (body, ordered) => { @@ -38,7 +38,7 @@ export function markedOptionsFactory(): MarkedOptions { return { renderer: renderer, gfm: true, - breaks: true, + breaks: false, pedantic: false, }; } diff --git a/src/app/pages/play-hash/play-hash.component.html b/src/app/pages/play-hash/play-hash.component.html new file mode 100644 index 0000000..0e5892d --- /dev/null +++ b/src/app/pages/play-hash/play-hash.component.html @@ -0,0 +1,40 @@ +Play Level by Hash +
+

+ This page helps players wanting to play levels from the Dry Archive + If you want to play a level from the archive, first head to + LBPFind + to find a level you'd like to play. +

+
+

+ Once you've found a level, press Info to view the level's data. Copy the Hash. +

+

+ It should look something like this hash: 50a197bfe47187c37c36f59ea9c038b1938fa9be +

+
+

+ Next, paste that hash below. +

+
+ + + +
+

+ And then, play! +

+ +
+
+ +
+ +
+

+ + Note that this feature has no safety against accidents. + Don't put an invalid hash, or a hash for a future version of the game, otherwise you might crash. +

+
diff --git a/src/app/pages/play-hash/play-hash.component.ts b/src/app/pages/play-hash/play-hash.component.ts new file mode 100644 index 0000000..069fdc4 --- /dev/null +++ b/src/app/pages/play-hash/play-hash.component.ts @@ -0,0 +1,25 @@ +import { Component } from '@angular/core'; +import {faCertificate, faPlay, faTriangleExclamation} from "@fortawesome/free-solid-svg-icons"; +import {ApiClient} from "../../api/api-client.service"; + +@Component({ + selector: 'app-play-hash', + templateUrl: './play-hash.component.html' +}) +export class PlayHashComponent { + protected readonly faCertificate = faCertificate; + protected readonly faPlay = faPlay; + + levelHash: string = ""; + + constructor(private api: ApiClient) { + } + + setAsOverride() { + if(this.levelHash.length <= 0) return; + + this.api.SetLevelHashAsOverride(this.levelHash); + } + + protected readonly faTriangleExclamation = faTriangleExclamation; +}