Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pano zoning UI #133

Merged
merged 6 commits into from
Aug 15, 2024
Merged

Pano zoning UI #133

merged 6 commits into from
Aug 15, 2024

Conversation

PeenScreeker
Copy link
Member

@PeenScreeker PeenScreeker commented Jul 25, 2024

Closes momentum-mod/game/issues/2122

This PR implements an in-game zoning tool to replace the previous VGUI implementation. The new UI is based on the zone definition refactor to be released with version 0.10 of Momentum Mod.

Depends on red change before merging.

Checks

  • I have thoroughly tested all of the code I have modified/added/removed to ensure something else did not break
  • I have followed semantic commit messages e.g. feat: Add foo, chore: Update bar, etc...
  • My branch has a clear history of changes that can be easy to follow when being reviewed commit-by-commit
  • My branch is functionally complete; the only changes to be done will be those potentially requested in code review
  • All changes requested in review have been fixuped into my original commits.
  • Fully tokenized all my strings (no hardcoded English strings!!) and supplied bulk JSON strings below

POEditor JSON Strings (if needed)

[
    {
        "term": "#Zoning_ShowMenu_Tooltip",
        "definition": "Show zoning menu"
    },
    {
        "term": "#Zoning_HideMenu_Tooltip",
        "definition": "Hide zoning menu"
    },
    {
        "term": "#Zoning_DFFlags_Haste",
        "definition": "Haste"
    },
    {
        "term": "#Zoning_DFFlags_Slick",
        "definition": "Slick"
    },
    {
        "term": "#Zoning_DFFlags_DamageBoost",
        "definition": "Damage Boost"
    },
    {
        "term": "#Zoning_DFFlags_Rockets",
        "definition": "Rockets"
    },
    {
        "term": "#Zoning_DFFlags_Plasma",
        "definition": "Plasma"
    },
    {
        "term": "#Zoning_DFFlags_BFG",
        "definition": "BFG"
    },
    {
        "term": "#Zoning_TrackListLabel",
        "definition": "Track List"
    },
    {
        "term": "#Zoning_New",
        "definition": "New"
    },
    {
        "term": "#Zoning_Delete",
        "definition": "Delete"
    },
    {
        "term": "#Zoning_PropertiesLabel",
        "definition": "Properties"
    },
    {
        "term": "#Zoning_MaxVelocity",
        "definition": "Max Velocity (Map-wide)"
    },
    {
        "term": "#Zoning_StagesEndAtStageStarts",
        "definition": "End segments at next segment start"
    },
    {
        "term": "#Zoning_DefragFlags",
        "definition": "Defrag bonus settings"
    },
    {
        "term": "#Zoning_DefragFlags_Edit",
        "definition": "Edit flags"
    },
    {
        "term": "#Zoning_LimitGroundSpeed",
        "definition": "Limit ground speed"
    },
    {
        "term": "#Zoning_CheckpointsRequired",
        "definition": "Checkpoints required"
    },
    {
        "term": "#Zoning_CheckpointsOrdered",
        "definition": "Checkpoints ordered"
    },
    {
        "term": "#Zoning_Name",
        "definition": "Segment name"
    },
    {
        "term": "#Zoning_Filter",
        "definition": "Zone filter"
    },
    {
        "term": "#Zoning_Filter_None",
        "definition": "No filter"
    },
    {
        "term": "#Zoning_Region",
        "definition": "Region"
    },
    {
        "term": "#Zoning_CreateRegion_Tooltip",
        "definition": "Add new region to this zone"
    },
    {
        "term": "#Zoning_DeleteRegion_Tooltip",
        "definition": "Delete the selected region"
    },
    {
        "term": "#Zoning_GridSnapSize",
        "definition": "Grid snap (default 8)"
    },
    {
        "term": "#Zoning_RegionPoints_Tooltip",
        "definition": "Edit region corners"
    },
    {
        "term": "#Zoning_RegionProperties_Tooltip",
        "definition": "Edit region properties"
    },
    {
        "term": "#Zoning_RegionTeleport_Tooltip",
        "definition": "Edit region teleport destination"
    },
    {
        "term": "#Zoning_EditPoints",
        "definition": "Pick points"
    },
    {
        "term": "#Zoning_RegionDetails_Bottom",
        "definition": "Bottom"
    },
    {
        "term": "#Zoning_RegionDetails_Height",
        "definition": "Height"
    },
    {
        "term": "#Zoning_RegionDetails_SafeHeight",
        "definition": "Safe height"
    },
    {
        "term": "#Zoning_RegionDetails_TPDest",
        "definition": "Teleport destination"
    },
    {
        "term": "#Zoning_TPDest_None",
        "definition": "No target"
    },
    {
        "term": "#Zoning_TPDest_MakeNew",
        "definition": "Specify new"
    },
    {
        "term": "#Zoning_TPDest_Position",
        "definition": "Position"
    },
    {
        "term": "#Zoning_TPDest_Yaw",
        "definition": "Yaw"
    },
    {
        "term": "#Zoning_Save",
        "definition": "Save zones"
    },
    {
        "term": "#Zoning_CancelEdit",
        "definition": "Cancel edit"
    },
    {
        "term": "#Zoning_Bonus",
        "definition": "Bonus"
    },
    {
        "term": "#Zoning_Segment",
        "definition": "Segment"
    },
    {
        "term": "#Zoning_EndZone",
        "definition": "End zone"
    },
    {
        "term": "#Zoning_CancelZone",
        "definition": "Cancel"
    },
    {
        "term": "#Zoning_Start_Track",
        "definition": "Start zone"
    },
    {
        "term": "#Zoning_Start_Stage",
        "definition": "Stage start"
    },
    {
        "term": "#Zoning_Delete_Message",
        "definition": "Delete selection"
    },
    {
        "term": "#Zoning_Cancel",
        "definition": "Cancel"
    }
]

