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

[Ready to Merge] UIModeController Class #295

Merged
merged 1 commit into from
Nov 25, 2017

Conversation

zigurana
Copy link

Refactoring: Split PasskeyListener and UI mode monitoring into new separate class: UIModeController (singleton).

The UIMode code started to end up in too many different locations for my liking, so I practiced implementing a singleton class for it.
The one functional improvement this brings, is that the passkey phrase (as reported by the new popup when changing the UI mode) is now pulled from the passkey actually stored in settings.xml:
uimodepopuprefac

Otherwise, this PR should have no functional changes.

I have one open question for anyone with an interest in this:
I was trying to insert the unicode glyph for the arrow symbols here, but I have no idea how to get that working, anyone has an idea?

@tomaz82
Copy link
Collaborator

tomaz82 commented Nov 10, 2017

I can get that working for you, later tonight, should add an UTF8Util.cpp/h that does the conversion both ways. If it might be useful in other places, if it's just for these 4 then I can easely get you the utf-8 hex for those 4 arrows. ( that u-2191 is utf-16 hex and as utf-8 hex it's e28691 )

You could try doing:
out += "\xe2\x86\x91"; // up 2191
out += "\xe2\x86\x93"; // down 2193
out += "\xe2\x86\x90"; // left 2190
out += "\xe2\x86\x92"; // right 2192

And no, it's more complicated than just replacing 21 with e286, that the 90, 91, 92 and 93 stayed the same was just pure conincidence.

@zigurana
Copy link
Author

Whohoo!
screenshot_20171110_113305_zigurana

Regarding the support functions for UTF-8, some of that might already be part of font.cpp

@tomaz82
Copy link
Collaborator

tomaz82 commented Nov 10, 2017

@zigurana Yeah I know, and I think it should be split out to a Unicode.cpp or whatever, with the ability to convert both ways. It does utf-8 to utf-16 ( kinda ), and for this you needed utf-16 to utf-8 ( kinda )

I'll look into it tonight.

@joolswills
Copy link
Member

Note this need rebasing currently due to other PRs. Also #306 if accepted would probably affect this PR.

@zigurana
Copy link
Author

zigurana commented Nov 15, 2017

The unicode characters for arrows are not included in the default ES font, and the default fallback font is not installed.
And so I am currently investigating suitable alternatives for the default fallback fonts, hopefully I will make some progress this week.

@pjft
Copy link
Collaborator

pjft commented Nov 15, 2017

An odd suggestion, but perhaps worth considering. Have you tried actually pasting the arrow character in the string in the code directly? I recall doing something like that for a special character for the help popup in OMX Player (I think the "bullet" one) and it worked well.

See here:

https://github.com/RetroPie/EmulationStation/blob/master/es-app/src/guis/GuiVideoScreensaverOptions.cpp#L74

Just a thought.

@zigurana
Copy link
Author

Yeah, I tried it, but it causes the whole file to be saved with a different code-page character encoding, and I had no idea what effect that could have. Also, it still does not work, if the font used for rendering does not support the glyph.

But thank you for the suggestion, it is indeed the easiest way to get the 'code' for that specific glyph in de string.

@zigurana zigurana force-pushed the UIModeController branch 2 times, most recently from 717bb4a to 8cc0dd9 Compare November 16, 2017 22:28
@zigurana
Copy link
Author

Ok, this is now ready to go, I've fixed the fallback fonts to include some that are installed by default on the pi.

@tomaz82
Copy link
Collaborator

tomaz82 commented Nov 17, 2017

Not sure what this PR does, but at a quick glance it does one big nono in coding, you access es-app code from es-core, that's something that should never be allowed :/

es-core is a support library for es-app, es-app requires es-core to function, but es-core should not require anything from es-app.

@hex007
Copy link

hex007 commented Nov 18, 2017

es-core should not be dependent on es-app. I agree.

@zigurana
Copy link
Author

zigurana commented Nov 18, 2017

I agree, but I have difficulty finding a good solution.

To explain : I need to use the ViewController methods (es-app) to reload all views, but I also need the inputs at a very early stage (before they can be consumed by Guicomponents). That happens now in Window (es-core).

