From 40cafe09c5160f4a407335dbd694e6491b07d1ee Mon Sep 17 00:00:00 2001 From: cuu Date: Wed, 5 Dec 2018 16:17:15 +0800 Subject: [PATCH] MultiLabel add iscjk --- sys.py/UI/lang_manager.py | 12 ++++++++++++ sys.py/UI/multilabel.py | 17 +++++++++++++++-- sys.py/langs/01_日本語.ini | 14 +++++++------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/sys.py/UI/lang_manager.py b/sys.py/UI/lang_manager.py index af00c67..0a1de09 100644 --- a/sys.py/UI/lang_manager.py +++ b/sys.py/UI/lang_manager.py @@ -17,6 +17,7 @@ class LangManager(object): _Langs = {} _Config = None _ConfigFileName = "00_English.ini" ## double % to escape + _CJKMode = False def __init__(self): self.Init() @@ -29,6 +30,17 @@ class LangManager(object): self._Langs = {} self.SetLangs() + def IsCJKMode(self):## in MultiLabel, latins seped by white spaces,CJK no needs for that + latins = ["English"] + self._CJKMode = True + + for i in latins: + if i in self._ConfigFileName: + self._CJKMode= False + break + + return self._CJKMode + def SetLangs(self): self._Config = CaseConfigParser() #print("SetLangs") diff --git a/sys.py/UI/multilabel.py b/sys.py/UI/multilabel.py index 0330580..ba47624 100644 --- a/sys.py/UI/multilabel.py +++ b/sys.py/UI/multilabel.py @@ -3,6 +3,7 @@ import pygame from skin_manager import MySkinManager +from lang_manager import MyLangManager class MultiLabel: ##Multi Line Label @@ -49,15 +50,27 @@ class MultiLabel: ##Multi Line Label self._CanvasHWND = _canvashwnd def blit_text(self, surface,text, pos, font): + iscjk = MyLangManager.IsCJKMode() + color = self._Color words = [word.split(' ') for word in text.splitlines()] space = font.size(' ')[0] + + if iscjk: + space = 0 + words = [list(word.decode("utf8")) for word in text.splitlines()] + max_width = self._Width x ,y = pos row_total_width = 0 lines = 0 - for i,line in enumerate(words[:4]): - for word in line[:12]: + line_max = 12 + row_max = 4 + if iscjk: + line_max = line_max*2 + + for i,line in enumerate(words[:row_max]): + for word in line[:line_max]: word_surface = font.render(word, True, color) word_width = word_surface.get_width() word_height = word_surface.get_height() diff --git a/sys.py/langs/01_日本語.ini b/sys.py/langs/01_日本語.ini index 0102928..392c2bc 100644 --- a/sys.py/langs/01_日本語.ini +++ b/sys.py/langs/01_日本語.ini @@ -26,23 +26,23 @@ AddFav=お気に入りに追加 ADdFavList=お気に入りリストに登録 Del=削除 Please upload data over Wi-Fi=Wi-Fiでデータを送信してください -ConfirmDeleteQ=削除しますか? +ConfirmDeleteQ=削除しますか? AlreadyExisted=既に存在している Cancel=取り消す Yes=はい ConfirmQ=確認? Disconnecting=接続を切断 -ConfirmUpdateToFQ=%%sにアップデートしますか? -UpdateToFQ=%%sにアップデート? -SetupGameEngineAutoQ=ゲームエンジンの自動セットアップを希望しますか? +ConfirmUpdateToFQ=%%sにアップデートしますか? +UpdateToFQ=%%sにアップデート? +SetupGameEngineAutoQ=ゲームエンジンの自動セットアップを希望しますか? Downloading=ダウンロード中 BATOver5Pct=バッテリーは5%%以上が必要 DeleteConfirm=削除の確認 FavouriteGames=お気に入りのゲーム -ConfirmForgetQ=無視しますか? +ConfirmForgetQ=無視しますか? ConfirmForget=無視しますか Disconnect=接続を切断 -ConfirmDisconnectQ=接続を切りますか? +ConfirmDisconnectQ=接続を切りますか? Confirm Disconnect=接続を切りますか Forget=無視 Forgeting=無視中 @@ -100,7 +100,7 @@ Power saving=省エネルギー Balanced=バランス Server=サーバ Performance=性能 -Confirm Power OFF?=電源オフしますか? +Confirm Power OFF?=電源オフしますか? Reboot=再起動 Shutdown=シャットダウン Play List=プレイリスト