Skip to content

Commit 5e28569

Browse files
johnmphLash-L
andauthored
feat: add support for hiding walls and rooms in map rendering (#763)
* feat(map): add option to hide walls and rooms in map rendering * fix(map): removed unnecessary conversion of empty dict to none --------- Co-authored-by: Luke Lashley <conway220@gmail.com>
1 parent 38da8b0 commit 5e28569

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

roborock/map/map_parser.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class MapParserConfig:
5151
show_background: bool = True
5252
"""Whether to show the background of the map."""
5353

54+
show_walls: bool = True
55+
"""Whether to show the walls of the map."""
56+
57+
show_rooms: bool = True
58+
"""Whether to show the rooms of the map."""
59+
5460
map_scale: int = DEFAULT_MAP_SCALE
5561
"""Scale factor for the map."""
5662

@@ -94,11 +100,22 @@ def parse(self, map_bytes: bytes) -> ParsedMapData | None:
94100

95101
def _create_map_data_parser(config: MapParserConfig) -> RoborockMapDataParser:
96102
"""Create a RoborockMapDataParser based on the config entry."""
97-
colors = ColorsPalette()
103+
color_dicts = {}
104+
room_colors = {}
105+
98106
if not config.show_background:
99-
colors = ColorsPalette({SupportedColor.MAP_OUTSIDE: (0, 0, 0, 0)})
107+
color_dicts[SupportedColor.MAP_OUTSIDE] = (0, 0, 0, 0)
108+
109+
if not config.show_walls:
110+
color_dicts[SupportedColor.GREY_WALL] = (0, 0, 0, 0)
111+
color_dicts[SupportedColor.MAP_WALL] = (0, 0, 0, 0)
112+
color_dicts[SupportedColor.MAP_WALL_V2] = (0, 0, 0, 0)
113+
114+
if not config.show_rooms:
115+
room_colors = {str(x): (0, 0, 0, 0) for x in range(1, 32)}
116+
100117
return RoborockMapDataParser(
101-
colors,
118+
ColorsPalette(color_dicts, room_colors),
102119
Sizes({k: v * config.map_scale for k, v in Sizes.SIZES.items() if k != Size.MOP_PATH_WIDTH}),
103120
config.drawables,
104121
ImageConfig(scale=config.map_scale),

0 commit comments

Comments
 (0)