Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark mode: stars instead of clouds in the main menu #11308

Open
Emojigit opened this issue Jun 3, 2021 · 9 comments
Open

Dark mode: stars instead of clouds in the main menu #11308

Emojigit opened this issue Jun 3, 2021 · 9 comments
Labels
Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature @ Mainmenu

Comments

@Emojigit
Copy link
Contributor

Emojigit commented Jun 3, 2021

Problem

I want the dark mode to reduce the power consumption. However, minetest does not support the dark mode.

Solutions

Use stars instead of clouds in the main menu.

@Emojigit Emojigit added the Feature request Issues that request the addition or enhancement of a feature label Jun 3, 2021
@sfan5 sfan5 added @ Mainmenu Concept approved Approved by a core dev: PRs welcomed! labels Jun 3, 2021
@Emojigit
Copy link
Contributor Author

Emojigit commented Jun 3, 2021

@sfan5 Tried to code it but failed.

Patch file
diff --git a/builtin/mainmenu/textures.lua b/builtin/mainmenu/textures.lua
index a3acbbdec..7c071b63b 100644
--- a/builtin/mainmenu/textures.lua
+++ b/builtin/mainmenu/textures.lua
@@ -66,6 +66,11 @@ function mm_texture.reset()
                else
                        mm_texture.set_dirt_bg()
                end
+               if core.settings:get_bool("dark_mode") then
+                       core.set_timeofday(0)
+               else
+                       core.set_timeofday(0.5)
+               end
        end
 end
Error Log
2021-06-03 17:44:13: ERROR[Main]: Main menu error: Runtime error from mod '' in callback handleMainMenuButtons(): ...-webserver/minetest/bin/../builtin/mainmenu/textures.lua:72: attempt to call field 'set_timeofday' (a nil value)
2021-06-03 17:44:13: ERROR[Main]: stack traceback:
2021-06-03 17:44:13: ERROR[Main]: 	...-webserver/minetest/bin/../builtin/mainmenu/textures.lua:72: in function 'reset'
2021-06-03 17:44:13: ERROR[Main]: 	...-webserver/minetest/bin/../builtin/mainmenu/textures.lua:35: in function 'update'
2021-06-03 17:44:13: ERROR[Main]: 	...webserver/minetest/bin/../builtin/mainmenu/tab_local.lua:322: in function 'on_change'
2021-06-03 17:44:13: ERROR[Main]: 	.../foobar/minetest/bin/../builtin/fstk/tabview.lua:144: in function 'switch_to_tab'
2021-06-03 17:44:13: ERROR[Main]: 	.../foobar/minetest/bin/../builtin/fstk/tabview.lua:169: in function 'handle_tab_buttons'
2021-06-03 17:44:13: ERROR[Main]: 	.../foobar/minetest/bin/../builtin/fstk/tabview.lua:85: in function 'handle_buttons'
2021-06-03 17:44:13: ERROR[Main]: 	/home/foobar/minetest/bin/../builtin/fstk/ui.lua:142: in function 'handle_buttons'
2021-06-03 17:44:13: ERROR[Main]: 	/home/foobar/minetest/bin/../builtin/fstk/ui.lua:186: in function </home/foobar/minetest/bin/../builtin/fstk/ui.lua:172>
Code refs
  1. // set_timeofday(val)
    // val = 0...1
    int ModApiEnvMod::l_set_timeofday(lua_State *L)
    {
    GET_ENV_PTR;
    // Do it
    float timeofday_f = readParam<float>(L, 1);
    luaL_argcheck(L, timeofday_f >= 0.0f && timeofday_f <= 1.0f, 1,
    "value must be between 0 and 1");
    int timeofday_mh = (int)(timeofday_f * 24000.0f);
    // This should be set directly in the environment but currently
    // such changes aren't immediately sent to the clients, so call
    // the server instead.
    //env->setTimeOfDay(timeofday_mh);
    getServer(L)->setTimeOfDay(timeofday_mh);
    return 0;
    }

@JosiahWI
Copy link
Contributor

JosiahWI commented Jun 3, 2021

It looks to me like the previous version of the code is calling a function to set the main menu texture. Because it says texture, I'm skeptical that the main menu has a time of day you can adjust.

@Emojigit
Copy link
Contributor Author

Emojigit commented Jun 4, 2021

This may require a C++ engine change and Lua changes

@velartrill
Copy link
Contributor

@Emojigit i support this but it's worth clarifying that on typical LCDs, dark colors consume more power than light colors. LCD color tech is fundamentally subtractive, not additive, and the more color you filter out, the more electricity it uses. so white uses the lowest amount of power, black the highest.

this is still a great idea tho, and i'd benefit a lot from it; i do a lot of mod testing at night and that means constantly flipping through the main screen, which is so bright it hurts my eyes lol.

@hlqkj
Copy link

hlqkj commented Jul 9, 2021

@velartrill technically wrong, but ok...

@velartrill
Copy link
Contributor

@hlqkj https://en.wikipedia.org/wiki/LCD

Liquid crystals do not emit light directly, instead using a backlight or reflector to produce images in color or monochrome

Most color LCD systems use the same technique, with color filters used to generate red, green, and blue subpixels

it's a great feature idea, but it won't save power except for CRT users, sorry. best way for users with LCDs to save power is to turn down the backlight or graphics quality.

@hlqkj
Copy link

hlqkj commented Jul 11, 2021

And except for OLED users too, that is most of the ones using mobile phones and tablets nowadays. Those are the devices where improved power consumption could help most I think.

As per LCD screens, you miss the point that the vast majority of the energy they consume comes from the backlight, not from the liquid crystal cells drive. Unless you, or your PC/monitor firmware, or your OS or something else adjusts the brightness for you the power drained by the display will not change much from its average.

However most modern hardware do dynamically adjust the brightness based on the displayed image, not only for power saving but also to improve contrast and save our eyes (see for example Intel's DPST). This brightness management does have an impact on the overall power consumption and that's why darker themes could help a bit even LCD users.

@GoodClover
Copy link
Contributor

GoodClover commented Jan 3, 2022

This would probably be called something else than dark_mode.
We have menu_clouds currently for enabling/disabling the clouds, adding a setting for stars would mean that setting could get replaced with something else.

I'd really like it if this was also possible to set from a game, I'm creating one set in space and having stars instead of clouds would be nice.
Unfortunately that's probably not possible. (I assume a game's minetest.conf is loaded after clicking Play Game)

An alternative solution to this is just to set a star image as a game's menu/background.png, as stars don't actually move much (unlike clouds).

@srifqi
Copy link
Member

srifqi commented Sep 28, 2022

I tried to add "night mode" back in June 2021, but it only worked for the main menu (not with the loading screen). Today, I tried to add/apply "night mode", too, for the loading screen.

EDIT: I only changed the colour of the sky and the clouds. There are no stars for now.

GitHub branch | Video (1)

Screenshots

main menu in night mode
loading screen in night mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature @ Mainmenu
Projects
None yet
Development

No branches or pull requests

7 participants