local WidgetBase      = require "core.modules.menusystem.widgets"
local MainMenuWidget  = WidgetBase.Text:extend()

function MainMenuWidget:new(menu, name)
  self.scene = menu.scene
  font = self.scene.assets.fonts["medium"]

  MainMenuWidget.super.new(self, menu, font, name)
end

local Widgets = {}
Widgets.Menu    = MainMenuWidget:extend()
Widgets.Mission = MainMenuWidget:extend()
Widgets.AddPig  = MainMenuWidget:extend()
Widgets.Save    = MainMenuWidget:extend()
Widgets.Load    = MainMenuWidget:extend()

function Widgets.Menu:new(menu, name, menuID)
  self.menuID = menuID
  Widgets.Menu.super.new(self, menu, name)
end

function Widgets.Menu:action()
  self.scene:selectMenu(self.menuID)
end

function Widgets.Mission:new(menu, levelID)
  local data = require("datas.levels." .. levelID)
  Widgets.Mission.super.new(self, menu, data.name)
  self.menusystem = menusystem
  self.levelID = levelID
  self.missionID = missionID
end

function Widgets.Mission:action()
  scenes.Levels(self.levelID)
end

function Widgets.AddPig:new(menu)
  Widgets.AddPig.super.new(self, menu, "Add Pig")
  self.label = "Add Pig"
end

function Widgets.AddPig:action()
  game.pigmanager:addPig("cochon")
  self.scene:refreshMenu()
end

function Widgets.Load:new(menu)
  Widgets.Load.super.new(self, menu, "Load Game")
end

function Widgets.Load:action()
  save:reload()
end

function Widgets.Save:new(menu)
  Widgets.Save.super.new(self, menu, "Save Game")
  self.menusystem = menusystem
end

function Widgets.Save:action()
  save:write()
end

return Widgets
