aboutsummaryrefslogtreecommitdiff
path: root/textures/base/pack/minimap_btn.png
blob: 727ba1e9d3e8bec8f6dc265d0d5dec5b863fce87 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 80 00 00 00 80 08 04 00 00 00 69 37 a9 .PNG........IHDR.............i7.
0020 40 00 00 00 02 73 42 49 54 08 08 55 ec 46 04 00 00 00 09 70 48 59 73 00 00 03 b1 00 00 03 b1 01 @....sBIT..U.F.....pHYs.........
0040 f5 83 ed 49 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 61 70 ...I....tEXtSoftware.www.inkscap
0060 65 2e 6f 72 67 9b ee 3c 1a 00 00 04 43 49 44 41 54 78 da ed 9c 5d 88 54 65 18 c7 9f dd b5 0f b1 e.org..<....CIDATx...].Te.......
0080 58 91 ed 43 2a 18 56 68 d9 35 d4 b0 8b 3e 34 0a 16 bb e8 1b 14 09 0d 2f 84 01 77 c1 a5 0f 58 96 X..C*.Vh.5...>4......../..w...X.
00a0 12 b6 82 18 89 2e 44 62 59 89 02 a1 45 e6 22 10 89 28 03 69 0b 29 32 51 71 d3 d1 4a 92 d2 b5 4c ......DbY...E."..(.i.)2Qq..J...L
00c0 4a 77 1b b5 dd fd 75 b1 c7 f5 cc ce 79 cf 9c 99 66 e6 9c 8b ff 6f ae 06 ce 79 9f f7 f9 9d 39 ef Jw....u.....y...f....o...y....9.
00e0 39 73 f1 fe cd 84 10 42 08 21 84 10 42 08 21 84 10 42 04 c3 7a be 64 98 97 98 5f f3 4a 2d 6c 67 9s.....B.!..B.!..B..z.d..._.J-lg
0100 94 f3 7c c0 cd 49 6a ff 1a e3 ec 60 69 8d aa 34 f2 04 59 ae ce d4 1a 63 2b a9 64 08 18 a6 90 61 ..|..Ij....`i..4..Y....c+.d....a
0120 d6 72 43 55 2b a4 78 83 d3 14 33 c9 6e 56 d1 10 b7 80 91 80 a9 9d 25 c3 3d 55 18 fb 26 d6 b0 87 .rCU+.x...3.nV........%.=U..&...
0140 09 c2 c8 d1 43 73 d2 04 00 4c b0 87 ce ca af 0f 1d 64 f8 83 68 e4 d9 c9 92 a4 09 98 e6 30 69 e6 ....Cs...L.......d..h........0i.
0160 95 39 e2 7c ba 38 40 f9 ec 63 35 73 92 26 00 e0 6f 06 e9 88 38 da 72 06 19 a3 72 ce 92 e1 ee b8 .9.|.8@..c5s.&..o...8.r...r.....
0180 04 9c e6 1d fe 74 4c 6c 92 4f 79 92 c6 90 71 ee e2 35 7e 0c 69 ed 08 5b f8 c7 37 de fb be 6f 85 .....tLl.Oy...q..5~.i..[..7...o.
01a0 5c 61 88 87 e3 10 30 e2 2d 5b fb 9d 4d fc 44 2f 2d 45 23 34 d1 49 96 7f 9d 67 5d 64 88 a7 48 91 \a....0.-[..M.D/-E#4.I...g]d..H.
01c0 f2 fd 36 26 cc 68 26 cd 0f ce b3 0e 96 7f f3 55 41 80 ef 87 9c 77 4c ec 32 59 1e 9a 39 b2 8d 0c ..6&.h&........UA....wL.2Y..9...
01e0 a3 ce 26 26 f9 8e 3e da 49 79 9f 02 01 de fb 41 27 59 e7 73 e2 2f 06 69 8f 41 80 99 19 77 d0 cb ..&&..>.Iy.....A'Y.s./.i.A...w..
0200 2f ce d6 0e d0 cd 3a f6 32 e5 3c 62 94 01 1e 9d 69 dd 21 c0 ab b5 88 0c e7 9d 12 f7 b2 86 a6 ba /.....:.2.<b....i.!.............
0220 0b 30 33 63 0e ab d9 57 f6 42 76 95 4f d8 40 eb ac e6 43 04 98 99 31 8f 34 87 9d 63 9e 64 6d 0c .03c...W.Bv.O.@...C...1.4..c.dm.
0240 02 bc 23 ee 63 80 4b 11 9b cf f1 26 f7 07 b4 5e 52 80 57 6b 25 bb 7c 2f cc 85 ac 8f 49 80 99 19 ..#.c.K....&...^R.Wk%.|/....I...
0260 cd f4 90 0b 6d fd 12 43 3c e7 6c 3d a2 00 33 33 16 d2 cf 99 80 0a c3 31 0a f0 8e 5d e1 58 ed 8f ....m..C<.l=..33.......1...].X..
0280 d0 47 47 89 e6 23 0b f0 9e 2c 4f 17 ad 30 23 b1 0b f0 fe da 6c f5 4d 6c 82 01 1e 8f d0 7a 99 02 .GG..#...,O..0#.....l.Ml.....z..
02a0 bc 5a 4b d9 c1 95 84 09 30 33 f3 3d b6 c6 22 37 5f 81 80 4a e7 27 01 12 20 01 12 20 01 12 20 01 .ZK.....03.=.."7_..J.'..........
02c0 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 ................................
02e0 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 20 01 12 ................................
0300 20 01 12 50 1f 01 e3 c9 16 30 ce 5b d1 f6 ee 57 20 60 19 7d 1c f3 ed 01 9c 8a 9a 5a 53 4f 01 d3 ...P.....0.[...W.`.}.......ZSO..
0320 5b 95 23 04 67 94 25 60 11 1b f9 2c 70 bb 65 9e 9d a5 53 6b 6a 2f 20 28 2d e0 28 9b b8 a5 0a 02 [.#.g.%`...,p.e...Skj/.(-.(.....
0340 1e e3 bd 90 cd f5 91 52 6b 6a 2f a0 cb b9 77 7f 1b 6d 15 0b 68 e7 65 be 0d d9 5c 5f c8 19 fa 59 .......Rkj/...w..m..h.e...\_...Y
0360 18 97 80 06 36 3b d3 5e a6 f8 9c 67 8b f7 ee 97 10 f0 0c 1f 71 b1 82 4d f7 bb 58 19 83 00 33 2f ....6;.^...g........q..M..X...3/
0380 38 e3 6b e7 d4 7e a3 9f db 22 09 58 42 1f 47 43 37 d7 f7 d3 4e 3a 24 b8 e5 18 3d 85 c1 19 75 11 8.k..~...".XB.GC7...N:$...=...u.
03a0 e0 95 5a ce a0 33 d8 e4 32 59 1e 09 11 d0 ca 3a 3e 76 c6 6e 40 9e ec f5 c5 b5 44 70 46 41 6a 4d ..Z..3..2Y.....:>v.n@.....DpFAjM
03c0 1d 05 98 99 71 3b bd 9c 0a 09 ce 48 33 b7 48 c0 83 64 02 a3 b2 ae 9f d5 c3 82 80 5a ad 21 51 4b ....q;.....H3.H..d.........Z.!QK
03e0 53 d7 82 33 ea 2c c0 cc 8c 26 9e e7 0b e7 02 76 8e b7 99 f4 dd b9 5f f9 be cd e6 77 de 65 71 68 S..3.,...&.....v......_....w.eqh
0400 ad b9 6c e4 60 48 6a cd ab fc 5c 77 01 de d4 ee 25 c3 85 8a 03 91 a6 a3 4f 6e 2c e3 e6 cb 97 1c ..l.`Hj...\w....%.......On,.....
0420 b3 be 02 cc cc b8 95 ee 90 a4 1f f7 75 7b bd fc 34 28 ee 64 0b bf 26 4c 80 37 b5 15 a1 31 49 b3 ............u{..4(.d..&L.7...1I.
0440 97 ca ff 13 c0 d6 18 10 9c 11 bf 00 33 2f d8 e4 5c 68 f3 df d3 5d 9d 4c 4a da d8 16 98 5a 13 a7 ............3/..\h...].LJ....Z..
0460 00 ef 6d e1 45 be 09 98 d8 05 b6 b3 ac ca b5 9a d9 cc f1 59 75 f6 5b 12 e0 01 3e f4 05 9b 1c e2 ..m.E..............Yu.[...>.....
0480 85 5a e5 83 d2 c0 2a 76 fb 1e b9 5d 96 14 68 21 c3 29 72 6c aa 43 ad 14 19 4e 90 e3 95 d8 c3 37 .Z....*v...]..h!.)rl.C...N.....7
04a0 85 10 42 08 21 84 10 42 08 21 84 10 22 a9 fc 07 a7 98 5a 71 4c 8e 8a 4b 00 00 00 00 49 45 4e 44 ..B.!..B.!..".....ZqL..K....IEND
04c0 ae 42 60 82 .B`.
='#n271'>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 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

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.
*/


#include "guiTable.h"
#include <queue>
#include <sstream>
#include <utility>
#include <string.h>
#include <IGUISkin.h>
#include <IGUIFont.h>
#include <IGUIScrollBar.h>
#include "debug.h"
#include "log.h"
#include "client/tile.h"
#include "gettime.h"
#include "util/string.h"
#include "util/numeric.h"
#include "util/string.h" // for parseColorString()
#include "settings.h" // for settings
#include "porting.h" // for dpi
#include "guiscalingfilter.h"

/*
	GUITable
*/

GUITable::GUITable(gui::IGUIEnvironment *env,
		gui::IGUIElement* parent, s32 id,
		core::rect<s32> rectangle,
		ISimpleTextureSource *tsrc
):
	gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle),
	m_tsrc(tsrc),
	m_is_textlist(false),
	m_has_tree_column(false),
	m_selected(-1),
	m_sel_column(0),
	m_sel_doubleclick(false),
	m_keynav_time(0),
	m_keynav_buffer(L""),
	m_border(true),
	m_color(255, 255, 255, 255),
	m_background(255, 0, 0, 0),
	m_highlight(255, 70, 100, 50),
	m_highlight_text(255, 255, 255, 255),
	m_rowheight(1),
	m_font(NULL),
	m_scrollbar(NULL)
{
	assert(tsrc != NULL);

	gui::IGUISkin* skin = Environment->getSkin();

	m_font = skin->getFont();
	if (m_font) {
		m_font->grab();
		m_rowheight = m_font->getDimension(L"A").Height + 4;
		m_rowheight = MYMAX(m_rowheight, 1);
	}

	const s32 s = skin->getSize(gui::EGDS_SCROLLBAR_SIZE);
	m_scrollbar = Environment->addScrollBar(false,
			core::rect<s32>(RelativeRect.getWidth() - s,
					0,
					RelativeRect.getWidth(),
					RelativeRect.getHeight()),
			this, -1);
	m_scrollbar->setSubElement(true);
	m_scrollbar->setTabStop(false);
	m_scrollbar->setAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_LOWERRIGHT,
			gui::EGUIA_UPPERLEFT, gui::EGUIA_LOWERRIGHT);
	m_scrollbar->setVisible(false);
	m_scrollbar->setPos(0);

	setTabStop(true);
	setTabOrder(-1);
	updateAbsolutePosition();

	core::rect<s32> relative_rect = m_scrollbar->getRelativePosition();
	s32 width = (relative_rect.getWidth()/(2.0/3.0)) * porting::getDisplayDensity() *
			g_settings->getFloat("gui_scaling");
	m_scrollbar->setRelativePosition(core::rect<s32>(
			relative_rect.LowerRightCorner.X-width,relative_rect.UpperLeftCorner.Y,
			relative_rect.LowerRightCorner.X,relative_rect.LowerRightCorner.Y
			));
}

