mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 22:23:29 +00:00
7d3ec0fcb8
related to #2260 ## Description: * Moves the player info panel from the right to the top of the screen * Disable the header ad for now because it would cover up the player info, we'll find a better place for it in the future * Remove the collapsable button/functionality. It's hard to even click the button because the panel disappears when you move away from a player, and I think the info is too valuable to ever need to be collapsed. * Removed the "land" and "irradiated land" since it didn't add much value * Remove all alt text & translation, you can't hover over the player overlay so it's irrelevant. * put troop info inside the troop bar to reduce amount of text <img width="479" height="88" alt="Screenshot 2026-02-01 at 8 57 33 PM" src="https://github.com/user-attachments/assets/3b72eb16-2efa-4c00-a4d0-5e085548fa78" /> <img width="438" height="136" alt="Screenshot 2026-02-01 at 8 58 06 PM" src="https://github.com/user-attachments/assets/285bb2c9-6deb-4ee8-bcc8-743cccd6b77e" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
114 lines
2.6 KiB
TypeScript
114 lines
2.6 KiB
TypeScript
import { LitElement, html } from "lit";
|
|
import { customElement } from "lit/decorators.js";
|
|
import { GameView } from "../../../core/game/GameView";
|
|
import { Layer } from "./Layer";
|
|
|
|
const AD_SHOW_TICKS = 2 * 60 * 10; // 2 minutes
|
|
const HEADER_AD_TYPE = "standard_iab_head1";
|
|
const HEADER_AD_CONTAINER_ID = "header-ad-container";
|
|
const TWO_XL_BREAKPOINT = 1536;
|
|
|
|
@customElement("in-game-header-ad")
|
|
export class InGameHeaderAd extends LitElement implements Layer {
|
|
public game: GameView;
|
|
|
|
private isHidden: boolean = false;
|
|
private adLoaded: boolean = false;
|
|
private shouldShow: boolean = false;
|
|
|
|
createRenderRoot() {
|
|
return this;
|
|
}
|
|
|
|
init() {
|
|
// TODO: move ad and re-enable.
|
|
// this.showHeaderAd();
|
|
}
|
|
|
|
private showHeaderAd(): void {
|
|
// Don't show header ad on screens smaller than 2xl
|
|
if (window.innerWidth < TWO_XL_BREAKPOINT) {
|
|
return;
|
|
}
|
|
if (!window.adsEnabled) {
|
|
return;
|
|
}
|
|
|
|
this.shouldShow = true;
|
|
this.requestUpdate();
|
|
|
|
// Wait for the element to render before loading the ad
|
|
this.updateComplete.then(() => {
|
|
this.loadAd();
|
|
});
|
|
}
|
|
|
|
private loadAd(): void {
|
|
if (!window.ramp) {
|
|
console.warn("Playwire RAMP not available for header ad");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
window.ramp.que.push(() => {
|
|
try {
|
|
window.ramp.spaAddAds([
|
|
{
|
|
type: HEADER_AD_TYPE,
|
|
selectorId: HEADER_AD_CONTAINER_ID,
|
|
},
|
|
]);
|
|
this.adLoaded = true;
|
|
console.log("Header ad loaded:", HEADER_AD_TYPE);
|
|
} catch (e) {
|
|
console.error("Failed to add header ad:", e);
|
|
}
|
|
});
|
|
} catch (error) {
|
|
console.error("Failed to load header ad:", error);
|
|
}
|
|
}
|
|
|
|
private hideHeaderAd(): void {
|
|
this.shouldShow = false;
|
|
this.adLoaded = false;
|
|
this.requestUpdate();
|
|
}
|
|
|
|
public tick() {
|
|
if (this.isHidden) {
|
|
return;
|
|
}
|
|
|
|
const gameTicks =
|
|
this.game.ticks() - this.game.config().numSpawnPhaseTurns();
|
|
if (gameTicks > AD_SHOW_TICKS) {
|
|
console.log("destroying header ad and refreshing PageOS");
|
|
this.hideHeaderAd();
|
|
this.isHidden = true;
|
|
|
|
if (window.PageOS?.session?.newPageView) {
|
|
window.PageOS.session.newPageView();
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
shouldTransform(): boolean {
|
|
return false;
|
|
}
|
|
|
|
render() {
|
|
if (!this.shouldShow) {
|
|
return html``;
|
|
}
|
|
|
|
return html`
|
|
<div
|
|
id="${HEADER_AD_CONTAINER_ID}"
|
|
class="hidden 2xl:flex fixed top-0 left-1/2 -translate-x-1/2 z-[100] justify-center items-center pointer-events-auto p-0 -mt-[20px]"
|
|
></div>
|
|
`;
|
|
}
|
|
}
|