Friday Facts #272 - Mod GUI
Author: Klonan,
published 5 years ago,
Hello,
a large part of the team is attending [url=http://www.gdsession.com/]GDS[/url], if you are in Prague and interested in Games, you are welcome to come as well.
[h1]New Manage/Install/Update mods GUI[/h1]
As we were going through the main menu, improving the looks and sometimes the interaction of most of the GUIs, it was obvious the mod management needed some attention. Most of the interaction was quite unintuitive and limited, making most players prefer using the [url=https://mods.factorio.com]web version[/url] and managing the files manually.
Mods will be managed, installed and updated from the same GUI, the 3 operations being shown as 3 tabs. The interaction, arrangement and intuitiveness of the GUI should be vastly improved. It still won't have all the features of the online mod portal (such as discussions) but provides a very quick hassle-free way of installing and updating mods without having to deal with files.
[img]https://steamcdn-a.akamaihd.net/steamcommunity/public/images/clans/12002589/a316bbe10ed9057368d039930470822fd64ff93c.png[/img]
[img]https://steamcdn-a.akamaihd.net/steamcommunity/public/images/clans/12002589/e361f1bd657112649c8bdb92f03e22104f1d9950.png[/img]
[img]https://steamcdn-a.akamaihd.net/steamcommunity/public/images/clans/12002589/a8fc318ab3cb54497caef82e3d8f4290632af6b7.png[/img]
Note these are just mockups, the in-game integration will be starting soon, and it should be done for 0.17.
The most notable changes are:[list][*]Only mods compatible with your game version are shown.[/*][*]The list of visible mods can be additionally filtered by their category.[/*][*]Mods will have a picture when browsing the mods list.[/*][*]When updating mods, you can clearly see version numbers, browse the changelog, and choose what updates, if any, you want to skip.[/*][/list]As usual I wrote an internal document to be used as a reference. It's quite boring and contains the same information, just more verbose. If you really want, you can see it [url=__cdn-assets__/img/blog/fff-271-ManageInstallUpdate-mods-gui.pdf]here[/url].
[h1]Invariants are required[/h1]
In a version of Factorio long ago we had this recurring problem with items and inventories. When an item was added or removed from some inventory it's meant to generate an event about what changed. These events are used for a multitude of different things and allow for many code simplifications and optimizations such as "turn off the inserter until a new item shows up in the chest it's taking from". It used to work like this:
[list][*]Code to remove/add some item in some inventory[*]Some logic with those items[*]Send the event about what changed in the inventory[/list]
However as with most things - things changed. Someone would add in new logic or just forget and not send the changed event. After all - programmers are human and we make mistakes. The issue kept recurring and was incredibly hard to test for because you can't write a test for some logic which doesn't exist yet: you can't test something is correct until you've written it and if you forgot to sent the changed event you can forget to write a test that checks you didn't forget it.
The only solution I could think of to the "human problem" is to remove the human part of the problem. If we no longer needed to remember to write the code to send the event and it "just happened automatically" any time we changed items around then the problem would just go away. That invariant - that changing [b]any[/b] item sends an event - solved the problem. However, it also taught me something: if some invariant is ever allowed to vary (aside from the obvious "an invariant that varies isn't an invariant") it's completely useless.
Invariants are amazing tools. We can write tests to enforce an invariant. Programmers don't need to think about handling things outside of the invariant because they can always say: "it should work as the invariant describes so I just don't need to handle the other cases". If the invariant is ever broken it's clearly a bug and has a clear solution.
As always, let us know what you think on our [url=https://forums.factorio.com/63830]forum[/url].