forked from Skyrat-SS13/Skyrat-tg
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path_modpack.dm
83 lines (73 loc) · 2.83 KB
/
_modpack.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/datum/modpack
/// A string unique ID for the modpack. Used for self-cheсks, must be same as modpack name in code. /datum/modpack/ru_crayons -> "id = ru_crayons"
var/id
/// An icon for modpack preview,
var/icon = 'modular_ss220/mods_icon_placeholder.dmi'
/// A string name for the modpack. Used for looking up other modpacks in init.
var/name
/// A string desc for the modpack. Can be used for modpack verb list as description.
var/desc
/// A string with authors of this modpack.
var/author
/// A string with group of this modpack. Choose between "Features", "Translations" and "Reverts"
var/group
/// A list of your modpack's dependencies. If you use obj from another modpack - put it here.
var/list/mod_depends = list()
/// Is modpack visible,
var/visible = TRUE // by default set to TRUE
// Modpacks initialization steps
/datum/modpack/proc/pre_initialize() // Basic modpack fuctions
if(!name)
return "Modpack name is unset."
/datum/modpack/proc/initialize() // Mods dependencies-checks
if(!mod_depends)
return
var/passed = 0
for(var/depend_id in mod_depends)
passed = 0
if(depend_id == id)
return "Mod depends on itself, ok and?"
for(var/datum/modpack/package as anything in SSmodpacks.loaded_modpacks)
if(package.id == depend_id)
if(passed >= 1)
return "Multiple include of one module in [id] mod dependencies."
passed++
if(passed == 0)
return "Module [id] depends on [depend_id], please include it in your game."
// Modpacks TGUI
/datum/modpack/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/spritesheet/simple/modpacks),
)
/datum/modpack/ui_state()
return GLOB.always_state
/datum/modpack/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
ui = new(user, src, "Modpacks")
ui.open()
/datum/modpack/ui_static_data(mob/user)
. = ..()
.["categories"] = list("Features", "Reverts", "Translations")
.["features"] = list()
.["translations"] = list()
.["reverts"] = list()
var/datum/asset/spritesheet/simple/assets = get_asset_datum(/datum/asset/spritesheet/simple/modpacks)
for(var/datum/modpack/modpack as anything in SSmodpacks.loaded_modpacks)
if (!modpack.visible) // needed for examples (or for some kind of event)
continue
var/list/modpack_data = list(
"name" = modpack.name,
"desc" = modpack.desc,
"author" = modpack.author,
"icon_class" = assets.icon_class_name("modpack-[modpack.id]"),
"id" = modpack.id,
)
if (modpack.group == "Фичи" || modpack.group == "Features")
.["features"] += list(modpack_data)
else if (modpack.group == "Переводы" || modpack.group == "Translations")
.["translations"] += list(modpack_data)
else if (modpack.group == "Баланс" || modpack.group == "Reverts")
.["reverts"] += list(modpack_data)
else
CRASH("Modpack [modpack.name] has bad group name or queued for deletion.")