-
Notifications
You must be signed in to change notification settings - Fork 1
/
SectorsMode.ts
102 lines (73 loc) · 2.83 KB
/
SectorsMode.ts
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
/// <reference path="EditingMode.ts" />
/// <reference path="jquery.d.ts" />
class SectorsMode extends EditingMode {
highlightedSector: Sector;
constructor() {
super();
this.highlightedSector = null;
}
public onMouseMove(event: MouseEvent) {
super.onMouseMove(event);
var redraw = false;
this.onRedraw();
if(!this.panning) {
var newHighlight: Sector = null;
for(var i=0; i < DEOTG.map.sectors.length; i++) {
if(DEOTG.map.sectors[i].pointInside(DEOTG.mouseMapPosition)) {
newHighlight = DEOTG.map.sectors[i];
break;
}
}
if(newHighlight != this.highlightedSector) {
redraw = true;
}
this.highlightedSector = newHighlight;
if(redraw)
this.onRedraw();
this.showSectorInfoOverlay();
}
}
public onMouseWheel(event: MouseEvent, delta: number) {
super.onMouseWheel(event, delta);
}
public onRedraw() {
DEOTG.renderer2d.clear();
DEOTG.renderer2d.drawSectors(DEOTG.map.sectors);
DEOTG.renderer2d.drawLinedefs(DEOTG.map.linedefs);
DEOTG.renderer2d.drawVertices(DEOTG.map.vertices);
DEOTG.renderer2d.drawThings(DEOTG.map.things);
if(this.highlightedSector != null)
this.drawHighlightedSector();
}
public drawHighlightedSector() {
var sector = this.highlightedSector;
DEOTG.renderer2d.drawSectorSidedefs(sector, new Color(192, 192, 0), 2);
/*
DEOTG.renderer2d.context.font = '12pt Calibri';
DEOTG.renderer2d.context.fillStyle = 'black';
DEOTG.renderer2d.context.fillText("Sector: " + sector.index, 10, 16);
DEOTG.renderer2d.context.fillText("Floor: " + sector.floorHeight, 10, 36);
DEOTG.renderer2d.showFlat(DEOTG.graphicsManager.flats[sector.floorTexture], 10, 42);
DEOTG.renderer2d.context.fillText("Ceiling: " + sector.ceilingHeight, 10, 123);
DEOTG.renderer2d.showFlat(DEOTG.graphicsManager.flats[sector.ceilingTexture], 10, 129);
*/
}
public showSectorInfoOverlay() {
var o = $('#sectorInfoOverlay');
if(this.highlightedSector == null) {
o.hide();
return;
}
o.find('#number').html(this.highlightedSector.index.toString());
o.find('#light').html(this.highlightedSector.lightLevel.toString());
o.find('#tag').html(this.highlightedSector.tag.toString());
o.find('#type').html(this.highlightedSector.type.toString());
o.find('#floorHeight').html(this.highlightedSector.floorHeight.toString());
o.find('#floorImage').attr("src", DEOTG.graphicsManager.flats[this.highlightedSector.floorTexture].canvas.toDataURL());
o.find('#floorName').html(this.highlightedSector.floorTexture);
o.find('#ceilingHeight').html(this.highlightedSector.ceilingHeight.toString());
o.find('#ceilingImage').attr("src", DEOTG.graphicsManager.flats[this.highlightedSector.ceilingTexture].canvas.toDataURL());
o.find('#ceilingName').html(this.highlightedSector.ceilingTexture);
o.show();
}
}