|
| 1 | +local clip_fs = [[ |
| 2 | + style_type[label;noclip=%c] |
| 3 | + style_type[button;noclip=%c] |
| 4 | + style_type[image_button;noclip=%c] |
| 5 | + style_type[item_image_button;noclip=%c] |
| 6 | + style_type[tabheader;noclip=%c] |
| 7 | + style_type[field;noclip=%c] |
| 8 | + style_type[textarea;noclip=%c] |
| 9 | + style_type[checkbox;noclip=%c] |
| 10 | + style_type[dropdown;noclip=%c] |
| 11 | + style_type[scrollbar;noclip=%c] |
| 12 | + style_type[table;noclip=%c] |
| 13 | +
|
| 14 | + label[0,0;A clipping test] |
| 15 | + button[0,1;3,0.8;x;A clipping test] |
| 16 | + image_button[0,2;3,0.8;bubble.png;x2;A clipping test] |
| 17 | + item_image_button[0,3;3,0.8;default:sword_steel;x3;A clipping test] |
| 18 | + tabheader[0,4.7;3,0.63;x4;Clip,Test,Text,Tabs;1;false;false] |
| 19 | + field[0,5;3,0.8;x5;Title;] |
| 20 | + textarea[0,6;3,1;x6;Title;] |
| 21 | + checkbox[0,7.5;x7;This is a test;true] |
| 22 | + dropdown[0,8;3,0.8;x8;Select An Item,One,Two,Three,Four,Five;1] |
| 23 | + scrollbar[0,9;3,0.8;horizontal;x9;3] |
| 24 | + tablecolumns[text;text] |
| 25 | + table[0,10;3,1;x10;one,two,three,four;1] |
| 26 | +]] |
| 27 | + |
| 28 | + |
| 29 | +local style_fs = [[ |
| 30 | + style[one_btn1;bgcolor=red;textcolor=yellow] |
| 31 | + button[0,0;2.5,0.8;one_btn1;Button] |
| 32 | +
|
| 33 | + style[one_btn2;border=false;textcolor=cyan] |
| 34 | + button[0,1.05;2.5,0.8;one_btn2;Text Button] |
| 35 | +
|
| 36 | + style[one_btn3;bgimg=bubble.png;bgimg_pressed=heart.png] |
| 37 | + button[0,2.1;1,1;one_btn3;Bor] |
| 38 | +
|
| 39 | + style[one_btn4;bgimg=bubble.png;bgimg_pressed=heart.png;border=false] |
| 40 | + button[1.25,2.1;1,1;one_btn4;Bub] |
| 41 | +
|
| 42 | + style[one_btn5;bgimg=bubble.png;bgimg_pressed=heart.png;border=false;alpha=false] |
| 43 | + button[0,3.35;1,1;one_btn5;Alph] |
| 44 | +
|
| 45 | + style[one_btn6;border=true] |
| 46 | + image_button[0,4.6;1,1;bubble.png;one_btn6;Border] |
| 47 | +
|
| 48 | + style[one_btn7;border=false] |
| 49 | + image_button[1.25,4.6;1,1;bubble.png;one_btn7;NoBor] |
| 50 | +
|
| 51 | + style[one_btn8;border=false] |
| 52 | + image_button[0,5.85;1,1;bubble.png;one_btn8;Border;false;true;heart.png] |
| 53 | +
|
| 54 | + style[one_btn9;border=true] |
| 55 | + image_button[1.25,5.85;1,1;bubble.png;one_btn9;NoBor;false;false;heart.png] |
| 56 | +
|
| 57 | + style[one_btn10;alpha=false] |
| 58 | + image_button[0,7.1;1,1;bubble.png;one_btn10;NoAlpha] |
| 59 | +
|
| 60 | + style[one_btn11;alpha=true] |
| 61 | + image_button[1.25,7.1;1,1;bubble.png;one_btn11;Alpha] |
| 62 | +
|
| 63 | + style[one_btn12;border=true] |
| 64 | + item_image_button[0,8.35;1,1;default:sword_steel;one_btn12;Border] |
| 65 | +
|
| 66 | + style[one_btn13;border=false] |
| 67 | + item_image_button[1.25,8.35;1,1;default:sword_steel;one_btn13;NoBor] |
| 68 | +
|
| 69 | +
|
| 70 | + container[2.75,0] |
| 71 | +
|
| 72 | + style[one_tb1;textcolor=Yellow] |
| 73 | + tabheader[0,3;2.5,0.63;one_tb1;Yellow,Text,Tabs;1;false;false] |
| 74 | +
|
| 75 | + style[one_f1;textcolor=yellow] |
| 76 | + field[0,4.25;2.5,0.8;one_f1;Field One;Yellow Text] |
| 77 | +
|
| 78 | + style[one_f2;border=false;textcolor=cyan] |
| 79 | + field[0,5.75;2.5,0.8;one_f2;Field Two;Borderless Cyan Text] |
| 80 | +
|
| 81 | + style[one_f3;textcolor=yellow] |
| 82 | + textarea[0,7.025;2.5,0.8;one_f3;Label;]] .. |
| 83 | + minetest.formspec_escape("Yellow Text\nLine two") .. [[ ] |
| 84 | +
|
| 85 | + style[one_f4;border=false;textcolor=cyan] |
| 86 | + textarea[0,8.324999999999999;2.5,0.8;one_f4;Label;]] .. |
| 87 | + minetest.formspec_escape("Borderless Cyan Text\nLine two") .. [[ ] |
| 88 | +
|
| 89 | + container_end[] |
| 90 | +]] |
| 91 | + |
| 92 | +--style_type[label;textcolor=green] |
| 93 | +--label[0,0;Green] |
| 94 | +--style_type[label;textcolor=blue] |
| 95 | +--label[0,1;Blue] |
| 96 | +--style_type[label;textcolor=;border=true] |
| 97 | +--label[1.2,0;Border] |
| 98 | +--style_type[label;border=true;bgcolor=red] |
| 99 | +--label[1.2,1;Background] |
| 100 | +--style_type[label;border=;bgcolor=] |
| 101 | +--label[0.75,2;Reset] |
| 102 | + |
| 103 | + |
| 104 | +local pages = { |
| 105 | + [[ |
| 106 | + size[12,12] |
| 107 | + real_coordinates[true] |
| 108 | + image_button[0,0;1,1;logo.png;;1x1] |
| 109 | + image_button[1,0;2,2;logo.png;;2x2] |
| 110 | + button[0,2;1,1;;1x1] |
| 111 | + button[1,2;2,2;;2x2] |
| 112 | + item_image[0,4;1,1;air] |
| 113 | + item_image[1,4;2,2;air] |
| 114 | + item_image_button[0,6;1,1;test:node;;1x1] |
| 115 | + item_image_button[1,6;2,2;test:node;;2x2] |
| 116 | + field[3,.5;3,.5;name;Field;text] |
| 117 | + pwdfield[6,.5;3,1;name;Password Field] |
| 118 | + field[3,1;3,1;;Read-Only Field;text] |
| 119 | + textarea[3,2;3,.5;name;Textarea;text] |
| 120 | + textarea[6,2;3,2;name;Textarea;text\nmore text] |
| 121 | + textarea[3,3;3,1;;Read-Only Textarea;text\nmore text] |
| 122 | + textlist[3,4;3,2;name;Textlist,Perfect Coordinates;1;false] |
| 123 | + tableoptions[highlight=#ABCDEF75;background=#00000055;border=false] |
| 124 | + table[6,4;3,2;name;Table,Cool Stuff,Foo,Bar;2] |
| 125 | + dropdown[3,6;3,1;name;This,is,a,dropdown;1] |
| 126 | + dropdown[6,6;3,2;name;I,am,a,bigger,dropdown;5] |
| 127 | + image[0,8;3,2;ignore.png] |
| 128 | + box[3,7;3,1;#00A3FF] |
| 129 | + checkbox[3,8;name;Check me!;false] |
| 130 | + checkbox[3,9;name;Uncheck me now!;true] |
| 131 | + scrollbar[0,11.5;11.5,.5;horizontal;name;500] |
| 132 | + scrollbar[11.5,0;.5,11.5;vertical;name;0] |
| 133 | + list[current_player;main;6,8;3,2;1] |
| 134 | + button[9,0;2.5,1;name;] |
| 135 | + button[9,1;2.5,1;name;] |
| 136 | + button[9,2;2.5,1;name;] |
| 137 | + label[9,0;This is a label.\nLine\nLine\nLine\nEnd] |
| 138 | + button[9,3;1,1;name;] |
| 139 | + vertlabel[9,4;VERT] |
| 140 | + label[10,3;HORIZ] |
| 141 | + tabheader[6.5,0;6,0.65;name;Tab 1,Tab 2,Tab 3,Secrets;1;false;false] |
| 142 | + ]], |
| 143 | + |
| 144 | + "size[12,12]real_coordinates[true]" .. |
| 145 | + "label[0.375,0.375;Styled]" .. |
| 146 | + "label[6.375,0.375;Unstyled]" .. |
| 147 | + "box[0,0.75;12,0.1;#999]" .. |
| 148 | + "box[6,0.85;0.1,11.15;#999]" .. |
| 149 | + "container[0.375,1.225]" .. |
| 150 | + style_fs .. |
| 151 | + "container_end[]container[6.375,1.225]" .. |
| 152 | + style_fs:gsub("one_", "two_"):gsub("style%[[^%]]+%]", ""):gsub("style_type%[[^%]]+%]", "") .. |
| 153 | + "container_end[]", |
| 154 | + |
| 155 | + "size[12,12]real_coordinates[true]" .. |
| 156 | + "label[0.1,0.5;Clip]" .. |
| 157 | + "container[-2.5,1]" .. clip_fs:gsub("%%c", "false") .. "container_end[]" .. |
| 158 | + "label[11,0.5;Noclip]" .. |
| 159 | + "container[11.5,1]" .. clip_fs:gsub("%%c", "true") .. "container_end[]", |
| 160 | +} |
| 161 | + |
| 162 | +local function show_test_formspec(pname, page_id) |
| 163 | + page_id = page_id or 2 |
| 164 | + |
| 165 | + local fs = pages[page_id] .. "tabheader[0,0;6,0.65;maintabs;Real Coord,Styles,Noclip;" .. page_id .. ";false;false]" |
| 166 | + |
| 167 | + minetest.show_formspec(pname, "test:formspec", fs) |
| 168 | +end |
| 169 | + |
| 170 | +minetest.register_on_player_receive_fields(function(player, formname, fields) |
| 171 | + if formname ~= "test:formspec" then |
| 172 | + return false |
| 173 | + end |
| 174 | + |
| 175 | + if fields.maintabs then |
| 176 | + show_test_formspec(player:get_player_name(), tonumber(fields.maintabs)) |
| 177 | + return true |
| 178 | + end |
| 179 | + |
| 180 | +end) |
| 181 | + |
| 182 | +minetest.register_node("test:node", { |
| 183 | + tiles = { "air.png" } |
| 184 | +}) |
| 185 | + |
| 186 | +minetest.register_chatcommand("formspec", { |
| 187 | + func = function(name) |
| 188 | + if not minetest.get_player_by_name(name) then |
| 189 | + return false, "You need to be online!" |
| 190 | + end |
| 191 | + |
| 192 | + show_test_formspec(name) |
| 193 | + return true, "Opened formspec" |
| 194 | + end, |
| 195 | +}) |
0 commit comments