This commit is contained in:
恍兮惚兮 2024-05-01 19:58:58 +08:00
parent 474eeff4df
commit 262186813c
12 changed files with 319 additions and 24 deletions

View File

@ -4,7 +4,7 @@ from PyQt5.QtWidgets import QWidget, QLabel, QProgressBar
from gui.usefulwidget import getsimpleswitch, getsimplecombobox from gui.usefulwidget import getsimpleswitch, getsimplecombobox
from myutils.config import globalconfig, _TR, static_data from myutils.config import globalconfig, _TR, static_data
from myutils.wrapper import threader from myutils.wrapper import threader
import platform import platform, winsharedutils, sys
from myutils.utils import makehtml from myutils.utils import makehtml
from functools import partial from functools import partial
from myutils.githubupdate import updatemethod, getvesionmethod from myutils.githubupdate import updatemethod, getvesionmethod
@ -12,14 +12,12 @@ from myutils.githubupdate import updatemethod, getvesionmethod
@threader @threader
def getversion(self): def getversion(self):
version = winsharedutils.queryversion(sys.argv[0])
if version is None:
return
versionstring = f"v{version[0]}.{version[1]}.{version[2]}"
self.versiontextsignal.emit( self.versiontextsignal.emit(
("当前版本") ("当前版本") + ":" + versionstring + " " + ("最新版本") + ":" + ("获取中")
+ ":"
+ static_data["version"]
+ " "
+ ("最新版本")
+ ":"
+ ("获取中")
) # ,'',url,url)) ) # ,'',url,url))
_version = getvesionmethod() _version = getvesionmethod()
@ -31,15 +29,14 @@ def getversion(self):
( (
"{}:{} {} {}:{}".format( "{}:{} {} {}:{}".format(
_TR("当前版本"), _TR("当前版本"),
static_data["version"], versionstring,
platform.architecture()[0], platform.architecture()[0],
_TR("最新版本"), _TR("最新版本"),
sversion, sversion,
) )
) )
) # ,'' if static_data["version"]== _version else newcontent,url,'LunaTranslator.zip')) )
if _version is not None and versionstring < _version:
if _version is not None and static_data["version"] < _version:
if globalconfig["autoupdate"]: if globalconfig["autoupdate"]:
updatemethod(_version, self.progresssignal.emit) updatemethod(_version, self.progresssignal.emit)

View File

