BOOL SaveWnd::selectExec() { int i; BOOL bSetCur = FALSE; int oldSelect = selectNum, oldBtn = btnSelect; switch(state){ case save_fadein: if(timeGetTime() >= startTime){ alpha = 1.0f; state = save_exec; }else{ alpha = 1.0f - (startTime -timeGetTime()) /500.0f; } SetAlpha(); btn[2].selectRect.top = 565; btn[2].selectRect.bottom = btn[2].selectRect.top+25; btn[2].selectRect.left = LONG(709 +(1.0f- alpha)*(47+40*4)); btn[2].selectRect.right = btn[2].selectRect.left +86; return TRUE; case save_fadeout: if(timeGetTime() >= startTime){ alpha = 0; changeExecMode(bak_mode); return FALSE; } alpha = (startTime -timeGetTime()) /500.0f; SetAlpha(); btn[2].selectRect.top = 457+4*27; btn[2].selectRect.top += LONG((1.0f-alpha)*40); btn[2].selectRect.bottom = btn[2].selectRect.top +25; return TRUE; case save_writeSure: if(keyState.push_left || keyState.push_right || keyState.push_up || keyState.push_down){ bYesNo = !bYesNo; SetWindowCursorPos(sysInf.hWnd,yesnoBtn[bYesNo].selectRect.left+43, yesnoBtn[bYesNo].selectRect.top+12); } for(i=0;i<2;i++){ if(yesnoBtn[i].CheckState(&sysInf.msPoint)){ if(i==0){ PlayEffectNum(evtHandle[11],SE_PUSH); state = save_writeExec; return TRUE; }else{ PlayEffectNum(evtHandle[11],SE_CANCEL); state = save_exec; } } } if(keyState.push_cancel){ PlayEffectNum(evtHandle[11],SE_CANCEL); state = save_exec; } return TRUE; case save_loadSure: if(keyState.push_left || keyState.push_right || keyState.push_up || keyState.push_down){ bYesNo = !bYesNo; SetWindowCursorPos(sysInf.hWnd,yesnoBtn[bYesNo].selectRect.left+43, yesnoBtn[bYesNo].selectRect.top+12); } for(i=0;i<2;i++){ if(yesnoBtn[i].CheckState(&sysInf.msPoint)){ if(i==0){ if(SAV_Load( selectNum+offsetNum+1 )){ PlayEffectNum(evtHandle[11],SE_PUSH); startTime = timeGetTime(); state = save_loadEnd; return TRUE; } startTime = timeGetTime() +500; state = save_fadeout; return TRUE; }else{ PlayEffectNum(evtHandle[11],SE_CANCEL); state = save_exec; } } } if(keyState.push_cancel){ PlayEffectNum(evtHandle[11],SE_CANCEL); state = save_exec; } return TRUE; case save_writeExec: new_time = selectNum+offsetNum+1; SAV_Save( new_time ); useTable[selectNum+offsetNum] = TRUE; struct _stat fstatus; char fname[32]; wsprintf( fname, "save_%02d.sav", new_time ); _stat(fname,&fstatus); file_time[selectNum+offsetNum] = fstatus.st_mtime; CreateInfo(); startTime = timeGetTime(); state = save_writeEnd; case save_loadEnd: case save_writeEnd: i = timeGetTime() -startTime; if(i>1000){ if(state==save_writeEnd){ changeExecMode(bak_mode); }else{ changeExecMode(event_exec_mode); } startTime = timeGetTime(); if(voicefile[0])PlayVoice(voicefile, FALSE, 255); voicefile[0] = '\0'; bFadeOut = TRUE; } return TRUE; } btnSelect = 0xff; for(i=0;i<3;i++){ if(btn[i].CheckState(&sysInf.msPoint)){ btnSelect = i; switch(i){ case 0: PlayEffectNum(evtHandle[11],SE_PUSH); if(0==offsetNum)offsetNum = 45; else offsetNum -= 5; CreateInfo(); return TRUE; case 1: PlayEffectNum(evtHandle[11],SE_PUSH); offsetNum += 5; if(offsetNum>45)offsetNum = 0; CreateInfo(); return TRUE; default: PlayEffectNum(evtHandle[11],SE_CANCEL); startTime = timeGetTime() +500; state = save_fadeout; return TRUE; } }else if(btn_onCursor==btn[i].GetState()){ btnSelect = i; if(oldBtn != btnSelect){ PlayEffectNum(evtHandle[11],SE_SELECT); } } } for(i=0;i<10;i++){ if(pageBtn[i].CheckState(&sysInf.msPoint)){ PlayEffectNum(evtHandle[11],SE_PUSH); btnSelect = i+3; offsetNum = i*5; CreateInfo(); return TRUE; }else if(btn_onCursor==pageBtn[i].GetState()){ btnSelect = i+3; if(oldBtn != btnSelect){ PlayEffectNum(evtHandle[11],SE_SELECT); } } } if(keyState.push_action){ if(selectNum<5){ if(useTable[selectNum+offsetNum]){ PlayEffectNum(evtHandle[11],SE_PUSH); SetWindowCursorPos(sysInf.hWnd,yesnoBtn[0].selectRect.left +43, yesnoBtn[0].selectRect.top +12); if(mode==save_mode) state = save_writeSure; else state = save_loadSure; return TRUE; }else if(mode==save_mode){ PlayEffectNum(evtHandle[11],SE_PUSH); state = save_writeExec; return TRUE; } } }else if(keyState.push_cancel){ PlayEffectNum(evtHandle[11],SE_CANCEL); startTime = timeGetTime() +500; state = save_fadeout; return TRUE; }else if(keyState.push_up){ for(i=0;i<5;i++){ if(selectNum==0xff){ selectNum = 0; }else if(selectNum==0){ selectNum = 4; if(0==offsetNum)offsetNum = 45; else offsetNum -= 5; CreateInfo(); }else{ selectNum --; } if(mode==save_mode || useTable[selectNum+offsetNum])break; } if(i==5){ selectNum = 0xff; }else{ bSetCur = TRUE; } }else if(keyState.push_down){ for(i=0;i<5;i++){ if(selectNum>=4){ selectNum = 0; offsetNum += 5; if(offsetNum>45)offsetNum = 0; CreateInfo(); }else{ selectNum ++; } if(mode==save_mode || useTable[selectNum+offsetNum])break; } if(i==5){ selectNum = 0xff; }else{ bSetCur = TRUE; } }else if(keyState.push_left){ if(0==offsetNum)offsetNum = 45; else offsetNum -= 5; CreateInfo(); return TRUE; }else if(keyState.push_right){ offsetNum += 5; if(offsetNum>45)offsetNum = 0; CreateInfo(); return TRUE; } if(bSetCur){ if(sysInf.msPoint.x>=20 && sysInf.msPoint.x<706){ point.x = sysInf.msPoint.x; }else{ point.x = 20 +40; } point.y = 18 +40 +selectNum*100; SetWindowCursorPos(sysInf.hWnd, point.x, point.y); }else{ selectNum = 0xff; for(i=0;i<5;i++){ rect.left = 20; rect.right = rect.left +686; rect.top = 18 +100*i; rect.bottom = rect.top +96; if(myPtInRect(&rect, &sysInf.msPoint)){ if(mode==save_mode || useTable[i+offsetNum]){ selectNum = i; break; } } } } if(0xff != selectNum){ yesnoBtn[0].selectRect.top = yesnoBtn[1].selectRect.top = 18+128+100*selectNum; yesnoBtn[0].selectRect.bottom = yesnoBtn[1].selectRect.bottom = yesnoBtn[0].selectRect.top +25; if(selectNum!=oldSelect){ PlayEffectNum(evtHandle[11],SE_SELECT); } } return TRUE; } // SaveWnd::selectExec
void lookPadState() { KeyState oldState = keyState; float oldDeg = keyState.deg; int i,j; BOOL bMove,bUseKeyMove = FALSE; HRESULT hr; static float sThumbLX = 0,sThumbLY=0,leng; point = sysInf.msPoint; GetCursorPos(&sysInf.msPoint); ScreenToClient(sysInf.hWnd,&sysInf.msPoint); if(sysInf.full_screen){ if(!sysInf.bShowMenu){ if(sysInf.msPoint.y<GetSystemMetrics(SM_CYMENUSIZE)){ ShowWindow(sysInf.hMenuWnd,SW_SHOW); UpdateWindow(sysInf.hMenuWnd); sysInf.bShowMenu = on; } }else{ if(sysInf.msPoint.y>GetSystemMetrics(SM_CYMENUSIZE)){ ShowWindow(sysInf.hMenuWnd, SW_HIDE); sysInf.bShowMenu = off; return; } } } if(sysInf.bShowMenu)return; clearAllPushData(); for(i=0;i<g_iDIDeviceNum; i++) { DIDEVICEOBJECTDATA od[100]; DWORD dwItems = 100; hr = g_pDIDevice[i]->Poll(); if (FAILED(hr)){ hr = g_pDIDevice[i]->Acquire(); while (hr==DIERR_INPUTLOST) hr = g_pDIDevice[i]->Acquire(); } hr = g_pDIDevice[i]->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), od, &dwItems, 0); if(DI_OK!=hr && DI_BUFFEROVERFLOW!=hr) continue; bMove = FALSE; for (j=0;j<dwItems;j++){ BOOL bState = (od[j].dwData != 0 ) ? TRUE : FALSE; switch(od[j].uAppData){ case INPUT_LEFTRIGHT: bMove = TRUE; sThumbLX = float(int(od[j].dwData)); break; case INPUT_UPDOWN: bMove = TRUE; sThumbLY = float(-int(od[j].dwData)); break; case INPUT_LEFT: bUseKeyMove = TRUE; keyState.data_kLeft = bState; break; case INPUT_RIGHT: bUseKeyMove = TRUE; keyState.data_kRight = bState; break; case INPUT_UP: bUseKeyMove = TRUE; keyState.data_kUp = bState; break; case INPUT_DOWN: bUseKeyMove = TRUE; keyState.data_kDown = bState; break; case INPUT_LEFTUP: bUseKeyMove = TRUE; keyState.data_kLeftUp = bState; break; case INPUT_RIGHTUP: bUseKeyMove = TRUE; keyState.data_kRightUp = bState; break; case INPUT_LEFTDOWN: bUseKeyMove = TRUE; keyState.data_kLeftDown = bState; break; case INPUT_RIGHTDOWN: bUseKeyMove = TRUE; keyState.data_kRightDown = bState; break; case INPUT_ACTION: keyState.push_action = bState; if(keyState.push_action){ keyState.data_action = TRUE; }else{ keyState.data_action = FALSE; } break; case INPUT_MOUSEA: keyState.push_mouse_a = bState; if(!sysInf.bIsActive)break; if(!myPtInRect(&screenRect,&sysInf.msPoint))break; keyState.push_action = bState; if(keyState.push_mouse_a){ keyState.data_action = TRUE; }else{ keyState.data_action = FALSE; } break; case INPUT_MOUSEB: keyState.push_mouse_b = bState; if(!sysInf.bIsActive)break; if(!myPtInRect(&screenRect,&sysInf.msPoint))break; keyState.push_cancel = bState; if(keyState.push_mouse_b){ keyState.data_cancel = TRUE; }else{ keyState.data_cancel = FALSE; } break; case INPUT_CANCEL: keyState.push_cancel = bState; if(keyState.push_cancel){ keyState.data_cancel = TRUE; }else{ keyState.data_cancel = FALSE; } break; case INPUT_MOUSEC: case INPUT_SKIP: keyState.push_skip = bState; if(sysInf.bAllSkip || sysInf.bAlreadyRead){ if(keyState.push_skip){ keyState.data_skip = TRUE; }else{ keyState.data_skip = FALSE; } }else{ keyState.data_skip = FALSE; } break; case INPUT_SHIFT: if(bState)msgWnd.toggleMessageSkip(); break; case INPUT_CAMP: keyState.push_camp = bState; break; case INPUT_LEFTTRIGGER: keyState.push_leftTrigger = bState; break; case INPUT_RIGHTTRIGGER: keyState.push_rightTrigger = bState; break; case INPUT_DEBUG: keyState.push_start = bState; break; case INPUT_END: if(bState){ } break; } } if(bUseKeyMove){ bMove = TRUE; if(keyState.data_kLeft || keyState.data_kLeftUp || keyState.data_kLeftDown){ sThumbLX = -32767; }else if(keyState.data_kRight || keyState.data_kRightUp || keyState.data_kRightDown){ sThumbLX = 32767; }else{ sThumbLX = 0; } if(keyState.data_kUp || keyState.data_kLeftUp || keyState.data_kRightUp){ sThumbLY = 32767; }else if(keyState.data_kDown || keyState.data_kLeftDown || keyState.data_kRightDown){ sThumbLY = -32767; }else{ sThumbLY = 0; } } if(bMove){ keyState.data_left = keyState.data_right = keyState.data_up = keyState.data_down = 0; leng = sqrtf(square(sThumbLX) +square(sThumbLY)); if(leng > 32768)leng = 32768; if(leng > 20000){ keyState.data_move = 1; keyState.moveLeng = leng; }else{ keyState.data_move = 0; keyState.moveLeng = 0; } if(0==keyState.data_mouse_b){ if(sThumbLX >20000){ if(oldState.data_right==0){ keyState.push_right = 1; keyState.repeatCntR = timeGetTime() +1000; } keyState.data_right = 1; }else if(sThumbLX < -20000){ if(oldState.data_left==0){ keyState.push_left = 1; keyState.repeatCntL = timeGetTime() +1000; } keyState.data_left = 1; } if(sThumbLY >20000){ if(oldState.data_up==0){ keyState.push_up = 1; keyState.repeatCntU = timeGetTime() +1000; } keyState.data_up = 1; }else if(sThumbLY < -20000){ if(oldState.data_down==0){ keyState.push_down = 1; keyState.repeatCntD = timeGetTime() +1000; } keyState.data_down = 1; } } } } checkMouseState(); if(keyState.push_up){ switch(sysInf.execMode){ case event_exec_mode: backLog.DispInit(); break; } } if( msgWnd.CheckButton() ){ keyState.push_action = 0; } if((keyState.push_action || keyState.push_cancel) && sysInf.bReadSkip){ sysInf.bReadSkip = FALSE; CheckMenuItem( sysInf.hMenu, ID_READSKIP, MF_UNCHECKED ); msgWnd.msgBtn[4].SetState(btn_normal); } } // lookPadState