Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Dec 24, 2024
1 parent f982f96 commit 9f038b3
Show file tree
Hide file tree
Showing 70 changed files with 1,773 additions and 1,035 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ cpp/LunaHook/.vscode/settings.json
cpp/LunaHook/scripts/YY-Thunks-1.0.7-Binary.zip
cpp/libs/YY-Thunks
py/LunaTranslator/.vscode/settings.json
py/files/yearsummary/yearsummary.value.js
3 changes: 3 additions & 0 deletions cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,8 @@ namespace ppsspp
{0x88F09F4, {CODEC_UTF16, 0, 0, 0, ULJM05976, "ULJM05976"}},
// オメルタ~沈黙の掟~ THE LEGACY
{0x88861C8, {0, 3, 0, 0, 0, "ULJM06393"}},
{0x8885fd8, {0, 0, 0, 0, 0, "ULJM06393"}},
{0x88ac3a8, {0, 1, 0, 0, 0, "ULJM06393"}},
// L.G.S~新説 封神演義~
{0x888A358, {0, 0, 0, 0, ULJM05943F, "ULJM06131"}}, // NAME+TEXT
{0x88DB214, {0, 0, 0, 0, ULJM05943F, "ULJM06131"}}, // TEXT
Expand All @@ -1534,6 +1536,7 @@ namespace ppsspp
{0x886E094, {0, 0, 0, 0, ULJM06129, "ULJM06129"}}, // name+text
// 十鬼の絆 花結綴り
{0x886E354, {0, 0, 0, 0, ULJM06289, "ULJM06301"}}, // name+text
{0x88f878c, {0, 0, 0, 0, ULJM06289, "ULJM06301"}},
// ティンクル☆くるせいだーす STARLIT BRAVE!!
{0x88A94BC, {0, 4, 0, 0, 0, "ULJS00315"}}, // text
// ティンクル☆くるせいだーす GoGo!
Expand Down
63 changes: 24 additions & 39 deletions cpp/exec/PyStand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ int PyStand::DetectScript()
//---------------------------------------------------------------------
const auto init_script =
LR"(
import sys
import os
import os,functools, locale, sys
PYSTAND = os.environ['PYSTAND']
PYSTAND_HOME = os.environ['PYSTAND_HOME']
PYSTAND_RUNTIME = os.environ['PYSTAND_RUNTIME']
Expand All @@ -253,26 +252,40 @@ def MessageBox(msg, info = 'Message'):
os.MessageBox = MessageBox
#sys.stdout=sys.stderr
sys.path.insert(0, './LunaTranslator')
)"
#ifndef PYSTAND_CONSOLE
LR"(
def fuckwrite(origin, message):
try:
if isinstance(message, str):
code=locale.getpreferredencoding()
origin(message.encode(encoding=code, errors='replace').decode(encoding=code, errors='replace'))
else:
origin(message)
except:
return
import traceback, io
sio = io.StringIO()
traceback.print_exc(file = sio)
os.MessageBox(sio.getvalue(), message)
try:
fd = os.open('CONOUT$', os.O_RDWR | os.O_BINARY)
fp = os.fdopen(fd, 'w')
sys.stdout = fp
sys.stderr = fp
attached = True
sys.stdout.write = functools.partial(fuckwrite,sys.stdout.write)
sys.stderr.write = functools.partial(fuckwrite,sys.stderr.write)
except Exception as e:
try:
fp = open(os.devnull, 'w', errors='ignore') # sometimes FileNotFound Error: [Errno 2]No such file or directory: 'nul'
fp = open(os.devnull, 'w', errors='replace') # sometimes FileNotFound Error: [Errno 2]No such file or directory: 'nul'
sys.stdout = fp
sys.stderr = fp
attached = False
except:
pass
)"
#endif
LR"(
sys.argv = [PYSTAND_SCRIPT] + sys.argv[1:]
text = open(PYSTAND_SCRIPT, 'rb').read()
environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}
Expand Down Expand Up @@ -324,41 +337,13 @@ int main()
{
return 3;
}
#ifndef PYSTAND_CONSOLE
// winmain下的stderr没有任何卵用,对于崩溃时的stderr根本显示不出来,所以还是用控制台来保存log吧
// print cmd无法显示的字符时,如果使用cmd打开,不论debug还是普通,都会error31崩溃。如果双击打开debug,却不会崩溃
// 但因为无法区分是使用cmd打开debug还是双击打开debug,所以干脆都这样吧
if (AttachConsole(ATTACH_PARENT_PROCESS))
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
int fd = _fileno(stdout);
if (fd >= 0)
{
std::string fn = std::to_string(fd);
SetEnvironmentVariableA("PYSTAND_STDOUT", fn.c_str());
}
fd = _fileno(stdin);
if (fd >= 0)
{
std::string fn = std::to_string(fd);
SetEnvironmentVariableA("PYSTAND_STDIN", fn.c_str());
}
}
#else
SetConsoleOutputCP(CP_UTF8);
/*
auto getCurrentTimestamp = []
{
auto now = std::chrono::system_clock::now();
std::time_t now_time_t = std::chrono::system_clock::to_time_t(now);
std::tm now_tm = *std::localtime(&now_time_t);
std::ostringstream oss;
oss << std::put_time(&now_tm, "log_%Y-%m-%d-%H-%M-%S.txt");
return oss.str();
};
auto curr = getCurrentTimestamp();
freopen(curr.c_str(), "a", stderr);
*/
#endif
int hr = ps.RunString(init_script);
return hr;
}
Expand Down
24 changes: 2 additions & 22 deletions cpp/shareddllproxy/Atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,28 +531,8 @@ wchar_t *TranslateFullLog(wchar_t *otext)

