48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
/// <reference path="../common/UIComponent.ts" />
|
|
|
|
module TS.SpaceTac.UI {
|
|
/**
|
|
* Widget to display the active missions list
|
|
*/
|
|
export class ActiveMissionsDisplay extends UIComponent {
|
|
private missions: ActiveMissions
|
|
private hash: number
|
|
|
|
constructor(parent: BaseView, missions: ActiveMissions) {
|
|
super(parent, 520, 240);
|
|
this.missions = missions;
|
|
this.hash = missions.getHash();
|
|
|
|
this.update();
|
|
}
|
|
|
|
/**
|
|
* Check if the active missions' status changed
|
|
*/
|
|
checkUpdate(): boolean {
|
|
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();
|
|
|
|
let active = this.missions.getCurrent();
|
|
let spacing = 80;
|
|
let offset = 245 - active.length * spacing;
|
|
active.forEach((mission, idx) => {
|
|
this.addImage(35, offset + spacing * idx, "map-missions", mission.main ? 0 : 1);
|
|
this.addText(90, offset + spacing * idx, mission.current_part.title, "#d2e1f3", 20, false, false, 430, true);
|
|
});
|
|
}
|
|
}
|
|
} |