From bbb64f51bc403a49d996b6ed21ca663693e7fff1 Mon Sep 17 00:00:00 2001 From: Ryhon Date: Thu, 23 Jan 2025 13:21:33 +0100 Subject: [PATCH] ModWorkshop mod links --- Injector/Main.tscn | 4 +++- Injector/ModList.gd | 30 +++++++++++++++++++++++------- Injector/mws_logo_white.svg | 19 +++++++++++++++++++ Injector/mws_logo_white.svg.import | 2 +- 4 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 Injector/mws_logo_white.svg diff --git a/Injector/Main.tscn b/Injector/Main.tscn index f5c2cb5..87f3647 100644 --- a/Injector/Main.tscn +++ b/Injector/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://b6nywv6aqxm3r"] +[gd_scene load_steps=10 format=3 uid="uid://b6nywv6aqxm3r"] [ext_resource type="Script" path="res://Main.gd" id="1_x5slr"] [ext_resource type="Texture2D" uid="uid://wbaqykif8euy" path="res://icon.svg" id="2_74yqq"] @@ -7,6 +7,7 @@ [ext_resource type="Texture2D" uid="uid://bhyjjcpqm564o" path="res://pin.svg" id="4_rv4x7"] [ext_resource type="Texture2D" uid="uid://epy24urpfgha" path="res://pin_disabled.svg" id="5_33vpw"] [ext_resource type="Texture2D" uid="uid://bcc6fhil26kqe" path="res://donate_icon.png" id="5_r2nj5"] +[ext_resource type="Texture2D" uid="uid://d1c10pv53ai2x" path="res://mws_logo_white.svg" id="6_0guad"] [ext_resource type="Script" path="res://AutoUpdater.gd" id="6_etu4i"] [node name="Main" type="Control" node_paths=PackedStringArray("VersionLabel", "StatusLabel", "Progress", "LoadingScreen", "ConfigScreen", "SettingsPage", "Mods", "Updater")] @@ -141,6 +142,7 @@ Main = NodePath("../../..") List = NodePath("ModListTree") PinIcon = ExtResource("4_rv4x7") PinIconDisabled = ExtResource("5_33vpw") +ModWorkshopLogo = ExtResource("6_0guad") metadata/_tab_index = 1 [node name="ModListTree" type="Tree" parent="ConfigScreen/TabContainer/Mods"] diff --git a/Injector/ModList.gd b/Injector/ModList.gd index b6d6431..3989a2f 100644 --- a/Injector/ModList.gd +++ b/Injector/ModList.gd @@ -7,6 +7,8 @@ class_name ModList @export var PinIcon: Texture2D @export var PinIconDisabled: Texture2D +@export var ModWorkshopLogo: Texture2D + var mods : Array[ModInfo] = [] class ModInfo: @@ -57,13 +59,16 @@ class ModInfo: const VERSION_COLUMN = 2 const VERSION_COLUMN_BUTTON_PIN = 0 -const ENABLED_COLUMN = 4 +const LINKS_CLOLUMN = 4 + +const ENABLED_COLUMN = 5 func _ready(): List.set_column_title(0, "Name") List.set_column_title(1, "ID") List.set_column_title(VERSION_COLUMN, "Version") List.set_column_title(3, "File name") + List.set_column_title(LINKS_CLOLUMN, "Links") List.set_column_title(ENABLED_COLUMN, "Enabled") for i in range(List.columns): @@ -73,6 +78,7 @@ func _ready(): List.set_column_custom_minimum_width(1, 175) List.set_column_custom_minimum_width(VERSION_COLUMN, 75) List.set_column_custom_minimum_width(3, 175) + List.set_column_custom_minimum_width(LINKS_CLOLUMN, 90) func loadMods(): mods = [] @@ -138,13 +144,23 @@ func loadMods(): # Pin version li.add_button(VERSION_COLUMN, PinIcon if pinned else PinIconDisabled, VERSION_COLUMN_BUTTON_PIN, false, "Pin version") + # Links + var links : Array[String] = [] + if modi.config.has_section_key("updates", "modworkshop"): + li.add_button(LINKS_CLOLUMN, ModWorkshopLogo, -1, false, "ModWorkshop") + links.append("https://modworkshop.net/mod/" + str(modi.config.get_value("updates", "modworkshop"))) + li.set_meta("links", links) + func buttonPressed(item: TreeItem, column: int, button: int, mousebtn: int) -> void: - if column == VERSION_COLUMN && button == VERSION_COLUMN_BUTTON_PIN: - if mousebtn == MOUSE_BUTTON_LEFT: - var mod : ModInfo = item.get_meta("mod") - mod.pinVersion(!mod.versionPinned) - item.set_button(VERSION_COLUMN, VERSION_COLUMN_BUTTON_PIN, PinIcon if mod.versionPinned else PinIconDisabled) - return + if column == VERSION_COLUMN && button == VERSION_COLUMN_BUTTON_PIN && mousebtn == MOUSE_BUTTON_LEFT: + var mod : ModInfo = item.get_meta("mod") + mod.pinVersion(!mod.versionPinned) + item.set_button(VERSION_COLUMN, VERSION_COLUMN_BUTTON_PIN, PinIcon if mod.versionPinned else PinIconDisabled) + return + if column == LINKS_CLOLUMN && mousebtn == MOUSE_BUTTON_LEFT: + var links : Array[String] = item.get_meta("links") + OS.shell_open(links[button]) + return func itemEdited() -> void: if List.get_edited_column() == 4: diff --git a/Injector/mws_logo_white.svg b/Injector/mws_logo_white.svg new file mode 100644 index 0000000..d48c2ba --- /dev/null +++ b/Injector/mws_logo_white.svg @@ -0,0 +1,19 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + \ No newline at end of file diff --git a/Injector/mws_logo_white.svg.import b/Injector/mws_logo_white.svg.import index 5f67cdc..f02a124 100644 --- a/Injector/mws_logo_white.svg.import +++ b/Injector/mws_logo_white.svg.import @@ -32,6 +32,6 @@ process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 detect_3d/compress_to=1 -svg/scale=1.0 +svg/scale=0.3 editor/scale_with_editor_scale=false editor/convert_colors_with_editor_theme=false