Open dwjclark11 opened 3 weeks ago
New branch as created to address this feature. feature-Add-Pages-and-Scrolling-to-Selector
Selector
with Page Functionalitym_Data
is changed with SetData()
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 Item
s 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.
@Brugoski Awesome, I will give this a look today or over the weekend. Thank you.
@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.
@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.
Description:
This will need to calculate the max number of pages based on the total number of items.
DecrementPage() -- Decrements the page and adjusts the currentY value.
SetData() -- The max pages needs to be clamped in some way. This should also be done in the CTOR.
int m_CurrentPage, m_MaxPages.