// --------------------------------------------------------------------------- #include #pragma hdrstop #include "GlobalUnit.h" #include "StyleSelFormUnit.h" #include "MessageFormUnit.h" #define FONT_RANGE 20 #define FONT_SIZE 10 #define PAGE_NUM_SHOW 6 #define LISTBOX_NUM_SHOW 20 #define LISTBOX_DOWN_WIDTH 40 #define BTNSTATE_RECOMMAND 0 #define BTNSTATE_FIND 1 #define BTNSTATE_COLLECT 2 #define BTNSTATE_SERACH 3 #define BTNSTATE_RECORD 4 TSTYLEINFO *sg_aMsg = NULL; DEFTSTYLEINFO * sg_tTmpMsg = NULL; int sg_nMsg = 0; vectorvc_vCollect; // 收藏列表 vectorvc_vAllStyles; vectorvc_vUseRecord; // 使用记录列表 vectorvc_vFind; // 符合查找条件列表 vector::iterator vc_pFind; int sg_iBeat = -1; int g_iCurStyleSort = -1; int __fastcall lessmarkCost(void * Item1, void * Item2) { DEFTSTYLEINFO *tmpSG1 = (DEFTSTYLEINFO *)Item1; DEFTSTYLEINFO *tmpSG2 = (DEFTSTYLEINFO *)Item2; if( tmpSG1->tStyleInfo.cost < tmpSG2->tStyleInfo.cost){ return -1; }else if(tmpSG1->tStyleInfo.cost > tmpSG2->tStyleInfo.cost){ return 1; } return 0; } int __fastcall lessmarkScore(void * Item1, void * Item2) { DEFTSTYLEINFO *tmpSG1 = (DEFTSTYLEINFO *)Item1; DEFTSTYLEINFO *tmpSG2 = (DEFTSTYLEINFO *)Item2; if( tmpSG1->tStyleInfo.score < tmpSG2->tStyleInfo.score){ return -1; }else if(tmpSG1->tStyleInfo.score > tmpSG2->tStyleInfo.score){ return 1; } return 0; } // --------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "PNGButton" #pragma resource "*.dfm" TStyleSelForm *StyleSelForm; USEFORM("MessageFormUnit.cpp", MessageForm); // --------------------------------------------------------------------------- __fastcall TStyleSelForm::TStyleSelForm(TComponent* Owner) : TForm(Owner) { m_iOldItemState = -1; m_iOldItemIndex = -1; m_iDwnLdgIndex = -1; m_bBase = false; m_iSelStage = -1; m_iChordType = -1; m_idSelected = -1; m_iSegType = -1; m_iSegNo = -1; } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::FormCreate(TObject *Sender) { // 屏幕位置显示 Left = Screen->Width / 2 - Width / 2; Top = Screen->Height / 2 - Height / 2; // 圆角 HRGN hRgn = CreateRoundRectRgn(0, 0, Width + 1, Height + 1, 6, 6); SetWindowRgn(Handle, hRgn, TRUE); DeleteObject(hRgn); // 相关图片加载 m_pImgRadioDown = new TBitmap(); m_pImgRadioUp = new TBitmap(); m_pImgCheckDown = new TBitmap(); m_pImgCheckUp = new TBitmap(); m_pImgCheckDown->LoadFromResourceName(int(HInstance), "StyleLstCheckA"); m_pImgCheckUp->LoadFromResourceName(int(HInstance), "StyleLstCheckB"); m_pImgRadioDown->LoadFromResourceName(int(HInstance), "StyleLstRadioA"); m_pImgRadioUp->LoadFromResourceName(int(HInstance), "StyleLstRadioB"); m_lblTitle->Font->Color = RGB(60,43,23); // 收藏菜单 m_pPopMenu = new TPopMenu(this); // 隐藏查找框 m_ImgFind->Visible = false; // 按钮状态 m_iBtnState = BTNSTATE_FIND; // 视听伴奏类型按钮 m_pbRadio[0] = m_pbBase1; m_pbRadio[1] = m_pbBase2; m_pbRadio[2] = m_pbBase3; m_pbRadio[3] = m_pbBase4; m_pbRadio[4] = m_pbInt1; m_pbRadio[5] = m_pbInt2; m_pbRadio[6] = m_pbInt3; m_pbRadio[7] = m_pbInt4; m_pbRadio[8] = m_pbEnd1; m_pbRadio[9] = m_pbEnd2; m_pbRadio[10] = m_pbEnd3; m_pbRadio[11] = m_pbEnd4; m_pbRadio[12] = m_pbFull; // 上下、头尾页按钮 m_btnPages[0] = m_btnHeadPage; m_btnPages[1] = m_btnUpPage; m_btnPages[2] = m_btnNextPage; m_btnPages[3] = m_btnEndPage; // 查找按钮 m_pbChecks[0] = m_pbPop; m_pbChecks[1] = m_pbFolk; m_pbChecks[2] = m_pbRock; m_pbChecks[3] = m_pbDance; m_pbChecks[4] = m_pbJazz; m_pbChecks[5] = m_pbBlus; m_pbChecks[6] = m_pbSamba; m_pbChecks[7] = m_pbClassical; m_pbChecks[8] = m_pbWaltz; m_pbChecks[9] = m_pbOthStyle; m_pbChecks[10] = m_pbFree; m_pbChecks[11] = m_pbInverts; // 得到默认选择查找类型 for (int i = 0; i < CHECK_NUM; i++) m_baChecks[i] = 0; // 如果是打开工程,则读取 g_iSelectedStyleType if (!g_lstStyleSelected.size()) { int nM = 0; while (nM < CHECK_NUM) { m_baChecks[nM] = (g_iSelectedStyleType >> nM) & 1; if (m_baChecks[nM] > 0) g_lstStyleSelected.push_back(nM); nM++; } } else { // 否则读取 g_lstStyleSelected vector::iterator pLst; for(pLst = g_lstStyleSelected.begin(); pLst != g_lstStyleSelected.end(); pLst++) m_baChecks[*pLst] = 1; } // radio默认完整选项 for (int i = 0; i < RADIO_NUM; i++) m_baRadio[i] = 0; m_baRadio[12] = 1; // 字体、页码选中颜色 m_clFont = RGB(79, 57, 30); m_clBox = RGB(94, 67, 35); // 提示时间延迟 m_pTimerHint = new TTimer(this); m_pTimerHint->Enabled = false; m_pTimerHint->Interval = TIME_HINT; m_pTimerHint->OnTimer = HintTimerProc; // 提示框 m_pShowHint = new TSkinHintWindow(this); m_btnFind->Down = true; m_ImgFind->Visible = true; // 读取信息文件 GetStyle(); // m_bActiveHappened = false; SetTransparent( this ); // Activate(NULL); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::FormDestroy(TObject *Sender) { delete m_pImgRadioDown; delete m_pImgRadioUp; delete m_pImgCheckDown; delete m_pImgCheckUp; delete m_pShowHint; delete m_pTimerHint; /* if( sg_aMsg ){ delete sg_aMsg; } */ } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::WMNCHitTest(TWMNCHitTest &Msg) { TForm::Dispatch(&Msg); if (Msg.Result == HTCLIENT && Msg.XPos > Left + 10 && Msg.XPos < Left + Width - 50 && Msg.YPos < Top + 24) Msg.Result = HTCAPTION; } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::CheckStylePaint(TObject *Sender) { if (m_ImgFind->Visible != true) return; for (int i = 0; i < CHECK_NUM; i++) { if( m_baChecks[i] ) m_pbChecks[i]->Canvas->Draw(0, 0, m_pImgCheckDown); else m_pbChecks[i]->Canvas->Draw(0, 0, m_pImgCheckUp); } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::CheckStyleMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (m_ImgFind->Visible != true || Button != mbLeft) return; TPaintBox * pPbCheckStyle = (TPaintBox*)Sender; Stop(); m_btnPlay->Enabled = false; m_btnTry->Enabled = false; // 判断全不选状态 bool bflag = false; if (m_baChecks[CHECK_NUM - 1] == 0) { bflag = true; } // 对按下的Check取反 for (int i = 0; i < CHECK_NUM; i++) { if (m_pbChecks[i] == pPbCheckStyle) { m_baChecks[i] = !m_baChecks[i]; break; } } if (m_baChecks[CHECK_NUM - 1] && bflag) { // 全不选,权限不在其范围 for (int i = 0; i < CHECK_NUM - 2; i++) { m_baChecks[i] = 0; } } else { if (pPbCheckStyle != m_pbFree) m_baChecks[CHECK_NUM - 1] = 0; } pPbCheckStyle->Invalidate(); // 查找、显示风格 FindStyle(); ShowStyle(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::RadioStylePaint(TObject *Sender) { for (int i = 0; i < RADIO_NUM; i++) { if (m_baRadio[i]) m_pbRadio[i]->Canvas->Draw(0, 0, m_pImgRadioDown); else m_pbRadio[i]->Canvas->Draw(0, 0, m_pImgRadioUp); } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::RadioStyleMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (mbLeft != Button) return; // 根据选中的风格决定radio可选 TPaintBox *pPbRadioStyle = (TPaintBox*)(Sender); int iradio = 0; for (int i = 0; i < RADIO_NUM; i++) { if (m_pbRadio[i] == pPbRadioStyle) { iradio = i; break; } } if (iradio == 6 || iradio == 7 || iradio == 10 || iradio == 11) return; for (int i = 0; i < RADIO_NUM; i++) m_baRadio[i] = 0; m_baRadio[iradio] = 1; pPbRadioStyle->Invalidate(); if (m_stLstSelect.iOldSelectItemIndex == -1) return; m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->Invalidate(); m_stLstSelect.bPlay = true; vc_pFind = vc_vFind.begin() + (m_stLstSelect.iOldSelectPage - 1) * LISTBOX_NUM_SHOW + m_stLstSelect.iOldSelectItemIndex; // 得到索引ID /* if ((*vc_pFind).tStyleInfo.idStyle <= 0) { int index = (m_stPageNum.iSelectPage - 1) * LISTBOX_NUM_SHOW + m_lbStyle->ItemIndex; vc_pFind = vc_vFind.begin() + index; } */ Play(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PageNumPaint(TObject *Sender) { m_pbPageNum->Canvas->Font->Size = g_szFont8; m_pbPageNum->Canvas->Font->Color = m_clFont; m_pbPageNum->Canvas->Brush->Style = bsClear; m_pbPageNum->Canvas->Pen->Color = clWhite; int nM = m_nPageNum - m_stPageNum.iStartPage; nM = nM >= PAGE_NUM_SHOW ? PAGE_NUM_SHOW : (nM + 1); int ipos = 0, iexpert = 0; for (int i = m_stPageNum.iStartPage; i < m_stPageNum.iStartPage + nM; i++) { iexpert = 6; if (i > 9) iexpert -= 2; // 绘制鼠标进入提示框 if (m_stPageNum.iMovingPage == i) m_pbPageNum->Canvas->Rectangle((m_stPageNum.iMovingPos)*FONT_RANGE, 1, FONT_RANGE*(m_stPageNum.iMovingPos + 1), m_pbPageNum->Height); m_pbPageNum->Canvas->TextOutW(ipos + iexpert, 1, IntToStr(i)); ipos += FONT_RANGE; } // 显示省略 if (m_stPageNum.bShowDots) m_pbPageNum->Canvas->TextOutW(ipos + 4, 2, "···"); // 绘制选中 for (int i = m_stPageNum.iStartPage; i < m_stPageNum.iStartPage + nM; i++) { if (m_stPageNum.iSelectPage == i) { m_pbPageNum->Canvas->Pen->Color = m_clBox; m_pbPageNum->Canvas->Rectangle (TRect((m_stPageNum.iCurrentPos - 1)*FONT_RANGE, 1, FONT_RANGE*m_stPageNum.iCurrentPos, m_pbPageNum->Height)); } } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PageNumMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // 点击数字页码 int iN = X / FONT_RANGE; // 空白的地方点击返回 if ((m_nPageNum - m_stPageNum.iStartPage) < iN) return; int mid = PAGE_NUM_SHOW / 2; if (iN >= 0 && iN < PAGE_NUM_SHOW) { m_stPageNum.iCurrentPos = iN + 1; // 所在格子位置 if (m_stPageNum.iCurrentPos == PAGE_NUM_SHOW - 1) { // 点击第5个位置 if ((m_nPageNum - m_stPageNum.iStartPage) >= PAGE_NUM_SHOW) { m_stPageNum.iStartPage++; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW - 2; } } else if (m_stPageNum.iCurrentPos == PAGE_NUM_SHOW) { // 点击第6个位置 if ((m_nPageNum - m_stPageNum.iStartPage) >= PAGE_NUM_SHOW) { m_stPageNum.iStartPage += 2; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW - 2; } } else if (m_stPageNum.iCurrentPos == 1) { // 点击第1个位置 m_stPageNum.iStartPage -= 2; m_stPageNum.iCurrentPos = 3; if (m_stPageNum.iStartPage < 0) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos -= 2; } else if (m_stPageNum.iStartPage == 0) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 2; } } else if (m_stPageNum.iCurrentPos == 2) { // 点击第2个位置 m_stPageNum.iStartPage--; m_stPageNum.iCurrentPos = 3; if (m_stPageNum.iStartPage < 1) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos--; } } if ((m_nPageNum - m_stPageNum.iStartPage) < PAGE_NUM_SHOW) m_stPageNum.bShowDots = false; else m_stPageNum.bShowDots = true; // 与上次选择相同 if (m_stPageNum.iStartPage + m_stPageNum.iCurrentPos - 1 == m_stPageNum.iSelectPage) return; // 得到选择的页码 m_stPageNum.iSelectPage = m_stPageNum.iStartPage + m_stPageNum.iCurrentPos - 1; // 添加页代码ListBox AddPageItem(m_stPageNum.iSelectPage); m_lbStyle->SetPlayItemIndex(); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage) { if (m_stLstSelect.bPlay) m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } else m_lbStyle->Invalidate(); m_pbPageNum->Invalidate(); } vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PageNumMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { int iN = X / FONT_RANGE; if (iN >= 0 && iN < PAGE_NUM_SHOW) { m_stPageNum.iMovingPos = iN; m_stPageNum.iMovingPage = m_stPageNum.iStartPage + m_stPageNum.iMovingPos; } else m_stPageNum.iMovingPage = -1; m_pbPageNum->Invalidate(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PageNumMouseLeave(TObject *Sender) { m_stPageNum.iMovingPage = -1; m_pbPageNum->Invalidate(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::BtnStepPageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Button != mbLeft) return; TPNGButton *pBtnTemp = (TPNGButton*)Sender; int iTemp = m_stPageNum.iSelectPage; // 下一页 if (pBtnTemp == m_btnNextPage) { if (m_stPageNum.iSelectPage < m_nPageNum) { m_stPageNum.iCurrentPos++; if ((m_nPageNum - m_stPageNum.iStartPage) >= PAGE_NUM_SHOW) { if (m_stPageNum.iCurrentPos == PAGE_NUM_SHOW - 1) { m_stPageNum.iStartPage++; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW - 2; } if (m_stPageNum.iCurrentPos == PAGE_NUM_SHOW) { m_stPageNum.iStartPage += 2; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW - 2; } } if ((m_nPageNum - m_stPageNum.iStartPage) < PAGE_NUM_SHOW) m_stPageNum.bShowDots = false; // 得到选择页码 m_stPageNum.iSelectPage++; } } // 上一页 else { if (m_stPageNum.iSelectPage >= 2) { m_stPageNum.iCurrentPos--; if (m_stPageNum.iCurrentPos < 1) m_stPageNum.iCurrentPos = 1; if (m_stPageNum.iCurrentPos == 1) { m_stPageNum.iStartPage -= 2; m_stPageNum.iCurrentPos = 3; if (m_stPageNum.iStartPage < 1) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 1; } } if (m_stPageNum.iCurrentPos == 2) { m_stPageNum.iStartPage--; m_stPageNum.iCurrentPos = 3; if (m_stPageNum.iStartPage < 1) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 2; } } if ((m_nPageNum - m_stPageNum.iStartPage) >= PAGE_NUM_SHOW) m_stPageNum.bShowDots = true; // 得到选择页码 m_stPageNum.iSelectPage--; } } if (iTemp == m_stPageNum.iSelectPage) { return; } m_pbPageNum->Invalidate(); AddPageItem(m_stPageNum.iSelectPage); m_lbStyle->SetPlayItemIndex(); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage) { if (m_stLstSelect.bPlay) m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); //m_lbStyle->Invalidate(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::BtnHeadOrEndPageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { // if (Button != mbLeft) return; TPNGButton *pBtnTemp = (TPNGButton*)Sender; // ********************************首页 if (pBtnTemp == m_btnHeadPage) { if (m_stPageNum.iStartPage == 1 && m_stPageNum.iCurrentPos == 1 && m_stPageNum.iSelectPage == 1) return; m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 1; m_stPageNum.iSelectPage = 1; m_stPageNum.bShowDots = false; if (m_nPageNum > PAGE_NUM_SHOW) m_stPageNum.bShowDots = true; // 列表框刷新到第1页 } // ********************************尾页 else if (pBtnTemp == m_btnEndPage) { if (m_stPageNum.iSelectPage == m_nPageNum) return; m_stPageNum.iSelectPage = m_nPageNum; if (m_nPageNum >= PAGE_NUM_SHOW) { m_stPageNum.iStartPage = m_nPageNum - PAGE_NUM_SHOW + 1; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW; } else { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = m_nPageNum; } m_stPageNum.bShowDots = false; // 列表框刷新到最后1页 } m_pbPageNum->Invalidate(); AddPageItem(m_stPageNum.iSelectPage); m_lbStyle->SetPlayItemIndex(); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage) { if (m_stLstSelect.bPlay) m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); //m_lbStyle->Invalidate(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::LstStyleMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { m_iHitItemIndex = -1; m_pTimerHint->Enabled = false; m_pShowHint->ReleaseHandle(); int ret = m_lbStyle->ItemAtPos(TPoint(X, Y), true); if (ret == -1) return; if (Button == mbRight) { // 收藏界面状态显示删除 bool bCollectDelete = false; if (m_iBtnState == BTNSTATE_COLLECT && !m_btnPngSearch->Down) { bCollectDelete = true; } if (m_btnPngSearch->Down) bCollectDelete = false; // If entry Pay_Btn_down's page,not display the pop-menu //add by tj 2014/7/2 // if (m_btnRecommand->Down) { // m_lbStyle->ItemIndex = ret; // m_stLstSelect.iOldSelectItemIndex = m_lbStyle->ItemIndex; // m_stLstSelect.iOldSelectPage = m_stPageNum.iSelectPage; // // m_lbStyle->Invalidate(); // return; // } int index = (m_stPageNum.iSelectPage - 1) * LISTBOX_NUM_SHOW + ret; vc_pFind = vc_vFind.begin() + index; // 得到索引ID m_iCollectDelete = index; m_stLstSelect.iIdCollect = vc_pFind->tStyleInfo.idStyle; if (!bCollectDelete) { // 增加收藏时检查是否重复 vector::iterator plst; for (plst = vc_vCollect.begin(); plst != vc_vCollect.end(); plst++) { if (vc_pFind->tStyleInfo.idStyle == *plst) { m_stLstSelect.iIdCollect = 0; break; } } } // Add a download menu item and disenabel the play button m_pPopMenu->ClearMenuItem(); TPoint point(X, Y); point = m_lbStyle->ClientToScreen(point); if (vc_pFind->tStyleInfo.state == e_UnDownload) { m_pPopMenu->CreateCustomMenuItem("下载", OnDownLoadStyle, -1, !g_bUpdateMandatory, false, 0); } else{ m_pPopMenu->CreateCustomMenuItem("重新下载", OnDownLoadStyle, -1, !g_bUpdateMandatory, false, 0); } m_pPopMenu->CreateCustomMenuItem("-", NULL, -1, true, false, 0); if (bCollectDelete) { m_pPopMenu->CreateCustomMenuItem("删除", OnCollect, -1, true, false, 0); m_bCollectDelete = true; } else { if (m_stLstSelect.iIdCollect != 0) m_pPopMenu->CreateCustomMenuItem("收藏", OnCollect, -1, true, false, 0); else m_pPopMenu->CreateCustomMenuItem("已收藏", OnCollect, -1, false, true, 0); } m_lbStyle->ItemIndex = ret; m_pPopMenu->Popup(point.x, point.y); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } else { //add by tj 2014/1/15 14:35 if ( m_lbStyle->ItemIndex != -1 && ( m_lbStyle->ItemIndex != m_stLstSelect.iOldSelectItemIndex || m_stLstSelect.iOldSelectPage != m_stPageNum.iSelectPage ) ) { int index = (m_stPageNum.iSelectPage - 1) * LISTBOX_NUM_SHOW + m_lbStyle->ItemIndex; Stop(); m_btnPlay->Enabled = true; m_btnTry->Enabled = true; m_stLstSelect.iSelect = index; m_stLstSelect.iOldSelectItemIndex = m_lbStyle->ItemIndex; m_stLstSelect.iOldSelectPage = m_stPageNum.iSelectPage; m_stLstSelect.bPlay = false; m_lbStyle->SetPlayItemIndex(); m_lbStyle->Invalidate(); /* if( m_iSelStage<0 ){ // 回到完整视听状态 for (int i = 0; i < RADIO_NUM; i++) m_baRadio[i] = 0; m_baRadio[12] = 1; //m_pbBase1->Invalidate(); } */ vc_pFind = vc_vFind.begin() + index; // 得到索引ID m_btnPlay->Enabled = e_Downloaded == vc_pFind->tStyleInfo.state; m_btnTry->Enabled = m_btnPlay->Enabled; m_btnPlay->Invalidate(); m_btnTry->Invalidate(); } } // Display the styles' state int iItemIndex = m_lbStyle->ItemAtPos(TPoint(X, Y), true); if (iItemIndex != -1) { TRect rtFocusItem = m_lbStyle->ItemRect(iItemIndex); rtFocusItem.Left = rtFocusItem.Right - LISTBOX_DOWN_WIDTH; if (rtFocusItem.PtInRect(TPoint(X, Y))) { m_iDownItemIndex = iItemIndex; } } // Refresh current item state(download) // ------------------------------------------------------------------ int iHotItemIndex = iItemIndex + (m_stPageNum.iSelectPage - 1) * 20; if (m_iOldItemIndex != -1) vc_vFind[m_iOldItemIndex].iStyleDownSate = m_iOldItemState; m_iOldItemState = vc_vFind[iHotItemIndex].iStyleDownSate; if (vc_vFind[iHotItemIndex].iStyleDownSate < 2) vc_vFind[iHotItemIndex].iStyleDownSate = 1; else vc_vFind[iHotItemIndex].iStyleDownSate += 10; static vectorvcItemsIndex; if (vcItemsIndex.size()) vcItemsIndex.clear(); vcItemsIndex.push_back(iHotItemIndex); if (-1 != m_iOldItemIndex && m_iOldItemState != -1) vcItemsIndex.push_back(m_iOldItemIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); m_iOldItemIndex = iHotItemIndex; // ------------------------------------------------------------------ } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::LstStyleMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { int ret = m_lbStyle->ItemAtPos(TPoint(X, Y), true); if (ret == -1) { m_pShowHint->ReleaseHandle(); return; } if (m_iHitItemIndex != ret && ret != -1) { m_iHitItemIndex = ret; m_pShowHint->ReleaseHandle(); } if (m_iHitItemIndex != -1) { m_pTimerHint->Enabled = true; m_xPos = X; m_yPos = Y; } return; if (ret != -1) { TRect rtItem = m_lbStyle->ItemRect(ret); // rtItem.Left = rtItem.Right - LISTBOX_DOWN_WIDTH; TPoint ptFocus = TPoint(X, Y); // TRect rtHotItem(); //Modify Item Focus Item Rect int iHotItemIndex = ret + (m_stPageNum.iSelectPage - 1) * 20; if (rtItem.PtInRect(ptFocus) && m_iOldItemIndex != iHotItemIndex) { // m_lbStyle->ItemIndex = ret; if (m_iOldItemIndex != -1) vc_vFind[m_iOldItemIndex].iStyleDownSate = m_iOldItemState; m_iOldItemState = vc_vFind[iHotItemIndex].iStyleDownSate; if (vc_vFind[iHotItemIndex].iStyleDownSate < 2) vc_vFind[iHotItemIndex].iStyleDownSate = 1; else vc_vFind[iHotItemIndex].iStyleDownSate += 10; static vectorvcItemsIndex; if (vcItemsIndex.size()) vcItemsIndex.clear(); vcItemsIndex.push_back(iHotItemIndex); if (-1 != m_iOldItemIndex && m_iOldItemState != -1) vcItemsIndex.push_back(m_iOldItemIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); m_iOldItemIndex = iHotItemIndex; } } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::LstStyleMouseLeave(TObject *Sender) { m_iHitItemIndex = -1; m_pTimerHint->Enabled = false; m_pShowHint->ReleaseHandle(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::LstStyleMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (m_stLstSelect.iOldSelectItemIndex != -1) { m_lbStyle->SetPlayItemIndex(); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage) { if (m_stLstSelect.bPlay) m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } m_lbStyle->Invalidate(); } int iItemIndex = m_lbStyle->ItemAtPos(TPoint(X, Y), true); if (-1 != iItemIndex) { TRect rtItemFocus = m_lbStyle->ItemRect(iItemIndex); //rtItemFocus.Left = rtItemFocus.Right - LISTBOX_DOWN_WIDTH; // Check the mouse-point position /* if (rtItemFocus.PtInRect(TPoint(X, Y)) && m_iDownItemIndex == iItemIndex) { int iVcIndex = (m_stPageNum.iSelectPage - 1) * 20 + m_iDownItemIndex; */ if (rtItemFocus.PtInRect(TPoint(X, Y))){ int iVcIndex = (m_stPageNum.iSelectPage - 1) * 20 + iItemIndex; // vc_vFind[iVcIndex].tStyleMsg.bIsDownLoaded if (e_Downloaded != vc_vFind[iVcIndex].tStyleInfo.state) { // Check the styles' download state /* int iSgItemIndex = -1; for (int i = 0; i < sg_nMsg; i++) { if (sg_tTmpMsg[i].iStyleDownSate > 1 && e_Downloaded != sg_tTmpMsg[i].tStyleInfo.state) { iSgItemIndex = i; break; } } if (iSgItemIndex != -1) { // if (iVcIndex == m_iDwnLdgIndex && m_iDwnLdgIndex != -1) if (vc_vFind[iVcIndex].iStyleDownSate > 2) { Timer2->Enabled = false; vc_vFind[iVcIndex].iStyleDownSate = 1; m_iOldItemState = 0; sg_tTmpMsg[iSgItemIndex].iStyleDownSate = 0; vectorvcItemsIndex; vcItemsIndex.push_back(iItemIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); OutputDebugString(L"Stop download the style;"); } else { MessageForm->ShowMessage(L"有风格已经开始下载,请等待...", MB_ICONINFORMATION | MB_OK); } } else { */ vc_vFind[iVcIndex].iStyleDownSate = 21; m_iOldItemState = 11; vectorvcItemsIndex; vcItemsIndex.push_back(iVcIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); m_iDwnLdgIndex = iVcIndex; RefreshAllStylesState(); Timer2->Enabled = true; int iStyleId = vc_vFind[iVcIndex].tStyleInfo.idStyle; HRESULT hr = f_CS_DownloadStyle(iStyleId, Handle); // } } } } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::m_pbPagesPaint(TObject *Sender) { // 显示总页数 m_pbPages->Canvas->Font->Size = g_szFont9; m_pbPages->Canvas->Font->Color = m_clFont; m_pbPages->Canvas->Brush->Style = bsClear; int x_pos = 0; if (m_nPageNum > 9) x_pos = 2; else x_pos = 5; m_pbPages->Canvas->TextOutW(x_pos, 0, IntToStr(m_nPageNum)); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::OnCollect(TObject* Sender) { TMenuItem* pItem = (TMenuItem*)Sender; // 收藏操作 if (!pItem->Checked) { if (m_stLstSelect.iIdCollect != 0) { if (!m_bCollectDelete) { // 增加收藏 vc_vCollect.push_back(m_stLstSelect.iIdCollect); } else { // 删除收藏 vc_vFind.clear(); vector::iterator plst; for (plst = vc_vCollect.begin(); plst != vc_vCollect.end(); plst++) { if (*plst == m_stLstSelect.iIdCollect) { vc_vCollect.erase(plst); break; } } if (vc_vCollect.size()) { for (int i = 0; i < sg_nMsg; i++) for (int j = 0; j < vc_vCollect.size(); j++) if (sg_tTmpMsg[i] .tStyleInfo.idStyle == vc_vCollect[j]) { vc_vFind.push_back(sg_tTmpMsg[i]); } } // 页码数 m_nPageNum = vc_vCollect.size() / LISTBOX_NUM_SHOW; m_nPageNum += vc_vCollect.size() % LISTBOX_NUM_SHOW ? 1 : 0; m_edtPageGo->Text = m_nPageNum ? 1 : 0; // 列表参数处理 if (m_stLstSelect.iOldSelectItemIndex != -1) { // 播放状态 int iSelect = (m_stLstSelect.iOldSelectPage - 1) * LISTBOX_NUM_SHOW + m_stLstSelect.iOldSelectItemIndex; if (m_iCollectDelete == iSelect) { // 删除选择或者播放的项 Stop(); m_stLstSelect.iOldSelectPage = -1; m_stLstSelect.iOldSelectItemIndex = -1; m_stLstSelect.bPlay = false; m_btnPlay->Enabled = false; m_btnTry->Enabled = false; } else { // 删除非选择或者播放的项 if (m_iCollectDelete < iSelect) { int ret = (m_stLstSelect.iOldSelectPage - 1) * LISTBOX_NUM_SHOW + m_stLstSelect.iOldSelectItemIndex; ret--; m_stLstSelect.iOldSelectPage = ret / LISTBOX_NUM_SHOW + 1; m_stLstSelect.iOldSelectItemIndex = ret % LISTBOX_NUM_SHOW; } } } // 页码参数处理 int deltePage = m_iCollectDelete / LISTBOX_NUM_SHOW + 1; int deleteItem = m_iCollectDelete % LISTBOX_NUM_SHOW; int dn = (vc_vCollect.size() + 1) / LISTBOX_NUM_SHOW; dn += (vc_vCollect.size() + 1) % LISTBOX_NUM_SHOW ? 1 : 0; int dv = (vc_vCollect.size() + 1) % LISTBOX_NUM_SHOW; if (dv == 1) { // 最后一页只有一个行 if (deltePage == m_stPageNum.iSelectPage) { // 当前页删除 if (m_stPageNum.iSelectPage > 1) { m_stPageNum.iSelectPage--; if (m_stPageNum.iStartPage > 1) { m_stPageNum.iStartPage--; } else { m_stPageNum.iCurrentPos--; } } else { m_stPageNum.iSelectPage = 1; m_stPageNum.iMovingPage = -1; m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 1; m_stPageNum.iMovingPos = -1; m_stPageNum.bShowDots = m_nPageNum > PAGE_NUM_SHOW ? true : false; } } else { // 非当前页删除 if (m_stPageNum.iStartPage > 1) m_stPageNum.iStartPage--; } } // 加载页 if (vc_vFind.size()) AddPageItem(m_stPageNum.iSelectPage); else // 查找内容为空 m_lbStyle->Clear(); m_lbStyle->SetPlayItemIndex(); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage && m_stLstSelect.iOldSelectPage != -1) { if (m_stLstSelect.bPlay) m_lbStyle->SetPlayItemIndex (m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } else { m_lbStyle->ItemIndex = -1; } ShowStyle(); m_lbStyle->Invalidate(); m_pbPages->Invalidate(); m_pbPageNum->Invalidate(); } } } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::EdtPageGoChange(TObject *Sender) { // 防止粘贴 String str = m_edtPageGo->Text; int n = str.Length(); if (n == 0) return; bool flag = false; for (int i = 1; i < n; i++) { if (str[i] < '0' || str[i] > '9') { m_edtPageGo->Clear(); flag = true; break; } } if (!flag) { if (StrToInt(str) > m_nPageNum) m_edtPageGo->Text = IntToStr(m_nPageNum); } } // --------------------------------------------------------------------------- int TStyleSelForm::GetStyle() { // 读文件,装载风格信息 bool bBeatChange = false; bool bSortChange = false; if( sg_iBeat != g_iMelodyTimeSignature ) bBeatChange = true; if( g_iCurStyleSort != g_iPreStyleSort ) bSortChange = true; if ( bBeatChange || bSortChange ) { if( bBeatChange ){ if (sg_aMsg) { delete sg_aMsg; sg_aMsg = NULL; } } if( sg_tTmpMsg ){ delete sg_tTmpMsg; sg_tTmpMsg = NULL; } sg_nMsg = 0; if (f_SM_GetStyleInfos(g_iMelodyTimeSignature, NULL, &sg_nMsg) == -1) return -1; sg_iBeat = g_iMelodyTimeSignature; g_iCurStyleSort = g_iPreStyleSort; if( bBeatChange ){ sg_aMsg = new TSTYLEINFO[sg_nMsg]; if (f_SM_GetStyleInfos(g_iMelodyTimeSignature, sg_aMsg, &sg_nMsg) == -1){ delete sg_aMsg; sg_nMsg = 0; return -1; } } sg_tTmpMsg = new DEFTSTYLEINFO[sg_nMsg]; System::Classes::TList* list_sg = new System::Classes::TList(); DEFTSTYLEINFO *tmpSG = NULL; for (int i = 0; i < sg_nMsg; i++) { tmpSG = new DEFTSTYLEINFO; if( bBeatChange ){ AnsiString strTmp = UTF8ToMBCS(sg_aMsg[i].detail.strAuthor) .c_str(); memcpy(sg_aMsg[i].detail.strAuthor, strTmp.c_str(), 40); strTmp = UTF8ToMBCS(sg_aMsg[i].detail.strStyleName).c_str(); memcpy(sg_aMsg[i].detail.strStyleName, strTmp.c_str(), 40); strTmp = UTF8ToMBCS(sg_aMsg[i].detail.strDescription).c_str(); memcpy(sg_aMsg[i].detail.strDescription, strTmp.c_str(), 120); } tmpSG->tStyleInfo = sg_aMsg[i]; tmpSG->iStyleDownSate = 0; list_sg->Add(tmpSG); } int iSortType, iSortMode; iSortType = g_iCurStyleSort & 0xffff; iSortMode = (g_iCurStyleSort & 0xffff0000)>>16; if( sg_nMsg ){ if( iSortType == STYLESORT_PRICE ){ list_sg->Sort(lessmarkCost); }else if( iSortType == STYLESORT_SCORE ){ list_sg->Sort(lessmarkScore); } int count = list_sg->Count; if(iSortMode==STYLESORT_DOWN){ for(int i=0; iItems[count-i-1]; } }else{ for(int i=0; iItems[i]; } } // for(int i=0; iCount; i++ ){ // // DebugPrint("strStyleName=%s", // ((DEFTSTYLEINFO *)list_sg->Items[i])->tStyleInfo.detail.strStyleName); // if(iSortType==1){ // DebugPrint(" cost=%d", // ((DEFTSTYLEINFO *)list_sg->Items[i])->tStyleInfo.cost); // }else if(iSortType==2){ // DebugPrint(" score=%d", // ((DEFTSTYLEINFO *)list_sg->Items[i])->tStyleInfo.score); // } // } } list_sg->Clear(); if(list_sg){ delete list_sg; } } int num = sg_nMsg / LISTBOX_NUM_SHOW; if (sg_nMsg % LISTBOX_NUM_SHOW) num++; m_nPageNum = num; // 读取收藏文件 int flen = 0; AnsiString strCollection = g_strUserPath.c_str(); strCollection += L"profile\\Collect.dat"; FILE *fpFrm = fopen(strCollection.c_str(), "rb"); if( fpFrm ){ fseek(fpFrm, 0, SEEK_END); flen = ftell(fpFrm); rewind(fpFrm); if( flen>0 ){ int *aCollect = new int[flen / sizeof(int)]; fread(aCollect, sizeof(int), flen / sizeof(int), fpFrm); vc_vCollect.clear(); for (int i = 0; i < flen / sizeof(int); i++) { vc_vCollect.push_back(aCollect[i]); } delete aCollect; } fclose(fpFrm); } return 0; } // --------------------------------------------------------------------------- int TStyleSelForm::FindStyle() { // 清空显示内容 if (vc_vFind.size()) vc_vFind.clear(); // 遍历每个风格信息, for (int i = 0; i < sg_nMsg; i++) { for (int index = 0; index < CHECK_NUM - 2; index++) { int iType1 = sg_tTmpMsg[i].tStyleInfo.detail.type[0]; int iType2 = sg_tTmpMsg[i].tStyleInfo.detail.type[1]; if( m_baChecks[CHECK_NUM-2] && sg_tTmpMsg[i].tStyleInfo.cost>0 ){ continue; } if ( m_baChecks[index] && ( index < CHECK_NUM - 3 && (iType1 == index || iType2 == index) || index == CHECK_NUM - 3 && (iType1 >= index || iType2 >=index ))) { bool bIsInsert = true; for (int j = 0; j < vc_vFind.size(); j++) { if (vc_vFind[j].tStyleInfo.idStyle == sg_tTmpMsg[i].tStyleInfo.idStyle) { bIsInsert = false; break; } } if (bIsInsert) { vc_vFind.push_back(sg_tTmpMsg[i]); } } } } /* // Debug Print Select Styles' Information String strPrintInfo = L"-------------------Begin-----------------------\r\n"; for (int i = 0; i < vc_vFind.size(); i++) { strPrintInfo += L"风格名:" + (String)vc_vFind[i].tStyleInfo.detail.strStyleName + L" 风格类型:(" + IntToStr(vc_vFind[i].tStyleInfo.detail.type[0]) + L"," + IntToStr(vc_vFind[i].tStyleInfo.detail.type[1]) + L");\r\n"; } strPrintInfo += L"-------------------End-----------------------\r\n"; OutputDebugString(strPrintInfo.c_str()); // -------------------------------------------------------------- */ vectorvcItemIndex; int iCurPage = 1; RefreshAllItem(vcItemIndex, iCurPage); m_lbStyle->SetItemIndex(vcItemIndex, iCurPage); vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, iCurPage, vcItemsIndex, true); m_lbStyle->ItemIndex = -1; return 0; } // --------------------------------------------------------------------------- /* int TStyleSelForm::IdToType(int id) { for (int i = 0; i < sg_nMsg; i++) { if (sg_aMsg[i].detail.iTimesignature == id) { g_lstStyleSelected.clear(); int aType[10] = {0}; // Need to modify by GGGrass char * strStyleType[] = { "流行", "民摇", "摇滚", "舞曲", "爵士", "蓝调", "桑巴", "古典", "圆舞曲", "独立"}; for (int iIndex = 0; iIndex < 10; iIndex++) { int iRet = 0; for (int jIndex = 0; jIndex < 2; jIndex++) { int index = sg_aMsg[i].detail.type[jIndex]; if (index >= 0 && index < 24) iRet += strstr(LSZ_STYLTYPES[index], strStyleType[iIndex]) ? 1 : 0; } aType[iIndex] = iRet > 0 ? 1 : 0; } g_iSelectedStyleType = 0; for (int j = 0; j < 10; j++) { DWORD temp = 0; temp = aType[j] << j; g_iSelectedStyleType |= temp; if (aType[j]) g_lstStyleSelected.push_back(j); } break; } } return 0; } */ // --------------------------------------------------------------------------- void TStyleSelForm::AddPageItem(int iPage) { m_lbStyle->Clear(); String strText; int iAdd = 0; char buf[20]; // m_lbStyle->Font->Style = TFontStyles()<tStyleInfo.detail.strStyleName; // 截取多余用……代替 strText += "_"; sprintf(buf, "%d", vc_pFind->tStyleInfo.cost); strText += buf; strText += "_"; strText += vc_pFind->tStyleInfo.detail.strDescription; // 截取多余用……代替 #ifdef _DEBUG OutputDebugString( strText.c_str() ); #endif m_lbStyle->AddItem( strText, NULL );// >Items->Add(strText); } iAdd++; } OutputDebugString( L"AddPageItem done" ); } // --------------------------------------------------------------------------- void TStyleSelForm::OnShowStyle() { int num = vc_vFind.size() / LISTBOX_NUM_SHOW; if (vc_vFind.size() % LISTBOX_NUM_SHOW) num++; m_nPageNum = num; if (1) { // m_btnPlay->Visible = true; // m_btnStop->Visible = false; m_btnPlay->Enabled = true; m_btnTry->Enabled = true; } // Hit提示索引 m_iHitItemIndex = -1; m_bCollectDelete = false; m_iCollectDelete = -1; // 初始化数字页码显示的有关参数 m_stPageNum.iSelectPage = 1; m_stPageNum.iMovingPage = -1; m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 1; m_stPageNum.iMovingPos = -1; m_stPageNum.bShowDots = m_nPageNum > PAGE_NUM_SHOW ? true : false; // 初始化列表选择的有关参数 m_stLstSelect.iOldSelectPage = -1; m_stLstSelect.iOldSelectItemIndex = -1; m_stLstSelect.iSelect = -1; m_stLstSelect.iIdCollect = 0; m_stLstSelect.bPlay = false; // 刷新总页数、数字页码 m_pbPages->Invalidate(); m_pbPageNum->Invalidate(); int nM = 0; for (vc_pFind = vc_vFind.begin(); vc_pFind != vc_vFind.end(); vc_pFind++) { nM++; if (vc_pFind->tStyleInfo.idStyle == m_idSelected) { break; } } int iPage = nM / LISTBOX_NUM_SHOW; if (nM % LISTBOX_NUM_SHOW) iPage++; int iPageSelected = (nM - 1) % LISTBOX_NUM_SHOW; m_stLstSelect.iSelect = nM - 1; m_edtPageGo->Text = iPage; if (iPage == 1) { AddPageItem(1); m_lbStyle->SetPlayItemIndex(); m_lbStyle->ItemIndex = iPageSelected; m_stLstSelect.iOldSelectPage = 1; m_stLstSelect.iOldSelectItemIndex = iPageSelected; if (e_UnDownload == vc_vFind[(nM - 1)].tStyleInfo.state) { m_iOldItemIndex = iPageSelected; vc_vFind[(nM - 1)].iStyleDownSate = 1; vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); } m_lbStyle->Invalidate(); // return; } else{ PageGoClick(NULL); } if (m_nPageNum==0) // m_edtPageGo->Text = 1; // else m_edtPageGo->Text = 0; m_stLstSelect.iOldSelectPage = iPage; m_stLstSelect.iOldSelectItemIndex = iPageSelected; m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } // --------------------------------------------------------------------------- void TStyleSelForm::ShowStyle() { // 得到查找结果总页数 int num = vc_vFind.size() / LISTBOX_NUM_SHOW; if (vc_vFind.size() % LISTBOX_NUM_SHOW) num++; m_nPageNum = num; if (m_nPageNum) m_edtPageGo->Text = 1; else m_edtPageGo->Text = 0; // Hit提示索引 m_iHitItemIndex = -1; m_bCollectDelete = false; m_iCollectDelete = -1; // 初始化数字页码显示的有关参数 m_stPageNum.iSelectPage = 1; m_stPageNum.iMovingPage = -1; m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = 1; m_stPageNum.iMovingPos = -1; m_stPageNum.bShowDots = m_nPageNum > PAGE_NUM_SHOW ? true : false; // 初始化列表选择的有关参数 m_stLstSelect.iOldSelectPage = -1; m_stLstSelect.iOldSelectItemIndex = -1; m_stLstSelect.iSelect = -1; m_stLstSelect.iIdCollect = 0; m_stLstSelect.bPlay = false; // 刷新总页数、数字页码 m_pbPages->Invalidate(); m_pbPageNum->Invalidate(); /* if (vc_vFind.size()) { // 刷新列表 AddPageItem(m_stPageNum.iSelectPage); } else { // 查找内容为空 m_lbStyle->Clear(); OutputDebugString(L"查找内容为空"); } */ m_lbStyle->SetPlayItemIndex(); m_lbStyle->ItemIndex = -1; vectorvcItemIndex; int iCurPage = 1; // OutputDebugString( L"RefreshAllItem..." ); RefreshAllItem(vcItemIndex, iCurPage); // OutputDebugString( L"done.\nSetItemIndex..." ); m_lbStyle->SetItemIndex(vcItemIndex, iCurPage); // OutputDebugString( L"done.\nResetItemsData..." ); // Add By GGGrass 2012年12月5日 15:12:08 if (vc_vFind.size()) { vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, iCurPage, vcItemsIndex, false); } // OutputDebugString( L"done." ); // End Add By GGGrass 2012年12月5日 15:12:18 //m_lbStyle->Invalidate(); if (vc_vFind.size()) { // 刷新列表 AddPageItem(m_stPageNum.iSelectPage); } else { // 查找内容为空 OutputDebugString(L"查找内容为空"); m_lbStyle->Clear(); } // m_lbStyle->Invalidate(); } // --------------------------------------------------------------------------- void TStyleSelForm::Play() { Stop(); if (m_stLstSelect.iOldSelectPage == -1) return; // 视听类型 int iType=-1, iNo=-1; for( int iRadio = 0; iRadio < RADIO_NUM-1; iRadio++ ){ if (m_baRadio[iRadio] != 0){ iNo = iRadio % 4; iType = iRadio / 4; break; } } BYTE pData[100000]; int nDataSize = 100000; int iPlayMode = 0; if( m_bBase && iType==-1 ){ iPlayMode = 1; //播放基本编曲+旋律 } else if( !m_bBase && iType==-1 ){ iPlayMode = 2; //从头播放完整编曲 } else if( !m_bBase && m_iSegType==0 ){ iPlayMode = 3; //从指定段开始播放编曲+旋律 } if( iPlayMode==1 ){ g_iSelectedStyleID = vc_pFind->tStyleInfo.idStyle; g_strSelectedStyleName = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.detail.strStyleName; GenerateBaseCompose(); HRESULT hr = f_MM_Play( Handle, 0, TYPE_AUDIO_BASECOMPOSE ); } else if( iPlayMode==2 ){ COMPOSESTAGELIST lstComposeStages; DuplicateComposeStages( lstComposeStages, vc_pFind->tStyleInfo.idStyle ); BYTE pBuffer[100000]; int nBufferLength = 100000; int nTemp=0; int ret = GetComposeData( lstComposeStages, g_iMelodyKey, nDataSize, pData, false, nTemp, NULL ); f_MM_PlayStyleDemo( pData, nDataSize, g_nMelodyTempo); for( int i=0; iidStyle = vc_pFind->tStyleInfo.idStyle; g_lstComposeStages[m_iSelStage]->iVar = iNo; if( vc_pFind->tStyleInfo.idStyle!=g_iSelectedStyleID ){ g_lstComposeStages[m_iSelStage]->strStyleName = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.detail.strStyleName; } else{ g_lstComposeStages[m_iSelStage]->strStyleName = ""; } GenerateCompose( g_iMelodyKey, false ); int nBeginBar = 0; for( int i=0; inStageBars; } HRESULT hr = f_MM_Play( Handle, nBeginBar, TYPE_SONG_COMPOSE ); } else{ HRESULT hr = f_SM_GetStyleDemo( nDataSize, pData, vc_pFind->tStyleInfo.idStyle, iType, iNo, g_iMelodyKey, m_iChordType); f_MM_PlayStyleDemo( pData, nDataSize, g_nMelodyTempo); } m_btnPlay->Visible = false; m_btnStop->Visible = true; m_btnTry->Enabled = true; } // --------------------------------------------------------------------------- void TStyleSelForm::Stop() { f_MM_Stop(); m_btnPlay->Visible = true; m_btnStop->Visible = false; } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::FindClick(TObject *Sender) { m_btnCollect->Down = false; m_btnRecord->Down = false; m_btnFind->Down = true; m_edSearch->Visible = false; m_imgSrearch->Visible = false; m_btnPngSearch->Down = false; m_btnRecommand->Down = false; if (m_iBtnState == BTNSTATE_FIND) { m_ImgFind->Visible = !m_ImgFind->Visible; return; } else { Stop(); m_btnPlay->Enabled = false; m_btnTry->Enabled = false; m_stLstSelect.bPlay = false; m_lbStyle->SetPlayItemIndex(); m_lbStyle->ItemIndex = -1; m_iBtnState = BTNSTATE_FIND; if (!m_ImgFind->Visible) { FindStyle(); if (Sender) ShowStyle(); } m_ImgFind->Visible = !m_ImgFind->Visible; } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::CollectClick(TObject *Sender) { m_btnCollect->Down = true; m_btnFind->Down = false; m_btnRecord->Down = false; m_edSearch->Visible = false; m_imgSrearch->Visible = false; m_btnPngSearch->Down = false; m_btnRecommand->Down = false; if (m_iBtnState == BTNSTATE_COLLECT ) { return; } Stop(); m_btnPlay->Enabled = false; m_btnTry->Enabled = false; m_stLstSelect.bPlay = false; m_lbStyle->SetPlayItemIndex(); m_iBtnState = BTNSTATE_COLLECT; m_ImgFind->Visible = false; if (vc_vFind.size()) vc_vFind.clear(); DebugPrint( "colect %d.\n", vc_vCollect.size() ); if (vc_vCollect.size()) { for (int i = 0; i < sg_nMsg; i++) { for (int j = 0; j < vc_vCollect.size(); j++) { if (sg_tTmpMsg[i].tStyleInfo.idStyle == vc_vCollect[j]) vc_vFind.push_back(sg_tTmpMsg[i]); } } } if (Sender) ShowStyle(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::RecordClick(TObject *Sender) { m_btnCollect->Down = false; m_btnFind->Down = false; m_btnRecord->Down = true; m_btnRecommand->Down = false; if (m_iBtnState == BTNSTATE_RECORD) return; Stop(); m_btnPlay->Enabled = false; m_btnTry->Enabled = false; m_stLstSelect.bPlay = false; m_lbStyle->SetPlayItemIndex(); m_iBtnState = BTNSTATE_RECORD; m_ImgFind->Visible = false; m_edSearch->Visible = false; m_imgSrearch->Visible = false; m_btnPngSearch->Down = false; if (vc_vFind.size()) vc_vFind.clear(); for (vc_pFind = vc_vUseRecord.begin(); vc_pFind != vc_vUseRecord.end(); vc_pFind++){ if( vc_pFind->tStyleInfo.detail.iTimesignature==g_iMelodyTimeSignature ) vc_vFind.push_back(*vc_pFind); } if (Sender) ShowStyle(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PlayClick(TObject *Sender) { Stop(); if (m_stLstSelect.iOldSelectItemIndex == -1) return; // 播放 vc_pFind = vc_vFind.begin() + (m_stLstSelect.iOldSelectPage - 1) * LISTBOX_NUM_SHOW + m_stLstSelect.iOldSelectItemIndex; // 得到索引ID // m_btnTry->Enabled = true; m_stLstSelect.bPlay = true; // m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); // m_lbStyle->Invalidate(); Play(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::StopClick(TObject *Sender) { Stop(); m_lbStyle->SetPlayItemIndex(); m_lbStyle->Invalidate(); m_stLstSelect.bPlay = false; } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::TryClick(TObject *Sender) { Stop(); if (m_stLstSelect.iSelect != -1) { bool flag = true; for (vc_pFind = vc_vUseRecord.begin(); vc_pFind != vc_vUseRecord.end(); vc_pFind++){ if (vc_pFind->tStyleInfo.idStyle == (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.idStyle) { flag = false; break; } } if (flag) vc_vUseRecord.push_back(*(vc_vFind.begin() + m_stLstSelect.iSelect)); int idSel = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.idStyle; if( idSel != m_idSelected ){ g_bComposeLoaded = false; m_idSelected = idSel; m_strName = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.detail.strStyleName; if( m_iSegType==-1 ){ g_bBaseComposeLoaded = false; } } // 保存本次查找风格种类 // IdToType(g_iSelectedStyleID); g_lstStyleSelected.clear(); g_iSelectedStyleType = 0; for (int i = 0; i < CHECK_NUM; i++) { DWORD temp = 0; if (m_baChecks[i]) { temp = 1 << i; g_iSelectedStyleType |= temp; g_lstStyleSelected.push_back(i); } } for( int j=0; j<4; j++ ){ if( m_baRadio[m_iSegType*4+j]==1 ){ m_iSegNo = j; } } } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::PageGoClick(TObject *Sender) { if (!vc_vFind.size()) return; int temp = m_stPageNum.iSelectPage; m_stPageNum.iSelectPage = StrToInt(m_edtPageGo->Text); if (m_nPageNum <= PAGE_NUM_SHOW) { // 页数小于等于 PAGE_NUM_SHOW m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = m_stPageNum.iSelectPage; m_stPageNum.bShowDots = false; } else { // 页数大于 PAGE_NUM_SHOW int rg = m_nPageNum - m_stPageNum.iSelectPage; if (rg <= 2) { m_stPageNum.bShowDots = false; m_stPageNum.iStartPage = m_nPageNum - PAGE_NUM_SHOW + 1; m_stPageNum.iCurrentPos = PAGE_NUM_SHOW - rg; } else { m_stPageNum.bShowDots = true; if (m_stPageNum.iSelectPage <= 4) { m_stPageNum.iStartPage = 1; m_stPageNum.iCurrentPos = m_stPageNum.iSelectPage; } else { m_stPageNum.iStartPage = m_stPageNum.iSelectPage - 3; m_stPageNum.iCurrentPos = 4; } } } // 跳转到当前页 if (m_stPageNum.iSelectPage == temp) return; m_pbPages->Invalidate(); m_pbPageNum->Invalidate(); AddPageItem(m_stPageNum.iSelectPage); if (m_stPageNum.iSelectPage == m_stLstSelect.iOldSelectPage) { m_lbStyle->SetPlayItemIndex(m_stLstSelect.iOldSelectItemIndex); m_lbStyle->ItemIndex = m_stLstSelect.iOldSelectItemIndex; } else { m_lbStyle->SetPlayItemIndex(); } vectorvcItemsIndex; m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); //m_lbStyle->Invalidate(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::HintTimerProc(TObject* Sender) { m_pTimerHint->Enabled = false; if (m_iHitItemIndex == -1) return; TPoint point(m_xPos - 20, m_yPos + 20); point = m_lbStyle->ClientToScreen(point); int iSel = (m_stPageNum.iSelectPage - 1) * LISTBOX_NUM_SHOW + m_iHitItemIndex; vector::iterator plst; plst = vc_vFind.begin() + iSel; String strHint = "名称:"; strHint += plst->tStyleInfo.detail.strStyleName; strHint += "\n消耗: "; char buf[20]; sprintf(buf, "%d(唱作音符)", plst->tStyleInfo.cost); strHint += buf; strHint += "\n描述:"; strHint += plst->tStyleInfo.detail.strDescription; strHint += "\n类型: "; String strType; for( int i=0; i<2; i++ ){ int type = plst->tStyleInfo.detail.type[i]; if( type<0 ) break; else{ if( type<24 ){ strType += (String)LSZ_STYLTYPES[type] + " "; } } } if (strType == L"") { strType = L"未知类型"; } strHint += strType; int score10 = (int)(plst->tStyleInfo.score/10.0 + 0.5); sprintf( buf, "%.1f", score10 / 10.0 ); strHint += "\n评分:"; strHint += buf; strHint += "(由专业版用户评分)"; m_pShowHint->ShowHintWindow(point, strHint); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { switch (Key) { case VK_RETURN: if (m_btnTry->Enabled) TryClick(NULL); break; case VK_ESCAPE: ModalResult = mrCancel; break; } } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::RecommandClick(TObject *Sender) { m_btnCollect->Down = false; m_btnFind->Down = false; m_btnRecord->Down = false; m_btnRecommand->Down = true; Stop(); m_ImgFind->Visible = false; m_btnPlay->Enabled = false; m_btnTry->Enabled = false; m_edSearch->Visible = false; m_imgSrearch->Visible = false; m_btnPngSearch->Down = false; m_stLstSelect.bPlay = false; if (m_iBtnState == BTNSTATE_RECOMMAND) return; m_iBtnState = BTNSTATE_RECOMMAND; m_lbStyle->SetPlayItemIndex(); m_lbStyle->ItemIndex = -1; if (vc_vFind.size()) { vc_vFind.clear(); } int rs_nMsg; if( f_SM_GetStyleRecomInfos(g_iMelodyTimeSignature, NULL, &rs_nMsg)==-1 || rs_nMsg==0 ) return; TSTYLEINFO *rs_aMsg = new TSTYLEINFO[rs_nMsg]; if (f_SM_GetStyleRecomInfos(g_iMelodyTimeSignature, rs_aMsg, &rs_nMsg) == -1){ delete rs_aMsg; rs_nMsg = 0; return; } DebugPrint("rs_nMsg=%d", rs_nMsg); for (int iIndex = 0; iIndex < sg_nMsg; iIndex++){ for (int indexRs = 0; indexRs < rs_nMsg; indexRs++) { if (rs_aMsg[indexRs].idStyle == sg_tTmpMsg[iIndex].tStyleInfo.idStyle){ vc_vFind.push_back(sg_tTmpMsg[iIndex]); break; } } } delete[] rs_aMsg; if(Sender) ShowStyle(); } // --------------------------------------------------------------------------- /* void TStyleSelForm::SetBtnPosByLogState(bool bIsLog) { // Recalculate the contorl position int iIntral = (m_btnRecord->Left - m_btnFind->BoundsRect.Right - m_btnRecord->Width * (bIsLog ? 3 : 2)) / (bIsLog ? 4 : 3); m_btnCollect->Left = m_btnFind->BoundsRect.Right + iIntral; m_btnRecommand->Left = m_btnCollect->BoundsRect.Right + iIntral; int iLeft = bIsLog ? m_btnRecommand->BoundsRect.Right : m_btnCollect->BoundsRect.Right; m_btnPngSearch->Left = iLeft + iIntral; m_btnRecommand->Visible = bIsLog; } */ void TStyleSelForm::RefreshAllItem(vector& vcIndexID, int & iPageIndex) { if (vcIndexID.size()) vcIndexID.clear(); // Display the strikeout-line while user logon and not in pay-page and listen page if (!g_bLogon || (g_bLogon && m_btnRecommand->Down)){ OutputDebugString( L"no items" ); return; } for (int i = 0; i < g_infoUser.ownStyleNum; i++) { for (int index = 0; index < vc_vFind.size(); index++) { vc_pFind = vc_vFind.begin() + index; if (vc_pFind->tStyleInfo.idStyle == g_infoUser.arrStyleId[i]) { vcIndexID.push_back(index); } } } iPageIndex = m_stPageNum.iSelectPage; } void TStyleSelForm::RefreshSearchStyles(const String strStyleName) { // 清空显示内容 if (vc_vFind.size()) vc_vFind.clear(); // 遍历每个风格信息, for (int i = 0; i < sg_nMsg; i++) { AnsiString strTmp = sg_tTmpMsg[i].tStyleInfo.detail.strStyleName; if (strStyleName == L"" || strTmp.Pos(strStyleName) > 0) { { vc_vFind.push_back(sg_tTmpMsg[i]); } } } ShowStyle(); } void __fastcall TStyleSelForm::m_edSearchChange(TObject *Sender) { String strTxtName = m_edSearch->Text.Trim(); RefreshSearchStyles(strTxtName); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::OnTimerDraw(TObject *Sender) { for (int i = 0; i < vc_vFind.size(); i++) { if (vc_vFind[i].iStyleDownSate > 1) { int iDwnLoadState = vc_vFind[i].iStyleDownSate - 2; vc_vFind[i].iStyleDownSate = (++iDwnLoadState) % 10 + 2; int iHotIndex = (m_stPageNum.iSelectPage - 1) * LISTBOX_NUM_SHOW + m_lbStyle->ItemIndex; if (i == iHotIndex) { vc_vFind[i].iStyleDownSate += 10; } vectorvcItemsIndex; if (vcItemsIndex.size()) vcItemsIndex.clear(); vcItemsIndex.push_back(i); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); break; } } } // --------------------------------------------------------------------------- void TStyleSelForm::RefreshAllStylesState() { for (int i = 0; i < vc_vFind.size(); i++) { if (vc_vFind[i].iStyleDownSate > 1) { for (int j = 0; j < sg_nMsg; j++) { if (sg_tTmpMsg[j].tStyleInfo.idStyle == vc_vFind[i] .tStyleInfo.idStyle) { sg_tTmpMsg[j].iStyleDownSate = vc_vFind[i].iStyleDownSate; return; } } } } } void __fastcall TStyleSelForm::OnNetworkMessage(TMessage &msg) { WORD eMessage = HIWORD(msg.WParam); WORD eExtra = LOWORD(msg.WParam); /* if(g_bLogon) f_CS_DownloadStyle(pStyle->idStyle, Handle); */ switch (eMessage) { case e_styleInfoResponse: // download the style data { if (0 == eExtra) { int iRet = 0; int iStyleId = msg.LParam; TSTYLEINFO pStyleInfo; iRet = f_SM_GetStyleInfo(iStyleId, &pStyleInfo); // sg_tTmpMsg for (int i = 0; i < sg_nMsg; i++) { if (sg_tTmpMsg[i].tStyleInfo.idStyle == iStyleId) { sg_tTmpMsg[i].tStyleInfo = pStyleInfo; break; } } if (0 == iRet) {; // InsertNetWorkListView(pStyleInfo); } else { String strError = L"Excute Function \"GetStyleInfo()\" Failed,StyleID = " + IntToStr(iStyleId); OutputDebugString(strError.c_str()); } } else if (eExtra == e_DatabaseError) { DebugPrint("服务器数据访问失败!\n"); } } break; case e_styleDataResponse: { // Data has downloaded if (0 == eExtra) { int iRet = 0; int iStyleId = msg.LParam; // Need to modify by GGGrass 2013年1月21日 10:59:40 // Here will stop the timer and reset the styles display // data and invalidate the listview control's data int iVcIndex = -1; for (int i = 0; i < vc_vFind.size(); i++) { if (iStyleId == vc_vFind[i].tStyleInfo.idStyle) { vc_vFind[i].tStyleInfo.state = e_Downloaded; vc_vFind[i].iStyleDownSate = 0; iVcIndex = i; break; } } for (int i = 0; i < sg_nMsg; i++) { if (iStyleId == sg_tTmpMsg[i].tStyleInfo.idStyle) { sg_tTmpMsg[i].tStyleInfo.state = e_Downloaded; sg_tTmpMsg[i].iStyleDownSate = 0; } } vectorvcItemsIndex; vcItemsIndex.push_back(iVcIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); RefreshAllStylesState(); m_lbStyle->Invalidate(); if( (m_stLstSelect.iOldSelectPage - 1)* LISTBOX_NUM_SHOW + m_stLstSelect.iOldSelectItemIndex==iVcIndex ){ m_btnPlay->Enabled = true; m_btnTry->Enabled = true; } } } break; default: break; } } void __fastcall TStyleSelForm::OnDownLoadStyle(TObject* Sender) { // OutputDebugString(L".........Begin to download style........."); int iVcIndex = -1; for (int i = 0; i < vc_vFind.size(); i++) { if (vc_pFind->tStyleInfo.idStyle == vc_vFind[i].tStyleInfo.idStyle) { iVcIndex = i; break; } } if (iVcIndex == -1) return; vc_vFind[iVcIndex].iStyleDownSate = 12; m_iOldItemState = 2; vectorvcItemsIndex; vcItemsIndex.push_back(iVcIndex); m_lbStyle->ResetItemsData(vc_vFind, m_stPageNum.iSelectPage, vcItemsIndex, true); m_iDwnLdgIndex = iVcIndex; RefreshAllStylesState(); Timer2->Enabled = true; // Here can download the style's data // if (g_bLogon) { int iStyleId = vc_vFind[iVcIndex].tStyleInfo.idStyle; HRESULT hr = f_CS_DownloadStyle(iStyleId, Handle); String strStyleID = L"Begin to download the stlye(id) = " + IntToStr(iStyleId) + L"~~~;"; OutputDebugString(strStyleID.c_str()); // } } void __fastcall TStyleSelForm::OnSearchStyles(TObject *Sender) { m_btnPngSearch->Down = true; m_btnCollect->Down = false; m_btnFind->Down = false; m_btnRecord->Down = false; m_btnRecommand->Down = false; m_edSearch->Visible = true; m_imgSrearch->Visible = true; m_imgSrearch->Transparent = true; m_ImgFind->Visible = false; m_btnRecommand->Down = false; if (m_iBtnState == BTNSTATE_SERACH) return; Stop(); // FindStyle(); m_lbStyle->SetPlayItemIndex(); // String strTxtName = m_edSearch->Text.Trim(); m_iBtnState = BTNSTATE_SERACH; // 清空显示内容 if (vc_vFind.size()) vc_vFind.clear(); // 遍历每个风格信息, for (int i = 0; i < sg_nMsg; i++) { vc_vFind.push_back(sg_tTmpMsg[i]); } ShowStyle(); m_edSearch->SetFocus(); } // --------------------------------------------------------------------------- void __fastcall TStyleSelForm::FormActivate(TObject *Sender) { // if(m_bActiveHappened) return; // else m_bActiveHappened = true; OutputDebugString( L"Form activate!" ); for( int i=0; i9 ) nM = 9; if( m_baChecks[nM]==0 ){ m_baChecks[nM] = 1; g_lstStyleSelected.push_back(nM); } break; } } bool bFindSelStyle = false; int rs_nMsg; if (f_SM_GetStyleRecomInfos(g_iMelodyTimeSignature, NULL, &rs_nMsg) == -1) bFindSelStyle = false; TSTYLEINFO *rs_aMsg = new TSTYLEINFO[rs_nMsg]; if (f_SM_GetStyleRecomInfos(g_iMelodyTimeSignature, rs_aMsg, &rs_nMsg) == -1){ delete rs_aMsg; rs_nMsg = 0; bFindSelStyle = false; } for (int indexRs = 0; indexRs < rs_nMsg; indexRs++) { if (rs_aMsg[indexRs].idStyle == m_idSelected) { bFindSelStyle = true; break; } } if(rs_aMsg) delete rs_aMsg; if( bFindSelStyle ){ RecommandClick(NULL); }else{ FindStyle(); } ShowStyle(); int nM = 0; for (vc_pFind = vc_vFind.begin(); vc_pFind != vc_vFind.end(); vc_pFind++) { nM++; if (vc_pFind->tStyleInfo.idStyle == m_idSelected){ if( vc_vUseRecord.empty() ) vc_vUseRecord.push_back(*vc_pFind); break; } } int iPage = nM / LISTBOX_NUM_SHOW; if (nM % LISTBOX_NUM_SHOW) iPage++; int iPageSelected = (nM - 1) % LISTBOX_NUM_SHOW; m_stLstSelect.iSelect = nM - 1; m_edtPageGo->Text = iPage; if( iPage>1 ){ PageGoClick(NULL); } m_stLstSelect.iOldSelectPage = iPage; m_stLstSelect.iOldSelectItemIndex = iPageSelected; m_lbStyle->ItemIndex = iPageSelected; /* // Judge the control position by logon state // SetBtnPosByLogState(g_bLogon); // if (g_bLogon) { vectorvcItemIndex; RefreshAllItem(vcItemIndex, iPage); RefreshAllStylesState(); m_lbStyle->SetItemIndex(vcItemIndex, iPage); m_lbStyle->Invalidate(); // } */ if( m_iSelStage>=0 ){ m_lblTitle->Caption = L"---分段设定---"; m_pbRadio[12]->Enabled = false; m_baRadio[12] = 0; for( int i=0; i<3; i++ ){ for( int j=0; j<4; j++ ){ if( i!=m_iSegType ){ m_pbRadio[i*4 + j]->Enabled = false; } } } m_baRadio[m_iSegType * 4 + m_iSegNo ] = 1; } } //--------------------------------------------------------------------------- void __fastcall TStyleSelForm::FormClose(TObject *Sender, TCloseAction &Action) { // Add By GGGrass 2012年12月7日 11:34:17 int iStyleDlIndex = -1; for (int i = 0; i < sg_nMsg; i++) { if (sg_tTmpMsg[i].iStyleDownSate > 1 && e_Downloaded != sg_tTmpMsg[i].tStyleInfo.state) { iStyleDlIndex = i; break; } } if (-1 != iStyleDlIndex) { int iRet = MessageForm->ShowMessage("有风格正在下载,退出将停止风格下载?", MB_ICONQUESTION | MB_YESNO); if (iRet != IDYES) return; else { sg_tTmpMsg[iStyleDlIndex].iStyleDownSate = 0; } } // End Add By GGGrass 2012年12月7日 11:34:13 f_MM_Stop(); AnsiString strCollection = g_strUserPath.c_str(); strCollection += L"profile\\Collect.dat"; if (vc_vCollect.size()) { // 保存收藏 int *aCollect = new int[vc_vCollect.size()]; for (int i = 0; i < vc_vCollect.size(); i++) aCollect[i] = vc_vCollect[i]; FILE *fpCollect = fopen(strCollection.c_str(), "wb"); if( fpCollect ){ fwrite(aCollect, sizeof(int), vc_vCollect.size(), fpCollect); fclose(fpCollect); } delete aCollect; } else { // 清除文件 remove(strCollection.c_str()); } f_CS_CancelOperation(); } //--------------------------------------------------------------------------- void __fastcall TStyleSelForm::OnPlayOver(TMessage &msg) { StopClick( NULL ); } //--------------------------------------------------------------------------- void TStyleSelForm::DuplicateComposeStages( COMPOSESTAGELIST& lstComposeStages, int idStyle ) { for( int i=0; iiMelodyStage = g_lstComposeStages[i]->iMelodyStage; pNewStage->iVar = g_lstComposeStages[i]->iVar; for( int j=0; jaFills.size(); j++ ){ pNewStage->aFills.push_back( g_lstComposeStages[i]->aFills[j] ); } if( g_lstComposeStages[i]->idStyle==g_iSelectedStyleID ){ pNewStage->idStyle = idStyle; if( pNewStage->iMelodyStage<0x100 ){ pNewStage->nStageBars = g_lstComposeStages[i]->nStageBars; } else if( pNewStage->iMelodyStage<0x110 ){ int iVar = pNewStage->iMelodyStage - 0x100; pNewStage->nStageBars = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.detail.aIntroBars[iVar]; } else{ int iVar = pNewStage->iMelodyStage - 0x110; pNewStage->nStageBars = (vc_vFind.begin() + m_stLstSelect.iSelect)->tStyleInfo.detail.aEndingBars[iVar]; } } else{ pNewStage->idStyle = g_lstComposeStages[i]->idStyle; pNewStage->nStageBars = g_lstComposeStages[i]->nStageBars; } lstComposeStages.push_back( pNewStage ); } } //---------------------------------------------------------------------------