-
-
Notifications
You must be signed in to change notification settings - Fork 893
Add Lakes as a movable, toggleable layer #1383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74defa0
Initial plan
Copilot d29458b
Add lakes as movable, toggleable layer in map layers panel
Copilot 5374a18
Reposition Lakes after Heightmap in panel and add e2e tests
Copilot c8ff7ba
Remove toggleLakes from the landmass preset
Copilot ca62139
Move #lakes SVG group after #terrs so lakes render above heightmap by…
Copilot dcd976c
Add water mask to #lakes group so inner lake islands are visible
Copilot 7a4cf60
Move #lakes mask to index.css instead of JS attribute
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,10 @@ a { | |
| fill-rule: evenodd; | ||
| } | ||
|
|
||
| #lakes { | ||
| mask: url(#water); | ||
| } | ||
|
|
||
| #lakes, | ||
| #coastline, | ||
| #armies, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
|
|
||
| test.describe("Lakes layer", () => { | ||
| test.beforeEach(async ({ context, page }) => { | ||
| await context.clearCookies(); | ||
|
|
||
| await page.goto("/"); | ||
| await page.evaluate(() => { | ||
| localStorage.clear(); | ||
| sessionStorage.clear(); | ||
| }); | ||
|
|
||
| await page.goto("/?seed=test-seed&width=1280&height=720"); | ||
|
|
||
| // Wait for map generation to complete | ||
| await page.waitForFunction(() => (window as any).mapId !== undefined, { | ||
| timeout: 60000, | ||
| }); | ||
|
|
||
| // Wait for any post-generation rendering to settle | ||
| await page.waitForTimeout(500); | ||
| }); | ||
|
|
||
| test("lakes toggle button hides and shows the #lakes SVG group", async ({ | ||
| page, | ||
| }) => { | ||
| const lakes = page.locator("#lakes"); | ||
|
|
||
| // Open the options panel (layers tab) so the toggle button is reachable | ||
| await page.evaluate(() => (window as any).showOptions()); | ||
|
|
||
| // Lakes should be visible by default | ||
| await expect(lakes).toBeVisible(); | ||
|
|
||
| // Click the toggle button to hide; wait for jQuery fadeOut to complete | ||
| await page.locator("#toggleLakes").click(); | ||
| await expect(lakes).toBeHidden(); | ||
|
|
||
| // Click again to show; wait for jQuery fadeIn to complete | ||
| await page.locator("#toggleLakes").click(); | ||
| await expect(lakes).toBeVisible(); | ||
| }); | ||
|
|
||
| test("KeyQ toggles the lakes layer", async ({ page }) => { | ||
| const lakes = page.locator("#lakes"); | ||
|
|
||
| // Lakes should be visible by default | ||
| await expect(lakes).toBeVisible(); | ||
|
|
||
| // Press Q to hide lakes; wait for jQuery fadeOut to complete | ||
| await page.keyboard.press("q"); | ||
| await expect(lakes).toBeHidden(); | ||
|
|
||
| // Press Q again to show lakes; wait for jQuery fadeIn to complete | ||
| await page.keyboard.press("q"); | ||
| await expect(lakes).toBeVisible(); | ||
| }); | ||
|
|
||
| test("Lakes panel entry is positioned just after Heightmap", async ({ | ||
| page, | ||
| }) => { | ||
| const [lakesIndex, heightmapIndex] = await page.evaluate(() => { | ||
| const items = Array.from( | ||
| document.querySelectorAll("#mapLayers > li") | ||
| ) as HTMLElement[]; | ||
| return [ | ||
| items.findIndex((li) => li.id === "toggleLakes"), | ||
| items.findIndex((li) => li.id === "toggleHeight"), | ||
| ]; | ||
| }); | ||
|
|
||
| expect(lakesIndex).toBe(heightmapIndex + 1); | ||
| }); | ||
|
|
||
| test("dragging Lakes above Heightmap in panel moves #lakes before #terrs in SVG", async ({ | ||
| page, | ||
| }) => { | ||
| // Confirm initial SVG order: #lakes is after #terrs (rendered above heightmap by default) | ||
| const initialOrder = await page.evaluate(() => { | ||
| const viewbox = document.getElementById("viewbox")!; | ||
| const ids = Array.from(viewbox.children).map((el) => el.id); | ||
| return { lakes: ids.indexOf("lakes"), terrs: ids.indexOf("terrs") }; | ||
| }); | ||
| expect(initialOrder.lakes).toBeGreaterThanOrEqual(0); | ||
| expect(initialOrder.terrs).toBeGreaterThanOrEqual(0); | ||
| expect(initialOrder.lakes).toBeGreaterThan(initialOrder.terrs); | ||
|
|
||
| // Simulate what moveLayer does when the user drags Lakes above Heightmap: | ||
| // panel item "toggleLakes" is now before "toggleHeight" → el.insertBefore(#terrs) | ||
| await page.evaluate(() => { | ||
| const $ = (window as any).$; | ||
| $("#lakes").insertBefore($("#terrs")); | ||
| }); | ||
|
|
||
| // After move: #lakes should be before #terrs in SVG → renders behind heightmap | ||
| const newOrder = await page.evaluate(() => { | ||
| const viewbox = document.getElementById("viewbox")!; | ||
| const ids = Array.from(viewbox.children).map((el) => el.id); | ||
| return { lakes: ids.indexOf("lakes"), terrs: ids.indexOf("terrs") }; | ||
| }); | ||
| expect(newOrder.lakes).toBeLessThan(newOrder.terrs); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.