Skip to content

Commit

Permalink
last commit before making new history
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Jul 26, 2024
1 parent fc1fb04 commit 6898a6e
Showing 1 changed file with 47 additions and 51 deletions.
98 changes: 47 additions & 51 deletions scripts/pages/zoning/zoning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ class ZoneMenu {
$.RegisterForUnhandledEvent('OnRegionSave', this.onRegionSave.bind(this));

$.RegisterForUnhandledEvent('LevelInitPostEntity', this.initMenu.bind(this));

//$.RegisterEventHandler('DropDownMenuClosed', this.panels.regionSelect, this.populateRegionProperties);
//$.RegisterEventHandler('DropDownMenuClosed', this.panels.filterSelect, this.updateZoneFilter.bind(this));
}

static onLoad() {
Expand All @@ -85,16 +82,12 @@ class ZoneMenu {
},
stagesEndAtStageStarts: true
},
bonuses: [this.createBonusTrack(), this.createBonusTrack(), this.createBonusTrack()] /*as BonusTrack[]*/
bonuses: [] as BonusTrack[]
} as MapTracks;

this.mapZoneData = {} as ZoneDef;
this.mapZoneData.tracks = tracks;
}

this.mapZoneData.tracks.bonuses[0].defragFlags = 31;
this.mapZoneData.tracks.bonuses[1].defragFlags = 6;
this.mapZoneData.tracks.bonuses[2].defragFlags = 11;
}

