aboutsummaryrefslogtreecommitdiff
path: root/textures/base/pack/checkbox_64.png
blob: 03eb90bfeae48d17c2135f5311e53f5127d2690a (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 40 00 00 00 40 08 06 00 00 00 aa 69 71 .PNG........IHDR...@...@......iq
0020 de 00 00 00 04 73 42 49 54 08 08 08 08 7c 08 64 88 00 00 00 09 70 48 59 73 00 00 01 d8 00 00 01 .....sBIT....|.d.....pHYs.......
0040 d8 01 fa 5c a6 72 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 77 77 77 2e 69 6e 6b 73 63 ...\.r....tEXtSoftware.www.inksc
0060 61 70 65 2e 6f 72 67 9b ee 3c 1a 00 00 02 7b 49 44 41 54 78 9c ed 9b 4d 6e d3 40 18 40 9f c9 c4 ape.org..<....{IDATx...Mn.@.@...
0080 8e b2 41 ca e7 6e 2c 38 44 91 90 38 03 d7 60 45 81 0d e7 60 59 b7 0b e0 14 dd d1 33 65 9b 21 2b ..A..n,8D..8..`E...`Y......3e.!+
00a0 b3 20 0e 25 89 eb 9f f9 f1 38 99 27 75 53 c9 53 bf 57 27 1e 4f 26 10 89 44 22 91 48 e4 cc 48 76 ...%.....8.'uS.S.W'.O&..D".H..Hv
00c0 3f 17 49 22 22 65 9e e7 3f b8 c0 08 89 88 dc 15 45 51 15 45 51 89 c8 4f 5a 22 cc 3c 9d 98 0f 12 ?.I""e..?.......EQ.EQ..OZ".<....
00e0 11 29 b3 2c fb 58 ff 42 29 75 9d a6 e9 6b ad f5 43 d3 41 e7 12 e0 48 be a6 2d c2 39 04 68 94 af .).,.X.B)u...k..C.A...H..-.9.h..
0100 79 2e c2 d4 03 b4 ca d7 34 45 98 72 80 ce f2 35 a7 22 4c 35 40 22 22 b7 59 96 dd f4 3d 50 29 75 y.......4E.r...5."L5@"".Y...=P)u
0120 9d 65 d9 ab cd 66 f3 00 f0 c2 fe b9 39 67 b0 7c 4d 55 55 bf f7 83 d9 39 27 6f f4 be ec 0f d9 6e .e...f......9g.|MUU....9'o.....n
0140 b7 f7 eb f5 fa 13 50 c1 b4 02 58 97 87 e9 04 70 22 0f d3 08 e0 4c 1e c2 0f e0 54 1e c2 0e e0 5c ......P...X....p"....L....T....\
0160 1e c2 0d e0 45 1e c2 0c e0 4d 1e c2 0b e0 55 1e c2 0a e0 5d 1e c2 09 30 8a 3c 84 11 60 34 79 18 ....E....M....U....]...0.<..`4y.
0180 3f c0 a8 f2 30 6e 80 d1 e5 a1 fb e3 b0 ed 75 f6 fa 91 d6 44 be 34 95 87 6e 01 12 11 b9 cd f3 fc ?...0n........u....D.4..n.......
01a0 3b 76 22 18 3f cf ef e4 bf 60 28 0f ed 2b 42 f5 65 7a 33 9b cd de b4 2d 31 77 60 3f de d0 01 76 ;v".?....`(..+B.ez3....-1w`?...v
01c0 97 fd 67 2c c8 c3 f3 01 06 ad b3 f7 19 af 2f 36 5e f3 87 34 05 18 bc ce de 77 bc ae b8 90 87 d3 ..g,........../6^..4.....w......
01e0 01 8c d6 d9 87 8c d7 86 2b 79 38 0e 60 bc ce 3e 74 bc 26 5c ca c3 ff 01 ac ac b3 9b 8c 77 88 6b ........+y8.`..>t.&\.........w.k
0200 79 f8 17 c0 da 3a bb e9 78 35 bb 5b 9d b5 77 fb 26 f6 f3 80 a7 6b e5 7d 49 d3 f4 c3 93 79 42 50 y....:..x5.[..w.&....k.}I....yBP
0220 f7 f9 36 f6 2f 01 ad f5 63 9a a6 57 4a a9 b7 83 06 fa 3b 4f b8 5a 2e 97 ef 0d e5 ef 7c c9 c3 f1 ..6./...c..WJ.....;O.Z......|...
0240 cc 2e 59 ad 56 df 16 8b c5 57 1f 7f fc 10 9f ff f9 9a a3 db a0 d6 fa 71 3e 9f bf 54 4a bd f3 75 ..Y.V....W.............q>..TJ..u
0260 12 60 7f 86 d7 95 93 13 21 ad f5 2f 9f 11 7c bc db 37 d1 38 15 f6 15 61 4c 79 68 79 18 72 1d 61 .`......!../..|..7.8...aLyhy.r.a
0280 6c 79 e8 b0 3f c0 55 84 10 e4 a1 e3 06 09 db 11 42 91 87 1e 3b 44 6c 45 08 49 1e 7a 6e 91 31 8d ly..?.U.........B...;DlE.I.zn.1.
02a0 10 9a 3c 0c d8 23 34 34 42 88 f2 30 70 93 54 df 08 a1 ca 83 c1 2e b1 ae 11 42 96 07 c3 6d 72 6d ..<..#44B..0p.T..........B...mrm
02c0 11 42 97 07 0b fb 04 9b 22 4c 41 1e 2c 6d 94 3c 8c 30 15 79 db 24 22 52 8a 48 c9 f8 9f 39 8e c6 .B......"LA.,m.<.0.y.$"R.H...9..
02e0 45 7f 55 25 12 89 44 26 c7 1f 01 68 eb 29 9e 6e 12 ba 00 00 00 00 49 45 4e 44 ae 42 60 82 E.U%..D&...h.).n......IEND.B`.
='#n170'>170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
--Minetest
--Copyright (C) 2015 PilzAdam
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

local FILENAME = "settingtypes.txt"

local CHAR_CLASSES = {
	SPACE = "[%s]",
	VARIABLE = "[%w_%-%.]",
	INTEGER = "[+-]?[%d]",
	FLOAT = "[+-]?[%d%.]",
	FLAGS = "[%w_%-%.,]",
}

-- returns error message, or nil
local function parse_setting_line(settings, line, read_all, base_level, allow_secure)
	-- comment
	local comment = line:match("^#" .. CHAR_CLASSES.SPACE .. "*(.*)$")
	if comment then
		if settings.current_comment == "" then
			settings.current_comment = comment
		else
			settings.current_comment = settings.current_comment .. "\n" .. comment
		end
		return
	end

	-- clear current_comment so only comments directly above a setting are bound to it
	-- but keep a local reference to it for variables in the current line
	local current_comment = settings.current_comment
	settings.current_comment = ""

	-- empty lines
	if line:match("^" .. CHAR_CLASSES.SPACE .. "*$") then
		return
	end

	-- category
	local stars, category = line:match("^%[([%*]*)([^%]]+)%]$")
	if category then
		table.insert(settings, {
			name = category,
			level = stars:len() + base_level,
			type = "category",
		})
		return
	end

	-- settings
	local first_part, name, readable_name, setting_type = line:match("^"
			-- this first capture group matches the whole first part,
			--  so we can later strip it from the rest of the line
			.. "("
				.. "([" .. CHAR_CLASSES.VARIABLE .. "+)" -- variable name
				.. CHAR_CLASSES.SPACE .. "*"
				.. "%(([^%)]*)%)"  -- readable name
				.. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.VARIABLE .. "+)" -- type
				.. CHAR_CLASSES.SPACE .. "*"
			.. ")")

	if not first_part then
		return "Invalid line"
	end

	if name:match("secure%.[.]*") and not allow_secure then
		return "Tried to add \"secure.\" setting"
	end

	if readable_name == "" then
		readable_name = nil
	end
	local remaining_line = line:sub(first_part:len() + 1)

	if setting_type == "int" then
		local default, min, max = remaining_line:match("^"
				-- first int is required, the last 2 are optional
				.. "(" .. CHAR_CLASSES.INTEGER .. "+)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.INTEGER .. "*)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.INTEGER .. "*)"
				.. "$")

		if not default or not tonumber(default) then
			return "Invalid integer setting"
		end

		min = tonumber(min)
		max = tonumber(max)
		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "int",
			default = default,
			min = min,
			max = max,
			comment = current_comment,
		})
		return
	end

	if setting_type == "string" or setting_type == "noise_params"
			or setting_type == "key" or setting_type == "v3f" then
		local default = remaining_line:match("^(.*)$")

		if not default then
			return "Invalid string setting"
		end
		if setting_type == "key" and not read_all then
			-- ignore key type if read_all is false
			return
		end

		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = setting_type,
			default = default,
			comment = current_comment,
		})
		return
	end

	if setting_type == "bool" then
		if remaining_line ~= "false" and remaining_line ~= "true" then
			return "Invalid boolean setting"
		end

		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "bool",
			default = remaining_line,
			comment = current_comment,
		})
		return
	end

	if setting_type == "float" then
		local default, min, max = remaining_line:match("^"
				-- first float is required, the last 2 are optional
				.. "(" .. CHAR_CLASSES.FLOAT .. "+)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.FLOAT .. "*)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.FLOAT .. "*)"
				.."$")

		if not default or not tonumber(default) then
			return "Invalid float setting"
		end

		min = tonumber(min)
		max = tonumber(max)
		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "float",
			default = default,
			min = min,
			max = max,
			comment = current_comment,
		})
		return
	end

	if setting_type == "enum" then
		local default, values = remaining_line:match("^"
				-- first value (default) may be empty (i.e. is optional)
				.. "(" .. CHAR_CLASSES.VARIABLE .. "*)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.FLAGS .. "+)"
				.. "$")

		if not default or values == "" then
			return "Invalid enum setting"
		end

		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "enum",
			default = default,
			values = values:split(",", true),
			comment = current_comment,
		})
		return
	end

	if setting_type == "path" then
		local default = remaining_line:match("^(.*)$")

		if not default then
			return "Invalid path setting"
		end

		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "path",
			default = default,
			comment = current_comment,
		})
		return
	end

	if setting_type == "flags" then
		local default, possible = remaining_line:match("^"
				-- first value (default) may be empty (i.e. is optional)
				-- this is implemented by making the last value optional, and
				-- swapping them around if it turns out empty.
				.. "(" .. CHAR_CLASSES.FLAGS .. "+)" .. CHAR_CLASSES.SPACE .. "*"
				.. "(" .. CHAR_CLASSES.FLAGS .. "*)"
				.. "$")

		if not default or not possible then
			return "Invalid flags setting"
		end

		if possible == "" then
			possible = default
			default = ""
		end

		table.insert(settings, {
			name = name,
			readable_name = readable_name,
			type = "flags",
			default = default,
			possible = possible,