Add fallback terrain icons in campaign selector (#80)
@ -32,6 +32,7 @@ DEFAULT_BUDGET = 2000
|
||||
class Campaign:
|
||||
name: str
|
||||
menu_thumbnail_dcs_relative_path: Path
|
||||
fallback_icon_path: Path
|
||||
authors: str
|
||||
description: str
|
||||
|
||||
@ -90,6 +91,7 @@ class Campaign:
|
||||
return cls(
|
||||
data["name"],
|
||||
TheaterLoader(data["theater"].lower()).menu_thumbnail_dcs_relative_path,
|
||||
TheaterLoader(data["theater"].lower()).icon_path,
|
||||
data.get("authors", "???"),
|
||||
data.get("description", ""),
|
||||
(version.major, version.minor),
|
||||
|
||||
@ -90,6 +90,10 @@ class TheaterLoader:
|
||||
def landmap_path(self) -> Path:
|
||||
return self.descriptor_path.with_name("landmap.p")
|
||||
|
||||
@property
|
||||
def icon_path(self) -> Path:
|
||||
return self.descriptor_path.with_name("icon.gif")
|
||||
|
||||
@property
|
||||
def menu_thumbnail_dcs_relative_path(self) -> Path:
|
||||
with self.descriptor_path.open() as descriptor_file:
|
||||
|
||||
@ -15,8 +15,17 @@ class QCampaignItem(QStandardItem):
|
||||
def __init__(self, campaign: Campaign) -> None:
|
||||
super(QCampaignItem, self).__init__()
|
||||
self.setData(campaign, QCampaignList.CampaignRole)
|
||||
|
||||
# Define terrain icon path from the DCS installation directory by default
|
||||
dcs_path = get_dcs_install_directory()
|
||||
icon_path = dcs_path / campaign.menu_thumbnail_dcs_relative_path
|
||||
|
||||
# If the path does not exist (user does not have the terrain installed),
|
||||
# use the old icons as fallback to avoid an ugly campaign list with missing icons
|
||||
if not icon_path.exists():
|
||||
print(f"Icon path: {campaign.fallback_icon_path}")
|
||||
icon_path = campaign.fallback_icon_path
|
||||
|
||||
self.setIcon(QtGui.QIcon(QPixmap(str(icon_path))))
|
||||
self.setEditable(False)
|
||||
if campaign.is_compatible:
|
||||
|
||||
BIN
resources/theaters/caucasus/icon.gif
Normal file
|
After Width: | Height: | Size: 852 B |
BIN
resources/theaters/falklands/icon.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/theaters/marianaislands/icon.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/theaters/nevada/icon.gif
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
resources/theaters/normandy/icon.gif
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/theaters/persian gulf/icon.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/theaters/syria/icon.gif
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/theaters/the channel/icon.gif
Normal file
|
After Width: | Height: | Size: 1.3 KiB |