1-- Copyright (C) 2007, 2010 - Bit-Blot
2--
3-- This file is part of Aquaria.
4--
5-- Aquaria is free software; you can redistribute it and/or
6-- modify it under the terms of the GNU General Public License
7-- as published by the Free Software Foundation; either version 2
8-- of the License, or (at your option) any later version.
9--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13--
14-- See the GNU General Public License for more details.
15--
16-- You should have received a copy of the GNU General Public License
17-- along with this program; if not, write to the Free Software
18-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20if not v then v = {} end
21if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
22
23dofile(appendUserDataPath("_mods/jukebox/scripts/jukeboxinclude.lua"))
24
25v.naija = 0
26v.mbDown = false
27
28function init(me)
29	resetContinuity()
30	setOverrideMusic("")
31
32	v.naija = getNaija()
33
34	entity_heal(v.naija, 999)
35	cam_toNode(me)
36	cam_setPosition(node_x(me), node_y(me))
37	entity_setInvincible(v.naija, true)
38	entity_setState(v.naija, STATE_TITLE)
39
40
41	setMousePos(400, 550)
42
43	disableInput()
44	toggleCursor(true, 0.1)
45	overrideZoom(1.0)
46
47	resetTimer()
48
49	local throne = getNode("naija")
50	avatar_toggleCape(false)
51	entity_animate(v.naija, "sitthrone", -1, 4)
52	entity_setPosition(v.naija, node_x(throne), node_y(throne))
53
54	setMousePos(400, 550)
55
56	fade(1, 0)
57	fade(0, 1)
58	fade2(0, 2, 1, 1, 1)
59
60	jukebox_playSong(math.random(#SONG_LIST))
61end
62
63function update(me, dt)
64	cam_setPosition(node_x(me), node_y(me))
65	if isInputEnabled() then
66		disableInput()
67		toggleCursor(true, 0.1)
68	end
69
70	local scale = 800.0/1024.0 + 0.01
71
72	overrideZoom(scale, 0)
73
74	if (isLeftMouse() or isRightMouse()) and not v.mbDown then
75		v.mbDown = true
76	elseif (not isLeftMouse() and not isRightMouse()) and v.mbDown then
77		v.mbDown = false
78		local node = getNodeToActivate()
79		setNodeToActivate(0)
80		if node ~= 0 then
81			node_activate(node, 0)
82		end
83	end
84end
85