+
+ -- Box good, textarea bad. Calculate textarea size from box.
+ local function create_textfield(size, label, text, bg_color)
+ local textarea = {
+ x = size.x + 0.3,
+ y = size.y,
+ w = size.w + 0.25,
+ h = size.h * 1.16 + 0.12
+ }
+ return ("box[%f,%f;%f,%f;%s]textarea[%f,%f;%f,%f;;%s;%s]"):format(
+ size.x, size.y, size.w, size.h, bg_color or "#000",
+ textarea.x, textarea.y, textarea.w, textarea.h,
+ core.formspec_escape(label), core.formspec_escape(text)
+ )
+
+ end
+
+ -- When there's an error: Shrink description textarea and add error below
+ if dialogdata.error_message then
+ local error_box = {
+ x = 0,
+ y = description_height - 0.4,
+ w = width - 0.25,
+ h = 0.5
+ }
+ formspec = formspec ..
+ create_textfield(error_box, "", dialogdata.error_message, "#600")
+ description_height = description_height - 0.75
+ end
+
+ -- Get description field
+ local description_box = {
+ x = 0,
+ y = 0.2,
+ w = width - 0.25,
+ h = description_height
+ }
+
+ local setting_name = setting.name
+ if setting.readable_name then
+ setting_name = fgettext_ne(setting.readable_name) ..
+ " (" .. setting.name .. ")"
+ end
+
+ local comment_text
+ if setting.comment == "" then
+ comment_text = fgettext_ne("(No description of setting given)")
+ else
+ comment_text = fgettext_ne(setting.comment)
+ end
+
+ return (
+ "size[" .. width .. "," .. height + 0.25 .. ",true]" ..
+ create_textfield(description_box, setting_name, comment_text) ..
+ formspec ..
+ "button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" ..
+ fgettext("Save") .. "]" ..
+ "button[" .. width / 2 .. "," .. height - 0.4 .. ";2.5,1;btn_cancel;" ..
+ fgettext("Cancel") .. "]"
+ )