Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Path: @/e2e
- [p1-ui-fidelity.spec.ts](p1-ui-fidelity.spec.ts) requires the desktop canvas to use WebGL2, checks populated ride windows avoid status bar and pointer overlap, validates compact coaster controls, builds while paused, checks the 2× construction cap and ride preview, verifies saved desktop window placement, and exercises ownership UI. The ride-access Pixel 8 scenario checks the construction controls fit the mobile viewport and uses touch to build.
- [ride-breakdown-proof.spec.ts](ride-breakdown-proof.spec.ts) captures both a forced breakdown with a mechanic en route and a separate naturally rolled breakdown. The natural seeded scene in [support/breakdown-scene.ts](support/breakdown-scene.ts) advances until reliability has fallen and rolling downtime is nonzero; its Maintenance screenshot documents those live values.
- [scenario-selection.spec.ts](scenario-selection.spec.ts) checks scenario tabs and previews, plus persistence of completed-park status across reloads.
- [title-source-link.spec.ts](title-source-link.spec.ts) checks the title screen's "Source on GitHub" link on desktop and Pixel 8: it is inside the viewport, opens the repository in a new tab with `noopener noreferrer`, is reachable with Tab, does not overlap the menu buttons, and returns after Back from a sub-view.
- [title-footer-links.spec.ts](title-footer-links.spec.ts) checks the title screen's Nori, build-story, and GitHub footer links on desktop, Pixel 8 and iPhone SE (plus a scrolled landscape-phone touch-target check): each has the expected href, opens in a new tab with `noopener noreferrer`, has the new-tab hint in its accessible name, sits fully inside the viewport, and overlaps neither the other links nor the menu buttons. It also checks Tab reachability on desktop, a 44 px minimum height on phones, and that the links return after Back from a sub-view.
- [readme-screenshots.spec.ts](readme-screenshots.spec.ts) captures the README images in [docs/screenshots/readme](../docs/screenshots/readme) and runs only when `README_SHOT_DIR` is set (`README_SHOTS` limits it to named parks). [support/readme-parks.ts](support/readme-parks.ts) builds developed parks in Node with the real simulation and integration fixtures, serializes them, and the spec imports each through Import save file, lets it run briefly, then frames and captures each view with WebGL2. Regenerate with `README_SHOT_DIR=docs/screenshots/readme pnpm exec playwright test --config=playwright.e2e.config.ts e2e/readme-screenshots.spec.ts`.
- [footpath-tool.spec.ts](footpath-tool.spec.ts) drives the Footpaths window through the UI: a dragged run previews its tiles and cost and lays them on release, a refused run shows red tiles with the reason, right-click and long-press remove a footpath with a refund, piece mode builds and removes at the cursor, and the hint shows once. Shared helpers are in [footpath-helpers.ts](footpath-helpers.ts).
- [scenery-catalog.spec.ts](scenery-catalog.spec.ts) browses the grouped Scenery menu on desktop and Pixel 8, checks tooltips, places, refuses and shift-removes new decorations. [scenery-proof.spec.ts](scenery-proof.spec.ts) (`@art-review`, set `SCENERY_PROOF_DIR`) photographs every decoration at four rotations and facings, its ghost, the menu and a decorated park in both renderers.
Expand Down
111 changes: 111 additions & 0 deletions e2e/title-footer-links.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { devices, expect, test } from './support/test';
import type { Locator, Page } from '@playwright/test';
import { createTestContext } from './support/test-contexts';

const FOOTER_LINKS = [
{ name: /Built with Nori.*\(opens in a new tab\)/, href: 'https://noriagentic.com/' },
{
name: /Why and how we built OpenCoaster.*\(opens in a new tab\)/,
href: 'https://12gramsofcarbon.com/p/agentics-its-never-been-easier-to',
},
{
name: /Source on GitHub.*\(opens in a new tab\)/,
href: 'https://github.com/tilework-tech/opencoaster',
},
];

const MENU_BUTTONS = ['New game', 'Sandbox', 'Continue', 'Load game', 'Import save file'];

type Box = { x: number; y: number; width: number; height: number };

function overlaps(a: Box, b: Box): boolean {
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
}

async function boxOf(locator: Locator): Promise<Box> {
const box = await locator.boundingBox();
expect(box).not.toBeNull();
return box!;
}

