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

Implemented a theme switcher feature #62

Merged
merged 64 commits into from Sep 29, 2018
Merged

Implemented a theme switcher feature #62

merged 64 commits into from Sep 29, 2018

Conversation

NightlyFox
Copy link
Contributor

So after seeing friedkeenen on reddit implement theming and you guys accept it into your guys code i was inspired to modify and implement something myself!

I was able to modify the code and add a menu that will replace the homebrew menu with a theme switcher menu whenever the minus button is pressed on the switch. This allows the users the ability to download a large list of themes, placing them in the theme folder and change the theme of their homebrew menu whenever they would like instead of having to go on a pc, or use a separate homebrew application to change the theme.cfg file.

This is what the theme menu looks like
2018092021371500-db1426d1dfd034027cecde9c2dd914b8

@yellows8
Copy link
Collaborator

:)

Remove the *bin.h files.

Makefile Outdated
@@ -2,7 +2,7 @@ export APP_VERSION := 2.0.0

.PHONY: clean all nx pc dist-bin

all: nx pc
all: nx pc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

@NightlyFox
Copy link
Contributor Author

Also, have you guys though of using this?
https://github.com/marketplace/codecov/plan/MDIyOk1hcmtldHBsYWNlTGlzdGluZ1BsYW4xNg==#pricing-and-setup

it is completely free for open source and public repositories!

@yellows8
Copy link
Collaborator

@NightlyFox
Copy link
Contributor Author

https://github.com/switchbrew/libnx/blob/master/.doozer.json

is this meant for me? im confused lol

@yellows8
Copy link
Collaborator

referring to "Also, have you guys though of using this?"

common/theme.c Outdated
@@ -74,10 +91,9 @@ void themeStartup(ThemePreset preset) {
case THEME_PRESET_DARK:
themeDefault = &themeDark;
if (good_cfg)
theme = config_lookup(&cfg, "darkTheme");
theme = config_lookup(&cfg, "darkTheme");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace

@yellows8
Copy link
Collaborator

Remove the "(old)" files.

@NightlyFox
Copy link
Contributor Author

referring to "Also, have you guys though of using this?"
gotcha, i saw doxygen but that just documents the code... it doesnt actually tell you that your code might cause a memory leak lol. you wouldnt mind if i installed the free version on my github and used in on the opensource code just to see how it works would ya? wouldnt want to do it without your permission
https://github.com/marketplace/codefactor

@yellows8
Copy link
Collaborator

Whatever, as long as no setup-commits are pushed to this branch.

//Todo load in the data about the theme?
//Add a theme name property to each one?
//Ability to load the theme as you hover over?
free((void*)name);//This was allocated by calloc and copied over by strcpy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't free that here, do it in the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IM AN IDIOT.... you mean free it in the area i created it.... gotcha

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That really doesn't need to be on the heap, should be a stack buffer in themeMenuScan.

@NightlyFox
Copy link
Contributor Author

Whatever, as long as no setup-commits are pushed to this branch.

coolio :) ill do that after this branched is fixed up and ready to merge

…that called it, now it is easier to track when its freed
@NightlyFox
Copy link
Contributor Author

found a bug, you can enter the theme menu while in netloader without properly backing out... causing it to not properly exit.

