-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add symbols editor #761
Add symbols editor #761
Conversation
9c6dce9
to
38702b3
Compare
As stated in the code, the type hint Gtk.ListStore.new seems to be incorrect. It says the function takes two parameters, but https://lazka.github.io/pgi-docs/Gtk-3.0/classes/ListStore.html#Gtk.ListStore.new says it takes one. How do I suppress this?
I copied this from existing code. Not sure what to do here.
??? |
|
@theCapypara Not sure if you saw it, but this is ready for review now. Just wanted to make sure you didn't miss it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!! I have some remarks, but nothing big.
<property name="shadow-type">in</property> | ||
<property name="propagate-natural-height">True</property> | ||
<child> | ||
<object class="GtkTreeView" id="symbols_treeview"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tree view requires horizontal scrolling in a lot of cases which is not great. However we can fix this with the GTK 4 migration. We really need to care more about smaller screen sizes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it a bit more bearable however, please switch the value and description column around. If you can figure out if there is a good way to make it so that only a small portion of description is shown by default and there is a way to show more details that would be even better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tree view requires horizontal scrolling in a lot of cases
Does it? I've never had to scroll horizontally. My screen resolution is on the high end (1080p), but there's always some space available on the right side.
The easiest fix would be to reduce the width limit for the description column, but I want to make sure it's necessary first. It might look worse in bigger screens if we do.
new_value_final = str(int(_id)) | ||
self.on_value_changed(path, new_value_final) | ||
|
||
def on_value_changed(self, path: str, new_value: str, model_iter: Optional[Gtk.TreeIter] = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add visual feedback when any row is changed. There should be an asterisks for unsaved changes similiar to how it is done in the main item tree. Maybe make changed rows bold as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where exactly should the asterisk appear? I don't think I can access the individual cells to change the text.
Bolding should be doable though. Do I just bold the entire row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
As for the asterisks, there are a few options, potentially the eaiest is to add a new cell renderer to the first column that renders a column in the store that either contains "" or "*", this is similiar to how it works in the main item store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh... how do I know when the ROM has been saved so I can restore the normal text display?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. I don't remember if there is a hook for that, maybe not. But tbh I think it's also fine if you don't reset it while the symbol editor is still open for now.
I guess another issue is also that you don't know what changed when you re-open. But that is also fine.
I guess this way it's more like a "this is what you changed since you last opened the symbol editor". In that case just using bold is probably better, no asterisk, since the asterisk is assosiated with the ROM itself not being saved, that might confuse people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright then, just bold for now.
from skytemple_files.hardcoded.symbols.manual.enums import get_enum_values, get_all_enum_types | ||
from skytemple_files.hardcoded.symbols.unsupported_type_error import UnsupportedTypeError | ||
|
||
_instance: "ModelGetter | None" = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put from __future__ import annotations
at the top of all source files and then use regular type annotations (not strings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhhh, so that's how you avoid ImportErrors when referencing a type before or during its declaration. The only workaround I knew was using a string to declare the type. Good to know.
I've changed it in all files that needed it. Why should it be included in the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just like to have it everywhere so Python parses the annotations consistently everywhere. Having that future enabled changes the runtime characteristics of annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be done
get() instead. | ||
""" | ||
if do_not_instantiate != self._instantiation_string: | ||
raise ValueError("This class cannot be directly instantiated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to use Python's __new__
for a singleton pattern, but this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elaborate, please? This is the only way I know right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Adds a new screen that can be used to view and edit the value of data symbols defined in pmdsky-debug. Requires SkyTemple/skytemple-files#505.
The new screen supports editing values as text. Symbols of known enum types use dropdowns or autocomplete textboxes, so the user can check the list of valid values. Boolean values use checkboxes. If the user inputs an invalid or out of range value, an error message is displayed.
Now that this editor exists, I see little purpose for the view located under Patches > Symbols. Maybe we should consider removing / hiding it.
I also think that Lists > Misc. Settings is outdated now, and I wouldn't mind removing it, mainly because:
But I don't have a strong opinion on the matter, it's just a suggestion.