async function expectFooterLinksBesideMenu(page: Page, minTargetHeight: number): Promise<void> {
await expect(page.getByRole('heading', { name: 'OpenCoaster' })).toBeVisible();
const linkBoxes: Box[] = [];
for (const { name, href } of FOOTER_LINKS) {
const link = page.getByRole('link', { name });
await expect(link).toBeVisible();
await expect(link).toHaveAttribute('href', href);
await expect(link).toHaveAttribute('target', '_blank');
const rel = (await link.getAttribute('rel')) ?? '';
expect(rel.split(/\s+/)).toEqual(expect.arrayContaining(['noopener', 'noreferrer']));
await expect(link).toBeInViewport({ ratio: 1 });
const box = await boxOf(link);
expect(box.height, `${name} touch target`).toBeGreaterThanOrEqual(minTargetHeight);
linkBoxes.push(box);
}
for (let i = 0; i < linkBoxes.length; i++) {
for (let j = i + 1; j < linkBoxes.length; j++) {
expect(overlaps(linkBoxes[i]!, linkBoxes[j]!), 'footer links overlap').toBe(false);
}
}
for (const name of MENU_BUTTONS) {
const buttonBox = await boxOf(page.getByRole('button', { name, exact: true }));
for (const linkBox of linkBoxes) {
expect(overlaps(linkBox, buttonBox), `a footer link overlaps ${name}`).toBe(false);
}
}
}

test('the title screen footer links to Nori, the build story and the source on desktop', async ({
page,
}) => {
await page.setViewportSize({ width: 1280, height: 800 });
await page.goto('/');
await expectFooterLinksBesideMenu(page, 0);

for (const { name } of FOOTER_LINKS) {
const link = page.getByRole('link', { name });
for (let i = 0; i < 16 && !(await link.evaluate((el) => el === document.activeElement)); i++) {
await page.keyboard.press('Tab');
}
await expect(link).toBeFocused();
}

await page.getByRole('button', { name: 'New game', exact: true }).click();
await page.getByRole('button', { name: 'Back', exact: true }).click();
await expectFooterLinksBesideMenu(page, 0);

await page.getByRole('button', { name: 'Load game', exact: true }).click();
await page.getByRole('button', { name: 'Back', exact: true }).click();
await expectFooterLinksBesideMenu(page, 0);
});

for (const device of ['Pixel 8', 'iPhone SE'] as const) {
test(`the title screen footer links fit beside the menu on ${device}`, async ({ browser }) => {
const { defaultBrowserType: _browserType, ...options } = devices[device];
void _browserType;
const context = await createTestContext(browser, options);
const page = await context.newPage();
await page.goto('/');
await expectFooterLinksBesideMenu(page, 44);
});
}

test('the title screen footer links keep phone-sized touch targets in landscape', async ({
browser,
}) => {
const { defaultBrowserType: _browserType, ...options } = devices['Pixel 7 landscape'];
void _browserType;
const context = await createTestContext(browser, options);
const page = await context.newPage();
await page.goto('/');
await expect(page.getByRole('heading', { name: 'OpenCoaster' })).toBeVisible();
for (const { name, href } of FOOTER_LINKS) {
const link = page.getByRole('link', { name });
await link.scrollIntoViewIfNeeded();
// The panel scrolls at fractional offsets, so allow sub-pixel clipping.
await expect(link).toBeInViewport({ ratio: 0.95 });
await expect(link).toHaveAttribute('href', href);
expect((await boxOf(link)).height, `${name} touch target`).toBeGreaterThanOrEqual(44);
}
});
58 changes: 0 additions & 58 deletions e2e/title-source-link.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/ui/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Path: @/src/ui
- Below 700 px width windows become stacked bottom sheets (only the front sheet is expanded; tapping a title collapses/expands), while toolbar actions move under a labeled Actions menu. The mobile menu includes separate clockwise and anticlockwise rotation buttons alongside pause, footpaths, rides, finance, staff, park, and save/load, with touch targets of at least 44 px. Pointer focus preserves a collapsed sheet so its title-bar controls, including close, remain tappable.
- Hosts the game shell: a title screen, an in-game menu (reached from Game options), and a one-time scenario outcome dialog.
- Title and scenario selection use the same bevelled window chrome as the in-game interface. Each category tab shows how many of its scenarios have been won (`Beginner Parks (1/4)`), won scenarios carry a Completed badge in the list, and the preview states the completion date or `Not completed`; the title screen takes a progress callback so it stays independent of storage. New Game shows a map-specific top-down image on each scenario card and for the selected park, with objective/deadline, category difficulty and map dimensions alongside it. The images are generated from prepared scenario maps before development or production builds; the UI selects native or 2× assets using `srcset`. Scenario JSON defaults to Beginner Parks unless `category` is set.
- The title screen's main menu ends with an "Open source, MIT licensed" footer linking to the GitHub repository (`SOURCE_REPOSITORY_URL` in [title-screen.ts](title-screen.ts)) in a new tab, with a visually hidden "opens in a new tab" hint for screen readers. The menu is rebuilt on every return from New game or Load game, so the footer reappears there; the scenario and save sub-views do not show it. An empty title message element is hidden so it takes no space above the footer.
- The title screen's main menu ends with a footer of three right-aligned links: a Nori call to action (`NORI_URL`), the article on why and how agents on Nori built OpenCoaster (`BUILD_STORY_URL`), and the "Open source, MIT licensed" GitHub repository link (`SOURCE_REPOSITORY_URL`), all in [title-screen.ts](title-screen.ts). One helper opens each in a new tab with `noopener noreferrer` and a visually hidden "opens in a new tab" hint. Below 700 px width or on coarse pointers (touch, including landscape phones) each link has a 44 px minimum touch target ([ui.css](ui.css)). The menu is rebuilt on every return from New game or Load game, so the footer reappears there; the scenario and save sub-views do not show it. An empty title message element is hidden so it takes no space above the footer. Footer copy deliberately avoids naming RollerCoaster Tycoon, per the clean-room rule in [CONTRIBUTING.md](../../CONTRIBUTING.md).

