@@ -22,6 +22,7 @@ class MacroMode(Enum):
2222
2323 LGS = "LGS"
2424 GHUB = "GHUB"
25+ GHUB2 = "GHUB-通用鼠标"
2526
2627class MacroConfigController ():
2728
@@ -56,7 +57,6 @@ def init_ui_data(self) -> None:
5657
5758 for macroMode in MacroMode :
5859 self .view .driversoft .addItem (macroMode .value , userData = macroMode )
59- self .driver_changed ()
6060
6161 for aimMode in AimMode :
6262 self .view .modes .addItem (aimMode .value , userData = aimMode )
@@ -95,6 +95,8 @@ def init_ui_with_config(self):
9595 keyBindings = []
9696 for key in self .config ["keybinds" ]:
9797 modifiers = key .split ("+" )[0 ].split ("," )
98+ if len (modifiers ) == 1 and modifiers [0 ] == "" :
99+ modifiers = []
98100 mouseBtn = key .split ("+" )[- 1 ]
99101 try :
100102 scriptFunc = self .macroFunctions [self .config ["keybinds" ][key ]]
@@ -121,7 +123,10 @@ def save_config(self):
121123
122124 keyBinding_data = self .tablemodel .data .copy ()
123125 keyBinding_data .append (KeyBinding (1 ,self .macroFunctions ["leftbutton" ]))
124- keyBinding_data .append (KeyBinding (2 ,self .macroFunctions ["rightbutton" ]))
126+ rightkey = 2
127+ if self .view .driversoft .currentData () == MacroMode .GHUB2 :
128+ rightkey = 3
129+ keyBinding_data .append (KeyBinding (rightkey ,self .macroFunctions ["rightbutton" ]))
125130
126131 ## render config.lua
127132 result = ""
@@ -195,13 +200,6 @@ def save_config(self):
195200
196201 Settings ().save_config_to_json ()
197202
198- def load_configs (self ,configpath ):
199- config = None
200- with open (configpath , "r" ) as f :
201- config = json .load (f )
202- if config :
203- self .config = config
204-
205203 def load_functions (self , script_file_path : str ) -> str :
206204 with open (script_file_path , "r" ) as f :
207205 scripts = json .load (f )
@@ -245,6 +243,16 @@ def download_driverscript(self):
245243 tempfile .tempdir .replace ("\\ " , "/" )+ "/config.lua" )
246244 with open (save_path , "w" ) as f :
247245 f .write (result )
246+ elif self .view .driversoft .currentData () == MacroMode .GHUB2 :
247+ try :
248+ mainscript = self .macroFunctions ["script" ]
249+ except :
250+ traceback .print_exc ()
251+ return
252+ result = mainscript .openContent .format (
253+ tempfile .tempdir .replace ("\\ " , "/" )+ "/config.lua" )
254+ with open (save_path , "w" ) as f :
255+ f .write (result )
248256
249257 def mode_changed (self ):
250258 self .config ["adsmode" ] = self .view .modes .currentData ().value
@@ -304,6 +312,8 @@ def driver_changed(self):
304312 self .macroFunctions = self .parse_functions_to_model (self .load_functions (Settings ().resource_dir + "lgsscripts.json" ))
305313 if macro == MacroMode .GHUB :
306314 self .macroFunctions = self .parse_functions_to_model (self .load_functions (Settings ().resource_dir + "ghubscripts.json" ))
315+ if macro == MacroMode .GHUB2 :
316+ self .macroFunctions = self .parse_functions_to_model (self .load_functions (Settings ().resource_dir + "ghub2scripts.json" ))
307317 self .load_macro_functions ()
308318
309319 def load_macro_functions (self ):
@@ -352,6 +362,8 @@ def save_macro_script(self,func:MacroFunction,openContent: str,closeContent:str,
352362 save_file = Settings ().resource_dir + "lgsscripts.json"
353363 elif self .view .driversoft .currentData () == MacroMode .GHUB :
354364 save_file = Settings ().resource_dir + "ghubscripts.json"
365+ elif self .view .driversoft .currentData () == MacroMode .GHUB2 :
366+ save_file = Settings ().resource_dir + "ghub2scripts.json"
355367
356368 with open (save_file ,"w" ) as file :
357369 json .dump (result , file , indent = 4 )
0 commit comments