From e2da67f302df34e460c9b0972b32415bd064fa0f Mon Sep 17 00:00:00 2001 From: Adrian Date: Sat, 21 Sep 2024 09:51:58 -0400 Subject: [PATCH] doc and mini-refactor --- src/data/emoji.ts | 102 +++++++++++---------- src/locales/ca_ES/menu.json | 1 + src/locales/de/menu.json | 2 +- src/locales/en/menu.json | 2 +- src/locales/es/menu.json | 2 +- src/locales/fr/menu.json | 2 +- src/locales/it/menu.json | 2 +- src/locales/ja/menu.json | 1 + src/locales/ko/menu.json | 2 +- src/locales/pt_BR/menu.json | 2 +- src/locales/zh_CN/menu.json | 2 +- src/locales/zh_TW/menu.json | 1 + src/ui/abstact-option-select-ui-handler.ts | 1 + src/ui/autocomplete-ui-handler.ts | 69 +++++++------- src/ui/form-modal-ui-handler.ts | 2 +- src/ui/modal-ui-handler.ts | 6 +- src/ui/rename-form-ui-handler.ts | 85 +++++++++-------- src/ui/test-dialogue-ui-handler.ts | 17 +--- 18 files changed, 151 insertions(+), 150 deletions(-) diff --git a/src/data/emoji.ts b/src/data/emoji.ts index 84ee4cd45dc..8a2b566094c 100644 --- a/src/data/emoji.ts +++ b/src/data/emoji.ts @@ -6,57 +6,59 @@ export default [ "☻", "♀", "♂", + "$", + "¢", + "£", + "¥", + "€", + "₽", // "☼", -// "ª", -// "►", -// "♫", -// "←", -// "→", -// "↩", -// "↪", -// "※", -// "⁜", -// "¶", -// "©", -// "®", -// "℗", -// "™", -// "$", -// "¢", -// "£", -// "¥", -// "↖", -// "↗", -// "↙", -// "↘", -// "↜", -// "↝", -// "↟", -// "↡", -// "↢", -// "↣", -// "↤", -// "↦", -// "↔", -// "↕", -// "↚", -// "↛", -// "↞", -// "↠", -// "↥", -// "↧", -// "↨", -// "↭", -// "↮", -// "↯", -// "↴", -// "↵", -// "↺", -// "↻", -// "↸", -// "↹", -// "↰", -// "↱" + // "ª", + // "►", + // "♫", + // "←", + // "→", + // "↩", + // "↪", + // "※", + // "⁜", + // "¶", + // "©", + // "®", + // "℗", + // "™", + // "↖", + // "↗", + // "↙", + // "↘", + // "↜", + // "↝", + // "↟", + // "↡", + // "↢", + // "↣", + // "↤", + // "↦", + // "↔", + // "↕", + // "↚", + // "↛", + // "↞", + // "↠", + // "↥", + // "↧", + // "↨", + // "↭", + // "↮", + // "↯", + // "↴", + // "↵", + // "↺", + // "↻", + // "↸", + // "↹", + // "↰", + // "↱" ] as string[]; export const emojiRegex: RegExp = /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g; diff --git a/src/locales/ca_ES/menu.json b/src/locales/ca_ES/menu.json index 42b0847b2f2..a1f2012b689 100644 --- a/src/locales/ca_ES/menu.json +++ b/src/locales/ca_ES/menu.json @@ -50,6 +50,7 @@ "choosePokemon": "Elegir un Pokémon.", "renamePokemon": "Rebatejar Pokémon", "rename": "Rebatejar", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Sobrenom", "errorServerDown": "Vaja! S'ha produït un problema en contactar amb el servidor.\n\nPots deixar aquesta pestanya oberta,\nel joc es tornarà a connectar automàticament." } diff --git a/src/locales/de/menu.json b/src/locales/de/menu.json index f91d5036aa7..60e0f0b52d0 100644 --- a/src/locales/de/menu.json +++ b/src/locales/de/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Wähle ein Pokémon.", "renamePokemon": "Pokémon umbennenen", "rename": "Umbenennen", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Spitzname", "errorServerDown": "Ups! Es gab einen Fehler beim Versuch\nden Server zu kontaktieren\nLasse dieses Fenster offen\nDu wirst automatisch neu verbunden.", "noSaves": "Du hast keine gespeicherten Dateien!", diff --git a/src/locales/en/menu.json b/src/locales/en/menu.json index 89c9684a6ed..0aac1d660ad 100644 --- a/src/locales/en/menu.json +++ b/src/locales/en/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Choose a Pokémon.", "renamePokemon": "Rename Pokémon", "rename": "Rename", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Nickname", "errorServerDown": "Oops! There was an issue contacting the server.\n\nYou may leave this window open,\nthe game will automatically reconnect.", "noSaves": "You don't have any save files on record!", diff --git a/src/locales/es/menu.json b/src/locales/es/menu.json index e1be4c63615..8df7e034945 100644 --- a/src/locales/es/menu.json +++ b/src/locales/es/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Elige un Pokémon.", "renamePokemon": "Renombrar Pokémon.", "rename": "Renombrar", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Apodo", "errorServerDown": "¡Ups! Ha habido un problema al contactar con el servidor.\n\nPuedes mantener esta ventana abierta,\nel juego se reconectará automáticamente.", "noSaves": "No tienes ninguna partida guardada registrada!", diff --git a/src/locales/fr/menu.json b/src/locales/fr/menu.json index 8d63bc8f2fe..59616046fec 100644 --- a/src/locales/fr/menu.json +++ b/src/locales/fr/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Sélectionnez un Pokémon.", "renamePokemon": "Renommer le Pokémon", "rename": "Renommer", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Surnom", "errorServerDown": "Oupsi ! Un problème de connexion au serveur est survenu.\n\nVous pouvez garder cette fenêtre ouverte,\nle jeu se reconnectera automatiquement.", "noSaves": "Vous n’avez aucune sauvegarde enregistrée !", diff --git a/src/locales/it/menu.json b/src/locales/it/menu.json index 78b90ff8a27..431806024ca 100644 --- a/src/locales/it/menu.json +++ b/src/locales/it/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Scegli un Pokémon.", "renamePokemon": "Rinomina un Pokémon", "rename": "Rinomina", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Nickname", "errorServerDown": "Poffarbacco! C'è stato un errore nella comunicazione col server.\n\nPuoi lasciare questa finestra aperta,\nil gioco si riconnetterà automaticamente.", "noSaves": "Non ci sono file di salvataggio registrati!", diff --git a/src/locales/ja/menu.json b/src/locales/ja/menu.json index f0914a7941c..a3f725c3308 100644 --- a/src/locales/ja/menu.json +++ b/src/locales/ja/menu.json @@ -50,6 +50,7 @@ "choosePokemon": "ポケモンを選ぶ", "renamePokemon": "ニックネームを変える", "rename": "名前を変える", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "ニックネーム", "errorServerDown": "おや!\nサーバーとの 接続中に 問題が 発生しました。\nゲームは 自動的に 再接続されます から\nウィンドウは 開いたままに しておいても よろしいです。", "noSaves": "何の セーブファイルも ありません!", diff --git a/src/locales/ko/menu.json b/src/locales/ko/menu.json index 9d89f66b338..7eee4a732a3 100644 --- a/src/locales/ko/menu.json +++ b/src/locales/ko/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "포켓몬을 선택하세요.", "renamePokemon": "포켓몬의 닉네임은?", "rename": "닉네임 바꾸기", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "닉네임", "errorServerDown": "서버 연결 중 문제가 발생했습니다.\n\n이 창을 종료하지 않고 두면,\n게임은 자동으로 재접속됩니다.", "noSaves": "기기에 세이브 파일이 없습니다!", diff --git a/src/locales/pt_BR/menu.json b/src/locales/pt_BR/menu.json index c8b9940ca74..052720993ba 100644 --- a/src/locales/pt_BR/menu.json +++ b/src/locales/pt_BR/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "Escolha um Pokémon.", "renamePokemon": "Renomear Pokémon", "rename": "Renomear", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "Apelido", "errorServerDown": "Opa! Não foi possível conectar-se ao servidor.\n\nVocê pode deixar essa janela aberta,\npois o jogo irá se reconectar automaticamente." } \ No newline at end of file diff --git a/src/locales/zh_CN/menu.json b/src/locales/zh_CN/menu.json index 279059a4ffe..f0d483db7ed 100644 --- a/src/locales/zh_CN/menu.json +++ b/src/locales/zh_CN/menu.json @@ -50,7 +50,7 @@ "choosePokemon": "选择一只宝可梦。", "renamePokemon": "给宝可梦起名", "rename": "起名", - "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji)", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "昵称", "errorServerDown": "糟糕!访问服务器时发生了错误。\n\n你可以保持页面开启,\n游戏会自动重新连接。", "noSaves": "你没有任何记录文件!", diff --git a/src/locales/zh_TW/menu.json b/src/locales/zh_TW/menu.json index fee9b1be85d..3af7d38fd05 100644 --- a/src/locales/zh_TW/menu.json +++ b/src/locales/zh_TW/menu.json @@ -47,6 +47,7 @@ "choosePokemon": "選擇一只寶可夢。", "renamePokemon": "給寶可夢起名", "rename": "起名", + "renameHelpEmoji": "Use \"/\" to access emoji library and enter a number to choose an emoji\n(e.g. \"/1\" for the first emoji, max. 6)", "nickname": "昵稱", "errorServerDown": "糟糕!訪問服務器時發生了錯誤。\n\n你可以保持頁面開啓,\n遊戲會自動重新連接。", "noSaves": "你沒有任何記錄檔!", diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index 4d55ff7c29f..2c326bafe98 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -354,5 +354,6 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { this.cursorObj.destroy(); } this.cursorObj = null; + this.scrollCursor = 0; } } diff --git a/src/ui/autocomplete-ui-handler.ts b/src/ui/autocomplete-ui-handler.ts index 1ec65d514bc..f0d6780e137 100644 --- a/src/ui/autocomplete-ui-handler.ts +++ b/src/ui/autocomplete-ui-handler.ts @@ -14,42 +14,11 @@ export interface OptionSelectConfigAC extends OptionSelectConfig { export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler { modalContainer: Phaser.GameObjects.Container; inputContainer: Phaser.GameObjects.Container; - handlerKeyDown: (inputObject: InputText, evt: KeyboardEvent) => void; - revertAutoCompleteMode: () => void; reverse?: true; constructor(scene: BattleScene, mode: Mode = Mode.AUTO_COMPLETE) { super(scene, mode); - - this.handlerKeyDown = (inputObject, evt) => { - // Don't move inputText cursor, cursor move fast for this - if (["arrowup"].some((key) => key === (evt.code || evt.key).toLowerCase())) { - evt.preventDefault(); - this.processInput(Button.UP); - } else if (["arrowdown"].some((key) => key === (evt.code || evt.key).toLowerCase())) { - evt.preventDefault(); - this.processInput(Button.DOWN); - } - - // Revert Mode if not press... - if (!["enter", "arrowup", "arrowdown", "shift", "control", "alt"].some((key) => (evt.code || evt.key).toLowerCase().includes(key))) { - this.revertAutoCompleteMode(); - } - - // Recovery focus - if (["escape"].some((key) => key === (evt.code || evt.key).toLowerCase())) { - const recoveryFocus = () => (inputObject.setFocus(), inputObject.off("blur", recoveryFocus)); - inputObject.on("blur", recoveryFocus); - } - }; - - this.revertAutoCompleteMode = () => { - const ui = this.getUi(); - if (ui.getMode() === Mode.AUTO_COMPLETE) { - ui.revertMode(); - } - }; - + this.handlerKeyDown = this.handlerKeyDown.bind(this); } getWindowWidth(): integer { @@ -124,7 +93,7 @@ export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler // If the modal goes off screen, center it // if ((this.optionSelectContainer.getBounds().width + this.optionSelectContainer.getBounds().x) > this.scene.game.canvas.width) { - // this.optionSelectContainer.setX(this.optionSelectContainer.getBounds().x - ((this.optionSelectContainer.getBounds().width + this.optionSelectContainer.getBounds().x) - this.scene.game.canvas.width)); + // this.optionSelectContainer.setX((this.optionSelectContainer.x) - ((this.optionSelectContainer.width + this.optionSelectContainer.x) - (this.scene.game.canvas.width / 6))); // } } } @@ -139,12 +108,44 @@ export default class AutoCompleteUiHandler extends AbstractOptionSelectUiHandler return false; } + handlerKeyDown (inputObject: InputText, evt: KeyboardEvent): void { + // Don't move inputText cursor + // TODO: cursor move fast for this + if (["arrowup"].some((key) => key === (evt.code || evt.key).toLowerCase())) { + evt.preventDefault(); + this.processInput(Button.UP); + } else if (["arrowdown"].some((key) => key === (evt.code || evt.key).toLowerCase())) { + evt.preventDefault(); + this.processInput(Button.DOWN); + } + + // Revert Mode if not press... + if (!["enter", "arrowup", "arrowdown", "shift", "control", "alt"].some((key) => (evt.code || evt.key).toLowerCase().includes(key))) { + this.revertAutoCompleteMode(); + } + + // Recovery focus + if (["escape"].some((key) => key === (evt.code || evt.key).toLowerCase())) { + const recoveryFocus = () => { + inputObject.setFocus(); + inputObject.off("blur", recoveryFocus); + }; + inputObject.on("blur", recoveryFocus); + } + } + + revertAutoCompleteMode(): void { + const ui = this.scene.ui; + if (ui.getMode() === Mode.AUTO_COMPLETE) { + ui.revertMode(); + } + } + clear(): void { super.clear(); const input = this.inputContainer.list.find((el) => el instanceof InputText); input?.off("keydown", this.handlerKeyDown); input?.off("blur", this.revertAutoCompleteMode); this.modalContainer.off("pointerdown", this.revertAutoCompleteMode); - this.scrollCursor = 0; } } diff --git a/src/ui/form-modal-ui-handler.ts b/src/ui/form-modal-ui-handler.ts index 331154263ad..610017ea2b5 100644 --- a/src/ui/form-modal-ui-handler.ts +++ b/src/ui/form-modal-ui-handler.ts @@ -91,7 +91,7 @@ export abstract class FormModalUiHandler extends ModalUiHandler { if (this.buttonBgs.length) { this.buttonBgs[0].off("pointerdown"); this.buttonBgs[0].on("pointerdown", () => { - if (this.submitAction) { + if (this.scene.ui.getMode() === this.mode && this.submitAction) { this.submitAction(); } }); diff --git a/src/ui/modal-ui-handler.ts b/src/ui/modal-ui-handler.ts index 80a39d7bf7f..570a009a846 100644 --- a/src/ui/modal-ui-handler.ts +++ b/src/ui/modal-ui-handler.ts @@ -119,7 +119,11 @@ export abstract class ModalUiHandler extends UiHandler { for (let a = 0; a < this.buttonBgs.length; a++) { if (a < this.buttonBgs.length) { - this.buttonBgs[a].on("pointerdown", (_) => config.buttonActions[a]()); + this.buttonBgs[a].on("pointerdown", (_) => { + if (this.scene.ui.getMode() === this.mode) { + config.buttonActions[a](); + } + }); } } diff --git a/src/ui/rename-form-ui-handler.ts b/src/ui/rename-form-ui-handler.ts index aad5f29eea3..7f4b9bbdfe1 100644 --- a/src/ui/rename-form-ui-handler.ts +++ b/src/ui/rename-form-ui-handler.ts @@ -8,10 +8,15 @@ import { addWindow } from "./ui-theme"; import { addTextObject, getTextStyleOptions, TextStyle } from "./text"; import InputText from "phaser3-rex-plugins/plugins/inputtext"; import BattleScene from "#app/battle-scene"; -import AutoCompleteUiHandler, { OptionSelectConfigAC } from "./autocomplete-ui-handler"; +import { OptionSelectConfigAC } from "./autocomplete-ui-handler"; import emojisAvailable from "#app/data/emoji"; import { emojiRegex } from "#app/data/emoji"; +/** + * Split string with emojis, since emojis length is longer and native split doesn't work. + * @param str + * @returns string[] + */ function textArrayWithEmojis(str: string): string[] { const result: string[] = []; let match; @@ -33,7 +38,10 @@ function textArrayWithEmojis(str: string): string[] { } export default class RenameFormUiHandler extends FormModalUiHandler { - protected autocomplete: AutoCompleteUiHandler; + + constructor (scene, mode: Mode | null = Mode.RENAME_POKEMON) { + super(scene, mode); + } getModalTitle(config?: ModalConfig): string { return i18next.t("menu:renamePokemon"); @@ -71,11 +79,11 @@ export default class RenameFormUiHandler extends FormModalUiHandler { helpEmojiListContainer.add(helpEmojiListBg); const scale = getTextStyleOptions(TextStyle.WINDOW, (this.scene as BattleScene).uiTheme).scale ?? 0.1666666667; - const helpEmojiListText = addTextObject(this.scene, 8, 8, i18next.t("menu:renameHelpEmoji"), TextStyle.TOOLTIP_CONTENT, { + const helpEmojiListText = addTextObject(this.scene, 8, 4, i18next.t("menu:renameHelpEmoji"), TextStyle.TOOLTIP_CONTENT, { fontSize: "80px", }); - helpEmojiListText.setWordWrapWidth(this.modalContainer.getBounds().width * 0.95); - const height = ((Math.min((helpEmojiListText.getWrappedText(helpEmojiListText.text) || []).length, 99)) * 96 * scale) + helpEmojiListText.y; + helpEmojiListText.setWordWrapWidth(890); + const height = ((Math.min((helpEmojiListText.getWrappedText(helpEmojiListText.text)).length, 99)) * (80 + helpEmojiListText.y) * scale) + helpEmojiListText.y; helpEmojiListBg.setSize(helpEmojiListBg.width, height); helpEmojiListContainer.add(helpEmojiListText); @@ -96,18 +104,10 @@ export default class RenameFormUiHandler extends FormModalUiHandler { this.inputs[0].text = args[1]; } this.submitAction = (_) => { - if (ui.getMode() === Mode.RENAME_POKEMON) { - this.sanitizeInputs(); - const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); - config.buttonActions[0](sanitizedName); - return true; - } - }; - const originalCancel = config.buttonActions[1]; - config.buttonActions[1] = ()=>{ - if (ui.getMode() === Mode.RENAME_POKEMON) { - originalCancel(); - } + this.sanitizeInputs(); + const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); + config.buttonActions[0](sanitizedName); + return true; }; // emoji list config @@ -119,11 +119,11 @@ export default class RenameFormUiHandler extends FormModalUiHandler { label: `${emoji} /${index + 1}`, handler: ()=> { // Retrieve the exact command, as it can be either "/", or "/n" - const command = input.text.split("").filter((_, i) => i >= (input.text.split("").filter((_, i) => i < input.cursorPosition).lastIndexOf("/")) && i < input.cursorPosition).join(""); + const command = textArrayWithEmojis(input.text).filter((_, i) => i >= (textArrayWithEmojis(input.text).filter((_, i) => i < input.cursorPosition).lastIndexOf("/")) && i < input.cursorPosition).join(""); - const texto = input.text; - const textBeforeCursor = texto.substring(0, input.cursorPosition); - const textAfterCursor = texto.substring(input.cursorPosition); + const text = input.text; + const textBeforeCursor = text.substring(0, input.cursorPosition); + const textAfterCursor = text.substring(input.cursorPosition); const exactlyCommand = textBeforeCursor.lastIndexOf(command); if (exactlyCommand !== -1) { @@ -142,25 +142,19 @@ export default class RenameFormUiHandler extends FormModalUiHandler { }; input.on("textchange", (inputObject:InputText, evt:InputEvent) => { - // If deleting and currently positioned at "/", display the list of emojis - if ( - !evt.data && - input.text.split("").filter((char) => emojisAvailable.some((em) => em === char)).length < maxEmojis && - input.text.split("").some((char, i) => char === "/" && i + 1 === input.cursorPosition) - ) { - ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOptions); - } + const text = input.text; + const arrayText = textArrayWithEmojis(text); // Remove disallowed emojis. - if (textArrayWithEmojis(input.text).filter((char) => { - // const isEmoji = !char.match(/[\u0000-\u00ff]/); // Emojis, special characters and kaomojis + if (arrayText.filter((char) => { + // const isEmoji = !char.match(/[\u0000-\u00ff]/); // Emojis, special characters and kaomojis, technically const isEmoji = char.match(emojiRegex); // Only Emojis const isAllowedEmoji = emojisAvailable.includes(char); return isEmoji && !isAllowedEmoji; }).length) { const regex = emojiRegex; let totalLength: number = 0; - const newText = input.text.replace(regex, (match) => { + const newText = text.replace(regex, (match) => { if (emojisAvailable.includes(match)) { return match; } @@ -174,13 +168,16 @@ export default class RenameFormUiHandler extends FormModalUiHandler { } - // If the number of available emojis exceeds the maximum allowed number of emojis.. //.. Delete any attempt to insert another one. while (textArrayWithEmojis(input.text).filter((char) => emojisAvailable.includes(char)).length > maxEmojis) { - const charactersWithEmojis = textArrayWithEmojis(input.text); - const emojis = charactersWithEmojis.filter((char, i, arr) => { + const splitWithEmojis = textArrayWithEmojis(input.text); + + // Retrieve only the emojis that are trying to be inserted + const emojis = splitWithEmojis.filter((char, i, arr) => { if (emojisAvailable.includes(char)) { + // The length of the emojis is usually greater than one + // And many can also be inserted by pasting let totalLength = 0; for (let j = 0; j <= i; j++) { totalLength += arr[j].length; @@ -189,9 +186,10 @@ export default class RenameFormUiHandler extends FormModalUiHandler { } return false; }); - const cursorPosition = input.cursorPosition; const lastEmoji = emojis[emojis.length - 1]; - const lastEmojiIndex = charactersWithEmojis.filter((char, i, arr) => { + + // Retrieve only the position before the cursorInput of the last available emoji that you want to insert + const lastEmojiIndex = splitWithEmojis.filter((char, i, arr) => { let totalLength = 0; for (let j = 0; j <= i; j++) { totalLength += arr[j].length; @@ -200,22 +198,23 @@ export default class RenameFormUiHandler extends FormModalUiHandler { }).lastIndexOf(lastEmoji); if (lastEmojiIndex !== -1) { - const textBeforeCursor = charactersWithEmojis.slice(0, lastEmojiIndex).join(""); - const textAfterCursor = charactersWithEmojis.slice(lastEmojiIndex + 1).join(""); + const textBeforeCursor = splitWithEmojis.slice(0, lastEmojiIndex).join(""); + const textAfterCursor = splitWithEmojis.slice(lastEmojiIndex + 1).join(""); const newText = textBeforeCursor + textAfterCursor; - if (newText !== input.text) { + if (newText !== text) { + const previousCursor = input.cursorPosition; input.setText(newText); - input.setCursorPosition(cursorPosition - lastEmoji.length); + input.setCursorPosition(previousCursor - lastEmoji.length); } } } // If the number of available emojis has been reached, do not display the list of emojis - if (evt.data && input.text.split("").filter((char) => emojisAvailable.some((em) => em === char)).length < maxEmojis) { + if (arrayText.filter((char) => emojisAvailable.some((em) => em === char)).length < maxEmojis) { // Retrieve the exact command, as it can be either "/", or "/n" - const command = input.text.split("").filter((_, i, arr) => i >= (input.text.split("").filter((_, i) => i < input.cursorPosition).lastIndexOf("/")) && i < input.cursorPosition).join(""); + const command = arrayText.filter((_, i) => i >= (arrayText.filter((_, i) => i < input.cursorPosition).lastIndexOf("/")) && i < input.cursorPosition).join(""); if (evt.data === "/") { ui.setOverlayMode(Mode.AUTO_COMPLETE, modalOptions); diff --git a/src/ui/test-dialogue-ui-handler.ts b/src/ui/test-dialogue-ui-handler.ts index 94c6b703e8f..2d853d3713b 100644 --- a/src/ui/test-dialogue-ui-handler.ts +++ b/src/ui/test-dialogue-ui-handler.ts @@ -130,19 +130,10 @@ export default class TestDialogueUiHandler extends FormModalUiHandler { this.inputs[0].text = args[1]; } this.submitAction = (_) => { - if (ui.getMode() === Mode.TEST_DIALOGUE) { - this.sanitizeInputs(); - const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); - config.buttonActions[0](sanitizedName); - return true; - } - return false; - }; - const originalCancel = config.buttonActions[1]; - config.buttonActions[1] = ()=>{ - if (ui.getMode() === Mode.TEST_DIALOGUE) { - originalCancel(); - } + this.sanitizeInputs(); + const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text))); + config.buttonActions[0](sanitizedName); + return true; }; return true; }