auto load saved designs

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

auto load saved designs

#1 Post by Dilvish »

I got tired of having to manually add my saved designs; the attached patch causes them to be automatically added to the empire's designs. It is somewhat inefficient in that the completed designs listbox is repopulated entirely as each saved design is added. This didn't seem to cause a noticeable slowdown and it had taken me long enough to find a reasonable spot to do this at all so I wasn't in the mood to sort through disconnecting and reconnecting the involved signals.

Geoff, this may not be what you had in mind long term (I wonder if it perhaps could cause designs to be added to empires when in moderator mode although I don't think that should cause a significant problem), but do you view it as at least a reasonable interim step?
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#2 Post by Dilvish »

hmm, just realized this is is causing the designs to get added back after they've been deleted, so that's a nuisance. When I had previously tried other locations for this code I kept running into trouble that the added design would trigger a sequence of signals that wasn't fully connected yet, causing the game to hang. I think I'll put in a turn check so that it only loads the saved designs on turn 1. Other suggestions are welcome.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Mitten.O
Programmer
Posts: 255
Joined: Sun Apr 06, 2014 4:15 pm

Re: auto load saved designs

#3 Post by Mitten.O »

Options that spring to mind:
* A button
* A Context menu entry
Or another way to manually say you wish to load all saved. Either would be a smaller nuisance than adding each and give a clear time to do it, while having lesser cost for those who don't want to use it.
Any code by me in this post is released under GPL 2.0 or later.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: auto load saved designs

#4 Post by MatGB »

Turn check probably best.

And now we've got saved designs, which is a really nice feature, I'm thinking readdress the way we've done predefined ship designs, make them much more 'example' basic designs without any follow ups for improved tech, but that's not urgent nor particularly on topic.

Turn 1 makes most sense I think.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#5 Post by Dilvish »

Mitten.O wrote:Options that spring to mind: * A button
Yeah, that is the first option that had come to mind, but that space is already rather crowded and I didn't like the prospects of trying to squeeze in a button.
* A Context menu entry
Ah! Yes, that's a great suggestion, a context menu could offer to add the current design (if not already known to the player's empire) and/or add all the saved designs. Fairly simple to code up & doesn't add any clutter, I like it.
MatGB wrote:Turn check probably best.
That was the best I could come up with, but I think it's good to give some control to the user. An options window option could be used but I hate to add more things there -- overall I think Mitten's context menu suggestion works out best (so long as it includes an option to add all saved designs not just the single one selected).
And now we've got saved designs, which is a really nice feature, I'm thinking readdress the way we've done predefined ship designs, make them much more 'example' basic designs without any follow ups for improved tech...
I strongly agree for the most part, but I think that keeping at least a couple improved tech follow ups would be best (like a radar scout and one or more upgrades to the Cruiser, and one or two exemplars with the Organic Hull).
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: auto load saved designs

#6 Post by MatGB »

I was thinking mass driver 1, laser 1 and plasma one for the 'main' hulls and then a couple exemplars with roughly equivalent weapon, laser1 or plasma1, with scouts and similar.

Keep the workhorse "everyone uses these at least once" hulls but dump the refinements &c.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: auto load saved designs

#7 Post by Geoff the Medio »

Dilvish wrote:...I wonder if it perhaps could cause designs to be added to empires when in moderator mode...
Don't think so... which empire would it add to? And I don't think there are many / any moderator actions for issuing orders for empires; that's not what moderating is about (playing the game for players vs. modifying the universe they play in).

I don't have strong preferences about how saved designs are used / added. I assumed it wouldn't be good to assume players would always want all saved designs added by default.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#8 Post by Dilvish »

Geoff the Medio wrote:I assumed it wouldn't be good to assume players would always want all saved designs added by default.
Well, it's really quite handy, and much easier to delete an unneeded design than to manually create a needed one, and even manually adding individual saved designs can get to be a nuisance after a few designs, so I think it's pretty likely anyone using this would want to load all saved designs and then just pare them down as desired or as the game progresses and they become stale (same as with any design).

For me, having simply added the if (CurrentTurn()==1) check to the above patch is perfect because I always want them loaded. I can understand the desire to leave it as a choice for the user, in which case the right-click context menu is the desired feature. I started to implement that (with both an option to load the current individual design or all saved designs) but got sidetracked; I'll try to wrap it up in time for the next weekly builds.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: auto load saved designs

#9 Post by Geoff the Medio »

If you're worried about moderators, or even if you're not, just add a check that the client's empire id isn't ALL_EMPIRES.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#10 Post by Dilvish »

ok here is a revised patch which adds a context menu to the saved designs list, to allow adding to the player empire designs either just the current design or all saved designs. The patch makes it look like a lot of lines have changed when really most of them were just indented one level. I did leave in one little piece in DesignWnd::MainPanel::Sanitize() that's currently unnecessary:

Code: Select all

        if (CurrentTurn() == 1) {
            //GetSavedDesignsManager().LoadAllSavedDesigns();
        }
-- on my machine I'll have that uncommented so as to always autoload, I thought it would be convenient for any other devs that wanted to autoload saved designs, but I can understand that it could be considered unneeded bloat; just let me know if you want it out or if you have any other comments.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#11 Post by Dilvish »

ok well I went ahead and committed it, with just a bit more commentary; it can always be adjusted.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: auto load saved designs

#12 Post by Geoff the Medio »

Dilvish wrote:I did leave in one little piece... but I can understand that it could be considered unneeded bloat
adrian_broher might dislike it. Might be better to comment out the whole thing, instead of just the bit inside the if block.

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#13 Post by Dilvish »

Okay.

Code: Select all

r7727 | dilvish-fo | 2014-09-22 11:20:00 -0700 (Mon, 22 Sep 2014) | 1 line
follow-up on r7726, commenting out some additional currently unnecessary lines and adding explanation
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
vincele
Space Dragon
Posts: 341
Joined: Sun Mar 23, 2014 6:10 pm

Re: auto load saved designs

#14 Post by vincele »

Dilvish wrote:Okay.

Code: Select all

r7727 | dilvish-fo | 2014-09-22 11:20:00 -0700 (Mon, 22 Sep 2014) | 1 line
follow-up on r7726, commenting out some additional currently unnecessary lines and adding explanation
What about an option in the setup screen to (dis-)allow autoloading, so that everyone can have the behaviour that suits him, and not only developers...
All the patches I'll provide for freeorion will be released under the GPL v2 or later license.
Let's unleash the dyson forest powa!

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: auto load saved designs

#15 Post by Dilvish »

vincele wrote:What about an option in the setup screen to (dis-)allow autoloading, so that everyone can have the behaviour that suits him, and not only developers...
Our UI/Graphics Lead Eleazar (largely absent as of late due to upsurge in RL demands) had urged us to minimize the addition of new options, but I agree that this seems like a pretty suitable situation for one.

Geoff, Vezzra, thoughts on that?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Post Reply