Skip to content

Commit 79e10f4

Browse files
committed
updated some comments and adjusted redundencies
2 parents 109daf6 + ab91432 commit 79e10f4

6 files changed

Lines changed: 174 additions & 31 deletions

File tree

games/game_stalker2heartofchornobyl.py

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
from typing import List
1+
import os
22
from enum import IntEnum, auto
3-
from pathlib import Path
4-
from PyQt6.QtCore import QDir, QFileInfo
3+
from typing import List
4+
5+
from PyQt6.QtCore import QDir
56
from PyQt6.QtWidgets import QMainWindow, QTabWidget, QWidget
7+
68
import mobase
7-
import os
9+
10+
from ..basic_features import BasicLocalSavegames, BasicModDataChecker, GlobPatterns
811
from ..basic_game import BasicGame
9-
from ..basic_features import BasicModDataChecker, GlobPatterns, BasicLocalSavegames
1012

1113

1214
class Problems(IntEnum):
1315
"""
1416
Enums for IPluginDiagnose.
1517
"""
18+
<<<<<<< HEAD
19+
=======
20+
21+
# PAK files placed in incorrect locations
22+
>>>>>>> ab91432d429d5ec75630e299423146320437832d
1623
MISPLACED_PAK_FILES = auto()
1724
MISSING_MOD_DIRECTORIES = auto()
1825

@@ -36,7 +43,7 @@ class S2HoCGame(BasicGame, mobase.IPluginFileMapper, mobase.IPluginDiagnose):
3643
GameIniFiles = [
3744
"%GAME_DOCUMENTS%/Saved/Config/Windows/Game.ini",
3845
"%GAME_DOCUMENTS%/Saved/Config/Windows/GameUserSettings.ini",
39-
"%GAME_DOCUMENTS%/Saved/Config/Windows/Engine.ini"
46+
"%GAME_DOCUMENTS%/Saved/Config/Windows/Engine.ini",
4047
]
4148

4249
_main_window: QMainWindow
@@ -66,7 +73,12 @@ def init(self, organizer: mobase.IOrganizer) -> bool:
6673
self._register_feature(
6774
BasicLocalSavegames(QDir(self.resolve_path(self.GameSavesDirectory)))
6875
)
76+
<<<<<<< HEAD
6977

