diff --git a/docs/resources/visualizing-your-world-logic.md b/docs/resources/visualizing-your-world-logic.md index 04c5a14..0c40347 100644 --- a/docs/resources/visualizing-your-world-logic.md +++ b/docs/resources/visualizing-your-world-logic.md @@ -1,20 +1,18 @@ # Visualizing Your World Logic ## Visualizing Regions as a UML Diagram -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! - -(To make use of this feature, you'll want to get a UML viewer like PlantUML.) +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. ![](../img/resources/visualize-regions-uml-example.png) -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: +To generate a region diagram: -1. Extract/unzip your apworld into a folder in your worlds folder, as if you were going to make changes to it. -2. Open the `__init__.py` file that's in the main folder (not the `hooks` folder). -3. Search for the text `visualize_regions`. -4. Remove the `#` from the front of the two lines that match to uncomment them. -5. Save the `__init__.py` and generate your world! -6. Open the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld. +1. Install your apworld as if you were going to play it +2. Generate a template yaml, and set any options that might change the logic +3. Add `generate_region_diagram: true` to your yaml +4. Generate a seed +5. Find the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld. +6. Put the contents of that file into a viewer like [PlantUML](https://www.planttext.com/) ## Organizing Connected Ideas on a Graph Some tools can help with visualizing your game's structure. diff --git a/docs/syntax/meta.md b/docs/syntax/meta.md index 5b31624..77a63f7 100644 --- a/docs/syntax/meta.md +++ b/docs/syntax/meta.md @@ -6,8 +6,6 @@ If you'd like to see all the available properties and their allowed values, view ## The meta.json structure The properties for this file are broken down into these headings below: -- [Visualizing region connections with UML](#visualizing-region-connections-with-uml) - - `enable_region_diagram` - [APWorld description](#apworld-description) - `apworld_description` - [WebWorld - Tutorials](#webworld---tutorials) @@ -25,19 +23,6 @@ The properties for this file are broken down into these headings below: --- -### Visualizing region connections with UML -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. - -Here's an example of enabling the creation of a region diagram during generation: - -```json -{ - "enable_region_diagram": true -} -``` - ---- - ### APWorld description 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. diff --git a/schemas/Manual.meta.schema.json b/schemas/Manual.meta.schema.json index ad4220e..1c3253e 100644 --- a/schemas/Manual.meta.schema.json +++ b/schemas/Manual.meta.schema.json @@ -81,11 +81,6 @@ } } } - }, - "enable_region_diagram": { - "description": "Enable the generation of puml diagram of your apworld region and locations for debug purposes", - "type": "boolean", - "default": false } }, "definitions": { diff --git a/src/Meta.py b/src/Meta.py index 55a9953..0056aff 100644 --- a/src/Meta.py +++ b/src/Meta.py @@ -68,5 +68,3 @@ def set_world_webworld(web: WebWorld) -> WebWorld: the player must manually refrain from using these gathered items until the tracker shows that they have been acquired or sent. """) world_webworld: ManualWeb = set_world_webworld(ManualWeb()) - -enable_region_diagram = bool(meta_table.get("enable_region_diagram", False)) diff --git a/src/Options.py b/src/Options.py index 896763d..e46bd0a 100644 --- a/src/Options.py +++ b/src/Options.py @@ -17,6 +17,10 @@ class FillerTrapPercent(Range): """How many fillers will be replaced with traps. 0 means no additional traps, 100 means all fillers are traps.""" range_end = 100 +class GenerateRegionDiagram(Toggle): + """Generate a region diagram.""" + visibility = Visibility.none # Hidden option + def createChoiceOptions(values: dict, aliases: dict) -> dict: values = {'option_' + i: v for i, v in values.items()} aliases = {'alias_' + i: v for i, v in aliases.items()} @@ -61,6 +65,7 @@ def addOptionToGroup(option_name: str, group: str): manual_options: dict[str, Type[Option[Any]]] = before_options_defined({}) manual_options["start_inventory_from_pool"] = StartInventoryPool +manual_options["generate_region_diagram"] = GenerateRegionDiagram if len(victory_names) > 1: if manual_options.get('goal'): diff --git a/src/__init__.py b/src/__init__.py index 4d51cd1..0813346 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -9,7 +9,7 @@ from .Data import item_table, location_table, event_table, region_table, category_table from .Game import game_name, filler_item_name, starting_items -from .Meta import world_description, world_webworld, enable_region_diagram +from .Meta import world_description, world_webworld from .Locations import location_id_to_name, location_name_to_id, location_name_to_location, location_name_groups, victory_names, event_name_to_event from .Items import item_id_to_name, item_name_to_id, item_name_to_item, item_name_groups from .DataValidation import runGenerationDataValidation, runPreFillDataValidation @@ -402,7 +402,7 @@ def generate_basic(self): after_generate_basic(self, self.multiworld, self.player) # Enable this in Meta.json to generate a diagram of your manual. Only works on 0.4.4+ - if enable_region_diagram: + if get_option_value(self.multiworld, self.player, "generate_region_diagram"): from Utils import visualize_regions visualize_regions(self.multiworld.get_region("Menu", self.player), f"{self.game}_{self.player}.puml") diff --git a/src/data/meta.json b/src/data/meta.json index bf4a7ab..f8a53d7 100644 --- a/src/data/meta.json +++ b/src/data/meta.json @@ -35,7 +35,5 @@ } } } - }, - "_comment_":"Enable the generation of puml diagram of your apworld region and locations for debug purposes", - "enable_region_diagram": false + } }