int SelectWnd::selectExec() { WORD oldSelect; int i; BOOL bSetCursor = FALSE; oldSelect = selectNum; selectNum = -1; for(i=0; i<slctCnt; i++) { if(PtInRect(&selectRect[i],sysInf.msPoint)) { selectNum = i; break; } } if(keyState.push_action) { if(selectNum >= 0) { PlayEffectNum(evtHandle[1],SelectSnd); selectEnd(); return selectNum; } } else if(bCancel && keyState.push_cancel) { PlayEffectNum(evtHandle[1],CancelSnd); selectEnd(); return -2; } else if(keyState.push_up || keyState.push_down) { if(keyState.push_up) { if(selectNum == (-1))selectNum = 0; else if(selectNum == 0)selectNum = slctCnt -1; else selectNum --; } else { if(selectNum == (-1))selectNum = 0; else { selectNum ++; if(selectNum >= slctCnt)selectNum = 0; } } bSetCursor = TRUE; } else if(keyState.push_left || keyState.push_right) { if(keyState.push_left) { selectNum = 0; } else { selectNum = slctCnt -1; } bSetCursor = TRUE; } if(bSetCursor) { point.x = selectRect[selectNum].left + 30; point.y = selectRect[selectNum].top + 20; SetWindowCursorPos(sysInf.hWnd, point.x, point.y); } if(oldSelect!=selectNum && selectNum>=0) { PlayEffectNum(evtHandle[1],CurMoveSnd); } return -1; } // SelectWnd::selectExec
void SelectWnd::SelectStart(BOOL cancel) { int i,j,offsetX,offsetY; bSelect = on; bCancel = cancel; selectNum = -1; width = 640; height = 60*slctCnt; offsetX = (WIN_SIZEX -width -(slctCnt-1)*10) /2; offsetX += (slctCnt-1)*10; offsetY = (WIN_SIZEY -62*slctCnt)/2; selectBuf.loadLGF(pack_gparts,"SELECTWND"); selectBase.loadLGF(pack_gparts,"SELECTWNDBase"); selectMsg.createColorBuf(width,height,32); for(j=0; j<slctCnt; j++) { selectMsg.BltFast(0,60*j,&selectBuf,NULL,FALSE); int offset = (616 -lstrlen((char *)slctMsg[j])*(mainFontSize/2)) /2; for(i=0; i<(int)lstrlen((char *)slctMsg[j]); i+=2) { OutputOutlineFont(&selectMsg,(BYTE *)&slctMsg[j][i] ,i*(mainFontSize/2)+offset,60*j +14,mainFontSize); if(slctMsg[j][i]<0x80) i--; } selectRect[j].left = offsetX; selectRect[j].right = offsetX +width; selectRect[j].top = offsetY +62*j; selectRect[j].bottom = selectRect[j].top +60; offsetX -= 10; } point.x = selectRect[0].left + 30; point.y = selectRect[0].top - 20; SetWindowCursorPos(sysInf.hWnd, point.x, point.y); if(sysInf.bReadSkip) { sysInf.bReadSkip = off; sysInf.bAlreadyRead = off; CheckMenuItem( sysInf.hMenu, ID_READSKIP, MF_UNCHECKED ); } back_mode = sysInf.execMode; changeExecMode(select_exec_mode); } // SelectWnd::SelectStart
TitleWnd::TitleWnd() { int i; RECT ptRect[4]; ZeroMemory(this,sizeof(TitleWnd)); ZeroMemory(&backSelectInf,sizeof(BackSelectInf)); ESC_InitEOprFlag(); lpSoundDS->ChangeMusic(bgmHandle,pack_bgmfile,2,TRUE,0); titleCBuf.loadLGF(pack_gparts,"title_op"); titleBtnCBuf.loadLGF( pack_gparts,"TitleButton"); rect.left = 200; rect.right = rect.left +400; rect.top = 460; rect.bottom = rect.top +70; for(i=0;i<4;i++){ ptRect[i].left = 0; ptRect[i].right = ptRect[i].left +400; ptRect[i].top = 70*i; ptRect[i].bottom = ptRect[i].top +70; } btn.Create(1,&titleBtnCBuf,&rect,ptRect,&g_DibInf.colorBuf); SetWindowCursorPos(sysInf.hWnd,rect.left+10, rect.top+10); titleCBuf.alpha = 0; changeExecMode( opening_mode ); } // TitleWnd::TitleWnd
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
SaveWnd::SaveWnd(exec_mode s_mode) { int i,j; ColorBuf wallWnd; ZeroMemory(this,sizeof(SaveWnd)); mode = s_mode; EnableMenuItem( sysInf.hMenu,ID_SAVEEXEC, MF_GRAYED ); EnableMenuItem( sysInf.hMenu,ID_LOADEXEC, MF_GRAYED ); bak_mode = sysInf.execMode; panel[0].loadLGF(pack_gparts,"database00"); panel[1].loadLGF(pack_gparts,"database01"); panel[2].loadLGF(pack_gparts,"database02"); button.loadLGF(pack_gparts,"SavePageBtn"); numParts.loadLGF(pack_gparts,"saveFont"); newParts.loadLGF(pack_gparts,"saveNew"); if(mode==save_mode){ pagebutton.loadLGF(pack_gparts,"SavePageNoBtn1"); wallWnd.loadLGF(pack_gparts,"savebg"); }else{ pagebutton.loadLGF(pack_gparts,"SavePageNoBtn2"); wallWnd.loadLGF(pack_gparts,"loadbg"); } retBtnPrt.loadLGF(pack_gparts,"returnBtn"); confirmWnd.loadLGF(pack_gparts,"saveConfirm"); yesNoWnd.loadLGF(pack_gparts,"saveYesNo"); backupWnd.createColorBuf(WIN_SIZEX,WIN_SIZEY,24,FALSE); backupWnd.BltFast(0,0,&g_DibInf.colorBuf,NULL,FALSE); backWnd.createColorBuf(WIN_SIZEX,WIN_SIZEY,24,FALSE); infoWnd.createColorBuf(686,496,32,FALSE); saveBmp.createColorBuf(thumbnailW,thumbnailH,24,FALSE); backWnd.BltFast(0,0,&backColorBuf,NULL,FALSE); backWnd.BltFast(0,0,&wallWnd,NULL,TRUE); maskWnd.createColorBuf(WIN_SIZEX,WIN_SIZEY,24,TRUE); maskWnd.alpha = 0.5f; for(i=0;i<5;i++){ backWnd.BltFast(20,18+100*i,&panel[0],NULL,TRUE); } saveBmp.Blt(NULL,&g_DibInf.colorBuf,NULL,FALSE); RECT selectRect = {709,565,709+86,565+25}; RECT btnRect[7]; for(i=0;i<5;i++){ btnRect[i].left = 0; btnRect[i].right = 86; btnRect[i].top = 25*i; btnRect[i].bottom = btnRect[i].top +25; } btn[2].Create(3,&retBtnPrt,&selectRect,btnRect,&g_DibInf.colorBuf); selectRect.left = 22; selectRect.right = selectRect.left +40; selectRect.top = 528; selectRect.bottom = selectRect.top +40; for(i=0;i<5;i++){ btnRect[i].left = 0; btnRect[i].right = btnRect[i].left +40; btnRect[i].top = i*40; btnRect[i].bottom = btnRect[i].top +40; } btn[0].Create(3,&button,&selectRect,btnRect,&g_DibInf.colorBuf); selectRect.left = 190; selectRect.right = selectRect.left +40; selectRect.top = 528; selectRect.bottom = selectRect.top +40; for(i=0;i<5;i++){ btnRect[i].left = 40; btnRect[i].right = btnRect[i].left +40; btnRect[i].top = i*40; btnRect[i].bottom = btnRect[i].top +40; } btn[1].Create(3,&button,&selectRect,btnRect,&g_DibInf.colorBuf); selectRect.top = 528; selectRect.bottom = selectRect.top +40; for(j=0;j<10;j++){ selectRect.left = 286 +j*42; selectRect.right = selectRect.left +40; for(i=0;i<7;i++){ btnRect[i].left = j*40; btnRect[i].right = btnRect[i].left +40; btnRect[i].top = i*40; btnRect[i].bottom = btnRect[i].top +40; } pageBtn[j].Create(5,&pagebutton,&selectRect,btnRect,&g_DibInf.colorBuf); } selectRect.top = 18+128; selectRect.bottom = selectRect.top +25; for(j=0;j<2;j++){ if(j==0){ selectRect.left = 20+289; selectRect.right = selectRect.left +86; }else{ selectRect.left = 20+385; selectRect.right = selectRect.left +86; } for(i=0;i<5;i++){ btnRect[i].left = j*86; btnRect[i].right = btnRect[i].left +86; btnRect[i].top = i*25; btnRect[i].bottom = btnRect[i].top +25; } yesnoBtn[j].Create(3,&yesNoWnd,&selectRect,btnRect,&g_DibInf.colorBuf); } time_t tmp_time = 0; for(i=0;i<50;i++){ char fname[32]; struct _stat fstatus; wsprintf( fname, "save_%02d.sav", i+1 ); if(0==_access(fname,0)){ useTable[i] = TRUE; _stat(fname,&fstatus); file_time[i] = fstatus.st_mtime; if(tmp_time < file_time[i]){ tmp_time = file_time[i]; new_time = i+1; } } } selectNum = btnSelect = 0xff; if(new_time){ offsetNum = ((new_time-1) /5)*5; SetWindowCursorPos(sysInf.hWnd, 100, 18+45+ 100* (new_time-1-offsetNum)); selectNum = (new_time-1-offsetNum); } CreateInfo(); wallWnd.Release(); changeExecMode(mode); startTime = timeGetTime() +500; state = save_fadein; } // SaveWnd::SaveWnd
void TitleWnd::Exec() { int i; BOOL bMoveCur = FALSE; short oldSelect = selectNum; switch(state){ case 0: baseCBuf.alpha += 0.02f; if(baseCBuf.alpha >= 1.0f){ backColorBuf.clearColorBuf(); baseCBuf.alpha = 1.0f; state = 1; } return; } if(keyState.push_up){ selectNum --; while(1){ if(selectNum<0){ selectNum = 4; break; } if(btn[selectNum].GetState()!=btn_disable)break; selectNum --; } bMoveCur = TRUE; }else if(keyState.push_down){ selectNum ++; while(1){ if(selectNum>4){ selectNum = 0; break; } if(btn[selectNum].GetState()!=btn_disable)break; selectNum ++; } bMoveCur = TRUE; }else if(keyState.push_left){ selectNum = 0; bMoveCur = TRUE; }else if(keyState.push_right){ selectNum = 4; bMoveCur = TRUE; } if(bMoveCur){ SetWindowCursorPos(sysInf.hWnd,btn[selectNum].selectRect.left+10, btn[selectNum].selectRect.top+10); }else{ selectNum = -1; } for(i=0;i<5;i++){ if(FALSE==btn[i].CheckState(&sysInf.msPoint)){ if(btn[i].GetState()==btn_onCursor)selectNum = i; continue; } selectNum = i; if(selectNum != 4) PlayEffectNum(evtHandle[1],SelectSnd); switch(i){ case 0: EXEC_ReadLang( "0500.sdt", &LangData ); AVG_SetScenarioNo(500); EXEC_StartLang( &LangData, MAIN_SCRIPT ); c_cls_all(); msgWnd.MsgCLS(); lpSoundDS->FadeOut(bgmHandle); saveInf.musicNum = -1; changeExecMode( event_exec_mode ); break; case 1: EXEC_ReadLang( "0000.sdt", &LangData ); AVG_SetScenarioNo(0); EXEC_StartLang( &LangData, MAIN_SCRIPT ); c_cls_all(); msgWnd.MsgCLS(); lpSoundDS->FadeOut(bgmHandle); saveInf.musicNum = -1; changeExecMode( event_exec_mode ); break; case 2: EXEC_LangBuf = (char *)&LangData.LangBuf; EXEC_LangInfo = &LangData; saveWnd = new SaveWnd(load_mode); break; case 3: lpCGmodeWnd = new CGmodeWnd; break; case 4: sysInf.bGameEnd = on; break; } } } // TitleWnd::Exec
TitleWnd::TitleWnd() { int i; RECT ptRect[4]; ZeroMemory(this,sizeof(TitleWnd)); ZeroMemory(&backSelectInf,sizeof(BackSelectInf)); EnableMenuItem( sysInf.hMenu, ID_BACKSELECT, MF_GRAYED ); ESC_InitEOprFlag(); lpSoundDS->ChangeMusic(bgmHandle,pack_bgmfile,2,TRUE,0); baseCBuf.loadLGF(pack_gparts,"TitleBase"); btnCBuf.loadLGF( pack_gparts,"TitleButton"); rect.left = 484; rect.right = rect.left +272; rect.top = 216; rect.bottom = rect.top +40; for(i=0;i<4;i++){ ptRect[i].left = 272*i; ptRect[i].right = ptRect[i].left +272; ptRect[i].top = 0; ptRect[i].bottom = 40; } btn[0].Create(1,&btnCBuf,&rect,ptRect,&baseCBuf); btn[0].Draw(); btn[0].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); SetWindowCursorPos(sysInf.hWnd,rect.left+10, rect.top+10); rect.left = 484; rect.right = rect.left +272; rect.top = 256; rect.bottom = rect.top +40; for(i=0;i<4;i++){ ptRect[i].left = 272*i; ptRect[i].right = ptRect[i].left +272; ptRect[i].top = 40; ptRect[i].bottom = ptRect[i].top +40; } btn[1].Create(1,&btnCBuf,&rect,ptRect,&baseCBuf); btn[1].Draw(); btn[1].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); rect.left = 484; rect.right = rect.left +272; rect.top = 296; rect.bottom = rect.top +40; for(i=0;i<4;i++){ ptRect[i].left = 272*i; ptRect[i].right = ptRect[i].left +272; ptRect[i].top = 80; ptRect[i].bottom = ptRect[i].top +40; } btn[2].Create(1,&btnCBuf,&rect,ptRect,&baseCBuf); btn[2].Draw(); btn[2].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); rect.left = 484; rect.right = rect.left +272; rect.top = 336; rect.bottom = rect.top +40; for(i=0;i<4;i++){ ptRect[i].left = 272*i; ptRect[i].right = ptRect[i].left +272; ptRect[i].top = 120; ptRect[i].bottom = ptRect[i].top +40; } if(AVG_GetCgFlag(0)){ btn[3].Create(1,&btnCBuf,&rect,ptRect,&baseCBuf); btn[3].Draw(); btn[3].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); }else{ btn[3].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); btn[3].SetState(btn_disable); } rect.left = 484; rect.right = rect.left +272; rect.top = 416; rect.bottom = rect.top +40; for(i=0;i<4;i++){ ptRect[i].left = 272*i; ptRect[i].right = ptRect[i].left +272; ptRect[i].top = 200; ptRect[i].bottom = ptRect[i].top +40; } btn[4].Create(1,&btnCBuf,&rect,ptRect,&baseCBuf); btn[4].Draw(); btn[4].Create(1,&btnCBuf,&rect,ptRect,&g_DibInf.colorBuf); baseCBuf.alpha = 0; changeExecMode( opening_mode ); } // TitleWnd::TitleWnd