From 5ff4e50b70f189f79aac2fab214a2dd06e6d72e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Obr=C4=99bski?= Date: Tue, 10 Sep 2024 20:40:23 +0200 Subject: [PATCH] Auto enable notes overlay when `gui/notes` is visible --- gui/notes.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gui/notes.lua b/gui/notes.lua index f04cf5cbe..d6354ac1e 100644 --- a/gui/notes.lua +++ b/gui/notes.lua @@ -5,6 +5,7 @@ local gui = require 'gui' local widgets = require 'gui.widgets' local guidm = require('gui.dwarfmode') local script = require 'gui.script' +local overlay = require 'plugins.overlay' local text_editor = reqscript('internal/journal/text_editor') local note_manager = reqscript('internal/notes/note_manager') @@ -13,6 +14,7 @@ local map_points = df.global.plotinfo.waypoints.points local NOTE_LIST_RESIZE_MIN = {w=26} local RESIZE_MIN = {w=65, h=30} local NOTE_SEARCH_BATCH_SIZE = 25 +local OVERLAY_NAME = 'notes.map_notes' local green_pin = dfhack.textures.loadTileset( 'hack/data/art/note_green_pin_map.png', @@ -351,7 +353,17 @@ function NotesScreen:onRenderFrame(dc, rect) end end +function NotesScreen:onAboutToShow() + if not overlay.get_state().config[OVERLAY_NAME].enabled then + self.should_disable_overlay = true + overlay.overlay_command({'enable', 'notes.map_notes'}) + end +end + function NotesScreen:onDismiss() + if self.should_disable_overlay then + overlay.overlay_command({'disable', 'notes.map_notes'}) + end view = nil end