static initMenu() {
Expand All @@ -106,12 +99,6 @@ class ZoneMenu {

this.updateSelection(this.mapZoneData.tracks.main, null, null);

this.createTrackEntry(this.panels.trackList, this.mapZoneData.tracks.main, 'Main');

for (const [i, bonus] of this.mapZoneData.tracks.bonuses.entries()) {
this.createTrackEntry(this.panels.trackList, bonus, `Bonus ${i + 1}`);
}

//@ts-expect-error function name not recognized
const entList = $.GetContextPanel().getEntityList();
this.filternameList = entList.filter ?? [];
Expand All @@ -127,17 +114,21 @@ class ZoneMenu {
}

this.showRegionMenu('Points');

this.createTrackEntry(this.panels.trackList, this.mapZoneData.tracks.main, 'Main');

for (const [i, bonus] of this.mapZoneData.tracks.bonuses.entries()) {
this.createTrackEntry(this.panels.trackList, bonus, `Bonus ${i + 1}`);
}
}

static showZoneMenu() {
// show zone menu
if (!this.mapZoneData || this.panels.trackList.Children().length === 0) {
this.initMenu();
}
}

static hideZoneMenu() {
// hide zone menu
if (this.panels.trackList?.Children().length) {
this.panels.trackList.RemoveAndDeleteChildren();
}
Expand All @@ -146,7 +137,6 @@ class ZoneMenu {
static toggleCollapse(container: Panel, expandIcon: Panel, collapseIcon: Panel) {
const shouldExpand = container.HasClass('hide');
container.SetHasClass('hide', !shouldExpand);
// Show the corresponding button icon
expandIcon.SetHasClass('hide', !shouldExpand);
collapseIcon.SetHasClass('hide', shouldExpand);
const parent = container.GetParent();
Expand Down Expand Up @@ -177,7 +167,6 @@ class ZoneMenu {
});
if (segmentContainer === null) continue;
if (segment.checkpoints.length === 0) {
//majorListContainer.RemoveAndDeleteChildren();
(trackContainer.FindChildTraverse('CollapseButton') as Panel).style.visibility = 'collapse';
continue;
}
Expand Down Expand Up @@ -273,8 +262,8 @@ class ZoneMenu {
static createRegion() {
return {
points: [] as Vec2D[],
//bottom: Number.MAX_SAFE_INTEGER,
//height: 0,
bottom: Number.MAX_SAFE_INTEGER,
height: 0,
teleDestTargetName: ''
} as Region;
}
Expand Down Expand Up @@ -315,19 +304,16 @@ class ZoneMenu {
this.panels.propertiesTrack.style.visibility = 'collapse';
this.panels.propertiesSegment.style.visibility = 'collapse';
this.panels.propertiesZone.style.visibility = 'visible';
//populate zone properties
this.populateZoneProperties();
} else if (selectedSegment !== null) {
this.panels.propertiesTrack.style.visibility = 'collapse';
this.panels.propertiesSegment.style.visibility = 'visible';
this.panels.propertiesZone.style.visibility = 'collapse';
//populate segment properties
this.populateSegmentProperties();
} else if (selectedTrack !== null) {
this.panels.propertiesTrack.style.visibility = 'visible';
this.panels.propertiesSegment.style.visibility = 'collapse';
this.panels.propertiesZone.style.visibility = 'collapse';
//populate track properties
this.populateTrackProperties();
}
}
Expand Down Expand Up @@ -450,17 +436,16 @@ class ZoneMenu {
if (teleDestIndex === 0) {
// no teleport destination for this region
region.teleDestTargetName = '';
//delete region.teleDestPos;
//delete region.teleDestYaw;
// disable pos/yaw text entry
//@ts-expect-error property must be optional
delete region.teleDestPos;
//@ts-expect-error property must be optional
delete region.teleDestYaw;

this.panels.regionTPPos.x.text = '';
this.panels.regionTPPos.y.text = '';
this.panels.regionTPPos.z.text = '';
this.panels.regionTPYaw.text = '';
this.panels.regionTPPos.x.enabled = false;
this.panels.regionTPPos.y.enabled = false;
this.panels.regionTPPos.z.enabled = false;
this.panels.regionTPYaw.enabled = false;
this.setRegionTPDestTextEntriesActive(false);
} else if (teleDestIndex === 1) {
if (!region.teleDestPos || !region.teleDestYaw) {
region.teleDestPos = { x: 0, y: 0, z: 0 };
Expand All @@ -478,28 +463,30 @@ class ZoneMenu {
this.panels.regionTPPos.y.text = region.teleDestPos.y.toFixed(2);
this.panels.regionTPPos.z.text = region.teleDestPos.z.toFixed(2);
this.panels.regionTPYaw.text = region.teleDestYaw.toFixed(2);

// enable pos/yaw text entry
this.panels.regionTPPos.x.enabled = true;
this.panels.regionTPPos.y.enabled = true;
this.panels.regionTPPos.z.enabled = true;
this.panels.regionTPYaw.enabled = true;
this.setRegionTPDestTextEntriesActive(true);
} else {
region.teleDestTargetName = this.teleDestList[teleDestIndex];
//delete region.teleDestPos;
//delete region.teleDestYaw;
// disable pos/yaw text entry

//@ts-expect-error property must be optional
delete region.teleDestPos;
//@ts-expect-error property must be optional
delete region.teleDestYaw;

this.panels.regionTPPos.x.text = '';
this.panels.regionTPPos.y.text = '';
this.panels.regionTPPos.z.text = '';
this.panels.regionTPYaw.text = '';
this.panels.regionTPPos.x.enabled = false;
this.panels.regionTPPos.y.enabled = false;
this.panels.regionTPPos.z.enabled = false;
this.panels.regionTPYaw.enabled = false;
this.setRegionTPDestTextEntriesActive(false);
}
}

static setRegionTPDestTextEntriesActive(enable: boolean) {
this.panels.regionTPPos.x.enabled = enable;
this.panels.regionTPPos.y.enabled = enable;
this.panels.regionTPPos.z.enabled = enable;
this.panels.regionTPYaw.enabled = enable;
}

static onRegionSave() {
const index = this.panels.regionSelect.GetSelected()?.GetAttributeInt('value', -1);
if (index > -1) {
Expand All @@ -510,15 +497,11 @@ class ZoneMenu {
$.GetContextPanel().regionPointsEdit();
// show acknowledge/place points dialog
} else {
//
// continue editing
}
}
}

static onTextSubmitted() {
//grab this.something.textentry.text
}

static addBonus() {
if (!this.mapZoneData) return;
const bonus = this.createBonusTrack();
Expand Down Expand Up @@ -558,7 +541,6 @@ class ZoneMenu {
const newZone = this.createZone();
this.selectedZone.segment.checkpoints.push(newZone);

//this.addTracklistEntry()
let trackPanel: Panel;
if (this.selectedZone.track === this.mapZoneData.tracks.main) {
trackPanel = this.panels.trackList.Children()[0];
Expand Down Expand Up @@ -682,8 +664,6 @@ class ZoneMenu {
} else {
this.selectedZone.segment.checkpoints.splice(checkpointIndex, 1);
}

// remove deleted zone from tracklist
} else if (this.selectedZone.segment) {
const index = this.mapZoneData.tracks.main.zones.segments.indexOf(this.selectedZone.segment);
this.mapZoneData.tracks.main.zones.segments.splice(index, 1);
Expand All @@ -695,6 +675,10 @@ class ZoneMenu {
this.mapZoneData.tracks.bonuses.splice(trackIndex, 1);
}
}

//hack: this can be a little more surgical
this.panels.trackList.RemoveAndDeleteChildren();
this.initMenu();
}

static setMaxVelocity() {
Expand Down Expand Up @@ -804,4 +788,16 @@ class ZoneMenu {
this.mapZoneData = null;
this.initMenu();
}

static isSelectionValid() {
return {
track: !!this.selectedZone && !!this.selectedZone.track,
segment: !!this.selectedZone && !!this.selectedZone.track && !!this.selectedZone.segment,
zone:
!!this.selectedZone &&
!!this.selectedZone.track &&
!!this.selectedZone.segment &&
!!this.selectedZone.zone
};
}
}

0 comments on commit 6898a6e

Please sign in to comment.