common/theme.c Outdated
@@ -49,20 +67,19 @@ void themeStartup(ThemePreset preset) {
char tmp_path[PATH_MAX] = {0};

#ifdef __SWITCH__
tmp_path[0] = '/';
tmp_path[0] = '/';/*will this work on the windows version?*/
Copy link
Contributor

@fincs fincs Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will. A common misconception is that Windows only accepts \. That is false, Windows accepts both \ and /.

common/theme.c Outdated
.enableWaveBlending = 0,
.buttonAText = "\uE0E0",
.buttonBText = "\uE0E1",
.buttonAText = buttonAText,/*setting the buttonAText = "\uE0E0" directly allocates the literal on the stack */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The claim in this comment is false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm, then what exactly does it do? when i googled it this was the conclusion that i came too... and i talked to my other coworkers about this as well and they thought the same thing.

@NightlyFox
Copy link
Contributor Author

2018092820183400-db1426d1dfd034027cecde9c2dd914b8
The minus button goes away when you press it and you enter the theme menu...
i was going to add the + button and language for "Exit" but then i read your comments... so i just have the code in place to display the + button

@NightlyFox
Copy link
Contributor Author

2018092820210800-db1426d1dfd034027cecde9c2dd914b8
and this is what the theme menu looks like. as you can see the menu is sorted except for the first menu entry, which is the Default Theme.

@NightlyFox
Copy link
Contributor Author

NightlyFox commented Sep 29, 2018

i got the light theme minus and plus buttons wrong...

i thought A->B in dark would be E->F in light...

@yellows8
Copy link
Collaborator

Don't add anything for +.

common/menu.c Outdated
if(hbmenu_state == HBMENU_THEME_MENU) {
DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_ThemeMenu));
} else {
DrawText(interuiregular18, getX, 0 + 47, themeCurrent.textColor, textGetString(StrId_ThemeMenu));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out these two lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont like it? :/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just disable for now, can figure out what to do with it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cant find the minus button for the light theme.... weird. are we using the built in font for the switch?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i am commenting them out and about to commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a file that shows all of the characters and their unicode numbers? i might try creating one of those....

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to load the shared-font with some font tool.

@NightlyFox
Copy link
Contributor Author

Don't add anything for +.

do you want me to get rid of the plus button text in theme.c?

@yellows8
Copy link
Collaborator

You can leave that.

@NightlyFox
Copy link
Contributor Author

One more thing... is it just SX OS that keeps it from working? or is netloader just not fully implemented currently?

@yellows8
Copy link
Collaborator

Wut, netloader works fine...

@yellows8
Copy link
Collaborator

@NightlyFox
Copy link
Contributor Author

Wut, netloader works fine...

hmmmmm..... could you compile my code and see if netloader works on your switch? i dont think i modified anything to make netloader not work.... i use SX OS, and when i press Y, nothing happens... the screen just stays blank foreva

@yellows8
Copy link
Collaborator

It's supposed to display a screen with no apps when netloader is active.

@NightlyFox
Copy link
Contributor Author

It's supposed to display a screen with no apps when netloader is active.

It's supposed to display a screen with no apps when netloader is active.

oh.... then i am totally confused as to what it is used for LOL

@yellows8
Copy link
Collaborator

@NightlyFox
Copy link
Contributor Author

NightlyFox commented Sep 29, 2018

https://switchbrew.org/wiki/Homebrew_Menu

found a bug... pressing A while in netloader... crashes the switch (at least it crashed mine)
so i looked at the code, netloader is launched without clearing the previous menu, or disabling the A button... so when the user presses A, it tries to launch the menu entry that it is currently pointing too, without properly exiting netloader.

@yellows8
Copy link
Collaborator

Can't repro, although button A handling could be disabled later for that.

Waiting on newline fix before merge...

@NightlyFox
Copy link
Contributor Author

Can't repro, although button A handling could be disabled later for that.

Waiting on newline fix before merge...

what newline fix?

@yellows8
Copy link
Collaborator

@NightlyFox
Copy link
Contributor Author

NightlyFox commented Sep 29, 2018

https://github.com/switchbrew/nx-hbmenu/pull/62/files#r221410644

it only showed one newline on my pc, but i got rid of the one.. now there is none... let me know if i need to add it back.....

@yellows8
Copy link
Collaborator

@NightlyFox
Copy link
Contributor Author

Undo that, I mean this: https://github.com/switchbrew/nx-hbmenu/pull/62/files#diff-fddcee21e62e3b656dcc5fb9af2e7c9bR169

ok... so i keep clicking this link and i have no idea what you are talking about... you want me to add a newline or remove one? are you talking about a newline before the if in the menuAddEntryToFront?

@yellows8
Copy link
Collaborator

Remove the newline right before themeMenuScan.

@yellows8
Copy link
Collaborator

:)

@NightlyFox
Copy link
Contributor Author

:)

Merge time!? 💃

@yellows8
Copy link
Collaborator

yes

@yellows8 yellows8 merged commit 992c4c4 into switchbrew:master Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants