dwjclark11 / TextRPG

This is the repository for my small youtube series ~Create a C++ Text RPG~
MIT License
8 stars 0 forks source link

Add the Concept Pages to Selector Class #5

Open dwjclark11 opened 3 weeks ago

dwjclark11 commented 3 weeks ago

Description:

dwjclark11 commented 3 weeks ago

New branch as created to address this feature. feature-Add-Pages-and-Scrolling-to-Selector

Brugoski commented 3 weeks ago

SelectorPagesFiles.zip

My First Version of Selector with Page Functionality

Attached is a zip with a few things I have worked on. I have not finished the scrolling selector yet, but I have a (probably) working SelectorPages class found in SelectorPages.h. With it is a barebones game state for testing it out. My implementation is a bit messy, but it should serve as a solution to the original problem of too many options to fit on screen. I have not noticed any glairing bugs yet, but I have also not tested it with Items or Equipment. Further polishing is likely.

Just as a note, I refrained from making SelectorPages a child of Selector because I thought they should be considered entirely separate, even if conceptually similar. This doesn't have to be the case if you choose to implement it differently (and probably more cleanly) than I did.

dwjclark11 commented 3 weeks ago

@Brugoski Awesome, I will give this a look today or over the weekend. Thank you.

dwjclark11 commented 3 weeks ago

@Brugoski This looks great! It does look like it would work for sure. The way I started the implementation is different. I will do some more testing then push it to this branch.

I have changed the SelectorParams struct to this:

struct SelectorParams // I find this cleaner looking
{
    int x{ 20 }, y{ 10 }, columns{ 1 };
    int currentX{ 0 }, currentY{ 0 };
    int spacingX{ 20 }, spacingY{ 5 };
    int maxRows{ 1 };
    std::wstring cursor{ L"->" };
};

I only added the maxRows, removed the constructor, and added default initialization. I find that cleaner.

I then added the concept of the m_CurrentPage and m_MaxPages to the selector. For the drawing of the items, all you have to do is offset where you are looking at in the data vector to only see entries within the current page.

I should hopefully be done my testing today and push to the branch.

If my testing does not come out as desired, I will try to implement what you have done. The code looks good, and I like the idea of having the DrawPages as an std::function. That way, the user can determine how it is drawn.

Thanks.

Brugoski commented 3 weeks ago

@dwjclark11 Thanks for the feedback! I hope testing goes well, I suspected there might be a clean way of adding a page system into the original Selector. I'll look forward to seeing how you phrase the implementation.