Skip to content
Snippets Groups Projects
Commit 834c21eb authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Allow SCFG ciolib and uifc parameters to be read from ctrl/scfg.ini

If a sysop wants to override the default user interface/console I/O library
behavior of SCFG without using command-line arguments, they can create a
ctrl/scfg.ini file with the following optional [section] keys:

[uifc]
mode (advanced uses, e.g. disabling mouse support)
height (in lines)
insert (keyboard insert mode, not overwrite)
esc_delay (ESC-key delay)

[ciolib]
mode (advanced uses)
scaling (fractional values, e.g. 1.5, supported)
height (in pixels)
width (in pixels)

Command-line arguments take precedence over scfg.ini settings (if set).

The scfg.ini file is read *before* parsing command-line args, so if a ctrl
directory is specified on the command-line (e.g. rather than via environment
variable), the scfg.ini file won't be read from that specified location but
rather the default (/sbbs/ctrl) or the SBBSCTRL env var value.

Another attempt to make Nelgin happy and close out issue #749, though no, this
doesn't auto-save the current parameters (you'll have to create/edit the
scfg.ini file by hand).
parent 22f52e3f
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6414 passed
......@@ -411,6 +411,27 @@ void banner()
printf("\nCompiled %s/%s %s %s with %s\n", GIT_BRANCH, GIT_HASH, __DATE__, __TIME__, compiler);
}
void read_scfg_ini()
{
char path[MAX_PATH + 1];
snprintf(path, sizeof path, "%s/scfg.ini", cfg.ctrl_dir);
FILE* fp = iniOpenFile(path, /* update: */false);
uifc.mode = iniReadInteger(fp, "uifc", "mode", uifc.mode);
uifc.scrn_len = iniReadInteger(fp, "uifc", "height", uifc.scrn_len);
uifc.insert_mode = iniReadBool(fp, "uifc", "insert", uifc.insert_mode);
uifc.esc_delay = iniReadInteger(fp, "uifc", "esc_delay", uifc.esc_delay);
ciolib_initial_mode = iniReadInteger(fp, "ciolib", "mode", ciolib_initial_mode);
ciolib_initial_scaling = iniReadFloat(fp, "ciolib", "scaling", ciolib_initial_scaling);
ciolib_initial_window_height = iniReadInteger(fp, "ciolib", "height", ciolib_initial_window_height);
ciolib_initial_window_width = iniReadInteger(fp, "ciolib", "width", ciolib_initial_window_width);
if (fp != NULL)
iniCloseFile(fp);
}
int main(int argc, char **argv)
{
char* p;
......@@ -433,6 +454,8 @@ int main(int argc, char **argv)
memset(&uifc,0,sizeof(uifc));
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir(/* warn: */true));
read_scfg_ini();
uifc.esc_delay=25;
const char* import = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment