Skip to content

Commit

Permalink
WIP more region details
Browse files Browse the repository at this point in the history
  • Loading branch information
PeenScreeker committed Jul 25, 2024
1 parent 97dcc0b commit 7253125
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
5 changes: 3 additions & 2 deletions layout/pages/zoning/zoning.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<Panel id="Filter" class="zoning__property">
<Label class="zoning__property-label" text="#Zoning_Filter" />
<DropDown id="FilterSelect" class="dropdown zoning__dropdown" menuclass="dropdown-menu" onuserinputsubmit="ZoneMenu.updateZoneFilter()">
<Label text="#Zoning_Filter_None" />
<Label text="#Zoning_Filter_None" value="0" />
<!-- Populated in js -->
</DropDown>
</Panel>
Expand Down Expand Up @@ -192,7 +192,8 @@
<Label class="zoning__property-label" text="#Zoning_RegionDetails_TPDest" />
<DropDown id="RegionTPDest" class="dropdown zoning__dropdown" menuclass="dropdown-menu" onuserinputsubmit="ZoneMenu.updateRegionTPDest()">
<!-- Populated in js -->
<Label text="#Zoning_MakeNewDest" />
<Label text="#Zoning_TPDest_None" value="0" />
<Label text="#Zoning_TPDest_MakeNew" value="1" />
</DropDown>
</Panel>
<Panel class="zoning__property">
Expand Down
43 changes: 31 additions & 12 deletions scripts/pages/zoning/zoning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ class ZoneMenu {

//@ts-expect-error function name not recognized
const entList = $.GetContextPanel().getEntityList();
this.filternameList = entList.filter;
this.teleDestList = entList.teleport;
if (this.filternameList) {
this.filternameList = entList.filter ?? [];
this.teleDestList = entList.teleport ?? [];
if (this.filternameList !== null) {
this.filternameList.unshift($.Localize('#Zoning_Filter_None') as string);
this.populateDropdown(this.filternameList, this.panels.filterSelect, '', true);
}
if (this.teleDestList) {
if (this.teleDestList !== null) {
this.teleDestList.unshift($.Localize('#Zoning_TPDest_MakeNew') as string);
this.teleDestList.unshift($.Localize('#Zoning_TPDest_None') as string);
this.populateDropdown(this.teleDestList, this.panels.regionTPDest, '', true);
Expand Down Expand Up @@ -379,8 +379,9 @@ class ZoneMenu {
this.panels.regionHeight.text = (region?.height ?? 0).toFixed(2) as string;
this.panels.regionSafeHeight.text = (region?.safeHeight ?? 0).toFixed(2) as string;

const tpIndex = region.teleDestTargetName ? this.teleDestList?.indexOf(region.teleDestTargetName) ?? 0 : 0;
const tpIndex = region.teleDestTargetName === '' ? 0 : this.teleDestList?.indexOf(region.teleDestTargetName) as number;
this.panels.regionTPDest.SetSelectedIndex(tpIndex);
$.Msg('TP Index: ', tpIndex)
}

static addRegion() {
Expand Down Expand Up @@ -449,19 +450,33 @@ class ZoneMenu {
//delete region.teleDestPos;
//delete region.teleDestYaw;
// disable pos/yaw text entry
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;
} else if (teleDestIndex === 1) {
const position: Vec3D = { x: 0, y: 0, z: 0 };
for (const [_, point] of region.points.entries()) {
position.x += point.x;
position.y += point.y;
if (!region.teleDestPos || !region.teleDestYaw) {
region.teleDestPos = { x: 0, y: 0, z: 0 };
for (const [_, point] of region.points.entries()) {
region.teleDestPos.x += point.x;
region.teleDestPos.y += point.y;
}
region.teleDestPos.x /= region.points.length;
region.teleDestPos.y /= region.points.length;
region.teleDestPos.z = region.bottom;
region.teleDestYaw = 0;
}
position.x /= region.points.length;
position.y /= region.points.length;
position.z = region.bottom;


this.panels.regionTPPos.x.text = region.teleDestPos.x.toFixed(2);
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;
Expand All @@ -472,6 +487,10 @@ class ZoneMenu {
//delete region.teleDestPos;
//delete region.teleDestYaw;
// disable pos/yaw text entry
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;
Expand Down
6 changes: 6 additions & 0 deletions styles/pages/zoning/zoning.scss
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,11 @@ $medium: 28px;
horizontal-align: right;
margin-left: 16px;
width: 80px;

&:disabled,
&:disabled:hover {
background-color: $textentry-background;
color: $textentry-text-disabled;
}
}
}

0 comments on commit 7253125

Please sign in to comment.