File size: 1,937 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
if not config.Mods then return end

function OnMsg.GatherModEditorLogins(context)
	context.steam_login = not not (IsSteamAvailable() and SteamGetUserId64())
end

function OnMsg.GatherModAuthorNames(authors)
	if IsSteamAvailable() then
		authors.steam = SteamGetPersonaName()
	end
end

function OnMsg.GatherModDefFolders(folders)
	if SteamIsWorkshopAvailable() then
		local steam_folders = SteamWorkshopItems()
		if #steam_folders > 0 then
			local workshop_item_ids = {}
			for i,folder in ipairs(steam_folders) do
				local dir, name = SplitPath(folder)
				workshop_item_ids[#workshop_item_ids + 1] = name
			end
		end
		for i=1,#steam_folders do
			steam_folders[i] = string.gsub(steam_folders[i], "\\", "/")
			steam_folders[i] = { path = steam_folders[i], source = "steam" }
		end
		table.iappend(folders, steam_folders)
	end
end

function GedOpUploadModToSteam(socket, root)
	local mod = root[1]
	local err = ValidateModBeforeUpload(socket, mod)
	if err then return end
	
	if "ok" ~= socket:WaitQuestion("Confirmation", Untranslated{"Mod <ModLabel> will be uploaded to Steam.", mod}) then
		return
	end
	
	local params = { }
	UploadMod(socket, mod, params, Steam_PrepareForUpload, Steam_Upload)
end

function OnMsg.GatherModDeleteFailReasons(mod, reasons)
	if mod.source == "steam" then
		table.insert(reasons, "This mod is downloaded from Steam and cannot be deleted - go in your Steam client and unsubscribe it from there.")
	end
end

function OnMsg.ClassesGenerate(classdefs)
	local steam_properties = {
		{
			category = "Mod",
			id = "steam_id",
			name = "Steam ID",
			editor = "number",
			default =  0,
			read_only = true,
			no_edit = not Platform.steam,
			modid = true,
		},
	}
	for i,steam_prop in ipairs(steam_properties) do
		table.insert(ModDef.properties, steam_prop)
	end
end

function OnMsg.ModBlacklistPrefixes(list)
	list[#list + 1] = "Steam"
	list[#list + 1] = "OnSteam"
	list[#list + 1] = "AsyncSteam"
end