Skip to content

Commit 79db711

Browse files
lcdrXiphoseer
authored andcommitted
Add GraphQL support to mission, mission-list components
1 parent ba1eac2 commit 79db711

File tree

3 files changed

+64
-29
lines changed

3 files changed

+64
-29
lines changed
Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
<ul class="mission-list" *ngIf="'
2-
select
3-
m.id as id,
4-
isMission,
5-
i.IconPath,
6-
name_en_US as name,
7-
case isMission
8-
when 0 then description_en_US
9-
else in_progress_en_US
10-
end tooltip
11-
from
12-
Missions m
13-
left join MissionText mt on m.id = mt.id
14-
left join Icons i on i.IconID =
15-
case isMission
16-
when 0 then missionIconID
17-
else (select largeTaskIconID from MissionTasks mt where mt.id = m.id limit 1)
18-
end '
19-
+_where+'
20-
order by
21-
isMission desc,
22-
UISortOrder
23-
' | query; let missions">
24-
<ng-container *ngFor="let mission of missions">
25-
<li [style.order]="1 - mission.isMission">
26-
<lux-mission [id]="+mission.id" [isMission]="((mission.isMission) == '1')" [title]="mission.name | default:(mission.isMission == '1' ? 'Mission' : 'Achievement')+' #'+mission.id" [icon]="mission.IconPath | icon" [tooltip]="mission.tooltip"></lux-mission>
27-
</li>
28-
</ng-container>
29-
<li class="mission-separator"></li>
1+
<ul *ngIf="missions; else deprecated" class="mission-list">
2+
<li *ngFor="let mission of missions" [style.order]="1 - mission.isMission" [style.order]="-mission.isMission * 10000 + mission.UISortOrder + 1">
3+
<lux-mission [mission]="mission"></lux-mission>
4+
</li>
5+
<li class="mission-separator"></li>
306
</ul>
7+
<ng-template #deprecated>
8+
<ul class="mission-list" *ngIf="'
9+
select
10+
m.id as id,
11+
isMission,
12+
i.IconPath,
13+
name_en_US as name,
14+
case isMission
15+
when 0 then description_en_US
16+
else in_progress_en_US
17+
end tooltip
18+
from
19+
Missions m
20+
left join MissionText mt on m.id = mt.id
21+
left join Icons i on i.IconID =
22+
case isMission
23+
when 0 then missionIconID
24+
else (select largeTaskIconID from MissionTasks mt where mt.id = m.id limit 1)
25+
end '
26+
+_where+'
27+
order by
28+
isMission desc,
29+
UISortOrder
30+
' | query; let missions">
31+
<ng-container *ngFor="let mission of missions">
32+
<li [style.order]="1 - mission.isMission">
33+
<lux-mission [id]="+mission.id" [isMission]="((mission.isMission) == '1')" [title]="mission.name | default:(mission.isMission == '1' ? 'Mission' : 'Achievement')+' #'+mission.id" [icon]="mission.IconPath | icon" [tooltip]="mission.tooltip"></lux-mission>
34+
</li>
35+
</ng-container>
36+
<li class="mission-separator"></li>
37+
</ul>
38+
</ng-template>

src/app/gui/mission-list/mission-list.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { Component, Input } from '@angular/core';
2+
import { MissionFragment } from "generated/graphql";
23

34
@Component({
45
selector: 'lux-mission-list',
56
templateUrl: './mission-list.component.html',
67
styleUrls: ['./mission-list.component.css']
78
})
89
export class MissionListComponent {
10+
@Input() missions: MissionFragment[];
11+
912
@Input()
1013
set ids(value: number[]) {
1114
this._where = "where m.id in ("+value+")";

src/app/gui/mission/mission.component.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
import { Component, HostBinding, Input } from "@angular/core";
22
import { DB_Icons } from "../../../defs/cdclient";
3+
import { MissionFragment } from "generated/graphql";
34

45
@Component({
56
selector: "lux-mission",
67
templateUrl: "./mission.component.html",
78
styleUrls: ["./mission.component.css"]
89
})
910
export class MissionComponent {
11+
@Input() set mission(value: MissionFragment) {
12+
this.id = value.id;
13+
this.sortOrder = value.UISortOrder;
14+
this.isMission = value.isMission == 1;
15+
if (value.name_loc) {
16+
this.title = value.name_loc;
17+
} else {
18+
this.title = (this.isMission ? 'Mission' : 'Achievement')+' #'+this.id;
19+
}
20+
let icon;
21+
if (this.isMission) {
22+
if (value.MissionText.length > 0) {
23+
this.tooltip = value.MissionText[0].in_progress_loc;
24+
}
25+
icon = value.MissionTasks[0].largeTaskIconID;
26+
} else {
27+
if (value.MissionText.length > 0) {
28+
this.tooltip = value.MissionText[0].description_loc;
29+
}
30+
icon = value.missionIconID;
31+
}
32+
this.icon = "/lu-res/textures/ui/" + (icon ? icon.IconPath : "inventory/unknown.png").toLowerCase().replace(/dds$/, "png");
33+
}
1034
@Input() id: number;
1135
@Input() isMission: boolean = true;
1236
/// Either iconID or icon must be provided. If possible do a bulk lookup of icon ID -> icon path on the DB side, this is much more efficient than specificing iconID for multiple missions.

0 commit comments

Comments
 (0)