maps4fs 2.9.3__py3-none-any.whl → 2.9.31__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of maps4fs might be problematic. Click here for more details.
- maps4fs/generator/component/grle.py +57 -0
- maps4fs/generator/config.py +20 -4
- maps4fs/generator/game.py +42 -2
- {maps4fs-2.9.3.dist-info → maps4fs-2.9.31.dist-info}/METADATA +1 -1
- {maps4fs-2.9.3.dist-info → maps4fs-2.9.31.dist-info}/RECORD +8 -8
- {maps4fs-2.9.3.dist-info → maps4fs-2.9.31.dist-info}/WHEEL +0 -0
- {maps4fs-2.9.3.dist-info → maps4fs-2.9.31.dist-info}/licenses/LICENSE.md +0 -0
- {maps4fs-2.9.3.dist-info → maps4fs-2.9.31.dist-info}/top_level.txt +0 -0
|
@@ -542,6 +542,17 @@ class GRLE(ImageComponent, XMLComponent):
|
|
|
542
542
|
|
|
543
543
|
for layer in texture_component.get_area_type_layers():
|
|
544
544
|
pixel_value = area_type_to_pixel_value(layer.area_type) # type: ignore
|
|
545
|
+
# * Not enabled for now.
|
|
546
|
+
# * If the layer is invisible, we need to draw the mask from the info layer.
|
|
547
|
+
# if layer.invisible:
|
|
548
|
+
# self.logger.debug("Processing invisible area type layer: %s.", layer.name)
|
|
549
|
+
# if layer.info_layer:
|
|
550
|
+
# self.logger.debug("Info layer available: %s.", layer.info_layer)
|
|
551
|
+
# weight_image = self.draw_invisible_layer_mask(layer, environment_size)
|
|
552
|
+
# else:
|
|
553
|
+
# self.logger.debug("No info layer available for layer: %s.", layer.name)
|
|
554
|
+
# continue
|
|
555
|
+
# else:
|
|
545
556
|
weight_image = self.get_resized_weight(layer, environment_size) # type: ignore
|
|
546
557
|
if weight_image is None:
|
|
547
558
|
self.logger.warning("Weight image for area type layer not found in %s.", layer.name)
|
|
@@ -562,6 +573,52 @@ class GRLE(ImageComponent, XMLComponent):
|
|
|
562
573
|
self.logger.debug("Environment InfoLayer PNG file saved: %s.", info_layer_environment_path)
|
|
563
574
|
self.preview_paths["environment"] = info_layer_environment_path
|
|
564
575
|
|
|
576
|
+
# def draw_invisible_layer_mask(self, layer: Layer, resize_to: int) -> np.ndarray:
|
|
577
|
+
# """Draw the mask for the invisible layer.
|
|
578
|
+
|
|
579
|
+
# Arguments:
|
|
580
|
+
# layer (Layer): The layer for which to draw the mask.
|
|
581
|
+
# resize_to (int): The size to which the mask should be resized.
|
|
582
|
+
|
|
583
|
+
# Returns:
|
|
584
|
+
# np.ndarray: The resized mask.
|
|
585
|
+
# """
|
|
586
|
+
# mask = np.zeros((self.map.size, self.map.size), dtype=np.uint8)
|
|
587
|
+
# polygons = self.get_infolayer_data(Parameters.TEXTURES, layer.info_layer)
|
|
588
|
+
# self.logger.debug("Found %d polygons in info layer %s.", len(polygons), layer.info_layer)
|
|
589
|
+
|
|
590
|
+
# for polygon in polygons:
|
|
591
|
+
# try:
|
|
592
|
+
# fitted_polygon = self.fit_object_into_bounds(
|
|
593
|
+
# polygon_points=polygon,
|
|
594
|
+
# # margin=self.map.grle_settings.farmland_margin,
|
|
595
|
+
# angle=self.rotation,
|
|
596
|
+
# )
|
|
597
|
+
# except ValueError as e:
|
|
598
|
+
# self.logger.debug(
|
|
599
|
+
# "Polygon could not be fitted into the map bounds with error: %s",
|
|
600
|
+
# e,
|
|
601
|
+
# )
|
|
602
|
+
# continue
|
|
603
|
+
# polygon_np = self.polygon_points_to_np(fitted_polygon)
|
|
604
|
+
|
|
605
|
+
# try:
|
|
606
|
+
# cv2.fillPoly(mask, [polygon_np], (float(255),)) # type: ignore
|
|
607
|
+
# except Exception as e:
|
|
608
|
+
# self.logger.debug(
|
|
609
|
+
# "Polygon could not be added to the mask with error: %s",
|
|
610
|
+
# e,
|
|
611
|
+
# )
|
|
612
|
+
# continue
|
|
613
|
+
|
|
614
|
+
# resized_mask = cv2.resize(
|
|
615
|
+
# mask,
|
|
616
|
+
# (resize_to, resize_to),
|
|
617
|
+
# interpolation=cv2.INTER_NEAREST,
|
|
618
|
+
# )
|
|
619
|
+
|
|
620
|
+
# return resized_mask
|
|
621
|
+
|
|
565
622
|
@monitor_performance
|
|
566
623
|
def get_resized_weight(
|
|
567
624
|
self, layer: Layer, resize_to: int, dilations: int = 3
|
maps4fs/generator/config.py
CHANGED
|
@@ -82,15 +82,31 @@ def ensure_templates():
|
|
|
82
82
|
text=True,
|
|
83
83
|
)
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
if os.name == "nt":
|
|
86
|
+
logger.info("Detected Windows OS, running PowerShell preparation script...")
|
|
87
|
+
prep_script = os.path.join(clone_dir, "prepare_data.ps1")
|
|
88
|
+
for_subprocess = [
|
|
89
|
+
"powershell",
|
|
90
|
+
"-ExecutionPolicy",
|
|
91
|
+
"Bypass",
|
|
92
|
+
"-File",
|
|
93
|
+
"prepare_data.ps1",
|
|
94
|
+
]
|
|
95
|
+
else:
|
|
96
|
+
logger.info("Detected non-Windows OS, running bash preparation script...")
|
|
97
|
+
prep_script = os.path.join(clone_dir, "prepare_data.sh")
|
|
98
|
+
for_subprocess = ["./prepare_data.sh"]
|
|
99
|
+
|
|
87
100
|
if os.path.exists(prep_script):
|
|
88
|
-
|
|
101
|
+
try:
|
|
102
|
+
os.chmod(prep_script, 0o755)
|
|
103
|
+
except Exception as e:
|
|
104
|
+
logger.warning("Could not set execute permissions on script: %s", str(e))
|
|
89
105
|
|
|
90
106
|
logger.info("Running data preparation script...")
|
|
91
107
|
# Run the preparation script from the cloned directory
|
|
92
108
|
subprocess.run(
|
|
93
|
-
|
|
109
|
+
for_subprocess, cwd=clone_dir, check=True, capture_output=True, text=True
|
|
94
110
|
)
|
|
95
111
|
|
|
96
112
|
# Copy the generated data directory to templates directory
|
maps4fs/generator/game.py
CHANGED
|
@@ -6,6 +6,8 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
8
|
|
|
9
|
+
from typing import Callable
|
|
10
|
+
|
|
9
11
|
import maps4fs.generator.config as mfscfg
|
|
10
12
|
from maps4fs.generator.component.background import Background
|
|
11
13
|
from maps4fs.generator.component.config import Config
|
|
@@ -166,8 +168,7 @@ class Game:
|
|
|
166
168
|
map_directory (str): The path to the map directory.
|
|
167
169
|
|
|
168
170
|
Returns:
|
|
169
|
-
str: The path to the DEM file.
|
|
170
|
-
"""
|
|
171
|
+
str: The path to the DEM file."""
|
|
171
172
|
raise NotImplementedError
|
|
172
173
|
|
|
173
174
|
def weights_dir_path(self, map_directory: str) -> str:
|
|
@@ -341,6 +342,45 @@ class Game:
|
|
|
341
342
|
bool: True if the mesh should be processed, False otherwise."""
|
|
342
343
|
return self._mesh_processing
|
|
343
344
|
|
|
345
|
+
def validate_template(self, map_directory: str) -> None:
|
|
346
|
+
"""Validates that all required files exist in the map template directory.
|
|
347
|
+
|
|
348
|
+
Arguments:
|
|
349
|
+
map_directory (str): The path to the map directory.
|
|
350
|
+
|
|
351
|
+
Raises:
|
|
352
|
+
FileNotFoundError: If any required files are missing from the template.
|
|
353
|
+
"""
|
|
354
|
+
all_files = []
|
|
355
|
+
for root, _, files in os.walk(map_directory):
|
|
356
|
+
for file in files:
|
|
357
|
+
all_files.append(os.path.join(root, file))
|
|
358
|
+
|
|
359
|
+
missing_files = []
|
|
360
|
+
for func in self.required_file_methods():
|
|
361
|
+
try:
|
|
362
|
+
required_filepath = func(map_directory)
|
|
363
|
+
except NotImplementedError:
|
|
364
|
+
continue
|
|
365
|
+
if required_filepath not in all_files:
|
|
366
|
+
missing_files.append(required_filepath)
|
|
367
|
+
if missing_files:
|
|
368
|
+
raise FileNotFoundError(f"The following files are not found: {missing_files}.")
|
|
369
|
+
|
|
370
|
+
def required_file_methods(self) -> list[Callable[[str], str]]:
|
|
371
|
+
"""Returns a list of methods that return paths to required files for map generation.
|
|
372
|
+
|
|
373
|
+
Returns:
|
|
374
|
+
list[Callable[[str], str]]: List of methods that take a map directory path
|
|
375
|
+
and return file paths that are required for the map template.
|
|
376
|
+
"""
|
|
377
|
+
return [
|
|
378
|
+
self.map_xml_path,
|
|
379
|
+
self.i3d_file_path,
|
|
380
|
+
self.get_environment_xml_path,
|
|
381
|
+
self.get_farmlands_xml_path,
|
|
382
|
+
]
|
|
383
|
+
|
|
344
384
|
|
|
345
385
|
class FS22(Game):
|
|
346
386
|
"""Class used to define the game version FS22."""
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
maps4fs/__init__.py,sha256=5ixsCA5vgcIV0OrF9EJBm91Mmc_KfMiDRM-QyifMAvo,386
|
|
2
2
|
maps4fs/logger.py,sha256=aZAa9glzgvH6ySVDLelSPTwHfWZtpGK5YBl-ufNUsPg,801
|
|
3
3
|
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
|
4
|
-
maps4fs/generator/config.py,sha256=
|
|
5
|
-
maps4fs/generator/game.py,sha256=
|
|
4
|
+
maps4fs/generator/config.py,sha256=p_yetsUWQBskC-FJwc9NnoJ_XHJvmpqs9ZNOIGDcOSo,7868
|
|
5
|
+
maps4fs/generator/game.py,sha256=QKJ6tXH59ubKx3MuHWnCKYXRhgKOa_lWh30OAMTJDFE,17605
|
|
6
6
|
maps4fs/generator/map.py,sha256=ak74FNSDQXPqaB0gOaZqVo8Sy0fvf_3iXHg6FJkHPpA,15888
|
|
7
7
|
maps4fs/generator/monitor.py,sha256=Yrc7rClpmJK53SRzrOYZNBlwJmb5l6TkW-laFbyBEno,3524
|
|
8
8
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
|
@@ -13,7 +13,7 @@ maps4fs/generator/component/__init__.py,sha256=s01yVVVi8R2xxNvflu2D6wTd9I_g73AMM
|
|
|
13
13
|
maps4fs/generator/component/background.py,sha256=c2bjK3DkQXvA6Gtb_hUM9m-7fIVgp2BxJp09c4ZY3_A,49434
|
|
14
14
|
maps4fs/generator/component/config.py,sha256=tI2RQaGIqBgJIi9KjYfMZZ8AWg_YVUm6KKsBHGV241g,31285
|
|
15
15
|
maps4fs/generator/component/dem.py,sha256=vMVJtU2jAS-2lfB9JsqodZsrUvY1h5xr3Dh5qk6txwk,11895
|
|
16
|
-
maps4fs/generator/component/grle.py,sha256=
|
|
16
|
+
maps4fs/generator/component/grle.py,sha256=FAcGmG7yq0icOElRoO4QMsVisZMsNrLhfNSWvGKnOHg,29899
|
|
17
17
|
maps4fs/generator/component/i3d.py,sha256=t6Y9JPXvKJ91wTBg_-noIsxDPk1OSdY9EwM5ZtgOl9Q,26771
|
|
18
18
|
maps4fs/generator/component/layer.py,sha256=bdy1XGOODyPqYUM3b_wEY2H9Piz-AaHsCDecl-qRHiM,6627
|
|
19
19
|
maps4fs/generator/component/satellite.py,sha256=1bPqd8JqAPqU0tEI9m-iuljMW9hXqlaCIxvq7kdpMY0,5219
|
|
@@ -23,8 +23,8 @@ maps4fs/generator/component/base/component.py,sha256=-7H3donrH19f0_rivNyI3fgLsiZ
|
|
|
23
23
|
maps4fs/generator/component/base/component_image.py,sha256=GXFkEFARNRkWkDiGSjvU4WX6f_8s6R1t2ZYqZflv1jk,9626
|
|
24
24
|
maps4fs/generator/component/base/component_mesh.py,sha256=2wGe_-wAZVRljMKzzVJ8jdzIETWg7LjxGj8A3inH5eI,25550
|
|
25
25
|
maps4fs/generator/component/base/component_xml.py,sha256=MT-VhU2dEckLFxAgmxg6V3gnv11di_94Qq6atfpOLdc,5342
|
|
26
|
-
maps4fs-2.9.
|
|
27
|
-
maps4fs-2.9.
|
|
28
|
-
maps4fs-2.9.
|
|
29
|
-
maps4fs-2.9.
|
|
30
|
-
maps4fs-2.9.
|
|
26
|
+
maps4fs-2.9.31.dist-info/licenses/LICENSE.md,sha256=Ptw8AkqJ60c4tRts6yuqGP_8B0dxwOGmJsp6YJ8dKqM,34328
|
|
27
|
+
maps4fs-2.9.31.dist-info/METADATA,sha256=PRyTxe_eyZh-PTlrk7rBm3qc6kzMFE3hBskAEpZEPiY,10043
|
|
28
|
+
maps4fs-2.9.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
29
|
+
maps4fs-2.9.31.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
|
30
|
+
maps4fs-2.9.31.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|