mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-27 15:44:12 +08:00
ui
This commit is contained in:
parent
78c88dae3b
commit
772b39e944
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 5)
|
||||
set(VERSION_MINOR 58)
|
||||
set(VERSION_PATCH 5)
|
||||
set(VERSION_PATCH 6)
|
||||
set(VERSION_REVISION 0)
|
||||
add_definitions(-DVERSION_MAJOR=${VERSION_MAJOR})
|
||||
add_definitions(-DVERSION_MINOR=${VERSION_MINOR})
|
||||
|
@ -18,7 +18,7 @@ When starting embedded translation, garbled text often occurs. Game garbling is
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/luanma.png)
|
||||
|
||||
At this time, you need to activate **Modify Game Font** in the **Embed Settings** and select an appropriate font to display Chinese characters.
|
||||
At this time, you need to activate **Modify Game Font** and select an appropriate font to display Chinese characters.
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/ziti.png)
|
||||
|
||||
@ -26,9 +26,7 @@ After modifying the font, Chinese characters can be displayed correctly:
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/okembed.png)
|
||||
|
||||
However, you may find that the embedded text is in Traditional Chinese, you can uncheck **Convert characters to Traditional/Japanese** in the **Embed Settings**.
|
||||
|
||||
> This is because **for many old Japanese galgames, they use their own built-in shift-jis character set processing and cannot correctly handle Chinese characters. By converting Chinese characters to similar Traditional/Japanese characters, the occurrence of garbled text can be reduced, so it is set to automatically convert Simplified Chinese to Traditional Chinese by default**. If garbled text appears after unchecking this setting, please restore it.
|
||||
For many ancient Japanese galgames, they used their built-in shift ji character set to process Chinese characters correctly. You can try **converting Chinese characters to traditional/Japanese characters** to reduce the occurrence of garbled characters.
|
||||
|
||||
For newer game engines and most English games, Unicode character sets such as utf-8 or utf-16 are generally used (such as **KiriKiri**, **Renpy**, **TyranoScript**, **RPGMakerMV**, etc.), and even if garbled text appears, it is usually a font issue, not a character set issue.
|
||||
|
||||
@ -38,8 +36,6 @@ After unchecking this setting, Simplified Chinese can be displayed correctly. Ho
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/good.png)
|
||||
|
||||
** **
|
||||
|
||||
## Some Other Settings
|
||||
|
||||
1. #### Keep Original Text
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/luanma.png)
|
||||
|
||||
В этом случае вам нужно активировать **изменение шрифта игры** в **настройках встроенного перевода** и выбрать подходящий шрифт для отображения китайских символов.
|
||||
В этот момент вы должны активировать **модификацию шрифта игры** и выбрать правильный шрифт, чтобы показать китайские символы
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/ziti.png)
|
||||
|
||||
@ -26,9 +26,8 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/okembed.png)
|
||||
|
||||
Но вы заметите, что встроенный текст написан на традиционном китайском. Вы можете отключить **преобразование китайских символов в традиционные/японские иероглифы** в **настройках встроенного перевода**.
|
||||
Для многих древних японских galgame, которые обрабатывают свои собственные встроенные наборы символов shift - jis, они не могут правильно обрабатывать китайские символы и могут попытаться **преобразовать китайские иероглифы в обычные / японские иероглифы**, чтобы уменьшить появление хаоса.
|
||||
|
||||
> Это связано с тем, что **многие старые японские галгеи используют собственный набор символов shift-jis, который не может правильно обрабатывать китайские символы. Преобразование китайских иероглифов в похожие традиционные/японские иероглифы может уменьшить количество глифов. Поэтому по умолчанию упрощенные китайские символы автоматически преобразуются в традиционные китайские**. Если после отключения этой настройки возникнут глифы, восстановите эту настройку.
|
||||
Для некоторых новых игровых движков и большинства английских игр обычно используются наборы символов Unicode, такие как utf-8 или utf-16 (например, **KiriKiri**, **Renpy**, **TyranoScript**, **RPGMakerMV** и т.д.). Даже если возникнут глифы, обычно это проблема шрифта, а не набора символов.
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/fanti.png)
|
||||
@ -37,8 +36,6 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/good.png)
|
||||
|
||||
** **
|
||||
|
||||
## Некоторые другие настройки
|
||||
|
||||
1. #### Сохранить оригинальный текст
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/luanma.png)
|
||||
|
||||
这时,你需要在**内嵌设置**中,激活**修改游戏字体**,并选择一个适当的字体,以显示中文字符
|
||||
这时,你需要激活**修改游戏字体**,并选择一个适当的字体,以显示中文字符
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/ziti.png)
|
||||
|
||||
@ -27,9 +27,8 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/okembed.png)
|
||||
|
||||
但会发现内嵌的文字是繁体中文,可以在**内嵌设置**中取消**将汉字转换成繁体/日式汉字**。
|
||||
对于许多古早日本galgame,他们使用自己内置的shift-jis字符集处理,无法正确处理中文字符,可以尝试**将汉字转换成繁体/日式汉字**,减少乱码的出现。
|
||||
|
||||
>这是因为**对于许多古早日本galgame,他们使用自己内置的shift-jis字符集处理,无法正确处理中文字符,通过将汉字翻译转换成型近的繁体/日式汉字,可以减少乱码的出现,因此默认是会自动将简体中文转换成繁体中文的**。如果取消这一设置后乱码,请恢复这一设置。
|
||||
对于一些较新的游戏引擎和大部分英文游戏,一般使用utf-8或utf-16等Unicode字符集(如**KiriKiri**,**Renpy**,**TyranoScript**,**RPGMakerMV**等),即使出现乱码一般也是字体的问题,而不是字符集的问题。
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/fanti.png)
|
||||
@ -38,8 +37,6 @@
|
||||
|
||||
![img](https://image.lunatranslator.org/zh/embed/good.png)
|
||||
|
||||
** **
|
||||
|
||||
## 一些其他设置
|
||||
|
||||
1. #### 保留原文
|
||||
|
@ -2,6 +2,7 @@ import functools, os
|
||||
import gobject
|
||||
from myutils.utils import splitocrtypes
|
||||
from myutils.config import globalconfig, _TR
|
||||
from gui.inputdialog import multicolorset, autoinitdialog
|
||||
from gui.inputdialog import autoinitdialog, autoinitdialog_items
|
||||
from gui.usefulwidget import (
|
||||
yuitsu_switch,
|
||||
@ -11,6 +12,10 @@ from gui.usefulwidget import (
|
||||
listediter,
|
||||
D_getIconButton,
|
||||
auto_select_webview,
|
||||
selectcolor,
|
||||
D_getspinbox,
|
||||
D_getcolorbutton,
|
||||
D_getsimplecombobox,
|
||||
)
|
||||
from gui.setting_display_text import on_not_find_qweb
|
||||
from gui.showword import showdiction
|
||||
@ -38,7 +43,7 @@ def gethiragrid(self):
|
||||
callback=functools.partial(
|
||||
autoinitdialog,
|
||||
self,
|
||||
globalconfig["hirasetting"][name]['args'],
|
||||
globalconfig["hirasetting"][name]["args"],
|
||||
globalconfig["hirasetting"][name]["name"],
|
||||
800,
|
||||
items,
|
||||
@ -141,7 +146,7 @@ def initinternal(self, names):
|
||||
callback=functools.partial(
|
||||
autoinitdialog,
|
||||
self,
|
||||
globalconfig["cishu"][cishu]['args'],
|
||||
globalconfig["cishu"][cishu]["args"],
|
||||
globalconfig["cishu"][cishu]["name"],
|
||||
800,
|
||||
items,
|
||||
@ -164,46 +169,114 @@ def initinternal(self, names):
|
||||
|
||||
def setTabcishu_l(self):
|
||||
|
||||
grids = [
|
||||
[
|
||||
(
|
||||
dict(title="分词器", type="grid", grid=gethiragrid(self)),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
grids_1 = [
|
||||
(
|
||||
dict(title="分词器", type="grid", grid=gethiragrid(self)),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
]
|
||||
offline, online = splitocrtypes(globalconfig["cishu"])
|
||||
grids += [
|
||||
grids2 = [
|
||||
(
|
||||
dict(
|
||||
title="辞书",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=initinternal(self, offline),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=initinternal(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
]
|
||||
grids = [
|
||||
grids_1,
|
||||
grids2,
|
||||
[],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="辞书",
|
||||
title="分词_&&_注音",
|
||||
type="grid",
|
||||
grid=[
|
||||
parent=self,
|
||||
name="fenyinsettings",
|
||||
enable=globalconfig["isshowrawtext"],
|
||||
grid=(
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=initinternal(self, offline),
|
||||
("显示注音"),
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowhira",
|
||||
),
|
||||
"",
|
||||
("颜色"),
|
||||
D_getcolorbutton(
|
||||
globalconfig,
|
||||
"jiamingcolor",
|
||||
callback=lambda: selectcolor(
|
||||
self,
|
||||
globalconfig,
|
||||
"jiamingcolor",
|
||||
self.jiamingcolor_b,
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
name="jiamingcolor_b",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"字体缩放",
|
||||
D_getspinbox(
|
||||
0.05,
|
||||
1,
|
||||
globalconfig,
|
||||
"kanarate",
|
||||
double=True,
|
||||
step=0.05,
|
||||
),
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=initinternal(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
"日语注音方案",
|
||||
D_getsimplecombobox(
|
||||
[
|
||||
"平假名",
|
||||
"片假名",
|
||||
"罗马音",
|
||||
],
|
||||
globalconfig,
|
||||
"hira_vis_type",
|
||||
),
|
||||
"",
|
||||
("语法加亮"),
|
||||
D_getsimpleswitch(globalconfig, "show_fenci"),
|
||||
"",
|
||||
("词性颜色"),
|
||||
D_getIconButton(
|
||||
callback=lambda: multicolorset(self),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
@ -256,7 +329,10 @@ def setTabcishu_l(self):
|
||||
],
|
||||
[
|
||||
"显示引擎",
|
||||
(functools.partial(_createseletengeinecombo_1, self), 0),
|
||||
(
|
||||
functools.partial(_createseletengeinecombo_1, self),
|
||||
0,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
@ -6,7 +6,6 @@ from gui.usefulwidget import (
|
||||
D_getsimplecombobox,
|
||||
makegrid,
|
||||
D_getspinbox,
|
||||
getvboxwidget,
|
||||
D_getIconButton,
|
||||
makesubtab_lazy,
|
||||
makescrollgrid,
|
||||
@ -14,43 +13,7 @@ from gui.usefulwidget import (
|
||||
)
|
||||
|
||||
|
||||
def makescalew(self, lay):
|
||||
|
||||
commonfsgrid = [
|
||||
[
|
||||
("缩放方式", 4),
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
static_data["scalemethods_vis"],
|
||||
globalconfig,
|
||||
"fullscreenmethod_4",
|
||||
static=True,
|
||||
),
|
||||
6,
|
||||
),
|
||||
]
|
||||
]
|
||||
|
||||
losslessgrid = [
|
||||
[
|
||||
("Magpie_路径", 4),
|
||||
(
|
||||
D_getIconButton(
|
||||
callback=lambda: getsomepath1(
|
||||
self,
|
||||
"Magpie_路径",
|
||||
globalconfig,
|
||||
"magpiepath",
|
||||
"Magpie_路径",
|
||||
isdir=True,
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
1,
|
||||
),
|
||||
("", 10),
|
||||
]
|
||||
]
|
||||
def makescalew(self, lay: QVBoxLayout):
|
||||
|
||||
innermagpie = [
|
||||
[
|
||||
@ -351,18 +314,54 @@ def makescalew(self, lay):
|
||||
],
|
||||
]
|
||||
|
||||
vw, vl = getvboxwidget()
|
||||
lay.addWidget(vw)
|
||||
gw, gd = makegrid(commonfsgrid, delay=True)
|
||||
vl.addWidget(gw)
|
||||
tw, td = makesubtab_lazy(
|
||||
["Magpie", "外部缩放软件"],
|
||||
losslessgrid = [
|
||||
[
|
||||
functools.partial(makescrollgrid, innermagpie),
|
||||
functools.partial(makescrollgrid, losslessgrid),
|
||||
("Magpie_路径", 4),
|
||||
(
|
||||
D_getIconButton(
|
||||
callback=lambda: getsomepath1(
|
||||
self,
|
||||
"Magpie_路径",
|
||||
globalconfig,
|
||||
"magpiepath",
|
||||
"Magpie_路径",
|
||||
isdir=True,
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
1,
|
||||
),
|
||||
("", 10),
|
||||
],
|
||||
delay=True,
|
||||
)
|
||||
vl.addWidget(tw)
|
||||
]
|
||||
|
||||
commonfsgrid = [
|
||||
[
|
||||
("缩放方式", 4),
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
static_data["scalemethods_vis"],
|
||||
globalconfig,
|
||||
"fullscreenmethod_4",
|
||||
static=True,
|
||||
),
|
||||
6,
|
||||
),
|
||||
],
|
||||
[
|
||||
(
|
||||
lambda: makesubtab_lazy(
|
||||
["Magpie", "外部缩放软件"],
|
||||
[
|
||||
functools.partial(makescrollgrid, innermagpie),
|
||||
functools.partial(makescrollgrid, losslessgrid),
|
||||
],
|
||||
delay=True,
|
||||
),
|
||||
0,
|
||||
)
|
||||
],
|
||||
]
|
||||
gw, gd = makegrid(commonfsgrid, delay=True)
|
||||
lay.addWidget(gw)
|
||||
gd()
|
||||
td()
|
||||
|
@ -2,11 +2,10 @@ from qtsymbols import *
|
||||
import functools, platform
|
||||
import gobject, os, zipfile
|
||||
from myutils.config import globalconfig, static_data, _TR
|
||||
from gui.inputdialog import multicolorset, autoinitdialog
|
||||
from gui.inputdialog import autoinitdialog
|
||||
from myutils.wrapper import tryprint
|
||||
from myutils.utils import dynamiclink, translate_exits, copytree, getannotatedapiname
|
||||
from gui.usefulwidget import (
|
||||
D_getsimplecombobox,
|
||||
getsimplecombobox,
|
||||
Singleton_close,
|
||||
saveposwindow,
|
||||
@ -332,7 +331,7 @@ def vistranslate_rank(self):
|
||||
("显示顺序"),
|
||||
globalconfig["fix_translate_rank_rank"],
|
||||
isrankeditor=True,
|
||||
namemapfunction=lambda k: _TR(getannotatedapiname(k))
|
||||
namemapfunction=lambda k: _TR(getannotatedapiname(k)),
|
||||
)
|
||||
|
||||
|
||||
@ -459,124 +458,31 @@ def xianshigrid_style(self):
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="",
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
"居中显示",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showatcenter"
|
||||
),
|
||||
"",
|
||||
"收到翻译时才刷新",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "refresh_on_get_trans"
|
||||
),
|
||||
"",
|
||||
"固定翻译显示顺序",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "fix_translate_rank"
|
||||
),
|
||||
D_getIconButton(
|
||||
functools.partial(
|
||||
vistranslate_rank, self
|
||||
),
|
||||
"fa.gear",
|
||||
),
|
||||
],
|
||||
[
|
||||
"显示原文",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowrawtext",
|
||||
callback=lambda x: __changeuibuttonstate(
|
||||
self, x
|
||||
),
|
||||
name="show_original_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"显示错误信息",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showtranexception"
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
"居中显示",
|
||||
D_getsimpleswitch(globalconfig, "showatcenter"),
|
||||
"",
|
||||
"收到翻译时才刷新",
|
||||
D_getsimpleswitch(globalconfig, "refresh_on_get_trans"),
|
||||
"",
|
||||
"固定翻译显示顺序",
|
||||
D_getsimpleswitch(globalconfig, "fix_translate_rank"),
|
||||
D_getIconButton(
|
||||
functools.partial(vistranslate_rank, self),
|
||||
"fa.gear",
|
||||
),
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="分词",
|
||||
type="grid",
|
||||
parent=self,
|
||||
name="fenyinsettings",
|
||||
enable=globalconfig["isshowrawtext"],
|
||||
grid=(
|
||||
[
|
||||
("显示注音"),
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowhira",
|
||||
),
|
||||
"",
|
||||
("颜色"),
|
||||
D_getcolorbutton(
|
||||
globalconfig,
|
||||
"jiamingcolor",
|
||||
callback=lambda: selectcolor(
|
||||
self,
|
||||
globalconfig,
|
||||
"jiamingcolor",
|
||||
self.jiamingcolor_b,
|
||||
),
|
||||
name="jiamingcolor_b",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"字体缩放",
|
||||
D_getspinbox(
|
||||
0.05,
|
||||
1,
|
||||
globalconfig,
|
||||
"kanarate",
|
||||
double=True,
|
||||
step=0.05,
|
||||
),
|
||||
],
|
||||
[
|
||||
"日语注音方案",
|
||||
D_getsimplecombobox(
|
||||
[
|
||||
"平假名",
|
||||
"片假名",
|
||||
"罗马音",
|
||||
],
|
||||
globalconfig,
|
||||
"hira_vis_type",
|
||||
),
|
||||
"",
|
||||
("语法加亮"),
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "show_fenci"
|
||||
),
|
||||
"",
|
||||
("词性颜色"),
|
||||
D_getIconButton(
|
||||
callback=lambda: multicolorset(self),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
"显示原文",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"isshowrawtext",
|
||||
callback=lambda x: __changeuibuttonstate(self, x),
|
||||
name="show_original_switch",
|
||||
parent=self,
|
||||
),
|
||||
"",
|
||||
"显示错误信息",
|
||||
D_getsimpleswitch(globalconfig, "showtranexception"),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -152,13 +152,8 @@ def makeproxytab():
|
||||
],
|
||||
delay=True,
|
||||
)
|
||||
group = LGroupBox()
|
||||
group.setTitle("使用代理的项目")
|
||||
l = QVBoxLayout()
|
||||
group.setLayout(l)
|
||||
l.addWidget(tab)
|
||||
dotab()
|
||||
return group
|
||||
return tab
|
||||
|
||||
|
||||
def setTab_proxy(self, l):
|
||||
@ -224,6 +219,18 @@ def setTab_proxy(self, l):
|
||||
(functools.partial(createproxyedit, self), 5),
|
||||
(functools.partial(createproxyedit_check, self), 5),
|
||||
],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="使用代理的项目",
|
||||
type="grid",
|
||||
grid=[
|
||||
[(makeproxytab, -1)],
|
||||
],
|
||||
),
|
||||
|
@ -1,7 +1,7 @@
|
||||
from qtsymbols import *
|
||||
import functools, os, json
|
||||
import windows, gobject
|
||||
from myutils.utils import translate_exits, getannotatedapiname, sortAwithB
|
||||
from myutils.utils import translate_exits, getannotatedapiname
|
||||
from myutils.config import (
|
||||
globalconfig,
|
||||
_TR,
|
||||
@ -14,7 +14,7 @@ from myutils.config import (
|
||||
from traceback import print_exc
|
||||
from gui.pretransfile import sqlite2json2
|
||||
from gui.codeacceptdialog import codeacceptdialog
|
||||
from gui.setting_textinput_ocr import getocrgrid
|
||||
from gui.setting_textinput_ocr import getocrgrid_table
|
||||
from gui.dialog_savedgame import dialog_savedgame_integrated
|
||||
from gui.usefulwidget import (
|
||||
D_getsimplecombobox,
|
||||
@ -24,7 +24,6 @@ from gui.usefulwidget import (
|
||||
makegrid,
|
||||
listediter,
|
||||
yuitsu_switch,
|
||||
getvboxwidget,
|
||||
D_getsimpleswitch,
|
||||
makesubtab_lazy,
|
||||
makescrollgrid,
|
||||
@ -53,228 +52,7 @@ def __create2(self):
|
||||
return self.selecthookbutton
|
||||
|
||||
|
||||
def gethookgrid(self):
|
||||
|
||||
grids = [
|
||||
[
|
||||
"选择游戏",
|
||||
functools.partial(__create, self),
|
||||
"",
|
||||
"选择文本",
|
||||
functools.partial(__create2, self),
|
||||
"",
|
||||
"游戏管理",
|
||||
D_getIconButton(
|
||||
lambda: dialog_savedgame_integrated(self),
|
||||
icon="fa.gamepad",
|
||||
),
|
||||
],
|
||||
[],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="默认设置",
|
||||
type="grid",
|
||||
grid=(
|
||||
[
|
||||
"代码页",
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
static_data["codepage_display"],
|
||||
globalconfig,
|
||||
"codepage_index",
|
||||
lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
4,
|
||||
),
|
||||
],
|
||||
[
|
||||
"刷新延迟_(ms)",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
10000,
|
||||
globalconfig,
|
||||
"textthreaddelay",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"最大缓冲区长度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000000,
|
||||
globalconfig,
|
||||
"maxBufferSize",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"最大缓存文本长度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000000000,
|
||||
globalconfig,
|
||||
"maxHistorySize",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"过滤包含乱码的文本行",
|
||||
D_getsimpleswitch(globalconfig, "filter_chaos_code"),
|
||||
D_getIconButton(
|
||||
icon="fa.gear",
|
||||
callback=lambda: codeacceptdialog(self),
|
||||
),
|
||||
],
|
||||
[
|
||||
"使用YAPI注入",
|
||||
D_getsimpleswitch(globalconfig, "use_yapi"),
|
||||
],
|
||||
),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
]
|
||||
|
||||
return grids
|
||||
|
||||
|
||||
def doexportchspatch(exe, gameuid):
|
||||
|
||||
b = windows.GetBinaryType(exe)
|
||||
is64 = b == 6
|
||||
arch = ["32", "64"][is64]
|
||||
|
||||
dllhook = os.path.abspath("./files/plugins/LunaHook/LunaHook{}.dll".format(arch))
|
||||
dllhost = os.path.abspath(
|
||||
"./files/plugins/LunaHook/LunaHost{}.dll".format(arch, arch)
|
||||
)
|
||||
runner = os.path.abspath("./files/plugins/shareddllproxy{}.exe".format(arch))
|
||||
|
||||
windows.CopyFile(
|
||||
dllhook, os.path.join(os.path.dirname(exe), os.path.basename(dllhook)), False
|
||||
)
|
||||
windows.CopyFile(
|
||||
dllhost, os.path.join(os.path.dirname(exe), os.path.basename(dllhost)), False
|
||||
)
|
||||
windows.CopyFile(runner, os.path.join(os.path.dirname(exe), "LunaPatch.exe"), False)
|
||||
|
||||
embedconfig = {
|
||||
"translation_file": "translation.json",
|
||||
"target_exe": os.path.basename(exe),
|
||||
"target_exe2": os.path.basename(exe),
|
||||
"startup_argument": None,
|
||||
"inject_timeout": 1000,
|
||||
"embedhook": savehook_new_data[gameuid]["embedablehook"],
|
||||
"embedsettings": globalconfig["embedded"],
|
||||
}
|
||||
with open(
|
||||
os.path.join(os.path.dirname(exe), "LunaPatch.json"), "w", encoding="utf8"
|
||||
) as ff:
|
||||
ff.write(json.dumps(embedconfig, ensure_ascii=False, indent=4))
|
||||
|
||||
|
||||
def selectgameuid(self):
|
||||
|
||||
dialog = LDialog(self, Qt.WindowType.WindowCloseButtonHint) # 自定义一个dialog
|
||||
dialog.setWindowTitle("选择游戏")
|
||||
dialog.resize(QSize(800, 10))
|
||||
formLayout = LFormLayout(dialog)
|
||||
dialog.setLayout(formLayout)
|
||||
|
||||
combo = FocusCombo()
|
||||
combo.addItems([savehook_new_data[_]["title"] for _ in savehook_new_list])
|
||||
|
||||
formLayout.addRow("选择游戏", combo)
|
||||
|
||||
button = QDialogButtonBox(
|
||||
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
)
|
||||
formLayout.addRow(button)
|
||||
button.rejected.connect(dialog.close)
|
||||
button.accepted.connect(dialog.accept)
|
||||
button.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||
button.button(QDialogButtonBox.StandardButton.Cancel).setText(_TR("取消"))
|
||||
if dialog.exec():
|
||||
return savehook_new_list[combo.currentIndex()]
|
||||
|
||||
|
||||
def exportchspatch(self):
|
||||
gameuid = selectgameuid(self)
|
||||
if gameuid is None:
|
||||
return
|
||||
exe = get_launchpath(gameuid)
|
||||
if exe.lower().endswith(".exe") == False:
|
||||
f = QFileDialog.getOpenFileName(
|
||||
self, caption=_TR("选择EXE文件"), filter="*.exe"
|
||||
)
|
||||
exe = f[0]
|
||||
if exe == "":
|
||||
return
|
||||
exe = os.path.normpath(exe)
|
||||
doexportchspatch(exe, gameuid)
|
||||
|
||||
f = QFileDialog.getOpenFileName(
|
||||
self,
|
||||
caption=_TR("选择预翻译文件"),
|
||||
directory="translation_record",
|
||||
filter="*.sqlite",
|
||||
)
|
||||
sqlfname_all = f[0]
|
||||
if not sqlfname_all:
|
||||
return
|
||||
sqlite2json2(
|
||||
self,
|
||||
sqlfname_all,
|
||||
os.path.join(os.path.dirname(exe), "translation.json"),
|
||||
existsmerge=True,
|
||||
isforembed=True,
|
||||
)
|
||||
|
||||
|
||||
def creategamefont_comboBox():
|
||||
|
||||
gamefont_comboBox = FocusFontCombo()
|
||||
|
||||
def callback(x):
|
||||
globalconfig["embedded"].__setitem__("changefont_font", x)
|
||||
try:
|
||||
gobject.baseobject.textsource.flashembedsettings()
|
||||
except:
|
||||
pass
|
||||
|
||||
gamefont_comboBox.currentTextChanged.connect(callback)
|
||||
gamefont_comboBox.setCurrentFont(QFont(globalconfig["embedded"]["changefont_font"]))
|
||||
return gamefont_comboBox
|
||||
|
||||
|
||||
def loadvalidtss():
|
||||
|
||||
alltransvis = []
|
||||
alltrans = []
|
||||
for x in globalconfig["fanyi"]:
|
||||
if x == "premt":
|
||||
continue
|
||||
if not translate_exits(x):
|
||||
continue
|
||||
alltransvis.append(getannotatedapiname(x))
|
||||
alltrans.append(x)
|
||||
sortAwithB(alltransvis, alltrans)
|
||||
return alltrans, alltransvis
|
||||
|
||||
|
||||
def gethookembedgrid(self):
|
||||
def gethookgrid_em(self):
|
||||
alltrans, alltransvis = loadvalidtss()
|
||||
grids = [
|
||||
[
|
||||
@ -286,7 +64,6 @@ def gethookembedgrid(self):
|
||||
"",
|
||||
"",
|
||||
],
|
||||
[],
|
||||
[
|
||||
"保留原文",
|
||||
D_getsimpleswitch(
|
||||
@ -325,7 +102,12 @@ def gethookembedgrid(self):
|
||||
[
|
||||
"限制每行字数",
|
||||
D_getsimpleswitch(globalconfig["embedded"], "limittextlength_use"),
|
||||
D_getspinbox(0, 1000, globalconfig["embedded"], "limittextlength_length"),
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000,
|
||||
globalconfig["embedded"],
|
||||
"limittextlength_length",
|
||||
),
|
||||
],
|
||||
[
|
||||
"修改游戏字体",
|
||||
@ -336,7 +118,6 @@ def gethookembedgrid(self):
|
||||
),
|
||||
creategamefont_comboBox,
|
||||
],
|
||||
[],
|
||||
[
|
||||
"内嵌安全性检查",
|
||||
D_getsimpleswitch(globalconfig["embedded"], "safecheck_use"),
|
||||
@ -355,6 +136,213 @@ def gethookembedgrid(self):
|
||||
return grids
|
||||
|
||||
|
||||
def gethookgrid(self):
|
||||
grids = [
|
||||
[
|
||||
"代码页",
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
static_data["codepage_display"],
|
||||
globalconfig,
|
||||
"codepage_index",
|
||||
lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
"",
|
||||
"",
|
||||
],
|
||||
[
|
||||
"刷新延迟_(ms)",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
10000,
|
||||
globalconfig,
|
||||
"textthreaddelay",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"最大缓冲区长度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000000,
|
||||
globalconfig,
|
||||
"maxBufferSize",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"最大缓存文本长度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000000000,
|
||||
globalconfig,
|
||||
"maxHistorySize",
|
||||
callback=lambda x: gobject.baseobject.textsource.setsettings(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"过滤包含乱码的文本行",
|
||||
D_getsimpleswitch(globalconfig, "filter_chaos_code"),
|
||||
D_getIconButton(
|
||||
icon="fa.gear",
|
||||
callback=lambda: codeacceptdialog(self),
|
||||
),
|
||||
],
|
||||
[
|
||||
"使用YAPI注入",
|
||||
D_getsimpleswitch(globalconfig, "use_yapi"),
|
||||
],
|
||||
]
|
||||
|
||||
return grids
|
||||
|
||||
|
||||
def doexportchspatch(exe, gameuid):
|
||||
|
||||
b = windows.GetBinaryType(exe)
|
||||
is64 = b == 6
|
||||
arch = ["32", "64"][is64]
|
||||
|
||||
dllhook = os.path.abspath("./files/plugins/LunaHook/LunaHook{}.dll".format(arch))
|
||||
dllhost = os.path.abspath(
|
||||
"./files/plugins/LunaHook/LunaHost{}.dll".format(arch, arch)
|
||||
)
|
||||
runner = os.path.abspath("./files/plugins/shareddllproxy{}.exe".format(arch))
|
||||
|
||||
windows.CopyFile(
|
||||
dllhook, os.path.join(os.path.dirname(exe), os.path.basename(dllhook)), False
|
||||
)
|
||||
windows.CopyFile(
|
||||
dllhost, os.path.join(os.path.dirname(exe), os.path.basename(dllhost)), False
|
||||
)
|
||||
windows.CopyFile(runner, os.path.join(os.path.dirname(exe), "LunaPatch.exe"), False)
|
||||
|
||||
embedconfig = {
|
||||
"translation_file": "translation.json",
|
||||
"target_exe": os.path.basename(exe),
|
||||
"target_exe2": os.path.basename(exe),
|
||||
"startup_argument": None,
|
||||
"inject_timeout": 1000,
|
||||
"embedhook": savehook_new_data[gameuid]["embedablehook"],
|
||||
"embedsettings": globalconfig["embedded"],
|
||||
}
|
||||
try:
|
||||
with open(
|
||||
os.path.join(os.path.dirname(exe), "LunaPatch.json"), "w", encoding="utf8"
|
||||
) as ff:
|
||||
ff.write(json.dumps(embedconfig, ensure_ascii=False, indent=4))
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def selectgameuid(self):
|
||||
|
||||
dialog = LDialog(self, Qt.WindowType.WindowCloseButtonHint) # 自定义一个dialog
|
||||
dialog.setWindowTitle("选择游戏")
|
||||
dialog.resize(QSize(800, 10))
|
||||
formLayout = LFormLayout(dialog)
|
||||
dialog.setLayout(formLayout)
|
||||
_internal = []
|
||||
_vis = []
|
||||
for gameuid in savehook_new_list:
|
||||
if not savehook_new_data[gameuid]["embedablehook"]:
|
||||
continue
|
||||
exe = get_launchpath(gameuid)
|
||||
if not exe.lower().endswith(".exe"):
|
||||
continue
|
||||
if not os.path.exists(exe):
|
||||
continue
|
||||
_vis.append(savehook_new_data[gameuid]["title"])
|
||||
_internal.append(gameuid)
|
||||
|
||||
combo = FocusCombo()
|
||||
combo.addItems(_vis)
|
||||
|
||||
formLayout.addRow("选择游戏", combo)
|
||||
|
||||
button = QDialogButtonBox(
|
||||
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
)
|
||||
formLayout.addRow(button)
|
||||
button.rejected.connect(dialog.close)
|
||||
button.accepted.connect(dialog.accept)
|
||||
button.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||
button.button(QDialogButtonBox.StandardButton.Cancel).setText(_TR("取消"))
|
||||
if dialog.exec():
|
||||
return _internal[combo.currentIndex()]
|
||||
|
||||
|
||||
def exportchspatch(self):
|
||||
gameuid = selectgameuid(self)
|
||||
if gameuid is None:
|
||||
return
|
||||
exe = get_launchpath(gameuid)
|
||||
doexportchspatch(exe, gameuid)
|
||||
|
||||
f = QFileDialog.getOpenFileName(
|
||||
self,
|
||||
caption=_TR("选择预翻译文件"),
|
||||
directory="translation_record",
|
||||
filter="*.sqlite",
|
||||
)
|
||||
sqlfname_all = f[0]
|
||||
if not sqlfname_all:
|
||||
return
|
||||
sqlite2json2(
|
||||
self,
|
||||
sqlfname_all,
|
||||
os.path.join(os.path.dirname(exe), "translation.json"),
|
||||
existsmerge=True,
|
||||
isforembed=True,
|
||||
)
|
||||
|
||||
|
||||
def creategamefont_comboBox():
|
||||
|
||||
gamefont_comboBox = FocusFontCombo()
|
||||
|
||||
def callback(x):
|
||||
globalconfig["embedded"].__setitem__("changefont_font", x)
|
||||
try:
|
||||
gobject.baseobject.textsource.flashembedsettings()
|
||||
except:
|
||||
pass
|
||||
|
||||
gamefont_comboBox.currentTextChanged.connect(callback)
|
||||
gamefont_comboBox.setCurrentFont(QFont(globalconfig["embedded"]["changefont_font"]))
|
||||
return gamefont_comboBox
|
||||
|
||||
|
||||
def sortAwithB(l1, l2):
|
||||
sorted_pairs = sorted(zip(l1, l2))
|
||||
return [x[1] for x in sorted_pairs], [x[0] for x in sorted_pairs]
|
||||
|
||||
|
||||
def loadvalidtss():
|
||||
|
||||
alltransvis = []
|
||||
alltrans = []
|
||||
for x in globalconfig["fanyi"]:
|
||||
if x == "premt":
|
||||
continue
|
||||
if not translate_exits(x):
|
||||
continue
|
||||
alltransvis.append(getannotatedapiname(x))
|
||||
alltrans.append(x)
|
||||
return sortAwithB(alltransvis, alltrans)
|
||||
|
||||
|
||||
def getTabclip(self):
|
||||
|
||||
grids = [
|
||||
@ -486,7 +474,7 @@ def filetranslate(self):
|
||||
100000,
|
||||
globalconfig,
|
||||
"livecaptions_delay",
|
||||
),
|
||||
),
|
||||
],
|
||||
[
|
||||
"最长等待时间_(ms)",
|
||||
@ -495,7 +483,7 @@ def filetranslate(self):
|
||||
100000,
|
||||
globalconfig,
|
||||
"livecaptions_maxwait",
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
@ -547,7 +535,6 @@ def outputgrid(self):
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
@ -614,7 +601,42 @@ def setTablanglz():
|
||||
]
|
||||
|
||||
|
||||
def setTabOne_lazy(self, basel):
|
||||
def setTabOne_lazy_h(self, basel: QVBoxLayout):
|
||||
grids = [
|
||||
[
|
||||
"选择游戏",
|
||||
functools.partial(__create, self),
|
||||
"",
|
||||
"选择文本",
|
||||
functools.partial(__create2, self),
|
||||
"",
|
||||
"游戏管理",
|
||||
D_getIconButton(
|
||||
lambda: dialog_savedgame_integrated(self),
|
||||
icon="fa.gamepad",
|
||||
),
|
||||
"",
|
||||
],
|
||||
[
|
||||
(
|
||||
lambda: makesubtab_lazy(
|
||||
["默认设置", "内嵌翻译"],
|
||||
[
|
||||
lambda l: makescrollgrid(gethookgrid(self), l),
|
||||
lambda l: makescrollgrid(gethookgrid_em(self), l),
|
||||
],
|
||||
delay=True,
|
||||
),
|
||||
0,
|
||||
)
|
||||
],
|
||||
]
|
||||
gridlayoutwidget, do = makegrid(grids, delay=True)
|
||||
basel.addWidget(gridlayoutwidget)
|
||||
do()
|
||||
|
||||
|
||||
def setTabOne_lazy(self, basel: QVBoxLayout):
|
||||
_rank = [
|
||||
("texthook", "HOOK"),
|
||||
("ocr", "OCR"),
|
||||
@ -657,22 +679,19 @@ def setTabOne_lazy(self, basel):
|
||||
),
|
||||
],
|
||||
]
|
||||
vw, vl = getvboxwidget()
|
||||
basel.addWidget(vw)
|
||||
gridlayoutwidget, do = makegrid(tab1grids, delay=True)
|
||||
vl.addWidget(gridlayoutwidget)
|
||||
basel.addWidget(gridlayoutwidget)
|
||||
tab, dotab = makesubtab_lazy(
|
||||
["HOOK设置", "OCR设置", "剪贴板", "内嵌翻译", "文本输出", "其他"],
|
||||
["HOOK设置", "OCR设置", "剪贴板", "文本输出", "其他"],
|
||||
[
|
||||
lambda l: makescrollgrid(gethookgrid(self), l),
|
||||
lambda l: makescrollgrid(getocrgrid(self), l),
|
||||
lambda l: setTabOne_lazy_h(self, l),
|
||||
lambda l: getocrgrid_table(self, l),
|
||||
lambda l: makescrollgrid(getTabclip(self), l),
|
||||
lambda l: makescrollgrid(gethookembedgrid(self), l),
|
||||
lambda l: makescrollgrid(outputgrid(self), l),
|
||||
lambda l: makescrollgrid(filetranslate(self), l),
|
||||
],
|
||||
delay=True,
|
||||
)
|
||||
vl.addWidget(tab)
|
||||
basel.addWidget(tab)
|
||||
do()
|
||||
dotab()
|
||||
|
@ -20,6 +20,9 @@ from gui.usefulwidget import (
|
||||
LStandardItemModel,
|
||||
SuperCombo,
|
||||
threebuttons,
|
||||
makesubtab_lazy,
|
||||
makescrollgrid,
|
||||
makegrid,
|
||||
)
|
||||
import gobject, qtawesome
|
||||
from gui.dynalang import LFormLayout, LDialog, LAction
|
||||
@ -380,43 +383,16 @@ class showocrimage(saveposwindow):
|
||||
self.originlabel.showboxtext(result.get("box"), result.get("text"))
|
||||
|
||||
|
||||
def getocrgrid(self):
|
||||
|
||||
grids = []
|
||||
|
||||
def internal(self):
|
||||
offline, online = splitocrtypes(globalconfig["ocr"])
|
||||
self.ocrswitchs = {}
|
||||
|
||||
grids += [
|
||||
engines = [
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="引擎",
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="离线",
|
||||
type="grid",
|
||||
grid=initgridsources(self, offline),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=initgridsources(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
],
|
||||
grid=initgridsources(self, offline),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
@ -425,170 +401,176 @@ def getocrgrid(self):
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="在线",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"识别方向",
|
||||
D_getsimplecombobox(
|
||||
["横向", "竖向", "自适应"], globalconfig, "verticalocr"
|
||||
),
|
||||
"",
|
||||
D_getIconButton(
|
||||
gobject.baseobject.createshowocrimage,
|
||||
icon="fa.picture-o",
|
||||
),
|
||||
"",
|
||||
"",
|
||||
]
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="后处理",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
(("合并多行识别结果"), 12),
|
||||
D_getsimpleswitch(globalconfig, "ocrmergelines"),
|
||||
("", 12),
|
||||
],
|
||||
[
|
||||
(("易错内容修正"), 12),
|
||||
D_getsimpleswitch(ocrerrorfix, "use"),
|
||||
D_getIconButton(
|
||||
callback=functools.partial(
|
||||
postconfigdialog,
|
||||
self,
|
||||
ocrerrorfix["args"]["替换内容"],
|
||||
"易错内容修正",
|
||||
["原文内容", "替换为"],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="自动化执行",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"自动化执行方法",
|
||||
D_getIconButton(
|
||||
callback=lambda: gobject.baseobject.openlink(
|
||||
dynamiclink("{docs_server}/#/zh/ocrparam")
|
||||
),
|
||||
icon="fa.question",
|
||||
),
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
[
|
||||
"分析图像更新",
|
||||
"周期执行",
|
||||
"分析图像更新+周期执行",
|
||||
"鼠标键盘触发+等待稳定",
|
||||
],
|
||||
globalconfig,
|
||||
"ocr_auto_method",
|
||||
callback=functools.partial(_ocrparam_create, self),
|
||||
),
|
||||
12,
|
||||
),
|
||||
],
|
||||
[(functools.partial(_ocrparam, self), 0)],
|
||||
],
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(
|
||||
title="其他",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"多重区域模式",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"multiregion",
|
||||
callback=lambda _: gobject.baseobject.textsource.leaveone(),
|
||||
),
|
||||
],
|
||||
[
|
||||
"范围框颜色",
|
||||
D_getcolorbutton(
|
||||
globalconfig,
|
||||
"ocrrangecolor",
|
||||
callback=lambda: selectcolor(
|
||||
self,
|
||||
globalconfig,
|
||||
"ocrrangecolor",
|
||||
self.ocrrangecolor_button,
|
||||
callback=lambda: gobject.baseobject.textsource.setstyle(),
|
||||
),
|
||||
name="ocrrangecolor_button",
|
||||
parent=self,
|
||||
),
|
||||
],
|
||||
[
|
||||
"范围框宽度",
|
||||
(
|
||||
D_getspinbox(
|
||||
1,
|
||||
100,
|
||||
globalconfig,
|
||||
"ocrrangewidth",
|
||||
callback=lambda x: gobject.baseobject.textsource.setstyle(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后立即进行一次识别",
|
||||
D_getsimpleswitch(globalconfig, "ocrafterrangeselect"),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后显示范围框",
|
||||
D_getsimpleswitch(
|
||||
globalconfig, "showrangeafterrangeselect"
|
||||
),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后自动绑定窗口",
|
||||
D_getsimpleswitch(globalconfig, "ocrautobindhwnd"),
|
||||
],
|
||||
[
|
||||
"选取OCR范围时不透明度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1,
|
||||
globalconfig,
|
||||
"ocrselectalpha",
|
||||
double=True,
|
||||
step=0.01,
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
],
|
||||
grid=initgridsources(self, online),
|
||||
),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
]
|
||||
return grids
|
||||
autorun = [
|
||||
[
|
||||
"自动化执行方法",
|
||||
D_getIconButton(
|
||||
callback=lambda: gobject.baseobject.openlink(
|
||||
dynamiclink("{docs_server}/#/zh/ocrparam")
|
||||
),
|
||||
icon="fa.question",
|
||||
),
|
||||
(
|
||||
D_getsimplecombobox(
|
||||
[
|
||||
"分析图像更新",
|
||||
"周期执行",
|
||||
"分析图像更新+周期执行",
|
||||
"鼠标键盘触发+等待稳定",
|
||||
],
|
||||
globalconfig,
|
||||
"ocr_auto_method",
|
||||
callback=functools.partial(_ocrparam_create, self),
|
||||
),
|
||||
12,
|
||||
),
|
||||
],
|
||||
[(functools.partial(_ocrparam, self), 0)],
|
||||
]
|
||||
after = [
|
||||
[
|
||||
(("合并多行识别结果"), 12),
|
||||
D_getsimpleswitch(globalconfig, "ocrmergelines"),
|
||||
("", 12),
|
||||
],
|
||||
[
|
||||
(("易错内容修正"), 12),
|
||||
D_getsimpleswitch(ocrerrorfix, "use"),
|
||||
D_getIconButton(
|
||||
callback=functools.partial(
|
||||
postconfigdialog,
|
||||
self,
|
||||
ocrerrorfix["args"]["替换内容"],
|
||||
"易错内容修正",
|
||||
["原文内容", "替换为"],
|
||||
),
|
||||
icon="fa.gear",
|
||||
),
|
||||
],
|
||||
]
|
||||
|
||||
others = [
|
||||
[
|
||||
"多重区域模式",
|
||||
D_getsimpleswitch(
|
||||
globalconfig,
|
||||
"multiregion",
|
||||
callback=lambda _: gobject.baseobject.textsource.leaveone(),
|
||||
),
|
||||
],
|
||||
[
|
||||
"范围框颜色",
|
||||
D_getcolorbutton(
|
||||
globalconfig,
|
||||
"ocrrangecolor",
|
||||
callback=lambda: selectcolor(
|
||||
self,
|
||||
globalconfig,
|
||||
"ocrrangecolor",
|
||||
self.ocrrangecolor_button,
|
||||
callback=lambda: gobject.baseobject.textsource.setstyle(),
|
||||
),
|
||||
name="ocrrangecolor_button",
|
||||
parent=self,
|
||||
),
|
||||
],
|
||||
[
|
||||
"范围框宽度",
|
||||
(
|
||||
D_getspinbox(
|
||||
1,
|
||||
100,
|
||||
globalconfig,
|
||||
"ocrrangewidth",
|
||||
callback=lambda x: gobject.baseobject.textsource.setstyle(),
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后立即进行一次识别",
|
||||
D_getsimpleswitch(globalconfig, "ocrafterrangeselect"),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后显示范围框",
|
||||
D_getsimpleswitch(globalconfig, "showrangeafterrangeselect"),
|
||||
],
|
||||
[
|
||||
"选取OCR范围后自动绑定窗口",
|
||||
D_getsimpleswitch(globalconfig, "ocrautobindhwnd"),
|
||||
],
|
||||
[
|
||||
"选取OCR范围时不透明度",
|
||||
(
|
||||
D_getspinbox(
|
||||
0,
|
||||
1,
|
||||
globalconfig,
|
||||
"ocrselectalpha",
|
||||
double=True,
|
||||
step=0.01,
|
||||
),
|
||||
2,
|
||||
),
|
||||
],
|
||||
]
|
||||
allothers = [
|
||||
[
|
||||
(
|
||||
dict(title="后处理", type="grid", grid=after),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
[
|
||||
(
|
||||
dict(title="其他设置", type="grid", grid=others),
|
||||
0,
|
||||
"group",
|
||||
)
|
||||
],
|
||||
]
|
||||
|
||||
return makesubtab_lazy(
|
||||
["引擎", "自动化执行", "其他设置"],
|
||||
[
|
||||
lambda l: makescrollgrid(engines, l),
|
||||
lambda l: makescrollgrid(autorun, l),
|
||||
lambda l: makescrollgrid(allothers, l),
|
||||
],
|
||||
delay=True,
|
||||
)
|
||||
|
||||
|
||||
def getocrgrid_table(self, basel: QVBoxLayout):
|
||||
grids = [
|
||||
[
|
||||
"识别方向",
|
||||
D_getsimplecombobox(
|
||||
["横向", "竖向", "自适应"], globalconfig, "verticalocr"
|
||||
),
|
||||
"",
|
||||
D_getIconButton(
|
||||
gobject.baseobject.createshowocrimage,
|
||||
icon="fa.picture-o",
|
||||
),
|
||||
"",
|
||||
"",
|
||||
],
|
||||
[(functools.partial(internal, self), 0)],
|
||||
]
|
||||
|
||||
self.ocrswitchs = {}
|
||||
|
||||
gridlayoutwidget, do = makegrid(grids, delay=True)
|
||||
basel.addWidget(gridlayoutwidget)
|
||||
do()
|
||||
|
@ -24,10 +24,8 @@ from gui.usefulwidget import (
|
||||
makegrid,
|
||||
makesubtab_lazy,
|
||||
makescrollgrid,
|
||||
getvboxwidget,
|
||||
)
|
||||
from traceback import print_exc
|
||||
from gui.dynalang import LPushButton, LLabel, LAction, LMenu
|
||||
from gui.dynalang import LPushButton, LLabel, LAction
|
||||
|
||||
|
||||
def deepcopydict(d):
|
||||
@ -469,7 +467,7 @@ def __changeuibuttonstate2(self, x):
|
||||
gobject.baseobject.maybeneedtranslateshowhidetranslate()
|
||||
|
||||
|
||||
def setTabTwo_lazy(self, basel):
|
||||
def setTabTwo_lazy(self, basel: QVBoxLayout):
|
||||
# 均衡负载 loadbalance
|
||||
# 单次负载个数 loadbalance_oncenum
|
||||
# 过时的,不再在ui中展示
|
||||
@ -493,20 +491,20 @@ def setTabTwo_lazy(self, basel):
|
||||
),
|
||||
),
|
||||
"",
|
||||
"翻译请求间隔_(s)",
|
||||
D_getspinbox(
|
||||
0, 9999, globalconfig, "requestinterval", step=0.1, double=True
|
||||
),
|
||||
],
|
||||
[
|
||||
"使用翻译缓存",
|
||||
D_getsimpleswitch(globalconfig, "uselongtermcache"),
|
||||
"",
|
||||
],
|
||||
[
|
||||
"最短翻译字数",
|
||||
D_getspinbox(0, 9999, globalconfig, "minlength"),
|
||||
"",
|
||||
"最长翻译字数",
|
||||
D_getspinbox(0, 9999, globalconfig, "maxlength"),
|
||||
"",
|
||||
"翻译请求间隔_(s)",
|
||||
D_getspinbox(
|
||||
0, 9999, globalconfig, "requestinterval", step=0.1, double=True
|
||||
),
|
||||
],
|
||||
]
|
||||
online_reg_grid = [[("若有多个api key,用|将每个key连接后填入,即可轮流使用", -1)]]
|
||||
@ -585,11 +583,9 @@ def setTabTwo_lazy(self, basel):
|
||||
developgrid += initsome2(self, develop, btnplus="dev")
|
||||
online_reg_grid += initsome2(self, shoufei, btnplus="api")
|
||||
pretransgrid += initsome11(self, pre)
|
||||
vw, vl = getvboxwidget()
|
||||
basel.addWidget(vw)
|
||||
|
||||
gridlayoutwidget, do = makegrid(grids, delay=True)
|
||||
vl.addWidget(gridlayoutwidget)
|
||||
basel.addWidget(gridlayoutwidget)
|
||||
tab, dotab = makesubtab_lazy(
|
||||
["在线翻译", "注册在线翻译", "离线翻译", "调试浏览器", "预翻译"],
|
||||
[
|
||||
@ -601,7 +597,7 @@ def setTabTwo_lazy(self, basel):
|
||||
],
|
||||
delay=True,
|
||||
)
|
||||
vl.addWidget(tab)
|
||||
basel.addWidget(tab)
|
||||
|
||||
do()
|
||||
dotab()
|
||||
|
@ -14,7 +14,7 @@ from gui.usefulwidget import (
|
||||
getIconButton,
|
||||
D_getsimpleswitch,
|
||||
makescrollgrid,
|
||||
getvboxwidget,
|
||||
getboxlayout,
|
||||
makesubtab_lazy,
|
||||
)
|
||||
from gui.inputdialog import (
|
||||
@ -145,7 +145,7 @@ def setTab7_lazy(self, basel):
|
||||
callback = functools.partial(
|
||||
autoinitdialog,
|
||||
self,
|
||||
postprocessconfig[post]['args'],
|
||||
postprocessconfig[post]["args"],
|
||||
postprocessconfig[post]["name"],
|
||||
600,
|
||||
items,
|
||||
@ -206,12 +206,14 @@ def setTab7_lazy(self, basel):
|
||||
)
|
||||
grids2 += [[("", 15)]]
|
||||
|
||||
def ___(lay):
|
||||
vboxw, vbox = getvboxwidget()
|
||||
def ___(lay: QVBoxLayout):
|
||||
vboxw, vbox = getboxlayout(
|
||||
[], lc=QVBoxLayout, margin0=True, makewidget=True, both=True
|
||||
)
|
||||
lay.addWidget(vboxw)
|
||||
makescrollgrid(grids, vbox, True, savelist, savelay)
|
||||
|
||||
vbox.addWidget(getcomparelayout(self))
|
||||
lay.addWidget(getcomparelayout(self))
|
||||
|
||||
tab, dotab = makesubtab_lazy(
|
||||
["文本预处理", "翻译优化"],
|
||||
|
@ -86,7 +86,7 @@ def getttsgrid(self, names):
|
||||
callback=functools.partial(
|
||||
autoinitdialog,
|
||||
self,
|
||||
globalconfig["reader"][name]['args'],
|
||||
globalconfig["reader"][name]["args"],
|
||||
globalconfig["reader"][name]["name"],
|
||||
800,
|
||||
items,
|
||||
@ -130,7 +130,7 @@ def getttsgrid(self, names):
|
||||
def setTab5lz(self):
|
||||
grids = []
|
||||
offline, online = splitocrtypes(globalconfig["reader"])
|
||||
alltrans, alltransvis=loadvalidtss()
|
||||
alltrans, alltransvis = loadvalidtss()
|
||||
grids += [
|
||||
[
|
||||
(
|
||||
@ -170,16 +170,16 @@ def setTab5lz(self):
|
||||
(
|
||||
dict(
|
||||
title="声音",
|
||||
type="grid",
|
||||
grid=[
|
||||
[
|
||||
"选择声音",
|
||||
functools.partial(createvoicecombo, self),
|
||||
(functools.partial(createvoicecombo, self), 0),
|
||||
],
|
||||
[
|
||||
"语速_(-10~10)",
|
||||
D_getspinbox(-10, 10, globalconfig["ttscommon"], "rate"),
|
||||
],
|
||||
[
|
||||
"",
|
||||
"音量_(0~100)",
|
||||
D_getspinbox(0, 100, globalconfig["ttscommon"], "volume"),
|
||||
],
|
||||
|
@ -1192,6 +1192,10 @@ class TranslatorWindow(resizableframeless):
|
||||
self.translate_text.textbrowser.showhideorigin(
|
||||
globalconfig["isshowrawtext"]
|
||||
)
|
||||
try:
|
||||
gobject.baseobject.settin_ui.fenyinsettings.setEnabled(globalconfig["isshowrawtext"])
|
||||
except:
|
||||
pass
|
||||
|
||||
def changeshowhidetrans(self):
|
||||
try:
|
||||
|
@ -1108,7 +1108,7 @@ def selectcolor(
|
||||
|
||||
|
||||
def getboxlayout(
|
||||
widgets, lc=QHBoxLayout, margin0=False, makewidget=False, delay=False, both=False
|
||||
widgets, lc=QHBoxLayout, margin0=False, makewidget=False, delay=False, both=False, space0=False
|
||||
):
|
||||
cp_layout = lc()
|
||||
|
||||
@ -1126,6 +1126,8 @@ def getboxlayout(
|
||||
_do = functools.partial(__do, cp_layout, widgets)
|
||||
if margin0:
|
||||
cp_layout.setContentsMargins(0, 0, 0, 0)
|
||||
if space0:
|
||||
cp_layout.setSpacing(0)
|
||||
if not delay:
|
||||
_do()
|
||||
if makewidget:
|
||||
@ -1140,10 +1142,6 @@ def getboxlayout(
|
||||
return cp_layout
|
||||
|
||||
|
||||
def getvboxwidget():
|
||||
return getboxlayout([], lc=QVBoxLayout, margin0=True, makewidget=True, both=True)
|
||||
|
||||
|
||||
class abstractwebview(QWidget):
|
||||
on_load = pyqtSignal(str)
|
||||
on_ZoomFactorChanged = pyqtSignal(float)
|
||||
|
@ -354,7 +354,7 @@ for uid in savehook_new_data:
|
||||
gamepath2uid_index[_p].append(uid)
|
||||
|
||||
|
||||
def get_launchpath(uid):
|
||||
def get_launchpath(uid) -> str:
|
||||
launch = savehook_new_data[uid].get("launchpath", "")
|
||||
if not launch:
|
||||
launch = uid2gamepath[uid]
|
||||
|
@ -1037,11 +1037,6 @@ def getannotatedapiname(x):
|
||||
)
|
||||
|
||||
|
||||
def sortAwithB(l1, l2):
|
||||
sorted_pairs = sorted(zip(l1, l2))
|
||||
return [x[0] for x in sorted_pairs], [x[1] for x in sorted_pairs]
|
||||
|
||||
|
||||
def inrange(n, s, e):
|
||||
return n >= s and n <= e
|
||||
|
||||
|
@ -314,7 +314,7 @@
|
||||
"translator_2": null,
|
||||
"use_appointed_translate": false,
|
||||
"timeout_translate": 2,
|
||||
"trans_kanji": true,
|
||||
"trans_kanji": false,
|
||||
"keeprawtext": false,
|
||||
"insertspace_policy": 0,
|
||||
"changefont": false,
|
||||
@ -341,7 +341,7 @@
|
||||
"myprocess": false,
|
||||
"arabic_reshaper": false
|
||||
},
|
||||
"uselongtermcache": false,
|
||||
"uselongtermcache": true,
|
||||
"showintab": true,
|
||||
"showintab_sub": true,
|
||||
"remove_useless_hook": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user