Pages

Friday, April 30, 2021

Month of polish

How would have thought that polishing UI would take so much time? Or conversely that there are so many UI components to pass through in such a simple game.


But don't expect fancy graphics and sci-fi fonts just yet. By polish, I meant raising UI from "just enough so it works" to "not an eyesore anymore". This still required checking placing and spacing of elements, adjusting their size, making the stuff that can grow large is scrollable, and repeat all of that for the landscape mode. Yup, you can play the game like a game now! Though I find portrait mode more practical for mobile apps, especially when not seated, stuff just looks nicer in the landscape mode when an app supports it adequately. I'll add some fancy sci-fi look and feel down the road but I have to first decide on a general theme of it.

Along the way, the contacts screen got renamed to diplomacy and made into the list of the known status of all players. It shows your relations with them (peace with uncontacted ones) and a score of all players, including yours. The screen sort of doubles as a leaderboard now.

Qubit spending screen got a little bit of functionality change too. You can't reallocate bonus levels arbitrarily anymore, you can only refund the levels you bought in the current turn.

Global news screen got a bit of controversial update, it shows a banner ad below news text. I'm not a fan of advertisements either but I'm not making this game entirely for free. There will be some monetization in it but I promise there will be no evil schemes. The banner will show only on the news screen, the galaxy map screen will be free of ads forever, and the news screen will not show for minor news if a certain number of turns did not pass since the last news item. Why did I decide to put an ad banner there instead of a more prominent place then? Well in most games a news screen (like GNN in Master of Orion games) is made to look like a funny version of real TV news: anchorman, news text and image in the primary screen area, and some white noise running at the bottom, usually a scrolling text with some jokes. In a way, I've placed an actual advertisement as a joke. Hopefully, you won't find the fact offensive.

There were some minor gameplay changes implemented this month. Restrictions on what you can see on the map are now enforced properly:

  • A star needs to be scouted in order to learn its planet size
  • A star needs to at least be inside your vision range to know if somebody else has a colony there
  • You need to have a fleet at the star to see other's colony population and factory count
  • You can only see the immediate next destination of other's fleets, not all waypoints
  • As before, other's fleet has to be in vision range to know about it at all

And there were some bug fixes too:

  • The colonization checkbox won't flip its state when clicking around the map anymore
  • Another case of a computer player hanging in an infinite loop fixed
  • Research progress not working properly after loading game fixed

The problem with the colonization checkbox was basically that the Android UI framework, like many other frameworks, doesn't make a distinction between user clicking/taping a checkbox and code setting/clearing check mark. So when selecting one uncolonized star after another, without deselecting or selecting some other type of object in between¸ the UI update logic would inadvertently set the colonization checkbox of a previous star to the state of the next one.

The research progress bug was an interesting one, after loading a game it was possible that multiple research fields (across multiple players!) would get research points simultaneously at the end of a turn. After loading, multiple research fields would share the same research progress describing object so investing points in one of them would advance all with the same object. It was hard to pinpoint down the exact moment when that object would get shared because save file data would look normal (no object sharing) and for no visible reason research loading code would make some objects shared and some distinct. And it was a single line of code on my side manipulating a data structure from a standard library, so a debugger could not step inside and let me see what is going on. After reading the documentation on that data structure (HashMap) very carefully, I've learned it doesn't behave as it does in other programming languages. Java Maps and their subclasses override default equality functions so two maps will show up being the same if their key-values are the same. In C# and other languages, the usual practice for collection's default equality function is to just check if memory addresses (references) are the same and have a separate function for testing item equality. Fortunately, the fix was not that difficult, I only need to change how caching identifies which objects have been loaded and have cache users work with that identifier. Each saved object already had a textual name so I just used that instead of a reference to the object's save data.