Files
Techmino/parts/scenes/dict.lua
C6H12O6 + NaCl + H2O 7f8e3e647a Update Zictionary scene + Small change in Vietnamese translation (#935)
* 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: b212fff8 7be2aa50
Author: 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

commit 7be2aa50dd
Author: 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

commit ed9417dcdf
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Aug 3 22:57:06 2023 +0700

    Reupdate Vietnamese translation (#930)

commit b212fff8d9
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Aug 3 20:54:45 2023 +0700

    Small update

commit b59d1dc188
Merge: 8fcdbd9d 36522c71
Author: 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

commit 36522c7146
Author: MrZ_26 <1046101471@qq.com>
Date:   Thu Aug 3 16:04:04 2023 +0800

    修复词典用不了滚轮
    整理代码

commit 20b74ea78a
Author: MrZ_26 <1046101471@qq.com>
Date:   Thu Aug 3 13:46:27 2023 +0800

    词典交互和代码逻辑优化
    框架跟进

commit 0ae9cbcdaa
Author: MrZ_26 <1046101471@qq.com>
Date:   Thu Aug 3 10:11:27 2023 +0800

    删行末空格

commit c9cbb0e363
Author: MrZ_26 <1046101471@qq.com>
Date:   Wed Aug 2 21:45:31 2023 +0800

    修复fixed序列反了

commit 0595ce4ea6
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Wed Aug 2 10:44:01 2023 +0700

    Update Vietnamese translation (again) (#929)

commit 8fcdbd9df5
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Wed Aug 2 10:22:54 2023 +0700

    remove duplicate

commit 798ea1be4f
Author: 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)

commit e6f4f69f6f
Merge: 14630990 fa89ba55
Author: 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

commit 14630990be
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 23:43:35 2023 +0700

    Small change

commit 7a15406262
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sat Jul 15 00:46:17 2023 +0700

    small update

commit 1d10f14c8e
Author: 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

commit 07341d48e4
Author: 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)

commit 2e2427f942
Author: MrZ_26 <1046101471@qq.com>
Date:   Wed Aug 2 10:34:19 2023 +0800

    框架跟进

commit aeddee2f03
Author: MrZ_26 <1046101471@qq.com>
Date:   Wed Aug 2 10:23:20 2023 +0800

    修复自定义页面编辑场地消行按钮用不了

commit 43037f8043
Author: 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)

commit 0c3d552d08
Author: MrZ_26 <1046101471@qq.com>
Date:   Wed Aug 2 00:46:54 2023 +0800

    越南语语言文件小修正

commit fa89ba55aa
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 23:43:35 2023 +0700

    Small change

commit a1b6b8a434
Author: 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)

commit 5061cad389
Author: 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

commit a26c49451b
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 11:01:26 2023 +0700

    Fix tip again (x2)

commit d66b2d6131
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 10:39:08 2023 +0700

    Fix tip again

commit e95f87ace1
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 10:35:13 2023 +0700

    Fix tip

commit 1ccd211bfc
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Aug 1 10:12:23 2023 +0700

    Add a funny tip 🤪

commit 86ce124dd0
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 31 22:49:09 2023 +0700

    Fixed wrong group tag

commit 7d62a04b17
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 31 22:47:02 2023 +0700

    Clean up outdated comment

commit fd3910fe14
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 31 15:37:10 2023 +0700

    small change

commit 4ab59ef4a2
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 31 12:13:45 2023 +0700

    Small change

commit bf5f7cb2c9
Merge: bb7b1b93 9d3fb33d
Author: 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

commit 9d3fb33d10
Author: 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

commit 4d82b182a6
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 31 02:53:15 2023 +0800

    语言选择场景标题文本修改

commit bb7b1b93cb
Author: 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

commit 5358538cb4
Merge: 23fd5cdb 78ac05ef
Author: 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

commit 23fd5cdbb9
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Fri Jul 28 23:33:19 2023 +0700

    small update

commit 4796a57bb4
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Fri Jul 28 23:23:18 2023 +0700

    Sort group, adapt #926

commit 78ac05efba
Author: MrZ_26 <1046101471@qq.com>
Date:   Wed Jul 26 02:02:42 2023 +0800

    框架跟进

commit cd7c58eb32
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 24 15:54:33 2023 +0700

    Small updates

commit 53857af2fa
Merge: a2cdd6f3 02cf7b71
Author: 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

