diff --git a/library/Core.cpp b/library/Core.cpp index 96fd3903f..15c7064c8 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -811,13 +811,23 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent) } } +static void run_dfhack_init(color_ostream &out, Core *core) +{ + if (!core->loadScriptFile(out, "dfhack.init", true)) + { + core->runCommand(out, "gui/no-dfhack-init"); + core->loadScriptFile(out, "dfhack.init-example", true); + } +} + // Load dfhack.init in a dedicated thread (non-interactive console mode) void fInitthread(void * iodata) { IODATA * iod = ((IODATA*) iodata); Core * core = iod->core; color_ostream_proxy out(core->getConsole()); - core->loadScriptFile(out, "dfhack.init", true); + + run_dfhack_init(out, core); } // A thread function... for the interactive console. @@ -837,7 +847,7 @@ void fIOthread(void * iodata) return; } - core->loadScriptFile(con, "dfhack.init", true); + run_dfhack_init(con, core); con.print("DFHack is ready. Have a nice day!\n" "Type in '?' or 'help' for general help, 'ls' to see all commands.\n"); diff --git a/scripts/gui/no-dfhack-init.lua b/scripts/gui/no-dfhack-init.lua new file mode 100644 index 000000000..f6171d5c7 --- /dev/null +++ b/scripts/gui/no-dfhack-init.lua @@ -0,0 +1,31 @@ +-- Shows the warning about missing configuration file. + +local gui = require 'gui' +local dlg = require 'gui.dialogs' + +local dfhack_init = { text = 'dfhack.init', pen = COLOR_LIGHTCYAN } +local dfhack_init_example = { text = 'dfhack.init-example', pen = COLOR_LIGHTCYAN } + +local message = { + 'The ', dfhack_init, ' configuration file is missing. To customize', NEWLINE, + 'your DFHack installation, rename the ', dfhack_init_example, ' file', NEWLINE, + 'to ', dfhack_init, ' and edit it to suit your needs.', NEWLINE, NEWLINE, + 'For now, ', dfhack_init_example, ' will be used instead.' +} + +dfhack.print('\n') + +for k,v in ipairs(message) do + if type(v) == 'table' then + dfhack.color(v.pen) + dfhack.print(v.text) + else + dfhack.color(COLOR_YELLOW) + dfhack.print(v) + end +end + +dfhack.color(COLOR_RESET) +dfhack.print('\n\n') + +dlg.showMessage('DFHack is not configured', message, COLOR_YELLOW)