Set dark mode as default

I want to change the default setting of my game to a black background with white text.

This is so that when I upload it to Dashington I can email it out with this look rather than relying on users to change it themselves.

Can I alter this variable within Choicescript or is this held within a javascript file? If it is the latter (which I suspect is true after reading an answer to a previous post back around March 21/22) is there any javascript programmer on here who could tell me which file I would need to alter/do it for me please?

Yours hopefully

1 Like

It’s on the Javascript, in ui.js. However, due to the way CS generates the playable .html file, the nightmode is an addition, not an individual mode that can be set to default. Realistically, programmers would simply alter the style.css stylesheet to change its corresponding properties to black. However, in CS, nightmode is set up by adding “extra” property: class: NightMode.

For your issue, what you can do instead is compile your game with an edited stylesheet, then upload the compiled .html to dashingon.com. Doing this, however, may disable the players from switching the color to normal white as the only mode will be Default (edited to black), Black, and White—well, CS has 3 modes you can pick: Default (Sepia), Black, and White, but people may complain that you removed Sepia from the game, for some reason.

The best, in the end, is to put a note to recommend the players switching the setting to the black background.

1 Like

That’s really helpful - thanks. I reckon I’ll upload it to dashingon.com with the edited stylesheet. I want to send it round as a demo to get feedback/interest - and part of that is the nightmode setting, low energy usage etc. If part of their feedback is that they hate the nightmode, then I’ll add that to the list!!

Thanks again

1 Like

There’s a simple solution. At the very first scene of your game (can be at the end of the startup.txt — before any text), add this piece of code:

*if not(choice_nightmode)
      *script document.body.classList.remove("whitemode"); document.body.classList.add("nightmode");

This forces the game to nightmode without messing up the css. And if the person wants, they can just set the game back to white background in the setting.

This script will do the exactly same thing as if the person went into settings and set the theme to dark mode themselves.

I tried in CSIDE and it throws an error, but when I just compile the game and run it, it works just fine.

8 Likes

WHOOOOPPPP!!!

Thanks so much cup_half_empty - that has sorted it in a very simple and speedy away. You are very kind. Hope all is well in Rio - obrigada.

1 Like

I would recommend sending an email to CoG asking about their rules regarding the *script command. It’s possible that they may not accept your game if that command is used (I’m not 100% on this, but I know that changes to the javascript files are an issue during submission, so it doesn’t hurt to check). :slight_smile:

1 Like