local monarch = require "monarch.monarch"
local transitions = require "monarch.transitions.gui"

function init(self)
	msg.post(".", "acquire_input_focus")
	gui.set_render_order(15)

	local transition = transitions.create(gui.get_node("root"))
		.show_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0)
		.show_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0)
		.back_in(transitions.slide_in_top, gui.EASING_OUTQUAD, 0.6, 0)
		.back_out(transitions.slide_out_top, gui.EASING_INQUAD, 0.6, 0)

	monarch.on_transition("about", transition)
end

function on_input(self, action_id, action)
	if action_id == hash("touch") and action.released then
		if gui.pick_node(gui.get_node("ok_reload_button"), action.x, action.y) then
			monarch.show(hash("menu"), { reload = true })
		elseif gui.pick_node(gui.get_node("ok_clear_button"), action.x, action.y) then
			monarch.show(hash("menu"), { clear = true })
		elseif gui.pick_node(gui.get_node("ok_clearreload_button"), action.x, action.y) then
			monarch.show(hash("menu"), { clear = true, reload = true })
		elseif gui.pick_node(gui.get_node("ok_button"), action.x, action.y) then
			monarch.show(hash("menu"))
		end
	end
end

function on_message(self, message_id, message, sender)
	monarch.on_message(message_id, message, sender)
end
