move sidebar mode management code to init

from onAboutToShow(). this allows the frames to be calculated correctly
during widget instantiation. otherwise widgets can end up with -1 width
develop
myk002 2022-04-29 12:10:05 -07:00
parent af47434f52
commit e603fee3ce
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 7 additions and 5 deletions

@ -443,11 +443,7 @@ MenuOverlay.ATTRS {
sidebar_mode = DEFAULT_NIL,
}
function MenuOverlay:computeFrame(parent_rect)
return self.df_layout.menu, gui.inset_frame(self.df_layout.menu, self.frame_inset)
end
function MenuOverlay:onAboutToShow(parent)
function MenuOverlay:init()
if not dfhack.isMapLoaded() then
-- sidebar menus are only valid when a fort map is loaded
error('A fortress map must be loaded.')
@ -471,7 +467,13 @@ function MenuOverlay:onAboutToShow(parent)
enterSidebarMode(self.sidebar_mode)
end
end
function MenuOverlay:computeFrame(parent_rect)
return self.df_layout.menu, gui.inset_frame(self.df_layout.menu, self.frame_inset)
end
function MenuOverlay:onAboutToShow(parent)
self:updateLayout()
if not self.df_layout.menu then
error("The menu panel of dwarfmode is not visible")