titlepicture

DT: Keys and Cam

Hey everyone! Surprise! This week, Desktop Tuesday is happening on Monday, since tomorrow I am out on work-related travel. As for the rest of the team, Alpha 22 is well underway, but we don’t have anything to show for that yet but piles and piles of code, so this week’s Desktop Tuesday is a public service announcement: to all of you playing with a European keyboard, or an Azerty, Dvorak, or Tolkien keyboard, like our own Engineer Justin who types in Tengwar, or to all of you who are used to playing Dwarf Fortress or The Sims or another game whose keyboard shortcuts you absolutely love, and to all of you who want to play just with a keyboard and remap everything perfectly so you don’t need a mouse, that functionality is in fact in A21. Let’s take a closer look behind the scenes.

Keys and Cam

Recap from the video:

  • You’ve been asking for key-remapping support for 3 years! Sorry for the long delay. We finally have a unified keymapping solution in A21, courtesy of Engineer Carl, who took it on for us as a short assignment between other projects.
  • We don’t have a UI for this yet, but to unlock the ability to navigate the game exactly as you want, merely go to the folder where Stonehearth is installed, and find a file called Stonehearth.json.
  • Json is a way of encoding data in key/value pairs. We use it all over SH to record static data about our objects.
  • In stonehearth.json file, under “bindings”, the top level keys describe the command, like opening the citizen’s manager or camera pan back or forward.
  • The interior keys give you two options, combo1 and combo2, for mapping those commands to keyboard shortcuts. You can map each shortcut to 2 different keys, in case you want 2 ways to do something.
  • To change these settings for your keyboard, open a second file, user_settings.json, and create a top-level section called user_bindings.
  • Copy the commands you want to change into this section, and edit combo1/2 to be the keys you’d prefer.
  • For example, if you play with a keyboard only , and would like to remap camera zoom to something more convenient than shift+s and shift+w, copy these settings out of stonehearth.json and into user_settings.json and assign them whatever keys you’d prefer.
  • Engineer Carl even managed to get key bindings working with a controller, except that of course SH has about 60 bindings and a standard controller has 12 buttons so that’s a UX problem for another day.
  • While we’re on the topic of keys, lets talk about a little extra that got into Alpha 21, as an exercise to help Engineer Justin learn about our camera: the Stonehearth followcam.
  • When selecting a hearthlings, merely press j (j for Justin, but also j because it was one of 2 keys that weren’t already bound to another shortcut) to activate followcam on that hearthlings.
  • This is pretty useful if you want to understand the flow of work around your town, or just if you’d like to chill out and watch a building go up.
  • Why, you might ask, did we get these two features into a21 when they’ve been missing for so long, and when there’s so much else to be done?
  • It’s a good question, and the answer is that SH recently added a few new engineers to the team–Angelo and Justin full time, and Carl, as it turns out, for just a few months between other projects.
  • When you’re new to a giant codebase like Stonehearth’s that uses a custom engine, it’s often best to get your feet wet on a small projects that will teach you the existing systems, rather that a new, large project that may encourage you to add new code without understanding the perils that lie beneath.
  • Before A21, SH’s keybindings were implemented three different horrible ways behind the scenes, and were distributed through all three layers of course codebase: c++, Luna, and js.
  • The key binding exercise touched, cleaned out, and unified all this code, in addition to setting us up for future quality of life improvements like the ability for UX designer Nikki to sanitize the assignments easily once all the features are complete.
  • The camera exercise taught Justin about not just the camera, but about the hairy quaternion math required to manipulate it, and about our update and refresh loops.

Alpha 22 is underway in the background of this update, with the team distributed among some near term gameplay projects, like adding depth to our hearthling interaction system, and some long term projects like water and building updates. In the meantime, hope you’re all enjoying Alpha 21. 🙂

Other Announcements

This week’s Thursday stream should happen at the usual time and feature Chris Klochek, engineer extraordinaire. Come with all of your building-related questions. 🙂