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

My changes since 2023-09-24 #60

Open
wants to merge 78 commits into
base: develop
Choose a base branch
from
Open

Conversation

gavrant
Copy link

@gavrant gavrant commented Sep 30, 2023

EDIT: A human-readable version of the changes can be found here: https://github.com/gavrant/nifskope/releases

…in List" mode

Fixed File -> Reload menu item being enabled on file load even if NifSkope fails to load the file.
Reason: the constructors of NifModel and KfmModel call clear() which do can produce errors in header setup (it already happened twice in my practice), and it would be better if those errors are shown to the user instead of being ignored in release builds.
…ifItems.

This is an "early access" code, committed for preview and trying it out.
Read the first comment for this commit on Github for more details.
- When no mesh file is loaded, whether it's a new window or a failure to load a file, the main window is switched to the "clean state": empty Block List, Block Details and Header, disabled Save, Reload, Import, Export, Render and Spells menus (including the right click ones and spells hot keys).
- Fixed subitems in Import/Export menus not being properly enabled/disabled on loading mesh files of different versions in a single main window.
- When Block List is in the list mode (View -> Block List -> Show Blocks in List), its "Expand all" and "Collapse all" buttons are hidden now.
- Auto-expand "BS Header" field in the mesh header in Header and Block Details. All "non-applicable" rows in the header are now hidden, whether "Show Non-applicable Rows" option is off or on (in the current nif.xml, all fields in the header are conditioned to the mesh version anyway). Also auto-expand "Roots" in the footer.
- Minor cleanup of NifSkope class.
…essage buffer flushed on short timer.

