mirror of
https://github.com/enzet/map-machine.git
synced 2025-04-28 09:47:17 +02:00
Support drawing options in scheme.
It is now necessary to enable drawing map features in the scheme file. In the `options` field one should enable the following features in order to have these features on the map, because they are disabled by default: - `draw_nodes`, - `draw_buildings`, - `draw_trees`, - `draw_craters`, - `draw_directions` Related to #140.
This commit is contained in:
parent
d3c18a3d5f
commit
f0b3d19b15
4 changed files with 63 additions and 37 deletions
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 439 KiB After Width: | Height: | Size: 440 KiB |
|
@ -87,49 +87,57 @@ class Map:
|
|||
path.update(figure.line_style.style)
|
||||
self.svg.add(path)
|
||||
|
||||
for tree in constructor.trees:
|
||||
tree.draw(self.svg, self.flinger, self.scheme)
|
||||
for crater in constructor.craters:
|
||||
crater.draw(self.svg, self.flinger)
|
||||
if self.scheme.draw_trees:
|
||||
for tree in constructor.trees:
|
||||
tree.draw(self.svg, self.flinger, self.scheme)
|
||||
|
||||
self.draw_buildings(constructor, self.configuration.use_building_colors)
|
||||
if self.scheme.draw_craters:
|
||||
for crater in constructor.craters:
|
||||
crater.draw(self.svg, self.flinger)
|
||||
|
||||
for direction_sector in constructor.direction_sectors:
|
||||
direction_sector.draw(self.svg, self.scheme)
|
||||
if self.scheme.draw_buildings:
|
||||
self.draw_buildings(
|
||||
constructor, self.configuration.use_building_colors
|
||||
)
|
||||
|
||||
if self.scheme.draw_directions:
|
||||
for direction_sector in constructor.direction_sectors:
|
||||
direction_sector.draw(self.svg, self.scheme)
|
||||
|
||||
# All other points
|
||||
|
||||
occupied: Optional[Occupied]
|
||||
if self.configuration.overlap == 0:
|
||||
occupied = None
|
||||
else:
|
||||
occupied = Occupied(
|
||||
self.flinger.size[0],
|
||||
self.flinger.size[1],
|
||||
self.configuration.overlap,
|
||||
)
|
||||
|
||||
nodes: list[Point] = sorted(
|
||||
constructor.points, key=lambda x: -x.priority
|
||||
)
|
||||
logging.info("Drawing main icons...")
|
||||
for node in nodes:
|
||||
node.draw_main_shapes(self.svg, occupied)
|
||||
|
||||
logging.info("Drawing extra icons...")
|
||||
for point in nodes:
|
||||
point.draw_extra_shapes(self.svg, occupied)
|
||||
|
||||
logging.info("Drawing texts...")
|
||||
for point in nodes:
|
||||
if (
|
||||
not self.configuration.is_wireframe()
|
||||
and self.configuration.label_mode != LabelMode.NO
|
||||
):
|
||||
point.draw_texts(
|
||||
self.svg, occupied, self.configuration.label_mode
|
||||
if self.scheme.draw_nodes:
|
||||
occupied: Optional[Occupied]
|
||||
if self.configuration.overlap == 0:
|
||||
occupied = None
|
||||
else:
|
||||
occupied = Occupied(
|
||||
self.flinger.size[0],
|
||||
self.flinger.size[1],
|
||||
self.configuration.overlap,
|
||||
)
|
||||
|
||||
nodes: list[Point] = sorted(
|
||||
constructor.points, key=lambda x: -x.priority
|
||||
)
|
||||
logging.info("Drawing main icons...")
|
||||
for node in nodes:
|
||||
node.draw_main_shapes(self.svg, occupied)
|
||||
|
||||
logging.info("Drawing extra icons...")
|
||||
for point in nodes:
|
||||
point.draw_extra_shapes(self.svg, occupied)
|
||||
|
||||
logging.info("Drawing texts...")
|
||||
for point in nodes:
|
||||
if (
|
||||
not self.configuration.is_wireframe()
|
||||
and self.configuration.label_mode != LabelMode.NO
|
||||
):
|
||||
point.draw_texts(
|
||||
self.svg, occupied, self.configuration.label_mode
|
||||
)
|
||||
|
||||
if self.configuration.show_credit:
|
||||
self.draw_credits(constructor.flinger.size)
|
||||
|
||||
|
|
|
@ -321,6 +321,16 @@ class Scheme:
|
|||
for element in group["tags"]:
|
||||
self.node_matchers.append(NodeMatcher(element, group))
|
||||
|
||||
options = content.get("options", {})
|
||||
|
||||
self.draw_nodes: bool = options.get("draw_nodes", False)
|
||||
|
||||
# Map features.
|
||||
self.draw_buildings: bool = options.get("draw_buildings", False)
|
||||
self.draw_trees: bool = options.get("draw_trees", False)
|
||||
self.draw_craters: bool = options.get("draw_craters", False)
|
||||
self.draw_directions: bool = options.get("draw_directions", False)
|
||||
|
||||
self.colors: dict[str, str] = content.get("colors", {})
|
||||
self.material_colors: dict[str, str] = content.get(
|
||||
"material_colors", {}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
options:
|
||||
|
||||
draw_nodes: yes
|
||||
draw_trees: yes
|
||||
draw_craters: yes
|
||||
draw_buildings: yes
|
||||
draw_directions: yes
|
||||
|
||||
colors:
|
||||
|
||||
# Entity
|
||||
|
|
Loading…
Add table
Reference in a new issue