diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c710d91a..bef01888f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,7 +100,6 @@ jobs: run: | export TERM=dumb status=0 - mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init script -qe -c "python ci/run-tests.py --headless --keep-status \"$DF_FOLDER\"" || status=$((status + 1)) python ci/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" || status=$((status + 2)) mkdir -p artifacts diff --git a/ci/run-tests.py b/ci/run-tests.py index be2a02b3f..a6a35bc76 100755 --- a/ci/run-tests.py +++ b/ci/run-tests.py @@ -68,7 +68,16 @@ init_contents = change_setting(init_contents, 'FPS', 'YES') if args.headless: init_contents = change_setting(init_contents, 'PRINT_MODE', 'TEXT') -test_init_file = 'dfhackzzz_test.init' # Core sorts these alphabetically +init_path = 'dfhack-config/init' +if not os.path.isdir('hack/init'): + # we're on an old branch that still reads init files from the root dir + init_path = '.' +try: + os.mkdir(init_path) +except OSError as error: + # ignore already exists errors + pass +test_init_file = os.path.join(init_path, 'dfhackzzz_test.init') # Core sorts these alphabetically with open(test_init_file, 'w') as f: f.write(''' devel/dump-rpc dfhack-rpc.txt diff --git a/conf.py b/conf.py index 5ec58fc98..71ba65fb7 100644 --- a/conf.py +++ b/conf.py @@ -24,32 +24,40 @@ import sys # -- Support :dfhack-keybind:`command` ------------------------------------ -# this is a custom directive that pulls info from dfhack.init-example +# this is a custom directive that pulls info from default keybindings from docutils import nodes from docutils.parsers.rst import roles sphinx_major_version = sphinx.version_info[0] -def get_keybinds(): +def get_keybinds(root, files, keybindings): + """Add keybindings in the specified files to the + given keybindings dict. + """ + for file in files: + with open(os.path.join(root, file)) as f: + lines = [l.replace('keybinding add', '').strip() for l in f.readlines() + if l.startswith('keybinding add')] + for k in lines: + first, command = k.split(' ', 1) + bind, context = (first.split('@') + [''])[:2] + if ' ' not in command: + command = command.replace('"', '') + tool = command.split(' ')[0].replace('"', '') + keybindings[tool] = keybindings.get(tool, []) + [ + (command, bind.split('-'), context)] + +def get_all_keybinds(root_dir): """Get the implemented keybinds, and return a dict of {tool: [(full_command, keybinding, context), ...]}. """ - with open('dfhack.init-example') as f: - lines = [l.replace('keybinding add', '').strip() for l in f.readlines() - if l.startswith('keybinding add')] keybindings = dict() - for k in lines: - first, command = k.split(' ', 1) - bind, context = (first.split('@') + [''])[:2] - if ' ' not in command: - command = command.replace('"', '') - tool = command.split(' ')[0].replace('"', '') - keybindings[tool] = keybindings.get(tool, []) + [ - (command, bind.split('-'), context)] + for root, _, files in os.walk(root_dir): + get_keybinds(root, files, keybindings) return keybindings -KEYBINDS = get_keybinds() +KEYBINDS = get_all_keybinds('data/init') # pylint:disable=unused-argument,dangerous-default-value,too-many-arguments diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 26befdb34..ea88d4473 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,3 +1,6 @@ +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/init/ + DESTINATION "${DFHACK_DATA_DESTINATION}/init") + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/quickfort/ DESTINATION "${DFHACK_DATA_DESTINATION}/data/quickfort") diff --git a/data/init/dfhack.default.init b/data/init/dfhack.default.init new file mode 100644 index 000000000..78dc70450 --- /dev/null +++ b/data/init/dfhack.default.init @@ -0,0 +1,8 @@ +# Default DFHack commands to run on program init + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/dfhack.init + +script hack/init/dfhack.keybindings.init +script hack/init/dfhack.tools.init diff --git a/dfhack.init-example b/data/init/dfhack.keybindings.init similarity index 60% rename from dfhack.init-example rename to data/init/dfhack.keybindings.init index 88528f650..e32a7c58e 100644 --- a/dfhack.init-example +++ b/data/init/dfhack.keybindings.init @@ -1,3 +1,9 @@ +# Default DFHack keybindings + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/dfhack.init + ############################## # Generic dwarfmode bindings # ############################## @@ -164,137 +170,3 @@ keybinding add Shift-B@pet/List/Unit "gui/autobutcher" # view pathable tiles from active cursor keybinding add Alt-Shift-P@dwarfmode/LookAround gui/pathable - -############################ -# UI and game logic tweaks # -############################ - -# stabilize the cursor of dwarfmode when switching menus -tweak stable-cursor - -# stop stacked liquid/bar/thread/cloth items from lasting forever -# if used in reactions that use only a fraction of the dimension. -# might be fixed by DF -# tweak fix-dimensions - -# make reactions requiring containers usable in advmode - the issue is -# that the screen asks for those reagents to be selected directly -tweak advmode-contained - -# support Shift-Enter in Trade and Move Goods to Depot screens for faster -# selection; it selects the current item or stack and scrolls down one line -tweak fast-trade - -# stop the right list in military->positions from resetting to top all the time -tweak military-stable-assign -# in same list, color units already assigned to squads in brown & green -tweak military-color-assigned - -# make crafted cloth items wear out with time like in old versions (bug 6003) -tweak craft-age-wear - -# stop adamantine clothing from wearing out (bug 6481) -#tweak adamantine-cloth-wear - -# Add "Select all" and "Deselect all" options to farm plot menus -tweak farm-plot-select - -# Add Shift-Left/Right controls to import agreement screen -tweak import-priority-category - -# Fixes a crash in the work order contition material list (bug 9905). -tweak condition-material - -# Adds an option to clear currently-bound hotkeys -tweak hotkey-clear - -# Allows lowercase letters in embark profile names, and allows exiting the name prompt without saving -tweak embark-profile-name - -# Reduce performance impact of temperature changes -tweak fast-heat 100 - -# Misc. UI tweaks -tweak block-labors # Prevents labors that can't be used from being toggled -tweak burrow-name-cancel -tweak cage-butcher -tweak civ-view-agreement -tweak do-job-now -tweak eggs-fertile -tweak fps-min -tweak hide-priority -tweak kitchen-prefs-all -tweak kitchen-prefs-empty -tweak max-wheelbarrow -tweak partial-items -tweak shift-8-scroll -tweak stone-status-all -tweak title-start-rename -tweak tradereq-pet-gender - -########################### -# Globally acting plugins # -########################### - -# Display DFHack version on title screen -enable title-version - -# Dwarf Manipulator (simple in-game Dwarf Therapist replacement) -enable manipulator - -# Search tool in various screens (by falconne) -enable search - -# Improved build material selection interface (by falconne) -enable automaterial - -# Other interface improvement tools -enable \ - confirm \ - dwarfmonitor \ - mousequery \ - autogems \ - autodump \ - automelt \ - autotrade \ - buildingplan \ - resume \ - trackstop \ - zone \ - stocks \ - autochop \ - stockpiles -#end a line with a backslash to make it continue to the next line. The \ is deleted for the final command. -# Multiline commands are ONLY supported for scripts like dfhack.init. You cannot do multiline command manually on the DFHack console. -# You cannot extend a commented line. -# You can comment out the extension of a line. - -# enable mouse controls and sand indicator in embark screen -embark-tools enable sticky sand mouse - -# enable option to enter embark assistant -enable embark-assistant - -########### -# Scripts # -########### - -# write extra information to the gamelog -modtools/extra-gamelog enable - -# extended status screen (bedrooms page) -enable gui/extended-status - -# add information to item viewscreens -view-item-info enable - -# a replacement for the "load game" screen -gui/load-screen enable - -############################## -# Extra DFHack command files # -############################## - -# Create a file named "onLoad.init" to run commands when a world is loaded -# and/or create a file named "onMapLoad.init" to run commands when a map is -# loaded. See the hack/examples/init/ directory for useful pre-made init files. diff --git a/data/init/dfhack.tools.init b/data/init/dfhack.tools.init new file mode 100644 index 000000000..aab17ebbe --- /dev/null +++ b/data/init/dfhack.tools.init @@ -0,0 +1,131 @@ +# Default DFHack tool configuration + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/dfhack.init + +############################ +# UI and game logic tweaks # +############################ + +# stabilize the cursor of dwarfmode when switching menus +tweak stable-cursor + +# stop stacked liquid/bar/thread/cloth items from lasting forever +# if used in reactions that use only a fraction of the dimension. +# might be fixed by DF +# tweak fix-dimensions + +# make reactions requiring containers usable in advmode - the issue is +# that the screen asks for those reagents to be selected directly +tweak advmode-contained + +# support Shift-Enter in Trade and Move Goods to Depot screens for faster +# selection; it selects the current item or stack and scrolls down one line +tweak fast-trade + +# stop the right list in military->positions from resetting to top all the time +tweak military-stable-assign +# in same list, color units already assigned to squads in brown & green +tweak military-color-assigned + +# make crafted cloth items wear out with time like in old versions (bug 6003) +tweak craft-age-wear + +# stop adamantine clothing from wearing out (bug 6481) +#tweak adamantine-cloth-wear + +# Add "Select all" and "Deselect all" options to farm plot menus +tweak farm-plot-select + +# Add Shift-Left/Right controls to import agreement screen +tweak import-priority-category + +# Fixes a crash in the work order contition material list (bug 9905). +tweak condition-material + +# Adds an option to clear currently-bound hotkeys +tweak hotkey-clear + +# Allows lowercase letters in embark profile names, and allows exiting the name prompt without saving +tweak embark-profile-name + +# Reduce performance impact of temperature changes +tweak fast-heat 100 + +# Misc. UI tweaks +tweak block-labors # Prevents labors that can't be used from being toggled +tweak burrow-name-cancel +tweak cage-butcher +tweak civ-view-agreement +tweak do-job-now +tweak eggs-fertile +tweak fps-min +tweak hide-priority +tweak kitchen-prefs-all +tweak kitchen-prefs-empty +tweak max-wheelbarrow +tweak partial-items +tweak shift-8-scroll +tweak stone-status-all +tweak title-start-rename +tweak tradereq-pet-gender + +########################### +# Globally acting plugins # +########################### + +# Display DFHack version on title screen +enable title-version + +# Dwarf Manipulator (simple in-game Dwarf Therapist replacement) +enable manipulator + +# Search tool in various screens (by falconne) +enable search + +# Improved build material selection interface (by falconne) +enable automaterial + +# Other interface improvement tools +enable \ + confirm \ + dwarfmonitor \ + mousequery \ + autogems \ + autodump \ + automelt \ + autotrade \ + buildingplan \ + resume \ + trackstop \ + zone \ + stocks \ + autochop \ + stockpiles +#end a line with a backslash to make it continue to the next line. The \ is deleted for the final command. +# Multiline commands are ONLY supported for scripts like dfhack.init. You cannot do multiline command manually on the DFHack console. +# You cannot extend a commented line. +# You can comment out the extension of a line. + +# enable mouse controls and sand indicator in embark screen +embark-tools enable sticky sand mouse + +# enable option to enter embark assistant +enable embark-assistant + +########### +# Scripts # +########### + +# write extra information to the gamelog +modtools/extra-gamelog enable + +# extended status screen (bedrooms page) +enable gui/extended-status + +# add information to item viewscreens +view-item-info enable + +# a replacement for the "load game" screen +gui/load-screen enable diff --git a/data/init/onLoad.default.init b/data/init/onLoad.default.init new file mode 100644 index 000000000..c13190357 --- /dev/null +++ b/data/init/onLoad.default.init @@ -0,0 +1,5 @@ +# Default DFHack commands to run when a world is loaded + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/onLoad.init diff --git a/data/init/onMapLoad.default.init b/data/init/onMapLoad.default.init new file mode 100644 index 000000000..44986a044 --- /dev/null +++ b/data/init/onMapLoad.default.init @@ -0,0 +1,6 @@ +# Default DFHack commands to run when a map is loaded, either in +# adventure or fort mode. + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/onMapLoad.init diff --git a/data/init/onMapUnload.default.init b/data/init/onMapUnload.default.init new file mode 100644 index 000000000..6441d72ff --- /dev/null +++ b/data/init/onMapUnload.default.init @@ -0,0 +1,5 @@ +# Default DFHack commands to run when a map is unloaded + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/onMapUnload.init diff --git a/data/init/onUnload.default.init b/data/init/onUnload.default.init new file mode 100644 index 000000000..9254a257b --- /dev/null +++ b/data/init/onUnload.default.init @@ -0,0 +1,5 @@ +# Default DFHack commands to run when a world is unloaded + +# Please do not edit this file directly. It will be overwritten with new +# defaults when you update DFHack. Instead, add your configuration to +# dfhack-config/init/onUnload.init diff --git a/dfhack-config/init/default.dfhack.init b/dfhack-config/init/default.dfhack.init new file mode 100644 index 000000000..aad18dd1c --- /dev/null +++ b/dfhack-config/init/default.dfhack.init @@ -0,0 +1,7 @@ +# Load DFHack defaults. +# +# If you delete this file, it will reappear when you restart DFHack. +# Instead, please comment out the following line if you do not want DFHack to +# load its default configuration. + +script hack/init/dfhack.default.init diff --git a/dfhack-config/init/default.onLoad.init b/dfhack-config/init/default.onLoad.init new file mode 100644 index 000000000..fe87d4209 --- /dev/null +++ b/dfhack-config/init/default.onLoad.init @@ -0,0 +1,7 @@ +# Load DFHack defaults. +# +# If you delete this file, it will reappear when you restart DFHack. +# Instead, please comment out the following line if you do not want DFHack to +# load its default configuration. + +script hack/init/onLoad.default.init diff --git a/dfhack-config/init/default.onMapLoad.init b/dfhack-config/init/default.onMapLoad.init new file mode 100644 index 000000000..9e781b924 --- /dev/null +++ b/dfhack-config/init/default.onMapLoad.init @@ -0,0 +1,7 @@ +# Load DFHack defaults. +# +# If you delete this file, it will reappear when you restart DFHack. +# Instead, please comment out the following line if you do not want DFHack to +# load its default configuration. + +script hack/init/onMapLoad.default.init diff --git a/dfhack-config/init/default.onMapUnload.init b/dfhack-config/init/default.onMapUnload.init new file mode 100644 index 000000000..716680fd0 --- /dev/null +++ b/dfhack-config/init/default.onMapUnload.init @@ -0,0 +1,7 @@ +# Load DFHack defaults. +# +# If you delete this file, it will reappear when you restart DFHack. +# Instead, please comment out the following line if you do not want DFHack to +# load its default configuration. + +script hack/init/onMapUnload.default.init diff --git a/dfhack-config/init/default.onUnload.init b/dfhack-config/init/default.onUnload.init new file mode 100644 index 000000000..712c35098 --- /dev/null +++ b/dfhack-config/init/default.onUnload.init @@ -0,0 +1,7 @@ +# Load DFHack defaults. +# +# If you delete this file, it will reappear when you restart DFHack. +# Instead, please comment out the following line if you do not want DFHack to +# load its default configuration. + +script hack/init/onUnload.default.init diff --git a/dfhack-config/init/dfhack.init b/dfhack-config/init/dfhack.init new file mode 100644 index 000000000..b05598f98 --- /dev/null +++ b/dfhack-config/init/dfhack.init @@ -0,0 +1,5 @@ +# This file runs when DFHack is initialized, when Dwarf Fortress is first +# started, before any world or save data is loaded. +# +# You can extend or override DFHack's default configuration by adding commands +# to this file. diff --git a/dfhack-config/init/onLoad.init b/dfhack-config/init/onLoad.init new file mode 100644 index 000000000..ef4fd97af --- /dev/null +++ b/dfhack-config/init/onLoad.init @@ -0,0 +1,6 @@ +# This file runs when a world is loaded. This happens when you open a save file +# in fort, adventure, or legends mode. If a fort is being loaded, this file runs +# before any onMapLoad.init files. +# +# You can extend or override DFHack's default configuration by adding commands +# to this file. diff --git a/dfhack-config/init/onMapLoad.init b/dfhack-config/init/onMapLoad.init new file mode 100644 index 000000000..90c6b9e14 --- /dev/null +++ b/dfhack-config/init/onMapLoad.init @@ -0,0 +1,5 @@ +# This file runs when a map is loaded in adventure or fort mode, after any +# onLoad.init files (which run earlier, when the world is loaded). +# +# You can extend or override DFHack's default configuration by adding commands +# to this file. diff --git a/dfhack-config/init/onMapUnload.init b/dfhack-config/init/onMapUnload.init new file mode 100644 index 000000000..c513d9cae --- /dev/null +++ b/dfhack-config/init/onMapUnload.init @@ -0,0 +1,5 @@ +# This file runs when a fortress map is unloaded, before any onUnload.init files +# (which run later, when the world is unloaded). +# +# You can extend or override DFHack's default configuration by adding commands +# to this file. diff --git a/dfhack-config/init/onUnload.init b/dfhack-config/init/onUnload.init new file mode 100644 index 000000000..c8ed3ab5b --- /dev/null +++ b/dfhack-config/init/onUnload.init @@ -0,0 +1,4 @@ +# This file runs when a world is unloaded. +# +# You can extend or override DFHack's default configuration by adding commands +# to this file. diff --git a/docs/Core.rst b/docs/Core.rst index ef178cc6e..fe881a54d 100644 --- a/docs/Core.rst +++ b/docs/Core.rst @@ -366,16 +366,27 @@ The following commands are *not* built-in, but offer similarly useful functions. * `repeat` +.. _dfhack-config: + +Configuration Files +=================== + +Most DFHack settings can be changed by modifying files in the ``dfhack-config`` +folder (which is in the DF folder). The default versions of these files, if they +exist, are in ``dfhack-config/default`` and are installed when DFHack starts if +necessary. + .. _init-files: Init Files -========== +---------- .. contents:: :local: DFHack allows users to automatically run commonly-used DFHack commands -when DF is first loaded, when a game is loaded, and when a game is unloaded. +when DF is first loaded, when a world is loaded, when a map is loaded, when a +map is unloaded, and when a world is unloaded. Init scripts function the same way they would if the user manually typed in their contents, but are much more convenient. In order to facilitate @@ -385,32 +396,33 @@ save-specific init files in the save folders. DFHack looks for init files in three places each time they could be run: -#. The main DF directory +#. The :file:`dfhack-config/init` subdirectory in the main DF directory #. :file:`data/save/{world}/raw`, where ``world`` is the current save, and #. :file:`data/save/{world}/raw/objects` -When reading commands from dfhack.init or with the `script` command, if the final -character on a line is a backslash then the next uncommented line is considered a -continuation of that line, with the backslash deleted. Commented lines are skipped, -so it is possible to comment out parts of a command with the ``#`` character. +For each of those directories, all matching init files will be executed in +alphabetical order. +Before running matched init scripts in any of those locations, the +:file:`dfhack-config/init/default.*` file that matches the event will be run to +load DFHack defaults. Only the :file:`dfhack-config/init` directory is checked +for this file, not any :file:`raw` directories. If you want DFHack to load +without running any of its default configuration commands, edit the +:file:`dfhack-config/init/default.*` files and comment out the commands you see +there. -.. _dfhack.init: +When reading commands from the init files or with the `script` command, if the +final character on a line is a backslash then the next uncommented line is +considered a continuation of that line, with the backslash deleted. Commented +lines are skipped, so it is possible to comment out parts of a command with the +``#`` character. -dfhack*.init ------------- -If your DF folder contains at least one file named ``dfhack*.init`` -(where ``*`` is a placeholder for any string), then all such files -are executed in alphabetical order when DF is first started. - -DFHack is distributed with :download:`/dfhack.init-example` as an example -with an up-to-date collection of basic commands; mostly setting standard -keybindings and `enabling ` plugins. You are encouraged to look -through this file to learn which features it makes available under which -key combinations. You may also customise it and rename it to ``dfhack.init``. +.. _dfhack.init: -If your DF folder does not contain any ``dfhack*.init`` files, the example -will be run as a fallback. +dfhack\*.init +............. +On startup, DFHack looks for files of the form ``dfhack*.init`` (where ``*`` is +a placeholder for any string, including the empty string). These files are best used for keybindings and enabling persistent plugins which do not require a world to be loaded. @@ -418,51 +430,49 @@ which do not require a world to be loaded. .. _onLoad.init: -onLoad*.init ------------- +onLoad\*.init +............. When a world is loaded, DFHack looks for files of the form ``onLoad*.init``, where ``*`` can be any string, including the empty string. -All matching init files will be executed in alphabetical order. A world being loaded can mean a fortress, an adventurer, or legends mode. These files are best used for non-persistent commands, such as setting a `fix ` script to run on `repeat`. -.. _onUnload.init: +.. _onMapLoad.init: -onUnload*.init --------------- -When a world is unloaded, DFHack looks for files of the form ``onUnload*.init``. -Again, these files may be in any of the above three places. -All matching init files will be executed in alphebetical order. +onMapLoad\*.init +................ +When a map is loaded, either in adventure or fort mode, DFHack looks for files +of the form ``onMapLoad*.init``, where ``*`` can be any string, including the +empty string. -Modders often use such scripts to disable tools which should not affect -an unmodded save. +These files are best used for commands that are only relevant once there is a +game map loaded. -.. _other_init_files: -Other init files ----------------- +.. _onMapUnload.init: +.. _onUnload.init: -* ``onMapLoad*.init`` and ``onMapUnload*.init`` are run when a map, - distinct from a world, is loaded. This is good for map-affecting - commands (e.g. `clean`), or avoiding issues in Legends mode. +onMapUnload\*.init and onUnload\*.init +...................................... +When a map or world is unloaded, DFHack looks for files of the form +``onMapUnload*.init`` or ``onUnload*.init``, respectively. -* Any lua script named ``raw/init.d/*.lua``, in the save or main DF - directory, will be run when any world or that save is loaded. +Modders often use unload init scripts to disable tools which should not run +after a modded save is unloaded. -.. _dfhack-config: +.. _other_init_files: -Configuration Files -=================== +raw/init.d/\*.lua +................. + +Any lua script named ``raw/init.d/*.lua``, in the save or main DF directory, +will be run when any world or that save is loaded. -Some DFHack settings can be changed by modifying files in the ``dfhack-config`` -folder (which is in the DF folder). The default versions of these files, if they -exist, are in ``dfhack-config/default`` and are installed when DFHack starts if -necessary. .. _script-paths: diff --git a/docs/changelog.txt b/docs/changelog.txt index 29e0d8e22..31f8b4615 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -41,7 +41,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled ## Misc Improvements - +- Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically. - `manipulator`: add a library of useful default professions - `manipulator`: move professions configuration from ``professions/`` to ``dfhack-config/professions/`` to keep it together with other dfhack configuration. If you have saved professions that you would like to keep, please manually move them to the new folder. - ``materials.ItemTraitsDialog``: added a default ``on_select``-handler which toggles the traits. diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 9e7bf8590..b3cdf93b9 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -460,9 +460,6 @@ endif() # install the offset file install(FILES xml/symbols.xml DESTINATION ${DFHACK_DATA_DESTINATION}) -# install the example autoexec file -install(FILES ../dfhack.init-example - DESTINATION ${DFHACK_BINARY_DESTINATION}) install(TARGETS dfhack-run dfhack-client binpatch LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} diff --git a/library/Core.cpp b/library/Core.cpp index 10f5057f3..aa43f3c2b 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1450,13 +1450,12 @@ static void run_dfhack_init(color_ostream &out, Core *core) return; } + // load baseline defaults + core->loadScriptFile(out, "dfhack-config/init/default.dfhack.init", false); + + // load user overrides std::vector prefixes(1, "dfhack"); - size_t count = loadScriptFiles(core, out, prefixes, "."); - if (!count || !Filesystem::isfile("dfhack.init")) - { - core->runCommand(out, "gui/no-dfhack-init"); - core->loadScriptFile(out, "dfhack.init-example", false); - } + loadScriptFiles(core, out, prefixes, "dfhack-config/init"); } // Load dfhack.init in a dedicated thread (non-interactive console mode) @@ -2226,7 +2225,11 @@ void Core::handleLoadAndUnloadScripts(color_ostream& out, state_change_event eve auto i = table.find(event); if ( i != table.end() ) { const std::vector& set = i->second; - loadScriptFiles(this, out, set, "." ); + + // load baseline defaults + this->loadScriptFile(out, "dfhack-config/init/default." + set[0] + ".init", false); + + loadScriptFiles(this, out, set, "dfhack-config/init"); loadScriptFiles(this, out, set, rawFolder); loadScriptFiles(this, out, set, rawFolder + "objects/"); }