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

Better editor undo redo #176

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Better editor undo redo #176

merged 3 commits into from
Jan 29, 2024

Conversation

gotmachine
Copy link
Contributor

@gotmachine gotmachine commented Jan 7, 2024

See #172

In stock, undo state is captured after part events are complete, and undoing will restore the state captured before that.
This make the user experience quite poor as undoing will loose all PAW tweaks made in between attach/detach actions.
This patch invert the undo/redo state capture logic, by moving state capture before attaching / detaching instead of after, and by capturing the current state when undoing is requested, in case a redo is requested next (see the RestoreState() patch)

Unfortunately, the crew assignement (VesselCrewManifest) is updated based on the last serialized undo state, so doing this notably result in the crew assignement window being out of sync with the ship current state. To fix this, after attaching or detaching, we call a reimplementation of the VesselCrewManifest update using the live ship state instead of the serialized state.

Still, due to many mostly unrelated code paths being triggered from the undo/redo code, this patch introduce a bunch of unavoidable behavior changes. We fix the most obvious, ie GameEvents.onEditorShipModified.Fire() being called before attach/detach, but this still introduce other more subtle shared/static state changes, which might cause weird side effects in plugins.

Here are binaries with the changes :
KSPCommunityFixes_1.34.0_BetterEditorUndoRedo.zip

It would be nice to get some testing on this. Things to look for :

  • Weirdness when undoing/redoing
  • Inconsistencies between parts shown in the crew assignement window and the current ship
  • General weirdness with in-editor crew state (life support mods ?)
  • General weirdness / behavior changes with in-editor mods relying on the ship state in a way or another

@gotmachine gotmachine added the kspQoL Quality of life modification label Jan 7, 2024
@JonnyOThan JonnyOThan merged commit e7a1f50 into dev Jan 29, 2024
1 check passed
JonnyOThan added a commit that referenced this pull request Jan 30, 2024
* New KSP QoL/performance patch : [**LowerMinPhysicsDTPerFrame**](#175) : Allow a min value of 0.02 instead of 0.03 for the "Max Physics Delta-Time Per Frame" main menu setting. This was already possible by manually editing the `settings.cfg` file, but changes would revert when going into the settings screen.

* Add tooltip describing the "Max Physics Delta-Time Per Frame" main menu setting

* merging master to dev (#181)

* zh-cn localization for ManufacturerFixes.cfg (#178)

* Remove ENABLE_PROFILER define that got added recently

---------

Co-authored-by: zhangyuesai <zhangyuesai@live.com>

* Fix #182: ModulePartInventory now accounts for changes to a part's mass or volume
-for example, changing a part's variant (rcs thruster blocks, structural tube) or its resource level could change its mass, but when you store it in inventory the mass would always use the value from the prefab

* oops, revert a couple changes to the csproj that made it into the last commit by accident

* Fix #185: calculate the correct mass for parts when picking them up off the ground in EVA construction

* Fix #104 : set dead kerbals to missing when loading a game and respawning is enabled

* Standardize spaces for indent in .editorconfig and add it to the SLN
(note personally I'd prefer tabs for indents, but all the existing code in here that didn't come from me uses spaces and consistency is more important)

* Change tabs -> spaces in the few files that used it
Whitespace-only change.
(note most of these were originally authored by me, but the project as a whole uses spaces pretty consistently)

* Fix #180: add ZeroCostTechNode patch

* Better editor undo redo (#176)

* BetterEditorUndoRedo : Exploratory fix for undo/redo state, doesn't work because of VesselCrewManifest side effects
See #172

* BetterEditorUndoRedo : functional, obvious issues fixed, still likely to cause side effects.

* disable BetterEditorUndoRedo by default

---------

Co-authored-by: JonnyOThan <jonnyothan@gmail.com>

* PAWGroupMemory is no longer per-window, but rather per-group (#186)

* Fix #50: PAWGroupMemory is no longer per-PAW, but stores the expansion state for all windows and is not cleared on scene changes
-possible future work: persist the collapse state to disk

* collapse or expand PAW groups when the PAW is shown

* Fix #179: ModulePartVariants now applies node position changes in all scenes

* enable BetterEditorUndoRedo by default

* Merge master -> dev (#187)

* zh-cn localization for ManufacturerFixes.cfg (#178)

* Remove ENABLE_PROFILER define that got added recently

---------

Co-authored-by: zhangyuesai <zhangyuesai@live.com>

* update readme with the new fixes

---------

Co-authored-by: gotmachine <24925209+gotmachine@users.noreply.github.com>
Co-authored-by: zhangyuesai <zhangyuesai@live.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kspQoL Quality of life modification
Development

Successfully merging this pull request may close these issues.

None yet

2 participants