From 647b0d451324aa0ddc777ba5aa18bfff43e972ec Mon Sep 17 00:00:00 2001 From: Richard Standow Date: Fri, 27 Feb 2026 09:55:28 +0000 Subject: [PATCH] feat: Restore grid search, auth, and CSP --- .docker/default.conf | 2 +- .gitignore | 52 ++++++- README.md | 148 +++++++++++++----- images/fantasy-icons/alchemist.svg | 1 + images/fantasy-icons/ambush.svg | 1 + images/fantasy-icons/beetle.svg | 1 + images/fantasy-icons/blacksmith.svg | 1 + images/fantasy-icons/boss.svg | 1 + images/fantasy-icons/bug.svg | 1 + images/fantasy-icons/camp.svg | 1 + images/fantasy-icons/castle.svg | 24 +++ images/fantasy-icons/city.svg | 1 + images/fantasy-icons/claw.svg | 1 + images/fantasy-icons/coffin.svg | 1 + images/fantasy-icons/crystal.svg | 1 + images/fantasy-icons/dragon.svg | 1 + images/fantasy-icons/fort.svg | 1 + images/fantasy-icons/gate.svg | 1 + images/fantasy-icons/godzilla.svg | 1 + images/fantasy-icons/gold_bar.svg | 1 + images/fantasy-icons/graveyard.svg | 1 + images/fantasy-icons/magic.svg | 1 + images/fantasy-icons/milestone_quest.svg | 1 + images/fantasy-icons/nest.svg | 1 + images/fantasy-icons/outpost.svg | 1 + images/fantasy-icons/quest.svg | 1 + images/fantasy-icons/ruined_city.svg | 1 + images/fantasy-icons/ruined_town.svg | 1 + images/fantasy-icons/ruined_village.svg | 1 + images/fantasy-icons/sacred-tree.svg | 16 ++ images/fantasy-icons/scorpion.svg | 1 + images/fantasy-icons/shop.svg | 1 + images/fantasy-icons/skeleton.svg | 1 + images/fantasy-icons/snake.svg | 1 + images/fantasy-icons/spider.svg | 1 + images/fantasy-icons/stable.svg | 1 + images/fantasy-icons/tavern.svg | 1 + images/fantasy-icons/town.svg | 1 + images/fantasy-icons/trap.svg | 1 + images/fantasy-icons/treasure.svg | 1 + images/fantasy-icons/undead.svg | 1 + images/fantasy-icons/village.svg | 1 + images/fantasy-icons/wagon.svg | 1 + images/fantasy-icons/wasp.svg | 1 + images/fantasy-icons/web.svg | 1 + images/fantasy-icons/wood.svg | 1 + images/fantasy-icons/wrecked_wagon.svg | 1 + images/fantasy-icons/zombie.svg | 1 + index.html | 15 ++ modules/custom_scripts/grid-search.js | 182 +++++++++++++++++++++++ modules/ui/general.js | 19 ++- 51 files changed, 449 insertions(+), 52 deletions(-) create mode 100644 images/fantasy-icons/alchemist.svg create mode 100644 images/fantasy-icons/ambush.svg create mode 100644 images/fantasy-icons/beetle.svg create mode 100644 images/fantasy-icons/blacksmith.svg create mode 100644 images/fantasy-icons/boss.svg create mode 100644 images/fantasy-icons/bug.svg create mode 100644 images/fantasy-icons/camp.svg create mode 100644 images/fantasy-icons/castle.svg create mode 100644 images/fantasy-icons/city.svg create mode 100644 images/fantasy-icons/claw.svg create mode 100644 images/fantasy-icons/coffin.svg create mode 100644 images/fantasy-icons/crystal.svg create mode 100644 images/fantasy-icons/dragon.svg create mode 100644 images/fantasy-icons/fort.svg create mode 100644 images/fantasy-icons/gate.svg create mode 100644 images/fantasy-icons/godzilla.svg create mode 100644 images/fantasy-icons/gold_bar.svg create mode 100644 images/fantasy-icons/graveyard.svg create mode 100644 images/fantasy-icons/magic.svg create mode 100644 images/fantasy-icons/milestone_quest.svg create mode 100644 images/fantasy-icons/nest.svg create mode 100644 images/fantasy-icons/outpost.svg create mode 100644 images/fantasy-icons/quest.svg create mode 100644 images/fantasy-icons/ruined_city.svg create mode 100644 images/fantasy-icons/ruined_town.svg create mode 100644 images/fantasy-icons/ruined_village.svg create mode 100644 images/fantasy-icons/sacred-tree.svg create mode 100644 images/fantasy-icons/scorpion.svg create mode 100644 images/fantasy-icons/shop.svg create mode 100644 images/fantasy-icons/skeleton.svg create mode 100644 images/fantasy-icons/snake.svg create mode 100644 images/fantasy-icons/spider.svg create mode 100644 images/fantasy-icons/stable.svg create mode 100644 images/fantasy-icons/tavern.svg create mode 100644 images/fantasy-icons/town.svg create mode 100644 images/fantasy-icons/trap.svg create mode 100644 images/fantasy-icons/treasure.svg create mode 100644 images/fantasy-icons/undead.svg create mode 100644 images/fantasy-icons/village.svg create mode 100644 images/fantasy-icons/wagon.svg create mode 100644 images/fantasy-icons/wasp.svg create mode 100644 images/fantasy-icons/web.svg create mode 100644 images/fantasy-icons/wood.svg create mode 100644 images/fantasy-icons/wrecked_wagon.svg create mode 100644 images/fantasy-icons/zombie.svg create mode 100644 modules/custom_scripts/grid-search.js diff --git a/.docker/default.conf b/.docker/default.conf index 9d3a7b22..df7688c2 100644 --- a/.docker/default.conf +++ b/.docker/default.conf @@ -6,7 +6,7 @@ server { location / { root /usr/share/nginx/html; index index.html; - add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; font-src data: 'self'"; + add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src data: 'self' https://fonts.gstatic.com https://fonts.googleapis.com; img-src 'self' data: blob: https:; connect-src 'self' https: blob:; worker-src 'self' blob:;"; add_header X-XSS-Protection "1; mode=block"; add_header X-Frame-Options "DENY"; add_header X-Content-Type-Options nosniff; diff --git a/.gitignore b/.gitignore index 2ea17d1d..329545f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,46 @@ -.vscode -.idea -/node_modules -/dist -/coverage -CONTRIBUTING-UPSTREAM.md +# IDE / editor config +.vscode/ +.idea/ + +# Node +/node_modules/ +/dist/ +/coverage/ + +# --- PNG source art for icons --- +# SVG icons are committed; PNGs are large AI-generated source files. +# They will be released separately if there is demand. +images/fantasy-icons/*.png + +# --- Local map saves --- +# Personal campaign maps β€” not for public distribution +MapSaves/ + +# --- POI / source data --- +POI_Source/ + +# --- Local custom scripts (root-level, not modules/custom_scripts) --- +custom_scripts/ + +# --- Python helper scripts (local tooling only) --- +diagnose_map.py +inspect_marker.py +list_markers.py +update_markers.py +update_markers_binary.py +scripts/ + +# --- Extra libs (bundled locally, not needed in repo) --- +libs/mapControls.min.js + +# --- Extra module files not yet merged upstream --- +modules/burgs-generator.js +modules/states-generator.js +modules/ui/burg-group-editor.js + +# --- Docker / server config (local deployment) --- +.docker/default.conf + +# --- Secrets --- +.env +.env.* diff --git a/README.md b/README.md index 726dc079..f11a1c8d 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,110 @@ -# Azgaar Fantasy Map Generator - D&D Grid Enhancement - -**Note on Tooling & Accessibility:** -I have mild dyslexia and use LLMs/Antigravity AI as technical prosthetics for writing and implementation. I architect the logic, design the structure, and define the best practices; the AI assists with the Java/JavaScript syntax and grammar formatting. If the documentation style seems overly structured, it is an intentional accessibility choice. I am always the one directing the logic and the "why" behind the code. - ---- - -## Project Overview -This is a personal fork of [Azgaar's Fantasy Map Generator](https://github.com/Azgaar/Fantasy-Map-Generator). - -As a long-time DM and SysAdmin/DevOps engineer, I needed a way to reference specific locations during tabletop sessions without manual tagging. This fork adds a **Grid Auto-Numbering** system designed for D&D campaign management and map indexing. - -## Features: Grid Auto-Numbering -This enhancement adds sequential coordinate numbering to grid cells (0001, 0002, 0003, etc.) starting from the top-left of the map. - -* **Dynamic Logic:** Numbers align automatically to Pointy Hex, Square, and Truncated Square grids. -* **Style Control:** Font size and color are fully adjustable via the Style panel to ensure readability against different map backgrounds. -* **Integration:** Toggle functionality is built directly into the existing "Grid" layer settings within the Style panel. -* **Documentation:** Technical implementation details and logic can be found in GRID-NUMBERING-README.md. - -## Local Setup -```bash -# Clone the repository -git clone [https://github.com/rstandow/Fantasy-Map-Generator](https://github.com/rstandow/Fantasy-Map-Generator) -cd Fantasy-Map-Generator - -# Launch -# This is a client-side application. Open index.html in any modern web browser. -``` - -## Contributing / Upstream -This feature was built to solve a specific table-top gaming need for my own D&D world. If there is interest from the main project or other contributors, I am happy to discuss contributing the grid logic back to the original repository. - -## Credits & License -* **Original Author:** Max Haniyeu (Azgaar) - [Original Repository](https://github.com/Azgaar/Fantasy-Map-Generator) -* **License:** MIT License -* **Fork Enhancements:** rstandow (2024) ( Will continue work on this Late Feb 2026 ) - +# Azgaar Fantasy Map Generator β€” Enhanced Fork + +This is a personal fork of [Azgaar's Fantasy Map Generator](https://github.com/Azgaar/Fantasy-Map-Generator) with custom enhancements for D&D campaign management. + +## Original Project + +**Original Repository**: [Azgaar/Fantasy-Map-Generator](https://github.com/Azgaar/Fantasy-Map-Generator) +**Original Author**: Max Haniyeu (Azgaar) +**License**: MIT License + +Full credit to Azgaar for creating this incredible fantasy map generation tool. Please visit and star the original repository! + +--- + +## Custom Enhancements in This Fork + +### ✨ Grid Auto-Numbering + +Added sequential numbering to grid cells for easy location referencing in tabletop RPG campaigns. + +**Features:** +- Sequential numbering (0001, 0002, 0003...) starting from top-left +- Customizable font size and color +- Toggle on/off in the Style panel +- Accurate alignment for pointy hex, flat hex, and square grid types + +**Usage:** +1. Enable the Grid layer (press `G`) +2. Open Style panel β†’ Select **Grid** +3. Check **Show grid numbers** +4. Adjust size and color as desired + +**Documentation:** See [`GRID-NUMBERING-README.md`](./GRID-NUMBERING-README.md) for full implementation details. + +--- + +### πŸ” Grid Search + +Search for map elements (Markers, Burgs, Units, Notes) by their grid cell number. + +**Features:** +- Search input in the **Tools β†’ Search** section +- Results dialog lists every element found inside the specified grid cell +- Click any result to pan the map to that element and open its editor +- Tooltips on Markers, Burgs, and Armies show the current grid number when grid numbering is active + +**Usage:** +1. Enable the Grid layer with numbering turned on +2. Open the **Tools** tab +3. Type a grid number (e.g. `1691`) in the **Search** field and click **Search Grid** +4. Click any result in the dialog to jump to it on the map + +--- + +### πŸ—ΊοΈ Custom Fantasy Icons + +A collection of D&D-themed SVG marker icons is included in `images/fantasy-icons/`. These can be used directly as custom markers in the map editor. + +**Available icons include:** alchemist, ambush, battlefield, blacksmith, boss, bridge, burial, camp, castle, cave, circus, city, coffin, crystal, dragon, dungeon, encounter, fair, forest, fort, gate, gold bar, graveyard, lighthouse, magic, milestone quest, monster, necropolis, nest, outpost, portal, quest, ruins, sacred tree, scorpion, ship, shop, skeleton, snake, spider, stable, tavern, town, trap, treasure, undead, village, wagon, wasp, web, wrecked wagon, zombie, and more. + +> **PNG source art:** AI-generated PNG versions of these icons (used as creative references) are not included in this repo to keep the size manageable. If there is demand, they will be uploaded in a separate `images/fantasy-icons-png/` directory. Open an issue to request them. + +--- + +## Running Locally + +```bash +# Clone this fork +git clone https://github.com/rstandow/Fantasy-Map-Generator +cd Fantasy-Map-Generator + +# Open in browser β€” no build step needed +# Simply open index.html in your web browser + +# Or run via the included Docker setup +docker compose up -d +``` + +--- + +## Contributing Back + +If you find any of these features useful, please consider: +- ⭐ Starring the [original Azgaar repository](https://github.com/Azgaar/Fantasy-Map-Generator) +- Opening a PR upstream if the feature might benefit the wider community + +--- + +## License + +This fork maintains the original MIT License. See [LICENSE](./LICENSE) for full details. + +**Copyright 2017–2024 Max Haniyeu (Azgaar)** +Fork enhancements Β© 2024–2025 + +--- + +## Acknowledgments + +- **Azgaar** β€” For creating and maintaining this fantastic map generator +- **Original Contributors** β€” Everyone who has contributed to the main project +- **D&D Community** β€” For inspiration and use cases + +--- + +> Azgaar's _Fantasy Map Generator_ is a free web application that helps fantasy writers, game masters, and cartographers create and edit fantasy maps. +> +> Link: [azgaar.github.io/Fantasy-Map-Generator](https://azgaar.github.io/Fantasy-Map-Generator) +> +> Refer to the [project wiki](https://github.com/Azgaar/Fantasy-Map-Generator/wiki) for guidance. Pull requests are highly welcomed! diff --git a/images/fantasy-icons/alchemist.svg b/images/fantasy-icons/alchemist.svg new file mode 100644 index 00000000..aedba8d4 --- /dev/null +++ b/images/fantasy-icons/alchemist.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/ambush.svg b/images/fantasy-icons/ambush.svg new file mode 100644 index 00000000..ee629032 --- /dev/null +++ b/images/fantasy-icons/ambush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/beetle.svg b/images/fantasy-icons/beetle.svg new file mode 100644 index 00000000..b1e22b32 --- /dev/null +++ b/images/fantasy-icons/beetle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/blacksmith.svg b/images/fantasy-icons/blacksmith.svg new file mode 100644 index 00000000..dcc382d3 --- /dev/null +++ b/images/fantasy-icons/blacksmith.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/boss.svg b/images/fantasy-icons/boss.svg new file mode 100644 index 00000000..43316bac --- /dev/null +++ b/images/fantasy-icons/boss.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/bug.svg b/images/fantasy-icons/bug.svg new file mode 100644 index 00000000..4f949f77 --- /dev/null +++ b/images/fantasy-icons/bug.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/camp.svg b/images/fantasy-icons/camp.svg new file mode 100644 index 00000000..ef5592e4 --- /dev/null +++ b/images/fantasy-icons/camp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/castle.svg b/images/fantasy-icons/castle.svg new file mode 100644 index 00000000..43a2fa38 --- /dev/null +++ b/images/fantasy-icons/castle.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/fantasy-icons/city.svg b/images/fantasy-icons/city.svg new file mode 100644 index 00000000..51e7e8b3 --- /dev/null +++ b/images/fantasy-icons/city.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/claw.svg b/images/fantasy-icons/claw.svg new file mode 100644 index 00000000..bb64cae6 --- /dev/null +++ b/images/fantasy-icons/claw.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/coffin.svg b/images/fantasy-icons/coffin.svg new file mode 100644 index 00000000..8ece9ad3 --- /dev/null +++ b/images/fantasy-icons/coffin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/crystal.svg b/images/fantasy-icons/crystal.svg new file mode 100644 index 00000000..451501da --- /dev/null +++ b/images/fantasy-icons/crystal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/dragon.svg b/images/fantasy-icons/dragon.svg new file mode 100644 index 00000000..413808ad --- /dev/null +++ b/images/fantasy-icons/dragon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/fort.svg b/images/fantasy-icons/fort.svg new file mode 100644 index 00000000..e64dac38 --- /dev/null +++ b/images/fantasy-icons/fort.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/gate.svg b/images/fantasy-icons/gate.svg new file mode 100644 index 00000000..7f189bcf --- /dev/null +++ b/images/fantasy-icons/gate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/godzilla.svg b/images/fantasy-icons/godzilla.svg new file mode 100644 index 00000000..e0bd1890 --- /dev/null +++ b/images/fantasy-icons/godzilla.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/gold_bar.svg b/images/fantasy-icons/gold_bar.svg new file mode 100644 index 00000000..a318a611 --- /dev/null +++ b/images/fantasy-icons/gold_bar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/graveyard.svg b/images/fantasy-icons/graveyard.svg new file mode 100644 index 00000000..290ed703 --- /dev/null +++ b/images/fantasy-icons/graveyard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/magic.svg b/images/fantasy-icons/magic.svg new file mode 100644 index 00000000..ecb595b0 --- /dev/null +++ b/images/fantasy-icons/magic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/milestone_quest.svg b/images/fantasy-icons/milestone_quest.svg new file mode 100644 index 00000000..c0235e70 --- /dev/null +++ b/images/fantasy-icons/milestone_quest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/nest.svg b/images/fantasy-icons/nest.svg new file mode 100644 index 00000000..193e6d27 --- /dev/null +++ b/images/fantasy-icons/nest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/outpost.svg b/images/fantasy-icons/outpost.svg new file mode 100644 index 00000000..93d246bb --- /dev/null +++ b/images/fantasy-icons/outpost.svg @@ -0,0 +1 @@ + diff --git a/images/fantasy-icons/quest.svg b/images/fantasy-icons/quest.svg new file mode 100644 index 00000000..fe39e6ce --- /dev/null +++ b/images/fantasy-icons/quest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/ruined_city.svg b/images/fantasy-icons/ruined_city.svg new file mode 100644 index 00000000..2edabf0c --- /dev/null +++ b/images/fantasy-icons/ruined_city.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/ruined_town.svg b/images/fantasy-icons/ruined_town.svg new file mode 100644 index 00000000..58173b34 --- /dev/null +++ b/images/fantasy-icons/ruined_town.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/ruined_village.svg b/images/fantasy-icons/ruined_village.svg new file mode 100644 index 00000000..48d3efff --- /dev/null +++ b/images/fantasy-icons/ruined_village.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/sacred-tree.svg b/images/fantasy-icons/sacred-tree.svg new file mode 100644 index 00000000..2abebe11 --- /dev/null +++ b/images/fantasy-icons/sacred-tree.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/images/fantasy-icons/scorpion.svg b/images/fantasy-icons/scorpion.svg new file mode 100644 index 00000000..564d62e9 --- /dev/null +++ b/images/fantasy-icons/scorpion.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/shop.svg b/images/fantasy-icons/shop.svg new file mode 100644 index 00000000..2bb91ac4 --- /dev/null +++ b/images/fantasy-icons/shop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/skeleton.svg b/images/fantasy-icons/skeleton.svg new file mode 100644 index 00000000..b771e0f0 --- /dev/null +++ b/images/fantasy-icons/skeleton.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/snake.svg b/images/fantasy-icons/snake.svg new file mode 100644 index 00000000..8804ac24 --- /dev/null +++ b/images/fantasy-icons/snake.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/spider.svg b/images/fantasy-icons/spider.svg new file mode 100644 index 00000000..0288463b --- /dev/null +++ b/images/fantasy-icons/spider.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/stable.svg b/images/fantasy-icons/stable.svg new file mode 100644 index 00000000..483dc50a --- /dev/null +++ b/images/fantasy-icons/stable.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/tavern.svg b/images/fantasy-icons/tavern.svg new file mode 100644 index 00000000..08d166db --- /dev/null +++ b/images/fantasy-icons/tavern.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/town.svg b/images/fantasy-icons/town.svg new file mode 100644 index 00000000..ad679c77 --- /dev/null +++ b/images/fantasy-icons/town.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/trap.svg b/images/fantasy-icons/trap.svg new file mode 100644 index 00000000..1b115fbf --- /dev/null +++ b/images/fantasy-icons/trap.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/treasure.svg b/images/fantasy-icons/treasure.svg new file mode 100644 index 00000000..206e5e95 --- /dev/null +++ b/images/fantasy-icons/treasure.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/undead.svg b/images/fantasy-icons/undead.svg new file mode 100644 index 00000000..41583311 --- /dev/null +++ b/images/fantasy-icons/undead.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/village.svg b/images/fantasy-icons/village.svg new file mode 100644 index 00000000..0d49daf7 --- /dev/null +++ b/images/fantasy-icons/village.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/wagon.svg b/images/fantasy-icons/wagon.svg new file mode 100644 index 00000000..afe20781 --- /dev/null +++ b/images/fantasy-icons/wagon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/wasp.svg b/images/fantasy-icons/wasp.svg new file mode 100644 index 00000000..29dc099b --- /dev/null +++ b/images/fantasy-icons/wasp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/web.svg b/images/fantasy-icons/web.svg new file mode 100644 index 00000000..baaa9a11 --- /dev/null +++ b/images/fantasy-icons/web.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/wood.svg b/images/fantasy-icons/wood.svg new file mode 100644 index 00000000..bfd656e8 --- /dev/null +++ b/images/fantasy-icons/wood.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/wrecked_wagon.svg b/images/fantasy-icons/wrecked_wagon.svg new file mode 100644 index 00000000..06b68cd6 --- /dev/null +++ b/images/fantasy-icons/wrecked_wagon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/fantasy-icons/zombie.svg b/images/fantasy-icons/zombie.svg new file mode 100644 index 00000000..9c4b0e8e --- /dev/null +++ b/images/fantasy-icons/zombie.svg @@ -0,0 +1 @@ + diff --git a/index.html b/index.html index 3944ae2a..4f6201c1 100644 --- a/index.html +++ b/index.html @@ -1786,6 +1786,15 @@ +
Search
+
+ + +
+
Regenerate
+ `; + }); + html += ``; + container.innerHTML = html; + + container.querySelectorAll('.grid-result-btn').forEach(btn => { + btn.addEventListener('click', function () { + const id = this.dataset.id; + const el = document.getElementById(id); + if (el) { + // check if we can open notes directly if requested, else trigger a standard click + const hasNote = notes.some(n => n.id === id); + + // Always pan to element! + const item = results.find(r => r.id === id); + if (item && item.x && item.y) { + const transform = d3.zoomIdentity.translate(svgWidth / 2 - item.x * scale, svgHeight / 2 - item.y * scale).scale(scale); + d3.select("svg").transition().duration(750).call(zoom.transform, transform); + } + + if (hasNote) { + editNotes(id, id); + } else { + const evt = new MouseEvent("click", { + bubbles: true, + cancelable: true, + view: window + }); + el.dispatchEvent(evt); + } + } else { + tip("Element not found on map", false, "error"); + } + }); + }); + } + + // Open Dialog + dialog.dialog({ + title: `Grid ${gridNum} Search`, + width: 300, + maxHeight: 400, + position: { my: "right top", at: "right-20 top+20", of: "svg", collision: "fit" } + }); +} + +// Initialize on load +setTimeout(initGridSearch, 2000); diff --git a/modules/ui/general.js b/modules/ui/general.js index 6e276bd6..133f45a2 100644 --- a/modules/ui/general.js +++ b/modules/ui/general.js @@ -121,7 +121,12 @@ function showMapTooltip(point, e, i, g) { const land = pack.cells.h[i] >= 20; // specific elements - if (group === "armies") return tip(e.target.parentNode.dataset.name + ". Click to edit"); + let gridSuffix = ""; + if (layerIsOn("toggleGrid") && gridOverlay.attr("data-show-numbers") === "1" && typeof getGridNumberFromMapCoords === 'function') { + gridSuffix = ` (Grid: ${getGridNumberFromMapCoords(point[0], point[1])})`; + } + + if (group === "armies") return tip(e.target.parentNode.dataset.name + gridSuffix + ". Click to edit"); if (group === "emblems" && e.target.tagName === "use") { const parent = e.target.parentNode; @@ -129,8 +134,8 @@ function showMapTooltip(point, e, i, g) { parent.id === "burgEmblems" ? [pack.burgs, "burg"] : parent.id === "provinceEmblems" - ? [pack.provinces, "province"] - : [pack.states, "state"]; + ? [pack.provinces, "province"] + : [pack.states, "state"]; const i = +e.target.dataset.i; if (event.shiftKey) highlightEmblemElement(type, g[i]); @@ -167,7 +172,7 @@ function showMapTooltip(point, e, i, g) { if (burgId) { const burg = pack.burgs[burgId]; const population = si(burg.population * populationRate * urbanization); - tip(`${burg.name}. Population: ${population}. Click to edit`); + tip(`${burg.name}. Population: ${population}${gridSuffix}. Click to edit`); if (burgsOverview?.offsetParent) highlightEditorLine(burgsOverview, burgId, 5000); return; } @@ -175,7 +180,7 @@ function showMapTooltip(point, e, i, g) { if (group === "labels") return tip("Click to edit the Label"); - if (group === "markers") return tip("Click to edit the Marker. Hold Shift to not close the assosiated note"); + if (group === "markers") return tip("Click to edit the Marker. Hold Shift to not close the assosiated note" + gridSuffix); if (group === "ruler") { const tag = e.target.tagName; @@ -394,7 +399,7 @@ function highlightEmblemElement(type, el) { const animation = d3.transition().duration(1000).ease(d3.easeSinIn); if (type === "burg") { - const {x, y} = el; + const { x, y } = el; debug .append("circle") .attr("cx", x) @@ -573,6 +578,6 @@ function showInfo() { $(this).dialog("close"); } }, - position: {my: "center", at: "center", of: "svg"} + position: { my: "center", at: "center", of: "svg" } }); }