Skip to content

Commit

Permalink
Мелкие изменения, 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Summersay415 committed Dec 4, 2024
1 parent 7d90196 commit f70cf22
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 43 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Circle Shot Launcher

Исходный код лаунчера Circle Shot. Исходный код самой игры находится [здесь](https://github.com/Diamond-Studio-GAMES/circle-shot).
Исходный код лаунчера Circle Shot. Исходный код самой игры находится [здесь](https://github.com/DiamondStudioGAMES/circle-shot).
Если хотите помочь проекту, обратитесь к [этому документу](https://github.com/DiamondStudioGAMES/circle-shot/blob/master/docs/CONTRIBUTING.md).
Некоторые инструкции, специфичные для лаунчера, доступны для ознакомления в папке `docs`.

Версия Godot: 4.4.dev3+
Версия Godot: 4.4.dev4+
File renamed without changes.
File renamed without changes.
20 changes: 14 additions & 6 deletions downloader/downloader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ enum Status {
IDLE = 0,
DOWNLOADING_ENGINE = 1,
DOWNLOADING_PACK = 2,
UNZIPPING = 3,
UNZIPPING_PACK = 3,
UNZIPPING_ENGINE = 4,
}

var status := Status.IDLE
Expand Down Expand Up @@ -48,9 +49,12 @@ func _process(_delta: float) -> void:
else:
_progress_bar.value = 0.0
_status_label.text = "Скачиваю ресурсы..."
Status.UNZIPPING:
Status.UNZIPPING_PACK:
_progress_bar.value = 1.0
_status_label.text = "Распаковка файлов..."
_status_label.text = "Распаковка ресурсов..."
Status.UNZIPPING_ENGINE:
_progress_bar.value = 1.0
_status_label.text = "Распаковка движка..."


func download_version(version_code: String, engine_version: String) -> void:
Expand Down Expand Up @@ -82,7 +86,7 @@ func _download_engine() -> void:
]
engine_name = engine_name.to_lower()
var url: String = _launcher.get_server_url().path_join("engines").path_join(engine_name)
print("Downloading engine from %s" % url)
print("Downloading engine from %s..." % url)
status = Status.DOWNLOADING_ENGINE
var err: Error = _engine_http.request(url)
if err != OK:
Expand All @@ -99,7 +103,7 @@ func _download_pack() -> void:
]
pack_name = pack_name.to_lower()
var url: String = _launcher.get_server_url().path_join("packs").path_join(pack_name)
print("Downloading pack from %s" % url)
print("Downloading pack from %s..." % url)
status = Status.DOWNLOADING_PACK
var err: Error = _pack_http.request(url)
if err != OK:
Expand All @@ -109,9 +113,10 @@ func _download_pack() -> void:


func _unzip_and_install() -> void:
status = Status.UNZIPPING
status = Status.UNZIPPING_PACK
await get_tree().process_frame
await get_tree().process_frame

var zip := ZIPReader.new()

var err: Error = zip.open(_launcher.data_path.path_join("tmp.pack.zip"))
Expand Down Expand Up @@ -141,6 +146,9 @@ func _unzip_and_install() -> void:
zip.close()

if FileAccess.file_exists(_launcher.data_path.path_join("tmp.engine.zip")):
status = Status.UNZIPPING_ENGINE
await get_tree().process_frame

err = zip.open(_launcher.data_path.path_join("tmp.engine.zip"))
if err != OK:
push_error("Error unzipping tmp.engine.zip: %s." % error_string(err))
Expand Down
4 changes: 2 additions & 2 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter="*.md, *.ico"
export_path="../../../../../media/ADATA HDD330/Проекты/Circle Shot/Launcher/circle_shot_launcher_v1.0.0-linux.x86_64"
export_path="../../../../../media/ADATA HDD330/Проекты/Circle Shot/Launcher/circle_shot_launcher_v1.0.1-linux.x86_64"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
Expand Down Expand Up @@ -50,7 +50,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter="*.md"
export_path="../../../../../media/ADATA HDD330/Проекты/Circle Shot/Launcher/circle_shot_launcher_v1.0.0-windows.x86_64.exe"
export_path="../../../../../media/ADATA HDD330/Проекты/Circle Shot/Launcher/circle_shot_launcher_v1.0.1-windows.x86_64.exe"
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
Expand Down
67 changes: 41 additions & 26 deletions launcher/launcher.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func list_local_versions() -> void:
if versions_file.get_value(version_code, "beta"):
version_name += " (БЕТА)"
(version_node.get_node(^"%VersionName") as Label).text = version_name
(version_node.get_node(^"%Run") as Button).pressed.connect(
(version_node.get_node(^"%Run") as BaseButton).pressed.connect(
run_version.bind(version_code)
)
(version_node.get_node(^"%Export") as Button).pressed.connect(
(version_node.get_node(^"%Export") as BaseButton).pressed.connect(
export_version.bind(version_code)
)
(version_node.get_node(^"%Remove") as Button).pressed.connect(
(version_node.get_node(^"%Remove") as BaseButton).pressed.connect(
remove_version.bind(version_code)
)
version_nodes.append(version_node)
Expand Down Expand Up @@ -125,7 +125,7 @@ func run_version(version_code: String) -> void:
arguments.append(i)
var pid: int = OS.create_process(executable_path, arguments)
if pid == -1:
push_error("Can't start game with executable path %s and pack path %s!" % [
push_error("Run: can't start executable at path %s with pack at path %s!" % [
executable_path,
pack_path
])
Expand Down Expand Up @@ -177,7 +177,7 @@ func show_update(version_code: String, engine_version: String, beta: bool) -> vo


func get_server_url() -> String:
return settings_file.get_value("settings", "server")
return settings_file.get_value("settings", "server_url")


func get_version_engine_path(version_code: String, engine_version := "") -> String:
Expand All @@ -202,16 +202,16 @@ func _export_version(path: String, version_code: String) -> void:
return

print("Exporting to %s." % path)
_status.text = "Выполняется экспорт..."
_status.text = "Экспорт: создание архива..."
($MouseBlock as CanvasItem).show()
await get_tree().process_frame
await get_tree().process_frame

var zip := ZIPPacker.new()
var err: Error = zip.open(path)
if err != OK:
_status.text = "Ошибка создания ZIP-файла!"
push_error("Creating ZIP failed with error %s." % error_string(err))
_status.text = "Экспорт: ошибка создания ZIP-файла!"
push_error("Export: creating ZIP failed with error %s." % error_string(err))
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return
Expand All @@ -229,10 +229,16 @@ func _export_version(path: String, version_code: String) -> void:
zip.write_file(config.encode_to_text().to_utf8_buffer())
zip.close_file()

_status.text = "Экспорт: сжатие движка..."
await get_tree().process_frame

zip.start_file("engine")
zip.write_file(FileAccess.get_file_as_bytes(get_version_engine_path(version_code)))
zip.close_file()

_status.text = "Экспорт: сжатие ресурсов..."
await get_tree().process_frame

zip.start_file("pack")
zip.write_file(FileAccess.get_file_as_bytes(get_version_pack_path(version_code)))
zip.close_file()
Expand All @@ -247,15 +253,16 @@ func _export_version(path: String, version_code: String) -> void:

func _import_version(path: String) -> void:
print("Importing from %s." % path)
_status.text = "Выполняется импорт..."
_status.text = "Импорт: открытие архива..."
($MouseBlock as CanvasItem).show()
await get_tree().process_frame
await get_tree().process_frame

var zip := ZIPReader.new()
var err: Error = zip.open(path)
if err != OK:
_status.text = "Ошибка открытия ZIP-файла!"
push_error("Import: can't open ZIP file. Error: %s." % error_string(err))
_status.text = "Импорт: ошибка открытия ZIP-файла!"
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return
Expand All @@ -265,17 +272,17 @@ func _import_version(path: String) -> void:
and zip.file_exists("pack")
and zip.file_exists("version.cfg")
):
_status.text = "В этом ZIP-файле нет нужных файлов."
push_error("ZIP file is missing some files (engine, pack, versions.cfg)")
_status.text = "Импорт: в ZIP-файле нет нужных файлов."
push_error("Import: ZIP file is missing some files (engine, pack, versions.cfg)")
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return

var config := ConfigFile.new()
err = config.parse(zip.read_file("version.cfg").get_string_from_utf8())
if err != OK:
_status.text = "Не могу открыть файл конфигурации в этом архиве!"
push_error("versions.cfg can't be parsed.")
_status.text = "Импорт: не могу открыть файл конфигурации в этом архиве!"
push_error("Import: versions.cfg can't be parsed.")
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return
Expand All @@ -294,8 +301,8 @@ func _import_version(path: String) -> void:
and config.has_section_key("config", "beta")
and typeof(config.get_value("config", "beta")) == TYPE_BOOL
):
_status.text = "Файл конфигурации в этом архиве содержит не всю информацию!"
push_error("versions.cfg don't have all needed information.")
_status.text = "Импорт: файл конфигурации в этом архиве содержит не всю информацию!"
push_error("Import: versions.cfg don't have all needed information.")
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return
Expand All @@ -304,15 +311,17 @@ func _import_version(path: String) -> void:
var engine_version: String = config.get_value("config", "engine_version")

if new_version_code in versions_file.get_sections():
_status.text = "Эта версия (%s) уже установлена!" % _get_version_name(new_version_code)
push_error("This version (%s) is already installed." % _get_version_name(new_version_code))
_status.text = "Импорт: эта версия (%s) уже установлена!" \
% _get_version_name(new_version_code)
push_error("Import: this version (%s) is already installed." \
% _get_version_name(new_version_code))
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return

if config.get_value("config", "platform") != OS.get_name():
_status.text = "Эта версия несовместима с вашей операционной системой!"
push_error("Incompatible platforms.")
_status.text = "Импорт: эта версия несовместима с вашей операционной системой!"
push_error("Import: incompatible platforms.")
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return
Expand All @@ -325,17 +334,20 @@ func _import_version(path: String) -> void:

if not engine_already_installed \
and config.get_value("config", "arch") != Engine.get_architecture_name():
_status.text = "Эта версия несовместима с вашей архитектурой процессора!"
push_error("Engine this needed version not found. Engine in archive uses different arch.")
_status.text = "Импорт: эта версия несовместима с вашей архитектурой процессора!"
push_error("Import: engine in archive uses different arch.")
_reset_status_timer.start()
($MouseBlock as CanvasItem).hide()
return

# Всё наконец-то ОК, распаковываем!
_status.text = "Импорт: распаковка ресурсов..."
await get_tree().process_frame

var pack_file := FileAccess.open(get_version_pack_path(new_version_code), FileAccess.WRITE)
if not pack_file:
_status.text = "Ошибка распаковки файла с ресурсами!"
push_error("Error creating pack file at path %s. Error: %s" % [
_status.text = "Импорт: ошибка распаковки файла с ресурсами!"
push_error("Import: error creating pack file at path %s. Error: %s" % [
get_version_pack_path(new_version_code),
error_string(FileAccess.get_open_error())
])
Expand All @@ -346,12 +358,14 @@ func _import_version(path: String) -> void:
pack_file.close()

if not engine_already_installed:
_status.text = "Импорт: распаковка движка..."
await get_tree().process_frame
var engine_file := FileAccess.open(
get_version_engine_path("", engine_version), FileAccess.WRITE
)
if not engine_file:
_status.text = "Ошибка распаковки файла движка!"
push_error("Error creating engine file at path %s. Error: %s" % [
_status.text = "Импорт: ошибка распаковки файла движка!"
push_error("Import: error creating engine file at path %s. Error: %s" % [
get_version_engine_path("", engine_version),
error_string(FileAccess.get_open_error())
])
Expand Down Expand Up @@ -382,6 +396,7 @@ func _remove_version(version_code: String, show_message := false) -> void:
for section: String in versions_file.get_sections():
if version_code == section:
continue
# есть значения по умолчанию так как versions.cfg может быть некорректным
if versions_file.get_value(version_code, "engine_version", "-1.0") == \
versions_file.get_value(section, "engine_version", "-2.0"):
delete_engine = false
Expand Down
Binary file modified misc/boot_splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified misc/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified misc/windows_icon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ config_version=5
[application]

config/name="Circle Shot Launcher"
config/version="1.0.0.0"
config/version="1.0.1"
run/main_scene="res://launcher/launcher.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="circle-shot-launcher"
Expand Down
12 changes: 10 additions & 2 deletions remote_manager/remote_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func list_remote_versions() -> void:
var editions: Array = remote_engine_versions.get_value(engine_version, "editions")
if my_edition in editions:
supported_engines.append(engine_version)
prints("Supported remote engines:", supported_engines)
print("Supported remote engines: ", supported_engines, '.')

var installed_engines: Array[String]
for version_code: String in _launcher.versions_file.get_sections():
installed_engines.append(_launcher.versions_file.get_value(version_code, "engine_version"))
prints("Installed engines:", supported_engines)
print("Installed engines: ", supported_engines, '.')

var version_nodes: Array[Node]
var highest_version: int = -1
Expand Down Expand Up @@ -150,10 +150,14 @@ func _on_versions_http_request_request_completed(result: HTTPRequest.Result,
response_code: HTTPClient.ResponseCode, _headers: PackedStringArray,
body: PackedByteArray) -> void:
if result != HTTPRequest.RESULT_SUCCESS:
_status.text = "Ошибка скачивания списка версий! Код ошибки: %d" % result
push_error("Get versions: result (%d) is not Success!" % result)
_update_button.disabled = false
return
if response_code != HTTPClient.RESPONSE_OK:
_status.text = "Ошибка скачивания списка версий! Код ошибки: %d" % response_code
push_error("Get versions: response code (%d) is not 200!" % response_code)
_update_button.disabled = false
return

var err: Error = remote_versions.parse(body.get_string_from_utf8())
Expand Down Expand Up @@ -192,10 +196,14 @@ func _on_engine_versions_http_request_request_completed(result: HTTPRequest.Resu
response_code: HTTPClient.ResponseCode, _headers: PackedStringArray,
body: PackedByteArray) -> void:
if result != HTTPRequest.RESULT_SUCCESS:
_status.text = "Ошибка скачивания списка версий движка! Код ошибки: %d" % result
push_error("Get engine versions: result (%d) is not Success!" % result)
_update_button.disabled = false
return
if response_code != HTTPClient.RESPONSE_OK:
_status.text = "Ошибка скачивания списка версий движка! Код ошибки: %d" % response_code
push_error("Get engine versions: response code (%d) is not 200!" % response_code)
_update_button.disabled = false
return

var err: Error = remote_engine_versions.parse(body.get_string_from_utf8())
Expand Down
8 changes: 4 additions & 4 deletions settings/settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class_name Settings
extends Window

const DEFAULT_ARGUMENTS := "--disable-update-check"
const DEFAULT_SERVER := "https://diamond-studio-games.github.io/circle-shot"
const DEFAULT_SERVER := "https://diamondstudiogames.github.io/circle-shot"
@onready var _launcher: Launcher = get_parent()

func _ready() -> void:
Expand All @@ -19,9 +19,9 @@ func _ready() -> void:

var arguments: String = \
_launcher.settings_file.get_value("settings", "arguments", DEFAULT_ARGUMENTS)
var server: String = _launcher.settings_file.get_value("settings", "server", DEFAULT_SERVER)
var server: String = _launcher.settings_file.get_value("settings", "server_url", DEFAULT_SERVER)
_launcher.settings_file.set_value("settings", "arguments", arguments)
_launcher.settings_file.set_value("settings", "server", server)
_launcher.settings_file.set_value("settings", "server_url", server)
(%ArgumentsEdit as LineEdit).text = arguments
(%ServerEdit as LineEdit).text = server

Expand Down Expand Up @@ -58,7 +58,7 @@ func _on_arguments_edit_text_changed(new_text: String) -> void:


func _on_server_edit_text_changed(new_text: String) -> void:
_launcher.settings_file.set_value("settings", "server", new_text)
_launcher.settings_file.set_value("settings", "server_url", new_text)
_launcher.save_files()


Expand Down

0 comments on commit f70cf22

Please sign in to comment.