Skip to content
Open
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 .docker/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 46 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
.vscode
.idea
/node_modules
/dist
/coverage
# 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.*
40 changes: 40 additions & 0 deletions GRID-NUMBERING-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Grid Auto-Numbering Implementation Details

**Technical Note:**
As part of my DevOps-focused workflow, I designed the logic and coordinate system for this feature and used Antigravity AI to assist with the specific JavaScript/D3.js implementation.

---

## Logic Overview
The grid numbering system is integrated into the SVG rendering pipeline. It iterates through the existing grid cell data generated by the map engine and overlays a text element for each cell.

### Coordinate System
The system uses a top-down, left-to-right indexing method:
* **Starting Point:** The top-leftmost cell is assigned `0001`.
* **Flow:** Numbers increment horizontally across the row before moving to the next line.
* **Formatting:** Numbers are padded with leading zeros (e.g., `0001`, `0010`, `0100`) to maintain a consistent 4-digit coordinate string, common in tabletop hex-crawl systems.

### Grid Support
The logic dynamically calculates the centroid of each cell to ensure proper label placement regardless of the grid geometry:
* **Pointy Hex:** Centers text within the hexagonal bounds.
* **Square:** Standard center-point alignment.
* **Truncated Square:** Adjusts for the irregular geometry to prevent label clipping.

## Integration Points

### Style Panel
Added a new sub-section under the **Grid** layer in the Style panel:
* **Toggle:** A checkbox to enable/disable the `gridLabels` group in the SVG.
* **Font Size:** A slider controlling the `font-size` attribute of the labels.
* **Color Picker:** A standard hex color input tied to the text `fill` attribute.

### SVG Layering
A new `<g>` element with the ID `#gridLabels` is appended to the main map SVG. It sits directly above the grid lines layer to ensure visibility while remaining below the "Labels" or "Markers" layers.

## Files Modified
* `index.html`: Added the toggle and styling controls to the UI.
* `modules/ui/grid-menu.js`: Logic for handling UI interactions and state.
* `modules/render-grid.js`: Core logic for calculating centroids and appending text elements to the SVG.

## Performance Considerations
For massive maps with thousands of cells, the numbering system is optimized to only render when the Grid layer is active. This prevents unnecessary DOM overhead during standard map navigation.
139 changes: 110 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,110 @@
# Fantasy Map Generator

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. The current progress is tracked in [Trello](https://trello.com/b/7x832DG4/fantasy-map-generator). Some details are covered in my old blog [_Fantasy Maps for fun and glory_](https://azgaar.wordpress.com).

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/9502eae9-92e0-4d0d-9f17-a2ba4a565c01)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/11a42446-4bd5-4526-9cb1-3ef97c868992)

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/e751a9e5-7986-4638-b8a9-362395ef7583)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/e751a9e5-7986-4638-b8a9-362395ef7583)

[![preview](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/b0d0efde-a0d1-4e80-8818-ea3dd83c2323)](https://github.com/Azgaar/Fantasy-Map-Generator/assets/26469650/b0d0efde-a0d1-4e80-8818-ea3dd83c2323)

Join our [Discord server](https://discordapp.com/invite/X7E84HU) and [Reddit community](https://www.reddit.com/r/FantasyMapGenerator) to share your creations, discuss the Generator, suggest ideas and get the most recent updates.

Contact me via [email](mailto:azgaar.fmg@yandex.com) if you have non-public suggestions. For bug reports please use [GitHub issues](https://github.com/Azgaar/Fantasy-Map-Generator/issues) or _#fmg-bugs_ channel on Discord. If you are facing performance issues, please read [the tips](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Tips#performance-tips).

Pull requests are highly welcomed. The codebase is messy and requires re-design. I will appreciate if you start with minor changes. Check out the [data model](https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Data-model) before contributing.

You can support the project on [Patreon](https://www.patreon.com/azgaar).

_Inspiration:_

- Martin O'Leary's [_Generating fantasy maps_](https://mewo2.com/notes/terrain)

- Amit Patel's [_Polygonal Map Generation for Games_](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation)

- Scott Turner's [_Here Dragons Abound_](https://heredragonsabound.blogspot.com)
# 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!
1 change: 1 addition & 0 deletions images/fantasy-icons/alchemist.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/fantasy-icons/ambush.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/fantasy-icons/battlefield.svg
1 change: 1 addition & 0 deletions images/fantasy-icons/beetle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/fantasy-icons/blacksmith.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading