diff --git a/game/campaignloader/campaign.py b/game/campaignloader/campaign.py index 03b5a05a..776a6698 100644 --- a/game/campaignloader/campaign.py +++ b/game/campaignloader/campaign.py @@ -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), diff --git a/game/theater/theaterloader.py b/game/theater/theaterloader.py index 7ce1e626..075d1873 100644 --- a/game/theater/theaterloader.py +++ b/game/theater/theaterloader.py @@ -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: diff --git a/qt_ui/windows/newgame/QCampaignList.py b/qt_ui/windows/newgame/QCampaignList.py index d21d33b7..7ec61448 100644 --- a/qt_ui/windows/newgame/QCampaignList.py +++ b/qt_ui/windows/newgame/QCampaignList.py @@ -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: diff --git a/resources/theaters/caucasus/icon.gif b/resources/theaters/caucasus/icon.gif new file mode 100644 index 00000000..9fb79352 Binary files /dev/null and b/resources/theaters/caucasus/icon.gif differ diff --git a/resources/theaters/falklands/icon.gif b/resources/theaters/falklands/icon.gif new file mode 100644 index 00000000..1a1a3b45 Binary files /dev/null and b/resources/theaters/falklands/icon.gif differ diff --git a/resources/theaters/marianaislands/icon.gif b/resources/theaters/marianaislands/icon.gif new file mode 100644 index 00000000..2546cb88 Binary files /dev/null and b/resources/theaters/marianaislands/icon.gif differ diff --git a/resources/theaters/nevada/icon.gif b/resources/theaters/nevada/icon.gif new file mode 100644 index 00000000..de705d09 Binary files /dev/null and b/resources/theaters/nevada/icon.gif differ diff --git a/resources/theaters/normandy/icon.gif b/resources/theaters/normandy/icon.gif new file mode 100644 index 00000000..33686f05 Binary files /dev/null and b/resources/theaters/normandy/icon.gif differ diff --git a/resources/theaters/persian gulf/icon.gif b/resources/theaters/persian gulf/icon.gif new file mode 100644 index 00000000..67a9ead8 Binary files /dev/null and b/resources/theaters/persian gulf/icon.gif differ diff --git a/resources/theaters/syria/icon.gif b/resources/theaters/syria/icon.gif new file mode 100644 index 00000000..1c261d57 Binary files /dev/null and b/resources/theaters/syria/icon.gif differ diff --git a/resources/theaters/the channel/icon.gif b/resources/theaters/the channel/icon.gif new file mode 100644 index 00000000..97f4561a Binary files /dev/null and b/resources/theaters/the channel/icon.gif differ