From be7bce1541665909283769d1847e6793c4715df3 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 20 Aug 2012 23:59:54 +0400 Subject: [PATCH] Immediately step once when showing the mechanism list. --- scripts/gui/mechanisms.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/gui/mechanisms.lua b/scripts/gui/mechanisms.lua index 8c585334f..b333f4277 100644 --- a/scripts/gui/mechanisms.lua +++ b/scripts/gui/mechanisms.lua @@ -95,6 +95,8 @@ function MechanismList:onRender() end function MechanismList:zoomToLink(link) + self:updateLayout() + df.global.world.selected_building = link.obj local cursor = link.cursor @@ -114,6 +116,7 @@ function MechanismList:zoomToLink(link) end function MechanismList:changeSelected(delta) + if #self.links <= 1 then return end self.selected = 1 + (self.selected + delta - 1) % #self.links self:zoomToLink(self.links[self.selected]) end @@ -140,4 +143,6 @@ if df.global.ui.main.mode ~= df.ui_sidebar_mode.QueryBuilding then qerror("This script requires the 'q' interface mode") end -MechanismList.new(df.global.world.selected_building):show() +local list = MechanismList.new(df.global.world.selected_building) +list:show() +list:changeSelected(1)