-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Added a "re-download" button to the mod management screen #14192
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
base: master
Are you sure you want to change the base?
Conversation
…loads based on the on-file url, not the url fetched from the online lookup. Useful for updating mods which haven't been officially published yet, or fixing corrupted mods.
|
Welcome! But I'm a nitpicker... These are for now unverified, I may edit this post later
|
|
Thanks for reviewing my PR! Don't worry about nitpicking; I am all ears. The main problem I had with those two classes is that ModInfoAndActionPane.kt has the buttons and uses the on-disk urls (for lack of a better word), and ModManagementScreen.kt has the download functions (private) and uses the queried urls from github yk looking for those tagged published mods. Honestly this "solution" is the 1st thing I found that worked but I believe you that there has to be a better way! :) With that said, here are some thoughts on your point.
|
|
As I said, to make those "brainstorm" entries more useful, I would have to check sources myself, means invest more time than I can at the moment. Sorry.
Not your fault. That's grown code soup. Mostly my fault, but whenever I think 'just rewrite the damn screen' (making it mostly a sortable grid where the distinction online/local/both is shown in the cells, not by segregating them, and a pane to its right encompassing the current buttons, filter, bottom description and everything already in ModInfoAndActionPane)... then I remember 'oh then you'd have to rewrite the entire backend too to get a grip on exception handling, on background job cancellation, and enforce a provider interface model where GitHub can be just one specialization...' - ouch. |
|
lol well imho unciv is pretty clean for a highly complex, decade running, open source hobby project! My tech philosophy in life is increasingly "If it works, don't touch it!". :)
|
|
OK, first find: Unciv/core/src/com/unciv/ui/screens/modmanager/ModInfoAndActionPane.kt Lines 132 to 140 in 8da4987
Called here: Unciv/core/src/com/unciv/ui/screens/modmanager/ModManagementScreen.kt Lines 614 to 617 in a58a032
So - the parent already 'injects' a kind of re-download mod button into the ModInfoAndActionPane, doing the actual DL itself. That should be adapted/leveraged/copied for your usecase somehow. I guess the uses are mutually exclusive? Think so, yes. Then one could offer the button with changing text as long as any useable uri is known. Leads to the next investigation... This here: Unciv/core/src/com/unciv/logic/github/Github.kt Lines 212 to 214 in 8da4987
... not sure atm (don't wanna look, avoid prejudices) where your code gets its uri from, but it just might be it would only work within one Unciv run, so - we should probably persist the source up there in all cases. Question is, do we put the direct_zip_url into modUrl or do we generously add a persisted field to ModOptions which will exist only on "direct" downloads ... I would 6:4 tend to the latter. I'm also rusty about what 'massaging' happens after you provide a download uri directly, there are some checks to recognize actual github sources and dodify fields accordingly - I just recently did something to ease testing older versions of mods via the per-commit-archive uri, and don't remember what that would leave in which field. I guess I'll have to run some downloads to look...
... to be continued ... |
That's a "copy link to clipboard" and has a tutorial mention - or it should. No, considering I now think the button would appear only for DLs via direct links, that's perfectly fine, no risk of confusion, and clear enough not doc is needed... ... and by now I'm sure we should persist the "direct zip" uri in ModOptions, as in my tests the modUrl field will in most cases get the repo "home" url correctly, and that's good, and needed for the button just mentioned. Also the code in Look. If you're well set up (Studio, local branches...) this should be easy: Tested superficially with this link: Caballero-Arepa/Barbarian-xp-farm@d35d01b Note this would offer the button ONLY for mods loaded with the "Download mod from URL".toTextButton(), and then only when it wasn't a plain repo homepage link which could successfully be queried via the GH api. Links to branches, tags, commits or zips hosted elsewhere should work - but only after DL'ing once with that code. |
|
Oh boy let me dig into this and update my branch with your ideas, thanks for the help! |
|
That |
|
Maybe related to this, how about always fetching updates based on the on-file url? There have historically been issues with mods not being updated by the maintaner so the mod had to be cloned, updated, and published by a different Github user, but with same name for compatibility (savefile editing has become difficult due to new security measures). Installing currently requires deletion of the old mod and reinstall from url the new mod, and "updating" the mod in mod overview screen overwrites the new mod by the old one (presumably matching on name and then taking the oldest/highest starred mod). Instead, one needs to update by deleting the mod and then doing a new install from URL, which is inconvenient and has been the cause of problems and confusion for users. See discussion history in "A Game for ages" thread: https://discord.com/channels/586194543280390151/1231258844789735514 |
Generally - no, the 'model' has always been: the name alone is the key, and the mods a set - highlander 'there can be only one'. That has been baked in into too much code to change easily. The usecase is valid though -> our trivial answer would be 'a running game isn't that valuable that you couldn't abandon it or finish with the unmaintained mod'...
You know what, those same-name mods might even be provoking UI bugs. There's something I haven't been able to pin down with the middle column going mad right after a download... Stuff appearing above 5Hex even though it still has most stars and sort still is by star... But every time I try to repro I can't. I see it only when I haven't got the debug breakpoints I'd need to investigate. And haven't got enough energy to hunt. |
|
I haven't dropped this. Just work and home got busy this past week. |
|
By now I am 90% convinced we should start saving the direct url and maybe some of the other info - like: did we recognize a branch url / tag / commit - right in |
Downloads based on the on-file url, not the url fetched from the online lookup. Useful for updating mods which haven't been officially published yet, or fixing corrupted mods.