diff --git a/source/gui/gui.cpp b/source/gui/gui.cpp index 12488169..d8812aa6 100644 --- a/source/gui/gui.cpp +++ b/source/gui/gui.cpp @@ -23,6 +23,7 @@ bool CButtonsMgr::init(CVideo &vid) m_soundVolume = 0xFF; m_noclick = false; m_nohover = false; + m_mouse = false; m_vid = vid; soundInit(); @@ -211,35 +212,34 @@ void CButtonsMgr::mouse(int chan, int x, int y) if (m_elts.empty()) return; float w, h; - u16 s = 0; - - if(m_selected[chan] > -1 && m_selected[chan] < (s32)m_elts.size()) + u16 start = 0; + if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size()) { m_elts[m_selected[chan]]->targetScaleX = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f; - s = (u16)m_selected[chan]; + start = (u16)m_selected[chan]; } m_selected[chan] = -1; - for (int i = (int)m_elts.size() - 1; i >= 0; --i) + for(int i = (int)m_elts.size() - 1; i >= 0; --i) { CButtonsMgr::SElement &b = *m_elts[i]; - if (b.t == CButtonsMgr::GUIELT_BUTTON) + if(b.t == CButtonsMgr::GUIELT_BUTTON) { SButton &but = *(CButtonsMgr::SButton *)&b; w = (float)(but.w / 2); h = (float)(but.h / 2); - if (but.visible && (float)x >= but.pos.x - w && (float)x < but.pos.x + w && (float)y >= but.pos.y - h && (float)y < but.pos.y + h) + if(but.visible && (float)x >= but.pos.x - w && (float)x < but.pos.x + w && (float)y >= but.pos.y - h && (float)y < but.pos.y + h) { m_selected[chan] = i; but.targetScaleX = 1.05f; but.targetScaleY = 1.05f; // - if (s != m_selected[chan]) + if(start != m_selected[chan]) { - if (m_soundVolume > 0 && !!but.hoverSound) + if(m_soundVolume > 0 && !!but.hoverSound) if(!m_nohover) but.hoverSound->Play(m_soundVolume); - if (m_rumbleEnabled) + if(m_rumbleEnabled) { m_rumble[chan] = 4; if(wii_rumble[chan]) WPAD_Rumble(chan, 1); @@ -252,15 +252,19 @@ void CButtonsMgr::mouse(int chan, int x, int y) } } +void CButtonsMgr::setMouse(bool enable) +{ + m_mouse = enable; +} + bool CButtonsMgr::selected(s16 button) { - for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) + for(int chan = WPAD_MAX_WIIMOTES - 1; chan >= 0; chan--) { if(m_selected[chan] == button) { - if(m_selected[chan] != -1) - if(!m_noclick) - click(m_selected[chan]); + if(m_selected[chan] != -1 && !m_noclick) + click(m_selected[chan]); return true; } } @@ -269,54 +273,58 @@ bool CButtonsMgr::selected(s16 button) void CButtonsMgr::up(void) { - if (m_elts.empty()) return; + if(m_elts.empty() || m_mouse) + return; + u32 start = 0; for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) { - if (m_selected[chan] < (s32)m_elts.size()) + if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size()) { m_elts[m_selected[chan]]->targetScaleX = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f; + start = m_selected[chan]; } - u32 start = m_selected[chan]; m_selected[chan] = -1; - for (u32 i = 1; i <= m_elts.size(); ++i) + } + for(u32 i = 1; i <= m_elts.size(); ++i) + { + u32 j = loopNum(start - i, m_elts.size()); + CButtonsMgr::SElement &b = *m_elts[j]; + if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) { - u32 j = loopNum(start - i, m_elts.size()); - CButtonsMgr::SElement &b = *m_elts[j]; - if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) - { - m_selected[chan] = j; - b.targetScaleX = 1.1f; - b.targetScaleY = 1.1f; - break; - } + m_selected[0] = j; + b.targetScaleX = 1.1f; + b.targetScaleY = 1.1f; + break; } } } void CButtonsMgr::down(void) { - if (m_elts.empty()) return; + if(m_elts.empty() || m_mouse) + return; + u32 start = 0; for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) { - if (m_selected[chan] < (s32)m_elts.size()) + if(m_selected[chan] != -1 && m_selected[chan] < (s32)m_elts.size()) { m_elts[m_selected[chan]]->targetScaleX = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f; + start = m_selected[chan]; } - u32 start = m_selected[chan]; m_selected[chan] = -1; - for (u32 i = 1; i <= m_elts.size(); ++i) + } + for(u32 i = 1; i <= m_elts.size(); ++i) + { + u32 j = loopNum(start + i, m_elts.size()); + CButtonsMgr::SElement &b = *m_elts[j]; + if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) { - u32 j = loopNum(start + i, m_elts.size()); - CButtonsMgr::SElement &b = *m_elts[j]; - if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) - { - m_selected[chan] = j; - b.targetScaleX = 1.1f; - b.targetScaleY = 1.1f; - break; - } + m_selected[0] = j; + b.targetScaleX = 1.1f; + b.targetScaleY = 1.1f; + break; } } } diff --git a/source/gui/gui.hpp b/source/gui/gui.hpp index d34e7074..f138dacc 100644 --- a/source/gui/gui.hpp +++ b/source/gui/gui.hpp @@ -51,6 +51,7 @@ public: void hide(s16 id, bool instant = false); void show(s16 id, bool instant = false); void mouse(int chan, int x, int y); + void setMouse(bool enable); void up(void); void down(void); void draw(void); @@ -148,6 +149,7 @@ private: u8 m_soundVolume; bool m_noclick; bool m_nohover; + bool m_mouse; CVideo m_vid; private: void _drawBtn(const SButton &b, bool selected, bool click); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 13f08ea0..81b2f4f5 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -630,7 +630,7 @@ private: bool WPadIR_Valid(int chan); bool WPadIR_ANY(void); - + void ShowZone(SZone zone, bool &showZone); void ShowMainZone(void); void ShowMainZone2(void); @@ -638,6 +638,7 @@ private: void ShowPrevZone(void); void ShowNextZone(void); void ShowGameZone(void); + bool ShowPointer(void); bool m_show_zone_main; bool m_show_zone_main2; bool m_show_zone_main3; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index fb749a7b..cf35c9fb 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -541,7 +541,7 @@ void CMenu::_game(bool launch) if(!m_gameSound.IsPlaying()) startGameSound = -6; } - else if(launch || m_btnMgr.selected(m_gameBtnPlay) || m_btnMgr.selected(m_gameBtnPlayFull) || !m_show_zone_game) + else if(launch || m_btnMgr.selected(m_gameBtnPlay) || m_btnMgr.selected(m_gameBtnPlayFull) || !ShowPointer()) { _hideGame(); m_gameSound.FreeMemory(); diff --git a/source/menu/menu_input.cpp b/source/menu/menu_input.cpp index cb5d53c2..b97ec0b0 100644 --- a/source/menu/menu_input.cpp +++ b/source/menu/menu_input.cpp @@ -103,6 +103,7 @@ void CMenu::ScanInput() for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) { m_btnMgr.setRumble(chan, WPadIR_Valid(chan), PAD_StickX(chan) < -20 || PAD_StickX(chan) > 20 || PAD_StickY(chan) < -20 || PAD_StickY(chan) > 20); + m_btnMgr.setMouse(WPadIR_Valid(chan) || m_show_pointer[chan]); if(WPadIR_Valid(chan)) { m_cursor[chan].draw(wd[chan]->ir.x, wd[chan]->ir.y, wd[chan]->ir.angle); @@ -205,6 +206,16 @@ bool CMenu::WPadIR_Valid(int chan) return false; } +bool CMenu::ShowPointer(void) +{ + for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) + { + if(WPadIR_Valid(chan) || m_show_pointer[chan]) + return true; + } + return false; +} + bool CMenu::WPadIR_ANY(void) { return (wd[0]->ir.valid || wd[1]->ir.valid || wd[2]->ir.valid || wd[3]->ir.valid);