### How it fits into the larger codebase

Expand Down
33 changes: 27 additions & 6 deletions src/ui/title-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { formatMoney } from './format';
import { slotRow } from './slot-list';

export const SOURCE_REPOSITORY_URL = 'https://github.com/tilework-tech/opencoaster';
export const NORI_URL = 'https://noriagentic.com/';
export const BUILD_STORY_URL = 'https://12gramsofcarbon.com/p/agentics-its-never-been-easier-to';

const SCENARIO_CATEGORIES: ReadonlyArray<{ id: ScenarioCategory; label: string }> = [
{ id: 'beginner', label: 'Beginner Parks' },
Expand Down Expand Up @@ -340,15 +342,34 @@ export function scenarioRulesText(def: ScenarioDef): string {
return lines.length === 0 ? 'Park rules: no restrictions.' : `Park rules: ${lines.join(' ')}`;
}

function sourceFooter(): HTMLElement {
const link = element('a', 'title-source-link', 'Source on GitHub');
link.href = SOURCE_REPOSITORY_URL;
function newTabLink(text: string, href: string, className: string): HTMLAnchorElement {
const link = element('a', `title-footer-link ${className}`, text);
link.href = href;
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.append(element('span', 'title-source-hint', ' (opens in a new tab)'));
link.append(element('span', 'title-footer-hint', ' (opens in a new tab)'));
return link;
}

function sourceFooter(): HTMLElement {
const promo = element('p', 'title-footer-row');
promo.append(
newTabLink(
'Built with Nori. Use it to build your own coaster game.',
NORI_URL,
'title-nori-link',
),
);
const story = element('p', 'title-footer-row');
story.append(newTabLink('Why and how we built OpenCoaster', BUILD_STORY_URL, 'title-story-link'));
const separator = element('span', undefined, ' · ');
separator.setAttribute('aria-hidden', 'true');
const footer = element('p', 'title-footer', 'Open source, MIT licensed');
footer.append(separator, link);
const license = element('p', 'title-footer-row', 'Open source, MIT licensed');
license.append(
separator,
newTabLink('Source on GitHub', SOURCE_REPOSITORY_URL, 'title-source-link'),
);
const footer = element('div', 'title-footer');
footer.append(promo, story, license);
return footer;
}
24 changes: 15 additions & 9 deletions src/ui/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -1219,44 +1219,50 @@
}
#app .title-footer {
margin: 10px -10px -10px;
padding: 6px 10px;
padding: 4px 10px;
border-top: 1px solid var(--bevel-dark);
background: #bdb9a7;
color: #403c32;
font-size: 12px;
line-height: 1.35;
text-align: right;
}
#app .title-source-link {
#app .title-footer-row {
margin: 0;
}
#app .title-footer-link {
display: inline-block;
padding: 6px 4px;
padding: 4px;
color: #23466e;
font-weight: 600;
text-decoration: underline;
}
@media (max-width: 699px) {
@media (max-width: 699px), (pointer: coarse) {
#app .title-footer {
padding: 0 10px;
}
#app .title-footer-row {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
column-gap: 0.3em;
padding: 0 10px;
}
#app .title-source-link {
#app .title-footer-link {
display: inline-flex;
align-items: center;
min-height: 44px;
padding: 0 4px;
}
}
#app .title-source-link:hover {
#app .title-footer-link:hover {
color: #13304f;
}
#app .title-source-link:focus-visible {
#app .title-footer-link:focus-visible {
outline: 2px solid #23466e;
outline-offset: 1px;
}
#app .title-source-hint {
#app .title-footer-hint {
position: absolute;
width: 1px;
height: 1px;
Expand Down
Loading