@PeenScreeker PeenScreeker force-pushed the feat/zone-menu branch 4 times, most recently from 10b1ecf to 368b5f7 Compare July 27, 2024 20:10
@PeenScreeker PeenScreeker marked this pull request as ready for review July 27, 2024 20:12
@PeenScreeker PeenScreeker changed the title DRAFT: Pano zoning UI Pano zoning UI Jul 27, 2024
@PeenScreeker PeenScreeker force-pushed the feat/zone-menu branch 5 times, most recently from 553c9d0 to f456304 Compare August 1, 2024 01:11
Copy link
Member

@tsa96 tsa96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot of nits and small TypeScript things, sorry to be annoying. Generally, you shouldn't need to cast at all as much as you're doing. We should probably turn off strict mode in the future anyway, but to assert that something is non-null to make TS happy, use ! instead of casting T | null to T.

Haven't read everything in detail yet, wanted to do a first pass tonight . I'll try stuff out in-game and give some UI/UX comments tomorrow.

Great work getting this in!

Comment on lines +62 to +65
<Button id="ZoningOpen" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 1');$.DispatchEvent('ZoneMenu_Show');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningOpen', '#Zoning_ShowMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
<Image class="button__icon" src="file://{images}/pencil-outline.svg" textureheight="24" />
</Button>
<Button id="ZoningClose" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 0');$.DispatchEvent('ZoneMenu_Hide');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningClose', '#Zoning_HideMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these really need to be console commands? We're likely to remove GameInterfaceAPI.ConsoleCommand in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is kind of tech debt.

  1. My original intent was to allow a player to start zoning by setting mom_zone_edit 1, but if it's Ok to only get into the zoning UI with a button on the tab menu, no sweat.
  2. There are some things handled in c++ by the existing zone editing code that need to be moved over to the new files. These are convars like grid size, and the code that generates the 3D crosshair.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay nbd - what's the long-term plan then? Note that we have $.RegisterConVarChangeListener now!

layout/pages/zoning/zoning.xml Outdated Show resolved Hide resolved
layout/pages/zoning/zoning.xml Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
Comment on lines +575 to +614
//@ts-expect-error property must be optional
delete region.teleDestPos;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grr

scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
@tsa96
Copy link
Member

tsa96 commented Aug 1, 2024

Don't think we should be merging this into master btw, 0.10 branch is fine.

@PeenScreeker PeenScreeker changed the base branch from master to feat/mom-0.10 August 2, 2024 02:47
@PeenScreeker PeenScreeker force-pushed the feat/zone-menu branch 2 times, most recently from e2835f6 to 4514331 Compare August 2, 2024 05:23
Copy link
Member Author

@PeenScreeker PeenScreeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a first pass at these comments. Still got a few to address

Comment on lines +62 to +65
<Button id="ZoningOpen" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 1');$.DispatchEvent('ZoneMenu_Show');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningOpen', '#Zoning_ShowMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
<Image class="button__icon" src="file://{images}/pencil-outline.svg" textureheight="24" />
</Button>
<Button id="ZoningClose" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 0');$.DispatchEvent('ZoneMenu_Hide');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningClose', '#Zoning_HideMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is kind of tech debt.

  1. My original intent was to allow a player to start zoning by setting mom_zone_edit 1, but if it's Ok to only get into the zoning UI with a button on the tab menu, no sweat.
  2. There are some things handled in c++ by the existing zone editing code that need to be moved over to the new files. These are convars like grid size, and the code that generates the 3D crosshair.

layout/pages/zoning/zoning.xml Outdated Show resolved Hide resolved
}

const selectButton = newTracklistPanel.FindChildTraverse('SelectButton') as Panel;
if (selectButton && object) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, it's always defined. fixed

scripts/pages/zoning/zoning.ts Show resolved Hide resolved
Comment on lines 285 to 286
const expandIcon = newTracklistPanel.FindChildTraverse('TracklistExpandIcon') as Panel;
const collapseIcon = newTracklistPanel.FindChildTraverse('TracklistCollapseIcon') as Panel;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
layout/pages/zoning/zoning.xml Outdated Show resolved Hide resolved
scripts/pages/zoning/zoning.ts Show resolved Hide resolved
if (teleDestIndex === 0) {
// no teleport destination for this region
region.teleDestTargetname = '';
//@ts-expect-error property must be optional
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment, let's chat about it

scripts/pages/zoning/zoning.ts Outdated Show resolved Hide resolved
@PeenScreeker PeenScreeker force-pushed the feat/zone-menu branch 8 times, most recently from 523e959 to 48b839b Compare August 9, 2024 03:05
@PeenScreeker
Copy link
Member Author

finally pushed the changes I made while flying over the weekend. This includes the margin and alignment changes we discussed

Comment on lines +62 to +65
<Button id="ZoningOpen" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 1');$.DispatchEvent('ZoneMenu_Show');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningOpen', '#Zoning_ShowMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
<Image class="button__icon" src="file://{images}/pencil-outline.svg" textureheight="24" />
</Button>
<Button id="ZoningClose" class="button horizontal-align-left" onactivate="GameInterfaceAPI.ConsoleCommand('mom_zone_edit 0');$.DispatchEvent('ZoneMenu_Hide');" onmouseover="UiToolkitAPI.ShowTextTooltip('ZoningClose', '#Zoning_HideMenu_Tooltip');" onmouseout="UiToolkitAPI.HideTextTooltip();">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay nbd - what's the long-term plan then? Note that we have $.RegisterConVarChangeListener now!

</ToggleButton>
</Panel>
</ContextMenuCustomLayout>
</root>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end?? Thought Prettier handled this, weird

expandIcon.SetHasClass('hide', !shouldExpand);
collapseIcon.SetHasClass('hide', shouldExpand);
const parent = container.GetParent();
if (parent && parent.HasClass('zoning__tracklist-segment')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent?.HasClass

@tsa96 tsa96 merged commit 5f01add into feat/mom-0.10 Aug 15, 2024
1 check passed
@tsa96 tsa96 deleted the feat/zone-menu branch August 15, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace VGUI zoning menu with Panorama
2 participants