write something there
This commit is contained in:
commit
b4b6c08f4f
8546 changed files with 309825 additions and 0 deletions
18
mods/minetest_game/sfinv/README.txt
Normal file
18
mods/minetest_game/sfinv/README.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
Minetest Game mod: sfinv
|
||||
========================
|
||||
See license.txt for license information.
|
||||
|
||||
Simple Fast Inventory.
|
||||
A cleaner, simpler, solution to having an advanced inventory in Luanti.
|
||||
See game_api.txt for this mod's API.
|
||||
Available for use outside of MTG here:
|
||||
https://forum.luanti.org/viewtopic.php?t=19765
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
rubenwardy (MIT)
|
||||
|
||||
Authors of media
|
||||
----------------
|
||||
paramat (CC BY-SA 3.0):
|
||||
sfinv_crafting_arrow.png - derived from a texture by BlockMen (CC BY-SA 3.0)
|
189
mods/minetest_game/sfinv/api.lua
Normal file
189
mods/minetest_game/sfinv/api.lua
Normal file
|
@ -0,0 +1,189 @@
|
|||
sfinv = {
|
||||
pages = {},
|
||||
pages_unordered = {},
|
||||
contexts = {},
|
||||
enabled = true
|
||||
}
|
||||
|
||||
function sfinv.register_page(name, def)
|
||||
assert(name, "Invalid sfinv page. Requires a name")
|
||||
assert(def, "Invalid sfinv page. Requires a def[inition] table")
|
||||
assert(def.get, "Invalid sfinv page. Def requires a get function.")
|
||||
assert(not sfinv.pages[name], "Attempt to register already registered sfinv page " .. dump(name))
|
||||
|
||||
sfinv.pages[name] = def
|
||||
def.name = name
|
||||
table.insert(sfinv.pages_unordered, def)
|
||||
end
|
||||
|
||||
function sfinv.override_page(name, def)
|
||||
assert(name, "Invalid sfinv page override. Requires a name")
|
||||
assert(def, "Invalid sfinv page override. Requires a def[inition] table")
|
||||
local page = sfinv.pages[name]
|
||||
assert(page, "Attempt to override sfinv page " .. dump(name) .. " which does not exist.")
|
||||
for key, value in pairs(def) do
|
||||
page[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
function sfinv.get_nav_fs(player, context, nav, current_idx)
|
||||
-- Only show tabs if there is more than one page
|
||||
if #nav > 1 then
|
||||
return "tabheader[0,0;sfinv_nav_tabs;" .. table.concat(nav, ",") ..
|
||||
";" .. current_idx .. ";true;false]"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
local theme_inv = [[
|
||||
image[0,5.2;1,1;gui_hb_bg.png]
|
||||
image[1,5.2;1,1;gui_hb_bg.png]
|
||||
image[2,5.2;1,1;gui_hb_bg.png]
|
||||
image[3,5.2;1,1;gui_hb_bg.png]
|
||||
image[4,5.2;1,1;gui_hb_bg.png]
|
||||
image[5,5.2;1,1;gui_hb_bg.png]
|
||||
image[6,5.2;1,1;gui_hb_bg.png]
|
||||
image[7,5.2;1,1;gui_hb_bg.png]
|
||||
list[current_player;main;0,5.2;8,1;]
|
||||
list[current_player;main;0,6.35;8,3;8]
|
||||
]]
|
||||
|
||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||
local tmp = {
|
||||
size or "size[8,9.1]",
|
||||
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
|
||||
show_inv and theme_inv or "",
|
||||
content
|
||||
}
|
||||
return table.concat(tmp, "")
|
||||
end
|
||||
|
||||
function sfinv.get_homepage_name(player)
|
||||
return "sfinv:crafting"
|
||||
end
|
||||
|
||||
function sfinv.get_formspec(player, context)
|
||||
-- Generate navigation tabs
|
||||
local nav = {}
|
||||
local nav_ids = {}
|
||||
local current_idx = 1
|
||||
for i, pdef in pairs(sfinv.pages_unordered) do
|
||||
if not pdef.is_in_nav or pdef:is_in_nav(player, context) then
|
||||
nav[#nav + 1] = pdef.title
|
||||
nav_ids[#nav_ids + 1] = pdef.name
|
||||
if pdef.name == context.page then
|
||||
current_idx = #nav_ids
|
||||
end
|
||||
end
|
||||
end
|
||||
context.nav = nav_ids
|
||||
context.nav_titles = nav
|
||||
context.nav_idx = current_idx
|
||||
|
||||
-- Generate formspec
|
||||
local page = sfinv.pages[context.page] or sfinv.pages["404"]
|
||||
if page then
|
||||
return page:get(player, context)
|
||||
else
|
||||
local old_page = context.page
|
||||
local home_page = sfinv.get_homepage_name(player)
|
||||
|
||||
if old_page == home_page then
|
||||
minetest.log("error", "[sfinv] Couldn't find " .. dump(old_page) ..
|
||||
", which is also the old page")
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
context.page = home_page
|
||||
assert(sfinv.pages[context.page], "[sfinv] Invalid homepage")
|
||||
minetest.log("warning", "[sfinv] Couldn't find " .. dump(old_page) ..
|
||||
" so switching to homepage")
|
||||
|
||||
return sfinv.get_formspec(player, context)
|
||||
end
|
||||
end
|
||||
|
||||
function sfinv.get_or_create_context(player)
|
||||
local name = player:get_player_name()
|
||||
local context = sfinv.contexts[name]
|
||||
if not context then
|
||||
context = {
|
||||
page = sfinv.get_homepage_name(player)
|
||||
}
|
||||
sfinv.contexts[name] = context
|
||||
end
|
||||
return context
|
||||
end
|
||||
|
||||
function sfinv.set_context(player, context)
|
||||
sfinv.contexts[player:get_player_name()] = context
|
||||
end
|
||||
|
||||
function sfinv.set_player_inventory_formspec(player, context)
|
||||
local fs = sfinv.get_formspec(player,
|
||||
context or sfinv.get_or_create_context(player))
|
||||
player:set_inventory_formspec(fs)
|
||||
end
|
||||
|
||||
function sfinv.set_page(player, pagename)
|
||||
local context = sfinv.get_or_create_context(player)
|
||||
local oldpage = sfinv.pages[context.page]
|
||||
if oldpage and oldpage.on_leave then
|
||||
oldpage:on_leave(player, context)
|
||||
end
|
||||
context.page = pagename
|
||||
local page = sfinv.pages[pagename]
|
||||
if page.on_enter then
|
||||
page:on_enter(player, context)
|
||||
end
|
||||
sfinv.set_player_inventory_formspec(player, context)
|
||||
end
|
||||
|
||||
function sfinv.get_page(player)
|
||||
local context = sfinv.contexts[player:get_player_name()]
|
||||
return context and context.page or sfinv.get_homepage_name(player)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if sfinv.enabled then
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
sfinv.contexts[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "" or not sfinv.enabled then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Get Context
|
||||
local name = player:get_player_name()
|
||||
local context = sfinv.contexts[name]
|
||||
if not context then
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Was a tab selected?
|
||||
if fields.sfinv_nav_tabs and context.nav then
|
||||
local tid = tonumber(fields.sfinv_nav_tabs)
|
||||
if tid and tid > 0 then
|
||||
local id = context.nav[tid]
|
||||
local page = sfinv.pages[id]
|
||||
if id and page then
|
||||
sfinv.set_page(player, id)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Pass event to page
|
||||
local page = sfinv.pages[context.page]
|
||||
if page and page.on_player_receive_fields then
|
||||
return page:on_player_receive_fields(player, context, fields)
|
||||
end
|
||||
end
|
||||
end)
|
19
mods/minetest_game/sfinv/init.lua
Normal file
19
mods/minetest_game/sfinv/init.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
-- sfinv/init.lua
|
||||
|
||||
dofile(minetest.get_modpath("sfinv") .. "/api.lua")
|
||||
|
||||
-- Load support for MT game translation.
|
||||
local S = minetest.get_translator("sfinv")
|
||||
|
||||
sfinv.register_page("sfinv:crafting", {
|
||||
title = S("Crafting"),
|
||||
get = function(self, player, context)
|
||||
return sfinv.make_formspec(player, context, [[
|
||||
list[current_player;craft;1.75,0.5;3,3;]
|
||||
list[current_player;craftpreview;5.75,1.5;1,1;]
|
||||
image[4.75,1.5;1,1;sfinv_crafting_arrow.png]
|
||||
listring[current_player;main]
|
||||
listring[current_player;craft]
|
||||
]], true)
|
||||
end
|
||||
})
|
59
mods/minetest_game/sfinv/license.txt
Normal file
59
mods/minetest_game/sfinv/license.txt
Normal file
|
@ -0,0 +1,59 @@
|
|||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright (C) 2016-2018 rubenwardy <rubenwardy@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more details:
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
License of media
|
||||
----------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright (C) 2019 paramat
|
||||
|
||||
You are free to:
|
||||
Share — copy and redistribute the material in any medium or format.
|
||||
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||
|
||||
Under the following terms:
|
||||
|
||||
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||
that suggests the licensor endorses you or your use.
|
||||
|
||||
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||
your contributions under the same license as the original.
|
||||
|
||||
No additional restrictions — You may not apply legal terms or technological measures that
|
||||
legally restrict others from doing anything the license permits.
|
||||
|
||||
Notices:
|
||||
|
||||
You do not have to comply with the license for elements of the material in the public
|
||||
domain or where your use is permitted by an applicable exception or limitation.
|
||||
No warranties are given. The license may not give you all of the permissions necessary
|
||||
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||
rights may limit how you use the material.
|
||||
|
||||
For more details:
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
2
mods/minetest_game/sfinv/locale/sfinv.de.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.de.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Fertigung
|
2
mods/minetest_game/sfinv/locale/sfinv.eo.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.eo.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Konstruado
|
2
mods/minetest_game/sfinv/locale/sfinv.es.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.es.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Creación
|
2
mods/minetest_game/sfinv/locale/sfinv.fr.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.fr.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Artisanat
|
2
mods/minetest_game/sfinv/locale/sfinv.id.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.id.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Kerajinan
|
2
mods/minetest_game/sfinv/locale/sfinv.it.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.it.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Assemblaggio
|
2
mods/minetest_game/sfinv/locale/sfinv.ja.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.ja.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=クラフト
|
2
mods/minetest_game/sfinv/locale/sfinv.jbo.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.jbo.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=nu zbasu
|
2
mods/minetest_game/sfinv/locale/sfinv.lv.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.lv.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Taisīšana
|
2
mods/minetest_game/sfinv/locale/sfinv.ms.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.ms.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Pertukangan
|
2
mods/minetest_game/sfinv/locale/sfinv.pl.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.pl.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Konstruowanie
|
2
mods/minetest_game/sfinv/locale/sfinv.pt_BR.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.pt_BR.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Construir
|
2
mods/minetest_game/sfinv/locale/sfinv.ru.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.ru.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Крафтинг
|
2
mods/minetest_game/sfinv/locale/sfinv.sk.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.sk.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Vytváranie
|
2
mods/minetest_game/sfinv/locale/sfinv.sv.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.sv.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Tillverkning
|
2
mods/minetest_game/sfinv/locale/sfinv.uk.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.uk.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=Майстрування
|
2
mods/minetest_game/sfinv/locale/sfinv.zh_CN.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.zh_CN.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=合成
|
2
mods/minetest_game/sfinv/locale/sfinv.zh_TW.tr
Normal file
2
mods/minetest_game/sfinv/locale/sfinv.zh_TW.tr
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=合成
|
2
mods/minetest_game/sfinv/locale/template.txt
Normal file
2
mods/minetest_game/sfinv/locale/template.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
# textdomain: sfinv
|
||||
Crafting=
|
2
mods/minetest_game/sfinv/mod.conf
Normal file
2
mods/minetest_game/sfinv/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = sfinv
|
||||
description = Minetest Game mod: sfinv
|
BIN
mods/minetest_game/sfinv/textures/sfinv_crafting_arrow.png
Normal file
BIN
mods/minetest_game/sfinv/textures/sfinv_crafting_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 382 B |
Loading…
Add table
Add a link
Reference in a new issue