//
// Author: Alexander Wolf
// Version: 1.2
// License: Public Domain
// Name: Tycho's Supernova
// Description: Flash of the supernova observed by Tycho Brahe in 1572. The Supernovae plugin has to be enabled.
//

include("i18n.inc");

var color = "#9999FF";
var JD = core.getJDay();

core.goHome();
core.wait(1);
core.setGuiVisible(false);
core.clear("natural");

LabelMgr.deleteAllLabels();
SolarSystem.setFlagLabels(false);

var label = LabelMgr.labelScreen(tr("Europe, Uraniborg."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.setObserverLocation("Uraniborg, Denmark", 2);
core.wait(4);

LabelMgr.setLabelShow(label, false);
core.wait(1);

label = LabelMgr.labelScreen(tr("Evening of 20 October 1572"), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.setDate("1572-10-20T17:00:00", "utc");
core.wait(3);

StelMovementMgr.zoomTo(200, 4);
core.wait(5);

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("Constellation Cassiopeia"), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);

ConstellationMgr.setFlagIsolateSelected(true);
ConstellationMgr.setFlagArt(false);
ConstellationMgr.setFlagLabels(false);
ConstellationMgr.setFlagLines(true);
ConstellationMgr.setFlagBoundaries(false);

core.selectObjectByName("Cassiopeia", false);
core.wait(1);

core.setMountMode("equatorial");
StelMovementMgr.setFlagTracking(true);
StelMovementMgr.zoomTo(60, 2);
core.wait(3);

ConstellationMgr.setFlagLines(false);
core.wait(.1);

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("5 days later..."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.setDate("+5 days");
core.wait(2);

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("Next 3 days..."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.setDate("+3 days");
core.wait(2);

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("New star! But people have not seen it yet..."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.wait(2);

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("Evening of 31 October 1572"), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.setDate("1572-10-31T17:00:00", "utc");
core.wait(2);

for (i=1; i<12; i++)
{
	LabelMgr.deleteAllLabels();
	label = LabelMgr.labelScreen(tr("Evening of ") + i + tr(" November 1572"), 20, 20, false, 20, color);
	LabelMgr.setLabelShow(label, true);
	core.setDate("+1 day");

	if (i==6)
	{
		core.wait(.5);
		label = LabelMgr.labelScreen(tr("Hooray! First observations in Korea and Europe."), 20, 50, false, 20, color);
		LabelMgr.setLabelShow(label, true);
		core.wait(.5);
	}

	if (i==8)
	{
		core.wait(.5);
		label = LabelMgr.labelScreen(tr("First observations in China."), 20, 50, false, 20, color);
		LabelMgr.setLabelShow(label, true);
		core.wait(.5);
	}

	if (i==11)
	{
		core.wait(.5);
		label = LabelMgr.labelScreen(tr("The clouds are gone and Tycho Brahe the first time watching a new star!"), 20, 50, false, 20, color);
		LabelMgr.setLabelShow(label, true);
		core.wait(1);
	}

	core.wait(2);
}

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("Next 60 days..."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.wait(.1);

for(i=0; i<60; i++)
{
	core.setDate("+1 day");
	core.wait(.1);
}

LabelMgr.deleteAllLabels();
label = LabelMgr.labelScreen(tr("Next other 40 days..."), 20, 20, false, 20, color);
LabelMgr.setLabelShow(label, true);
core.wait(.1);

for(i=0; i<40; i++)
{
	core.setDate("+1 day");
	core.wait(.1);
}

LabelMgr.deleteAllLabels();
core.setMountMode("azimuthal");
core.wait(.1);
core.clear("natural");
core.wait(.1);
core.goHome();
core.setJDay(JD);
core.wait(1);
core.setGuiVisible(true);