Skip to content

Commit

Permalink
just messing around
Browse files Browse the repository at this point in the history
  • Loading branch information
LuNeder committed Sep 22, 2023
1 parent 00006b9 commit 61ab5da
Show file tree
Hide file tree
Showing 424 changed files with 8,954 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
13 changes: 2 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg

# Imported translations (automatically generated from CSV files)
*.translation

# Mono-specific ignores
.mono/
data_*/
# Godot 4+ specific ignores
.godot/
21 changes: 21 additions & 0 deletions addons/input_helper/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-present Nathan Hoad

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
230 changes: 230 additions & 0 deletions addons/input_helper/assets/update.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions addons/input_helper/assets/update.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ddixs2ish5bi6"
path="res://.godot/imported/update.svg-3137f1f7d53c08c0ae65aabe138d898b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/input_helper/assets/update.svg"
dest_files=["res://.godot/imported/update.svg-3137f1f7d53c08c0ae65aabe138d898b.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
83 changes: 83 additions & 0 deletions addons/input_helper/components/download_update_panel.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@tool

extends Control


signal failed()
signal updated(updated_to_version: String)


const TEMP_FILE_NAME = "user://temp.zip"


@onready var logo: TextureRect = %Logo
@onready var label: Label = $VBox/Label
@onready var http_request: HTTPRequest = $HTTPRequest
@onready var download_button: Button = %DownloadButton

var next_version: String = "":
set(next_next_version):
next_version = next_next_version
label.text = "Version %s is available for download!" % next_version
get:
return next_version


func save_zip(bytes: PackedByteArray) -> void:
var file: FileAccess = FileAccess.open(TEMP_FILE_NAME, FileAccess.WRITE)
file.store_buffer(bytes)
file.flush()


### Signals


func _on_download_button_pressed() -> void:
# Safeguard the actual input helper repo from accidentally updating itself
if FileAccess.file_exists("res://examples/device_tester.gd"):
prints("You can't update the input helper from within itself.")
failed.emit()
return

http_request.request("https://github.com/nathanhoad/godot_input_helper/archive/refs/tags/v%s.zip" % next_version)
download_button.disabled = true
download_button.text = "Downloading..."


func _on_http_request_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
if result != HTTPRequest.RESULT_SUCCESS:
failed.emit()
return

# Save the downloaded zip
save_zip(body)

OS.move_to_trash(ProjectSettings.globalize_path("res://addons/input_helper"))

var zip_reader: ZIPReader = ZIPReader.new()
zip_reader.open(TEMP_FILE_NAME)
var files: PackedStringArray = zip_reader.get_files()

var base_path = files[1]
# Remove archive folder
files.remove_at(0)
# Remove assets folder
files.remove_at(0)

for path in files:
var new_file_path: String = path.replace(base_path, "")
if path.ends_with("/"):
DirAccess.make_dir_recursive_absolute("res://addons/%s" % new_file_path)
else:
var file: FileAccess = FileAccess.open("res://addons/%s" % new_file_path, FileAccess.WRITE)
file.store_buffer(zip_reader.read_file(path))

zip_reader.close()

DirAccess.remove_absolute(TEMP_FILE_NAME)

updated.emit(next_version)


func _on_notes_button_pressed() -> void:
OS.shell_open("https://github.com/nathanhoad/godot_input_helper/releases/tag/v%s" % next_version)
Loading

0 comments on commit 61ab5da

Please sign in to comment.