GUITable::~GUITable()
{
	for (size_t i = 0; i < m_rows.size(); ++i)
		delete[] m_rows[i].cells;

	if (m_font)
		m_font->drop();
	
	m_scrollbar->remove();
}

GUITable::Option GUITable::splitOption(const std::string &str)
{
	size_t equal_pos = str.find('=');
	if (equal_pos == std::string::npos)
		return GUITable::Option(str, "");
	else
		return GUITable::Option(str.substr(0, equal_pos),
				str.substr(equal_pos + 1));
}

void GUITable::setTextList(const std::vector<std::string> &content,
		bool transparent)
{
	clear();

	if (transparent) {
		m_background.setAlpha(0);
		m_border = false;
	}

	m_is_textlist = true;

	s32 empty_string_index = allocString("");

	m_rows.resize(content.size());
	for (s32 i = 0; i < (s32) content.size(); ++i) {
		Row *row = &m_rows[i];
		row->cells = new Cell[1];
		row->cellcount = 1;
		row->indent = 0;
		row->visible_index = i;
		m_visible_rows.push_back(i);

		Cell *cell = row->cells;
		cell->xmin = 0;
		cell->xmax = 0x7fff;  // something large enough
		cell->xpos = 6;
		cell->content_type = COLUMN_TYPE_TEXT;
		cell->content_index = empty_string_index;
		cell->tooltip_index = empty_string_index;
		cell->color.set(255, 255, 255, 255);
		cell->color_defined = false;
		cell->reported_column = 1;

		// parse row content (color)
		const std::string &s = content[i];
		if (s[0] == '#' && s[1] == '#') {
			// double # to escape
			cell->content_index = allocString(s.substr(2));
		}
		else if (s[0] == '#' && s.size() >= 7 &&
				parseColorString(
					s.substr(0,7), cell->color, false)) {
			// single # for color
			cell->color_defined = true;
			cell->content_index = allocString(s.substr(7));
		}
		else {
			// no #, just text
			cell->content_index = allocString(s);
		}

	}

	allocationComplete();

	// Clamp scroll bar position
	updateScrollBar();
}

