This commit is contained in:
恍兮惚兮 2024-11-04 00:53:21 +08:00
parent fbb30251c4
commit 0d56af06d8
9 changed files with 49 additions and 62 deletions

3
.gitignore vendored
View File

@ -32,4 +32,5 @@ src/files/themes
src/run37.bat
src/run3732.bat
src/plugins/builds
src/plugins/libs/webview2
src/plugins/libs/webview2
src/plugins/.vscode/settings.json

View File

@ -363,7 +363,6 @@ class lazyscrollflow(ScrollArea):
QApplication.processEvents() # 会在最大化时死锁
except:
print_exc()
break
@trypass
@ -534,7 +533,6 @@ class delayloadvbox(QWidget):
if procevent:
QApplication.processEvents()
except:
print_exc()
break
self.nowvisregion = region
@ -729,6 +727,7 @@ class stackedlist(ScrollArea):
self.scrolled.connect(lambda _: self.doshowlazywidget(True, _))
self.saveregion = QRect()
@trypass
def doshowlazywidget(self, procevent, region: QRect = None):
if region:
self.saveregion = QRect(region)

View File

@ -430,6 +430,7 @@ class TranslatorWindow(resizableframeless):
@threader
def autohidedelaythread(self):
while True:
time.sleep(0.5)
# 当鼠标悬停,或前景窗口为当前进程的其他窗口时,禁止自动隐藏
if self.geometry().contains(QCursor.pos()) or (
windows.GetForegroundWindow() != self.winid
@ -446,7 +447,6 @@ class TranslatorWindow(resizableframeless):
self.hidesignal.emit()
self.autohidestart = False
time.sleep(0.5)
def showhideui(self):
if self._move_drag:

View File

@ -345,6 +345,14 @@ class __uid2gamepath:
uid2gamepath = __uid2gamepath()
# 建立索引,当游戏特别多的时候,节省时间
gamepath2uid_index = {}
for uid in savehook_new_data:
_p = os.path.abspath(savehook_new_data[uid]["gamepath"])
if _p not in gamepath2uid_index:
gamepath2uid_index[_p] = []
gamepath2uid_index[_p].append(uid)
def get_launchpath(uid):
launch = savehook_new_data[uid].get("launchpath", "")
@ -361,19 +369,18 @@ def findgameuidofpath(gamepath, findall=False):
else:
return None, None
gamepath = os.path.normpath(gamepath)
uids = gamepath2uid_index.get(gamepath, [])
if findall:
return uids
collect = []
for sub in savegametaged:
if sub is None:
use = savehook_new_list
else:
use = sub["games"]
for uid in use:
if os.path.abspath(savehook_new_data[uid]["gamepath"]) == gamepath:
if findall:
if uid not in collect:
collect.append(uid)
else:
return uid, use
for uid in uids:
if uid in use:
return uid, use
if findall:
return collect
else:

View File

@ -17,6 +17,7 @@ from myutils.config import (
savehook_new_data,
findgameuidofpath,
getdefaultsavehook,
gamepath2uid_index,
)
import threading, winreg
import re, heapq, winsharedutils
@ -271,9 +272,30 @@ def titlechangedtask(gameuid, title):
trysearchforid(gameuid, [title])
class gamepath2uid_index_helper(dict):
def __init__(self, d, uid):
super.__init__(d)
self.uid = uid
def __setitem__(self, key, value):
if key == "gamepath":
origin = os.path.abspath(self.get(key))
if origin in gamepath2uid_index and self.uid in gamepath2uid_index[origin]:
try:
gamepath2uid_index[origin].remove(self.uid)
except:
pass
absv = os.path.abspath(value)
if absv not in gamepath2uid_index:
gamepath2uid_index[absv] = []
gamepath2uid_index[absv].append(self.uid)
super.__setitem__(key, value)
def initanewitem(title):
uid = f"{time.time()}_{uuid.uuid4()}"
savehook_new_data[uid] = getdefaultsavehook(title)
savehook_new_data[uid] = gamepath2uid_index_helper(getdefaultsavehook(title), uid)
return uid

View File

@ -1,5 +0,0 @@
{
"files.associations": {
"valarray": "cpp"
}
}

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 55)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)

View File

@ -53,10 +53,7 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
}
LocalFree(argvw);
// init: _cwd (current working directory)
wchar_t path[MAX_PATH + 10];
GetCurrentDirectoryW(MAX_PATH + 1, path);
_cwd = path;
// init: _pystand (full path of PyStand.exe)
GetModuleFileNameW(NULL, path, MAX_PATH + 1);
@ -64,57 +61,24 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
wsprintf(path, L"e:\\github\\tools\\pystand\\pystand.exe");
#endif
_pystand = path;
_home = std::filesystem::path(path).parent_path().wstring();
// init: _home
int size = (int)wcslen(path);
for (; size > 0; size--)
{
if (path[size - 1] == L'/')
break;
if (path[size - 1] == L'\\')
break;
}
path[size] = 0;
SetCurrentDirectoryW(path);
GetCurrentDirectoryW(MAX_PATH + 1, path);
_home = path;
SetCurrentDirectoryW(_cwd.c_str());
SetCurrentDirectoryW(_home.c_str());
// init: _runtime (embedded python directory)
bool abspath = false;
if (wcslen(rtp) >= 3)
{
if (rtp[1] == L':')
{
if (rtp[2] == L'/' || rtp[2] == L'\\')
abspath = true;
}
}
if (abspath == false)
{
_runtime = _home + L"\\" + rtp;
}
else
{
_runtime = rtp;
}
GetFullPathNameW(_runtime.c_str(), MAX_PATH + 1, path, NULL);
_runtime = path;
_runtime = (std::filesystem::path(_home) / rtp).wstring();
// check home
std::wstring check = _runtime;
if (!PathFileExistsW(check.c_str()))
if (!PathFileExistsW(_runtime.c_str()))
{
std::wstring msg = L"Missing embedded Python3 in:\n" + check;
std::wstring msg = L"Missing embedded Python3 in:\n" + _runtime;
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
return false;
}
// check python3.dll
std::wstring check2 = _runtime + L"\\python3.dll";
if (!PathFileExistsW(check2.c_str()))
if (!PathFileExistsW((_runtime + L"\\python3.dll").c_str()))
{
std::wstring msg = L"Missing python3.dll in:\r\n" + check;
std::wstring msg = L"Missing python3.dll in:\r\n" + _runtime;
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
return false;
}

View File

@ -33,7 +33,6 @@ protected:
protected:
HINSTANCE _hDLL;
std::wstring _cwd; // current working directory
std::wstring _args; // arguments
std::wstring _pystand; // absolute path of pystand
std::wstring _runtime; // absolute path of embedded python runtime