78+
=======
79+
80+
# Create the directory more reliably
81+
>>>>>>> ab91432d429d5ec75630e299423146320437832d
7082
if (
7183
self._organizer.managedGame()
7284
and self._organizer.managedGame().gameName() == self.gameName()
@@ -79,9 +91,17 @@ def init(self, organizer: mobase.IOrganizer) -> bool:
7991
except OSError as e:
8092
self._organizer.log(mobase.LogLevel.ERROR, f"OS error creating mod directory: {e}")
8193
except Exception as e:
94+
<<<<<<< HEAD
8295
self._organizer.log(mobase.LogLevel.ERROR, f"Unexpected error creating mod directory: {e}")
8396

8497
organizer.onUserInterfaceInitialized(self.init_tab)
98+
=======
99+
print(f"Error creating mod directory: {e}")
100+
101+
# Initialize PAK tab when UI is ready
102+
organizer.onUserInterfaceInitialized(self.init_tab)
103+
104+
>>>>>>> ab91432d429d5ec75630e299423146320437832d
85105
return True
86106

87107
def init_tab(self, main_window: QMainWindow):
@@ -99,6 +119,7 @@ def init_tab(self, main_window: QMainWindow):
99119
return
100120

101121
from .stalker2heartofchornobyl.paks import S2HoCPaksTabWidget
122+
102123
self._paks_tab = S2HoCPaksTabWidget(main_window, self._organizer)
103124

104125
tab_widget.addTab(self._paks_tab, "PAK Files")
@@ -108,6 +129,7 @@ def init_tab(self, main_window: QMainWindow):
108129
except Exception as e:
109130
self._organizer.log(mobase.LogLevel.ERROR, f"Error initializing PAK tab: {e}")
110131
import traceback
132+
111133
traceback.print_exc()
112134

113135
def mappings(self) -> List[mobase.Mapping]:
@@ -128,8 +150,9 @@ def mappings(self) -> List[mobase.Mapping]:
128150

129151
def gameDirectory(self) -> QDir:
130152
return QDir(self._gamePath)
131-
153+
132154
def paksDirectory(self) -> QDir:
155+
<<<<<<< HEAD
133156
path = os.path.join(self.gameDirectory().absolutePath(), self.GameDataPath, "Content", "Paks")
134157
return QDir(path)
135158

@@ -149,14 +172,33 @@ def binariesDirectory(self) -> QDir:
149172
path = os.path.join(self.gameDirectory().absolutePath(), self.GameDataPath, "Binaries", "Win64")
150173
return QDir(path)
151174

175+
=======
176+
return QDir(self.gameDirectory().absolutePath() + "/Stalker2/Content/Paks")
177+
178+
def paksModsDirectory(self) -> QDir:
179+
# Use os.path.join for more reliable path construction
180+
path = os.path.join(self.paksDirectory().absolutePath(), "~mods")
181+
return QDir(path)
182+
183+
def logicModsDirectory(self) -> QDir:
184+
# Update path to place LogicMods under Paks
185+
return QDir(
186+
self.gameDirectory().absolutePath() + "/Stalker2/Content/Paks/LogicMods"
187+
)
188+
189+
def binariesDirectory(self) -> QDir:
190+
return QDir(self.gameDirectory().absolutePath() + "/Stalker2/Binaries/Win64")
191+
192+
>>>>>>> ab91432d429d5ec75630e299423146320437832d
152193
def getModMappings(self) -> dict[str, list[str]]:
153194
return {
154195
"Content/Paks/~mods": [self.paksModsDirectory().absolutePath()],
155196
}
156-
197+
157198
def activeProblems(self) -> list[int]:
158199
problems = set()
159200
if self._organizer.managedGame() == self:
201+
<<<<<<< HEAD
160202

161203
mod_path = self.paksModsDirectory().absolutePath()
162204
if not os.path.isdir(mod_path):
@@ -167,9 +209,24 @@ def activeProblems(self) -> list[int]:
167209
mod_info = self._organizer.modList().getMod(mod)
168210
filetree = mod_info.fileTree()
169211

212+
=======
213+
# More reliable directory check using os.path
214+
mod_path = self.paksModsDirectory().absolutePath()
215+
if not os.path.isdir(mod_path):
216+
problems.add(Problems.MISSING_MOD_DIRECTORIES)
217+
print(f"Missing mod directory: {mod_path}")
218+
219+
# Check for misplaced PAK files
220+
for mod in self._organizer.modList().allMods():
221+
mod_info = self._organizer.modList().getMod(mod)
222+
filetree = mod_info.fileTree()
223+
224+
# Check for PAK files at the root level (remove LogicMods paths)
225+
>>>>>>> ab91432d429d5ec75630e299423146320437832d
170226
for entry in filetree:
171-
if entry.name().endswith(('.pak', '.utoc', '.ucas')) and not any(
172-
entry.path().startswith(p) for p in ['Content/Paks/~mods', 'Paks', '~mods']
227+
if entry.name().endswith((".pak", ".utoc", ".ucas")) and not any(
228+
entry.path().startswith(p)
229+
for p in ["Content/Paks/~mods", "Paks", "~mods"]
173230
):
174231
problems.add(Problems.MISPLACED_PAK_FILES)
175232
break
@@ -230,7 +287,7 @@ def __init__(self, patterns: GlobPatterns = GlobPatterns()):
230287
move_patterns = {
231288
"*.pak": "Content/Paks/~mods/",
232289
"*.utoc": "Content/Paks/~mods/",
233-
"*.ucas": "Content/Paks/~mods/"
290+
"*.ucas": "Content/Paks/~mods/",
234291
}
235292
valid_roots = ["Content", "Paks", "~mods"]
236293
base_patterns = GlobPatterns(valid=valid_roots, move=move_patterns)
@@ -239,4 +296,4 @@ def __init__(self, patterns: GlobPatterns = GlobPatterns()):
239296

240297

241298
def createPlugin():
242-
return S2HoCGame()
299+
return S2HoCGame()
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1+
from .paks import S2HoCPaksModel, S2HoCPaksTabWidget, S2HoCPaksView
12

2-
from .paks import S2HoCPaksTabWidget, S2HoCPaksModel, S2HoCPaksView
3-
4-
__all__ = [
5-
"S2HoCPaksTabWidget",
6-
"S2HoCPaksModel",
7-
"S2HoCPaksView"
8-
]
3+
__all__ = ["S2HoCPaksTabWidget", "S2HoCPaksModel", "S2HoCPaksView"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .model import S2HoCPaksModel
2-
from .view import S2HoCPaksView
2+
from .view import S2HoCPaksView
33
from .widget import S2HoCPaksTabWidget
44

5-
__all__ = ["S2HoCPaksTabWidget", "S2HoCPaksModel", "S2HoCPaksView"]
5+
__all__ = ["S2HoCPaksTabWidget", "S2HoCPaksModel", "S2HoCPaksView"]

games/stalker2heartofchornobyl/paks/model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,8 @@ def dropMimeData(
257257
index -= 1
258258

259259
self.set_paks(new_paks)
260-
return True
260+
<<<<<<< HEAD
261+
return True
262+
=======
263+
return False
264+
>>>>>>> ab91432d429d5ec75630e299423146320437832d

games/stalker2heartofchornobyl/paks/view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def dataChanged(
3131
self, topLeft: QModelIndex, bottomRight: QModelIndex, roles: Iterable[int] = ()
3232
):
3333
super().dataChanged(topLeft, bottomRight, roles)
34-
self.repaint()
34+
self.repaint()

0 commit comments

Comments
 (0)