Scripts/planner.js |
this.name = "planner.js";
this.author = "Ramen";
this.copyright = "(C) 2015 Ramen";
this.licence = "CC-NC-by-SA 3.0";
this.description = "This OXP doesn't do very much yet.";
this.version = "1.0.0";
"use strict";
this._tempVal = "";
this.startUpComplete = function()
{
if (!missionVariables.planner_planNames)
{
missionVariables.planner_plans = JSON.stringify({});
missionVariables.planner_planNames = JSON.stringify({"1_EXIT":
"Exit."});
}
this._plans = JSON.parse(missionVariables.planner_plans);
this._planNames = JSON.parse(missionVariables.planner_planNames);
this.$dockedCheck();
}
this.shipDockedWithStation = function()
{
this.$dockedCheck();
this.playerWillSaveGame();
}
this.playerWillSaveGame = function()
{
missionVariables.planner_plans = JSON.stringify(this._plans);
missionVariables.planner_planNames = JSON.stringify(this._planNames);
}
this.$dockedCheck = function()
{
player.ship.dockedStation.setInterface("Planner",
{ title: "Planner",
category: "Info",
summary: "A Planner for "+
"'Real life' or Oolite",
callback:
this.$planner.bind(this)});
}
this.$planner = function()
{
mission.runScreen({
title: "Planner",
message: "Choose an option.",
choicesKey: "planner_options"},
this.$choice);
}
this.$choice = function(choice)
{
if (choice == "1_ADD")
{
mission.runScreen({
title: "Planner",
message: "Enter subject. (30 char. max)",
textEntry: "TRUE"},
this.$subject);
}
else if (choice == "2_REMOVE")
{
mission.runScreen({
title: "Planner",
message: "Choose plan to remove.",
choices: this._planNames},
this.$remove);
}
else if (choice == "3_VIEW")
{
mission.runScreen({
title: "Planner",
message: "Choose a plan.",
choices: this._planNames},
this.$view);
}
else
{
return;
}
}
this.$subject = function(choice)
{
this._tempVal = choice;
mission.runScreen({
title: "Planner",
message: "Enter details. (30 char. max)",
exitScreen: "GUI_SCREEN_INTERFACES",
textEntry: "TRUE"},
this.$details);
}
this.$details = function(choice)
{
if (choice == "")
{
return;
}
this._plans[this._tempVal] = choice;
this._planNames[this._tempVal] = this._tempVal;
}
this.$remove = function(choice)
{
if (choice == "1_EXIT")
{
return;
}
delete this._plans[choice];
delete this._planNames[choice];
player.consoleMessage(choice + " removed.");
}
this.$view = function(choice)
{
if (choice == "1_EXIT")
{
return;
}
mission.runScreen({
title: choice,
message: "Details:\n" + this._plans[choice]});
}
|