Skip to content

Commit

Permalink
feat: teleport to region
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Sep 21, 2024
1 parent b66797d commit 00c6c0f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions images/eye-arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions layout/pages/zoning/zoning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<Panel id="Region" class="zoning__property">
<Label class="zoning__property-label" text="#Zoning_Region" />
<Panel class="zoning__region-property-container">
<Button id="MoveToRegionButton" class="button button--green zoning__property-button mr-2" onactivate="ZoneMenuHandler.teleportToRegion()" onmouseover="UiToolkitAPI.ShowTextTooltip('MoveToRegionButton', '#Zoning_MoveToRegion_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
<Image class="button__icon" src="file://{images}/eye-arrow-right.svg" />
</Button>
<Button id="AddRegionButton" class="button button--blue zoning__property-button mr-2" onactivate="ZoneMenuHandler.addRegion()" onmouseover="UiToolkitAPI.ShowTextTooltip('AddRegionButton', '#Zoning_CreateRegion_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
<Image class="button__icon" src="file://{images}/add.svg" />
</Button>
Expand Down
21 changes: 19 additions & 2 deletions scripts/pages/zoning/zoning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ class ZoneMenuHandler {

const collapseButton = newTracklistPanel.FindChildTraverse('CollapseButton');
const childContainer = newTracklistPanel.FindChildTraverse('ChildContainer');
const expandIcon = newTracklistPanel.FindChildTraverse<Image>('TracklistExpandIcon');
const collapseIcon = newTracklistPanel.FindChildTraverse<Image>('TracklistCollapseIcon');
if (collapseButton && childContainer) {
const expandIcon = newTracklistPanel.FindChildTraverse<Image>('TracklistExpandIcon');
const collapseIcon = newTracklistPanel.FindChildTraverse<Image>('TracklistCollapseIcon');
collapseButton.SetPanelEvent('onactivate', () =>
this.toggleCollapse(childContainer, expandIcon, collapseIcon)
);
Expand All @@ -269,6 +269,15 @@ class ZoneMenuHandler {
selectButton.SetPanelEvent('onactivate', () =>
this.updateSelection(selectionObj.track, selectionObj.segment, selectionObj.zone)
);
if (selectionObj.zone) {
selectButton.SetPanelEvent('ondblclick', () =>
this.panels.zoningMenu.moveToRegion(selectionObj.zone.regions[0])
);
} else {
selectButton.SetPanelEvent('ondblclick', () =>
this.toggleCollapse(childContainer, expandIcon, collapseIcon)
);
}

if (setActive) {
selectButton.SetSelected(true);
Expand Down Expand Up @@ -445,6 +454,14 @@ class ZoneMenuHandler {
this.updateZones();
}

teleportToRegion() {
if (!this.selectedZone || !this.selectedZone.zone) return;

const index = this.panels.regionSelect.GetSelected().GetAttributeInt('value', -1);
const region = this.selectedZone.zone.regions[index];
this.panels.zoningMenu.moveToRegion(region);
}

pickCorners() {
if (!this.selectedZone || !this.selectedZone.zone) return;

Expand Down
2 changes: 2 additions & 0 deletions scripts/types-mom/panels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ interface ZoneMenu extends AbstractPanel<'ZoneMenu'> {
getEntityList(): import('pages/zoning/zoning').EntityList;

setCornersFromRegion(region: import('common/web').Region): void;

moveToRegion(region: import('common/web').Region): void;
}

0 comments on commit 00c6c0f

Please sign in to comment.