-
Notifications
You must be signed in to change notification settings - Fork 45
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
Rework special node button dictionary #607
Comments
Oh dear... Somehow I'd never seen this before now. Line 583 in e83ad32
My gut reaction is that I hate it. |
What if the information was encoded as XML, which was written by a WYSIWYG editor showing what the edit special node dialog would look like when the node's definition was parsed? |
That sounds like extreme overkill for something that's only going to be edited by developers… it's not the most terrible of ideas, but I don't think I like it. |
Basically what that means is that the magic characters are only parsed at startup – the scenario editor code doesn't need to understand them, instead using an enum. This is part of the work for #607
I got started on trying to clean this up. The above commit defines the structure of how the information should be in memory, while retaining the magic characters during loading. Any comments are welcome. |
I was baffled recently by trying to parse through this area of code the other day: 3bd4adc#diff-176a6d3d8f719743296a0862725f49ddc4706bde78837e720bec1ab78b9c6200L880 And I can say that it is a lot more readable with enums than with magic characters as the case labels. |
Does it seem like the above WIP commit might be going in the right direction? (Pay the closest attention to the newly-added file.) |
Seems like you accidentally deleted the weight field from item.hpp? But I really like the way it's going, with the builder pattern. It's much more readable to see which node has which properties. (The only thing about the builder pattern is, it's only readable if you recognize it & know how it works. When I first saw |
Considering various ways of formatting this. The above commit shows "compact" style in specials-general and specials-oneshot, but "verbose" style in specials-affect. Beyond the difference shown there, there are a few other options:
There's no need to respond to this, but if you have any thoughts on the matter at all, feel free to let me know. |
I don't think I mind the verbose style. I do think |
I think that completes the rework of the button dictionary? It looks like the pickers are working correctly still. |
It can't really break the game, can it? Just the editor? |
It can actually break the game, since this structure is also used by the function that parses special nodes from a file. |
Basically what that means is that the magic characters are only parsed at startup – the scenario editor code doesn't need to understand them, instead using an enum. This is part of the work for #607
Basically what that means is that the magic characters are only parsed at startup – the scenario editor code doesn't need to understand them, instead using an enum. This is part of the work for #607
Basically what that means is that the magic characters are only parsed at startup – the scenario editor code doesn't need to understand them, instead using an enum. This is part of the work for #607
Basically what that means is that the magic characters are only parsed at startup – the scenario editor code doesn't need to understand them, instead using an enum. This is part of the work for #607
The special node
button_dict
(in special.cpp) encodes what sort of button should be placed on each special node field and what kind of picker should appear when that button is pressed. It's encoded as 2-dimensional arrays with each ASCII character having a different meaning. It's quite compact and works just fine, but actually editing it to fix issues or add a new type is rather painstaking.I'm trying to think of a better way to do it that's easier to edit while not being overly verbose. This is in service of eventually adding several new picker types (including some dynamic pickers), as well as a "simple toggle" case which replaces the entire field with an LED.
Ultimately what it needs to do is to populate a
node_properties_t
struct for each possible special node type. Directly declaring the array ofnode_properties_t
would probably be possible but feels like it would be overly verbose.The text was updated successfully, but these errors were encountered: