Skip to content

Code & Build Cleanup & Enhancements #18

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

Closed
wants to merge 20 commits into from

Conversation

mheller575
Copy link
Contributor

Hello, I stumbled on your Snake and GameMenu projects while learning SFML and thought it was an excellent introduction and I wanted to contribute if possible.

I am happy to discuss and address any and all feedback you have for me. Thank you for putting these projects together!

Pull request includes changes for:

  • Fix to CmakeLists.txt that prevented build from running properly. Target under Win32 if statement in CmakeLists was targetting "CMakeSFMLProject" which is from the SFML CMake template file. Changing this to the "gamemenu" target fixed the build for WIndows. (Found this while attempting to build the Snake project.

  • Updated code formatting for a more typical 4 space tab indenting scheme. this makes the code easier to read in my opinion. (I understand if you don't agree with this spacing scheme. I can undo if you prefer.)

  • Removed the old style header guard #ifndef in favor of "#pragma once" which is the C++14 and later handling.

  • Removed any use of non-portable base types in favor of "cstdint" typedefs for portability.

  • Changed names of files for the types contained within.

  • Added missing internal impl header file to the build process for "cmakelists.txt". Header isn't built but for users using Visual Studio it adds the header to the project file.

  • Changed standalone C functions to a utilize a factory builder factory function that returns a shared pointer. Shared pointer is preferred as it automatically handles cleanup of the raw memory. It is also clearer to the client that the returned object is a pointer that requires management. The returned pointer is then an interface to the menu. This hides the internal implementation of the menu from the client and gives them explicit management/use functions they can call and reference on the pointer.

  • Updated internal implementation to simplify the creation of the menu. Also simplified the logic for layout and drawing.

  • Changed Example code to not use the struct initializer. The struct initializer required C++20 but no other C++20 features were being used in the core project. Removed the use so the Example and the core code can both use C++14. (Users of the project are welcome to use C++20 if they want, but it is not required.)

  • Added comments and documentation to public functions and the example.

  • Added mouse support to the menu.

@ParadoxZero
Copy link
Owner

Thank you so much for the PR. This looks like a lot of changes. I am currently traveling right now. Would love to review it once I am back.

Thanks again for the effort!

@ParadoxZero
Copy link
Owner

@mheller575 apologies for the delay - I forgot that I didn't update the thread.

Thank you so much for taking your time to create this PR. However, I cannot accept this PR since you are changing a bunch of fundamental things here like the API convention e.g. the C-Style API to cppisque. Also the file names were snake case as capital letters are troublesome in cross platform settings - as Windows is case-insensitive while posix is case sensitive.

Also note - shared_ptr is not preferred due to it's performance impact. As a rule of thumb I follow unique_ptr always. Not using it in the API boundary was to adhere to C-Style API.

If possible I would love to cherry-pick just the mouse support since that's a lovely addition.

Once again, thank you for your PR :)

@mheller575
Copy link
Contributor Author

Hi @ParadoxZero no problem on the delay. It has been a while so I can't specifically recall why I made all the changes I did.

I would be happy to close this PR and open a new one with just the mouse support and the CMake fix for the Windows build.

@mheller575 mheller575 closed this Jun 6, 2025
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.

2 participants