latex bot discord
latexbot
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | .gitmodules | 6 | ||||
| -rw-r--r-- | Latex.gd | 130 | ||||
| -rw-r--r-- | Latex.tscn | 6 | ||||
| -rw-r--r-- | Main.tscn | 3 | ||||
| -rw-r--r-- | README.md | 44 | ||||
| l--------- | addons/discord_gd | 1 | ||||
| l--------- | addons/gdcli | 1 | ||||
| -rw-r--r-- | autoloads/CLI.gd | 11 | ||||
| -rw-r--r-- | export_presets.cfg | 360 | ||||
| -rw-r--r-- | html/.gdignore | 0 | ||||
| -rw-r--r-- | html/custom.html | 280 | ||||
| -rw-r--r-- | project.godot | 88 | ||||
| m--------- | submodules/discord.gd | 0 | ||||
| m--------- | submodules/gdcli | 0 |
15 files changed, 225 insertions, 711 deletions
@@ -6,3 +6,9 @@ logs/ .vscode/ exports/ *.x86_64 +token +*.tex +*.aux +*.dvi +*.log +texs/ diff --git a/.gitmodules b/.gitmodules index 68b663d..f941959 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "gdcli"] - path = submodules/gdcli - url = https://github.com/bend-n/gdcli +[submodule "submodules/discord.gd"] + path = submodules/discord.gd + url = https://github.com/3ddelano/discord.gd diff --git a/Latex.gd b/Latex.gd new file mode 100644 index 0000000..1f52119 --- /dev/null +++ b/Latex.gd @@ -0,0 +1,130 @@ +extends Node + +var template_tex := """ +\\documentclass[varwidth=true]{standalone} +\\usepackage[utf8]{inputenc} +\\usepackage{xcolor} +\\usepackage{amsmath} + +\\color{white} +\\begin{document} + +%s + +\\end{document} +""" + +var f := File.new() +var thread_pool := [] + + +func compile(source: String) -> RegEx: + var reg := RegEx.new() + reg.compile(source) + return reg + + +func _ready(): + for _i in range(5): + thread_pool.append(Thread.new()) + var dir = Directory.new() + if !dir.dir_exists("res://texs"): + dir.make_dir("texs") + f.open("res://texs/.gdignore", File.WRITE) # touch .gdignore + f.close() + var bot := DiscordBot.new() + add_child(bot) + var file = File.new() + var err = file.open("res://token", File.READ) + var token + if err == OK: + token = file.get_as_text() + elif OS.has_environment("TOKEN"): + token = OS.get_environment("TOKEN") + else: + push_error("token missing") + file.close() + bot.TOKEN = token + bot.connect("bot_ready", self, "_on_bot_ready") + bot.connect("message_create", self, "_on_message_create") + bot.login() + + +func _on_bot_ready(bot: DiscordBot): + bot.set_presence({"activity": {"type": "Game", "name": "Printing LaTeX"}}) + print("Logged in as " + bot.user.username + "#" + bot.user.discriminator) + print("Listening on " + str(bot.channels.size()) + " channels and " + str(bot.guilds.size()) + " guilds.") + + +func _on_message_create(bot: DiscordBot, message: Message, _channel: Dictionary): + if message.author.bot: + return + var msg: String + var reg := compile("`{3}(la)?tex([^`]+)`{3}") + var res := reg.search(message.content) + if res: + msg = res.strings[2] + else: + var reg2 := compile("!(la)?tex\\s*([\\s\\S]+)") + var res2 := reg2.search(message.content) + if !res2: + return + msg = res2.strings[2] + + msg = msg.strip_edges() + + print("----\n%s\n----" % msg) + if !msg: + return + + var th :Thread + for thread in thread_pool: + if !thread.is_alive(): + th = thread + break + if !th: + thread_pool.append(Thread.new()) + th = thread_pool[-1] + + th.start(self, "latex2img", template_tex % msg) + while true: + yield(get_tree(), "idle_frame") + if !th.is_alive(): + var img = th.wait_to_finish() + if img is Dictionary: + bot.reply(message, "No({err}): `{output}`".format(img)) + return + bot.reply( + message, + "Tex:", + {"files": [{"name": "code.png", "media_type": "image/png", "data": img.save_png_to_buffer()}]} + ) + return + + +func _notification(what): + if what == NOTIFICATION_EXIT_TREE: + OS.execute("bash", ["-c", "rm -r texs"], false) + + +func latex2img(latex: String): + randomize() + var name := ("%s-%s" % [randi() % 201, randi() % 201]).c_escape() + f.open("res://texs/%s.tex" % name, File.WRITE_READ) + f.store_string(latex) + f.close() + var output :PoolStringArray = [] + var err = OS.execute("bash", ["-c", "cd texs && latex -interaction=nonstopmode '%s.tex'" % name], true, output, true) + if err: + return {err = err, output = "(la)" + output.join(" ")} + output.resize(0) + var dvipng = [ + "-c", "dvipng -strict -bg Transparent --png -Q 250 -D 250 -T tight -o 'texs/%s.png' 'texs/%s.dvi'" % [name, name] + ] + err = OS.execute("bash", dvipng, true, output, true) + if err: + return {err = err, output = "(dvi)" +output.join(" ")} + var img := Image.new() + err = img.load("res://texs/%s.png" % name) + OS.execute("bash", ["-c", "rm 'texs/%s.'*" % name], false) + return img diff --git a/Latex.tscn b/Latex.tscn new file mode 100644 index 0000000..a38fcf6 --- /dev/null +++ b/Latex.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Latex.gd" type="Script" id=1] + +[node name="Latex" type="Node"] +script = ExtResource( 1 ) diff --git a/Main.tscn b/Main.tscn deleted file mode 100644 index 70a653e..0000000 --- a/Main.tscn +++ /dev/null @@ -1,3 +0,0 @@ -[gd_scene format=2] - -[node name="Main" type="Node2D"] @@ -3,46 +3,4 @@ [](https://godotengine.org "Made with godot") <a href='https://ko-fi.com/bendn' title='Buy me a coffee' target='_blank'><img height='28' src='https://storage.ko-fi.com/cdn/brandasset/kofi_button_red.png' alt='Buy me a coffee'> </a> -Godot template repository for my programs - ---- - -## How to use - -- Click use this template button -- Clone your new repository -- Add your files & change `FUNDING.yml` -- Commit & push - -<details> -<summary>For itch.io depoloyment</summary> -<br> - -Add a secret called `BUTLER_CREDENTIALS` with your [butler api key](https://itch.io/user/settings/api-keys). - -</details> - -<details> -<summary>For android builds</summary> -<br> - -> **Note** -> -> The keystore user/alias is found automatically. - -Add two secrets: - -- `ANDROID_KEYSTORE_BASE64` -- `ANDROID_KEYSTORE_PASSWORD` - -</details> - ---- - -### Availability - -| windows | ios | linux | android | mac | html | | -| :----------------: | :-: | :----------------: | :----------------: | :----------------: | :----------------: | :-----------: | -| :x: | :x: | :x: | :x: | :x: | :heavy_check_mark: | github pages | -| :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | itch.io | -| :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | godot exports | +Discord bot for printing latex. diff --git a/addons/discord_gd b/addons/discord_gd new file mode 120000 index 0000000..737cb4a --- /dev/null +++ b/addons/discord_gd @@ -0,0 +1 @@ +../submodules/discord.gd/addons/discord_gd/
\ No newline at end of file diff --git a/addons/gdcli b/addons/gdcli deleted file mode 120000 index ac119d8..0000000 --- a/addons/gdcli +++ /dev/null @@ -1 +0,0 @@ -../submodules/gdcli/addons/gdcli/
\ No newline at end of file diff --git a/autoloads/CLI.gd b/autoloads/CLI.gd deleted file mode 100644 index 095bfd3..0000000 --- a/autoloads/CLI.gd +++ /dev/null @@ -1,11 +0,0 @@ -extends Node - -func _ready() -> void: - var p := Parser.new() - p.add_argument(Arg.new({triggers=["-h", "--help", "-?"], help="show this help message and exit", action="store_true"})) - var args = p.parse_arguments() - if args == null: - get_tree().quit() - elif args.get("help", false): - print(p.help()) - get_tree().quit()
\ No newline at end of file diff --git a/export_presets.cfg b/export_presets.cfg index 9270cf2..fb88f7e 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -1,48 +1,5 @@ [preset.0] -name="Windows" -platform="Windows Desktop" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="" -script_export_mode=1 -script_encryption_key="" - -[preset.0.options] - -custom_template/debug="" -custom_template/release="" -binary_format/64_bits=true -binary_format/embed_pck=true -texture_format/bptc=false -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false -texture_format/no_bptc_fallbacks=true -codesign/enable=false -codesign/identity_type=0 -codesign/identity="" -codesign/password="" -codesign/timestamp=true -codesign/timestamp_server_url="" -codesign/digest_algorithm=1 -codesign/description="" -codesign/custom_options=PoolStringArray( ) -application/modify_resources=false -application/icon="" -application/file_version="" -application/product_version="" -application/company_name="" -application/product_name="" -application/file_description="" -application/copyright="" -application/trademarks="" - -[preset.1] - name="Linux" platform="Linux/X11" runnable=true @@ -54,7 +11,7 @@ export_path="" script_export_mode=1 script_encryption_key="" -[preset.1.options] +[preset.0.options] custom_template/debug="" custom_template/release="" @@ -65,318 +22,3 @@ texture_format/s3tc=true texture_format/etc=false texture_format/etc2=false texture_format/no_bptc_fallbacks=true - -[preset.2] - -name="HTML" -platform="HTML5" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="" -script_export_mode=1 -script_encryption_key="" - -[preset.2.options] - -custom_template/debug="" -custom_template/release="" -variant/export_type=0 -vram_texture_compression/for_desktop=true -vram_texture_compression/for_mobile=false -html/export_icon=true -html/custom_html_shell="res://html/custom.html" -html/head_include="" -html/canvas_resize_policy=2 -html/focus_canvas_on_start=true -html/experimental_virtual_keyboard=true -progressive_web_app/enabled=false -progressive_web_app/offline_page="" -progressive_web_app/display=1 -progressive_web_app/orientation=0 -progressive_web_app/icon_144x144="" -progressive_web_app/icon_180x180="" -progressive_web_app/icon_512x512="" -progressive_web_app/background_color=Color( 0, 0, 0, 1 ) - -[preset.3] - -name="Mac" -platform="Mac OSX" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="" -script_export_mode=1 -script_encryption_key="" - -[preset.3.options] - -custom_template/debug="" -custom_template/release="" -application/name="Godot Template" -application/info="Godot Template" -application/icon="" -application/identifier="com.godot-template" -application/signature="" -application/app_category="Games" -application/short_version="1.0" -application/version="1.0" -application/copyright="" -display/high_res=false -privacy/microphone_usage_description="" -privacy/camera_usage_description="" -privacy/location_usage_description="" -privacy/address_book_usage_description="" -privacy/calendar_usage_description="" -privacy/photos_library_usage_description="" -privacy/desktop_folder_usage_description="" -privacy/documents_folder_usage_description="" -privacy/downloads_folder_usage_description="" -privacy/network_volumes_usage_description="" -privacy/removable_volumes_usage_description="" -codesign/enable=true -codesign/identity="" -codesign/timestamp=true -codesign/hardened_runtime=true -codesign/replace_existing_signature=true -codesign/entitlements/custom_file="" -codesign/entitlements/allow_jit_code_execution=false -codesign/entitlements/allow_unsigned_executable_memory=false -codesign/entitlements/allow_dyld_environment_variables=false -codesign/entitlements/disable_library_validation=false -codesign/entitlements/audio_input=false -codesign/entitlements/camera=false -codesign/entitlements/location=false -codesign/entitlements/address_book=false -codesign/entitlements/calendars=false -codesign/entitlements/photos_library=false -codesign/entitlements/apple_events=false -codesign/entitlements/debugging=false -codesign/entitlements/app_sandbox/enabled=false -codesign/entitlements/app_sandbox/network_server=false -codesign/entitlements/app_sandbox/network_client=false -codesign/entitlements/app_sandbox/device_usb=false -codesign/entitlements/app_sandbox/device_bluetooth=false -codesign/entitlements/app_sandbox/files_downloads=0 -codesign/entitlements/app_sandbox/files_pictures=0 -codesign/entitlements/app_sandbox/files_music=0 -codesign/entitlements/app_sandbox/files_movies=0 -codesign/custom_options=PoolStringArray( ) -notarization/enable=false -notarization/apple_id_name="" -notarization/apple_id_password="" -notarization/apple_team_id="" -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false - -[preset.4] - -name="Android" -platform="Android" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="" -script_export_mode=1 -script_encryption_key="" - -[preset.4.options] - -custom_template/debug="" -custom_template/release="" -custom_build/use_custom_build=false -custom_build/export_format=0 -custom_build/min_sdk="" -custom_build/target_sdk="" -architectures/armeabi-v7a=true -architectures/arm64-v8a=false -architectures/x86=false -architectures/x86_64=false -keystore/debug="" -keystore/debug_user="" -keystore/debug_password="" -keystore/release="" -keystore/release_user="" -keystore/release_password="" -one_click_deploy/clear_previous_install=false -version/code=1 -version/name="1.0" -package/unique_name="org.godotengine.$genname" -package/name="" -package/signed=true -package/classify_as_game=true -package/retain_data_on_uninstall=false -package/exclude_from_recents=false -launcher_icons/main_192x192="" -launcher_icons/adaptive_foreground_432x432="" -launcher_icons/adaptive_background_432x432="" -graphics/opengl_debug=false -xr_features/xr_mode=0 -xr_features/hand_tracking=0 -xr_features/hand_tracking_frequency=0 -xr_features/passthrough=0 -screen/immersive_mode=true -screen/support_small=true -screen/support_normal=true -screen/support_large=true -screen/support_xlarge=true -user_data_backup/allow=false -command_line/extra_args="" -apk_expansion/enable=false -apk_expansion/SALT="" -apk_expansion/public_key="" -permissions/custom_permissions=PoolStringArray( ) -permissions/access_checkin_properties=false -permissions/access_coarse_location=false -permissions/access_fine_location=false -permissions/access_location_extra_commands=false -permissions/access_mock_location=false -permissions/access_network_state=false -permissions/access_surface_flinger=false -permissions/access_wifi_state=false -permissions/account_manager=false -permissions/add_voicemail=false -permissions/authenticate_accounts=false -permissions/battery_stats=false -permissions/bind_accessibility_service=false -permissions/bind_appwidget=false -permissions/bind_device_admin=false -permissions/bind_input_method=false -permissions/bind_nfc_service=false -permissions/bind_notification_listener_service=false -permissions/bind_print_service=false -permissions/bind_remoteviews=false -permissions/bind_text_service=false -permissions/bind_vpn_service=false -permissions/bind_wallpaper=false -permissions/bluetooth=false -permissions/bluetooth_admin=false -permissions/bluetooth_privileged=false -permissions/brick=false -permissions/broadcast_package_removed=false -permissions/broadcast_sms=false -permissions/broadcast_sticky=false -permissions/broadcast_wap_push=false -permissions/call_phone=false -permissions/call_privileged=false -permissions/camera=false -permissions/capture_audio_output=false -permissions/capture_secure_video_output=false -permissions/capture_video_output=false -permissions/change_component_enabled_state=false -permissions/change_configuration=false -permissions/change_network_state=false -permissions/change_wifi_multicast_state=false -permissions/change_wifi_state=false -permissions/clear_app_cache=false -permissions/clear_app_user_data=false -permissions/control_location_updates=false -permissions/delete_cache_files=false -permissions/delete_packages=false -permissions/device_power=false -permissions/diagnostic=false -permissions/disable_keyguard=false -permissions/dump=false -permissions/expand_status_bar=false -permissions/factory_test=false -permissions/flashlight=false -permissions/force_back=false -permissions/get_accounts=false -permissions/get_package_size=false -permissions/get_tasks=false -permissions/get_top_activity_info=false -permissions/global_search=false -permissions/hardware_test=false -permissions/inject_events=false -permissions/install_location_provider=false -permissions/install_packages=false -permissions/install_shortcut=false -permissions/internal_system_window=false -permissions/internet=false -permissions/kill_background_processes=false -permissions/location_hardware=false -permissions/manage_accounts=false -permissions/manage_app_tokens=false -permissions/manage_documents=false -permissions/manage_external_storage=false -permissions/master_clear=false -permissions/media_content_control=false -permissions/modify_audio_settings=false -permissions/modify_phone_state=false -permissions/mount_format_filesystems=false -permissions/mount_unmount_filesystems=false -permissions/nfc=false -permissions/persistent_activity=false -permissions/process_outgoing_calls=false -permissions/read_calendar=false -permissions/read_call_log=false -permissions/read_contacts=false -permissions/read_external_storage=false -permissions/read_frame_buffer=false -permissions/read_history_bookmarks=false -permissions/read_input_state=false -permissions/read_logs=false -permissions/read_phone_state=false -permissions/read_profile=false -permissions/read_sms=false -permissions/read_social_stream=false -permissions/read_sync_settings=false -permissions/read_sync_stats=false -permissions/read_user_dictionary=false -permissions/reboot=false -permissions/receive_boot_completed=false -permissions/receive_mms=false -permissions/receive_sms=false -permissions/receive_wap_push=false -permissions/record_audio=false -permissions/reorder_tasks=false -permissions/restart_packages=false -permissions/send_respond_via_message=false -permissions/send_sms=false -permissions/set_activity_watcher=false -permissions/set_alarm=false -permissions/set_always_finish=false -permissions/set_animation_scale=false -permissions/set_debug_app=false -permissions/set_orientation=false -permissions/set_pointer_speed=false -permissions/set_preferred_applications=false -permissions/set_process_limit=false -permissions/set_time=false -permissions/set_time_zone=false -permissions/set_wallpaper=false -permissions/set_wallpaper_hints=false -permissions/signal_persistent_processes=false -permissions/status_bar=false -permissions/subscribed_feeds_read=false -permissions/subscribed_feeds_write=false -permissions/system_alert_window=false -permissions/transmit_ir=false -permissions/uninstall_shortcut=false -permissions/update_device_stats=false -permissions/use_credentials=false -permissions/use_sip=false -permissions/vibrate=false -permissions/wake_lock=false -permissions/write_apn_settings=false -permissions/write_calendar=false -permissions/write_call_log=false -permissions/write_contacts=false -permissions/write_external_storage=false -permissions/write_gservices=false -permissions/write_history_bookmarks=false -permissions/write_profile=false -permissions/write_secure_settings=false -permissions/write_settings=false -permissions/write_sms=false -permissions/write_social_stream=false -permissions/write_sync_settings=false -permissions/write_user_dictionary=false diff --git a/html/.gdignore b/html/.gdignore deleted file mode 100644 index e69de29..0000000 --- a/html/.gdignore +++ /dev/null diff --git a/html/custom.html b/html/custom.html deleted file mode 100644 index 832478b..0000000 --- a/html/custom.html +++ /dev/null @@ -1,280 +0,0 @@ -<!DOCTYPE html> -<html xmlns="https://www.w3.org/1999/xhtml" lang="" xml:lang=""> - <head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, user-scalable=no" /> - <title>$GODOT_PROJECT_NAME</title> - <style type="text/css"> - body { - touch-action: none; - margin: 0; - border: 0 none; - padding: 0; - min-width: 100%; - min-height: 100%; - text-align: center; - background-size: cover; - background-repeat: no-repeat; - background: linear-gradient(to right, yellow, orange 60%, cyan); - } - - #canvas { - display: block; - margin: 0; - color: white; - } - - #canvas:focus { - outline: none; - } - - .godot { - font-family: ubuntu; - font-weight: bold; - color: #e0e0e0; - background-color: black; - } - - /* Status display - * ============== */ - - #status { - position: absolute; - left: 0; - top: 0; - right: 0; - bottom: 0; - display: flex; - justify-content: center; - align-items: center; - /* don't consume click events - make children visible explicitly */ - visibility: hidden; - } - - #status-progress { - width: 600px; - height: 50px; - background-color: #dcc621; - background-image: linear-gradient(to left, cyan, orange 60%, yellow); - border: 5px solid black; - padding: 3px; - border-radius: 30px; - visibility: visible; - } - - @media only screen and (orientation: portrait) { - #status-progress { - width: 61.8%; - } - } - - #status-progress-inner { - height: 100%; - width: 0; - box-sizing: border-box; - transition: width 0.5s linear; - background-image: linear-gradient(45deg, blue 30%, red); - border: 3px solid black; - border-radius: 30px; - } - - #status-indeterminate { - height: 42px; - visibility: visible; - position: relative; - } - - #status-indeterminate > div { - width: 4.5px; - height: 0; - border-style: solid; - border-width: 9px 3px 0 3px; - border-color: black transparent transparent transparent; - transform-origin: center 21px; - position: absolute; - } - - #status-indeterminate > div:nth-child(1) { - transform: rotate(22.5deg); - } - #status-indeterminate > div:nth-child(2) { - transform: rotate(67.5deg); - } - #status-indeterminate > div:nth-child(3) { - transform: rotate(112.5deg); - } - #status-indeterminate > div:nth-child(4) { - transform: rotate(157.5deg); - } - #status-indeterminate > div:nth-child(5) { - transform: rotate(202.5deg); - } - #status-indeterminate > div:nth-child(6) { - transform: rotate(247.5deg); - } - #status-indeterminate > div:nth-child(7) { - transform: rotate(292.5deg); - } - #status-indeterminate > div:nth-child(8) { - transform: rotate(337.5deg); - } - - #status-notice { - margin: 0 100px; - line-height: 1.3; - visibility: visible; - padding: 4px 6px; - visibility: visible; - } - </style> - $GODOT_HEAD_INCLUDE - </head> - <body> - <canvas id="canvas"> - HTML5 canvas appears to be unsupported in the current browser.<br /> - Please try updating or use a different browser. - </canvas> - <div id="status"> - <div - id="status-progress" - style="display: none" - oncontextmenu="event.preventDefault();" - > - <div id="status-progress-inner"></div> - </div> - <div - id="status-indeterminate" - style="display: none" - oncontextmenu="event.preventDefault();" - > - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - <div></div> - </div> - <div id="status-notice" class="godot" style="display: none"></div> - </div> - - <script type="text/javascript" src="$GODOT_URL"></script> - <script type="text/javascript"> - //<![CDATA[ - - const GODOT_CONFIG = $GODOT_CONFIG; - var engine = new Engine(GODOT_CONFIG); - - (function () { - const INDETERMINATE_STATUS_STEP_MS = 100; - var statusProgress = document.getElementById("status-progress"); - var statusProgressInner = document.getElementById( - "status-progress-inner" - ); - var statusIndeterminate = document.getElementById( - "status-indeterminate" - ); - var statusNotice = document.getElementById("status-notice"); - - var initializing = true; - var statusMode = "hidden"; - - var animationCallbacks = []; - function animate(time) { - animationCallbacks.forEach((callback) => callback(time)); - requestAnimationFrame(animate); - } - requestAnimationFrame(animate); - - function setStatusMode(mode) { - if (statusMode === mode || !initializing) return; - [statusProgress, statusIndeterminate, statusNotice].forEach( - (elem) => { - elem.style.display = "none"; - } - ); - animationCallbacks = animationCallbacks.filter(function (value) { - return value != animateStatusIndeterminate; - }); - switch (mode) { - case "progress": - statusProgress.style.display = "block"; - break; - case "indeterminate": - statusIndeterminate.style.display = "block"; - animationCallbacks.push(animateStatusIndeterminate); - break; - case "notice": - statusNotice.style.display = "block"; - break; - case "hidden": - break; - default: - throw new Error("Invalid status mode"); - } - statusMode = mode; - } - - function animateStatusIndeterminate(ms) { - var i = Math.floor((ms / INDETERMINATE_STATUS_STEP_MS) % 8); - if (statusIndeterminate.children[i].style.borderTopColor == "") { - Array.prototype.slice - .call(statusIndeterminate.children) - .forEach((child) => { - child.style.borderTopColor = ""; - }); - statusIndeterminate.children[i].style.borderTopColor = "#dfdfdf"; - } - } - - function setStatusNotice(text) { - while (statusNotice.lastChild) { - statusNotice.removeChild(statusNotice.lastChild); - } - var lines = text.split("\n"); - lines.forEach((line) => { - statusNotice.appendChild(document.createTextNode(line)); - statusNotice.appendChild(document.createElement("br")); - }); - } - - function displayFailureNotice(err) { - var msg = err.message || err; - console.error(msg); - setStatusNotice(msg); - setStatusMode("notice"); - initializing = false; - } - - if (!Engine.isWebGLAvailable()) { - displayFailureNotice("WebGL not available"); - } else { - setStatusMode("indeterminate"); - engine - .startGame({ - onProgress: function (current, total) { - if (total > 0) { - statusProgressInner.style.width = - (current / total) * 100 + "%"; - setStatusMode("progress"); - if (current === total) { - // wait for progress bar animation - setTimeout(() => { - setStatusMode("indeterminate"); - }, 500); - } - } else { - setStatusMode("indeterminate"); - } - }, - }) - .then(() => { - setStatusMode("hidden"); - initializing = false; - }, displayFailureNotice); - } - })(); - </script> - </body> -</html> diff --git a/project.godot b/project.godot index 663e841..f1f35ec 100644 --- a/project.godot +++ b/project.godot @@ -10,31 +10,93 @@ config_version=4 _global_script_classes=[ { "base": "Reference", -"class": "Arg", +"class": "ApplicationCommand", "language": "GDScript", -"path": "res://addons/gdcli/Arg.gd" +"path": "res://addons/discord_gd/classes/application_command.gd" }, { "base": "Reference", -"class": "Parser", +"class": "BitField", "language": "GDScript", -"path": "res://addons/gdcli/Parser.gd" +"path": "res://addons/discord_gd/classes/bit_field.gd" +}, { +"base": "HTTPRequest", +"class": "DiscordBot", +"language": "GDScript", +"path": "res://addons/discord_gd/discord.gd" +}, { +"base": "Reference", +"class": "DiscordInteraction", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/discord_interaction.gd" +}, { +"base": "Reference", +"class": "Embed", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/embed.gd" +}, { +"base": "Reference", +"class": "Helpers", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/helpers.gd" +}, { +"base": "Reference", +"class": "Message", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/message.gd" +}, { +"base": "Reference", +"class": "MessageActionRow", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/message_action_row.gd" +}, { +"base": "Reference", +"class": "MessageButton", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/message_button.gd" +}, { +"base": "BitField", +"class": "MessageFlags", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/message_flags.gd" +}, { +"base": "BitField", +"class": "Permissions", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/permissions.gd" +}, { +"base": "Reference", +"class": "SelectMenu", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/select_menu.gd" +}, { +"base": "Reference", +"class": "User", +"language": "GDScript", +"path": "res://addons/discord_gd/classes/user.gd" } ] _global_script_class_icons={ -"Arg": "", -"Parser": "" +"ApplicationCommand": "", +"BitField": "", +"DiscordBot": "", +"DiscordInteraction": "", +"Embed": "", +"Helpers": "", +"Message": "", +"MessageActionRow": "", +"MessageButton": "", +"MessageFlags": "", +"Permissions": "", +"SelectMenu": "", +"User": "" } [application] config/name="Godot Template" -run/main_scene="res://Main.tscn" +run/main_scene="res://Latex.tscn" config/use_custom_user_dir=true config/custom_user_dir_name="GodotTemplate" -[autoload] - -CLI="*res://autoloads/CLI.gd" - [debug] gdscript/warnings/return_value_discarded=false @@ -49,6 +111,10 @@ window/dpi/allow_hidpi=true window/stretch/mode="2d" window/stretch/aspect="keep" +[editor_plugins] + +enabled=PoolStringArray( ) + [logging] file_logging/enable_file_logging=true diff --git a/submodules/discord.gd b/submodules/discord.gd new file mode 160000 +Subproject a6ace61217f3edeee9c8254f638f2d85cbde7bd diff --git a/submodules/gdcli b/submodules/gdcli deleted file mode 160000 -Subproject 2b7891b100fcaaf6c09d67bc265d15a6603c8ad |