* Squashed commit of the following: commit f50627095805c090b49c1054645ad33cb896f4d0 Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Aug 5 09:49:59 2023 +0700 Change icon in dict.lua commit 1f7da069425f00f431c9299689897a665cb2d80d Merge:b212fff87be2aa50Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Aug 4 18:14:29 2023 +0700 Merge https://github.com/26F-Studio/Techmino into VietnameseTranslation commit7be2aa50ddAuthor: C₂₉H₂₅N₃O₅ <a1228465111@163.com> Date: Fri Aug 4 18:40:12 2023 +0800 Font & Virtual Key Update (#932) - Changed the main font to Exo2 - Changed the monospaced font to League Mono - Changed the virtual key design to increase legibility and match the font - Added a few symbols commited9417dcdfAuthor: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Aug 3 22:57:06 2023 +0700 Reupdate Vietnamese translation (#930) commitb212fff8d9Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Aug 3 20:54:45 2023 +0700 Small update commitb59d1dc188Merge:8fcdbd9d36522c71Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Aug 3 19:40:20 2023 +0700 Merge branch 'main' of https://github.com/26F-Studio/Techmino into VietnameseTranslation commit36522c7146Author: MrZ_26 <1046101471@qq.com> Date: Thu Aug 3 16:04:04 2023 +0800 修复词典用不了滚轮 整理代码 commit20b74ea78aAuthor: MrZ_26 <1046101471@qq.com> Date: Thu Aug 3 13:46:27 2023 +0800 词典交互和代码逻辑优化 框架跟进 commit0ae9cbcdaaAuthor: MrZ_26 <1046101471@qq.com> Date: Thu Aug 3 10:11:27 2023 +0800 删行末空格 commitc9cbb0e363Author: MrZ_26 <1046101471@qq.com> Date: Wed Aug 2 21:45:31 2023 +0800 修复fixed序列反了 commit0595ce4ea6Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Wed Aug 2 10:44:01 2023 +0700 Update Vietnamese translation (again) (#929) commit8fcdbd9df5Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Wed Aug 2 10:22:54 2023 +0700 remove duplicate commit798ea1be4fAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Wed Aug 2 10:09:02 2023 +0700 remove duplicate item in ZH file (thanks SundayLee) commite6f4f69f6fMerge:14630990fa89ba55Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Wed Aug 2 10:00:17 2023 +0700 Merge branch 'VietnameseTranslation' of https://github.com/SweetSea-ButImNotSweet/Techmino into VietnameseTranslation commit14630990beAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 23:43:35 2023 +0700 Small change commit7a15406262Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 15 00:46:17 2023 +0700 small update commit1d10f14c8eAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 21:08:10 2023 +0700 Remove most of unnecessary keywords commit07341d48e4Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 14:38:46 2023 +0700 Update the manual (Rebasing all old commits) commit2e2427f942Author: MrZ_26 <1046101471@qq.com> Date: Wed Aug 2 10:34:19 2023 +0800 框架跟进 commitaeddee2f03Author: MrZ_26 <1046101471@qq.com> Date: Wed Aug 2 10:23:20 2023 +0800 修复自定义页面编辑场地消行按钮用不了 commit43037f8043Author: NOT_A_ROBOT <not_a_normal_robot@protonmail.com> Date: Tue Aug 1 23:50:08 2023 +0700 Shorten mission displays with RLE (#927) (may need optimization) commit0c3d552d08Author: MrZ_26 <1046101471@qq.com> Date: Wed Aug 2 00:46:54 2023 +0800 越南语语言文件小修正 commitfa89ba55aaAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 23:43:35 2023 +0700 Small change commita1b6b8a434Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 23:39:04 2023 +0700 Vietnamese Zictionary update [ONLY MERGE AFTER MERGING #926] (#915) * Tweak keywords * Small update * Update the manual * Remove most of unnecessary keywords * Revert change * Push updates * small update * Add tips that missing * Nvm, little change * Minor changes * Little update * Some updates * Small change in updatelog * Push update * small update * Small update * Update the translation, last time? * Push * Push small updates, READY! * Push updates * Clean up some missed items * small updates because of my flipped memory * Small changes + NEW TOOL! * Remove old info * Small updates * Small updates * Replace alnost "hố" --> "lỗ * Small updates * Sort group, adapt #926 * small update * Fix some stupid mistake when do translating * Small change * small change * Clean up outdated comment * Fixed wrong group tag * Add a funny tip 🤪 * Fix tip * Fix tip again * Fix tip again (x2) commit5061cad389Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 23:38:30 2023 +0700 [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 commita26c49451bAuthor: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 11:01:26 2023 +0700 Fix tip again (x2) commitd66b2d6131Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 10:39:08 2023 +0700 Fix tip again commite95f87ace1Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 10:35:13 2023 +0700 Fix tip commit1ccd211bfcAuthor: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Aug 1 10:12:23 2023 +0700 Add a funny tip 🤪 commit86ce124dd0Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 22:49:09 2023 +0700 Fixed wrong group tag commit7d62a04b17Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 22:47:02 2023 +0700 Clean up outdated comment commitfd3910fe14Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 15:37:10 2023 +0700 small change commit4ab59ef4a2Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 12:13:45 2023 +0700 Small change commitbf5f7cb2c9Merge:bb7b1b939d3fb33dAuthor: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 11:04:48 2023 +0700 Merge branch '26F-Studio:main' into VietnameseTranslation commit9d3fb33d10Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 31 02:20:24 2023 +0700 Improve Zictionary scene so we don't need to hyper tapping much than before (#926) * 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 commit4d82b182a6Author: MrZ_26 <1046101471@qq.com> Date: Mon Jul 31 02:53:15 2023 +0800 语言选择场景标题文本修改 commitbb7b1b93cbAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 29 10:36:53 2023 +0700 Fix some stupid mistake when do translating commit5358538cb4Merge:23fd5cdb78ac05efAuthor: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Jul 28 23:33:55 2023 +0700 Merge branch '26F-Studio:main' into VietnameseTranslation commit23fd5cdbb9Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Jul 28 23:33:19 2023 +0700 small update commit4796a57bb4Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Jul 28 23:23:18 2023 +0700 Sort group, adapt #926 commit78ac05efbaAuthor: MrZ_26 <1046101471@qq.com> Date: Wed Jul 26 02:02:42 2023 +0800 框架跟进 commitcd7c58eb32Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 24 15:54:33 2023 +0700 Small updates commit53857af2faMerge:a2cdd6f302cf7b71Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 23 21:59:57 2023 +0700 Merge branch '26F-Studio:main' into VietnameseTranslation commita2cdd6f367Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 23 21:59:28 2023 +0700 Replace alnost "hố" --> "lỗ commit02cf7b71c1Merge:091bb234aefde7a7Author: MrZ_26 <1046101471@qq.com> Date: Thu Jul 20 15:00:40 2023 +0800 Merge remote-tracking branch 'tech/imple/revise-seq-generator' commit4629b4718fAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 17 22:17:15 2023 +0700 Small updates commit9907971722Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 17 22:04:06 2023 +0700 Small updates commit16d89195d5Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 17 09:58:28 2023 +0700 Remove old info commit091bb23488Author: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 10:47:23 2023 +0800 词典标题栏不会溢出了 commit0ec0d80e9cAuthor: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 10:29:38 2023 +0800 修复手柄摇杆左右的图标反了 close #912 commitd4d87ccb5cAuthor: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 05:50:18 2023 +0800 调整bagP1inf序列模式位置 commitc782c1fcddAuthor: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 05:47:20 2023 +0800 修复四连块之外的ASC旋转中心不正确 close #910 commitf7cdae8677Author: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 04:24:49 2023 +0800 修复玩家死亡掉落动画任务能跨局把新开的局里的玩家移除 close #918 commitf41a68de0dAuthor: MrZ_26 <1046101471@qq.com> Date: Mon Jul 17 04:19:32 2023 +0800 添加bagPinf序列模式的图标 commitc38bb7986aAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 17 00:15:31 2023 +0700 Small changes + NEW TOOL! commit80b56af045Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 12:42:02 2023 +0700 small updates because of my flipped memory commit745f836ddfAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 12:30:22 2023 +0700 Clean up some missed items commit9f45842046Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 12:23:14 2023 +0700 Push updates commit9b7c09d89cAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 11:50:04 2023 +0700 Push small updates, READY! commitbe11a9ada4Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 11:25:52 2023 +0700 Push commit92361e073cAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun Jul 16 11:18:50 2023 +0700 Update the translation, last time? commit146db2325dAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 15 09:15:08 2023 +0700 Small update commit9ec237acc1Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 15 00:46:17 2023 +0700 small update commitc39c6c0701Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 15 00:42:14 2023 +0700 Push update commit1273d54135Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sat Jul 15 00:42:01 2023 +0700 Small change in updatelog commitb649d9864dMerge:58df11fe3dc61688Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Jul 14 19:52:50 2023 +0700 Merge branch '26F-Studio:main' into VietnameseTranslation commit58df11feb3Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Fri Jul 14 10:12:33 2023 +0700 Some updates commitaefde7a777Merge:7e00a7d73dc61688Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Thu Jul 13 14:15:51 2023 +0800 Merge branch 'main' into imple/revise-seq-generator commit3dc61688c4Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Thu Jul 13 13:26:17 2023 +0800 add new generator: bagP1inf (#916) commit6502af6003Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Jul 13 09:10:20 2023 +0700 Little update commit42f0671223Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Jul 13 07:38:06 2023 +0700 Minor changes commit7f2f608fd4Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Jul 13 00:40:08 2023 +0700 Nvm, little change commit8e0315762fAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Thu Jul 13 00:32:27 2023 +0700 Add tips that missing commit7e00a7d764Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Wed Jul 12 07:42:50 2023 +0800 use `trueNextCount` as replay-visible next count commit8304cf655bAuthor: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Wed Jul 12 07:27:22 2023 +0800 make sequence generator independent of player commit7d4d664b5bAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Jul 11 23:17:38 2023 +0700 small update commit34c125504bAuthor: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Tue Jul 11 20:47:14 2023 +0700 Push updates commitc25e7a3d5bAuthor: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Tue Jul 11 20:05:31 2023 +0800 fix noInitSZO commitb7b02ab5bcAuthor: Imple Lee <80144331+ImpleLee@users.noreply.github.com> Date: Tue Jul 11 19:50:52 2023 +0800 simplify sequence generator commitf0e2a6d162Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 21:08:22 2023 +0700 Revert change commitb1b39a3a67Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 21:08:10 2023 +0700 Remove most of unnecessary keywords commit47b201ed71Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 14:38:46 2023 +0700 Update the manual commit6c59718274Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 12:12:34 2023 +0700 Small update commit974895ca03Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Mon Jul 10 12:03:28 2023 +0700 Tweak keywords * Edit the index in Zictionary, not much * Revert a change in dict.lua * Small change in Vietnamese translation * Fix strange behaviors and update Vnese Zictionary * Push a little change * Last update? * Rewritten sentences * Fix stuck help text (by not clearing search result when trigger with F1 key * Fix stuck help text (by not clearing search result when trigger with F1 key) * Fix a small bug * Update Vietnamese translation * small change * Block performance loss * Update Vietnamese translation (to 1/2 works now) * Replace unfittable word * Temp update * Just a big update * Update both manual and UI translation * Smaller fallback * uh forgetting changes * remove "not" in a line which was for debugging * Sync work * Update debug code * Update debug code * Update Zictionary + update for hot reloading code * Last update * Last update again * Last update, TB;DR * Commenting out the hotload function * Merge from the stash * shorten file * Fix cannot use Backspace key * Edit comment * last update
346 lines
12 KiB
Lua
346 lines
12 KiB
Lua
local gc=love.graphics
|
|
|
|
local floor,abs=math.floor,math.abs
|
|
local ins=table.insert
|
|
local find=string.find
|
|
|
|
local scene={}
|
|
|
|
local dict-- Dict list
|
|
local result-- Result Lable
|
|
local localeFile -- Language file name, used for force reload
|
|
|
|
local lastTickInput
|
|
local searchWait-- Searching animation timer
|
|
|
|
local lastSearch-- Last searched string
|
|
local lastSelected -- Last selected item
|
|
|
|
local currentFontSize=25 -- Current font size, default: 25
|
|
|
|
local typeColor={
|
|
help=COLOR.Y,
|
|
org=COLOR.lF,
|
|
game=COLOR.lC,
|
|
term=COLOR.lR,
|
|
setup=COLOR.lY,
|
|
pattern=COLOR.lJ,
|
|
command=COLOR.lN,
|
|
english=COLOR.B,
|
|
name=COLOR.lV,
|
|
}
|
|
|
|
-- Scan the dictionary and return the list
|
|
local function _filter(word_org)
|
|
local word=word_org
|
|
word=word:gsub("[Tt][Ee][Tt][Rr][Ii][Ss]",CHAR.zChan.thinking)
|
|
if FNNS then word=word:gsub("[Pp]\97\116\114\101\111\110",CHAR.zChan.qualified) end
|
|
return word,word_org
|
|
end
|
|
local function _scanDict(D)
|
|
if not D[1][1] then return end
|
|
local cut=TABLE.cut
|
|
for i=1,#D do
|
|
local O=D[i]
|
|
O.title,O.title_Org=_filter(O[1])
|
|
O.keywords=O[2]
|
|
O.type=O[3]
|
|
O.content,O.content_Org=_filter(O[4])
|
|
O.url=O[5]
|
|
cut(O)
|
|
end
|
|
end
|
|
local function _getList() return result[1] and result or dict end
|
|
|
|
local textBox =WIDGET.newTextBox {name='infoBox',x=320,y=180,w=862,h=526,font=25,fix=true}
|
|
local inputBox=WIDGET.newInputBox{name='input', x=20, y=110,w=762,h=60, font=40,limit=32}
|
|
local listBox =WIDGET.newListBox {name='listBox',x=20, y=180,w=280,h=526,font=30,lineH=35,drawF=function(item,id,ifSel)
|
|
-- Background
|
|
if ifSel then
|
|
gc.setColor(1,1,1,.4)
|
|
gc.rectangle('fill',0,0,280,35)
|
|
end
|
|
setFont(30)
|
|
-- Name & color
|
|
GC.shadedPrint(item.title,10,-3,'left',1,COLOR.D,typeColor[item.type])
|
|
end}
|
|
|
|
-- Necessary local functions
|
|
-- Update the infobox
|
|
local function _updateInfoBox(c)
|
|
local _t,t
|
|
if c==nil then
|
|
if listBox.selected==0 then
|
|
if text.dict.helpText then
|
|
_t,t=true,text.dict.helpText:repD(
|
|
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.key.winMenu
|
|
)
|
|
else -- Fallback
|
|
listBox.selected=lastSelected
|
|
scene.widgetList.help.color=COLOR.Z
|
|
MES.new("error","Cannot found the Help text! Maybe just a mistake?")
|
|
return
|
|
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
|
|
end
|
|
local _w,c=FONT.get(currentFontSize):getWrap(c,840)
|
|
textBox:setTexts(c)
|
|
end
|
|
-- Clear the result
|
|
local function _clearResult()
|
|
TABLE.cut(result)
|
|
listBox.selected,lastSelected,searchWait,lastSearch=1,1,0,false
|
|
scene.widgetList.copy.hide=false
|
|
_updateInfoBox()
|
|
end
|
|
-- Search through the dictionary
|
|
local function _search()
|
|
local input=inputBox:getText()
|
|
local pos
|
|
_clearResult()
|
|
local first
|
|
if dict=='vi' then
|
|
local success,input=pcall(function() STRING.lowerUTF8(input) end)
|
|
if not success then input=input:lower() end
|
|
else
|
|
input=input:lower() end
|
|
for i=1,#dict do
|
|
if dict=='vi' then
|
|
pos=find(STRING.lowerUTF8(dict[i].title),input,nil,true) or find(STRING.lowerUTF8(dict[i].keywords),input,nil,true)
|
|
else
|
|
pos=find(dict[i].title:lower(),input,nil,true) or find(dict[i].keywords:lower(),input,nil,true)
|
|
end
|
|
if pos==1 and not first then
|
|
ins(result,1,dict[i])
|
|
first=true
|
|
elseif pos then
|
|
ins(result,dict[i])
|
|
end
|
|
end
|
|
|
|
listBox:setList(_getList())
|
|
|
|
if #result>0 then SFX.play('reach') end
|
|
lastSearch=input
|
|
_updateInfoBox()
|
|
end
|
|
|
|
-- Jump over n items
|
|
local function _jumpover(key,n)
|
|
local dir=(key=='left' or key=='pageup') and 'up' or 'down'
|
|
for _=1,n or 1 do scene.widgetList.listBox:arrowKey(dir) end
|
|
|
|
_updateInfoBox()
|
|
lastSelected=listBox.selected
|
|
scene.widgetList.copy.hide=false
|
|
end
|
|
|
|
-- Copy the content
|
|
local function _copy()
|
|
local t=_getList()[listBox.selected]
|
|
t=t.title_Org..":\n"..t.content_Org..(t.url and "\n[ "..t.url.." ]\n" or "\n")..text.dictNote
|
|
love.system.setClipboardText(t)
|
|
scene.widgetList.copy.hide=true
|
|
MES.new('info',text.copyDone)
|
|
end
|
|
|
|
-- Changing font size, z=0 --> reset
|
|
local function _setZoom(z)
|
|
currentFontSize=MATH.clamp(z~=0 and currentFontSize+z or 25,15,40)
|
|
textBox.font=currentFontSize
|
|
textBox.lineH=currentFontSize*7/5 -- Recalculate the line's height
|
|
textBox.capacity=math.ceil((textBox.h-10)/textBox.lineH)
|
|
_updateInfoBox()
|
|
MES.new("check",z~=0 and text.dict.sizeChanged:repD(currentFontSize) or text.dict.sizeReset,1.26)
|
|
end
|
|
|
|
-- Reset everything when opening Zictionary
|
|
function scene.enter()
|
|
localeFile='parts.language.dict_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or SETTING.locale:find'vi' and 'vi' or 'en')
|
|
dict=require(localeFile)
|
|
_scanDict(dict)
|
|
|
|
inputBox:clear()
|
|
result={}
|
|
|
|
searchWait=0
|
|
lastSelected=0
|
|
lastSearch=false
|
|
listBox:setList(_getList())
|
|
scene.widgetList.help.color=COLOR.Z
|
|
|
|
if not MOBILE then WIDGET.focus(inputBox) end
|
|
BG.set('rainbow')
|
|
end
|
|
|
|
function scene.wheelMoved(_,y)
|
|
if WIDGET.sel==listBox then
|
|
listBox:scroll(-y)
|
|
else
|
|
textBox:scroll(-y)
|
|
end
|
|
end
|
|
function scene.keyDown(key)
|
|
local inputBoxFocus=WIDGET.isFocus(inputBox)
|
|
|
|
-- Switching selected items
|
|
if key=='up' or key=='down' then
|
|
textBox:scroll(key=='up' and -1 or 1)
|
|
|
|
elseif (key=='left' or key=='pageup' or key=='right' or key=='pagedown') then
|
|
_jumpover(key,love.keyboard.isDown('lctrl','rctrl','lalt','ralt','lshift','rshift') and 12)
|
|
|
|
elseif key=='cC' or key=='c' and love.keyboard.isDown('lctrl','rctrl') then
|
|
if listBox.selected>0 then
|
|
_copy()
|
|
end
|
|
|
|
elseif (key=='-' or key=='=' or key=='0') and (inputBox:getText()=="" or not inputBoxFocus) and not MOBILE then
|
|
WIDGET.unFocus(true)
|
|
_setZoom(key=='0' and 0 or key=='-' and -5 or 5)
|
|
|
|
elseif key=='application' and listBox.selected>=0 then
|
|
local url=_getList()[listBox.selected].url
|
|
if url then love.system.openURL(url) end
|
|
elseif key=='delete' then
|
|
if inputBox:hasText() then
|
|
_clearResult()
|
|
inputBox:clear()
|
|
SFX.play('hold')
|
|
_updateInfoBox()
|
|
end
|
|
elseif key=='escape' then
|
|
if inputBox:hasText() then
|
|
scene.keyDown('delete')
|
|
else
|
|
SCN.back()
|
|
end
|
|
elseif key=='f1' then
|
|
-- inputBox:clear()
|
|
-- _clearResult()
|
|
listBox.selected=listBox.selected==0 and lastSelected or 0
|
|
scene.widgetList.help.color=listBox.selected==0 and COLOR.W or COLOR.Z
|
|
searchWait=0
|
|
_updateInfoBox()
|
|
|
|
-- ***ONLY USE FOR HOTLOADING ZICTIONARY WHILE IN GAME!***
|
|
-- ***Please commenting out this code if you don't use***
|
|
-- elseif key=='f5' then
|
|
-- local _
|
|
-- local success,_r=pcall(function()
|
|
-- package.loaded[localeFile]=nil
|
|
-- dict=require(localeFile)
|
|
-- _scanDict(dict)
|
|
-- end
|
|
-- )
|
|
-- if not success then
|
|
-- SFX.play('finesseError_long')
|
|
-- _,_r=FONT.get(30):getWrap(tostring(_r),1000)
|
|
-- MES.new("error","Hotload failed! May need restarting!\n\n"..table.concat(_r,"\n"))
|
|
-- else
|
|
-- local lastLscrollPos=listBox.scrollPos
|
|
-- local lastTscrollPos=textBox.scrollPos
|
|
-- listBox:setList(_getList())
|
|
-- if #inputBox:getText()>0 then _search() end
|
|
-- listBox.selected=lastSelected<#dict and lastSelected or #dict -- In case the last item is removed!
|
|
-- listBox.scrollPos=lastLscrollPos
|
|
-- _updateInfoBox()
|
|
-- textBox.scrollPos=lastTscrollPos
|
|
-- SFX.play('pc')
|
|
-- end
|
|
else
|
|
if not inputBoxFocus then WIDGET.focus(inputBox) end
|
|
return true
|
|
end
|
|
end
|
|
|
|
function scene.gamepadDown(key)
|
|
local Joystick=love.joystick.getJoysticks()[love.joystick.getJoystickCount()]
|
|
|
|
if key=='dpup' or key=='dpdown' then
|
|
if Joystick:isGamepadDown('a') then
|
|
_setZoom(key=='dpup' and 5 or -5)
|
|
else
|
|
textBox:scroll(key=='dpup' and -3 or 3)
|
|
end
|
|
elseif key=='dpleft' or key=='dpright' then
|
|
_jumpover(key:gsub('dp',''),Joystick:isGamepadDown('a') and 12)
|
|
elseif key=='y' then
|
|
scene.keyDown('f1')
|
|
elseif key=='back' then
|
|
SCN.back()
|
|
end
|
|
end
|
|
|
|
function scene.update(dt)
|
|
local input=inputBox:getText()
|
|
if input~=lastTickInput then
|
|
if #input==0 then
|
|
_clearResult()
|
|
listBox:setList(_getList())
|
|
else
|
|
searchWait=.8
|
|
end
|
|
lastTickInput=input
|
|
end
|
|
if searchWait>0 then
|
|
searchWait=searchWait-dt
|
|
if searchWait<=0 and #input>0 and input~=lastSearch then
|
|
_search()
|
|
end
|
|
end
|
|
if listBox.selected~=lastSelected and listBox.selected~=0 then
|
|
if listBox.selected==0 then scene.keyDown('f1') end
|
|
lastSelected=listBox.selected
|
|
scene.widgetList.copy.hide=false
|
|
_updateInfoBox()
|
|
end
|
|
end
|
|
|
|
function scene.draw()
|
|
-- Draw background
|
|
gc.setColor(COLOR.dX)
|
|
gc.rectangle('fill',1194,335,80,370,5)
|
|
gc.rectangle('fill',1194,180,80,80 ,5) -- Help key
|
|
-- Draw outline
|
|
gc.setLineWidth(2)
|
|
gc.setColor(COLOR.Z)
|
|
gc.rectangle('line',1194,335,80,370,5)
|
|
gc.line(1194,555,1274,555)
|
|
gc.rectangle('line',1194,180,80,80 ,5) -- Help key
|
|
|
|
if searchWait>0 then
|
|
local r=TIME()*2
|
|
local R=floor(r)%7+1
|
|
gc.setColor(1,1,1,1-abs(r%1*2-1))
|
|
gc.draw(TEXTURE.miniBlock[R],821,140,TIME()*10%6.2832,7,7,2*DSCP[R][0][2]+1,2*(#BLOCKS[R][0]-DSCP[R][0][1])-1)
|
|
end
|
|
end
|
|
|
|
scene.widgetList={
|
|
WIDGET.newText {name='book', x=20, y=15, font=70,align='L',fText=CHAR.icon.zBook},
|
|
WIDGET.newText {name='title', x=100, y=15, font=70,align='L'},
|
|
listBox,
|
|
inputBox,
|
|
textBox,
|
|
WIDGET.newKey {name='link', x=1234,y=595,w=60,font=45,fText=CHAR.icon.globe, code=pressKey'application',hideF=function() return not (listBox.selected>0 and _getList()[listBox.selected].url) end},
|
|
WIDGET.newKey {name='copy', x=1234,y=665,w=60,font=40,fText=CHAR.icon.copy, code=pressKey'cC',hideF=function() return not (listBox.selected>0) end},
|
|
|
|
WIDGET.newKey {name='zoomin', x=1234,y=375,w=60,font=40,fText=CHAR.icon.zoomIn, code=function() _setZoom(5) end},
|
|
WIDGET.newKey {name='zoomout', x=1234,y=445,w=60,font=40,fText=CHAR.icon.zoomOut, code=function() _setZoom(-5) end},
|
|
WIDGET.newKey {name='resetzoom',x=1234,y=515,w=60,font=40,fText=CHAR.icon.zoomDefault,code=function() _setZoom(0) end},
|
|
|
|
WIDGET.newKey {name='help', x=1234,y=220,w=60,font=40,fText=CHAR.icon.help, code=pressKey'f1'},
|
|
|
|
WIDGET.newButton{name='back', x=1185,y=60, w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
|
WIDGET.newText {name='buttontip',x=1274,y=110,w=762,h=60,font=40,align='R',fText=CHAR.controller.xboxY.."/[F1]: "..CHAR.icon.help}
|
|
}
|
|
-- NOTE: The gap between Link-Copy, Zoom is 60*1.5-10=80 :) The gap between 2 buttons in one group is 60+10=70
|
|
return scene |