Skip to content

Commit

Permalink
ModWorkshop mod links
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryhon0 committed Jan 23, 2025
1 parent 0061b81 commit bbb64f5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Injector/Main.tscn
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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")]
Expand Down Expand Up @@ -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"]
Expand Down
30 changes: 23 additions & 7 deletions Injector/ModList.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions Injector/mws_logo_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Injector/mws_logo_white.svg.import
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bbb64f5

Please sign in to comment.