mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-30 19:45:50 +01:00
Adding (untested) 2 way menu axis support (using the scrollOrientation parameter)
This commit is contained in:
parent
b5cd4c17df
commit
79b4a7e3de
@ -1,7 +1,9 @@
|
||||
previousItem = Up
|
||||
nextItem = Down
|
||||
pageUp = Left
|
||||
pageDown = Right
|
||||
up = Up
|
||||
down = Down
|
||||
left = Left
|
||||
right: Right
|
||||
pageUp = A
|
||||
pageDown = B
|
||||
select = Space
|
||||
back = Escape
|
||||
quit = Q
|
||||
|
||||
@ -31,8 +31,23 @@ bool UserInput::Initialize()
|
||||
{
|
||||
bool retVal = true;
|
||||
|
||||
retVal = MapKey("nextItem", KeyCodeNextItem) && retVal;
|
||||
retVal = MapKey("previousItem", KeyCodePreviousItem) && retVal;
|
||||
if(!MapKey("up", KeyCodeUp))
|
||||
{
|
||||
retVal = MapKey("previousItem", KeyCodeUp) && retVal;
|
||||
}
|
||||
if(!MapKey("left", KeyCodeLeft))
|
||||
{
|
||||
retVal = MapKey("previousItem", KeyCodeLeft) && retVal;
|
||||
}
|
||||
if(!MapKey("down", KeyCodeDown))
|
||||
{
|
||||
retVal = MapKey("nextItem", KeyCodeDown) && retVal;
|
||||
}
|
||||
if(!MapKey("right", KeyCodeRight))
|
||||
{
|
||||
retVal = MapKey("nextItem", KeyCodeRight) && retVal;
|
||||
}
|
||||
|
||||
retVal = MapKey("pageDown", KeyCodePageDown) && retVal;
|
||||
retVal = MapKey("pageUp", KeyCodePageUp) && retVal;
|
||||
retVal = MapKey("select", KeyCodeSelect) && retVal;
|
||||
|
||||
@ -25,8 +25,10 @@ class UserInput
|
||||
public:
|
||||
enum KeyCode_E
|
||||
{
|
||||
KeyCodeNextItem,
|
||||
KeyCodePreviousItem,
|
||||
KeyCodeUp,
|
||||
KeyCodeDown,
|
||||
KeyCodeLeft,
|
||||
KeyCodeRight,
|
||||
KeyCodeSelect,
|
||||
KeyCodeBack,
|
||||
KeyCodePageDown,
|
||||
|
||||
@ -65,6 +65,7 @@ ScrollingList::ScrollingList(Configuration &c,
|
||||
, FontInst(font)
|
||||
, LayoutKey(layoutKey)
|
||||
, ImageType(imageType)
|
||||
, HorizontalScroll(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -155,6 +156,16 @@ void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *spriteList)
|
||||
AllocateSpritePoints();
|
||||
}
|
||||
|
||||
bool ScrollingList::IsHorizontalScroll()
|
||||
{
|
||||
return HorizontalScroll;
|
||||
}
|
||||
|
||||
void ScrollingList::SetScrollOrientation(bool horizontal)
|
||||
{
|
||||
HorizontalScroll = horizontal;
|
||||
}
|
||||
|
||||
void ScrollingList::SetScrollAcceleration(float value)
|
||||
{
|
||||
ScrollAcceleration = value;
|
||||
|
||||
@ -61,6 +61,8 @@ public:
|
||||
void DestroyItems();
|
||||
void SetPoints(std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints);
|
||||
void SetScrollDirection(ScrollDirection direction);
|
||||
void SetScrollOrientation(bool horizontal);
|
||||
bool IsHorizontalScroll();
|
||||
void PageUp();
|
||||
void PageDown();
|
||||
bool IsIdle();
|
||||
@ -127,5 +129,6 @@ private:
|
||||
Font *FontInst;
|
||||
std::string LayoutKey;
|
||||
std::string ImageType;
|
||||
bool HorizontalScroll;
|
||||
};
|
||||
|
||||
|
||||
@ -335,6 +335,13 @@ void Page::SetScrolling(ScrollDirection direction)
|
||||
ActiveMenu->SetScrollDirection(menuDirection);
|
||||
}
|
||||
|
||||
bool Page::IsHorizontalScroll()
|
||||
{
|
||||
if(!ActiveMenu) { return false; }
|
||||
|
||||
return ActiveMenu->IsHorizontalScroll();
|
||||
}
|
||||
|
||||
void Page::PageScroll(ScrollDirection direction)
|
||||
{
|
||||
if(ActiveMenu)
|
||||
|
||||
@ -58,6 +58,7 @@ public:
|
||||
void StartComponents();
|
||||
void Stop();
|
||||
void SetScrolling(ScrollDirection direction);
|
||||
bool IsHorizontalScroll();
|
||||
unsigned int GetMenuDepth();
|
||||
Item *GetSelectedItem();
|
||||
Item *GetPendingSelectedItem();
|
||||
|
||||
@ -580,6 +580,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
||||
xml_attribute<> *menuTypeXml = menuXml->first_attribute("type");
|
||||
xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime");
|
||||
xml_attribute<> *scrollAccelerationXml = menuXml->first_attribute("scrollAcceleration");
|
||||
xml_attribute<> *scrollOrientationXml = menuXml->first_attribute("scrollOrientation");
|
||||
|
||||
if(menuTypeXml)
|
||||
{
|
||||
@ -612,6 +613,15 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
||||
menu->SetScrollAcceleration(Utils::ConvertFloat(scrollAccelerationXml->value()));
|
||||
}
|
||||
|
||||
if(scrollOrientationXml)
|
||||
{
|
||||
std::string scrollOrientation = scrollOrientationXml->value();
|
||||
if(scrollOrientation == "horizontal")
|
||||
{
|
||||
menu->SetScrollOrientation(true);
|
||||
}
|
||||
}
|
||||
|
||||
ViewInfo *v = menu->GetBaseViewInfo();
|
||||
BuildViewInfo(menuXml, v);
|
||||
|
||||
|
||||
@ -378,24 +378,38 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
||||
|
||||
Attract.Reset();
|
||||
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodePreviousItem)])
|
||||
if(page->IsHorizontalScroll())
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionBack);
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeLeft)])
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionBack);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeRight)])
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionForward);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeUp)])
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionBack);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeDown)])
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionForward);
|
||||
}
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeNextItem)])
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionForward);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodePageUp)])
|
||||
{
|
||||
page->PageScroll(Page::ScrollDirectionBack);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodePageDown)])
|
||||
{
|
||||
page->PageScroll(Page::ScrollDirectionForward);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeAdminMode)])
|
||||
{
|
||||
else
|
||||
{
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodePageUp)])
|
||||
{
|
||||
page->PageScroll(Page::ScrollDirectionBack);
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodePageDown)])
|
||||
{
|
||||
page->PageScroll(Page::ScrollDirectionForward);
|
||||
}
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeAdminMode)])
|
||||
{
|
||||
//todo: add admin mode support
|
||||
}
|
||||
if (keys[Input.GetScancode(UserInput::KeyCodeSelect)])
|
||||
@ -432,8 +446,10 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
||||
state = RETROFE_QUIT_REQUEST;
|
||||
}
|
||||
|
||||
if(!keys[Input.GetScancode(UserInput::KeyCodePreviousItem)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodeNextItem)] &&
|
||||
if(!keys[Input.GetScancode(UserInput::KeyCodeUp)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodeLeft)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodeDown)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodeRight)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodePageUp)] &&
|
||||
!keys[Input.GetScancode(UserInput::KeyCodePageDown)])
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user