commit a2cdd6f367
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sun Jul 23 21:59:28 2023 +0700

    Replace alnost "hố" --> "lỗ

commit 02cf7b71c1
Merge: 091bb234 aefde7a7
Author: MrZ_26 <1046101471@qq.com>
Date:   Thu Jul 20 15:00:40 2023 +0800

    Merge remote-tracking branch 'tech/imple/revise-seq-generator'

commit 4629b4718f
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 17 22:17:15 2023 +0700

    Small updates

commit 9907971722
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 17 22:04:06 2023 +0700

    Small updates

commit 16d89195d5
Author: C6H12O6 + NaCl + H2O <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 17 09:58:28 2023 +0700

    Remove old info

commit 091bb23488
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 10:47:23 2023 +0800

    词典标题栏不会溢出了

commit 0ec0d80e9c
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 10:29:38 2023 +0800

    修复手柄摇杆左右的图标反了 close #912

commit d4d87ccb5c
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 05:50:18 2023 +0800

    调整bagP1inf序列模式位置

commit c782c1fcdd
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 05:47:20 2023 +0800

    修复四连块之外的ASC旋转中心不正确 close #910

commit f7cdae8677
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 04:24:49 2023 +0800

    修复玩家死亡掉落动画任务能跨局把新开的局里的玩家移除 close #918

commit f41a68de0d
Author: MrZ_26 <1046101471@qq.com>
Date:   Mon Jul 17 04:19:32 2023 +0800

     添加bagPinf序列模式的图标

commit c38bb7986a
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 17 00:15:31 2023 +0700

    Small changes + NEW TOOL!

commit 80b56af045
Author: 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

commit 745f836ddf
Author: 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

commit 9f45842046
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sun Jul 16 12:23:14 2023 +0700

    Push updates

commit 9b7c09d89c
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sun Jul 16 11:50:04 2023 +0700

    Push small updates, READY!

commit be11a9ada4
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sun Jul 16 11:25:52 2023 +0700

    Push

commit 92361e073c
Author: 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?

commit 146db2325d
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sat Jul 15 09:15:08 2023 +0700

    Small update

commit 9ec237acc1
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sat Jul 15 00:46:17 2023 +0700

    small update

commit c39c6c0701
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sat Jul 15 00:42:14 2023 +0700

    Push update

commit 1273d54135
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Sat Jul 15 00:42:01 2023 +0700

    Small change in updatelog

commit b649d9864d
Merge: 58df11fe 3dc61688
Author: 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

commit 58df11feb3
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Fri Jul 14 10:12:33 2023 +0700

    Some updates

commit aefde7a777
Merge: 7e00a7d7 3dc61688
Author: 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

commit 3dc61688c4
Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Date:   Thu Jul 13 13:26:17 2023 +0800

    add new generator: bagP1inf (#916)

commit 6502af6003
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Jul 13 09:10:20 2023 +0700

    Little update

commit 42f0671223
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Jul 13 07:38:06 2023 +0700

    Minor changes

commit 7f2f608fd4
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Jul 13 00:40:08 2023 +0700

    Nvm, little change

commit 8e0315762f
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Thu Jul 13 00:32:27 2023 +0700

    Add tips that missing

commit 7e00a7d764
Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Date:   Wed Jul 12 07:42:50 2023 +0800

    use `trueNextCount` as replay-visible next count

commit 8304cf655b
Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Date:   Wed Jul 12 07:27:22 2023 +0800

    make sequence generator independent of player

commit 7d4d664b5b
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Jul 11 23:17:38 2023 +0700

    small update

commit 34c125504b
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Tue Jul 11 20:47:14 2023 +0700

    Push updates

commit c25e7a3d5b
Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Date:   Tue Jul 11 20:05:31 2023 +0800

    fix noInitSZO

commit b7b02ab5bc
Author: Imple Lee <80144331+ImpleLee@users.noreply.github.com>
Date:   Tue Jul 11 19:50:52 2023 +0800

    simplify sequence generator

commit f0e2a6d162
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 10 21:08:22 2023 +0700

    Revert change

commit b1b39a3a67
Author: 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

commit 47b201ed71
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 10 14:38:46 2023 +0700

    Update the manual

commit 6c59718274
Author: Squishy (C6H12O6+NaCl+H2O) <106439598+SweetSea-ButImNotSweet@users.noreply.github.com>
Date:   Mon Jul 10 12:12:34 2023 +0700

    Small update

commit 974895ca03
Author: 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
2023-08-28 01:55:34 +08:00

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