Skip to content

Commit

Permalink
Merge pull request #1670 from heinezen/feature/changelog_update
Browse files Browse the repository at this point in the history
Check for outdated modpacks on startup
  • Loading branch information
TheJJ committed Aug 7, 2024
2 parents 641127f + 9d8641e commit d09adb0
Show file tree
Hide file tree
Showing 23 changed files with 355 additions and 220 deletions.
38 changes: 38 additions & 0 deletions cfg/converter/games/game_editions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ expansions = []
"C:/Program Files (x86)/Microsoft Games/Age of Empires II",
]

[AOC.targetmods.aoe2_base]
version = "0.5.1"
versionstr = "1.0c"
min_api_version = "0.5.0"


[AOCDEMO]
name = "Age of Empires 2: The Conqueror's Trial Version"
Expand All @@ -57,6 +62,12 @@ expansions = []
terrain = ["data/Terrain.drs"]
blend = ["data/blendomatic.dat"]

[AOCDEMO.targetmods.trial_base]
version = "0.5.1"
versionstr = "Trial"
min_api_version = "0.5.0"


[AOK]
name = "Age of Empires 2: Age of Kings"
game_edition_id = "AOK"
Expand Down Expand Up @@ -90,6 +101,8 @@ expansions = []
"C:/Program Files (x86)/Microsoft Games/Age of Empires II",
]

[AOK.targetmods]


[AOE1DE]
name = "Age of Empires 1: Definitive Edition (Steam)"
Expand Down Expand Up @@ -131,6 +144,11 @@ expansions = []
"C:/Program Files (x86)/Steam/steamapps/common/AoEDE",
]

[AOE1DE.targetmods.de1_base]
version = "0.5.1"
versionstr = "1.0a"
min_api_version = "0.5.0"


[ROR]
name = "Age of Empires 1: Rise of Rome"
Expand Down Expand Up @@ -166,6 +184,11 @@ expansions = []
"C:/Program Files (x86)/Microsoft Games/Age of Empires",
]

[ROR.targetmods.aoe1_base]
version = "0.5.1"
versionstr = "1.0a"
min_api_version = "0.5.0"


[HDEDITION]
name = "Age of Empires 2: HD Edition"
Expand Down Expand Up @@ -205,6 +228,11 @@ expansions = []
"C:/Program Files (x86)/Steam/steamapps/common/Age2HD",
]

[HDEDITION.targetmods.hd_base]
version = "0.5.1"
versionstr = "5.8"
min_api_version = "0.5.0"


[AOE2DE]
name = "Age of Empires 2: Definitive Edition"
Expand Down Expand Up @@ -249,6 +277,11 @@ expansions = []
"C:/Program Files (x86)/Steam/steamapps/common/AoE2DE",
]

[AOE2DE.targetmods.de2_base]
version = "0.6.0"
versionstr = "Update 118476+"
min_api_version = "0.5.0"


[SWGB]
name = "Star Wars: Galactic Battlegrounds"
Expand Down Expand Up @@ -285,3 +318,8 @@ expansions = ["SWGB_CC"]
"C:/Program Files (x86)/Steam/steamapps/common/STAR WARS - Galactic Battlegrounds Saga",
"C:/Program Files/Steam/steamapps/common/STAR WARS - Galactic Battlegrounds Saga",
]

[SWGB.targetmods.swgb_base]
version = "0.5.1"
versionstr = "1.1-gog4"
min_api_version = "0.5.0"
45 changes: 25 additions & 20 deletions cfg/converter/games/game_expansions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,36 @@
file_version = "1.0"

[AFRI_KING]
name = "African Kingdoms (HD)"
name = "African Kingdoms (HD)"
game_edition_id = "AFRI_KING"
subfolder = "hd_ak"
support = "nope"
targetmod = [ "aoe2-ak", "aoe2-ak-graphics" ]
subfolder = "hd_ak"
support = "nope"
targetmod = ["aoe2-ak", "aoe2-ak-graphics"]

[AFRI_KING.mediapaths]
graphics = [ "resources/_common/slp/" ]
sounds = [ "resources/_common/sound/" ]
interface = [ "resources/_common/drs/interface/" ]
terrain = [ "resources/_common/terrain/" ]
graphics = ["resources/_common/slp/"]
sounds = ["resources/_common/sound/"]
interface = ["resources/_common/drs/interface/"]
terrain = ["resources/_common/terrain/"]

[AFRI_KING.targetmods]


[SWGB_CC]
name = "Clone Campaigns"
name = "Clone Campaigns"
game_edition_id = "SWGB_CC"
subfolder = "swgb_cc"
support = "yes"
targetmod = [ "swgb-cc", "swgb-cc-graphics" ]
subfolder = "swgb_cc"
support = "yes"
targetmod = ["swgb-cc", "swgb-cc-graphics"]

[SWGB_CC.mediapaths]
datfile = [ "Game/Data/genie_x1.dat" ]
gamedata = [ "Game/Data/genie_x1.dat" ]
graphics = [ "Game/Data/graphics_x1.drs" ]
language = [ "Game/language_x1.dll" ]
palettes = [ "Game/Data/interfac_x1.drs" ]
sounds = [ "Game/Data/sounds_x1.drs" ]
interface = [ "Game/Data/interfac_x1.drs" ]
terrain = [ "Game/Data/terrain_x1.drs" ]
datfile = ["Game/Data/genie_x1.dat"]
gamedata = ["Game/Data/genie_x1.dat"]
graphics = ["Game/Data/graphics_x1.drs"]
language = ["Game/language_x1.dll"]
palettes = ["Game/Data/interfac_x1.drs"]
sounds = ["Game/Data/sounds_x1.drs"]
interface = ["Game/Data/interfac_x1.drs"]
terrain = ["Game/Data/terrain_x1.drs"]

