changeset 38:658272d883ed

* Support (more or less) button style selects (fuuko's ones) * Strip text objects from strings (may support object text objects later)
author thib
date Tue, 17 Mar 2009 20:35:08 +0000
parents f88d47a4bf87
children de29c4d2d043
files font/text_stream.cc scn2k/scn2k_text.cc
diffstat 2 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/font/text_stream.cc
+++ b/font/text_stream.cc
@@ -90,6 +90,33 @@ void TextStream::Add(const char* str) {
 	TextElem elem;
 	for (; *str; str++) {
 		if (*str >= 0x20) {
+			if (*str == '#') { // Commands
+				str++;
+				char command = (*str)|32;
+				str++;
+				const char *tmp = str;
+				while (isdigit(*str)) {
+					str++;
+				}
+				char *args = new char[str+1-tmp];
+				strncpy(args, tmp, str-tmp);
+				args[str-tmp] = 0;
+				// Different commands:
+				switch(command) {
+					case 'c':
+						/*TODO: int r, g, b; char key[17];
+						sprintf(key, "#COLOR_TABLE.%03d", args);
+						if (config.GetParam(key, 3, &r, &g, &b)) { // color not found
+							r = g = b = 0;
+						}
+						elem.type = TextElem::color;
+						elem.impl.Color.r = r;
+						elem.impl.Color.g = g;
+						elem.impl.Color.b = b;*/
+						break;
+				}
+				delete[] args;
+			}
 			elem.type = TextElem::glyph;
 			elem.impl.Glyph.code = *str;
 		} else if (*str < 0 && str[1] != 0) {
--- a/scn2k/scn2k_text.cc
+++ b/scn2k/scn2k_text.cc
@@ -668,7 +668,8 @@ void TextImpl::CreateSelect(Cmd& cmd) {
 	char key[1024];
 	sprintf(key, "#WINDOW.%03d.SELCOM_USE",text_window_number);
 	int sel_type = 0;
-	config.GetParam(key, 1, &sel_type);
+	if (cmd.cmd3 == 1) config.GetParam(key, 1, &sel_type);
+	else if (cmd.cmd3 == 3) sel_type = 0;
 
 	int sel_size = cmd.args.size() / 2;
 	int i;