@ -1,5 +1,4 @@
{ {
"version": "v2.48.0",
"themes": { "themes": {
"dark": [ "dark": [
{ {

View File

@ -1,4 +1,4 @@
import os, sys import os, sys, re
import shutil, json import shutil, json
import subprocess import subprocess
import urllib.request import urllib.request
@ -217,11 +217,12 @@ def buildPlugins():
if __name__ == "__main__": if __name__ == "__main__":
if sys.argv[1] == "loadversion": if sys.argv[1] == "loadversion":
os.chdir(rootDir) os.chdir(rootDir)
with open( with open("plugins/CMakeLists.txt", "r", encoding="utf8") as ff:
"LunaTranslator/files/defaultconfig/static_data.json", "r", encoding="utf8" pattern = r"set\(VERSION_MAJOR\s*(\d+)\s*\)\nset\(VERSION_MINOR\s*(\d+)\s*\)\nset\(VERSION_PATCH\s*(\d+)\s*\)"
) as ff: match = re.findall(pattern, ff.read())[0]
version = json.loads(ff.read())["version"] version_major, version_minor, version_patch = match
print("version=" + version) versionstring = f"v{version_major}.{version_minor}.{version_patch}"
print("version=" + versionstring)
exit() exit()
arch = sys.argv[1] arch = sys.argv[1]
isdebug = len(sys.argv) > 2 and int(sys.argv[2]) isdebug = len(sys.argv) > 2 and int(sys.argv[2])

View File

@ -24,6 +24,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>)
include(libs/libs.cmake) include(libs/libs.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
include(generate_product_version)
set(VERSION_MAJOR 2)
set(VERSION_MINOR 48)
set(VERSION_PATCH 0)
add_subdirectory(exec) add_subdirectory(exec)
add_subdirectory(shareddllproxy) add_subdirectory(shareddllproxy)
add_subdirectory(winrtutils) add_subdirectory(winrtutils)

View File

@ -3,8 +3,17 @@ project(LUNA)
option(PYSTAND_CONSOLE "Build PyStand as a console application." OFF) option(PYSTAND_CONSOLE "Build PyStand as a console application." OFF)
# sources
set(sources PyStand.cpp luna.rc) generate_product_version(
versioninfo
NAME "LunaTranslator"
COMPANY_COPYRIGHT "HIllya51 (C) 2024"
VERSION_MAJOR ${VERSION_MAJOR}
VERSION_MINOR ${VERSION_MINOR}
VERSION_PATCH ${VERSION_PATCH}
)
set(sources PyStand.cpp luna.rc ${versioninfo})
add_executable(LunaTranslator_debug ${sources}) add_executable(LunaTranslator_debug ${sources})
target_compile_definitions(LunaTranslator_debug PRIVATE PYSTAND_CONSOLE) target_compile_definitions(LunaTranslator_debug PRIVATE PYSTAND_CONSOLE)

View File

@ -2,7 +2,17 @@
project(shareddllproxy) project(shareddllproxy)
add_executable(shareddllproxy shareddllproxy.cpp dllinject.cpp ntleas.cpp aspatch.cpp) generate_product_version(
versioninfo
NAME "LunaTranslator shareddllproxy"
COMPANY_COPYRIGHT "HIllya51 (C) 2024"
VERSION_MAJOR ${VERSION_MAJOR}
VERSION_MINOR ${VERSION_MINOR}
VERSION_PATCH ${VERSION_PATCH}
)
add_executable(shareddllproxy shareddllproxy.cpp dllinject.cpp ntleas.cpp aspatch.cpp ${versioninfo})
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
add_library(x64lib magpie.cpp lossless.cpp) add_library(x64lib magpie.cpp lossless.cpp)
target_link_libraries(shareddllproxy x64lib ${Detours}) target_link_libraries(shareddllproxy x64lib ${Detours})

View File

@ -0,0 +1,82 @@
#pragma once
#ifndef PRODUCT_VERSION_MAJOR
#define PRODUCT_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
#endif
#ifndef PRODUCT_VERSION_MINOR
#define PRODUCT_VERSION_MINOR @PRODUCT_VERSION_MINOR@
#endif
#ifndef PRODUCT_VERSION_PATCH
#define PRODUCT_VERSION_PATCH @PRODUCT_VERSION_PATCH@
#endif
#ifndef PRODUCT_VERSION_BUILD
#define PRODUCT_VERSION_BUILD @PRODUCT_VERSION_REVISION@
#endif
#ifndef FILE_VERSION_MAJOR
#define FILE_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
#endif
#ifndef FILE_VERSION_MINOR
#define FILE_VERSION_MINOR @PRODUCT_VERSION_MINOR@
#endif
#ifndef FILE_VERSION_PATCH
#define FILE_VERSION_PATCH @PRODUCT_VERSION_PATCH@
#endif
#ifndef FILE_VERSION_BUILD
#define FILE_VERSION_BUILD @PRODUCT_VERSION_REVISION@
#endif
#ifndef __TO_STRING
#define __TO_STRING_IMPL(x) #x
#define __TO_STRING(x) __TO_STRING_IMPL(x)
#endif
#define PRODUCT_VERSION_MAJOR_MINOR_STR __TO_STRING(PRODUCT_VERSION_MAJOR) "." __TO_STRING(PRODUCT_VERSION_MINOR)
#define PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR PRODUCT_VERSION_MAJOR_MINOR_STR "." __TO_STRING(PRODUCT_VERSION_PATCH)
#define PRODUCT_VERSION_FULL_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(PRODUCT_VERSION_BUILD)
#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,PRODUCT_VERSION_BUILD
#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_FULL_STR "\0"
#define FILE_VERSION_MAJOR_MINOR_STR __TO_STRING(FILE_VERSION_MAJOR) "." __TO_STRING(FILE_VERSION_MINOR)
#define FILE_VERSION_MAJOR_MINOR_PATCH_STR FILE_VERSION_MAJOR_MINOR_STR "." __TO_STRING(FILE_VERSION_PATCH)
#define FILE_VERSION_FULL_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(FILE_VERSION_BUILD)
#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,FILE_VERSION_BUILD
#define FILE_VERSION_RESOURCE_STR FILE_VERSION_FULL_STR "\0"
#ifndef PRODUCT_ICON
#define PRODUCT_ICON "@PRODUCT_ICON@"
#endif
#ifndef PRODUCT_COMMENTS
#define PRODUCT_COMMENTS "@PRODUCT_COMMENTS@\0"
#endif
#ifndef PRODUCT_COMPANY_NAME
#define PRODUCT_COMPANY_NAME "@PRODUCT_COMPANY_NAME@\0"
#endif
#ifndef PRODUCT_COMPANY_COPYRIGHT
#define PRODUCT_COMPANY_COPYRIGHT "@PRODUCT_COMPANY_COPYRIGHT@\0"
#endif
#ifndef PRODUCT_FILE_DESCRIPTION
#define PRODUCT_FILE_DESCRIPTION "@PRODUCT_FILE_DESCRIPTION@\0"
#endif
#ifndef PRODUCT_INTERNAL_NAME
#define PRODUCT_INTERNAL_NAME "@PRODUCT_NAME@\0"
#endif
#ifndef PRODUCT_ORIGINAL_FILENAME
#define PRODUCT_ORIGINAL_FILENAME "@PRODUCT_ORIGINAL_FILENAME@\0"
#endif
#ifndef PRODUCT_BUNDLE
#define PRODUCT_BUNDLE "@PRODUCT_BUNDLE@\0"
#endif

View File

@ -0,0 +1,52 @@
#include "VersionInfo.h"
#if defined(__MINGW64__) || defined(__MINGW32__)
// MinGW-w64, MinGW
#if defined(__has_include) && __has_include(<winres.h>)
#include <winres.h>
#else
#include <afxres.h>
#include <winresrc.h>
#endif
#else
// MSVC, Windows SDK
#include <winres.h>
#endif
//IDI_ICON1 ICON PRODUCT_ICON
//LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILE_VERSION_RESOURCE
PRODUCTVERSION PRODUCT_VERSION_RESOURCE
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000904b0"
BEGIN
VALUE "Comments", PRODUCT_COMMENTS
VALUE "CompanyName", PRODUCT_COMPANY_NAME
VALUE "FileDescription", PRODUCT_FILE_DESCRIPTION
VALUE "FileVersion", FILE_VERSION_RESOURCE_STR
VALUE "InternalName", PRODUCT_INTERNAL_NAME
VALUE "LegalCopyright", PRODUCT_COMPANY_COPYRIGHT
VALUE "OriginalFilename", PRODUCT_ORIGINAL_FILENAME
VALUE "ProductName", PRODUCT_BUNDLE
VALUE "ProductVersion", PRODUCT_VERSION_RESOURCE_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x9, 1200
END
END

View File

@ -0,0 +1,107 @@
include (CMakeParseArguments)
set (GenerateProductVersionCurrentDir ${CMAKE_CURRENT_LIST_DIR})
# generate_product_version() function
#
# This function uses VersionInfo.in template file and VersionResource.rc file
# to generate WIN32 resource with version information and general resource strings.
#
# Usage:
# generate_product_version(
# SomeOutputResourceVariable
# NAME MyGreatProject
# ICON ${PATH_TO_APP_ICON}
# VERSION_MAJOR 2
# VERSION_MINOR 3
# VERSION_PATCH ${BUILD_COUNTER}
# VERSION_REVISION ${BUILD_REVISION}
# )
# where BUILD_COUNTER and BUILD_REVISION could be values from your CI server.
#
# You can use generated resource for your executable targets:
# add_executable(target-name ${target-files} ${SomeOutputResourceVariable})
#
# You can specify resource strings in arguments:
# NAME - name of executable (no defaults, ex: Microsoft Word)
# BUNDLE - bundle (${NAME} is default, ex: Microsoft Office)
# ICON - path to application icon (${CMAKE_SOURCE_DIR}/product.ico by default)
# VERSION_MAJOR - 1 is default
# VERSION_MINOR - 0 is default
# VERSION_PATCH - 0 is default
# VERSION_REVISION - 0 is default
# COMPANY_NAME - your company name (no defaults)
# COMPANY_COPYRIGHT - ${COMPANY_NAME} (C) Copyright ${CURRENT_YEAR} is default
# COMMENTS - ${NAME} v${VERSION_MAJOR}.${VERSION_MINOR} is default
# ORIGINAL_FILENAME - ${NAME} is default
# INTERNAL_NAME - ${NAME} is default
# FILE_DESCRIPTION - ${NAME} is default
function(generate_product_version outfiles)
set (options)
set (oneValueArgs
NAME
BUNDLE
ICON
VERSION_MAJOR
VERSION_MINOR
VERSION_PATCH
VERSION_REVISION
COMPANY_NAME
COMPANY_COPYRIGHT
COMMENTS
ORIGINAL_FILENAME
INTERNAL_NAME
FILE_DESCRIPTION)
set (multiValueArgs)
cmake_parse_arguments(PRODUCT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT PRODUCT_BUNDLE OR "${PRODUCT_BUNDLE}" STREQUAL "")
set(PRODUCT_BUNDLE "${PRODUCT_NAME}")
endif()
if (NOT PRODUCT_ICON OR "${PRODUCT_ICON}" STREQUAL "")
set(PRODUCT_ICON "${CMAKE_SOURCE_DIR}/product.ico")
endif()
if (NOT PRODUCT_VERSION_MAJOR EQUAL 0 AND (NOT PRODUCT_VERSION_MAJOR OR "${PRODUCT_VERSION_MAJOR}" STREQUAL ""))
set(PRODUCT_VERSION_MAJOR 1)
endif()
if (NOT PRODUCT_VERSION_MINOR EQUAL 0 AND (NOT PRODUCT_VERSION_MINOR OR "${PRODUCT_VERSION_MINOR}" STREQUAL ""))
set(PRODUCT_VERSION_MINOR 0)
endif()
if (NOT PRODUCT_VERSION_PATCH EQUAL 0 AND (NOT PRODUCT_VERSION_PATCH OR "${PRODUCT_VERSION_PATCH}" STREQUAL ""))
set(PRODUCT_VERSION_PATCH 0)
endif()
if (NOT PRODUCT_VERSION_REVISION EQUAL 0 AND (NOT PRODUCT_VERSION_REVISION OR "${PRODUCT_VERSION_REVISION}" STREQUAL ""))
set(PRODUCT_VERSION_REVISION 0)
endif()
if (NOT PRODUCT_COMPANY_COPYRIGHT OR "${PRODUCT_COMPANY_COPYRIGHT}" STREQUAL "")
string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y")
set(PRODUCT_COMPANY_COPYRIGHT "${PRODUCT_COMPANY_NAME} (C) Copyright ${PRODUCT_CURRENT_YEAR}")
endif()
if (NOT PRODUCT_COMMENTS OR "${PRODUCT_COMMENTS}" STREQUAL "")
set(PRODUCT_COMMENTS "${PRODUCT_NAME} v${PRODUCT_VERSION_MAJOR}.${PRODUCT_VERSION_MINOR}")
endif()
if (NOT PRODUCT_ORIGINAL_FILENAME OR "${PRODUCT_ORIGINAL_FILENAME}" STREQUAL "")
set(PRODUCT_ORIGINAL_FILENAME "${PRODUCT_NAME}")
endif()
if (NOT PRODUCT_INTERNAL_NAME OR "${PRODUCT_INTERNAL_NAME}" STREQUAL "")
set(PRODUCT_INTERNAL_NAME "${PRODUCT_NAME}")
endif()
if (NOT PRODUCT_FILE_DESCRIPTION OR "${PRODUCT_FILE_DESCRIPTION}" STREQUAL "")
set(PRODUCT_FILE_DESCRIPTION "${PRODUCT_NAME}")
endif()
set (_VersionInfoFile ${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.h)
set (_VersionResourceFile ${CMAKE_CURRENT_BINARY_DIR}/VersionResource.rc)
configure_file(
${GenerateProductVersionCurrentDir}/VersionInfo.in
${_VersionInfoFile}
@ONLY)
configure_file(
${GenerateProductVersionCurrentDir}/VersionResource.rc
${_VersionResourceFile}
COPYONLY)
list(APPEND ${outfiles} ${_VersionInfoFile} ${_VersionResourceFile})
set (${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,14 @@
# Package Information for pkg-config
prefix=@PJSIP_ROOT_DIR_FOR_PKGCONFIG@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/pjlib/include;${prefix}/pjlib-util/include;${prefix}/pjmedia/include;${prefix}/pjnath/include;${prefix}/pjsip/include
Name: LunaHook
Description: Visual Novel Text Hook Engine
URL: https://github.com/HIllya51/LunaHook
Version: @PJSIP_VERSION@
Libs: -L${libdir} -llibpjproject-$$(Platform)-$$(PlatformToolset)-$$(Configuration)-@PJSIP_CRT_LINKAGE@.lib
Libs.private: -lWs2_32.lib
Cflags: -I${includedir}

View File

@ -1,8 +1,16 @@
project(winrtutils) project(winrtutils)
generate_product_version(
versioninfo
NAME "LunaTranslator winrtutils"
COMPANY_COPYRIGHT "HIllya51 (C) 2024"
VERSION_MAJOR ${VERSION_MAJOR}
VERSION_MINOR ${VERSION_MINOR}
VERSION_PATCH ${VERSION_PATCH}
)
add_library(winrtutils MODULE winrtsnapshot.cpp cinterface.cpp dllmain.cpp pch.cpp winrtocr.cpp ) add_library(winrtutils MODULE winrtsnapshot.cpp cinterface.cpp dllmain.cpp pch.cpp winrtocr.cpp ${versioninfo})
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set_target_properties(winrtutils PROPERTIES OUTPUT_NAME "winrtutils64") set_target_properties(winrtutils PROPERTIES OUTPUT_NAME "winrtutils64")

View File

@ -2,7 +2,16 @@
project(winsharedutils) project(winsharedutils)
add_library(winsharedutils MODULE hwnd.cpp darklistener.cpp theme.cpp version.cpp otsu.cpp cinterface.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp maglistener.cpp) generate_product_version(
versioninfo
NAME "LunaTranslator winsharedutils"
COMPANY_COPYRIGHT "HIllya51 (C) 2024"
VERSION_MAJOR ${VERSION_MAJOR}
VERSION_MINOR ${VERSION_MINOR}
VERSION_PATCH ${VERSION_PATCH}
)
add_library(winsharedutils MODULE hwnd.cpp darklistener.cpp theme.cpp version.cpp otsu.cpp cinterface.cpp clipboard.cpp lnk.cpp dllmain.cpp levenshtein.cpp muteprocess.cpp sapi_dll.cpp simplemecab.cpp SimpleBrowser.cpp MWebBrowser.cpp icon.cpp maglistener.cpp ${versioninfo})
target_link_libraries(winsharedutils dwmapi) target_link_libraries(winsharedutils dwmapi)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set_target_properties(winsharedutils PROPERTIES OUTPUT_NAME "winsharedutils64") set_target_properties(winsharedutils PROPERTIES OUTPUT_NAME "winsharedutils64")