From acc753e440fb6ce54342c1f4e4fc980c5e008448 Mon Sep 17 00:00:00 2001 From: Giuseppe Gadola Date: Wed, 15 Feb 2023 12:38:21 +0100 Subject: feat(commands): added hide and pause commands --- lua/pets/pet.lua | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lua/pets/pet.lua') diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua index e13d9e0..2442eec 100644 --- a/lua/pets/pet.lua +++ b/lua/pets/pet.lua @@ -43,7 +43,7 @@ end -- start the animation of the pet function M.Pet:animate() self.popup:mount() - self.animation:start(self.popup.bufnr) + self.animation:start() end -- delete the pet :( @@ -56,4 +56,32 @@ function M.Pet:kill() end end +function M.Pet:toggle_pause() + if not self.paused then + self.animation:stop_timer() + self.paused = true + else + if self.animation.current_image then + self.animation.current_image:delete(0, { free = false }) + end + self.animation:start_timer() + self.paused = false + end +end + +function M.Pet:toggle_hide() + if not self.paused then + self.animation:stop_timer() + if self.animation.current_image then + self.animation.current_image:delete(0, { free = false }) + end + self.popup:unmount() + self.paused = true + else + self.popup:mount() + self.animation:start() + self.paused = false + end +end + return M -- cgit v1.3-2-g11bf