aboutsummaryrefslogtreecommitdiff
path: root/assets
ModeNameSize
-rw-r--r--AdvTrains_Additions.zip889352logplain
-rw-r--r--Weichenhebel-CooleLokAnimiert.zip154594logplain
d---------Weichenhebel-CooleLokAnimiert57logplain
-rw-r--r--advtrains_across.xcf13559logplain
-rw-r--r--advtrains_newlocomotive.xcf7462378logplain
-rw-r--r--advtrains_wagon.png72273logplain
-rw-r--r--andreaskreuz.blend507904logplain
-rw-r--r--andreaskreuz.blend1507904logplain
-rw-r--r--andreaskreuz.png69701logplain
-rw-r--r--at_il_tcb_node.blend483100logplain
d---------blender1289logplain
-rw-r--r--dampflock4.blend1000628logplain
d---------img_large114logplain
-rw-r--r--init.lua0logplain
d---------interlocking.html.LyXconv3596logplain
-rw-r--r--interlocking.lyx47235logplain
-rw-r--r--interlocking.lyx~47133logplain
-rw-r--r--larger rails.xcf1239132logplain
d---------lyx_img745logplain
-rw-r--r--magleves_lockomotive.blend747680logplain
-rw-r--r--magleves_track.blend464960logplain
-rw-r--r--magleves_wagon.blend709904logplain
d---------manual.html.LyXconv2327logplain
-rw-r--r--manual.lyx14464logplain
-rw-r--r--manual.odt1047714logplain
d---------manual_img1858logplain
d---------mbbrailtextures175logplain
-rw-r--r--mod.conf206logplain
-rw-r--r--modern_japan_lockomotive.blend892480logplain
-rw-r--r--modern_japan_wagon.blend856968logplain
d---------oldmodels134logplain
-rw-r--r--schild.blend513160logplain
-rw-r--r--schild.blend1513160logplain
-rw-r--r--schild.png28705logplain
-rw-r--r--schild_flaeche.png526logplain
-rw-r--r--signal_wall.blend512620logplain
-rw-r--r--signal_wall.png107155logplain
-rw-r--r--signal_wall_ceiling.blend512620logplain
-rw-r--r--uban_fancy.blend1020740logplain
-rw-r--r--wagonfancytexture.png42023logplain
-rw-r--r--wagong_fancy.blend1044484logplain
64'>664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
--Minetest
--Copyright (C) 2018-20 rubenwardy
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

if not core.get_http_api then
	function create_store_dlg()
		return messagebox("store",
				fgettext("ContentDB is not available when Minetest was compiled without cURL"))
	end
	return
end

-- Unordered preserves the original order of the ContentDB API,
-- before the package list is ordered based on installed state.
local store = { packages = {}, packages_full = {}, packages_full_unordered = {} }

local http = core.get_http_api()

-- Screenshot
local screenshot_dir = core.get_cache_path() .. DIR_DELIM .. "cdb"
assert(core.create_dir(screenshot_dir))
local screenshot_downloading = {}
local screenshot_downloaded = {}

-- Filter
local search_string = ""
local cur_page = 1
local num_per_page = 5
local filter_type = 1
local filter_types_titles = {
	fgettext("All packages"),
	fgettext("Games"),
	fgettext("Mods"),
	fgettext("Texture packs"),
}

local number_downloading = 0
local download_queue = {}

local filter_types_type = {
	nil,
	"game",
	"mod",
	"txp",
}

local REASON_NEW = "new"
local REASON_UPDATE = "update"
local REASON_DEPENDENCY = "dependency"


local function get_download_url(package, reason)
	local base_url = core.settings:get("contentdb_url")
	local ret = base_url .. ("/packages/%s/%s/releases/%d/download/"):format(package.author, package.name, package.release)
	if reason then
		ret = ret .. "?reason=" .. reason
	end
	return ret
end


