tab_about.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. --Minetest
  2. --Copyright (C) 2013 sapier
  3. --
  4. --This program is free software; you can redistribute it and/or modify
  5. --it under the terms of the GNU Lesser General Public License as published by
  6. --the Free Software Foundation; either version 2.1 of the License, or
  7. --(at your option) any later version.
  8. --
  9. --This program is distributed in the hope that it will be useful,
  10. --but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. --GNU Lesser General Public License for more details.
  13. --
  14. --You should have received a copy of the GNU Lesser General Public License along
  15. --with this program; if not, write to the Free Software Foundation, Inc.,
  16. --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. local function prepare_credits(dest, source)
  18. local string = table.concat(source, "\n") .. "\n"
  19. local hypertext_escapes = {
  20. ["\\"] = "\\\\",
  21. ["<"] = "\\<",
  22. [">"] = "\\>",
  23. }
  24. string = string:gsub("[\\<>]", hypertext_escapes)
  25. string = string:gsub("%[.-%]", "<gray>%1</gray>")
  26. table.insert(dest, string)
  27. end
  28. local function get_credits()
  29. local f = assert(io.open(core.get_mainmenu_path() .. "/credits.json"))
  30. local json = core.parse_json(f:read("*all"))
  31. f:close()
  32. return json
  33. end
  34. return {
  35. name = "about",
  36. caption = fgettext("About"),
  37. cbf_formspec = function(tabview, name, tabdata)
  38. local logofile = defaulttexturedir .. "logo.png"
  39. local version = core.get_version()
  40. local hypertext = {
  41. "<tag name=heading color=#ff0>",
  42. "<tag name=gray color=#aaa>",
  43. }
  44. local credits = get_credits()
  45. table.insert_all(hypertext, {
  46. "<heading>", fgettext_ne("Core Developers"), "</heading>\n",
  47. })
  48. prepare_credits(hypertext, credits.core_developers)
  49. table.insert_all(hypertext, {
  50. "\n",
  51. "<heading>", fgettext_ne("Core Team"), "</heading>\n",
  52. })
  53. prepare_credits(hypertext, credits.core_team)
  54. table.insert_all(hypertext, {
  55. "\n",
  56. "<heading>", fgettext_ne("Active Contributors"), "</heading>\n",
  57. })
  58. prepare_credits(hypertext, credits.contributors)
  59. table.insert_all(hypertext, {
  60. "\n",
  61. "<heading>", fgettext_ne("Previous Core Developers"), "</heading>\n",
  62. })
  63. prepare_credits(hypertext, credits.previous_core_developers)
  64. table.insert_all(hypertext, {
  65. "\n",
  66. "<heading>", fgettext_ne("Previous Contributors"), "</heading>\n",
  67. })
  68. prepare_credits(hypertext, credits.previous_contributors)
  69. hypertext = table.concat(hypertext):sub(1, -2)
  70. local fs = "image[1.5,0.6;2.5,2.5;" .. core.formspec_escape(logofile) .. "]" ..
  71. "style[label_button;border=false]" ..
  72. "button[0.1,3.4;5.3,0.5;label_button;" ..
  73. core.formspec_escape(version.project .. " " .. version.string) .. "]" ..
  74. "button_url[1.5,4.1;2.5,0.8;homepage;minetest.net;https://www.minetest.net/]" ..
  75. "hypertext[5.5,0.25;9.75,6.6;credits;" .. minetest.formspec_escape(hypertext) .. "]"
  76. -- Render information
  77. local active_renderer_info = fgettext("Active renderer:") .. " " ..
  78. core.formspec_escape(core.get_active_renderer())
  79. fs = fs .. "style[label_button2;border=false]" ..
  80. "button[0.1,6;5.3,0.5;label_button2;" .. active_renderer_info .. "]"..
  81. "tooltip[label_button2;" .. active_renderer_info .. "]"
  82. -- Irrlicht device information
  83. local irrlicht_device_info = fgettext("Irrlicht device:") .. " " ..
  84. core.formspec_escape(core.get_active_irrlicht_device())
  85. fs = fs .. "style[label_button3;border=false]" ..
  86. "button[0.1,6.5;5.3,0.5;label_button3;" .. irrlicht_device_info .. "]"..
  87. "tooltip[label_button3;" .. irrlicht_device_info .. "]"
  88. if PLATFORM == "Android" then
  89. fs = fs .. "button[0.5,5.1;4.5,0.8;share_debug;" .. fgettext("Share debug log") .. "]"
  90. else
  91. fs = fs .. "tooltip[userdata;" ..
  92. fgettext("Opens the directory that contains user-provided worlds, games, mods,\n" ..
  93. "and texture packs in a file manager / explorer.") .. "]"
  94. fs = fs .. "button[0.5,5.1;4.5,0.8;userdata;" .. fgettext("Open User Data Directory") .. "]"
  95. end
  96. return fs
  97. end,
  98. cbf_button_handler = function(this, fields, name, tabdata)
  99. if fields.share_debug then
  100. local path = core.get_user_path() .. DIR_DELIM .. "debug.txt"
  101. core.share_file(path)
  102. end
  103. if fields.userdata then
  104. core.open_dir(core.get_user_path())
  105. end
  106. end,
  107. on_change = function(type)
  108. if type == "ENTER" then
  109. mm_game_theme.set_engine()
  110. end
  111. end,
  112. }