As most of these components live in es-core (but not all!), it's difficult to find a clean cut there.

As a side note : what is the benefit of this split between es-core and es-app? There is only a single user of core, and it seems unlikely that there will be any others soon.

So, I am open to fix this, but I need some pointers.

@zigurana
Copy link
Author

Ok, I think that I can safely move it to es-app, and hook into the ViewController::input() method, as that is the top of the GuiComponent stack anyways. I'll come with an alternative later today

@zigurana
Copy link
Author

Ok, that was not as complicated as I thought. I've moved the UIModeController class to the same directory as ViewController (with which it has the closest interactions anyways). For the UIModeController::listener(), method, I intercept the inputs from ViewController, as it is the top of the stack anyways, so all inputs should still be available.
Thanks for kicking my butt, I hope this time the PR is acceptable.

@zigurana
Copy link
Author

Wait, I think I have the non-saving settings thing as well, hold this for now please.

@tomaz82
Copy link
Collaborator

tomaz82 commented Nov 18, 2017

Okay, just a few personal opinions:

The CMakeLists, why tabs when everything else there use 4 spaces?
Why was the ResourceManager::GetInstance::fileExists changed?

And a really personal preference, when I cleaned up the header includes, I set it up in alphabetical order, folders first, then any external includes last. Also, always include files based on root folder, so folder/whatever.h instead of just whatever.h, it helps when several work on a project, and when a project grows, if everything is based on the root folder. Again, just my personal preference.

@zigurana
Copy link
Author

Hi Tomaz, thanks for looking at this.

Regarding the spaces: short reason: because my IDE at work has tabs set to 4 spaces, and I forgot. Longer reason, because we should decide on a type of formatting, start using Clang or something, and -never- talk about whitespaces again (only slightly joking).

The ResourceManager::getInstance()->fileExists(path) is a check on the availability of a file (designated by its path), as a resource already in memory, rather than available as a file on the system. We want the latter, because the fallback fonts are not loaded into memory be default, but we want to be able to get them when someone uses a fancy symbol.

I'll change the includes, I have zero preference, so I'll follow yours.

@tomaz82
Copy link
Collaborator

tomaz82 commented Nov 18, 2017

ResourceManager::getInstance()->fileExists(path) does check if it's an embedded file that's being asked for, then it does a fs::exists, so I'd suggest you revert those changes for now.

@zigurana
Copy link
Author

Ok, updated the PR, reverted the changes to Font.cpp to call ResourceManager's fileExists() method again. UIMode settings are now saved after the popupbox has been shown (and accepted).

* Split out UIMode controller in separate class (in es-app).
* Fix passphrase input for wX360 controllers by ignoring hat-inputs
* Fix font fallback mechanism on rpi for non ascii characters using new Unicode2Chars() method.
* Fix UIMode not being saved due to popup window.
@zigurana
Copy link
Author

@tomaz82, if you don't have any other concerns, I think this is ready to merge, agreed?

@hex007
Copy link

hex007 commented Nov 20, 2017

As a side note : what is the benefit of this split between es-core and es-app? There is only a single user of core, and it seems unlikely that there will be any others soon.

@joolswills Might know why the split was introduced

@joolswills
Copy link
Member

I don't recall anything. Probably was before we forked it?

@zigurana
Copy link
Author

No matter, I am not changing it for this PR, that's for sure!

@joolswills
Copy link
Member

I'm going to merge this a bit later - so if anyone has any comments - let me know asap. Thanks for your work on this @zigurana

@zigurana zigurana changed the title new: UIModeController Class [Ready to Merge] UIModeController Class Nov 23, 2017
@joolswills joolswills merged commit ca046f7 into RetroPie:master Nov 25, 2017
@joolswills
Copy link
Member

Thanks

@zigurana zigurana deleted the UIModeController branch December 1, 2017 08:41
lubosz pushed a commit to lubosz/EmulationStation that referenced this pull request Feb 29, 2020
Allow gamelist subsets storage/customisations per system
Yaoh pushed a commit to Yaoh/EmulationStation that referenced this pull request Jul 13, 2020
[Ready to Merge] UIModeController Class
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.

5 participants