/* -------------------------------------------------------------------------- * * Speichert alle Konfigurationsdaten aus den Widgets von ui_config * * -------------------------------------------------------------------------- */ void ui_config_card_save(void) { ini_section(client_ini, "card"); /* Farbe und Transparenz speichern */ ini_puthsv(client_ini, "color", sgGetColorSelHSV(ui_config_card_hue)); ini_putulong(client_ini, "alpha", card_tint.a); /* Effekte */ ini_putdouble(client_ini, "zoom", card_config.zoom); ini_putlong(client_ini, "border", card_config.border); }
/* -------------------------------------------------------------------------- * * Liest Benutzeridentifikation aus der client.ini * * Gibt 1 zurück falls der Videomodus geändert wurde * * -------------------------------------------------------------------------- */ int client_configure(void) { int width, height, depth, fullscreen, contrast; const char *pattern, *cursor; sgHSV hsv; char *user, *pass, *info; ini_section(client_ini, "client"); width = ini_getulong_default(client_ini, "width", CLIENT_DEFAULT_WIDTH); height = ini_getulong_default(client_ini, "height", CLIENT_DEFAULT_HEIGHT); depth = ini_getulong_default(client_ini, "depth", CLIENT_DEFAULT_DEPTH); fullscreen = ini_getulong_default(client_ini, "fullscreen", CLIENT_DEFAULT_FULLSCREEN); hsv = ini_gethsv_default(client_ini, "bgcolor", CLIENT_DEFAULT_BGCOLOR); hsv.a = 255; pattern = ini_gets_default(client_ini, "pattern", CLIENT_DEFAULT_PATTERN); contrast = ini_getlong_default(client_ini, "contrast", CLIENT_DEFAULT_CONTRAST); cursor = ini_gets_default(client_ini, "cursor", CLIENT_DEFAULT_CURSOR); client_config.font[0] = ini_gets_default(client_ini, "font[0]", CLIENT_DEFAULT_FONT0); client_config.font[1] = ini_gets_default(client_ini, "font[1]", CLIENT_DEFAULT_FONT1); client_config.font[2] = ini_gets_default(client_ini, "font[2]", CLIENT_DEFAULT_FONT2); client_config.version = ini_gets_default(client_ini, "version", VERSION); user = ini_gets_default(client_ini, "user", CLIENT_DEFAULT_USER); pass = ini_gets_default(client_ini, "pass", CLIENT_DEFAULT_PASS); info = ini_gets_default(client_ini, "info", CLIENT_DEFAULT_INFO); client_strlcpy(client_config.user, user, sizeof(client_config.user)); client_strlcpy(client_config.pass, pass, sizeof(client_config.pass)); client_strlcpy(client_config.info, info, sizeof(client_config.info)); client_strlcpy(client_config.info, info, sizeof(client_config.info)); if(*(Uint32 *)&hsv != *(Uint32 *)&client_config.bgcolor || client_config.contrast != contrast || (client_config.cursor != cursor) || (client_config.pattern != pattern)) { client_config.cursor = cursor; client_config.bgcolor = hsv; client_config.pattern = pattern; client_config.contrast = contrast; client_setlook(); } if(width != client_config.width || height != client_config.height || depth != client_config.depth || fullscreen != client_config.fullscreen) { client_config.width = width; client_config.height = height; client_config.depth = depth; client_config.fullscreen = fullscreen; client_setmode(); return 1; } return 0; }
static void merc_ini_load(void) { char *value; int i; ini_t *ini = ini_load(INI_NAME); if (!ini) { LOG("No "INI_NAME" found."); return; } while (ini_seek_section(ini, NULL)) { int i; char *end; char *section = ini_section(ini); if (strncasecmp(section, "merc", 4) != 0) continue; i = strtoul(§ion[4], &end, 10) - 1; if (!section[4] || *end) continue; if (i < 0 || i >= MERCOPT_MAX) continue; while (ini_seek_setting(ini, NULL)) { char *key = ini_key(ini); char *value = ini_value(ini); if (strcasecmp(key, "class") == 0) { mercopt[i].merc_class = strtoul(value, NULL, 0); } else if (strcasecmp(key, "allow_class") == 0) { int j; int klass[7]; int klasses = merc_parse_array(value, klass, 7); mercopt[i].allow_class = 0; for (j = 0; j < klasses; ++j) mercopt[i].allow_class |= 1 << klass[j]; } else if (strcasecmp(key, "allow_2h") == 0) { mercopt[i].allow_2h = !!strtoul(value, NULL, 0); } else if (strcasecmp(key, "dual") == 0) { mercopt[i].dual_types = merc_parse_array(value, mercopt[i].dual_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "except") == 0) { mercopt[i].except_types = merc_parse_array(value, mercopt[i].except_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "allow") == 0) { mercopt[i].allow_types = merc_parse_array(value, mercopt[i].allow_type, MERCOPT_TYPE_MAX); } else if (strcasecmp(key, "deny") == 0) { mercopt[i].deny_types = merc_parse_array(value, mercopt[i].deny_type, MERCOPT_TYPE_MAX); } /* else, ignore ( option for new version? :-D ) */ } } value = ini_get_setting(ini, "mercmod", "loadmpq"); if (value) { merc_load_image_mpq = !!strtoul(value, NULL, 0); } for (i = 0; i < INVREC_MAX; ++i) { char setting[32]; snprintf(setting, sizeof(setting), "inv%d", i + 1); value = ini_get_setting(ini, "mercmod", setting); if (value) { int j, r; int arr[1 + 6*INVENTORY_REC_ITEM_MAX]; int count = merc_parse_array(value, arr, 1 + 6*INVENTORY_REC_ITEM_MAX); if (count <= 0) continue; invrec_idx[i] = arr[0]; for (j = 1, r = 0; j <= (count-6); j += 6) { invrec[i][r].left = arr[j]; invrec[i][r].right = arr[j+1]; invrec[i][r].top = arr[j+2]; invrec[i][r].bottom = arr[j+3]; invrec[i][r].w = arr[j+4]; invrec[i][r].h = arr[j+5]; } } } ini_free(ini); }