1
0
Fork 0
spacetac/src/ui/map/ActiveMissionsDisplay.ts

64 lines
2 KiB
TypeScript
Raw Normal View History

/// <reference path="../common/UIComponent.ts" />
2017-09-24 22:23:22 +00:00
module TK.SpaceTac.UI {
/**
* Widget to display the active missions list
*/
export class ActiveMissionsDisplay extends UIComponent {
private missions: ActiveMissions
private hash: number
2017-07-11 22:28:45 +00:00
private markers?: MissionLocationMarker
2017-07-11 22:28:45 +00:00
constructor(parent: BaseView, missions: ActiveMissions, markers?: MissionLocationMarker) {
2017-07-06 22:55:29 +00:00
super(parent, 520, 240);
this.missions = missions;
this.hash = missions.getHash();
2017-07-11 22:28:45 +00:00
this.markers = markers;
this.update();
}
/**
* Check if the active missions' status changed
*/
checkUpdate(): boolean {
this.missions.checkStatus();
let new_hash = this.missions.getHash();
if (new_hash != this.hash) {
this.hash = new_hash;
this.update();
return true;
} else {
return false;
}
}
/**
* Update the current missions list
*/
private update() {
this.clearContent();
2017-08-21 22:41:44 +00:00
let markers: [StarLocation | Star, string][] = [];
2017-07-11 22:28:45 +00:00
let active = this.missions.getCurrent();
2017-07-06 22:55:29 +00:00
let spacing = 80;
let offset = 245 - active.length * spacing;
active.forEach((mission, idx) => {
2017-08-21 22:41:44 +00:00
let image = mission.main ? "map-mission-main" : "map-mission-standard";
this.addImage(35, offset + spacing * idx, image);
2017-07-06 22:55:29 +00:00
this.addText(90, offset + spacing * idx, mission.current_part.title, "#d2e1f3", 20, false, false, 430, true);
2017-07-11 22:28:45 +00:00
let location = mission.current_part.getLocationHint();
if (location) {
2017-08-21 22:41:44 +00:00
markers.push([location, image]);
2017-07-11 22:28:45 +00:00
}
});
2017-07-11 22:28:45 +00:00
if (this.markers) {
this.markers.setMarkers(markers);
}
}
}
}