1893 lines
50 KiB
C++
1893 lines
50 KiB
C++
// ---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "GlobalUnit.h"
|
|
#include "MainFormUnit.h"
|
|
#include "StyleSetFormUnit.h"
|
|
#include "HarmonyFormUnit.h"
|
|
#include "LoginFormUnit.h"
|
|
#include "TryListenFormUnit.h"
|
|
#include "Instruments.h"
|
|
#include "AboutFormUnit.h"
|
|
#include "ProgressFormUnit.h"
|
|
#include "StylesUpProgressFormUnit.h"
|
|
#include "VerifyStylesFormUnit.h"
|
|
|
|
// ---------------------------------------------------------------------------
|
|
#pragma package(smart_init)
|
|
#pragma resource "*.dfm"
|
|
TMainForm *MainForm;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
__fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner)
|
|
{
|
|
m_strExlFileName = L"";
|
|
m_strMidiDirPath = L"";
|
|
m_iNeedUpdateNum = 0;
|
|
m_iVcIndex = -1;
|
|
|
|
memset(m_cStyleTypes, -1, 2);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::FormCreate(TObject *Sender)
|
|
{
|
|
string strRoot = ((AnsiString)g_strExecutePath.c_str()).c_str();
|
|
|
|
OutputDebugStringA("Begin to Init Media Control Data...\n");
|
|
|
|
HRESULT hResult = f_MM_InitialObjects(Handle, (char*)strRoot.c_str());
|
|
if (S_OK != hResult) {
|
|
OutputDebugStringA("InitialObjects failed~~~\n");
|
|
return ;
|
|
}
|
|
|
|
InitFontList();
|
|
|
|
mdBtn1->Tag = 0;
|
|
mdBtn2->Tag = 0;
|
|
mdBtn2->Visible = false;
|
|
stLabel1->Caption = L"添加风格";
|
|
stLabel2->Caption = L"添加风格";
|
|
|
|
g_bRecreator = true;
|
|
|
|
memset(m_cStyleTypes, -1, 2);
|
|
|
|
// m_bIsMadeStyle = FALSE;
|
|
|
|
// Refresh styles set information's position
|
|
ReposTypeCtrls();
|
|
ResetStylesData(true);
|
|
InitCheckerView();
|
|
|
|
// 执行文件版本信息
|
|
DWORD dwHandle;
|
|
DWORD dwVerLen = GetFileVersionInfoSize(Application->ExeName.c_str(),
|
|
&dwHandle);
|
|
if (dwVerLen) {
|
|
TCHAR *lpData = new TCHAR[dwVerLen];
|
|
if (GetFileVersionInfo(Application->ExeName.c_str(), 0, dwVerLen,
|
|
lpData)) {
|
|
PVSFixedFileInfo lpffi;
|
|
UINT uLen;
|
|
if (VerQueryValue(lpData, TEXT("\\"), (void **)&lpffi, &uLen)) {
|
|
g_infoSoftwareUpdate.version.majorVersion =
|
|
HIWORD(lpffi->dwFileVersionMS);
|
|
g_infoSoftwareUpdate.version.minorVersion =
|
|
LOWORD(lpffi->dwFileVersionMS);
|
|
g_infoSoftwareUpdate.version.modifyVersion =
|
|
HIWORD(lpffi->dwFileVersionLS);
|
|
g_infoSoftwareUpdate.version.buildVersion =
|
|
LOWORD(lpffi->dwFileVersionLS);
|
|
}
|
|
}
|
|
delete[]lpData;
|
|
}
|
|
|
|
sprintf(g_strCurrentVersion, "%d.%d.%d.%04d",
|
|
g_infoSoftwareUpdate.version.majorVersion,
|
|
g_infoSoftwareUpdate.version.minorVersion,
|
|
g_infoSoftwareUpdate.version.modifyVersion,
|
|
g_infoSoftwareUpdate.version.buildVersion);
|
|
|
|
// strcpy( g_strServerURL, "ComposeMusic.xicp.net:81" );
|
|
// strcpy( g_strServerURL, "192.168.5.80" );
|
|
// strcpy( g_strServerURL, "localhost" );
|
|
char idDevice[6];
|
|
*(UINT*)idDevice = time(NULL);
|
|
*(USHORT*)(idDevice+4) = Random(65536);
|
|
|
|
if (f_CS_InitialService(Handle, SOFTWARE_ID, &g_infoSoftwareUpdate,
|
|
g_strServerURL, (char*)strRoot.c_str(),
|
|
idDevice ) == S_OK) {
|
|
g_bAutoLogin = GetAutoLogin(g_infoUser.strUserName,
|
|
g_infoUser.strPassword);
|
|
|
|
// Retset the login settings paramater if the UserName or Password is empty
|
|
int iRetPs = strcmp(g_infoUser.strPassword, "");
|
|
int iRetUs = strcmp(g_infoUser.strUserName, "");
|
|
|
|
if (g_bAutoLogin && iRetPs && iRetUs) {
|
|
f_CS_Login(&g_infoUser, false);
|
|
m_btnLogin->Caption = L"取消登录";
|
|
m_lbUserInfo->Caption = L"正在登录...";
|
|
m_lbUserInfo->Visible = true;
|
|
}
|
|
else {
|
|
g_bAutoLogin = false;
|
|
}
|
|
}
|
|
else {
|
|
MessageBox(Handle, L"网络服务启动失败!\n(将无法进行网络相关操作)", L"错误提示",
|
|
MB_ICONERROR | MB_OK);
|
|
return;
|
|
}
|
|
|
|
f_CM_Initialize();
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::FormResize(TObject *Sender)
|
|
{
|
|
switch (WindowState) {
|
|
case wsMaximized:
|
|
case wsNormal:
|
|
m_lvStyles->Height = Height - m_lvStyles->Top - 120;
|
|
m_lvStyles->Width = ClientWidth - m_lvStyles->Left - 360;
|
|
GroupBox1->Left = ClientWidth - 26 - GroupBox1->Width;
|
|
GroupBox2->Left = GroupBox1->Left;
|
|
GroupBox2->Height = Height - GroupBox2->Top - 120;
|
|
m_Descri->Height = GroupBox2->Height - m_Descri->Top - 17;
|
|
|
|
m_btnCompose->Left = GroupBox1->Left;
|
|
m_btnCompose->Top = GroupBox2->Top + GroupBox2->Height + 17;
|
|
m_btnSegment->Left = m_lvStyles->Left + m_lvStyles->Width - m_btnSegment->Width;
|
|
m_btnSegment->Top = m_btnCompose->Top;
|
|
m_btnUpload->Top = m_btnCompose->Top;
|
|
m_btnUpload->Left = GroupBox1->Left + GroupBox1->Width - m_btnUpload->Width;
|
|
m_btnVerify->Top = m_btnUpload->Top;
|
|
m_btnVerify->Left = m_btnUpload->Left;
|
|
m_btnSaveExcel->Top = m_btnUpload->Top;
|
|
|
|
m_cbSelectAll->Top = Height - 95;
|
|
Label11->Top = m_cbSelectAll->Top;
|
|
m_cbFonts->Top = m_cbSelectAll->Top - 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
|
|
{
|
|
|
|
// Save the list data to the excel file if data has changed
|
|
if (m_vcMdItemIndexs.size())
|
|
SaveStylesDataToFile();
|
|
|
|
HRESULT hr = S_FALSE;
|
|
if (f_CS_DestroyService) {
|
|
DebugPrint("Start f_CS_DestroyService");
|
|
if (FAILED(hr = f_CS_DestroyService())) {
|
|
DebugPrint("Destroy client service failed! code=%x\n", hr);
|
|
}
|
|
DebugPrint("End f_CS_DestroyService");
|
|
}
|
|
|
|
if (f_MM_DestroyObjects) {
|
|
if (FAILED(hr = f_MM_DestroyObjects())) {
|
|
DebugPrint("Destroy f_MM_DestroyObjects code=%x\n", hr);
|
|
}
|
|
}
|
|
|
|
if (f_CM_Release) {
|
|
if (FAILED(hr = f_CM_Release())) {
|
|
DebugPrint("Relase compose module failed! code=%x\n", hr);
|
|
}
|
|
}
|
|
|
|
// ClearFont
|
|
vector<FONTINFO*>::iterator iFI = m_lstFonts.begin();
|
|
while (iFI != m_lstFonts.end()) {
|
|
delete(*iFI);
|
|
|
|
iFI = m_lstFonts.erase(iFI);
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuExitClick(TObject *Sender)
|
|
{
|
|
Close();
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuAboutClick(TObject *Sender)
|
|
{
|
|
TAboutForm * pAboutForm = new TAboutForm(NULL);
|
|
pAboutForm->ShowModal();
|
|
delete pAboutForm;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuHelpClick(TObject *Sender)
|
|
{
|
|
AnsiString strAboutDir = g_strExecutePath.c_str();
|
|
strAboutDir += L"Help\\";
|
|
|
|
if (FileExists((strAboutDir + L"Help.chm"))) {
|
|
::ShellExecuteA(Handle, "open", "help.chm", NULL, strAboutDir.c_str(),
|
|
SW_MAXIMIZE);
|
|
}
|
|
else {
|
|
MessageBox(Handle, L"未找到指定的帮助文件...", L"消息提示",
|
|
MB_ICONINFORMATION | MB_OK);
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuOpenFileClick(TObject *Sender)
|
|
{
|
|
TOpenDialog * pDlg = new TOpenDialog(NULL);
|
|
pDlg->Title = "打开文件";
|
|
pDlg->Options << ofFileMustExist;
|
|
pDlg->Filter = "Excel文件 (*.xls)|*.xls|Excel2003文件 (*.xlsx)|*.xlsx|";
|
|
pDlg->DefaultExt = "xls";
|
|
if (pDlg->Execute(Handle)) {
|
|
m_strExlFileName = pDlg->FileName.c_str();
|
|
}
|
|
|
|
delete pDlg;
|
|
|
|
m_strMidiDirPath = ExtractFilePath(m_strExlFileName);
|
|
|
|
if (FileExists(m_strExlFileName.c_str(), true)) {
|
|
GetRecreatorStyles(m_strExlFileName);
|
|
|
|
f_CM_Clear();
|
|
|
|
m_btnSaveExcel->Enabled = true;
|
|
}
|
|
else{
|
|
m_btnSaveExcel->Enabled = false;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuRefreshClick(TObject *Sender)
|
|
{
|
|
if( !g_bLogon ){
|
|
OnLoginClick(NULL);
|
|
}
|
|
|
|
if( g_bLogon ){
|
|
m_lvStyles->Enabled = true;
|
|
ResetStylesData( false );
|
|
ShowCheckStyles();
|
|
|
|
TProgressForm * dlgProgress = new TProgressForm(this);
|
|
dlgProgress->m_hMain = Handle;
|
|
int ret = dlgProgress->Style_Update();
|
|
delete dlgProgress;
|
|
|
|
if( mrOk!=ret ){
|
|
ResetStylesData( false );
|
|
m_lvStyles->Enabled = false;
|
|
|
|
if( ret==e_InvalidAuthority ){
|
|
ShowMessage(L"该用户无审核权限!");
|
|
}
|
|
else if( ret==e_DatabaseError ){
|
|
ShowMessage(L"服务器数据访问失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuViewRecreatorClick(TObject *Sender)
|
|
{
|
|
if( g_bRecreator )
|
|
return;
|
|
|
|
// 风格批量合成
|
|
g_bRecreator = true;
|
|
|
|
m_menuRecreator->Checked = g_bRecreator;
|
|
m_menuChecker->Checked = !g_bRecreator;
|
|
m_lvStyles->Enabled = true;
|
|
m_btnUpload->Enabled = false;
|
|
|
|
ResetStylesData(g_bRecreator);
|
|
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0 || iHotItemIndex >= m_lvStyles->Items->Count) {
|
|
memset(m_cStyleTypes, -1, 2);
|
|
ClearAuthorCtrlsInfo();
|
|
}
|
|
else {
|
|
RefeshListAuthorData(m_lvStyles, iHotItemIndex, false);
|
|
RefreshListStyleType(m_lvStyles, iHotItemIndex, true);
|
|
RefreshCtrlsData(false);
|
|
}
|
|
|
|
if(m_lvStyles->ItemIndex >= 0){
|
|
m_btnSegment->Enabled = true;
|
|
m_btnVerify->Enabled = true;
|
|
}
|
|
else{
|
|
m_btnSegment->Enabled = false;
|
|
m_btnVerify->Enabled = false;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::MenuViewCheckerClick(TObject *Sender)
|
|
{
|
|
if( !g_bRecreator )
|
|
return;
|
|
|
|
// 风格审核
|
|
g_bRecreator = false;
|
|
|
|
m_menuRecreator->Checked = g_bRecreator;
|
|
m_menuChecker->Checked = !g_bRecreator;
|
|
m_lvStyles->Enabled = true;
|
|
m_btnVerify->Enabled = false;
|
|
|
|
ResetStylesData(g_bRecreator);
|
|
InitCheckerView();
|
|
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0 || iHotItemIndex >= m_lvStyles->Items->Count) {
|
|
memset(m_cStyleTypes, -1, 2);
|
|
ClearAuthorCtrlsInfo();
|
|
}
|
|
else {
|
|
RefeshListAuthorData(m_lvStyles, iHotItemIndex, false);
|
|
RefreshListStyleType(m_lvStyles, iHotItemIndex, true);
|
|
RefreshCtrlsData(false);
|
|
}
|
|
|
|
m_btnSegment->Enabled = m_lvStyles->ItemIndex >= 0;
|
|
m_btnCompose->Enabled = m_lvStyles->ItemIndex >= 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnLoginClick(TObject *Sender)
|
|
{
|
|
if( !g_bLogon ){
|
|
m_btnLogin->Caption = L"登录";
|
|
m_lbUserInfo->Visible = false;
|
|
|
|
f_CS_Logoff();
|
|
|
|
TLoginForm * dlgLogin = new TLoginForm(this);
|
|
dlgLogin->m_strUsername = g_infoUser.strUserName;//UFF8ToMBCS(g_infoUser.strUserName).c_str();
|
|
dlgLogin->m_strPassword = g_infoUser.strPassword;
|
|
|
|
if (dlgLogin->ShowModal() == mrOk) {
|
|
m_btnLogin->Caption = L"取消登录";
|
|
|
|
m_lbUserInfo->Visible = true;
|
|
m_lbUserInfo->Caption = L"正在登录...";
|
|
|
|
bool bSync = Sender==NULL;
|
|
int ret = f_CS_Login(&g_infoUser, bSync );
|
|
|
|
if( bSync && ret==0 ){
|
|
g_bLogon = true;
|
|
}
|
|
}
|
|
|
|
delete dlgLogin;
|
|
}
|
|
else {
|
|
f_CS_Logoff();
|
|
g_bLogon = false;
|
|
|
|
m_btnLogin->Caption = L"登录";
|
|
m_lbUserInfo->Visible = false;
|
|
|
|
if( !g_bRecreator ){
|
|
m_btnVerify->Enabled = false;
|
|
}
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnSegmentClick(TObject *Sender)
|
|
{
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0 || iHotItemIndex > m_lvStyles->Items->Count) {
|
|
MessageBox(Handle, L"请选择风格!", L"提示信息", MB_ICONWARNING | MB_OK);
|
|
return;
|
|
}
|
|
|
|
int idLoc=-1, idStyle=iHotItemIndex;
|
|
if( g_bRecreator ){
|
|
int iRet = RecombineStyle( iHotItemIndex );
|
|
if( iRet!=0 ){
|
|
return;
|
|
}
|
|
}
|
|
else{
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[iHotItemIndex]->Data;
|
|
idLoc = pStyle->idLoc;
|
|
idStyle = pStyle->idStyle;
|
|
|
|
TProgressForm * dlgProgress = new TProgressForm(this);
|
|
dlgProgress->m_hMain = Handle;
|
|
int ret = dlgProgress->Compare_Style( idStyle );
|
|
delete dlgProgress;
|
|
|
|
if( mrOk!=ret ){
|
|
return;
|
|
}
|
|
|
|
g_iMelodyTimeSignature = pStyle->pOrigin->detail.iTimesignature;
|
|
g_nMelodyTempo = pStyle->pOrigin->detail.iTempo;
|
|
f_MM_SetTimeSignature( g_iMelodyTimeSignature );
|
|
f_MM_SetTempo( g_nMelodyTempo );
|
|
}
|
|
|
|
THarmonyForm * ptHarFrm = new THarmonyForm(this, idLoc, idStyle);
|
|
ptHarFrm->ShowModal();
|
|
delete ptHarFrm;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnComposeClick(TObject *Sender)
|
|
{
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0 || iHotItemIndex > m_lvStyles->Items->Count) {
|
|
MessageBox(Handle, L"请选择风格!", L"提示信息", MB_ICONWARNING | MB_OK);
|
|
return;
|
|
}
|
|
|
|
int idLoc=-1, idStyle=iHotItemIndex;
|
|
if( g_bRecreator ){
|
|
int iRet = RecombineStyle( iHotItemIndex );
|
|
if( iRet!=0 ){
|
|
return;
|
|
}
|
|
}
|
|
else{
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[iHotItemIndex]->Data;
|
|
idLoc = pStyle->idLoc;
|
|
idStyle = pStyle->idStyle;
|
|
|
|
g_iMelodyTimeSignature = pStyle->pOrigin->detail.iTimesignature;
|
|
g_nMelodyTempo = pStyle->pOrigin->detail.iTempo;
|
|
f_MM_SetTimeSignature( g_iMelodyTimeSignature );
|
|
f_MM_SetTempo( g_nMelodyTempo );
|
|
}
|
|
|
|
TTryListenForm *pLstForm = new TTryListenForm(NULL, idLoc, idStyle );
|
|
|
|
pLstForm->ShowModal();
|
|
delete pLstForm;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnUpLoadClick(TObject *Sender) {
|
|
|
|
// Init the combine style files's data
|
|
if (m_vcDefStyleInfo.size())
|
|
m_vcDefStyleInfo.clear();
|
|
|
|
int iFileIndex = -1, iStyleIndex = -1, iAuthorIndex = -1, iPriceIndex = -1,
|
|
iCostIndex = -1, iScoreIndex = -1, iDescriIndex = -1, iTypeIndex = -1;
|
|
|
|
for (int i = 0; i < m_lvStyles->Columns->Count; i++) {
|
|
String strCaption = m_lvStyles->Columns->Items[i]->Caption;
|
|
|
|
if (strCaption.Trim() == L"文件名") {
|
|
iFileIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"风格名") {
|
|
iStyleIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"价格") {
|
|
iPriceIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"消耗") {
|
|
iCostIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"好评度") {
|
|
iScoreIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"描述") {
|
|
iDescriIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"作者") {
|
|
iAuthorIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"风格类型") {
|
|
iTypeIndex = i;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < m_lvStyles->Items->Count; i++) {
|
|
if (m_lvStyles->Items->Item[i]->Checked == true) {
|
|
TStrings *lpStrs = m_lvStyles->Items->Item[i]->SubItems;
|
|
TDEFSTYLEINFO defStyleInfo;
|
|
defStyleInfo.idStyle = i;
|
|
|
|
// 文件名
|
|
if (iFileIndex > 0)
|
|
defStyleInfo.strFileName =
|
|
m_strMidiDirPath + lpStrs->Strings[iFileIndex - 1];
|
|
else if (iFileIndex == 0)
|
|
defStyleInfo.strFileName = L"";
|
|
|
|
// 风格名
|
|
if (iStyleIndex > 0) {
|
|
AnsiString strTxt = lpStrs->Strings[iStyleIndex - 1].c_str();
|
|
strcpy(defStyleInfo.tStyleInfo.detail.strStyleName,
|
|
strTxt.c_str());
|
|
}
|
|
else if (iStyleIndex == 0)
|
|
memset(defStyleInfo.tStyleInfo.detail.strStyleName, 0, 40);
|
|
|
|
// 作者
|
|
if (iAuthorIndex > 0)
|
|
memcpy(defStyleInfo.tStyleInfo.detail.strAuthor,
|
|
((AnsiString)lpStrs->Strings[iAuthorIndex - 1]).c_str(),
|
|
wcslen(lpStrs->Strings[iAuthorIndex - 1].c_str())*2);
|
|
else if (iAuthorIndex == 0)
|
|
memset(defStyleInfo.tStyleInfo.detail.strAuthor, 0, 40);
|
|
/*
|
|
// 价格
|
|
if (iPriceIndex > 0)
|
|
defStyleInfo.tStyleInfo.price =
|
|
_wtoi(lpStrs->Strings[iPriceIndex - 1].c_str());
|
|
else if (iPriceIndex == 0)
|
|
defStyleInfo.tStyleInfo.price = 0;
|
|
*/
|
|
// 消耗
|
|
if (iCostIndex > 0)
|
|
defStyleInfo.tStyleInfo.cost =
|
|
_wtoi(lpStrs->Strings[iCostIndex - 1].c_str());
|
|
else if (iCostIndex == 0)
|
|
defStyleInfo.tStyleInfo.cost = 0;
|
|
/*
|
|
// 好评度
|
|
if (iScoreIndex > 0)
|
|
defStyleInfo.tStyleInfo.score =
|
|
_wtoi(lpStrs->Strings[iScoreIndex - 1].c_str());
|
|
else if (iScoreIndex == 0)
|
|
defStyleInfo.tStyleInfo.score = 0;
|
|
*/
|
|
// 描述
|
|
if (iDescriIndex > 0)
|
|
memcpy(defStyleInfo.tStyleInfo.detail.strDescription,
|
|
((AnsiString)lpStrs->Strings[iDescriIndex - 1]).c_str(),
|
|
wcslen(lpStrs->Strings[iDescriIndex - 1].c_str())*2);
|
|
else if (iDescriIndex == 0)
|
|
memset(defStyleInfo.tStyleInfo.detail.strDescription, 0, 120);
|
|
|
|
// 风格类型
|
|
if (iTypeIndex > 0) {
|
|
int type0 = -1, type1 = -1, type2 = -1, type3 = -1;
|
|
sscanf(((AnsiString)lpStrs->Strings[iTypeIndex - 1]).c_str(),
|
|
"%d,%d,%d,%d", &type0, &type1, &type2, &type3);
|
|
defStyleInfo.tStyleInfo.detail.type[0] = type0;
|
|
defStyleInfo.tStyleInfo.detail.type[1] = type1;
|
|
defStyleInfo.tStyleInfo.detail.type[2] = type2;
|
|
defStyleInfo.tStyleInfo.detail.type[3] = type3;
|
|
}
|
|
else if (iDescriIndex == 0)
|
|
memset(defStyleInfo.tStyleInfo.detail.type, -1, sizeof(defStyleInfo.tStyleInfo.detail.type));
|
|
|
|
// 刷新主奏乐器
|
|
// Need Change
|
|
//RefreshListHarParam(m_lvStyles, i, true);
|
|
|
|
m_vcDefStyleInfo.push_back(defStyleInfo);
|
|
}
|
|
}
|
|
|
|
if (m_vcDefStyleInfo.size() < 1) {
|
|
ShowMessage(L"请选择要上传的风格!!!");
|
|
return;
|
|
}
|
|
|
|
// 上传生成的风格文件数据
|
|
if (!g_bLogon) {
|
|
TLoginForm * dlgLogin = new TLoginForm(NULL);
|
|
|
|
BOOL bRepeat = TRUE;
|
|
while (bRepeat) {
|
|
dlgLogin->m_strUsername = g_infoUser.strUserName;//UFF8ToMBCS(g_infoUser.strUserName).c_str();
|
|
dlgLogin->m_strPassword = g_infoUser.strPassword;
|
|
|
|
if (dlgLogin->ShowModal() == mrOk) {
|
|
|
|
// 登录部分
|
|
TProgressForm * dlgProgress = new TProgressForm(this);
|
|
dlgProgress->m_hMain = Handle;
|
|
int ret = dlgProgress->User_Login();
|
|
int eExtra = dlgProgress->m_iOperationResult;
|
|
delete dlgProgress;
|
|
|
|
// e_WaitTimeout
|
|
bRepeat = false;
|
|
if (ret != mrCancel) {
|
|
if (eExtra == 0) {
|
|
g_bLogon = true;
|
|
}
|
|
else if (m_btnLogin->Caption.Trim() == L"取消登录") {
|
|
PostMessage(Handle, MSG_UPDATA_LOGOFF, 0, 0);
|
|
}
|
|
|
|
if (eExtra == e_LoginPasswordError) {
|
|
MessageBox(Handle, L"登录失败。输入密码错,请重新登录!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
g_infoUser.strPassword[0] = 0;
|
|
bRepeat = TRUE;
|
|
}
|
|
else if (eExtra == e_LoginUserNotExist) {
|
|
MessageBox(Handle, L"登录失败。无效的用户名,请重新登录!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
g_infoUser.strUserName[0] = 0;
|
|
g_infoUser.strPassword[0] = 0;
|
|
bRepeat = TRUE;
|
|
}
|
|
else if (eExtra == e_DatabaseError) {
|
|
MessageBox(Handle, L"登录失败。服务器访问错,请稍后重试!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
}
|
|
else if (eExtra == e_SocketError) {
|
|
MessageBox(Handle, L"登录失败。网络故障,请关闭程序后重试!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
}
|
|
else if (eExtra == e_WaitTimeout) {
|
|
MessageBox(Handle, L"登录失败。网络超时,请稍后重试!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
}
|
|
}
|
|
else {;
|
|
}
|
|
}
|
|
else {
|
|
bRepeat = false;
|
|
}
|
|
delete dlgLogin;
|
|
}
|
|
}
|
|
|
|
if (g_bLogon) {
|
|
// 开始上传
|
|
TStylesUpProgressForm * dlgProgress = new TStylesUpProgressForm(NULL);
|
|
dlgProgress->Styles_Upload(m_vcDefStyleInfo);
|
|
int eExtra = dlgProgress->m_iOperationResult;
|
|
|
|
delete dlgProgress;
|
|
|
|
if (mrOk == eExtra) {
|
|
MessageBox(Handle, L"上传成功!", L"消息提示", MB_ICONINFORMATION | MB_OK);
|
|
}
|
|
else if (mrCancel != eExtra) {
|
|
MessageBox(Handle, L"上传失败!", L"消息提示", MB_ICONINFORMATION | MB_OK);
|
|
}
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnSelectAllClick(TObject *Sender) {
|
|
|
|
if( g_bRecreator ){
|
|
if (m_lvStyles->Items->Count <= 0) {
|
|
m_cbSelectAll->Checked = false;
|
|
}
|
|
|
|
for (int i = 0; i < m_lvStyles->Items->Count; i++) {
|
|
m_lvStyles->Items->Item[i]->Checked = m_cbSelectAll->Checked;
|
|
}
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnSaveExcelClick(TObject *Sender)
|
|
{
|
|
if ((FileExists(m_strExlFileName, true)) && (m_lvStyles->Items->Count > 0) ) {
|
|
SaveStylesDataToFile();
|
|
|
|
if (m_vcMdItemIndexs.size()) {
|
|
m_vcMdItemIndexs.clear();
|
|
m_lvStyles->Invalidate();
|
|
}
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnVerifyClick(TObject *Sender)
|
|
{
|
|
int iItemIndex = m_lvStyles->ItemIndex;
|
|
if( m_lvStyles->Items->Count <= 0 ){
|
|
MessageBox(Handle, L"没有需要审核的风格!", L"提示信息", MB_ICONWARNING | MB_OK);
|
|
return;
|
|
}
|
|
if( iItemIndex < 0 || iItemIndex >= m_lvStyles->Items->Count ){
|
|
MessageBox(Handle, L"请选择你要审核的风格!", L"提示信息", MB_ICONQUESTION | MB_OK);
|
|
return;
|
|
}
|
|
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[iItemIndex]->Data;
|
|
if( pStyle->pOrigin->state == e_CheckedAlready ) {
|
|
MessageBox(Handle, L"该风格已审核!!!", L"提示信息", MB_ICONWARNING | MB_OK);
|
|
return;
|
|
}
|
|
|
|
int iChkStyleRet = -1;
|
|
TVerifyStylesForm * pVfStyleFrm = new TVerifyStylesForm(NULL);
|
|
pVfStyleFrm->m_iStyleId = pStyle->idStyle;
|
|
|
|
if( mrOk == pVfStyleFrm->ShowModal() ){
|
|
iChkStyleRet = pVfStyleFrm->m_iRetCheckStyle;
|
|
}
|
|
|
|
delete pVfStyleFrm;
|
|
|
|
// 修改已经审核的标记变量
|
|
if( 0==iChkStyleRet ){
|
|
pStyle->pOrigin->state = e_CheckedAlready;
|
|
m_lvStyles->Items->Item[iItemIndex]->Caption = L"已审核";
|
|
m_btnVerify->Enabled = false;
|
|
}
|
|
/* else {
|
|
m_lvStyles->Items->Item[iItemIndex]->Caption = L"未审核";
|
|
}
|
|
*/
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnTypeClick(TObject *Sender)
|
|
{
|
|
TButton * pBtn = (TButton*)Sender;
|
|
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0 || iHotItemIndex > m_lvStyles->Items->Count) {
|
|
MessageBox(Handle, L"请选择你要设置的风格!", L"提示信息", MB_ICONWARNING | MB_OK);
|
|
return;
|
|
}
|
|
|
|
if (pBtn->Tag == 0) {
|
|
|
|
TStyleSetForm * pStyleFrm = new TStyleSetForm(this);
|
|
|
|
memcpy(pStyleFrm->m_cStyleTypes, m_cStyleTypes, 2);
|
|
if (pStyleFrm->ShowModal() == mrOk) {
|
|
|
|
memcpy(&m_cStyleTypes[0], pStyleFrm->m_cStyleTypes, 2);
|
|
|
|
if (m_cStyleTypes[0] == -1 && m_cStyleTypes[1] == -1)
|
|
return;
|
|
|
|
// Set the style's type
|
|
|
|
stLabel1->Caption = LSZ_STYLTYPES[m_cStyleTypes[0]];
|
|
mdBtn1->Caption = L"-";
|
|
mdBtn1->Tag = 1;
|
|
|
|
if (m_cStyleTypes[1] >= 0) {
|
|
stLabel2->Caption = LSZ_STYLTYPES[m_cStyleTypes[1]];
|
|
mdBtn2->Caption = L"-";
|
|
mdBtn2->Tag = 1;
|
|
}
|
|
else ;
|
|
|
|
stLabel2->Visible = true;
|
|
mdBtn2->Visible = true;
|
|
}
|
|
delete pStyleFrm;
|
|
}
|
|
else if (pBtn->Tag == 1) {
|
|
|
|
// If the label2 has some data
|
|
if (pBtn == mdBtn1) {
|
|
|
|
mdBtn1->Caption = mdBtn2->Caption;
|
|
stLabel1->Caption = stLabel2->Caption;
|
|
|
|
mdBtn1->Tag = mdBtn2->Tag;
|
|
|
|
mdBtn2->Caption = L"+";
|
|
stLabel2->Caption = L"添加风格";
|
|
|
|
mdBtn2->Visible = mdBtn2->Tag;
|
|
stLabel2->Visible = mdBtn2->Tag;
|
|
|
|
mdBtn2->Tag = 0;
|
|
m_cStyleTypes[0] = m_cStyleTypes[1];
|
|
m_cStyleTypes[1] = -1;
|
|
}
|
|
else {
|
|
mdBtn2->Caption = L"+";
|
|
stLabel2->Caption = L"添加风格";
|
|
mdBtn2->Tag = 0;
|
|
|
|
if (mdBtn2->Tag) {
|
|
mdBtn2->Visible = false;
|
|
stLabel2->Visible = false;
|
|
}
|
|
else {
|
|
mdBtn2->Visible = true;
|
|
stLabel2->Visible = true;
|
|
}
|
|
|
|
m_cStyleTypes[1] = -1;
|
|
}
|
|
}
|
|
else ;
|
|
|
|
RefreshCtrlsData(true);
|
|
ReposTypeCtrls();
|
|
|
|
// if() Need Change
|
|
if (m_lvStyles->ItemIndex >= 0)
|
|
RefreshListStyleType(m_lvStyles, iHotItemIndex, false);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnStyleNameExit(TObject *Sender)
|
|
{
|
|
int iHotIndex = m_lvStyles->ItemIndex;
|
|
if (iHotIndex < 0)
|
|
return;
|
|
RefeshListAuthorData(m_lvStyles, iHotIndex, true);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnAuthorExit(TObject *Sender)
|
|
{
|
|
int iHotIndex = m_lvStyles->ItemIndex;
|
|
if (iHotIndex < 0)
|
|
return;
|
|
RefeshListAuthorData(m_lvStyles, iHotIndex, true);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnCostExit(TObject *Sender)
|
|
{
|
|
int num = 0;
|
|
TEdit* pEdit = (TEdit*)Sender;
|
|
|
|
if( pEdit==m_edPrice )
|
|
num = g_infoAuthor.price = _wtoi(pEdit->Text.c_str());
|
|
else if( pEdit==m_edCost )
|
|
num = g_infoAuthor.cost = _wtoi(pEdit->Text.c_str());
|
|
/* else if( pEdit==m_edScore )
|
|
num = g_infoAuthor.score = _wtoi(pEdit->Text.c_str());
|
|
|
|
char chBuf[30] = {0};
|
|
sprintf(chBuf, "%d", g_infoAuthor.price);
|
|
m_edPrice->Text = (String)chBuf;
|
|
*/
|
|
int iHotIndex = m_lvStyles->ItemIndex;
|
|
if (iHotIndex < 0)
|
|
return;
|
|
RefeshListAuthorData(m_lvStyles, iHotIndex, true);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnDescriExit(TObject *Sender)
|
|
{
|
|
int iHotIndex = m_lvStyles->ItemIndex;
|
|
if (iHotIndex < 0)
|
|
return;
|
|
RefeshListAuthorData(m_lvStyles, iHotIndex, true);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnStyleNameChange(TObject *Sender) {
|
|
AnsiString strTxt = m_StyleName->Text.Trim();
|
|
if (strTxt.Length() > 40) {
|
|
strTxt = strTxt.SubString(0, 40);
|
|
m_StyleName->Text = strTxt;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnAuthorChange(TObject *Sender) {
|
|
AnsiString strTxt = m_Author->Text.Trim();
|
|
if (strTxt.Length() > 40) {
|
|
strTxt = strTxt.SubString(0, 40);
|
|
m_Author->Text = strTxt;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnDescriChange(TObject *Sender) {
|
|
AnsiString strTxt = m_Descri->Text.Trim();
|
|
if (strTxt.Length() > 120) {
|
|
strTxt = strTxt.SubString(0, 120);
|
|
m_Descri->Text = strTxt;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnFontChange(TObject *Sender)
|
|
{
|
|
int iIndex = m_cbFonts->ItemIndex;
|
|
// AnsiString strFontName = m_lstFonts.at(iIndex)->strFileName;
|
|
// f_MM_SetFont(strFontName.c_str());
|
|
|
|
char strFile[1][256];
|
|
strcpy( strFile[0], m_lstFonts.at(iIndex)->strFileName );
|
|
|
|
int ret = f_MM_SetDefaultFont( 1, strFile );
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnStylesMouseDown(TObject *Sender,
|
|
TMouseButton Button, TShiftState Shift, int X, int Y)
|
|
{
|
|
int iHotItemIndex = m_lvStyles->ItemIndex;
|
|
if (iHotItemIndex < 0){
|
|
m_btnSegment->Enabled = false;
|
|
m_btnCompose->Enabled = false;
|
|
m_btnVerify->Enabled = false;
|
|
m_btnUpload->Enabled = false;
|
|
return;
|
|
}
|
|
|
|
m_btnSegment->Enabled = true;
|
|
m_btnCompose->Enabled = true;
|
|
|
|
RefeshListAuthorData(m_lvStyles, iHotItemIndex, false);
|
|
RefreshListStyleType(m_lvStyles, iHotItemIndex, true);
|
|
RefreshCtrlsData(false);
|
|
|
|
if( g_bRecreator ){
|
|
m_btnUpload->Enabled = true;
|
|
}
|
|
else{
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[iHotItemIndex]->Data;
|
|
m_btnVerify->Enabled = g_bLogon && pStyle->pOrigin->state==e_Downloaded;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnStylesDrawItem(TCustomListView *Sender, TListItem *Item,
|
|
TCustomDrawState State, bool &DefaultDraw)
|
|
{
|
|
/*
|
|
for (int i = 0; i < m_vcMdItemIndexs.size(); i++) {
|
|
if (Item->Index == m_vcMdItemIndexs[i]) {
|
|
// TBrush * pOldBr = ((TListView*)Sender)->Canvas->Brush;
|
|
|
|
TRect rtItem = Item->DisplayRect(drLabel);
|
|
((TListView*)Sender)->Canvas->Brush->Color = RGB(255, 20, 20);
|
|
((TListView*)Sender)->Canvas->FillRect(rtItem);
|
|
|
|
// ((TListView*)Sender)->Canvas->Brush = pOldBr;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnNetworkMessage(TMessage & msg)
|
|
{
|
|
WORD eMessage = HIWORD(msg.WParam);
|
|
WORD eExtra = LOWORD(msg.WParam);
|
|
|
|
switch (eMessage) {
|
|
case e_loginResponse:
|
|
if (eExtra == 0) {
|
|
String strHeaderName = g_strExecutePath.c_str();
|
|
g_bLogon = true;
|
|
|
|
DebugPrint(
|
|
"用户信息:\nID=%d\n 昵称: %s\n账户余额:%d\n权限:0x%X\n已购买风格数:%d\n头像: %s\nVIP: %d\n",
|
|
g_infoUser.accountInfo.ID,
|
|
g_infoUser.strNickName,
|
|
g_infoUser.accountInfo.balance,
|
|
// g_infoUser.accountInfo.pops,
|
|
// g_infoUser.accountInfo.fans,
|
|
// g_infoUser.accountInfo.songs,
|
|
g_infoUser.accountInfo.authority,
|
|
g_infoUser.ownStyleNum,
|
|
g_infoUser.strIconFile,
|
|
g_infoUser.accountInfo.vipPeriod);
|
|
|
|
m_lbUserInfo->Visible = true;
|
|
m_btnLogin->Caption = L"注销";
|
|
if( strlen(g_infoUser.strNickName)>0 ){
|
|
m_lbUserInfo->Caption = g_infoUser.strNickName;
|
|
}
|
|
else{
|
|
m_lbUserInfo->Caption = g_infoUser.strUserName;
|
|
}
|
|
// m_lbUserInfo->Caption = g_infoUser.strUserName;//UFF8ToMBCS(g_infoUser.strUserName).c_str();
|
|
|
|
String strHint = L"";
|
|
|
|
strHint += L"\r\n用户名:" + (String)g_infoUser.strUserName + L"\r\n";
|
|
strHint += "音符数:";
|
|
strHint += IntToStr(g_infoUser.accountInfo.balance);
|
|
// strHint += "\n魅力值:";
|
|
// strHint += IntToStr(g_infoUser.accountInfo.pops);
|
|
// strHint += "\n粉丝数:";
|
|
// strHint += IntToStr(g_infoUser.accountInfo.fans);
|
|
// strHint += "\n歌曲数:";
|
|
// strHint += IntToStr(g_infoUser.accountInfo.songs);
|
|
|
|
m_lbUserInfo->Hint = strHint;
|
|
|
|
// if( !g_bRecreator )
|
|
// f_CS_UpdateStyle(g_infoUser.accountInfo.ID);
|
|
}
|
|
else if (eExtra == e_LoginPasswordError) {
|
|
MessageBox(Handle, L"登录失败。输入密码错,请重新登录!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
g_infoUser.strPassword[0] = 0;
|
|
PostMessage(Handle, UM_LOGIN, 0, 0);
|
|
}
|
|
else if (eExtra == e_LoginUserNotExist) {
|
|
MessageBox(Handle, L"登录失败。无效的用户名,请重新登录!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
g_infoUser.strUserName[0] = 0;
|
|
g_infoUser.strPassword[0] = 0;
|
|
PostMessage(Handle, UM_LOGIN, 0, 0);
|
|
}
|
|
else if (eExtra == e_DatabaseError) {
|
|
MessageBox(Handle, L"登录失败。服务器访问错,请稍后重试!", L"提示信息",
|
|
MB_ICONERROR | MB_OK);
|
|
}
|
|
|
|
break;
|
|
|
|
case e_versionResponse:
|
|
if (eExtra == e_DatabaseError) {
|
|
DebugPrint("服务器数据访问失败!\n");
|
|
|
|
break;
|
|
}
|
|
else {
|
|
if (eExtra == e_UpdateMandatory || eExtra == e_UpdateOptional) {
|
|
int year = g_infoSoftwareUpdate.tIssueDate >> 16;
|
|
int month = (g_infoSoftwareUpdate.tIssueDate & 0xFF00) >> 8;
|
|
int day = g_infoSoftwareUpdate.tIssueDate & 0xFF;
|
|
|
|
string sDescribe = UFF8ToMBCS(g_infoSoftwareUpdate.strDescribe);
|
|
|
|
DebugPrint(
|
|
"最新的客户端版本:Ver %d.%d.%d.%04d\n发布时间:%d-%d-%d\n文件大小:%dK\n文件描述:%s\n",
|
|
g_infoSoftwareUpdate.version.majorVersion,
|
|
g_infoSoftwareUpdate.version.minorVersion,
|
|
g_infoSoftwareUpdate.version.modifyVersion,
|
|
g_infoSoftwareUpdate.version.buildVersion, year, month, day,
|
|
g_infoSoftwareUpdate.nFileSize, sDescribe.c_str());
|
|
|
|
if (eExtra == e_UpdateMandatory) {
|
|
DebugPrint("该版本为强制更新版。\n\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
/* case e_styleUpdateResponse: {
|
|
if( !g_bRecreator && 0==eExtra ){
|
|
ShowCheckStyles();
|
|
}
|
|
else if( e_InvalidAuthority==eExtra ){
|
|
ShowMessage(L"该用户无审核权限!");
|
|
}
|
|
}
|
|
|
|
break;
|
|
*/
|
|
case e_styleInfoResponse: // longpara
|
|
if( !g_bRecreator && e_CheckStyle==eExtra ){
|
|
int iRet = 0;
|
|
int iStyleId = msg.LParam;
|
|
|
|
bool bNew = true;
|
|
for( int i=0; i<m_lvStyles->Items->Count; i++ ){
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[i]->Data;
|
|
if( pStyle->idStyle==iStyleId ){
|
|
bNew = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( !bNew )
|
|
break;
|
|
|
|
TPROSTYLE * pStyleInfo = new TPROSTYLE;
|
|
pStyleInfo->pOrigin = new TSTYLEORIGIN;
|
|
iRet = f_CM_GetStyleInfo( 2, iStyleId, pStyleInfo );
|
|
|
|
if( 0==iRet ){
|
|
AddCheckStyle(pStyleInfo);
|
|
}
|
|
else {
|
|
String strError =
|
|
L"Excute Function \"GetStyleInfo()\" Failed,StyleID = " +
|
|
IntToStr(iStyleId);
|
|
OutputDebugString(strError.c_str());
|
|
delete pStyleInfo;
|
|
}
|
|
}
|
|
else if (eExtra == e_DatabaseError) {
|
|
DebugPrint("服务器数据访问失败!\n");
|
|
}
|
|
|
|
break;
|
|
|
|
case e_styleDataResponse:
|
|
if( !g_bRecreator ){
|
|
int idLoc = 0;
|
|
int iStyleId = msg.LParam;
|
|
|
|
if( e_CheckStyle==eExtra ){
|
|
idLoc = 2;
|
|
for( int i=0; i<m_lvStyles->Items->Count; i++ ){
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[i]->Data;
|
|
|
|
if( pStyle && iStyleId==pStyle->idStyle ){
|
|
m_lvStyles->Items->Item[i]->Caption = L"未审核";
|
|
m_lvStyles->Items->Item[i]->Checked = false;
|
|
pStyle->pOrigin->state = e_Downloaded;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
f_CM_GenerateCheckData( idLoc, iStyleId );
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::OnNetworkError(TMessage & msg)
|
|
{
|
|
WORD eMessage = HIWORD(msg.WParam);
|
|
WORD eExtra = LOWORD(msg.WParam);
|
|
|
|
DebugPrint("网络访问错误,消息号:%d,错误号:0x%X\n", eMessage, eExtra);
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::UMLogin(TMessage & msg)
|
|
{
|
|
m_btnLogin->Caption = L"登录";
|
|
m_lbUserInfo->Visible = false;
|
|
f_CS_Logoff();
|
|
g_bLogon = false;
|
|
|
|
TLoginForm * dlgLogin = new TLoginForm(this);
|
|
dlgLogin->m_strUsername = g_infoUser.strUserName;//UFF8ToMBCS(g_infoUser.strUserName).c_str();
|
|
dlgLogin->m_strPassword = g_infoUser.strPassword;
|
|
|
|
if (dlgLogin->ShowModal() == mrOk) {
|
|
|
|
AnsiString astr = dlgLogin->m_strUsername;
|
|
strncpy(g_infoUser.strUserName, astr.c_str(), astr.Length() + 1);
|
|
astr = dlgLogin->m_strPassword;
|
|
strncpy(g_infoUser.strPassword, astr.c_str(), astr.Length() + 1);
|
|
|
|
f_CS_Login(&g_infoUser, FALSE);
|
|
}
|
|
|
|
delete dlgLogin;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void __fastcall TMainForm::UMLogoff(TMessage &msg)
|
|
{
|
|
f_CS_Logoff();
|
|
g_bLogon = false;
|
|
|
|
m_btnLogin->Caption = L"登录";
|
|
m_lbUserInfo->Visible = false;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
#include "libxl.h"
|
|
using namespace libxl;
|
|
#pragma comment(lib,"libxl.lib")
|
|
|
|
void TMainForm::GetRecreatorStyles(const String strFileName)
|
|
{
|
|
if (!FileExists(strFileName.c_str(), false))
|
|
return;
|
|
|
|
Book* book = xlCreateBook();
|
|
book->setKey(L"AlexQ", L"windows-2020230803c9e40167b96268abp3r1g3");
|
|
|
|
if(!book->load(strFileName.c_str())){
|
|
DebugPrint("打开EXCEL文件错误");
|
|
return;
|
|
}
|
|
|
|
Sheet* sheet = book->getSheet(0);
|
|
if(!sheet){
|
|
book->release();
|
|
DebugPrint("打开EXCEL表格错误");
|
|
return;
|
|
}
|
|
|
|
int iColNum = sheet->lastFilledCol();
|
|
int iRowNum = sheet->lastFilledRow();
|
|
if( iColNum==0 || iRowNum==0 ){
|
|
book->release();
|
|
DebugPrint("EXCEL无数据");
|
|
return;
|
|
}
|
|
|
|
// 清除列表中的数据
|
|
if (m_lvStyles->Items->Count) {
|
|
m_lvStyles->Clear();
|
|
}
|
|
if (m_lvStyles->Columns->Count) {
|
|
for (int i = m_lvStyles->Columns->Count - 1; i >= 0; i--) {
|
|
m_lvStyles->Columns->Delete(i);
|
|
}
|
|
}
|
|
|
|
// 数字索引
|
|
TListColumn * pCol = m_lvStyles->Columns->Add();
|
|
pCol->Caption = L" ";
|
|
pCol->Width = 48;
|
|
|
|
for (int i = 0; i < iColNum; i++) {
|
|
String strValue = sheet->readStr(0, i);
|
|
|
|
if( strValue.Length()>0 ){
|
|
TListColumn * pCol = m_lvStyles->Columns->Add();
|
|
pCol->Caption = strValue;
|
|
pCol->Width = strValue.Length() * 20;
|
|
}
|
|
else{
|
|
iColNum = i+1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
TListItem * pItem = NULL;
|
|
for (int i = 1; i < iRowNum; i++) {
|
|
String strValue = sheet->readStr(i, 0);
|
|
|
|
if( strValue.Length()>0 ){
|
|
pItem = m_lvStyles->Items->Add();
|
|
pItem->Caption = IntToStr(i);
|
|
pItem->SubItems->Add(strValue.c_str());
|
|
|
|
for (int j = 1; j < iColNum; j++) {
|
|
String strValue = sheet->readStr(i, j);
|
|
pItem->SubItems->Add(strValue.c_str());
|
|
}
|
|
}
|
|
else{
|
|
break;
|
|
}
|
|
}
|
|
|
|
book->release();
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::SaveStylesDataToFile()
|
|
{
|
|
// Save the data to the excel
|
|
if (!FileExists(m_strExlFileName.c_str(), false))
|
|
return;
|
|
|
|
Book* book = xlCreateBook();
|
|
book->setKey(L"AlexQ", L"windows-2020230803c9e40167b96268abp3r1g3");
|
|
|
|
if(!book->load(m_strExlFileName.c_str())){
|
|
DebugPrint("打开EXCEL文件错误");
|
|
return;
|
|
}
|
|
|
|
Sheet* sheet = book->getSheet(0);
|
|
if(!sheet){
|
|
book->release();
|
|
DebugPrint("打开EXCEL表格错误");
|
|
return;
|
|
}
|
|
|
|
// Get/Set the ListItem Column and rows num
|
|
int iColNum = m_lvStyles->Columns->Count;
|
|
int iRowNum = m_lvStyles->Items->Count;
|
|
|
|
String strValue = L"";
|
|
|
|
for (int i = 0; i < iRowNum; i++) {
|
|
for (int j = 1; j < iColNum-1; j++) {
|
|
strValue = m_lvStyles->Items->Item[i]->SubItems->Strings[j];
|
|
|
|
sheet->writeStr(i+1, j, strValue.c_str());
|
|
}
|
|
}
|
|
|
|
if( !book->save(m_strExlFileName.c_str()) ){
|
|
DWORD dwErr = GetLastError();
|
|
|
|
if( dwErr==32 )
|
|
ShowMessage("文件在其它程序中打开,无法写入。");
|
|
else
|
|
ShowMessage( book->errorMessage() );
|
|
}
|
|
|
|
book->release();
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::ReposTypeCtrls()
|
|
{
|
|
mdBtn1->Left = stLabel1->BoundsRect.Right;
|
|
stLabel2->Left = mdBtn1->BoundsRect.Right + 10;
|
|
mdBtn2->Left = stLabel2->BoundsRect.Right;
|
|
|
|
mdBtn1->Top = stLabel1->Top - 2;
|
|
stLabel2->Top = stLabel1->Top;
|
|
mdBtn2->Top = stLabel1->Top - 2;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::InitFontList()
|
|
{
|
|
// Scan font of current software directory
|
|
String strDir = (String)g_strExecutePath.c_str() + L"Fonts\\";
|
|
ScanLocalFont(strDir);
|
|
|
|
// Scan font of YHD-software directory
|
|
HKEY hComposerKey;
|
|
DWORD dwDisposition;
|
|
|
|
long lResult = RegCreateKeyEx(HKEY_CURRENT_USER, REGKEY_ACPRO, 0, NULL,
|
|
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hComposerKey,
|
|
&dwDisposition);
|
|
if (lResult == ERROR_SUCCESS) {
|
|
DWORD dwSize;
|
|
BYTE szBuffer[MAX_PATH];
|
|
|
|
if (dwDisposition == REG_OPENED_EXISTING_KEY) {
|
|
dwSize = MAX_PATH;
|
|
lResult = RegQueryValueEx(hComposerKey, REGKEY_INSTALDIR, NULL,
|
|
NULL, szBuffer, &dwSize);
|
|
if (lResult == ERROR_SUCCESS && dwSize > 0) {
|
|
strDir = (TCHAR*)szBuffer;
|
|
strDir += L"\\Fonts\\";
|
|
ScanLocalFont(strDir);
|
|
}
|
|
}
|
|
}
|
|
|
|
RegCloseKey(hComposerKey);
|
|
|
|
for (int i = 0; i < (int)m_lstFonts.size(); i++) {
|
|
String strTmp = ExtractFileName((String)((FONTINFO*)m_lstFonts[i])->strFontName);
|
|
m_cbFonts->AddItem(strTmp, NULL);
|
|
}
|
|
|
|
int iFont = -1;
|
|
// 开始设置音色库
|
|
for (int i = 0; i < (int)m_lstFonts.size(); i++) {
|
|
// AnsiString strFontName = m_lstFonts.at(i)->strFileName;
|
|
char strFile[1][256];
|
|
strcpy( strFile[0], m_lstFonts.at(i)->strFileName );
|
|
|
|
int ret = f_MM_SetDefaultFont( 1, strFile );
|
|
|
|
// int ret = f_MM_SetFont(strFontName.c_str());
|
|
if( ret==S_OK || ret==FONT_SF2 ){
|
|
iFont = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
m_cbFonts->ItemIndex = iFont;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::InitCheckerView()
|
|
{
|
|
if (m_lvStyles->Columns->Count) {
|
|
for (int i = m_lvStyles->Columns->Count - 1; i >= 0; i--) {
|
|
m_lvStyles->Columns->Delete(i);
|
|
}
|
|
}
|
|
|
|
String strCaption = L"状态";
|
|
TListColumn * pCol = m_lvStyles->Columns->Add();
|
|
pCol->Caption = strCaption;
|
|
pCol->Width = 80;
|
|
|
|
for (int i = 0; i <8; i++) {
|
|
String strCaption = LSZ_LIST_HEADS[i];
|
|
TListColumn * pCol = m_lvStyles->Columns->Add();
|
|
pCol->Caption = strCaption;
|
|
pCol->Width = strCaption.Length() * 20;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::ShowCheckStyles()
|
|
{
|
|
//获取当前节拍所有风格
|
|
int nStyleNum = 0;
|
|
|
|
if( 0==f_CM_GetStyleInfos( e_ST_Temp, -1, NULL, &nStyleNum ) && nStyleNum>0 ){
|
|
TPROSTYLE * aStyleInfos = new TPROSTYLE[nStyleNum];
|
|
for( int i=0; i<nStyleNum; i++ ){
|
|
aStyleInfos[i].pOrigin = new TSTYLEORIGIN;
|
|
}
|
|
|
|
f_CM_GetStyleInfos( e_ST_Temp, -1, aStyleInfos, &nStyleNum );
|
|
|
|
for( int i=0; i<nStyleNum; i++ ){
|
|
TPROSTYLE* pInfo = new TPROSTYLE;
|
|
memcpy( pInfo, &aStyleInfos[i], sizeof(TPROSTYLE) );
|
|
|
|
pInfo->pOrigin = new TSTYLEORIGIN;
|
|
memcpy( pInfo->pOrigin, aStyleInfos[i].pOrigin, sizeof(TSTYLEORIGIN) );
|
|
|
|
AddCheckStyle( pInfo );
|
|
}
|
|
|
|
delete[] aStyleInfos;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
String TS2Str( int iTS )
|
|
{
|
|
switch( iTS ){
|
|
case 0:
|
|
return "4/4";
|
|
case 1:
|
|
return "3/4";
|
|
case 2:
|
|
return "2/4";
|
|
case 3:
|
|
return "6/8";
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
void TMainForm::AddCheckStyle(TPROSTYLE * pStyle)
|
|
{
|
|
// Begin to add data
|
|
int iStyleIndex = -1, iAuthorIndex = -1, iTSIndex = -1, iCostIndex = -1,
|
|
iDescriIndex = -1, iScoreIndex = -1, iStyleType = -1;
|
|
|
|
for (int i = 0; i < m_lvStyles->Columns->Count; i++) {
|
|
String strCaption = m_lvStyles->Columns->Items[i]->Caption;
|
|
|
|
if (strCaption.Trim() == L"风格类型") {
|
|
iStyleType = i;
|
|
}
|
|
else if (strCaption.Trim() == L"风格名") {
|
|
iStyleIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"节拍") {
|
|
iTSIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"消耗") {
|
|
iCostIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"好评度") {
|
|
iScoreIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"描述") {
|
|
iDescriIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"作者") {
|
|
iAuthorIndex = i;
|
|
}
|
|
}
|
|
|
|
TListItem * pItem = m_lvStyles->Items->Add();
|
|
TSTYLEORIGIN* pOrigin = pStyle->pOrigin;
|
|
|
|
if( e_Downloaded==pOrigin->state )
|
|
pItem->Caption = L"未审核";
|
|
else
|
|
pItem->Caption = L"未下载";
|
|
|
|
for( int i=0; i<m_lvStyles->Columns->Count; i++)
|
|
pItem->SubItems->Add(L"");
|
|
|
|
int iItemIndex = m_lvStyles->Items->Count - 1;
|
|
if( iItemIndex>=0 ){
|
|
String strValue = L"";
|
|
TStrings * lpStrs = m_lvStyles->Items->Item[iItemIndex]->SubItems;
|
|
lpStrs->Strings[iStyleIndex-1] = UFF8ToMBCS(pOrigin->detail.strStyleName).c_str();
|
|
lpStrs->Strings[iAuthorIndex-1] = UFF8ToMBCS(pOrigin->detail.strAuthor).c_str();
|
|
lpStrs->Strings[iDescriIndex-1] = UFF8ToMBCS(pOrigin->detail.strDescription).c_str();
|
|
lpStrs->Strings[iTSIndex-1] = TS2Str(pOrigin->detail.iTimesignature);
|
|
lpStrs->Strings[iCostIndex-1] = IntToStr(pOrigin->cost);
|
|
lpStrs->Strings[iScoreIndex-1] = IntToStr(pOrigin->score);
|
|
lpStrs->Strings[iStyleType-1] = IntToStr(pOrigin->detail.type[0]) + L","
|
|
+ IntToStr(pOrigin->detail.type[1]);
|
|
|
|
pItem->Data = (LPVOID)pStyle;
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::RefreshCtrlsData(const bool bIsSave)
|
|
{
|
|
if (bIsSave)
|
|
memcpy(g_infoAuthor.detail.type, m_cStyleTypes, sizeof(m_cStyleTypes));
|
|
else {
|
|
BOOL bRet = m_cStyleTypes[0] != -1;
|
|
|
|
mdBtn2->Visible = bRet;
|
|
stLabel2->Visible = bRet;
|
|
stLabel1->Caption = bRet ? LSZ_STYLTYPES[m_cStyleTypes[0]] : "添加风格";
|
|
mdBtn1->Caption = bRet ? L"-" : L"+";
|
|
mdBtn1->Tag = bRet;
|
|
|
|
mdBtn2->Caption = L"+";
|
|
stLabel2->Caption = L"添加风格";
|
|
if (m_cStyleTypes[1] != -1) {
|
|
mdBtn2->Tag = 1;
|
|
mdBtn2->Caption = L"-";
|
|
stLabel2->Caption = LSZ_STYLTYPES[m_cStyleTypes[1]];
|
|
}
|
|
else
|
|
mdBtn2->Tag = 0;
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::ScanLocalFont(const String strDir) {
|
|
char strFontName[80], strCopyright[128], strComment[256];
|
|
|
|
AnsiString strFileName = strDir;
|
|
// 添加音色库
|
|
TSearchRec sr;
|
|
int iAttr = 0;
|
|
|
|
if (FindFirst(strDir + L"*.*", iAttr, sr) == 0) {
|
|
do {
|
|
strFileName = strDir;
|
|
strFileName += sr.Name;
|
|
int nInst, nDrum;
|
|
if (f_MM_GetFontInfo(strFileName.c_str(), strFontName, &nInst, NULL, &nDrum, NULL) == S_OK) {
|
|
FONTINFO * pFI = new FONTINFO;
|
|
strcpy(pFI->strFileName, strFileName.c_str());
|
|
|
|
if (strlen(strFontName) > 0)
|
|
strcpy(pFI->strFontName, strFontName);
|
|
else
|
|
strcpy(pFI->strFontName,
|
|
AnsiString(sr.Name.c_str()).c_str());
|
|
|
|
// Delete the same font path while insert font
|
|
|
|
BOOL bIsSame = FALSE;
|
|
for (int i = 0; i < (int)m_lstFonts.size(); i++) {
|
|
String strTmp =
|
|
ExtractFileName((String)((FONTINFO*)m_lstFonts[i])
|
|
->strFontName);
|
|
if (strTmp == (String)strFontName) {
|
|
bIsSame = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!bIsSame)
|
|
m_lstFonts.push_back(pFI);
|
|
}
|
|
}
|
|
while (FindNext(sr) == 0);
|
|
|
|
FindClose(sr);
|
|
}
|
|
else {
|
|
iAttr = GetLastError();
|
|
}
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::RefeshListAuthorData(TListView * pListView,
|
|
const int iItemIndex, const bool bIsSave) {
|
|
|
|
TListView * pTmpListView = pListView;
|
|
int iFileIndex = -1, iStyleIndex = -1, iAuthorIndex = -1, iPriceIndex = -1,
|
|
iCostIndex = -1, iScoreIndex = -1, iDescriIndex = -1;
|
|
|
|
for (int i = 0; i < pTmpListView->Columns->Count; i++) {
|
|
String strCaption = pTmpListView->Columns->Items[i]->Caption;
|
|
|
|
if (strCaption.Trim() == L"文件名") {
|
|
iFileIndex = i;
|
|
}
|
|
/* else if (strCaption.Trim() == L"推荐和弦") {
|
|
iUpChordsIndex = i;
|
|
}
|
|
*/ else if (strCaption.Trim() == L"风格名") {
|
|
iStyleIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"价格") {
|
|
iPriceIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"消耗") {
|
|
iCostIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"好评度") {
|
|
iScoreIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"描述") {
|
|
iDescriIndex = i;
|
|
}
|
|
else if (strCaption.Trim() == L"作者") {
|
|
iAuthorIndex = i;
|
|
}
|
|
}
|
|
|
|
if (bIsSave) // Save data to the list control
|
|
{
|
|
int iHotIndex = pTmpListView->ItemIndex;
|
|
if (iHotIndex < 0)
|
|
return;
|
|
|
|
int iVcIndex = -1;
|
|
for( int i=0; i<m_vcMdItemIndexs.size(); i++ ){
|
|
if (m_vcMdItemIndexs[i] == iHotIndex) {
|
|
iVcIndex = i;
|
|
break;
|
|
}
|
|
}
|
|
/*
|
|
String strUpChords = L"";
|
|
for (int i = 0; i < 8; i++) {
|
|
strUpChords += IntToStr(g_infoAuthor.detail.chordRecom[i]) + L",";
|
|
}
|
|
*/
|
|
TStrings * lpStrs = pTmpListView->Items->Item[iItemIndex]->SubItems;
|
|
if (lpStrs->Strings[iStyleIndex - 1] != m_StyleName->Text ||
|
|
lpStrs->Strings[iAuthorIndex - 1] != m_Author->Text ||
|
|
lpStrs->Strings[iPriceIndex - 1] != m_edPrice->Text ||
|
|
lpStrs->Strings[iCostIndex - 1] != m_edCost->Text ||
|
|
// lpStrs->Strings[iScoreIndex - 1] != m_edScore->Text ||
|
|
lpStrs->Strings[iDescriIndex - 1] != m_Descri->Text ){
|
|
// || lpStrs->Strings[iUpChordsIndex - 1] != strUpChords)
|
|
|
|
// 判断在Vector中是否已经含有该值
|
|
if (iVcIndex == -1) {
|
|
m_vcMdItemIndexs.push_back(iItemIndex);
|
|
m_lvStyles->Invalidate();
|
|
}
|
|
}
|
|
|
|
lpStrs->Strings[iStyleIndex - 1] = m_StyleName->Text;
|
|
lpStrs->Strings[iAuthorIndex - 1] = m_Author->Text;
|
|
lpStrs->Strings[iPriceIndex - 1] = m_edPrice->Text;
|
|
lpStrs->Strings[iCostIndex - 1] = m_edCost->Text;
|
|
// lpStrs->Strings[iScoreIndex - 1] = m_edScore->Text;
|
|
lpStrs->Strings[iDescriIndex - 1] = m_Descri->Text;
|
|
// lpStrs->Strings[iUpChordsIndex - 1] = strUpChords;
|
|
}
|
|
else // Refresh Controls' data from list
|
|
{
|
|
TStrings *lpStrs = pTmpListView->Items->Item[iItemIndex]->SubItems;
|
|
if (iStyleIndex > 0)
|
|
m_StyleName->Text = lpStrs->Strings[iStyleIndex - 1];
|
|
else if (iStyleIndex == 0)
|
|
m_StyleName->Text = L"";
|
|
|
|
if (iAuthorIndex > 0)
|
|
m_Author->Text = lpStrs->Strings[iAuthorIndex - 1];
|
|
else if (iAuthorIndex == 0)
|
|
m_Author->Text = L"";
|
|
|
|
if (iPriceIndex > 0)
|
|
m_edPrice->Text = lpStrs->Strings[iPriceIndex - 1];
|
|
|
|
if (iCostIndex > 0)
|
|
m_edCost->Text = lpStrs->Strings[iCostIndex - 1];
|
|
|
|
// if (iScoreIndex > 0)
|
|
// m_edScore->Text = lpStrs->Strings[iScoreIndex - 1];
|
|
|
|
if (iDescriIndex > 0)
|
|
m_Descri->Text = lpStrs->Strings[iDescriIndex - 1];
|
|
else if (iDescriIndex == 0)
|
|
m_Descri->Text = L"";
|
|
|
|
// Add By GGGrass 2013年1月9日 16:21:39
|
|
/* String strUpChords = L"";
|
|
if (iDescriIndex > 0)
|
|
strUpChords = lpStrs->Strings[iUpChordsIndex - 1];
|
|
|
|
if (strUpChords.Length() < 16)
|
|
memset(g_infoAuthor.detail.chordRecom, -1, 8);
|
|
|
|
int iIndex = -1;
|
|
String strTmpValue = L"-1";
|
|
for (int i = 0; i < 8; i++) {
|
|
iIndex = strUpChords.Pos(L",");
|
|
strTmpValue = strUpChords.SubString(0, iIndex - 1);
|
|
strUpChords = strUpChords.SubString(iIndex + 1,
|
|
strUpChords.Length() - iIndex);
|
|
|
|
if (iIndex > 0)
|
|
g_infoAuthor.detail.chordRecom[i] = _wtoi(strTmpValue.c_str());
|
|
else
|
|
g_infoAuthor.detail.chordRecom[i] = -1;
|
|
}
|
|
*/ // End Add By GGGrass 2013年1月9日 16:21:49
|
|
}
|
|
}
|
|
|
|
int TMainForm::RecombineStyle( UINT index )
|
|
{
|
|
// 这里风格审核的时候 如果要于主奏乐器里面试听 则需要重新编曲
|
|
// Need Modify By GGGrass 2013年1月10日 10:21:42
|
|
// Begin-----风格批量上传
|
|
int iRet = -1;
|
|
int iFileIndex = -1;
|
|
|
|
for (int i = 0; i < m_lvStyles->Columns->Count; i++) {
|
|
String strCaption = m_lvStyles->Columns->Items[i]->Caption;
|
|
if (strCaption.Trim() == L"文件名") {
|
|
iFileIndex = i;
|
|
}
|
|
}
|
|
|
|
if (iFileIndex > 0 && iFileIndex < m_lvStyles->Columns->Count) {
|
|
String strFileName = m_strMidiDirPath;
|
|
strFileName += m_lvStyles->Items->Item[index]->SubItems->Strings[iFileIndex - 1];
|
|
|
|
iRet = f_CM_RecombineFiles( index, ((AnsiString)strFileName).c_str(),
|
|
&g_iMelodyTimeSignature, &g_nMelodyTempo);
|
|
|
|
f_MM_SetTimeSignature( g_iMelodyTimeSignature );
|
|
f_MM_SetTempo( g_nMelodyTempo );
|
|
}
|
|
else
|
|
return iRet;
|
|
|
|
// End---风格批量上传 End->2013年1月10日 10:19:52
|
|
return iRet;
|
|
}
|
|
|
|
void TMainForm::RefreshAuthorData(bool bIsUpdate) {
|
|
// Need add harmonys' param
|
|
if (!bIsUpdate) {
|
|
memcpy(g_infoAuthor.detail.strAuthor,
|
|
((AnsiString)m_Author->Text).c_str(), 20);
|
|
memcpy(g_infoAuthor.detail.strStyleName,
|
|
((AnsiString)m_StyleName->Text).c_str(), 20);
|
|
memcpy(g_infoAuthor.detail.strDescription,
|
|
((AnsiString)m_Descri->Text).c_str(), 80);
|
|
|
|
memcpy(g_infoAuthor.detail.type, m_cStyleTypes, sizeof(m_cStyleTypes));
|
|
RefreshCtrlsData(true);
|
|
|
|
g_infoAuthor.price = _wtoi(m_edPrice->Text.Trim().c_str());
|
|
g_infoAuthor.cost = _wtoi(m_edCost->Text.Trim().c_str());
|
|
// g_infoAuthor.score = _wtoi(m_edScore->Text.Trim().c_str());
|
|
|
|
if (g_bLogon)
|
|
g_infoAuthor.detail.idAuthor = g_infoUser.accountInfo.ID;
|
|
}
|
|
else {
|
|
RefreshCtrlsData(false);
|
|
m_Author->Text = (WideString)g_infoAuthor.detail.strAuthor;
|
|
m_StyleName->Text = (WideString)g_infoAuthor.detail.strStyleName;
|
|
|
|
char chBuf[30] = {0};
|
|
sprintf(chBuf, "%d", g_infoAuthor.price);
|
|
m_edPrice->Text = (String)chBuf;
|
|
|
|
sprintf(chBuf, "%d", g_infoAuthor.cost);
|
|
m_edCost->Text = (String)chBuf;
|
|
|
|
// sprintf(chBuf, "%d", g_infoAuthor.score);
|
|
// m_edScore->Text = (String)chBuf;
|
|
|
|
m_Descri->Text = (WideString)g_infoAuthor.detail.strDescription;
|
|
}
|
|
}
|
|
|
|
|
|
void TMainForm::ClearAuthorCtrlsInfo()
|
|
{
|
|
// Reset author's data
|
|
TMAKESTYLEINFO tmpAthrInfo;
|
|
memcpy(&g_infoAuthor, &tmpAthrInfo, sizeof(TMAKESTYLEINFO));
|
|
|
|
if (g_bLogon)
|
|
g_infoAuthor.detail.idAuthor = g_infoUser.accountInfo.ID;
|
|
|
|
RefreshAuthorData(true);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
void TMainForm::ResetStylesData(const bool bRecreator)
|
|
{
|
|
// 清空列表
|
|
for( int i=0; i<m_lvStyles->Items->Count; i++ ){
|
|
TPROSTYLE * pStyle = (TPROSTYLE*)m_lvStyles->Items->Item[i]->Data;
|
|
|
|
if( pStyle )
|
|
delete pStyle;
|
|
}
|
|
m_lvStyles->Clear();
|
|
|
|
// 显示信息
|
|
m_menuOpen->Enabled = bRecreator;
|
|
m_menuRefresh->Enabled = !bRecreator;
|
|
m_btnUpload->Visible = bRecreator;
|
|
m_btnVerify->Visible = !bRecreator;
|
|
m_btnSaveExcel->Visible = bRecreator;
|
|
|
|
for (int i = 0; i < GroupBox2->ControlCount; i++) {
|
|
TControl* pCtrl = GroupBox2->Controls[i];
|
|
if( pCtrl->ClassNameIs( TButton::ClassName() )
|
|
|| pCtrl->ClassNameIs( TEdit::ClassName() )
|
|
|| pCtrl->ClassNameIs( TMemo::ClassName() ) ){
|
|
pCtrl->Enabled = bRecreator;
|
|
}
|
|
}
|
|
|
|
String strCaption = bRecreator ? L"魔方风格批量合成" : L"魔方风格批量审核";
|
|
Caption = strCaption;
|
|
}
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void TMainForm::RefreshListStyleType(TListView * pListView, const int iHotItemIndex,
|
|
const bool bIsRead)
|
|
{
|
|
TListView * pTempView = pListView;
|
|
|
|
int iStyleType = -1;
|
|
for (int i = 0; i < pTempView->Columns->Count; i++) {
|
|
String strCaption = pTempView->Columns->Items[i]->Caption;
|
|
|
|
if (strCaption.Trim() == L"风格类型") {
|
|
iStyleType = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
TStrings *lpStrs = pTempView->Items->Item[iHotItemIndex]->SubItems;
|
|
// Save data to list control
|
|
if (!bIsRead) {
|
|
String strValue = L"";
|
|
|
|
strValue = IntToStr(m_cStyleTypes[0]) + L"," +
|
|
IntToStr(m_cStyleTypes[1]) + L",";
|
|
lpStrs->Strings[iStyleType - 1] = strValue;
|
|
|
|
}
|
|
else // Read the data to class paramater
|
|
{
|
|
String strTxt = L"";
|
|
int iIndex = -1;
|
|
strTxt = lpStrs->Strings[iStyleType - 1];
|
|
|
|
char *tokenPtr=NULL;
|
|
tokenPtr=strtok(((AnsiString)strTxt).c_str(),",");
|
|
for( int i=0; tokenPtr!=NULL; i++ ){
|
|
m_cStyleTypes[i] = atoi( tokenPtr );
|
|
tokenPtr = strtok( NULL, "," );
|
|
}
|
|
}
|
|
}
|
|
|