Skip to content

Commit c0411a6

Browse files
author
[xct24]
committed
v0.2.2-beta2
1. 修复部分全局变量操作的bug 2. 修正部分截图相关参数
1 parent 248adaf commit c0411a6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
## Version Info
2121
global globalVersion
22-
globalVersion = 'PCRJJCAnalyzer-v0.2.2-beta1'
22+
globalVersion = 'PCRJJCAnalyzer-v0.2.2-beta2'
2323

2424
## PrepareInitialPaths
2525
if not os.path.exists(os.path.join(os.path.expanduser('~'), "PCRJJCAnalyzer")):
@@ -103,9 +103,12 @@ def __init__(self, parent=None, mainGUI=None):
103103
def onOpenConfigFolderButtonClicked(self):
104104
os.startfile(os.path.join(os.path.expanduser('~'), "PCRJJCAnalyzer"))
105105
def onResetSettingsButton(self):
106+
global config_dict
106107
util.config_writeConfig(util.default_dict)
107-
util.loadConfig()
108-
global_logger.info("已重置设定。")
108+
config_dict = util.default_dict
109+
self.customizedApiUrlLineEdit.setDisabled(True)
110+
self.defaultApiUrlRadioButton.setChecked(True)
111+
global_logger.warning("已重置设定。")
109112
def onLoggingLevelDropboxSelect(self, loggingLevel):
110113
if loggingLevel == "Warning":
111114
logging.getLogger().setLevel(logging.WARNING)
@@ -149,7 +152,7 @@ def setApiModeOnClicked(self):
149152
self.customizedApiUrlLineEdit.setDisabled(False)
150153
try:
151154
util.config_writeConfig(config_dict)
152-
util.loadConfig()
155+
util.config_loadConfig()
153156
except Exception as e:
154157
global_logger.exception("Failed to write config", e)
155158
def customizedApirUrlLineEditHandler(self,customizedApiUrl):
@@ -1053,7 +1056,7 @@ def parseChars(self):
10531056
refImage = cv2.imdecode(np.fromfile(refImagePath,dtype=np.uint8),cv2.IMREAD_COLOR) # 读取参考图
10541057
for i in range(len(self.charImageList)):
10551058
charNum = i+1
1056-
charIndex = (util.cv_getIndex(util.cv_getMidPoint(self.charImageList[i], refImage, eval("cv2.%s" % config_dict['algorithm'] )), refImageParams)) # 计算出目标角色在参考图中的坐标位置(行与列)
1059+
charIndex = (util.cv_getIndex(util.cv_getMidPoint(self.charImageList[i], refImage, eval("%s" % config_dict['algorithm'] )), refImageParams)) # 计算出目标角色在参考图中的坐标位置(行与列)
10571060
charName = characterIndexList[charIndex[0]]["unit_name"]
10581061
charId = characterIndexList[(charIndex[0])]["unit_id"]
10591062
self.charDataList[i] = {"name": charName, "id": charId}
@@ -1067,6 +1070,7 @@ def parseChars(self):
10671070

10681071
if __name__ == '__main__':
10691072
# ### CLI测试部分
1073+
global config_dict
10701074
config_dict = util.config_loadConfig()
10711075
refImageParams = util.config_getRefImageParams()
10721076
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
'effectiveMarginOffSet': [0, 32, 42, 0],
3939
'customizedApi': False,
4040
'customizedApiUrl': '',
41-
'algorithm': 'cv.TM_SQDIFF',
41+
'algorithm': 'cv2.TM_SQDIFF',
4242
'matchTemplateParams':
4343
{
4444
'charLocationRatioConfig_CurrentEnemyTeam':
@@ -57,7 +57,7 @@
5757
},
5858
'charLocationRatioConfig_HistoryTeamTwo':
5959
{
60-
'y': 0.4773333333,
60+
'y': 0.49,
6161
'w': 0.058583784,
6262
'h': 0.09,
6363
'x': [0.486625, 0.5571875, 0.628375, 0.69825, 0.7686375]
@@ -71,14 +71,14 @@
7171
},
7272
'charLocationRatioConfig_HistoryTeamOne_WithTitleBanner':
7373
{
74-
'y': 0.29,
74+
'y': 0.50,
7575
'w': 0.058583784,
7676
'h': 0.09,
7777
'x': [0.486625, 0.5571875, 0.628375, 0.69825, 0.7686375]
7878
},
7979
'charLocationRatioConfig_HistoryTeamTwo_WithTitleBanner':
8080
{
81-
'y': 0.483333,
81+
'y': 0.49,
8282
'w': 0.058583784,
8383
'h': 0.09,
8484
'x': [0.486625, 0.5571875, 0.628375, 0.69825, 0.7686375]
@@ -200,7 +200,6 @@ def config_loadConfig():
200200
config_dict = copy.deepcopy(default_dict)
201201
config_file = open(os.path.join(os.path.expanduser('~'), "PCRJJCAnalyzer", "config.json"),'w',encoding='utf-8')
202202
json.dump(config_dict,config_file,ensure_ascii=False)
203-
config_file.close()
204203
return config_dict
205204

206205
def config_loadRefImageParams():
@@ -231,6 +230,7 @@ def config_writeConfig(config_dict):
231230
config_file = open(os.path.join(os.path.expanduser('~'), "PCRJJCAnalyzer", "config.json"),'w',encoding='utf-8')
232231
json.dump(config_dict,config_file,ensure_ascii=False)
233232
config_file.close()
233+
config_loadConfig()
234234
return
235235

236236
# 暂不开放

0 commit comments

Comments
 (0)