forked from NyashniyVladya/Translator3000
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Введение системы предварительного перевода
- Loading branch information
Vladya
committed
Oct 13, 2020
1 parent
60e101e
commit 73d7a05
Showing
6 changed files
with
119 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
init -9 python in _translator3000: | ||
|
||
class Preparer(threading.Thread, NoRollback): | ||
|
||
""" | ||
Демон для параллельного перевода всего текста в игре. | ||
""" | ||
|
||
__author__ = "Vladya" | ||
|
||
def __init__(self, translator_object): | ||
|
||
super(Preparer, self).__init__() | ||
self.daemon = True | ||
|
||
self._translator = translator_object | ||
|
||
self._status = None | ||
self._completed = False | ||
|
||
def _show_scan_status(self, *screen_args, **screen_kwargs): | ||
|
||
""" | ||
Демонстрация статуса сканирования. | ||
""" | ||
|
||
if (not self._completed) and self._status: | ||
_done, _scope_of_work = self._status | ||
ui.text( | ||
"Переведено {0} строк из {1} ({2:.1%}).".format( | ||
_done, | ||
_scope_of_work, | ||
(float(_done) / float(_scope_of_work)) | ||
), | ||
color="#fff", | ||
outlines=[(2, "#000", 0, 0)], | ||
anchor=(.0, .0), | ||
pos=(.01, .01) | ||
) | ||
|
||
def run(self): | ||
|
||
_renpy_translator = renpy.game.script.translator | ||
|
||
say_objects = tuple( | ||
sorted( | ||
map( | ||
lambda tl: tl.predict()[0], | ||
_renpy_translator.default_translates.itervalues() | ||
), | ||
key=lambda _node: (_node.filename, _node.linenumber) | ||
) | ||
) | ||
text_len = len(say_objects) | ||
|
||
try: | ||
for counter, say_node in enumerate(say_objects): | ||
self._status = (counter, text_len) | ||
renpy.restart_interaction() # Для перерисовки статуса. | ||
self._translator(say_node.what, _update_on_hdd=False) | ||
finally: | ||
self._translator._translator_object._backup_database() | ||
self._status = None | ||
self._completed = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters