Jacudibu / PRUNner

Base Planner & Management tool for Prosperous Universe
MIT License
19 stars 13 forks source link

Dark Mode #33

Open louhy opened 2 years ago

louhy commented 2 years ago

Would you accept a dark mode and/or other minor visual modifications in a pull request? (Personally I'd just change from light to dark and not have a toggle, but usually someone objects to that kind of change.)

No promises, but my eyes hurt enough staring at white that it is tempting. I'm not sure how hard this would be to do, so that could be a factor also...

If anyone else wants to tackle this, that works too.

Jacudibu commented 2 years ago

Hey, sure! If I recall correctly, the Avalonia sample app already had something like that, maybe that's worth checking out?

Obviously some way to toggle it on and off would be preferable :innocent:

louhy commented 2 years ago

Yes I noticed that there's a reference to a "visual designer". I was planning to use JetBrains Rider, but Avalonia is a Visual Studio plugin. Is Visual Studio community good enough or does it need to be a paid for version of VS?

louhy commented 2 years ago

Ah - well apparently there's an Avalonia plugin for Rider. I guess I'll see what that is.. Good thing too because regular Visual Studio doesn't work on Linux which would be a big problem...

Jacudibu commented 2 years ago

Alternatively there's always VSCode, but I'd also recommend Rider over any VS version, anytime. :D

louhy commented 2 years ago

Oh I thought you were using VS after seeing the "Microsoft Visual Studio Solution File" in the project. Unfortunately I'm getting an exception from the Avalonia plugin for Rider so I'm checking with the author to see if they'll resolve it... I suspect it's just untested on Linux. Not sure how important it is to have working but it seems like a good idea.

Jacudibu commented 2 years ago

Nah, that came in through some other PR. :D Mh, it's definitely useful for smaller elements. The bigger Views usually don't have an appropriate constructor with mock data to actually show anything in those previews (yet).

louhy commented 2 years ago

Oh really, so you use Rider?? Then you're using the "AvaloniaRider" plugin successfully? If so either it's an OS related issue, or maybe something is trying to phone home that my security setup is denying. The first thing I see when I startup is a big red "IDE error occurred" message (which has been reported):

Socket error while session is still alive

java.io.EOFException
    at java.base/java.io.DataInputStream.readFully(DataInputStream.java:203)
    at java.base/java.io.DataInputStream.readFully(DataInputStream.java:172)
    at me.fornever.avaloniarider.bson.BsonStreamReader.readBytes(BsonStreamReader.kt:26)
    at me.fornever.avaloniarider.bson.BsonStreamReader.readMessage(BsonStreamReader.kt:30)
    at me.fornever.avaloniarider.previewer.AvaloniaPreviewerSession.processSocketMessages(AvaloniaPreviewerSession.kt:64)
    at me.fornever.avaloniarider.previewer.AvaloniaPreviewerSessionController$executePreviewerAsync$sessionJob$1.invokeSuspend(AvaloniaPreviewerSessionController.kt:299)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:833)
louhy commented 2 years ago

Sounds like the plugin author thinks the issue is in this project. Going through the stack trace reported in the Avalonia tab the only file it mentions in the project is App.axaml line 31 which leads to a file that says this (lol):

I really have no clue how this stuff here works... :D This here is probably a terribly crime against humanity.

Obtaining AppBuilder instance from PRUNner.Program.BuildAvaloniaApp
Initializing application in design mode
Unhandled exception. System.Exception: Unsupported Environment!
   at PRUNner.App.App.OnFrameworkInitializationCompleted() in /home/louhy/git/PRUNner/PRUNner/App/App.axaml.cs:line 31
   at Avalonia.Controls.AppBuilderBase`1.Setup() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 312
   at Avalonia.Controls.AppBuilderBase`1.SetupWithoutStarting() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 167
   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.AppInitializer`1.ConfigureApp(IAvaloniaRemoteTransportConnection transport, CommandLineArgs args, Object obj) in /_/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs:line 154
   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(String[] cmdline) in /_/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs:line 179
   at Avalonia.Designer.HostApp.Program.Main(String[] args) in /_/src/tools/Avalonia.Designer.HostApp/Program.cs:line 47

Hmm.. might take some work to figure this out.

louhy commented 2 years ago

This bit is hilarious though. I just happened onto the thing to change - line 29 in App.axaml if you change "Light" here to "Dark":

<FluentTheme Mode="Dark"/>

Dark mode enabled, haha. Could use some work to look nicer but it looks sorta that easy. I guess it's just a matter of binding that to a button somehow and then hopefully there's some way to customize it with CSS or something.

image

Jacudibu commented 2 years ago

Sounds like the plugin author thinks the issue is in this project. Going through the stack trace reported in the Avalonia tab the only file it mentions in the project is App.axaml line 31 which leads to a file that says this (lol):

I really have no clue how this stuff here works... :D This here is probably a terribly crime against humanity.

OH BOY IT'S THAT FILE... *ahem* yeah, that could be the case! ...xD Dunno, it worked for me back when I implemented the Material Icon thingies, haven't really used the preview much afterwards tbh. But I think back then I didn't use that custom NumericUpDown thingy.

Anyway, thanks for your efforts! :) I'll add some way to persist the choice tomorrow and then publish a new version with that. Those colors might need some more love in the long run as contrast feels fairly high with that pitch black background, but it's still better than nothing! ^^

louhy commented 2 years ago

Yeah actually my next suggestion was to look at using standardized storage for persistent settings like this theme setting (or whatever else, maybe including a standard save file location). On Win I think it's usually /ProgramData or under the user's home under AppData or something. Linux we'd probably want a PRUNner directory inside the user's home directory .config folder.

I'm not sure the current method of saving your data to the current working directory works out great for me, since I tend to run the application from Rider itself (lol). Of course that puts the data into the generated debug folder so I risk losing it if I don't back it up.

Yes the defaults are a bit high contrast and there might be a few other minor issues lurking. So far my eyes are bleeding less than the white causes, so I'm good with this until it gets tweaked!

louhy commented 1 year ago

Got a few fixes/improvements for you in another PR coming, what do you think?

Jacudibu commented 1 year ago

Any improvement that makes people's eyes bleed less is always welcome. :D

Sorry for the late response, guess the "tomorrow" I mentioned in my last message has finally arrived. I've added a way to save and load the active theme. And yeah, I agree that storing this within the empire file is a bit wrong, but it's also so simple and easy! Might think about moving that someplace else once there are more "global" user settings. :)

Regarding running the app directly through rider... that's the same thing I've always been doing back when I still actively played the game. xD For now you could move the userdata folder somewhere else and create a link, that might save the day in case you ever clean the build directory.

louhy commented 1 year ago

Oh cool, persistence will be nice, that has been bothering me too and I was starting to look into it myself.

Yeah I'm still trying to figure out how to make that black background contrast a little less dramatic. I think I'm actually okay with how it is now but you're right that it might be a little much for some people. I've also got a question out to the Avalonia group to find out what the "correct" way of doing this is, as the current method still feels a bit wrong, even though it works.

The link idea is a good one, I think I'll try that to be safe.

martin1194 commented 1 year ago

This issue can be close. https://github.com/Jacudibu/PRUNner/commit/beb0e40505f75517552461710d536f53b0658ad8