forked from ModOrganizer2/modorganizer-basic_games
-
Notifications
You must be signed in to change notification settings - Fork 2
/
game_darkmessiahofmightandmagic.py
47 lines (39 loc) · 1.48 KB
/
game_darkmessiahofmightandmagic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import struct
from pathlib import Path
import mobase
from PyQt6.QtGui import QImage
from ..basic_features import BasicGameSaveGameInfo
from ..basic_game import BasicGame
class DarkMessiahOfMightAndMagicGame(BasicGame):
Name = "Dark Messiah of Might and Magic Support Plugin"
Author = "Holt59"
Version = "0.1.0"
GameName = "Dark Messiah of Might & Magic"
GameShortName = "darkmessiahofmightandmagic"
GameNexusName = "darkmessiahofmightandmagic"
GameNexusId = 628
GameSteamId = 2100
GameBinary = "mm.exe"
GameDataPath = "mm"
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Dark-Messiah-of-Might-&-Magic"
)
GameDocumentsDirectory = "%GAME_PATH%/mm"
GameSavesDirectory = "%GAME_PATH%/mm/SAVE"
GameSaveExtension = "sav"
def _read_save_tga(self, filepath: Path) -> QImage | None:
# Qt TGA reader does not work for TGA, I hope that all files
# have the same format:
with open(
filepath.parent.joinpath(filepath.name.replace(".sav", ".tga")), "rb"
) as fp:
data = fp.read()
_, _, w, h, bpp, _ = struct.unpack("<HHHHBB", data[8:18])
if bpp != 24:
return None
return QImage(data[18:], w, h, QImage.Format.Format_RGB888)
def init(self, organizer: mobase.IOrganizer):
super().init(organizer)
self._register_feature(BasicGameSaveGameInfo(self._read_save_tga))
return True