From 79069687e7f398985aa6c3df2f0736ade6e4badb Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 8 Jul 1996 07:25:19 +0000 Subject: [PATCH] Corretto caricamento colori da file di configurazione git-svn-id: svn://10.65.10.50/trunk@3144 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/config.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/include/config.cpp b/include/config.cpp index 6abe73cd1..807fdf03e 100755 --- a/include/config.cpp +++ b/include/config.cpp @@ -121,12 +121,11 @@ void TConfig::_write_file() out.close(); in.close(); - while (access(_file, 02) != 0) - message_box("Il file %s e' gia' in uso", (const char*)_file); - /* - TFilename bak(_file); bak.ext("bak"); - rename(_file, bak); - */ + if (fexist(_file)) + { + while (access(_file, 02) != 0) + message_box("Il file %s e' gia' in uso", (const char*)_file); + } fcopy(temp, _file); // Copia dalla tempdir al nuovo .ini remove(temp); // Cancella file temporaneo } @@ -369,7 +368,26 @@ COLOR TConfig::get_color( int r, g, b; RGB_COLOR(def, r, g, b); TString16 d; d << r << ',' << g << ',' << b; set(var, d, section, TRUE, index); - } + } + + // Se nel colore non compare l'indice cerca di calcolarlo + const byte color_index = byte(def >> 12); + if (color_index < 0x1 || color_index > 0xF) + { + const COLOR native_color[11] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_CYAN, + COLOR_MAGENTA, COLOR_YELLOW, COLOR_BLACK, COLOR_DKGRAY, + COLOR_GRAY, COLOR_LTGRAY, COLOR_WHITE }; + + for (int c = 0; c < 11; c++) + { + if (def == (native_color[c] & 0x00FFFFFF)) // Confronta solo la terna R,G,B + { + def = native_color[c]; + break; + } + } + } + return def; }