| 1101 | | |
|---|
| 1102 | | /* File exists */ |
|---|
| 1103 | | if ((fff) && (!ignore_prefs)) |
|---|
| 1104 | | { |
|---|
| 1105 | | /* Process the file */ |
|---|
| 1106 | | while (file_getl(fff, buf, sizeof(buf))) |
|---|
| 1107 | | { |
|---|
| 1108 | | /* Count lines */ |
|---|
| 1109 | | line++; |
|---|
| 1110 | | |
|---|
| 1111 | | /* Skip "empty" lines, "blank" lines, and comments */ |
|---|
| 1112 | | if (!buf[0]) continue; |
|---|
| 1113 | | if (isspace((unsigned char)buf[0])) continue; |
|---|
| 1114 | | if (buf[0] == '#') continue; |
|---|
| 1115 | | |
|---|
| 1116 | | if (buf[0] == '[') |
|---|
| | 1103 | |
|---|
| | 1104 | /* File doesn't exist */ |
|---|
| | 1105 | if (!fff) return; |
|---|
| | 1106 | |
|---|
| | 1107 | /* Process the file */ |
|---|
| | 1108 | while (file_getl(fff, buf, sizeof(buf))) |
|---|
| | 1109 | { |
|---|
| | 1110 | /* Count lines */ |
|---|
| | 1111 | line++; |
|---|
| | 1112 | |
|---|
| | 1113 | /* Skip "empty" lines, "blank" lines, and comments */ |
|---|
| | 1114 | if (!buf[0]) continue; |
|---|
| | 1115 | if (isspace((unsigned char)buf[0])) continue; |
|---|
| | 1116 | if (buf[0] == '#') continue; |
|---|
| | 1117 | |
|---|
| | 1118 | if (buf[0] == '[') |
|---|
| | 1119 | { |
|---|
| | 1120 | if (prefix(buf, "[General Settings]")) |
|---|
| 1118 | | if (prefix(buf, "[General Settings]")) |
|---|
| 1119 | | { |
|---|
| 1120 | | section = GENERAL_PREFS; |
|---|
| 1121 | | } |
|---|
| 1122 | | else if (prefix(buf,"[Term window")) |
|---|
| 1123 | | { |
|---|
| 1124 | | section = TERM_PREFS; |
|---|
| 1125 | | sscanf(buf, "[Term window %d]", &t); |
|---|
| 1126 | | td = &data[t]; |
|---|
| 1127 | | } |
|---|
| 1128 | | else if (prefix(buf,"[Extra window")) |
|---|
| 1129 | | { |
|---|
| 1130 | | section = XTRA_WIN_PREFS; |
|---|
| 1131 | | sscanf(buf, "[Extra window %d]", &x); |
|---|
| 1132 | | xd = &xdata[x]; |
|---|
| 1133 | | } |
|---|
| | 1122 | section = GENERAL_PREFS; |
|---|
| | 1123 | } |
|---|
| | 1124 | else if (prefix(buf,"[Term window")) |
|---|
| | 1125 | { |
|---|
| | 1126 | section = TERM_PREFS; |
|---|
| | 1127 | sscanf(buf, "[Term window %d]", &t); |
|---|
| | 1128 | td = &data[t]; |
|---|
| | 1129 | } |
|---|
| | 1130 | else if (prefix(buf,"[Extra window")) |
|---|
| | 1131 | { |
|---|
| | 1132 | section = XTRA_WIN_PREFS; |
|---|
| | 1133 | sscanf(buf, "[Extra window %d]", &x); |
|---|
| | 1134 | xd = &xdata[x]; |
|---|
| | 1135 | } |
|---|
| | 1136 | continue; |
|---|
| | 1137 | } |
|---|
| | 1138 | |
|---|
| | 1139 | if (section == GENERAL_PREFS) |
|---|
| | 1140 | { |
|---|
| | 1141 | if (prefix(buf, "Tile set=")) |
|---|
| | 1142 | { |
|---|
| | 1143 | val = get_value(buf); |
|---|
| | 1144 | sscanf(buf, "Tile set=%d", &val); |
|---|
| | 1145 | arg_graphics = val; |
|---|
| 1139 | | if (prefix(buf, "Tile set=")) |
|---|
| | 1150 | val = get_value(buf); |
|---|
| | 1151 | sscanf(buf, "Big Tiles=%d", &val); |
|---|
| | 1152 | use_bigtile = val; |
|---|
| | 1153 | continue; |
|---|
| | 1154 | } |
|---|
| | 1155 | } |
|---|
| | 1156 | |
|---|
| | 1157 | if (section == TERM_PREFS) |
|---|
| | 1158 | { |
|---|
| | 1159 | if (prefix(buf, "visible=")) |
|---|
| | 1160 | { |
|---|
| | 1161 | sscanf(buf, "visible=%d", &val); |
|---|
| | 1162 | td->visible = val; |
|---|
| | 1163 | } |
|---|
| | 1164 | else if (prefix(buf, "font=")) |
|---|
| | 1165 | { |
|---|
| | 1166 | str = my_stristr(buf, "="); |
|---|
| | 1167 | if (str != NULL) |
|---|
| 1154 | | |
|---|
| 1155 | | if (section == TERM_PREFS) |
|---|
| | 1174 | else if (prefix(buf, "x=")) sscanf(buf, "x=%d", &td->location.x); |
|---|
| | 1175 | else if (prefix(buf, "y=")) sscanf(buf, "y=%d",&td->location.y); |
|---|
| | 1176 | else if (prefix(buf, "width=")) sscanf(buf, "width=%d", &td->size.w); |
|---|
| | 1177 | else if (prefix(buf, "height=")) sscanf(buf, "height=%d", &td->size.h); |
|---|
| | 1178 | else if (prefix(buf, "cols=")) sscanf(buf, "cols=%d", &td->cols); |
|---|
| | 1179 | else if (prefix(buf, "rows=")) sscanf(buf, "rows=%d", &td->rows); |
|---|
| | 1180 | else if (prefix(buf, "tile_width=")) sscanf(buf, "tile_width=%d", &td->tile.w); |
|---|
| | 1181 | else if (prefix(buf, "tile_height=")) sscanf(buf, "tile_height=%d", &td->tile.h); |
|---|
| | 1182 | continue; |
|---|
| | 1183 | } |
|---|
| | 1184 | |
|---|
| | 1185 | if (section == XTRA_WIN_PREFS) |
|---|
| | 1186 | { |
|---|
| | 1187 | if (prefix(buf, "visible=")) |
|---|
| 1162 | | else if (prefix(buf, "font=")) |
|---|
| 1163 | | { |
|---|
| 1164 | | str = my_stristr(buf, "="); |
|---|
| 1165 | | if (str != NULL) |
|---|
| 1166 | | { |
|---|
| 1167 | | if (str[0] == '=') |
|---|
| 1168 | | str++; |
|---|
| 1169 | | my_strcpy(td->font.name, str, strlen(str) + 1); |
|---|
| 1170 | | } |
|---|
| 1171 | | } |
|---|
| 1172 | | else if (prefix(buf, "x=")) sscanf(buf, "x=%d", &td->location.x); |
|---|
| 1173 | | else if (prefix(buf, "y=")) sscanf(buf, "y=%d",&td->location.y); |
|---|
| 1174 | | else if (prefix(buf, "width=")) sscanf(buf, "width=%d", &td->size.w); |
|---|
| 1175 | | else if (prefix(buf, "height=")) sscanf(buf, "height=%d", &td->size.h); |
|---|
| 1176 | | else if (prefix(buf, "cols=")) sscanf(buf, "cols=%d", &td->cols); |
|---|
| 1177 | | else if (prefix(buf, "rows=")) sscanf(buf, "rows=%d", &td->rows); |
|---|
| 1178 | | else if (prefix(buf, "tile_width=")) sscanf(buf, "tile_width=%d", &td->tile.w); |
|---|
| 1179 | | else if (prefix(buf, "tile_height=")) sscanf(buf, "tile_height=%d", &td->tile.h); |
|---|
| 1180 | | continue; |
|---|
| 1182 | | |
|---|
| 1183 | | if (section == XTRA_WIN_PREFS) |
|---|
| 1184 | | { |
|---|
| 1185 | | if (prefix(buf, "visible=")) |
|---|
| 1186 | | { |
|---|
| 1187 | | sscanf(buf, "visible=%d", &val); |
|---|
| 1188 | | xd->visible = val; |
|---|
| 1189 | | } |
|---|
| 1190 | | else if (prefix(buf, "font=")) |
|---|
| 1191 | | { |
|---|
| 1192 | | str = my_stristr(buf, "="); |
|---|
| 1193 | | if (str != NULL) |
|---|
| 1194 | | { |
|---|
| 1195 | | if (str[0] == '=') |
|---|
| 1196 | | str++; |
|---|
| 1197 | | my_strcpy(xd->font.name, str, strlen(str) + 1); |
|---|
| 1198 | | } |
|---|
| 1199 | | } |
|---|
| 1200 | | else if (prefix(buf, "x=")) sscanf(buf, "x=%d", &xd->location.x); |
|---|
| 1201 | | else if (prefix(buf, "y=")) sscanf(buf, "y=%d",&xd->location.y); |
|---|
| 1202 | | else if (prefix(buf, "width=")) sscanf(buf, "width=%d", &xd->size.w); |
|---|
| 1203 | | else if (prefix(buf, "height=")) sscanf(buf, "height=%d", &xd->size.h); |
|---|
| 1204 | | } |
|---|
| 1205 | | } |
|---|
| 1206 | | } |
|---|
| 1207 | | |
|---|
| 1208 | | /* Close the file */ |
|---|
| | 1202 | else if (prefix(buf, "x=")) sscanf(buf, "x=%d", &xd->location.x); |
|---|
| | 1203 | else if (prefix(buf, "y=")) sscanf(buf, "y=%d",&xd->location.y); |
|---|
| | 1204 | else if (prefix(buf, "width=")) sscanf(buf, "width=%d", &xd->size.w); |
|---|
| | 1205 | else if (prefix(buf, "height=")) sscanf(buf, "height=%d", &xd->size.h); |
|---|
| | 1206 | } |
|---|
| | 1207 | } |
|---|
| | 1208 | |
|---|