Skip to content

Commit c8ff11b

Browse files
Rui914kwolekr
Rui914
authored andcommittedMar 31, 2016
Mainmenu: Move description.txt textbox down
Additionally, fix misc. code style issues
1 parent f9a9038 commit c8ff11b

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed
 

Diff for: ‎builtin/mainmenu/tab_texturepacks.lua

+20-18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
--------------------------------------------------------------------------------
1919
local function filter_texture_pack_list(list)
2020
local retval = {}
21+
2122
for _, item in ipairs(list) do
2223
if item ~= "base" then
2324
retval[#retval + 1] = item
@@ -35,9 +36,9 @@ local function render_texture_pack_list(list)
3536
local retval = ""
3637

3738
for i, v in ipairs(list) do
38-
if v:sub(1,1) ~= "." then
39+
if v:sub(1, 1) ~= "." then
3940
if retval ~= "" then
40-
retval = retval ..","
41+
retval = retval .. ","
4142
end
4243

4344
retval = retval .. core.formspec_escape(v)
@@ -50,14 +51,14 @@ end
5051
--------------------------------------------------------------------------------
5152
local function get_formspec(tabview, name, tabdata)
5253

53-
local retval = "label[4,-0.25;".. fgettext("Select texture pack:") .. "]"..
54+
local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" ..
5455
"textlist[4,0.25;7.5,5.0;TPs;"
5556

5657
local current_texture_path = core.setting_get("texture_path")
5758
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
5859
local index = tonumber(core.setting_get("mainmenu_last_selected_TP"))
5960

60-
if index == nil then index = 1 end
61+
if not index then index = 1 end
6162

6263
if current_texture_path == "" then
6364
retval = retval ..
@@ -66,15 +67,16 @@ local function get_formspec(tabview, name, tabdata)
6667
return retval
6768
end
6869

69-
local infofile = current_texture_path ..DIR_DELIM.."description.txt"
70+
local infofile = current_texture_path .. DIR_DELIM .. "description.txt"
7071
-- This adds backwards compatibility for old texture pack description files named
7172
-- "info.txt", and should be removed once all such texture packs have been updated
7273
if not file_exists(infofile) then
73-
infofile = current_texture_path ..DIR_DELIM.."info.txt"
74+
infofile = current_texture_path .. DIR_DELIM .. "info.txt"
7475
if file_exists(infofile) then
75-
core.log("info.txt is depreciated. description.txt should be used instead.");
76+
core.log("info.txt is depreciated. description.txt should be used instead.")
7677
end
7778
end
79+
7880
local infotext = ""
7981
local f = io.open(infofile, "r")
8082
if not f then
@@ -84,8 +86,8 @@ local function get_formspec(tabview, name, tabdata)
8486
f:close()
8587
end
8688

87-
local screenfile = current_texture_path..DIR_DELIM.."screenshot.png"
88-
local no_screenshot = nil
89+
local screenfile = current_texture_path .. DIR_DELIM .. "screenshot.png"
90+
local no_screenshot
8991
if not file_exists(screenfile) then
9092
screenfile = nil
9193
no_screenshot = defaulttexturedir .. "no_screenshot.png"
@@ -94,24 +96,24 @@ local function get_formspec(tabview, name, tabdata)
9496
return retval ..
9597
render_texture_pack_list(list) ..
9698
";" .. index .. "]" ..
97-
"image[0.25,0.25;4.0,3.7;"..core.formspec_escape(screenfile or no_screenshot).."]"..
98-
"textarea[0.6,3.25;3.7,1.5;;"..core.formspec_escape(infotext or "")..";]"
99+
"image[0.25,0.25;4.0,3.7;" .. core.formspec_escape(screenfile or no_screenshot) .. "]" ..
100+
"textarea[0.6,3.5;3.7,1.5;;" .. core.formspec_escape(infotext or "") .. ";]"
99101
end
100102

101103
--------------------------------------------------------------------------------
102104
local function main_button_handler(tabview, fields, name, tabdata)
103-
if fields["TPs"] ~= nil then
105+
if fields["TPs"] then
104106
local event = core.explode_textlist_event(fields["TPs"])
105107
if event.type == "CHG" or event.type == "DCL" then
106108
local index = core.get_textlist_index("TPs")
107-
core.setting_set("mainmenu_last_selected_TP",
108-
index)
109+
core.setting_set("mainmenu_last_selected_TP", index)
109110
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
110111
local current_index = core.get_textlist_index("TPs")
111-
if current_index ~= nil and #list >= current_index then
112-
local new_path = core.get_texturepath()..DIR_DELIM..list[current_index]
113-
if list[current_index] == fgettext("None") then new_path = "" end
114-
112+
if current_index and #list >= current_index then
113+
local new_path = core.get_texturepath() .. DIR_DELIM .. list[current_index]
114+
if list[current_index] == fgettext("None") then
115+
new_path = ""
116+
end
115117
core.setting_set("texture_path", new_path)
116118
end
117119
end

0 commit comments

Comments
 (0)