/usr/share/oolite/Scripts/oolite-primable-equipment-manager.js is in oolite-data 1.82-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | /*
oolite-primable-equipment-manager.js
Allocate primable equipment to the two 'fast activate' buttons.
Oolite
Copyright © 2004-2013 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
/*jslint white: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
/*global missionVariables, player*/
"use strict";
this.name = "oolite-primable-equipment-register";
this.author = "cim";
this.copyright = "© 2008-2013 the Oolite team.";
this.startUpComplete = this.shipDockedWithStation = this.playerBoughtNewShip = function()
{
this._initialiseInterface();
}
this.playerBoughtEquipment = function(eqkey)
{
this._initialiseInterface();
this._updatePrimableEquipmentSettings(eqkey,false);
}
this._updatePrimableEquipmentSettings = function(eqkey,quiet)
{
/* If the player has gained some equipment which is recommended
* for fast activation, and the activation slot has nothing in it,
* assign to that slot. */
var info = EquipmentInfo.infoForKey(eqkey);
if (info.fastAffinityDefensive && player.ship.equipmentStatus(player.ship.fastEquipmentA) != "EQUIPMENT_OK" && player.ship.equipmentStatus(player.ship.fastEquipmentA) != "EQUIPMENT_DAMAGED")
{
// no installed equipment in fast slot A, so assign this
player.ship.fastEquipmentA = eqkey;
if (!quiet)
{
player.consoleMessage(expandDescription("[oolite-primablemanager-notify-assign]",{
"oolite-primable-equipment": info.name,
"oolite-primable-slot": expandDescription("[oolite-primablemanager-slot-defensive]")
}),7.5);
player.consoleMessage(expandDescription("[oolite-primablemanager-notify-setup]"),7.5);
}
}
else if (info.fastAffinityOffensive && player.ship.equipmentStatus(player.ship.fastEquipmentB) != "EQUIPMENT_OK" && player.ship.equipmentStatus(player.ship.fastEquipmentB) != "EQUIPMENT_DAMAGED")
{
// no installed equipment in fast slot B, so assign this
player.ship.fastEquipmentB = eqkey;
if (!quiet)
{
player.consoleMessage(expandDescription("[oolite-primablemanager-notify-assign]",{
"oolite-primable-equipment": info.name,
"oolite-primable-slot": expandDescription("[oolite-primablemanager-slot-offensive]")
}),7.5);
player.consoleMessage(expandDescription("[oolite-primablemanager-notify-setup]"),7.5);
}
}
}
this._initialiseInterface = function()
{
if (player.ship.dockedStation)
{
var definition = null;
if (this._equipmentWithScripts().length > 0)
{
definition = {
title: expandMissionText("oolite-primablemanager-interface-title"),
category: expandMissionText("oolite-primablemanager-interface-category"),
summary: expandMissionText("oolite-primablemanager-interface-summary"),
callback: this._configurePrimableEquipment.bind(this)
};
}
player.ship.dockedStation.setInterface("oolite-primable-equipment-manager",definition);
}
}
this._equipmentWithScripts = function()
{
var result = [];
var equipment = player.ship.equipment;
for (var i=0;i<equipment.length;i++)
{
if (equipment[i].scriptName != "")
{
result.push(equipment[i]);
}
}
return result;
}
this._nameEquipment = function(key)
{
var equipment = this._equipmentWithScripts();
for (var i=0;i<equipment.length;i++)
{
if (equipment[i].equipmentKey == key)
{
return equipment[i].name;
}
}
return expandMissionText("oolite-primablemanager-select-none");
}
this._equipmentChoices = function(current) {
var choices = {};
var equipment = this._equipmentWithScripts();
var chosen = false;
var choice;
for (var i=0;i<equipment.length;i++)
{
choice = {
text: equipment[i].name
}
if (equipment[i].equipmentKey == current)
{
choice.color = "greenColor";
choice.text += " "+expandMissionText("oolite-primablemanager-selected-text");
chosen = true;
}
choices[equipment[i].equipmentKey] = choice;
}
choice = {
text: expandMissionText("oolite-primablemanager-select-none")
};
if (!chosen)
{
choice.color = "greenColor";
choice.text += " "+expandMissionText("oolite-primablemanager-selected-text");
}
choices["ZZZZZZ_OOLITE_EQ_NONE"] = choice;
return choices;
}
this._initialChoice = function(key)
{
if (player.ship.equipmentStatus(key) == "EQUIPMENT_OK" || player.ship.equipmentStatus(key) == "EQUIPMENT_DAMAGED")
{
return key;
}
return "ZZZZZZ_OOLITE_EQ_NONE";
}
this._configurePrimableEquipment = function()
{
mission.runScreen({
titleKey: "oolite-primablemanager-page1-title",
messageKey: "oolite-primablemanager-setup-text",
choices: this._equipmentChoices(player.ship.fastEquipmentA),
initialChoicesKey: this._initialChoice(player.ship.fastEquipmentA),
exitScreen: "GUI_SCREEN_INTERFACES",
screenID: "oolite-primablemanager"
},this._configureStage2.bind(this));
}
this._configureStage2 = function(choice)
{
if (choice != "")
{
player.ship.fastEquipmentA = choice;
}
mission.runScreen({
titleKey: "oolite-primablemanager-page2-title",
messageKey: "oolite-primablemanager-setup-text",
choices: this._equipmentChoices(player.ship.fastEquipmentB),
initialChoicesKey: this._initialChoice(player.ship.fastEquipmentB),
exitScreen: "GUI_SCREEN_INTERFACES",
screenID: "oolite-primablemanager"
},this._configureStage3.bind(this));
}
this._configureStage3 = function(choice)
{
if (choice != "")
{
player.ship.fastEquipmentB = choice;
}
var message = expandMissionText("oolite-primablemanager-completed",{
"oolite-primable-a" : this._nameEquipment(player.ship.fastEquipmentA),
"oolite-primable-b" : this._nameEquipment(player.ship.fastEquipmentB)
});
mission.runScreen({
titleKey: "oolite-primablemanager-page3-title",
message: message,
exitScreen: "GUI_SCREEN_INTERFACES",
screenID: "oolite-primablemanager"
});
}
|