struct AtlasConfig atlcfg;

static void writestring(wchar_t *text, HANDLE hPipe)
{
DWORD _;
auto len = text ? (2 * wcslen(text)) : 0;
if (!WriteFile(hPipe, &len, 4, &_, NULL))
return;
if (text)
if (!WriteFile(hPipe, text, len, &_, NULL))
return;
}
static wchar_t *readstring(HANDLE hPipe)
{
DWORD _;
int len;
if (!ReadFile(hPipe, &len, 4, &_, NULL))
return nullptr;
wchar_t *otext = new wchar_t[len / 2 + 1];
if (!ReadFile(hPipe, otext, len, &_, NULL))
return nullptr;
otext[len / 2] = 0;
return otext;
}
void writestring(const wchar_t *text, HANDLE hPipe);
wchar_t *readstring(HANDLE hPipe);
HANDLE mutex = NULL;
int atlaswmain(int argc, wchar_t *argv[])
{
Expand Down
7 changes: 3 additions & 4 deletions cpp/shareddllproxy/eztrans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ std::optional<std::wstring> CTextProcess::eztrans_proc(const std::wstring &input
output = HangulDecode(output);
return output;
}
void writestring(const wchar_t *text, HANDLE hPipe);

int eztrans(int argc, wchar_t *argv[])
{
Expand All @@ -700,12 +701,10 @@ int eztrans(int argc, wchar_t *argv[])
if (!ReadFile(hPipe, buff, 12000, &_, NULL))
break;
auto trans = CTextProcess::eztrans_proc(buff);
std::wstring res;
if (trans)
res = trans.value();
writestring(trans.value().c_str(), hPipe);
else
res = L"translate failed";
WriteFile(hPipe, res.data(), 2 * res.size(), &_, NULL);
writestring(0, hPipe);
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions cpp/shareddllproxy/lec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void SetUpLEC()
RegCloseKey(key);
}
}
static void writestring(wchar_t *text, HANDLE hPipe)
void writestring(const wchar_t *text, HANDLE hPipe)
{
DWORD _;
auto len = text ? (2 * wcslen(text)) : 0;
Expand All @@ -159,7 +159,7 @@ static void writestring(wchar_t *text, HANDLE hPipe)
if (!WriteFile(hPipe, text, len, &_, NULL))
return;
}
static wchar_t *readstring(HANDLE hPipe)
wchar_t *readstring(HANDLE hPipe)
{
DWORD _;
int len;
Expand Down
4 changes: 2 additions & 2 deletions cpp/version.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

set(VERSION_MAJOR 6)
set(VERSION_MINOR 14)
set(VERSION_PATCH 13)
set(VERSION_MINOR 15)
set(VERSION_PATCH 0)
set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
Expand Down
19 changes: 0 additions & 19 deletions py/LunaTranslator/LunaTranslator_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,7 @@ def urlprotocol():
print_exc()


def is64_bit_os():
import ctypes

is64bit = ctypes.c_bool()
handle = ctypes.windll.kernel32.GetCurrentProcess()
success = ctypes.windll.kernel32.IsWow64Process(handle, ctypes.byref(is64bit))
return (success and is64bit).value


def disablestdio():
import platform

if (int(platform.version().split(".")[0]) <= 6) and (not is64_bit_os()):
# win7 32位,有时候print会谜之报错PermissionError WinError 31
sys.stdout = None
sys.stderr = None


if __name__ == "__main__":
disablestdio()
switchdir()
prepareqtenv()
from qtsymbols import QApplication
Expand Down
Loading

0 comments on commit 9f038b3

Please sign in to comment.