-
Notifications
You must be signed in to change notification settings - Fork 42
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
SubLayouts TODO/Wishlist #141
Comments
Have you considered changing how all of your column/row calculations are stored/performed, from reading it form the initial spreadsheet, to passing it to the translator, to including extra defines/overrides and then even more SubLayout key/value pairs from the parent? If all values were parsed per row, then passed around as key-value dictionaries, then it could simplify how the translator works, at the minor cost of rebuilding the dictionaries when changing rows in the spreadsheets. It also means that incorporating the custom _defines, as well as many nested layers of Primary Layouts, becomes trivial, because you just override any existing keys with their new values, then append the rest. Currently you have a more space efficient method, and possibly marginally faster since each row is already in the same order, but it comes at the cost of programmability/extensibility. The Translators would only care about taking their one dictionary input, and the actual functioning/lookup of them would be effectively identical. It decouples the Translators from the Deck a lot more, and means that passing in arbitrary values with the dictionaries can give easier results (such as filenames). Random string needs to be translated: here's the string and the dictionary and you've got your result. At the moment, that's really hard to do because the keys are stored in one place, in a particular order, and the values are stored elsewhere. Appending them is extremely difficult and has led to the current method of having lookup overrides. The way I coded the key/value appending originally (before you showed me how it actually works) was to have each PrimaryLayout append/overwrite all of it's values into the SubLayout, and if that SubLayout become its own parent layout, then even the fields passed in from another PrimaryLayout would be passed on in the dictionary to the grandchild SubLayout. |
For protecting against SubLayout cycles, we can keep a running List inside each CardExporterBase (of the name of each PrimaryLayout above it), then if we encounter that the next SubLayout is already in that list we can cancel the cycle. |
I would love to have the functionality for SubLayout in-memory rendering, but then the question becomes how to reference them? Currently, my PrimaryLayout is using a @[ShipType Unique] field in the spreadsheet which declares the name of the suffix of the outputted file from the SubLayout. Then in the SubLayout, it has its own Named ID which I'm using in the Filename override field as Unique_Ship_@[ShipType]. Then in the display of the PrimaryLayout's graphics, it's checking if @[ShipType Unique] is empty, and if it is, then it grabs Normal_Ship_@[ShipType] from the SubLayout, otherwise it grabs the Unique one. This means that I currently have a SubLayout with 10 Normal_Ship_@[ShipType] in it, that never change except for the colors that are inherited from the ParentLayout, but my SubLayout ALSO has a bunch bunch bunch of other Unique_Ship_@[ShipType] which are variations on the base Ships, but still need the colors/icons from the PrimaryLayout. The colors can change (in the PrimaryLayout), and some of the Unique ships will exist on multiple PrimaryLayout cards, so I don't want to have them as a separate non-SubLayout. Also, I really want to keep consistent sizing/spacing/positioning of the elements between the Unique and the Normal Ship info, so I'm try to avoid having two essentially identical Layouts with identical columns, but different rows, and simultaneously have to make duplicate entries for multiple sets of colors. If I've already got the functionality to duplicate the PrimaryLayout colors to any necessary SubLayout cards, that's what I want. This hopefully makes it more clear why #noccarddraw would be so useful, because I can check for @[ShipType Unique] inside each SubLayout card, and for only that PrimaryLayout, I can disable the rendering/saving for the Normal or Unique card, as necessary. Also, technically it's not @[ShipType Unique] in the SubLayout, it has a field called @[ShipType] and I'm checking for @[@[ShipType] Unique] when I'm inside the SubLayout (to get which card is correct for the PrimaryLayout). |
As for logging, I think log-only level of reporting for the SubLayout is acceptable, since the SubLayout itself can also be checked as a regular Layout for issues/errors. |
🤣 I was asking myself the same sorts of questions the other day. I'll have to investigate if there is some critical reason for not using a dictionary for the column mapping to the list of entries in a row. The reference code hasn't changed much in a decade or more so it might be time for me to revisit it a bit. Edit: did some hacking to remind myself about this... while there are a couple reasons to keep around the raw |
10/10 I agree about the override columns. They should be local-presentation overrides and not be transitive :) Though I've started using #(if @[ImageOffsetX] != #empty then $[x:#math;@[ImageOffsetX]+&[x]#] )# instead of overrides, since generally we just need to move it by a certain amount, instead of a fixed position (with my limited experience), and i find this method works really well since I also keep column names as unique as possible in the majority of my layouts, and certainly between PrimaryLayouts and SubLayouts. |
Would it be possible to get a reference &[fileextension] for the requested file type, accessible from inside a Layout/SubLayout? Then we can swap around file export types and still know which one to reference in the PrimaryLayout, and which ones to check against in SubLayout for #noexport. |
One thing missing from your implementation of the SubLayouts is the FileExportSingleCard version. |
FileExportSingleCardI'm working on the massive Dictionary change and I held off on FileExportSingleCard as a little bit of logic around initiating sublayouts will be changing too. Hopefully that's not blocking anything too critical for you. The good news is I was able to have a nested set of sublayouts export with the following nesting
fileextensionI'll add this to the wishlist above for tracking. 👍 Code Refactor: CardPrintIndex RemovalI think |
Comically large and semi-risky change to how the rows store and access their column values has been submitted: b44ce66 FileExportSingleCard should be usable now. I didn't update FileCardClipboardExporter yet (but will at some point). |
So what you're saying is that without CardPrintIndex, and by storing the count of cards in the Dictionary, we can dynamically have card counts work properly with #noexcept? cheeky smile |
From testing the new dictionaries as well as the FileExportSingleCard, they all seem to work as before, so it's cleaner, more functional, and without regression, great job! |
Wishlist: In addition to &[fileextension] can we add &[currentlayoutname] or something similar which is set to the name of the current PRIMARY layout which is being executed? That way we can add tests for if we're rendering in a sublayout or the primary or most-primary layout. |
WIP commit to protect again sublayout cycles (specifically in file card exports at this time). Bit rough but coming together. Also added
|
To protect against cycles, since you've defined ![rootlayout], you can just check if the layout you're trying to render is ![rootlayout] again and quit? |
The cycle might start at a lower level. The check I implemented looks at the entire list of layouts (in the "stack" from the root) to make sure the next SubLayout to export isn't already in the list. |
Massive update with hopefully no new issues... image cache is the spot I might expect some problems from. 9570d31 ❗ The main point to highlight for those relying on exported file sublayouts is the section below: SubLayout Elements (Updated)
The new aspect is there are now two parameters supported:
Full examples:
Define splitter changeddefines and values are now split with double SubLayouts as In-Memory-Only ExportsNow all SubLayouts export into a Bitmap cached in memory by default. They can optionally write to files as well (but you must specify a format). SubLayouts exports can be accessed via their export name format with no extension. These may overwritten with subsequent SubLayout exports (of course). New variables
... hopefully I covered everything, ha! |
I'm really curious about the in-memory method. Do you feel like it will save time avoiding the file round-trip? I'll check out the performance of all of this too. |
The file write/read for every nested sublayout adds some additional processing time (IO waits etc.). No need to thrash someone's hard drive unless they really want to. 🔥 |
I dropped the folder and .png from all of my SubLayout references, and the memory-based method works amazingly well. I'm a fan. It also seems faster. |
Both
The |
I thought they seemed correct before, deckindex/cardindex, since the cardindex was where we were in the deck, and I thought the deckindex was the index of the layout inside the list of layouts. But thanks, I've made my fix and ![deckindex] definitely works as expected now, thanks |
I found a bug: Disabling a SubLayout Element still forces execution of the SubLayout reference, but I think that should only happen if the SubLayout Element is enabled. |
Bug fixed: 24e1412 |
I've seen the light and understand better now one of the ideas/issues you mentioned earlier: I think you're right that having control over which card(s) in the SubLayout run could be a good thing. For example, I want to create a PrimaryLayout which is just a lower-resolution version of a SubLayout, which is itself a PrimaryLayout at extremely high resolution. (Custom control over thumbnails) Doing it as such, there's N^2 iterations of the Main layout. Changing the definition to |
Reference cache enabled during exports (applies to CSV/Excel references automatically): 784886f This should improve sublayout export speeds and cut down on unnecessary hard drive reads. ... assuming I didn't totally break things. 🤣 🙄 Edit 2: Added
New part: |
Can confirm |
TODO/wishlist items for consideration
Investigate removal ofCardPrintIndex
completely. It is likely legacy and should be considered for removal.[low priority] This is really just for the benefit of the code being less complicatedFunctionality to export SubLayout to in-memory image for useAddexportindices
sublayout parameter (reuse the export index logic from the command line and export to convert1-3
etc.)Reference Cache for files (at least during export)Add SubLayout parametersskipReferences
(don't pass the reference values from parent -> sublayout)skipDefines
(don't pass the defines from parent -> sublayout)Passing custom defines to a SubLayout (as defines via key/value).Translations:Add fileextension translation as related to exports (to know the file type being exported, probably just pass along the enum value)Parent layout namePrimary layout name (top)Investigate the dangers of nested SubLayoutsProtect against SubLayout loopsPassing the line information from parent through to all sublayouts in the stack (currently it's just parent -> sublayout each time)Passing defines through to the SubLayout (not sure how much use this would get)Need to double check if there is special processing for defines that might make this more difficultFileCardClipboardExporter support (should be minimal)PDF exporter supportWrite instructions (at least the basics) and make a pre-release for people over at BGG to test.References
Original ticket: #121
The text was updated successfully, but these errors were encountered: