From 79b4a7e3de5ad087c32726e142b2c2c1fb24bb5d Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Tue, 3 Mar 2015 11:56:38 -0600 Subject: [PATCH] Adding (untested) 2 way menu axis support (using the scrollOrientation parameter) --- Package/Environment/Common/controls.conf | 10 ++-- RetroFE/Source/Control/UserInput.cpp | 19 ++++++- RetroFE/Source/Control/UserInput.h | 6 ++- .../Graphics/Component/ScrollingList.cpp | 11 ++++ .../Source/Graphics/Component/ScrollingList.h | 3 ++ RetroFE/Source/Graphics/Page.cpp | 7 +++ RetroFE/Source/Graphics/Page.h | 1 + RetroFE/Source/Graphics/PageBuilder.cpp | 10 ++++ RetroFE/Source/RetroFE.cpp | 52 ++++++++++++------- 9 files changed, 93 insertions(+), 26 deletions(-) diff --git a/Package/Environment/Common/controls.conf b/Package/Environment/Common/controls.conf index b4fd723..77c89f0 100644 --- a/Package/Environment/Common/controls.conf +++ b/Package/Environment/Common/controls.conf @@ -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 diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index ea0ce4e..23d3707 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -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; diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index 455a87c..07c4cf5 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -25,8 +25,10 @@ class UserInput public: enum KeyCode_E { - KeyCodeNextItem, - KeyCodePreviousItem, + KeyCodeUp, + KeyCodeDown, + KeyCodeLeft, + KeyCodeRight, KeyCodeSelect, KeyCodeBack, KeyCodePageDown, diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 6990d30..5880300 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -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 *spriteList) AllocateSpritePoints(); } +bool ScrollingList::IsHorizontalScroll() +{ + return HorizontalScroll; +} + +void ScrollingList::SetScrollOrientation(bool horizontal) +{ + HorizontalScroll = horizontal; +} + void ScrollingList::SetScrollAcceleration(float value) { ScrollAcceleration = value; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 41d41a7..0038599 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -61,6 +61,8 @@ public: void DestroyItems(); void SetPoints(std::vector *scrollPoints, std::vector *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; }; diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 37e7eca..d408e01 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -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) diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index d60a299..0ff8f21 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -58,6 +58,7 @@ public: void StartComponents(); void Stop(); void SetScrolling(ScrollDirection direction); + bool IsHorizontalScroll(); unsigned int GetMenuDepth(); Item *GetSelectedItem(); Item *GetPendingSelectedItem(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 30a6bc1..ec03da4 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -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); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 23a271c..92ee853 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -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)]) {