tab_about.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. --Luanti
  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. string = core.hypertext_escape(string)
  20. string = string:gsub("%[.-%]", "<gray>%1</gray>")
  21. table.insert(dest, string)
  22. end
  23. local function get_credits()
  24. local f = assert(io.open(core.get_mainmenu_path() .. "/credits.json"))
  25. local json = core.parse_json(f:read("*all"))
  26. f:close()
  27. return json
  28. end
  29. return {
  30. name = "about",
  31. caption = fgettext("About"),
  32. cbf_formspec = function(tabview, name, tabdata)
  33. local logofile = defaulttexturedir .. "logo.png"
  34. local version = core.get_version()
  35. local hypertext = {
  36. "<tag name=heading color=#ff0>",
  37. "<tag name=gray color=#aaa>",
  38. }
  39. local credits = get_credits()
  40. table.insert_all(hypertext, {
  41. "<heading>", fgettext_ne("Core Developers"), "</heading>\n",
  42. })
  43. prepare_credits(hypertext, credits.core_developers)
  44. table.insert_all(hypertext, {
  45. "\n",
  46. "<heading>", fgettext_ne("Core Team"), "</heading>\n",
  47. })
  48. prepare_credits(hypertext, credits.core_team)
  49. table.insert_all(hypertext, {
  50. "\n",
  51. "<heading>", fgettext_ne("Active Contributors"), "</heading>\n",
  52. })
  53. prepare_credits(hypertext, credits.contributors)
  54. table.insert_all(hypertext, {
  55. "\n",
  56. "<heading>", fgettext_ne("Previous Core Developers"), "</heading>\n",
  57. })
  58. prepare_credits(hypertext, credits.previous_core_developers)
  59. table.insert_all(hypertext, {
  60. "\n",
  61. "<heading>", fgettext_ne("Previous Contributors"), "</heading>\n",
  62. })
  63. prepare_credits(hypertext, credits.previous_contributors)
  64. hypertext = table.concat(hypertext):sub(1, -2)
  65. local fs = "image[1.5,0.6;2.5,2.5;" .. core.formspec_escape(logofile) .. "]" ..
  66. "style[label_button;border=false]" ..
  67. "button[0.1,3.4;5.3,0.5;label_button;" ..
  68. core.formspec_escape(version.project .. " " .. version.string) .. "]" ..
  69. "button_url[1.5,4.1;2.5,0.8;homepage;luanti.org;https://www.luanti.org/]" ..
  70. "hypertext[5.5,0.25;9.75,6.6;credits;" .. core.formspec_escape(hypertext) .. "]"
  71. -- Render information
  72. local active_renderer_info = fgettext("Active renderer:") .. " " ..
  73. core.formspec_escape(core.get_active_renderer())
  74. fs = fs .. "style[label_button2;border=false]" ..
  75. "button[0.1,6;5.3,0.5;label_button2;" .. active_renderer_info .. "]"..
  76. "tooltip[label_button2;" .. active_renderer_info .. "]"
  77. -- Irrlicht device information
  78. local irrlicht_device_info = fgettext("Irrlicht device:") .. " " ..
  79. core.formspec_escape(core.get_active_irrlicht_device())
  80. fs = fs .. "style[label_button3;border=false]" ..
  81. "button[0.1,6.5;5.3,0.5;label_button3;" .. irrlicht_device_info .. "]"..
  82. "tooltip[label_button3;" .. irrlicht_device_info .. "]"
  83. if PLATFORM == "Android" then
  84. fs = fs .. "button[0.5,5.1;4.5,0.8;share_debug;" .. fgettext("Share debug log") .. "]"
  85. else
  86. fs = fs .. "tooltip[userdata;" ..
  87. fgettext("Opens the directory that contains user-provided worlds, games, mods,\n" ..
  88. "and texture packs in a file manager / explorer.") .. "]"
  89. fs = fs .. "button[0.5,5.1;4.5,0.8;userdata;" .. fgettext("Open User Data Directory") .. "]"
  90. end
  91. return fs
  92. end,
  93. cbf_button_handler = function(this, fields, name, tabdata)
  94. if fields.share_debug then
  95. local path = core.get_user_path() .. DIR_DELIM .. "debug.txt"
  96. core.share_file(path)
  97. end
  98. if fields.userdata then
  99. core.open_dir(core.get_user_path())
  100. end
  101. end,
  102. on_change = function(type)
  103. if type == "ENTER" then
  104. mm_game_theme.set_engine()
  105. end
  106. end,
  107. }