[SWGB_CC.targetmods]
29 changes: 23 additions & 6 deletions openage/convert/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
from ..util.fslike.wrapper import (DirectoryCreator,
Synchronizer as AccessSynchronizer)
from .service.debug_info import debug_cli_args, debug_game_version, debug_mounts
from .service.init.conversion_required import conversion_required
from .service.init.changelog import check_updates
from .service.init.modpack_search import enumerate_modpacks
from .service.init.mount_asset_dirs import mount_asset_dirs
from .service.init.version_detect import create_version_objects
from .tool.interactive import interactive_browser
from .tool.subtool.acquire_sourcedir import acquire_conversion_source_dir, wanna_convert
from .tool.subtool.acquire_sourcedir import acquire_conversion_source_dir, wanna_convert, \
wanna_check_updates
from .tool.subtool.version_select import get_game_version

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -238,6 +240,16 @@ def init_subparser(cli: ArgumentParser):
"--export-api", action='store_true',
help="Export the openage nyan API definition as a modpack")

cli.add_argument(
"--check-updates", action='store_true',
help="Check if the assets are up to date"
)

cli.add_argument(
"--no-prompts", action='store_false', dest='show_prompts',
help="Disable user prompts"
)


def main(args, error):
""" CLI entry point """
Expand Down Expand Up @@ -268,11 +280,16 @@ def main(args, error):
from ..assets import get_asset_path
outdir = get_asset_path(args.output_dir)

if args.force or wanna_convert() or conversion_required(outdir):
if args.force or (args.show_prompts and wanna_convert()):
convert_assets(outdir, args, srcdir)

else:
print("assets are up to date; no conversion is required.")
print("override with --force.")
if args.check_updates or (args.show_prompts and wanna_check_updates()):
# check if the assets are up to date
modpack_dir = outdir / "converted"
available_modpacks = enumerate_modpacks(modpack_dir, exclude={"engine"})

game_info_dir = args.cfg_dir / "converter" / "games"

check_updates(available_modpacks, game_info_dir)

return 0
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def _get_aoe2_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("aoe2_base", "0.5.1", versionstr="1.0c", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["aoe2_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("aoe2_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023-2023 the openage authors. See copying.md for legal info.
# Copyright 2023-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -40,7 +40,10 @@ def _get_demo_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("trial_base", "0.5.1", versionstr="Trial", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["trial_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("trial_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023-2023 the openage authors. See copying.md for legal info.
# Copyright 2023-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -40,7 +40,10 @@ def _get_aoe1_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("de1_base", "0.5.1", versionstr="1.0a", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["de1_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("de1_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def _get_aoe2_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("de2_base", "0.6.0", versionstr="Update 118476+", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["de2_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("de2_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2023 the openage authors. See copying.md for legal info.
# Copyright 2021-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -40,7 +40,10 @@ def _get_aoe2_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("hd_base", "0.5.1", versionstr="5.8", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["hd_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("hd_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 the openage authors. See copying.md for legal info.
# Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -41,7 +41,10 @@ def _get_aoe1_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("aoe1_base", "0.5.1", versionstr="1.0a", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["aoe1_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("aoe1_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 the openage authors. See copying.md for legal info.
# Copyright 2020-2024 the openage authors. See copying.md for legal info.
#
# pylint: disable=too-few-public-methods

Expand Down Expand Up @@ -40,7 +40,10 @@ def _get_swgb_base(cls, full_data_set: GenieObjectContainer) -> Modpack:

mod_def = modpack.get_info()

mod_def.set_info("swgb_base", "0.5.1", versionstr="1.1-gog4", repo="openage")
targetmod_info = full_data_set.game_version.edition.target_modpacks["swgb_base"]
version = targetmod_info["version"]
versionstr = targetmod_info["versionstr"]
mod_def.set_info("swgb_base", version, versionstr=versionstr, repo="openage")

mod_def.add_include("data/**")

Expand Down
2 changes: 1 addition & 1 deletion openage/convert/service/init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_py_modules(
__init__.py
api_export_required.py
conversion_required.py
changelog.py
modpack_search.py
mount_asset_dirs.py
version_detect.py
Expand Down
49 changes: 49 additions & 0 deletions openage/convert/service/init/changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2024-2024 the openage authors. See copying.md for legal info.

"""
Check for updates in the openage converter modpacks.
"""
from __future__ import annotations
import typing

from itertools import chain

from openage.util.version import SemanticVersion

from ....log import info

from ..init.version_detect import create_version_objects


if typing.TYPE_CHECKING:
from openage.util.fslike.union import UnionPath


def check_updates(available_modpacks: dict[str, str], game_info_dir: UnionPath):
"""
Check if there are updates available for the openage converter modpacks.
:param available_modpacks: Available modpacks and their versions. Modpack names are keys,
versions are values.
:param game_info_dir: The directory containing the game information.
"""
game_editions, game_expansions = create_version_objects(game_info_dir)
for game_def in chain(game_editions, game_expansions):
for targetmod_name, targetmod_def in game_def.target_modpacks.items():
if targetmod_name in available_modpacks:
converter_version = SemanticVersion(targetmod_def["version"])
try:
modpack_version = SemanticVersion(available_modpacks[targetmod_name])

except ValueError:
# Some really old converted modpacks don't use semantic versioning
# these should always be updated
modpack_version = SemanticVersion("0.0.0")

if converter_version > modpack_version:
info(("Modpack %s v%s is outdated: "
"newer version v%s is available"),
targetmod_name, modpack_version, converter_version)

else:
info("Modpack %s v%s is up-to-date", targetmod_name, modpack_version)
Loading

0 comments on commit d09adb0

Please sign in to comment.