void GUITable::setTable(const TableOptions &options,
		const TableColumns &columns,
		std::vector<std::string> &content)
{
	clear();

	// Naming conventions:
	// i is always a row index, 0-based
	// j is always a column index, 0-based
	// k is another index, for example an option index

	// Handle a stupid error case... (issue #1187)
	if (columns.empty()) {
		TableColumn text_column;
		text_column.type = "text";
		TableColumns new_columns;
		new_columns.push_back(text_column);
		setTable(options, new_columns, content);
		return;
	}

	// Handle table options
	video::SColor default_color(255, 255, 255, 255);
	s32 opendepth = 0;
	for (size_t k = 0; k < options.size(); ++k) {
		const std::string &name = options[k].name;
		const std::string &value = options[k].value;
		if (name == "color")
			parseColorString(value, m_color, false);
		else if (name == "background")
			parseColorString(value, m_background, false);
		else if (name == "border")
			m_border = is_yes(value);
		else if (name == "highlight")
			parseColorString(value, m_highlight, false);
		else if (name == "highlight_text")
			parseColorString(value, m_highlight_text, false);
		else if (name == "opendepth")
			opendepth = stoi(value);
		else
			errorstream<<"Invalid table option: \""<<name<<"\""
				<<" (value=\""<<value<<"\")"<<std::endl;
	}

	// Get number of columns and rows
	// note: error case columns.size() == 0 was handled above
	s32 colcount = columns.size();
	assert(colcount >= 1);
	// rowcount = ceil(cellcount / colcount) but use integer arithmetic
	s32 rowcount = (content.size() + colcount - 1) / colcount;
	assert(rowcount >= 0);
	// Append empty strings to content if there is an incomplete row
	s32 cellcount = rowcount * colcount;
	while (content.size() < (u32) cellcount)
		content.push_back("");

	// Create temporary rows (for processing columns)
	struct TempRow {
		// Current horizontal position (may different between rows due
		// to indent/tree columns, or text/image columns with width<0)
		s32 x;
		// Tree indentation level
		s32 indent;
		// Next cell: Index into m_strings or m_images
		s32 content_index;
		// Next cell: Width in pixels
		s32 content_width;
		// Vector of completed cells in this row
		std::vector<Cell> cells;
		// Stores colors and how long they last (maximum column index)
		std::vector<std::pair<video::SColor, s32> > colors;

		TempRow(): x(0), indent(0), content_index(0), content_width(0) {}
	};
	TempRow *rows = new TempRow[rowcount];

	// Get em width. Pedantically speaking, the width of "M" is not
	// necessarily the same as the em width, but whatever, close enough.
	s32 em = 6;
	if (m_font)
		em = m_font->getDimension(L"M").Width;

	s32 default_tooltip_index = allocString("");

	std::map<s32, s32> active_image_indices;

	// Process content in column-major order
	for (s32 j = 0; j < colcount; ++j) {
		// Check column type
		ColumnType columntype = COLUMN_TYPE_TEXT;
		if (columns[j].type == "text")
			columntype = COLUMN_TYPE_TEXT;
		else if (columns[j].type == "image")
			columntype = COLUMN_TYPE_IMAGE;
		else if (columns[j].type == "color")
			columntype = COLUMN_TYPE_COLOR;
		else if (columns[j].type == "indent")
			columntype = COLUMN_TYPE_INDENT;
		else if (columns[j].type == "tree")
			columntype = COLUMN_TYPE_TREE;
		else
			errorstream<<"Invalid table column type: \""
				<<columns[j].type<<"\""<<std::endl;

		// Process column options
		s32 padding = myround(0.5 * em);
		s32 tooltip_index = default_tooltip_index;
		s32 align = 0;
		s32 width = 0;
		s32 span = colcount;

		if (columntype == COLUMN_TYPE_INDENT) {
			padding = 0; // default indent padding
		}
		if (columntype == COLUMN_TYPE_INDENT ||
				columntype == COLUMN_TYPE_TREE) {
			width = myround(em * 1.5); // default indent width
		}

		for (size_t k = 0; k < columns[j].options.size(); ++k) {
			const std::string &name = columns[j].options[k].name;
			const std::string &value = columns[j].options[k].value;
			if (name == "padding")
				padding = myround(stof(value) * em);
			else if (name == "tooltip")
				tooltip_index = allocString(value);
			else if (name == "align" && value == "left")
				align = 0;
			else if (name == "align" && value == "center")
				align = 1;
			else if (name == "align" && value == "right")
				align = 2;
			else if (name == "align" && value == "inline")
				align = 3;
			else if (name == "width")
				width = myround(stof(value) * em);
			else if (name == "span" && columntype == COLUMN_TYPE_COLOR)
				span = stoi(value);
			else if (columntype == COLUMN_TYPE_IMAGE &&
					!name.empty() &&
					string_allowed(name, "0123456789")) {
				s32 content_index = allocImage(value);
				active_image_indices.insert(std::make_pair(
							stoi(name),
							content_index));
			}
			else {
				errorstream<<"Invalid table column option: \""<<name<<"\""
					<<" (value=\""<<value<<"\")"<<std::endl;
			}
		}

		// If current column type can use information from "color" columns,
		// find out which of those is currently active
		if (columntype == COLUMN_TYPE_TEXT) {
			for (s32 i = 0; i < rowcount; ++i) {
				TempRow *row = &rows[i];
				while (!row->colors.empty() && row->colors.back().second < j)
					row->colors.pop_back();
			}
		}

		// Make template for new cells
		Cell newcell;
		memset(&newcell, 0, sizeof newcell);
		newcell.content_type = columntype;
		newcell.tooltip_index = tooltip_index;
		newcell.reported_column = j+1;

		if (columntype == COLUMN_TYPE_TEXT) {
			// Find right edge of column
			s32 xmax = 0;
			for (s32 i = 0; i < rowcount; ++i) {
				TempRow *row = &rows[i];
				row->content_index = allocString(content[i * colcount + j]);
				const core::stringw &text = m_strings[row->content_index];
				row->content_width = m_font ?
					m_font->getDimension(text.c_str()).Width : 0;
				row->content_width = MYMAX(row->content_width, width);
				s32 row_xmax = row->x + padding + row->content_width;
				xmax = MYMAX(xmax, row_xmax);
			}
			// Add a new cell (of text type) to each row
			for (s32 i = 0; i < rowcount; ++i) {
				newcell.xmin = rows[i].x + padding;
				alignContent(&newcell, xmax, rows[i].content_width, align);
				newcell.content_index = rows[i].content_index;
				newcell.color_defined = !rows[i].colors.empty();
				if (newcell.color_defined)
					newcell.color = rows[i].colors.back().first;
				rows[i].cells.push_back(newcell);
				rows[i].x = newcell.xmax;
			}
		}
		else if (columntype == COLUMN_TYPE_IMAGE) {
			// Find right edge of column
			s32 xmax = 0;
			for (s32 i = 0; i < rowcount; ++i) {
				TempRow *row = &rows[i];
				row->content_index = -1;

				// Find content_index. Image indices are defined in
				// column options so check active_image_indices.
				s32 image_index = stoi(content[i * colcount + j]);
				std::map<s32, s32>::iterator image_iter =
					active_image_indices.find(image_index);
				if (image_iter != active_image_indices.end())
					row->content_index = image_iter->second;

				// Get texture object (might be NULL)
				video::ITexture *image = NULL;
				if (row->content_index >= 0)
					image = m_images[row->content_index];

				// Get content width and update xmax
				row->content_width = image ? image->getOriginalSize().Width : 0;
				row->content_width = MYMAX(row->content_width, width);
				s32 row_xmax = row->x + padding + row->content_width;
				xmax = MYMAX(xmax, row_xmax);
			}
			// Add a new cell (of image type) to each row
			for (s32 i = 0; i < rowcount; ++i) {
				newcell.xmin = rows[i].x + padding;
				alignContent(&newcell, xmax, rows[i].content_width, align);
				newcell.content_index = rows[i].content_index;
				rows[i].cells.push_back(newcell);
				rows[i].x = newcell.xmax;
			}
			active_image_indices.clear();
		}
		else if (columntype == COLUMN_TYPE_COLOR) {
			for (s32 i = 0; i < rowcount; ++i) {
				video::SColor cellcolor(255, 255, 255, 255);
				if (parseColorString(content[i * colcount + j], cellcolor, true))
					rows[i].colors.push_back(std::make_pair(cellcolor, j+span));
			}
		}
		else if (columntype == COLUMN_TYPE_INDENT ||
				columntype == COLUMN_TYPE_TREE) {
			// For column type "tree", reserve additional space for +/-
			// Also enable special processing for treeview-type tables
			s32 content_width = 0;
			if (columntype == COLUMN_TYPE_TREE) {
				content_width = m_font ? m_font->getDimension(L"+").Width : 0;
				m_has_tree_column = true;
			}
			// Add a new cell (of indent or tree type) to each row