Skip to content

Commit 2751ec0

Browse files
authored
Merge pull request #199 from ManualForArchipelago/visualize_from_yaml
Replace meta.yaml setting for visualize_regions with something easier and more single-use
2 parents 4fcc8fe + 5cd9569 commit 2751ec0

File tree

7 files changed

+16
-37
lines changed

7 files changed

+16
-37
lines changed

docs/resources/visualizing-your-world-logic.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Visualizing Your World Logic
22

33
## Visualizing Regions as a UML Diagram
4-
There's a wonderful tool in Archipelago (written by el_) that allows viewing all of your region connections visually as a diagram! Manual doesn't officially have a way to use this tool yet, but we hope to one day!
5-
6-
(To make use of this feature, you'll want to get a UML viewer like PlantUML.)
4+
When troubleshooting region connections while building a world, it can be helpful to see that you've connected those regions (and their locations) properly. By setting the `generate_region_diagram: true` in your yaml, a UML file will be added to your Archipelago install folder when you generate this world. Open that UML file in a UML viewer (such as PlantUML), and it will lay out region connections with boxes and lines interconnecting them.
75

86
![](../img/resources/visualize-regions-uml-example.png)
97

10-
Until Manual officially supports using it, there's a workaround to use it if you don't mind looking at a tiny amount of code:
8+
To generate a region diagram:
119

12-
1. Extract/unzip your apworld into a folder in your worlds folder, as if you were going to make changes to it.
13-
2. Open the `__init__.py` file that's in the main folder (not the `hooks` folder).
14-
3. Search for the text `visualize_regions`.
15-
4. Remove the `#` from the front of the two lines that match to uncomment them.
16-
5. Save the `__init__.py` and generate your world!
17-
6. Open the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld.
10+
1. Install your apworld as if you were going to play it
11+
2. Generate a template yaml, and set any options that might change the logic
12+
3. Add `generate_region_diagram: true` to your yaml
13+
4. Generate a seed
14+
5. Find the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld.
15+
6. Put the contents of that file into a viewer like [PlantUML](https://www.planttext.com/)
1816

1917
## Organizing Connected Ideas on a Graph
2018
Some tools can help with visualizing your game's structure.

docs/syntax/meta.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ If you'd like to see all the available properties and their allowed values, view
66

77
## The meta.json structure
88
The properties for this file are broken down into these headings below:
9-
- [Visualizing region connections with UML](#visualizing-region-connections-with-uml)
10-
- `enable_region_diagram`
119
- [APWorld description](#apworld-description)
1210
- `apworld_description`
1311
- [WebWorld - Tutorials](#webworld---tutorials)
@@ -25,19 +23,6 @@ The properties for this file are broken down into these headings below:
2523

2624
---
2725

28-
### Visualizing region connections with UML
29-
When troubleshooting region connections while building a world, it can be helpful to see that you've connected those regions (and their locations) properly. By setting the `enable_region_diagram` property to true, a UML file will be added to your Archipelago install folder when you generate this world. Open that UML file in a UML viewer (such as PlantUML), and it will lay out region connections with boxes and lines interconnecting them.
30-
31-
Here's an example of enabling the creation of a region diagram during generation:
32-
33-
```json
34-
{
35-
"enable_region_diagram": true
36-
}
37-
```
38-
39-
---
40-
4126
### APWorld description
4227
The world description describes the game that this APWorld was made for. This is the text that is shown for that game in the "Supported Games" listing of a running webhost.
4328

schemas/Manual.meta.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@
8181
}
8282
}
8383
}
84-
},
85-
"enable_region_diagram": {
86-
"description": "Enable the generation of puml diagram of your apworld region and locations for debug purposes",
87-
"type": "boolean",
88-
"default": false
8984
}
9085
},
9186
"definitions": {

src/Meta.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,3 @@ def set_world_webworld(web: WebWorld) -> WebWorld:
6868
the player must manually refrain from using these gathered items until the tracker shows that they have been acquired or sent.
6969
""")
7070
world_webworld: ManualWeb = set_world_webworld(ManualWeb())
71-
72-
enable_region_diagram = bool(meta_table.get("enable_region_diagram", False))

src/Options.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class FillerTrapPercent(Range):
1717
"""How many fillers will be replaced with traps. 0 means no additional traps, 100 means all fillers are traps."""
1818
range_end = 100
1919

20+
class GenerateRegionDiagram(Toggle):
21+
"""Generate a region diagram."""
22+
visibility = Visibility.none # Hidden option
23+
2024
def createChoiceOptions(values: dict, aliases: dict) -> dict:
2125
values = {'option_' + i: v for i, v in values.items()}
2226
aliases = {'alias_' + i: v for i, v in aliases.items()}
@@ -61,6 +65,7 @@ def addOptionToGroup(option_name: str, group: str):
6165

6266
manual_options: dict[str, Type[Option[Any]]] = before_options_defined({})
6367
manual_options["start_inventory_from_pool"] = StartInventoryPool
68+
manual_options["generate_region_diagram"] = GenerateRegionDiagram
6469

6570
if len(victory_names) > 1:
6671
if manual_options.get('goal'):

src/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .Data import item_table, location_table, event_table, region_table, category_table
1111
from .Game import game_name, filler_item_name, starting_items
12-
from .Meta import world_description, world_webworld, enable_region_diagram
12+
from .Meta import world_description, world_webworld
1313
from .Locations import location_id_to_name, location_name_to_id, location_name_to_location, location_name_groups, victory_names, event_name_to_event
1414
from .Items import item_id_to_name, item_name_to_id, item_name_to_item, item_name_groups
1515
from .DataValidation import runGenerationDataValidation, runPreFillDataValidation
@@ -402,7 +402,7 @@ def generate_basic(self):
402402
after_generate_basic(self, self.multiworld, self.player)
403403

404404
# Enable this in Meta.json to generate a diagram of your manual. Only works on 0.4.4+
405-
if enable_region_diagram:
405+
if get_option_value(self.multiworld, self.player, "generate_region_diagram"):
406406
from Utils import visualize_regions
407407
visualize_regions(self.multiworld.get_region("Menu", self.player), f"{self.game}_{self.player}.puml")
408408

src/data/meta.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@
3535
}
3636
}
3737
}
38-
},
39-
"_comment_":"Enable the generation of puml diagram of your apworld region and locations for debug purposes",
40-
"enable_region_diagram": false
38+
}
4139
}

0 commit comments

Comments
 (0)