Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Template for new versions:
# Future

## New Tools
- `gui/logcleaner`: graphical overlay for configuring the logcleaner plugin with enable and filter toggles.

## New Features

Expand Down
24 changes: 24 additions & 0 deletions docs/gui/logcleaner.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
gui/logcleaner
==============

.. dfhack-tool::
:summary: Configure logcleaner plugin settings.
:tags: fort auto units

This is the configuration interface for the `logcleaner` plugin. You can enable
or disable the plugin and toggle which report types are automatically cleared.

Usage
-----

::

gui/logcleaner

Hotkeys
---------

- Shift+E: Enable/disable the plugin
- Shift+C: Toggle combat report clearing
- Shift+S: Toggle sparring report clearing (default enabled)
- Shift+H: Toggle hunting report clearing
105 changes: 105 additions & 0 deletions gui/logcleaner.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
-- configuration and status panel interface for logcleaner

local gui = require('gui')
local plugin = require('plugins.logcleaner')
local widgets = require('gui.widgets')

Logcleaner = defclass(Logcleaner, widgets.Window)
Logcleaner.ATTRS{
frame_title='Logcleaner',
frame={w=45, h=14},
frame_inset=1,
}

function Logcleaner:init()
self:addviews{
widgets.ToggleHotkeyLabel{
view_id='enable_toggle',
frame={t=0, l=0},
key='CUSTOM_SHIFT_E',
label='logcleaner is',
options={
{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED},
},
on_change=function(val)
dfhack.run_command({val and 'enable' or 'disable', 'logcleaner'})
end,
},
widgets.Label{
frame={t=2, l=0},
text='Select log types to automatically clear.',
text_pen=COLOR_GREY,
},
widgets.ToggleHotkeyLabel{
view_id='combat_toggle',
frame={t=4, l=0},
key='CUSTOM_SHIFT_C',
label='Combat:',
options={
{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED},
},
on_change=function(val)
plugin.logcleaner_setCombat(val)
end,
},
widgets.ToggleHotkeyLabel{
view_id='sparring_toggle',
frame={t=6, l=0},
key='CUSTOM_SHIFT_S',
label='Sparring:',
options={
{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED},
},
on_change=function(val)
plugin.logcleaner_setSparring(val)
end,
},
widgets.ToggleHotkeyLabel{
view_id='hunting_toggle',
frame={t=8, l=0},
key='CUSTOM_SHIFT_H',
label='Hunting:',
options={
{value=true, label='Enabled', pen=COLOR_GREEN},
{value=false, label='Disabled', pen=COLOR_RED},
},
on_change=function(val)
plugin.logcleaner_setHunting(val)
end,
},
}
end

function Logcleaner:onRenderBody(dc)
self.subviews.enable_toggle:setOption(plugin.isEnabled())
self.subviews.combat_toggle:setOption(plugin.logcleaner_getCombat())
self.subviews.sparring_toggle:setOption(plugin.logcleaner_getSparring())
self.subviews.hunting_toggle:setOption(plugin.logcleaner_getHunting())
Logcleaner.super.onRenderBody(self, dc)
end

--
-- LogcleanerScreen
--

LogcleanerScreen = defclass(LogcleanerScreen, gui.ZScreen)
LogcleanerScreen.ATTRS{
focus_path='logcleaner',
}

function LogcleanerScreen:init()
self:addviews{Logcleaner{}}
end

function LogcleanerScreen:onDismiss()
view = nil
end

if not dfhack.isMapLoaded() or not dfhack.world.isFortressMode() then
qerror('logcleaner requires a fortress map to be loaded')
end

view = view and view:raise() or LogcleanerScreen{}:show()
5 changes: 5 additions & 0 deletions internal/control-panel/registry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ COMMANDS_BY_IDX = {
{command='hide-tutorials', group='gameplay', mode='system_enable'},
{command='immortal-cravings', group='gameplay', mode='enable'},
{command='light-aquifers-only', group='gameplay', mode='run'},
{command='logcleaner', group='gameplay', mode='enable'},
{command='logcleaner all', group='gameplay', mode='run',
desc='Enable logcleaner with all filters (combat, sparring, hunting).'},
{command='logcleaner sparring', group='gameplay', mode='run',
desc='Enable logcleaner with sparring filter (default).'},
{command='misery', group='gameplay', mode='enable'},
{command='orders-reevaluate', help_command='orders', group='gameplay', mode='repeat',
desc='Invalidates all work orders once a month, allowing conditions to be rechecked.',
Expand Down