Skip to content

Commit e5b9e60

Browse files
committed
feat: bg img credits
1 parent b6ef7c6 commit e5b9e60

5 files changed

Lines changed: 22 additions & 19 deletions

File tree

17.7 KB
Loading
67.2 KB
Loading

layout/pages/main-menu/base-menu.xml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@
6363
</Button>
6464
</Panel>
6565

66-
<!-- Background author -->
67-
<Panel id="BgCredit" class="mainmenu__featured-bg MainMenuModeOnly NoCampaignSelectedOnly hide">
68-
<Panel class="flow-down vertical-align-center">
69-
<Label class="mainmenu__featured-bg__text" text="#MainMenu_Home_BackgroundCredit" />
70-
<Label id="BgName" class="mainmenu__featured-bg__name" text="[PH] Author" />
71-
</Panel>
72-
<AvatarImage id="BgAvatar" class="mainmenu__featured-bg__avatar" />
73-
</Panel>
74-
7566
<Panel class="ControllerOnly fancy-orange p-3 flow-down vertical-align-bottom m-3" style="max-width: 512px;">
7667
<Label class="text-l text-weight-bold horizontal-align-center" text="#MainMenu_ControllerUI_Note_Title" />
7768
<Label class="horizontal-align-center text-align-center" text="#MainMenu_ControllerUI_Note_Desc" />
@@ -96,6 +87,14 @@
9687
</Panel>
9788

9889
<Panel class="horizontal-align-right flow-down m-3">
90+
<!-- Background author -->
91+
<Panel id="BgCredit" class="mainmenu__featured-bg mb-1 MainMenuModeOnly NoCampaignSelectedOnly">
92+
<Panel class="flow-down vertical-align-center">
93+
<Label class="mainmenu__featured-bg__text" text="#MainMenu_Home_BackgroundCredit" />
94+
<Label id="BgName" class="mainmenu__featured-bg__name" text="[PH] Author" />
95+
</Panel>
96+
<Image id="BgAvatar" class="mainmenu__featured-bg__avatar" scaling="stretch-to-fit-preserve-aspect" />
97+
</Panel>
9998
<Panel class="horizontal-align-right flow-right">
10099
<TooltipPanel tooltip="#MainMenu_Socials_GitHub">
101100
<Button class="button button-2x" onactivate="SteamOverlayAPI.OpenURL('https://p2ce.org/issues')">

scripts/pages/main-menu/base-menu.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ class BaseMenu {
130130
static continueImg = $<Image>('#ContinueSaveThumb')!;
131131

132132
static bgMapLoad: uuid | undefined = undefined;
133+
static bgMapAuthorLabel = $<Label>('#BgName')!;
134+
static bgMapAuthorImg = $<Image>('#BgAvatar')!;
133135

134136
static mapSelection = 0;
135137
static maps = [
136-
'p2ce_background_chmb18_ovg',
137-
'p2ce_background_laser_intro',
138-
'p2ce_background_gentle_hum',
139-
'p2ce_background_mikatastrophe-dark'
138+
{ map: 'p2ce_background_chmb18_ovg', author: { name: 'Beckeroo', image: 'beckeroo.jpg' } },
139+
{ map: 'p2ce_background_gentle_hum', author: { name: 'Beckeroo', image: 'beckeroo.jpg' } },
140+
{ map: 'p2ce_background_laser_intro', author: { name: 'pivotman319', image: 'pivotman319.jpg' } },
141+
{ map: 'p2ce_background_mikatastrophe-dark', author: { name: 'mikatastrophe', image: 'mikatastrophe.png' } },
140142
];
141143
static music;
142144

@@ -284,10 +286,13 @@ class BaseMenu {
284286

285287
static rerollMap() {
286288
this.mapSelection = Math.floor(Math.random() * this.maps.length);
287-
$.Msg(`BASE MENU: Rolled background map: ${this.mapSelection}, ${this.maps[this.mapSelection]}`);
289+
const map = this.maps[this.mapSelection];
290+
$.Msg(`BASE MENU: Rolled background map: ${this.mapSelection}, ${map.map}`);
291+
this.bgMapAuthorLabel.text = map.author.name;
292+
this.bgMapAuthorImg.SetImage(`file://{images}/menu/featured/author_${map.author.image}`);
288293
$.DispatchEvent(
289294
'MainMenuSetBackgroundImage',
290-
`file://{images}/menu/featured/${this.maps[this.mapSelection]}.png`
295+
`file://{images}/menu/featured/${map.map}.png`
291296
);
292297
}
293298

@@ -332,7 +337,7 @@ class BaseMenu {
332337
this.bgMapLoad = GameInterfaceAPI.RegisterGameEventHandler(
333338
'map_load_failed',
334339
(mapName: string, isBackgroundMap: boolean) => {
335-
if (!isBackgroundMap || mapName !== `maps\\${this.maps[this.mapSelection]}.bsp`) return;
340+
if (!isBackgroundMap || mapName !== `maps\\${this.maps[this.mapSelection].map}.bsp`) return;
336341
$.Warning('!!!!! Could not load featured background map !!!!!');
337342
$.Schedule(0.001, () => {
338343
$.DispatchEvent('MainMenuSwitchReverse', false);
@@ -343,7 +348,7 @@ class BaseMenu {
343348
}
344349

345350
$.RegisterForUnhandledEvent('MapLoaded', (map: string, bg: boolean) => {
346-
if (bg && map === `maps\\${this.maps[this.mapSelection]}.bsp`) {
351+
if (bg && map === `maps\\${this.maps[this.mapSelection].map}.bsp`) {
347352
$.DispatchEvent('MainMenuHideBackgroundImage', false);
348353
$.DispatchEvent('MainMenuSwitchReverse', false);
349354
$.DispatchEvent('MainBackgroundLoaded');
@@ -356,7 +361,7 @@ class BaseMenu {
356361

357362
$.Schedule(0.1, () => {
358363
GameInterfaceAPI.ConsoleCommand('disconnect');
359-
GameInterfaceAPI.ConsoleCommand(`map_background "${this.maps[this.mapSelection]}"`);
364+
GameInterfaceAPI.ConsoleCommand(`map_background "${this.maps[this.mapSelection].map}"`);
360365
});
361366
}
362367

styles/pages/main-menu/main-menu.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ $pane-move-time: 0.1s;
569569
border: $menu-pane-border;
570570
padding: 10px 15px;
571571
horizontal-align: right;
572-
margin: 15px;
573572
flow-children: right;
574573

575574
&__text {

0 commit comments

Comments
 (0)