From 5061cad389c248414ae5b60eda3db59cf315bb82 Mon Sep 17 00:00:00 2001 From: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue, 1 Aug 2023 23:38:30 +0700 Subject: [PATCH] [HOTFIX] [MERGE NOW!] Fix bugs for #926 (#928) * Attempt to rework Zictionary scene * Rearrange the layout and handling most of thing * Remove ALPHA key, done keyboard handling, changed some key's behavior * Add Help text * Update Help text & fix some bugs * Update help text * Edit help text * Support gamepad * small changes in help text * small changes * Fix copy bug * small change * Add hint text to open Hint * Fix a bug that item accidentally selected when scrolling * Clean up a dumb function (Forget to cleanup in previous commit) * add backup solution, just in case * fix another bug * fix touch bug * Refix the scroll bug when touch * small code changes * small change in English file * Fix bugs, change text, adjust a icon * Change English text * Add Vietnamese translation * Add Chinese, adjust English & Vietnamese * Small change in secret Easter egg * Fix spelling mistake --- parts/language/lang_en.lua | 72 +++++++++++++++++--------------------- parts/language/lang_vi.lua | 53 ++++++++++++++++++++++++++++ parts/language/lang_zh.lua | 37 ++++++++++++++++++++ parts/scenes/dict.lua | 38 ++++++++++++-------- 4 files changed, 147 insertions(+), 53 deletions(-) diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index 7a2a92fb..94c11bbe 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -380,56 +380,50 @@ return { support="Support the author", dict={ sizeChanged="Changed font size: $1", - sizeReset="Reset font size: 25", + sizeReset="Font size has been reset!", helpText= [[ -ZICTIONARY NAVIGATION INSTRUCTION +INSTRUCTIONS FOR NAVIGATION IN TETRODICTIONARY -NOTE: Some functions may not have specific gestures for gamepad input. -In such cases, you can use alternative input methods or follow the provided instructions. +A. Mouse and Touchscreen + - Press/touch [$13] to open Help. + - Hold and drag up/down or scroll the mouse to navigate through the text. -Scrolling text: - Keyboard: Use [$1] to scroll up, [$2] to scroll down. - Gamepad: Use $5 to scroll up, $6 to scroll down. - Mouse/Touch screen: Use the familiar scrolling gestures. + - Press/touch a term in the list on the left to select the entry you want to look up. + - Press/touch [$16] or [$17] to quickly scroll through the list. You can also click the middle mouse button or right mouse button and then scroll the mouse to switch between entries. -Exiting Zictionary: - Keyboard: Press [Esc] key. - Gamepad: Press [BACK] button. - Mouse/Touch screen: Press the Back button in the top right corner of the screen. + - Press/touch [aA] to display the font control buttons. + - Press/touch [a] to decrease the font size and [A] to increase the font size. + - To reset the font size to the default size, wait for a few seconds until the [100%] button appears, then press [100%]. -Opening/closing Help: - Keyboard: Press [F1] key. - Gamepad: Press $10 key. - Mouse/Touch screen: Tap [$13] key. + - Press/touch [$14] to copy the content of the current entry. + - Press/touch [$15] to open the link of the current entry (if available). -Opening previous/next item in the list: - Keyboard: Press [$3] to open the previous item, [$4] to open the next one. - Gamepad: Press $7 to open the previous item, $8 to open the next one. - Mouse/Touch screen: Click/touch the item below the currently selected one in the list. + - Click the back button in the top right corner to exit TetroDictionary. -Jumping backward/forward through 12 items: - Keyboard: Hold [Ctrl]/[Shift]/[Alt] key first, then press [$3] to jump backward, [$4] to jump forward. - Gamepad: Hold $11 key first, then press $7 to jump backward, and $8 to jump forward. - Mouse/Touch screen: Click/Touch [$16] to jump backward, [$17] to jump forward -Changing font size (DEFAULT: 25): - Keyboard: Hold Ctrl key first, then press [-] to make the text smaller, [+] to make it bigger, [0] to reset the font size to default. - Gamepad: Hold $11 key first, then press $6 to make the text smaller, and $5 to make it bigger. - Mouse/Touch screen: - Press [aA] to show [a] and [A] buttons. - Click/touch [a] to make the text smaller. - Click/touch [A] to make the text bigger. - To reset the font size, wait for 3 seconds for [aA] [100%] to reappear, then click/touch [100%] to reset. - Note: There's no gesture to reset the font size with the Gamepad, but you can set it back to 25. +B. Keyboard + Press... + - [F1] to display Help. + - [$1] or [$2] to scroll through the text. + - [$3] to open the previous entry and [$4] to open the next entry. -Copying the content: - Keyboard: Press [Ctrl] + [C]. - Mouse/Touch screen: Press [$14] key. + - [Ctrl] + [-] to decrease the font size, [Ctrl] + [+] to increase the font size. + - [Ctrl] + [0] to restore the default font size. -Opening item's URL (if available): - Keyboard: Press [$18] (Context menu/Application key). - Mouse/Touch screen: Press [$15] key. + - [Ctrl] + [C] to copy text. + - [$18] (Context Menu key/Application key) + - to open the link of the current entry (if available). + + - [Esc] to exit TetroDictionary. + +C. Gamepad + - Press $10 to display Help. + - Press $5 or $6 to scroll through the text. + - Press $7 to open the previous entry and $8 to open the next entry. + - Hold $11 and press $7 or $8 to scroll quickly through the list. + - Hold $11 and press $6 to decrease the font size or $5 to increase the font size. + - Press [BACK] to exit TetroDictionary. ]] -- 1-4: Up, Down, Left, Right -- 5-8: Up, Down, Left, Right but D-Pad diff --git a/parts/language/lang_vi.lua b/parts/language/lang_vi.lua index 9b32ae95..044a0a9f 100644 --- a/parts/language/lang_vi.lua +++ b/parts/language/lang_vi.lua @@ -385,6 +385,59 @@ return { sha2 [Egor Skriptunoff] ]], support="Hỗ trợ người làm game", + dict={ + sizeChanged="Đã đổi cỡ phông: $1", + sizeReset="Đã đặt lại cỡ phông!", + helpText= +[[ +HƯỚNG DẪN ĐIỀU HƯỚNG TRONG TETRODICTIONARY + +A. Chuột và màn hình cảm ứng + - Nhấn/chạm [$13] để mở Trợ giúp. + - Giữ và kéo lên/xuống hoặc lăn chuột để cuộn văn bản. + + - Nhấn/chạm vào một mục trong danh sách ở bên trái để chọn mục cần tra. + - Nhấn/chạm [$16] hoặc [$17] để nhanh chóng cuộn qua danh sách. Bạn cũng có thể nhấn giữ chuột giữa hoặc chuột phải sau đó lăn chuột để chuyển qua các mục. + + - Nhấn/chạm [aA] để hiện 2 nút điều khiển cỡ chữ. + - Nhấn/chạm [a] để giảm cỡ chữ và [A] để tăng cỡ chữ. + - Để đặt cỡ chữ về cỡ mặc định, chờ một vài giây để nút [100%] xuất hiện, sau đó nhấn [100%]. + + - Nhấn/chạm [$14] để sao chép nội dung của mục đang xem. + - Nhấn/chạm [$15] để mở link của mục đang xem (nếu có). + + - Nhấp vào nút quay lại ở góc trên bên phải để thoát TetroDictionary + + +B. Bàn phím + Nhấn… + - [F1] để hiển thị Trợ giúp. + - [$1] hoặc [$2] để cuộn qua văn bản. + - [$3] để mở mục trước đó và [$4] để mở mục tiếp theo. + + - [Ctrl] + [-] để giảm cỡ chữ, [Ctrl] + [+] để tăng cỡ chữ. + - [Ctrl] + [0] để khôi phục về cỡ chữ mặc định + + - [Ctrl] + [C] để sao chép văn bản + - [$18] (phím Menu ngữ cảnh/phím Ứng dụng) + để mở liên kết của mục đang xem (nếu có) + + - [Esc] để thoát TetroDictionary + + +C. Tay cầm chơi game (Gamepad) + Nhấn $10 để hiển thị trợ giúp. + Nhấn $5 hoặc $6 để cuộn văn bản. + Nhấn $7 để mở mục trước và $8 để mở mục tiếp theo. + Giữ $11 và nhấn $7 hoặc $8 để cuộn nhanh qua danh sách. + Giữ $11 và nhấn $6 để giảm cỡ chữ hoặc $5 để tăng cỡ chữ. + Nhấn [BACK] để thoát TetroDictionary. +]] + -- 1-4: Up, Down, Left, Right + -- 5-8: Up, Down, Left, Right but D-Pad + -- 9-12: X, Y, A, B + -- 13-18: Help, Copy, Open, Forward, Backward, MENU + }, WidgetText={ main={ offline="Chơi đơn", diff --git a/parts/language/lang_zh.lua b/parts/language/lang_zh.lua index 08f1a78d..4d340b84 100644 --- a/parts/language/lang_zh.lua +++ b/parts/language/lang_zh.lua @@ -379,6 +379,43 @@ return { sha2 [Egor Skriptunoff] ]], support="支持作者", + dict={ -- Message from Sea: credit to User670 for helping me out this part. + sizeChanged="已更改字号为$1", + sizeReset="字号已重置", + helpText= +[[ +小Z词典操作说明 + +鼠标与触摸屏: + 点击 [$13] 显示帮助。 + 拖动或使用鼠标滚轮以滚动文本。 + 点击左侧列表中的项目以选择词条,点击 [$16] 或 [$17] 快速滚动列表。 + 点击 [aA] 显示字号控制,然后点击 [a] 缩小字号,[A] 增大字号。要重置字号为默认大小,稍等片刻直到 [100%] 按钮显示,然后点击 [100%]。 + 点击 [$14] 复制词条文本。 + 点击 [$15] 打开词条中的链接(如有)。 + 点击右上角的返回按钮退出小Z词典。 + +键盘: + 按 [F1] 显示帮助。 + 按 [$1] 或 [$2] 滚动文本。 + 按 [$3] 打开上一词条,按 [$4] 打开下一词条。使用 [Ctrl + $3] 或 [Ctrl + $4] 快速滚动列表。 + 按 [Ctrl + 减号键] 缩小字号,[Ctrl + 等号键] 增大字号,[Ctrl + 0] 恢复默认字号。 + 按 [Ctrl + C] 复制词条文本。 + 按 [$18] (上下文菜单键,应用程序键)打开词条中的链接(如有)。 + 按 [Esc] 退出小Z词典。 + +游戏手柄: + 按 $10 显示帮助。 + 按 $5 或 $6 滚动文本。 + 按 $7 打开上一词条,按 $8 打开下一词条。按住 $11 并按 $7 或 $8 快速滚动列表。 + 按住 $11 并按 $6 缩小字号,或 $5 增大字号。 + 按 [BACK] 退出小Z词典。 +]] + -- 1-4: Up, Down, Left, Right + -- 5-8: Up, Down, Left, Right but D-Pad + -- 9-12: X, Y, A, B + -- 13-18: Help, Copy, Open, Forward, Backward, MENU + }, WidgetText={ main={ offline="单机游戏", diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 47d60d30..d78a392c 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -21,7 +21,7 @@ local currentFontSize=25 -- Current font size, default: 25 local showingHelp=false -- Help is triggered or not local zoomWait=0 -- The last time zoom is triggered -local oldScrollPos=0 +local lastScrollPos local lastMouseX,lastMouseY,lastTouchX,lastTouchY local typeColor={ @@ -101,10 +101,9 @@ local function _search() ins(result,dict[i]) end end - if #result>0 then - SFX.play('reach') - justSearched=true - end + + if #result>0 then SFX.play('reach') end + justSearched=true lastSearch=input end @@ -132,13 +131,21 @@ local function _updateInfoBox(c) if showingHelp then if text.dict.helpText then t,_t=text.dict.helpText:repD( - CHAR.key.up, CHAR.key.down, CHAR.key.left, CHAR.key.right, - CHAR.controller.xboxX, CHAR.controller.xboxY, CHAR.controller.xboxA, CHAR.controller.xboxB, + CHAR.key.up, CHAR.key.down, CHAR.key.left, CHAR.key.right, + CHAR.controller.dpadU,CHAR.controller.dpadD,CHAR.controller.dpadL,CHAR.controller.dpadR, + CHAR.controller.xboxX,CHAR.controller.xboxY,CHAR.controller.xboxA,CHAR.controller.xboxB, - CHAR.icon.help, CHAR.icon.copy, CHAR.icon.globe, - CHAR.icon.toUp, CHAR.icon.toDown, CHAR.key.winMenu + CHAR.icon.help,CHAR.icon.copy, CHAR.icon.globe, + CHAR.icon.toUp,CHAR.icon.toDown,CHAR.key.winMenu ),true - else _t,t=true,{"NO HELP TEXT AVAILABLE!\n","Please switch language to English and try again to read the help text"} end + else _t,t=true,{ + "OUCH! I can't seem to find any translated Help text anywhere.", + "\nI guess you'll have to switch to English and try again to read it instead!", + "\n\nOn another note, you could make an issue on GitHub or send this to Techmino's Discord server.", + "\nThe cause? I'm not sure... My guess is that there's something seriously wrong with the language files or the source code of this scene. BUT all the language files have a callback to English, and the original language - Chinese - has a version of the Help text! I'm not entirely certain if it worked or not, though.", + "\n\nOh, and it would be nice if you could let us know about it or you can fix it by yourself!", + "\n\n-- Sea, the one who rewrote the Zictionary scene and left this message just in case." + } end else _t,t=pcall(function() return _getList()[listBox.selected].content end) end if _t then c=t else c={""} end _t,t=nil,nil @@ -199,10 +206,9 @@ end local function fixScrollingByTouch(x,y,lastX,lastY) if WIDGET.isFocus(listBox) then - if abs(oldScrollPos-listBox.scrollPos)>26 then - oldScrollPos=listBox.scrollPos + if abs(lastScrollPos-listBox.scrollPos)>26 then + lastScrollPos=listBox.scrollPos listBox.selected=lastSelected - listBox.scrollPos=oldScrollPos else lastSelected=listBox.selected scene.widgetList.copy.hide=false @@ -224,6 +230,8 @@ function scene.enter() searchWait=0 lastSelected=0 listBox.selected=1 + listBox.scrollPos=0 + lastScrollPos=0 lastSearch=false if not MOBILE then WIDGET.focus(inputBox) end @@ -242,6 +250,7 @@ function scene.keyDown(key) return elseif WIDGET.isFocus(listBox) then listBox:scroll(key=='up' and -1 or 1) + lastScrollPos=listBox.scrollPos return end end @@ -382,6 +391,7 @@ function scene.draw() -- If yes, update lastSelected then update the textbox! elseif justSearched then listBox:setList(_getList()) + _updateInfoBox() justSearched=false elseif lastSelected~=listBox.selected and not love.mouse.isDown(1) then _updateInfoBox() @@ -406,7 +416,7 @@ scene.widgetList={ WIDGET.newKey {name='link', x=1234,y=600,w=60,font=45,fText=CHAR.icon.globe, code=pressKey'application',hideF=function() return not ((not (showingHelp or listBox.selected==0)) and _getList()[listBox.selected].url) end}, WIDGET.newKey {name='copy', x=1234,y=670,w=60,font=40,fText=CHAR.icon.copy, code=pressKey'cC'}, - WIDGET.newKey {name='openzoom', x=1234,y=300,w=60,font=25,fText="aA", code=function() _openZoom() end,hide=false}, + WIDGET.newKey {name='openzoom', x=1234,y=300,w=60,font=30,fText="aA", code=function() _openZoom() end,hide=false}, WIDGET.newKey {name='resetzoom',x=1234,y=370,w=60,font=25,fText="100%", code=function() _resetZoom() end,hide=false}, WIDGET.newKey {name='zoomin', x=1234,y=300,w=60,font=40,fText="A", code=function() _setZoom(5) end,hide=true}, WIDGET.newKey {name='zoomout', x=1234,y=370,w=60,font=40,fText="a", code=function() _setZoom(-5) end,hide=true},