mirror of
https://github.com/c9moser/sgbackup.git
synced 2026-01-19 19:40:13 +00:00
2025.01.15 03:49:18
This commit is contained in:
parent
649053bb20
commit
39e9201539
@ -189,7 +189,7 @@ class GameFileMatcher(GObject):
|
|||||||
|
|
||||||
def __init__(self,match_type:GameFileType,match_file:str):
|
def __init__(self,match_type:GameFileType,match_file:str):
|
||||||
GObject.__init__(self)
|
GObject.__init__(self)
|
||||||
self.match_type = type
|
self.match_type = match_type
|
||||||
self.match_file = match_file
|
self.match_file = match_file
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
@ -203,10 +203,10 @@ class GameFileMatcher(GObject):
|
|||||||
return self.__match_type
|
return self.__match_type
|
||||||
|
|
||||||
@match_type.setter
|
@match_type.setter
|
||||||
def match_type(self,type:GameFileType):
|
def match_type(self,match_type:GameFileType):
|
||||||
if not isinstance(type,GameFileType):
|
if not isinstance(match_type,GameFileType):
|
||||||
raise TypeError("match_type is not a GameFileType instance!")
|
raise TypeError("match_type is not a GameFileType instance!")
|
||||||
self.__match_type = type
|
self.__match_type = match_type
|
||||||
|
|
||||||
@Property(type=str)
|
@Property(type=str)
|
||||||
def match_file(self)->str:
|
def match_file(self)->str:
|
||||||
@ -1036,7 +1036,7 @@ class Game(GObject):
|
|||||||
def dbid(self)->str:
|
def dbid(self)->str:
|
||||||
return self.__dbid
|
return self.__dbid
|
||||||
@dbid.setter
|
@dbid.setter
|
||||||
def id(self,id:str):
|
def dbid(self,id:str):
|
||||||
self.__dbid = id
|
self.__dbid = id
|
||||||
|
|
||||||
@Property(type=str)
|
@Property(type=str)
|
||||||
@ -1044,14 +1044,9 @@ class Game(GObject):
|
|||||||
return self.__key
|
return self.__key
|
||||||
@key.setter
|
@key.setter
|
||||||
def key(self,key:str):
|
def key(self,key:str):
|
||||||
set_game = False
|
if self.__key and self.__key != key:
|
||||||
if self.__key in GAMES:
|
self._old_key = self.__key
|
||||||
del GAMES[self.__key]
|
|
||||||
set_game = True
|
|
||||||
|
|
||||||
self.__key = key
|
self.__key = key
|
||||||
if set_game:
|
|
||||||
GAMES[self.__key] = self
|
|
||||||
|
|
||||||
@Property(type=str)
|
@Property(type=str)
|
||||||
def name(self)->str:
|
def name(self)->str:
|
||||||
@ -1300,11 +1295,16 @@ class Game(GObject):
|
|||||||
with open(path,'wt',encoding='utf-8') as ofile:
|
with open(path,'wt',encoding='utf-8') as ofile:
|
||||||
ofile.write(json.dumps(self.serialize(),ensure_ascii=False,indent=4))
|
ofile.write(json.dumps(self.serialize(),ensure_ascii=False,indent=4))
|
||||||
|
|
||||||
|
gm = GameManager.get_global()
|
||||||
|
if hasattr(self,'_old_key'):
|
||||||
|
if self._old_key in gm.games:
|
||||||
|
del gm.games[self._old_key]
|
||||||
|
delattr(self,'_old_key')
|
||||||
|
gm.add_game(self)
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return (bool(self.game_data) and bool(self.savegame_root) and bool(self.savegame_dir))
|
return (bool(self.game_data) and bool(self.savegame_root) and bool(self.savegame_dir))
|
||||||
|
|
||||||
def is_backup_file(self,filename:str):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_backup_files(self)->dict[str:str]|None:
|
def get_backup_files(self)->dict[str:str]|None:
|
||||||
def get_backup_files_recursive(sgroot:pathlib.Path,sgdir:str,subdir:str|None=None):
|
def get_backup_files_recursive(sgroot:pathlib.Path,sgdir:str,subdir:str|None=None):
|
||||||
@ -1339,7 +1339,7 @@ class Game(GObject):
|
|||||||
if not os.path.exists(sgpath):
|
if not os.path.exists(sgpath):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
backup_files = get_backup_files_recursive(sgroot,sgdir)
|
return get_backup_files_recursive(sgroot,sgdir)
|
||||||
|
|
||||||
@Property(type=str)
|
@Property(type=str)
|
||||||
def savegame_subdir(self)->str:
|
def savegame_subdir(self)->str:
|
||||||
|
|||||||
@ -114,51 +114,6 @@ class RegistryKeyData(GObject):
|
|||||||
return bool(self.__regkey)
|
return bool(self.__regkey)
|
||||||
|
|
||||||
|
|
||||||
class GameFileMatcherData(GObject):
|
|
||||||
"""
|
|
||||||
GameFileMatcherData The data for the file matcher.
|
|
||||||
"""
|
|
||||||
def __init__(self,match_type:GameFileType,match_value:str):
|
|
||||||
"""
|
|
||||||
GameFileMatcherData
|
|
||||||
|
|
||||||
:param match_type: The type of the game file matcher.
|
|
||||||
:type match_type: GameFileType
|
|
||||||
:param match_value: The value to match the file.
|
|
||||||
:type match_value: str
|
|
||||||
|
|
||||||
"""
|
|
||||||
GObject.__init__(self)
|
|
||||||
self.match_type = match_type
|
|
||||||
self.match_value = match_value
|
|
||||||
|
|
||||||
@Property
|
|
||||||
def match_type(self)->GameFileType:
|
|
||||||
"""
|
|
||||||
match_type The type of the matcher
|
|
||||||
|
|
||||||
:type: GameFileType
|
|
||||||
"""
|
|
||||||
|
|
||||||
return self.__match_type
|
|
||||||
|
|
||||||
@match_type.setter
|
|
||||||
def match_type(self,type:GameFileType):
|
|
||||||
self.__match_type = type
|
|
||||||
|
|
||||||
@Property(type=str)
|
|
||||||
def match_value(self)->str:
|
|
||||||
"""
|
|
||||||
match_value The value to match files against.
|
|
||||||
|
|
||||||
:type: str
|
|
||||||
"""
|
|
||||||
return self.__match_value
|
|
||||||
|
|
||||||
@match_value.setter
|
|
||||||
def match_value(self,value:str):
|
|
||||||
self.__match_value = value
|
|
||||||
|
|
||||||
class GameFileTypeData(GObject):
|
class GameFileTypeData(GObject):
|
||||||
""" GameFileTypeData The *Gio.Liststore* data for GameFileType *Gtk.DropDown* widgets."""
|
""" GameFileTypeData The *Gio.Liststore* data for GameFileType *Gtk.DropDown* widgets."""
|
||||||
def __init__(self,match_type:GameFileType,name:str):
|
def __init__(self,match_type:GameFileType,name:str):
|
||||||
@ -171,6 +126,8 @@ class GameFileTypeData(GObject):
|
|||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
GObject.__init__(self)
|
GObject.__init__(self)
|
||||||
|
if not isinstance(match_type,GameFileType):
|
||||||
|
raise TypeError("GameFileType")
|
||||||
self.__match_type = match_type
|
self.__match_type = match_type
|
||||||
self.__name = name
|
self.__name = name
|
||||||
|
|
||||||
@ -782,7 +739,7 @@ class GameDialog(Gtk.Dialog):
|
|||||||
widget.add_button.connect('clicked',self._on_filematch_add_button_clicked,widget)
|
widget.add_button.connect('clicked',self._on_filematch_add_button_clicked,widget)
|
||||||
widget.actions.pack_start(widget.add_button)
|
widget.actions.pack_start(widget.add_button)
|
||||||
|
|
||||||
model = Gio.ListStore.new(GameFileMatcherData)
|
model = Gio.ListStore.new(GameFileMatcher)
|
||||||
selection = Gtk.SingleSelection.new(model)
|
selection = Gtk.SingleSelection.new(model)
|
||||||
selection.set_autoselect(False)
|
selection.set_autoselect(False)
|
||||||
selection.set_can_unselect(True)
|
selection.set_can_unselect(True)
|
||||||
@ -920,11 +877,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
#filematch
|
#filematch
|
||||||
fm_model = self.__windows.filematch.columnview.get_model().get_model()
|
fm_model = self.__windows.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.windows.file_matchers:
|
for fm in self.__game.windows.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
im_model = self.__windows.ignorematch.columnview.get_model().get_model()
|
im_model = self.__windows.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.windows.ignore_matchers:
|
for im in self.__game.windows.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
# set lookup regkeys
|
# set lookup regkeys
|
||||||
var_model = self.__windows.variables.columnview.get_model().get_model()
|
var_model = self.__windows.variables.columnview.get_model().get_model()
|
||||||
@ -949,11 +906,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
#filematch
|
#filematch
|
||||||
fm_model = self.__linux.filematch.columnview.get_model().get_model()
|
fm_model = self.__linux.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.linux.file_matchers:
|
for fm in self.__game.linux.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(fm.match_type,fm.match_file))
|
||||||
|
|
||||||
im_model = self.__linux.ignorematch.columnview.get_model().get_model()
|
im_model = self.__linux.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.linux.ignore_matchers:
|
for im in self.__game.linux.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
var_model = self.__linux.variables.columnview.get_model().get_model()
|
var_model = self.__linux.variables.columnview.get_model().get_model()
|
||||||
for name,value in self.__game.linux.variables.items():
|
for name,value in self.__game.linux.variables.items():
|
||||||
@ -967,11 +924,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
#filematch
|
#filematch
|
||||||
fm_model = self.__macos.filematch.columnview.get_model().get_model()
|
fm_model = self.__macos.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.macos.file_matchers:
|
for fm in self.__game.macos.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(fm.match_type,fm.match_file))
|
||||||
|
|
||||||
im_model = self.__macos.ignorematch.columnview.get_model().get_model()
|
im_model = self.__macos.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.macos.ignore_matchers:
|
for im in self.__game.macos.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
var_model = self.__macos.variables.columnview.get_model().get_model()
|
var_model = self.__macos.variables.columnview.get_model().get_model()
|
||||||
for name,value in self.__game.linux.variables.items():
|
for name,value in self.__game.linux.variables.items():
|
||||||
@ -986,11 +943,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
#filematch
|
#filematch
|
||||||
fm_model = self.__steam_windows.filematch.columnview.get_model().get_model()
|
fm_model = self.__steam_windows.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.steam_windows.file_matchers:
|
for fm in self.__game.steam_windows.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(fm.match_type,fm.match_file))
|
||||||
|
|
||||||
im_model = self.__steam_windows.ignorematch.columnview.get_model().get_model()
|
im_model = self.__steam_windows.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.steam_windows.ignore_matchers:
|
for im in self.__game.steam_windows.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
var_model = self.__steam_windows.variables.columnview.get_model().get_model()
|
var_model = self.__steam_windows.variables.columnview.get_model().get_model()
|
||||||
for name,value in self.__game.steam_windows.variables.items():
|
for name,value in self.__game.steam_windows.variables.items():
|
||||||
@ -1004,11 +961,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
|
|
||||||
fm_model = self.__steam_linux.filematch.columnview.get_model().get_model()
|
fm_model = self.__steam_linux.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.steam_linux.file_matchers:
|
for fm in self.__game.steam_linux.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(fm.match_type,fm.match_file))
|
||||||
|
|
||||||
im_model = self.__steam_linux.ignorematch.columnview.get_model().get_model()
|
im_model = self.__steam_linux.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.steam_linux.ignore_matchers:
|
for im in self.__game.steam_linux.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
var_model = self.__steam_linux.variables.columnview.get_model().get_model()
|
var_model = self.__steam_linux.variables.columnview.get_model().get_model()
|
||||||
for name,value in self.__game.steam_linux.variables.items():
|
for name,value in self.__game.steam_linux.variables.items():
|
||||||
@ -1022,11 +979,11 @@ class GameDialog(Gtk.Dialog):
|
|||||||
|
|
||||||
fm_model = self.__steam_macos.filematch.columnview.get_model().get_model()
|
fm_model = self.__steam_macos.filematch.columnview.get_model().get_model()
|
||||||
for fm in self.__game.steam_macos.file_matchers:
|
for fm in self.__game.steam_macos.file_matchers:
|
||||||
fm_model.append(GameFileMatcherData(fm.match_type,fm.match_file))
|
fm_model.append(GameFileMatcher(fm.match_type,fm.match_file))
|
||||||
|
|
||||||
im_model = self.__steam_macos.ignorematch.columnview.get_model().get_model()
|
im_model = self.__steam_macos.ignorematch.columnview.get_model().get_model()
|
||||||
for im in self.__game.steam_macos.ignore_matchers:
|
for im in self.__game.steam_macos.ignore_matchers:
|
||||||
im_model.append(GameFileMatcherData(im.match_type,im.match_file))
|
im_model.append(GameFileMatcher(im.match_type,im.match_file))
|
||||||
|
|
||||||
var_model = self.__steam_macos.variables.columnview.get_model().get_model()
|
var_model = self.__steam_macos.variables.columnview.get_model().get_model()
|
||||||
for name,value in self.__game.steam_macos.variables.items():
|
for name,value in self.__game.steam_macos.variables.items():
|
||||||
@ -1335,7 +1292,7 @@ class GameDialog(Gtk.Dialog):
|
|||||||
|
|
||||||
def _on_filematch_dropdown_selection_changed(self,dropdown,data,item):
|
def _on_filematch_dropdown_selection_changed(self,dropdown,data,item):
|
||||||
data = item.get_item()
|
data = item.get_item()
|
||||||
data.match_type = dropdown.get_selected_item()
|
data.match_type = dropdown.get_selected_item().match_type
|
||||||
|
|
||||||
def _on_filematch_type_dropdown_setup(self,factory,item):
|
def _on_filematch_type_dropdown_setup(self,factory,item):
|
||||||
label = Gtk.Label()
|
label = Gtk.Label()
|
||||||
@ -1418,7 +1375,7 @@ class GameDialog(Gtk.Dialog):
|
|||||||
var_widget.remove_button.set_sensitive(True)
|
var_widget.remove_button.set_sensitive(True)
|
||||||
|
|
||||||
def _on_filematch_add_button_clicked(self,button,widget):
|
def _on_filematch_add_button_clicked(self,button,widget):
|
||||||
widget.columnview.get_model().get_model().append(GameFileMatcherData(GameFileType.GLOB,""))
|
widget.columnview.get_model().get_model().append(GameFileMatcher(GameFileType.GLOB,""))
|
||||||
|
|
||||||
def _on_filematch_value_label_changed(self,label,widget):
|
def _on_filematch_value_label_changed(self,label,widget):
|
||||||
if not label.get_text():
|
if not label.get_text():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user