local function download_and_extract(param)
	local package = param.package

	local filename = core.get_temp_path(true)
	if filename == "" or not core.download_file(param.url, filename) then
		core.log("error", "Downloading " .. dump(param.url) .. " failed")
		return {
			msg = fgettext("Failed to download $1", package.name)
		}
	end

	local tempfolder = core.get_temp_path()
	if tempfolder ~= "" then
		tempfolder = tempfolder .. DIR_DELIM .. "MT_" .. math.random(1, 1024000)
		if not core.extract_zip(filename, tempfolder) then
			tempfolder = nil
		end
	else
		tempfolder = nil
	end
	os.remove(filename)
	if not tempfolder then
		return {
			msg = fgettext("Install: Unsupported file type or broken archive"),
		}
	end

	return {
		path = tempfolder
	}
end

local function start_install(package, reason)
	local params = {
		package = package,
		url = get_download_url(package, reason),
	}

	number_downloading = number_downloading + 1

	local function callback(result)
		if result.msg then
			gamedata.errormessage = result.msg
		else
			local path, msg = pkgmgr.install_dir(package.type, result.path, package.name, package.path)
			core.delete_dir(result.path)
			if not path then
				gamedata.errormessage = msg
			else
				core.log("action", "Installed package to " .. path)

				local conf_path
				local name_is_title = false
				if package.type == "mod" then
					local actual_type = pkgmgr.get_folder_type(path)
					if actual_type.type == "modpack" then
						conf_path = path .. DIR_DELIM .. "modpack.conf"
					else
						conf_path = path .. DIR_DELIM .. "mod.conf"
					end
				elseif package.type == "game" then
					conf_path = path .. DIR_DELIM .. "game.conf"
					name_is_title = true
				elseif package.type == "txp" then
					conf_path = path .. DIR_DELIM .. "texture_pack.conf"
				end

				if conf_path then
					local conf = Settings(conf_path)
					if name_is_title then
						conf:set("name",   package.title)
					else
						conf:set("title",  package.title)
						conf:set("name",   package.name)
					end
					if not conf:get("description") then
						conf:set("description", package.short_description)
					end
					conf:set("author",     package.author)
					conf:set("release",    package.release)
					conf:write()
				end
			end
		end

		package.downloading = false

		number_downloading = number_downloading - 1

		local next = download_queue[1]
		if next then
			table.remove(download_queue, 1)

			start_install(next.package, next.reason)
		end

		ui.update()
	end

	package.queued = false
	package.downloading = true

	if not core.handle_async(download_and_extract, params, callback) then
		core.log("error", "ERROR: async event failed")
		gamedata.errormessage = fgettext("Failed to download $1", package.name)
		return
	end
end

local function queue_download(package, reason)
	local max_concurrent_downloads = tonumber(core.settings:get("contentdb_max_concurrent_downloads"))
	if number_downloading < max_concurrent_downloads then
		start_install(package, reason)
	else
		table.insert(download_queue, { package = package, reason = reason })
		package.queued = true
	end
end

local function get_raw_dependencies(package)
	if package.raw_deps then
		return package.raw_deps
	end

	local url_fmt = "/api/packages/%s/dependencies/?only_hard=1&protocol_version=%s&engine_version=%s"
	local version = core.get_version()
	local base_url = core.settings:get("contentdb_url")
	local url = base_url .. url_fmt:format(package.id, core.get_max_supp_proto(), version.string)

	local response = http.fetch_sync({ url = url })
	if not response.succeeded then
		return
	end

	local data = core.parse_json(response.data) or {}

	local content_lookup = {}
	for _, pkg in pairs(store.packages_full) do
		content_lookup[pkg.id] = pkg
	end

	for id, raw_deps in pairs(data) do
		local package2 = content_lookup[id:lower()]
		if package2 and not package2.raw_deps then
			package2.raw_deps = raw_deps

			for _, dep in pairs(raw_deps) do
				local packages = {}