This allows Message::append to easily handle tens of thousands of error message without freezing the app.
Also refactored DetailsMessageBox class code.
- Rewrote the Import/Export menu management code in a better style.
- Fixed Help -> Interactive Help menu item doing nothing.
- Render menu now will be active when no file is loaded (it's basically just user settings, no point disabling it).
- Fixed some dialogs (transform edit, "About NifSkope" and several others) not getting keyboard focus on being opened.
- Minor refactoring of a few of my previous window modality fixes.
In other words, the UI (text, toolbar icons, etc.) will scale now according to the OS settings. Useful for high DPI displays.
See hexabits#59
Requires additional testing because I have only a 1080p display and Windows 10 at my disposal.

Note for project building: if you don't regenerate the project file from NifSkope.pro, you must add copying of qt.conf file from build folder to the folder where the NifSkope.exe is located by hand.
Thanks to Dr. Bernd Gärtner for his Miniball.hpp ( https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html ).
The new algorithm generally produces smaller bounding spheres than the old one. In the testing case on a real mesh it gave from 5% to 22% better results (smaller spheres) for different shapes, and it's quite possible that it can perform even better for some other meshes.
…ed panels when the main window is opened again

Fix 1: moved restoreUi() after show(). This is the way.
Fix 2: added a workaround for a Qt 5 bug of not restoring docked widgets properly if they are saved while the main window is maximized.
References for the Qt 5 bug (could be fixed in Qt 6):
    https://bugreports.qt.io/browse/QTBUG-46620
    https://bugreports.qt.io/browse/QTBUG-16252
    https://stackoverflow.com/questions/44005852/qdockwidgetrestoregeometry-not-working-correctly-when-qmainwindow-is-maximized

It's very likely to be a fix for hexabits#50
This is a fix for the following scenario:
If you minimize a NifSkope window and then double click on a .nif file in Windows Explorer or any other file manager, the file is opened in a new window that is also minimized and requires an additional click to bring it to the front.

+ Minor window state version refactor.
…howing a default nif, with some improvements

* Reverted the "clean state" from 99e3586 . This needs (will get?) a different approach.
* Standardized the behavior of Save, Reload, Import, Export, Header menus and the default view mode on new window/load file.
* Standardized the default selection in Block List, Block Details and Header panels on new window, loading a file or switching between the list and tree modes.
* Forced a quick update of the render view on new window (this will eliminate the view rendering nothing for 0.3 sec on opening a new window).
* Cleanup and other minor optimizations in nifskope.cpp and nifskope_ui.cpp.
@ja231c
Copy link

ja231c commented Oct 29, 2023

This breaks fractional scaling, resulting in oversized interface at 150% UI scale.
Also results in "large icons" being way too big.
Previously 150% with large icons resulted in a UI that has just the right size,
While this solves #59 it does so by making the interface unusably large at 150% UI scale.

#50 does appear to be solved though.

That being said - the viewport is cut-off at launch if you do not resize the window.

This fixes UI scales like 150% being rounded up to 200%, making the interface too big.
See hexabits#60 (comment)
@gavrant
Copy link
Author

gavrant commented Oct 30, 2023

@ja231c , I just committed a possible fix for "making the interface unusably large at 150% UI scale." Could you test it?

That being said - the viewport is cut-off at launch if you do not resize the window.

Do I correctly understand the issue as "on opening NifSkope, its main window does not fit on the screen, with its parts being cut-off"? If yes, it's probably an artefact of applying the saved sizes and positions from the old non-scaled UI to the new upscaled one. Does the issue go away if you resize and position the main window properly to fit on the screen, close NifSkope, then open it again?

General note on the whole High DPI thing: on my current 1080p config, it's rather painful to work with UI scales greater than 100%. So I would appreciate any testing and feedback from actual high DPI users.

@ja231c
Copy link

ja231c commented Oct 30, 2023

150% scale now works properly.

Although I would like to request that the "large icons" (but without extra scaling at 150%, at higher use extra scaling) be used if at 150% and up even when "large icons" are disabled (enabling "large icons" should make them bigger); reason: they're sharper than the regular icons.

Regarding the 3d viewport, screenshots here:
at start:
at_start
after resize:
after_resize

It's like the "at start" image every start, not just the first one, if it was just the first one I wouldn't even bother mentioning it.

Also, the "Windows XP" theme does not work, although this is not a problem with those changes, original Dev 9 had the "Windows" theme not functional, then there was updates that made the "Windows" theme work but the "Windows XP" not work, the problem is that the "Windows XP" theme is the better theme, more legible, more compact and all that.

@gavrant
Copy link
Author

gavrant commented Oct 30, 2023

Although I would like to request that the "large icons" (but without extra scaling at 150%, at higher use extra scaling) be used if at 150% and up even when "large icons" are disabled (enabling "large icons" should make them bigger); reason: they're sharper than the regular icons.

Wouldn't your suggestion conflict with #59? To quote its author, @GammaMetroid: "Even using the large icons option, they are still rather small on my screen".

To be clear about the whole situation with the toolbar icons, in NifSkope they are simple 36x36 or 32x32 images, not vector or multi-size "adaptive" icons, so they look nice in the "large icons" mode and with 100% UI scale (because they are not downscaled or upscaled), but become so-so in the "small icons" mode or with non-100% scales. Potentially, I can fix this by replacing the images with .svg's or something, but first I'd like to know where the current NifSkope icons came from almost 10 years ago, and this is a question to @hexabits .

Regarding the 3d viewport...

Good news: I reproduced the behavior and even found the culprit, just need some time to come with a proper fix.

the "Windows XP" theme...

That's a known issue. Rumor has it Qt broke the theme in an update. I was going to research this sometime later.

@ja231c
Copy link

ja231c commented Oct 31, 2023

#59 was about icon scale at 300% ui scale - the icons previously did not scale with ui scale at all, resulting in them being too small at extreme ui scale settings;

What I'm suggesting is using the "large icons" without any scaling when "large icons" are disabled at 150% ui scale (and with less scaling above 150%), else people at 150% and higher ui scale will have lower resolution icons after this is merged because the "large icons" are really really big when scaled to up to match ui scale.

With "large icons" enabled it should scale them like normal;
"large icons" off 150% ui scale should result in "large icons" with no scaling, as in, same behavior we have now with "large icons" enabled.

@ja231c
Copy link

ja231c commented Nov 4, 2023

I've found another issue with high dpi with these changes, namely the UV editor doesn't fill the whole window, this time resizing the window does nothing to alleviate the issue.
uv_editor_bug

gavrant added 6 commits July 23, 2024 22:30
…Data blocks

Fixes hexabits#67 , niftools#242

Bonus: refactored the NifStream code so this kind of bugs would happen less likely in the future (added asserts in strategic places, moved boilerplate code to macros or functions, and so on). This refactor also fixes a few other potential bugs on reading and writing meshes.
- Replaced the old versioning system based around build/VERSION and NifSkope.pro with a Python script that does all the work (generates src/version.h and updates README.md). Reasoning:
    - The Python script is far more flexible when it comes to flourishing version numbers with custom suffixes (that was the main goal - to add suffixes to versions to tell apart different NifSkope forks).
    - It does not involve resetting C++ project from NifSkope.pro on version update (just run the script and that's all).
    - It does not require a Cygwin installation to update README.md on Windows (I believe that nowadays it's easier to find a PC with Python 3 than find one with Cygwin).
    - It allowed to get rid of ~800 lines of code, replacing them with a handful of generated defines.
- Updating Qt framework does not always reset the UI settings anymore (only a major version change will trigger this now).
- Fixed many rough spots in importing the app settings from pre-2.0 installations and moved the code from the main window initialization to main.cpp.
- Added proper version info to NifSkope.exe (the one shown in the file's properties) as is customary on Windows.
I think it makes more sense to be at the bottom.
By integrating the uncommitted sk_multilayer.prog from hexabits posted in hexabits#65
@gavrant gavrant changed the title My changes since 2023-09-24 (UI fixes/improvements + "new style" NifItem/NifModel interface) My changes since 2023-09-24 Jul 28, 2024
gavrant added 23 commits July 29, 2024 17:02
…alls of NifSkope

Reason: the feature is too unstable ATM for it to be enabled by default, could result in corrupted mesh files.
…g Sanitize (including "Auto Sanitize" on save) and Texture -> Add spells and on importing .OBJ files

Fixes hexabits#68
Note: this does fix ALL of the "Could not find subitem" spam on importing .OBJ files, just texture-related.
Minor optimizations and code cleanup.
NodeList::clear() was suspicious, modifying the node list while looping through it in a straight forward "for" (a good opportunity to leak some memory).
Added two new data members - 'block' (NifFieldConst, as a step to minimizing the use of QModelIndex to read mesh data) and 'model' (const NifModel *, to avoid dragging the NifModel as a function argument everywhere).
Made the 2 new members and one old member ('scene') public but const because a) they are set once in the constructor and never change  during the lifetime of a IControllable; b) they are frequently needed all over the code; c) "public but const" doesn't require a getter function with a creative name to set up proper access to them.

The rest of the changes are just "refactor it as you see it".
Main result: fixed a bunch of minor bugs in them, mostly controllers not updating their data when it's changed by the user
It's WIP, not fully tested yet.
Blocks won't appear in their children branches anymore (especially true for the root "0" node).
Also optimized the whole tree population routine, cutting off roughly 70% of its execution time.
This is mostly about copy-pasting blocks but also affects other scenarios of attaching a block to another block by hand.

* Fixed blocks not being linked properly if the paste goes to a child field of the target block. Close #5 .
* Expanded the number of supported "child block - target block" combinations. It now auto-fills the following fields in the target block if the inserted child block is of a suitable type: "Data", "Skin" or "Skin Instance" in shapes; "Data" and "Skin Partition" in skin instances; "Texture Set" in shaders; "Body", "Shape" and "Data" in collisions.
* Updating Properties list in pre-Skyrim blocks became smarter (it now replaces old properties of the same type as the new one instead of just adding the new one).
* And other, lesser improvements and fixes.
…is clicked

It does make sense to give some indication that we are in the "user view" mode when it's just saved.
Close #4
* Added support for all types of blocks derived from BSShaderProperty that missed it:
    BSSkyShaderProperty (Skyrim and newer)
    WaterShaderProperty (FO3)
    TallGrassShaderProperty (FO3)
    BSDistantTreeShaderProperty (?)
    DistantLODShaderProperty (?)
    HairShaderProperty (?)
    VolumetricFogShaderProperty (?)
* Fixed FO3 shapes with SkyShaderProperty and TileShaderProperty being rendered untextured in NifSkope.
* Fixed a few minor bugs with z-buffering, texture clamping and vertex alphas in the obscurer shaders other than BSLightingShaderProperty and BSEffectShaderProperty from Skyrim+.

Close #6
Bonus: refactored and standardized code formatting in glproperty and, to a lesser degree, in renderer .cpp and .h.
…re sometimes doing nothing

"Doing nothing" == not selecting the shape/vertex/etc. at the mouse cursor.
Also introduced safeguards/fallbacks for the cases when the selection info could not be encoded into 3 RGB bytes (this should rarely happen anyway though, unless you encounter a mesh with 65535+ nodes or with 255+ shapes).
Added support for NiGeomMorpherController in NiControllerManager (FO3 or earlier?)
If a controller goes from active to inactive state (either by changing its flags or by clearing its interpolator), the render data of the controller's target is now properly reset.
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.

3 participants