maps4fs 1.7.6__py3-none-any.whl → 1.7.8__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.
maps4fs/generator/game.py CHANGED
@@ -58,18 +58,19 @@ class Game:
58
58
  return os.path.join(map_directory, "maps", "map", "map.xml")
59
59
 
60
60
  @classmethod
61
- def from_code(cls, code: str) -> Game:
61
+ def from_code(cls, code: str, map_template_path: str | None = None) -> Game:
62
62
  """Returns the game instance based on the game code.
63
63
 
64
64
  Arguments:
65
65
  code (str): The code of the game.
66
+ map_template_path (str, optional): Path to the map template file. Defaults to None.
66
67
 
67
68
  Returns:
68
69
  Game: The game instance.
69
70
  """
70
71
  for game in cls.__subclasses__():
71
72
  if game.code and game.code.lower() == code.lower():
72
- return game()
73
+ return game(map_template_path)
73
74
  raise ValueError(f"Game with code {code} not found.")
74
75
 
75
76
  @property
maps4fs/generator/grle.py CHANGED
@@ -163,7 +163,7 @@ class GRLE(Component):
163
163
  # use fields_np as base layer and overlay farmlands_np on top of it with 50% alpha blending.
164
164
  return cv2.addWeighted(fields_np, 0.5, farmlands_np, 0.5, 0)
165
165
 
166
- # pylint: disable=R0801, R0914
166
+ # pylint: disable=R0801, R0914, R0915
167
167
  def _add_farmlands(self) -> None:
168
168
  """Adds farmlands to the InfoLayer PNG file."""
169
169
 
@@ -174,18 +174,20 @@ class GRLE(Component):
174
174
  with open(textures_info_layer_path, "r", encoding="utf-8") as textures_info_layer_file:
175
175
  textures_info_layer = json.load(textures_info_layer_file)
176
176
 
177
+ farmlands = []
178
+ farmyards: list[list[tuple[int, int]]] | None = textures_info_layer.get("farmyards")
179
+ if farmyards and self.map.grle_settings.add_farmyards:
180
+ farmlands.extend(farmyards)
181
+ self.logger.debug("Found %s farmyards in textures info layer.", len(farmyards))
182
+
177
183
  fields: list[list[tuple[int, int]]] | None = textures_info_layer.get("fields")
178
184
  if not fields:
179
185
  self.logger.warning("Fields data not found in textures info layer.")
180
186
  return
187
+ farmlands.extend(fields)
181
188
 
182
189
  self.logger.debug("Found %s fields in textures info layer.", len(fields))
183
190
 
184
- farmyards: list[list[tuple[int, int]]] | None = textures_info_layer.get("farmyards")
185
- if farmyards and self.map.grle_settings.add_farmyards:
186
- fields.extend(farmyards)
187
- self.logger.debug("Found %s farmyards in textures info layer.", len(farmyards))
188
-
189
191
  info_layer_farmlands_path = os.path.join(
190
192
  self.game.weights_dir_path(self.map_directory), "infoLayer_farmlands.png"
191
193
  )
@@ -212,10 +214,10 @@ class GRLE(Component):
212
214
  # the farmland_id. So as a result we do not have a gap in the farmland IDs.
213
215
  farmland_id = 1
214
216
 
215
- for field in fields:
217
+ for farmland_data in farmlands:
216
218
  try:
217
219
  fitted_field = self.fit_object_into_bounds(
218
- polygon_points=field,
220
+ polygon_points=farmland_data,
219
221
  margin=self.map.grle_settings.farmland_margin,
220
222
  angle=self.rotation,
221
223
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: maps4fs
3
- Version: 1.7.6
3
+ Version: 1.7.8
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: MIT License
@@ -594,6 +594,8 @@ The tool also supports the expert settings. Do not use them until you read the d
594
594
 
595
595
  - Upload custom background image - if you have an image, which represents the map and background terrain you can use it for generation. Note, that the image should meet the following requirements: 1:1 aspect ratio, size = map size + 2048 * 2, it should be uint16 (unsigned 16-bit integer) grayscale (single channel) image. The image should be in the PNG format. If any of the requirements are not met, the tool raises an error. If you're using rotation, the image should already be rotated.
596
596
 
597
+ - Upload custom map template - you can use your own map template for generation. Note, that is must have the same structure as built-in templates. It's recommended to use the built-in templates and edit them as you need, instead of creating the new ones from scratch.
598
+
597
599
  ## Resources
598
600
  In this section, you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
599
601
  To create a basic map, you only need the Giants Editor. But if you want to create a background terrain - the world around the map, so it won't look like it's floating in the void - you also need Blender and the Blender Exporter Plugins. To create realistic textures for the background terrain, the QGIS is required to obtain high-resolution satellite images.<br>
@@ -5,8 +5,8 @@ maps4fs/generator/background.py,sha256=tV4UXvtkNN-OSvv6ujp4jFWRU1xGBgEvSakVGZ1H4
5
5
  maps4fs/generator/component.py,sha256=pbpGaWy5C0UzxpcJ72HPY2gMol98snDr-bvNZSX4yY0,20823
6
6
  maps4fs/generator/config.py,sha256=0QmK052B8bxyHVhg3jzCORLfOBMMmqVfhhbqXKf6OMk,4383
7
7
  maps4fs/generator/dem.py,sha256=20gx0dzX0LyO6ipvDitst-BwGfcKogFqgQf9Q2qMH5U,10933
8
- maps4fs/generator/game.py,sha256=Nf5r2ubV4YVAVHGzJyhbF2GnOC0qV3HlHYIZBCWciHs,7992
9
- maps4fs/generator/grle.py,sha256=hcbVBJ4j_Zr2QvEVo2cYNh2jARVXp_X3onifBtp9Zxs,20922
8
+ maps4fs/generator/game.py,sha256=GmCl_KQ9D-UwKao4HFEb0PRAm829ThtSZfkgzK3Oh2g,8143
9
+ maps4fs/generator/grle.py,sha256=g9AHq3yBJgRxNnvHt9W_heU7tnJjYzEkLzGpoKFR34M,21007
10
10
  maps4fs/generator/i3d.py,sha256=pUyHKWKcw43xVCf3Y8iabtbQba05LYxMHi8vziGksIA,24843
11
11
  maps4fs/generator/map.py,sha256=a50KQEr1XZKjS_WKXywGwh4OC3gyjY6M8FTc0eNcxpg,10183
12
12
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
@@ -23,8 +23,8 @@ maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,4
23
23
  maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
24
24
  maps4fs/toolbox/custom_osm.py,sha256=X6ZlPqiOhNjkmdD_qVroIfdOl9Rb90cDwVSLDVYgx80,1892
25
25
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
26
- maps4fs-1.7.6.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
27
- maps4fs-1.7.6.dist-info/METADATA,sha256=JJrc4bG4NmytUf6tI4QdMF2_a2GJjKLzUnHOGLIuE28,40436
28
- maps4fs-1.7.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
- maps4fs-1.7.6.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
30
- maps4fs-1.7.6.dist-info/RECORD,,
26
+ maps4fs-1.7.8.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
27
+ maps4fs-1.7.8.dist-info/METADATA,sha256=sRpKVOaUwW-yNcVKTmxCmgamzSCXWe5yNBke1hmIy3g,40705
28
+ maps4fs-1.7.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
29
+ maps4fs-1.7.8.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
30
+ maps4fs-1.7.8.dist-info/RECORD,,