The Farmer Was Replaced
Install with App

Details

Latest version
1.2.0
Last Updated
First Uploaded
Downloads
100
Likes
0
Size
474KB
Dependants

Categories

The Editor Was Replaced

A BepInEx 5 mod for The Farmer Was Replaced that adds a proper editor experience around the game's floating code windows - a file sidebar, real subdirectory support with dotted imports, improved external file watching, and settings that ride the game's own options menu.

The Editor Was Replaced running on the Showcase save: the sidebar file
tree with search, and three executing windows with red stop
buttons

Features

  • Sidebar file tree - one row per code file, grouped into collapsible folders (the Folder Folder chevron row opens and closes them). Open files have brighter rows, closed ones are dimmed. Drag the sidebar's right edge to widen it; the width is remembered per save.
  • Per-row buttons - run/stop (works while the window is closed; while code runs the button becomes the red stop button, stoppable between steps) and an optional delete button that removes the file from the save through the game's own confirmation.
  • Top button row - search toggle, new file, expand all, collapse all, close all windows, and refresh (rescans the save directory).
  • Search - filter the tree by name; focus keybind (Ctrl+K by default); while the box holds text, Escape clears it first instead of opening the pause menu.
  • Output console bar - the game's output page becomes a Chrome-style console docked at the bottom edge beside the sidebar: an always-there strip with an unread dot, expand/clear/open-file buttons, read-only selectable text, wheel scrolling, a drag-to-resize top edge, and a Ctrl+J toggle keybind. The game's warning icon expands it; size and state are remembered per save.
  • Preserve output - a checkbox on the console strip keeps the output (and its output.txt) when a new script starts, like Chrome's "preserve log"; the clear button still clears manually. Remembered per save.
  • Open output.txt - a button on the strip opens the console's log file in your system text editor.
  • Configurable scrollback - an "output scrollback" setting (10 to 5000 lines, default 100) decides how much output the console keeps; lowering it trims the existing buffer too. While output floods in, the console rebuilds its text at most 10 times a second so large buffers stay smooth.
  • Subdirectories & dotted imports - utils/helpers.py is importable as import utils.helpers; files live in real subdirectories on disk and round-trip through the game's save.
  • Own window titles - per-window rename via the game's own validation, hide buttons, and a trash icon on the file-window close button (closing a file window deletes the file from the save).
  • External file watching - the game's watcher becomes recursive and delete-aware: files created, changed, deleted or renamed outside the game open, update, and close their windows automatically.
  • Code indenting - a "code indent" option (2 spaces / 4 spaces / tab); in 2-space mode the editor also handles multi-line indent/unindent and converts typed tabs.
  • Monospaced fonts - "console font" and "editor font" dropdowns pick the face the output console and the builtin editor render in. The recommended faces (FiraCode, JetBrains Mono, Cascadia Mono, IBM Plex Mono, Noto Mono) ship with the mod and render identically on every OS; below a separator, the dropdowns also list every monospaced font installed on the machine, discovered by reading the system's font files. Missing fonts fall back to FiraCode.
  • Settings - hide default file windows (on by default), focus sidebar search keybind, toggle output bar keybind, output scrollback, console font, editor font, sidebar indent, show file paths (off), show delete buttons (off), code indent - persisted in the game's own options.txt.
  • Per-save memory - every save remembers expanded folders, hidden windows and search visibility, and restores them on load.
  • Docs page - an in-game documentation page (i button → General Info) explaining every button with its icon (assets/tewr.md).

Build & install

Requires the game installed via Steam (auto-detected; override with the TFWR_GAME_DIR environment variable). The build references the game's managed assemblies and copies the mod DLL into BepInEx/plugins/.

make prepare   # set up hooks + environment
make build     # build + copy to BepInEx/plugins
make run       # launch the game with the mod loaded
make format    # dotnet format (also enforced by a pre-commit hook)
make decompile # refresh decompiled game sources into decompiled/

Project layout

src/
  Core/       Plugin (BepInEx entry), PluginInfo, Patcher (registers every Harmony seam)
  Api/        GameApi - reflection facade over the game's internals (per-subsystem partials)
  Shared/     UiFactory, EmbeddedResources, SavePaths, ModIcons, FontAssets
  Options/    ModOptions (names), ModConfig (typed getters), GameOptions, OptionsPatches
  Docs/       ModDocs, DocsPatches, DocsIcons (inline docs icons)
  Editor/     CodeIndentPatches, ImportPatches, EditorFont (editor font swap)
  CodeFiles/  CodeFilesPatches (save side), WorkspaceFiles (load side),
              WatcherPatches (thin adapters), ExternalFileChanges (runtime service)
  Sidebar/    SidebarPanel + tree/rows/search/top-buttons,
              ScrollPatches, GameInputPatches, StatePersistence
  Output/     OutputBar (docked console), OutputPatches (output-page redirect),
              LoggerPatches (scrollback + preserve), SystemFonts (system font discovery)
  Windows/    EditorWindows (registry), TrackedWindow, WindowTitleUi,
              WindowChrome, WindowCapturePatches

assets/       embedded icon PNGs, the packed docs atlas, the in-game docs page
tools/        atlas build scripts (make-atlas.sh, normalize-atlas.py)

License and credits

Code: MIT, see LICENSE.

The sidebar and docs icons are from [Font Awesome Free] (https://fontawesome.com), licensed [CC BY 4.0] (https://creativecommons.org/licenses/by/4.0/). The docs atlas also draws two glyphs (the sidebar's run and stop markers) procedurally.

Bundled monospaced fonts, all licensed [SIL OFL 1.1] (https://openfontlicense.org): JetBrains Mono by JetBrains, Cascadia Mono by Microsoft, and IBM Plex Mono by IBM.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.