Add fallback terrain icons in campaign selector (#80)
@ -32,6 +32,7 @@ DEFAULT_BUDGET = 2000
|
|||||||
class Campaign:
|
class Campaign:
|
||||||
name: str
|
name: str
|
||||||
menu_thumbnail_dcs_relative_path: Path
|
menu_thumbnail_dcs_relative_path: Path
|
||||||
|
fallback_icon_path: Path
|
||||||
authors: str
|
authors: str
|
||||||
description: str
|
description: str
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ class Campaign:
|
|||||||
return cls(
|
return cls(
|
||||||
data["name"],
|
data["name"],
|
||||||
TheaterLoader(data["theater"].lower()).menu_thumbnail_dcs_relative_path,
|
TheaterLoader(data["theater"].lower()).menu_thumbnail_dcs_relative_path,
|
||||||
|
TheaterLoader(data["theater"].lower()).icon_path,
|
||||||
data.get("authors", "???"),
|
data.get("authors", "???"),
|
||||||
data.get("description", ""),
|
data.get("description", ""),
|
||||||
(version.major, version.minor),
|
(version.major, version.minor),
|
||||||
|
|||||||
@ -90,6 +90,10 @@ class TheaterLoader:
|
|||||||
def landmap_path(self) -> Path:
|
def landmap_path(self) -> Path:
|
||||||
return self.descriptor_path.with_name("landmap.p")
|
return self.descriptor_path.with_name("landmap.p")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon_path(self) -> Path:
|
||||||
|
return self.descriptor_path.with_name("icon.gif")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def menu_thumbnail_dcs_relative_path(self) -> Path:
|
def menu_thumbnail_dcs_relative_path(self) -> Path:
|
||||||
with self.descriptor_path.open() as descriptor_file:
|
with self.descriptor_path.open() as descriptor_file:
|
||||||
|
|||||||
@ -15,8 +15,17 @@ class QCampaignItem(QStandardItem):
|
|||||||
def __init__(self, campaign: Campaign) -> None:
|
def __init__(self, campaign: Campaign) -> None:
|
||||||
super(QCampaignItem, self).__init__()
|
super(QCampaignItem, self).__init__()
|
||||||
self.setData(campaign, QCampaignList.CampaignRole)
|
self.setData(campaign, QCampaignList.CampaignRole)
|
||||||
|
|
||||||
|
# Define terrain icon path from the DCS installation directory by default
|
||||||
dcs_path = get_dcs_install_directory()
|
dcs_path = get_dcs_install_directory()
|
||||||
icon_path = dcs_path / campaign.menu_thumbnail_dcs_relative_path
|
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.setIcon(QtGui.QIcon(QPixmap(str(icon_path))))
|
||||||
self.setEditable(False)
|
self.setEditable(False)
|
||||||
if campaign.is_compatible:
|
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 |