👍️[Update] Model : Overlay 任意のテキストをOverlayで表示するエンドポイントを追加
This commit is contained in:
@@ -689,6 +689,19 @@ class Model:
|
||||
}
|
||||
return self.overlay_image.createOverlayImageShort(message, your_language, translation, target_language, ui_type)
|
||||
|
||||
def createOverlayImage(self, message):
|
||||
ui_language = config.UI_LANGUAGE
|
||||
convert_languages = {
|
||||
"en": "Japanese",
|
||||
"jp": "Japanese",
|
||||
"ko":"Korean",
|
||||
"zh-Hans":"Chinese Simplified",
|
||||
"zh-Hant":"Chinese Traditional",
|
||||
}
|
||||
language = convert_languages.get(ui_language, "Japanese")
|
||||
ui_type = config.OVERLAY_UI_TYPE
|
||||
return self.overlay_image.createOverlayImage(message, language, ui_type)
|
||||
|
||||
def clearOverlayImage(self):
|
||||
self.overlay.clearImage()
|
||||
|
||||
|
||||
@@ -229,3 +229,25 @@ class OverlayImage:
|
||||
background = Image.alpha_composite(background, decoration_image)
|
||||
img = Image.alpha_composite(background, img)
|
||||
return img
|
||||
|
||||
def createOverlayImage(self, message, your_language, ui_type="default"):
|
||||
ui_size = self.getUiSize()
|
||||
height = ui_size["height"]
|
||||
width = ui_size["width"]
|
||||
font_size = ui_size["font_size"]
|
||||
|
||||
ui_colors = self.getUiColors(ui_type)
|
||||
text_color = ui_colors["text_color"]
|
||||
background_color = ui_colors["background_color"]
|
||||
background_outline_color = ui_colors["background_outline_color"]
|
||||
|
||||
img = self.createTextboxShort(message, your_language, text_color, width, height, font_size)
|
||||
|
||||
background = Image.new("RGBA", img.size, (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(background)
|
||||
draw.rounded_rectangle([(0, 0), img.size], radius=30, fill=background_color, outline=background_outline_color, width=5)
|
||||
|
||||
decoration_image = self.createDecorationImage(ui_type, img.size)
|
||||
background = Image.alpha_composite(background, decoration_image)
|
||||
img = Image.alpha_composite(background, img)
|
||||
return img
|
||||
@@ -1392,6 +1392,14 @@ class Controller:
|
||||
model.oscStopSendTyping()
|
||||
return {"status":200, "result":True}
|
||||
|
||||
@staticmethod
|
||||
def sendTextOverlaySmallLog(data, *args, **kwargs) -> dict:
|
||||
if config.OVERLAY_SMALL_LOG is True:
|
||||
if model.overlay.initialized is True:
|
||||
overlay_image = model.createOverlayImage(data)
|
||||
model.updateOverlay(overlay_image)
|
||||
return {"status":200, "result":data}
|
||||
|
||||
def swapYourLanguageAndTargetLanguage(self, *args, **kwargs) -> dict:
|
||||
your_languages = config.SELECTED_YOUR_LANGUAGES
|
||||
your_language_primary = your_languages[config.SELECTED_TAB_NO]["primary"]
|
||||
|
||||
@@ -82,6 +82,8 @@ mapping = {
|
||||
"/run/typing_message_box": {"status": False, "variable":controller.typingMessageBox},
|
||||
"/run/stop_typing_message_box": {"status": False, "variable":controller.stopTypingMessageBox},
|
||||
|
||||
"/run/send_text_overlay_small_log": {"status": True, "variable":controller.sendTextOverlaySmallLog},
|
||||
|
||||
"/run/swap_your_language_and_target_language": {"status": True, "variable":controller.swapYourLanguageAndTargetLanguage},
|
||||
|
||||
"/run/update_software": {"status": True, "variable":controller.updateSoftware},
|
||||
|
||||
Reference in New Issue
Block a user