-fixed codedump when scrolling through settings with up/down on

dpad
-fixed a bug when pointer gets on screen and some option is selected
via dpad and pointer gets off screen again that the dpad setting was
completely fucked up
-only enable scrolling through settings with dpad if no pointer is
on the screen (to not confuse wiiflow)
-alternative way of booting game with pressing A and pointer not
on screen (for some people the current way didnt work properly)
This commit is contained in:
fix94.1 2012-09-15 19:14:08 +00:00
parent a161a9f308
commit 7ea08544d3
5 changed files with 64 additions and 42 deletions

View File

@ -23,6 +23,7 @@ bool CButtonsMgr::init(CVideo &vid)
m_soundVolume = 0xFF; m_soundVolume = 0xFF;
m_noclick = false; m_noclick = false;
m_nohover = false; m_nohover = false;
m_mouse = false;
m_vid = vid; m_vid = vid;
soundInit(); soundInit();
@ -211,35 +212,34 @@ void CButtonsMgr::mouse(int chan, int x, int y)
if (m_elts.empty()) return; if (m_elts.empty()) return;
float w, h; float w, h;
u16 s = 0; u16 start = 0;
if(m_selected[chan] != -1 && 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]]->targetScaleX = 1.f;
m_elts[m_selected[chan]]->targetScaleY = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f;
s = (u16)m_selected[chan]; start = (u16)m_selected[chan];
} }
m_selected[chan] = -1; 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]; CButtonsMgr::SElement &b = *m_elts[i];
if (b.t == CButtonsMgr::GUIELT_BUTTON) if(b.t == CButtonsMgr::GUIELT_BUTTON)
{ {
SButton &but = *(CButtonsMgr::SButton *)&b; SButton &but = *(CButtonsMgr::SButton *)&b;
w = (float)(but.w / 2); w = (float)(but.w / 2);
h = (float)(but.h / 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; m_selected[chan] = i;
but.targetScaleX = 1.05f; but.targetScaleX = 1.05f;
but.targetScaleY = 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) if(!m_nohover)
but.hoverSound->Play(m_soundVolume); but.hoverSound->Play(m_soundVolume);
if (m_rumbleEnabled) if(m_rumbleEnabled)
{ {
m_rumble[chan] = 4; m_rumble[chan] = 4;
if(wii_rumble[chan]) WPAD_Rumble(chan, 1); 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) 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] == button)
{ {
if(m_selected[chan] != -1) if(m_selected[chan] != -1 && !m_noclick)
if(!m_noclick) click(m_selected[chan]);
click(m_selected[chan]);
return true; return true;
} }
} }
@ -269,54 +273,58 @@ bool CButtonsMgr::selected(s16 button)
void CButtonsMgr::up(void) 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--) 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]]->targetScaleX = 1.f;
m_elts[m_selected[chan]]->targetScaleY = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f;
start = m_selected[chan];
} }
u32 start = m_selected[chan];
m_selected[chan] = -1; 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()); m_selected[0] = j;
CButtonsMgr::SElement &b = *m_elts[j]; b.targetScaleX = 1.1f;
if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) b.targetScaleY = 1.1f;
{ break;
m_selected[chan] = j;
b.targetScaleX = 1.1f;
b.targetScaleY = 1.1f;
break;
}
} }
} }
} }
void CButtonsMgr::down(void) 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--) 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]]->targetScaleX = 1.f;
m_elts[m_selected[chan]]->targetScaleY = 1.f; m_elts[m_selected[chan]]->targetScaleY = 1.f;
start = m_selected[chan];
} }
u32 start = m_selected[chan];
m_selected[chan] = -1; 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()); m_selected[0] = j;
CButtonsMgr::SElement &b = *m_elts[j]; b.targetScaleX = 1.1f;
if (b.t == CButtonsMgr::GUIELT_BUTTON && b.visible) b.targetScaleY = 1.1f;
{ break;
m_selected[chan] = j;
b.targetScaleX = 1.1f;
b.targetScaleY = 1.1f;
break;
}
} }
} }
} }

View File

@ -51,6 +51,7 @@ public:
void hide(s16 id, bool instant = false); void hide(s16 id, bool instant = false);
void show(s16 id, bool instant = false); void show(s16 id, bool instant = false);
void mouse(int chan, int x, int y); void mouse(int chan, int x, int y);
void setMouse(bool enable);
void up(void); void up(void);
void down(void); void down(void);
void draw(void); void draw(void);
@ -148,6 +149,7 @@ private:
u8 m_soundVolume; u8 m_soundVolume;
bool m_noclick; bool m_noclick;
bool m_nohover; bool m_nohover;
bool m_mouse;
CVideo m_vid; CVideo m_vid;
private: private:
void _drawBtn(const SButton &b, bool selected, bool click); void _drawBtn(const SButton &b, bool selected, bool click);

View File

@ -638,6 +638,7 @@ private:
void ShowPrevZone(void); void ShowPrevZone(void);
void ShowNextZone(void); void ShowNextZone(void);
void ShowGameZone(void); void ShowGameZone(void);
bool ShowPointer(void);
bool m_show_zone_main; bool m_show_zone_main;
bool m_show_zone_main2; bool m_show_zone_main2;
bool m_show_zone_main3; bool m_show_zone_main3;

View File

@ -541,7 +541,7 @@ void CMenu::_game(bool launch)
if(!m_gameSound.IsPlaying()) if(!m_gameSound.IsPlaying())
startGameSound = -6; 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(); _hideGame();
m_gameSound.FreeMemory(); m_gameSound.FreeMemory();

View File

@ -103,6 +103,7 @@ void CMenu::ScanInput()
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) 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.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)) if(WPadIR_Valid(chan))
{ {
m_cursor[chan].draw(wd[chan]->ir.x, wd[chan]->ir.y, wd[chan]->ir.angle); 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; 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) bool CMenu::WPadIR_ANY(void)
{ {
return (wd[0]->ir.valid || wd[1]->ir.valid || wd[2]->ir.valid || wd[3]->ir.valid); return (wd[0]->ir.valid || wd[1]->ir.valid || wd[2]->ir.valid || wd[3]->ir.valid);