📄 freeamptheme.cpp
字号:
oText = string("Display track name only.");
break;
case kNameArtist:
oText = string("Display track and artist name.");
break;
case kNameArtistAlbum:
oText = string("Display track, artist and album name.");
break;
}
m_pWindow->ControlStringValue("Info", true, oText);
break;
}
case 'h':
case 'H':
ShowHelp();
break;
case '@':
{
string oText("-23:59:59");
if (m_pWindow->DoesControlExist("TimeRemaining"))
m_pWindow->ControlStringValue("TimeRemaining", true, oText);
else
m_pWindow->ControlStringValue("Time", true, oText);
break;
}
case '!':
{
m_bShowBuffers = !m_bShowBuffers;
break;
}
}
}
void FreeAmpTheme::ShowHelp(void)
{
if (!::ShowHelp(m_pContext, FreeAmp_Main_Window))
{
MessageDialog oBox(m_pContext);
string oMessage("Cannot find the help files. Please make sure that the "
"help files are properly installed, and you are not "
"running "the_BRANDING" from the build directory.");
oBox.Show(oMessage.c_str(), string(BRANDING), kMessageOk, true);
}
}
bool FreeAmpTheme::HandleMenuCommand(uint32 uCommand)
{
switch(uCommand)
{
case kMCMyMusic:
m_pContext->target->AcceptEvent(
new Event(CMD_ToggleMusicBrowserUI));
return true;
case kMCPlay:
m_pContext->target->AcceptEvent(
new Event(CMD_Play));
return true;
case kMCStop:
m_pContext->target->AcceptEvent(
new Event(CMD_Stop));
return true;
case kMCPause:
m_pContext->target->AcceptEvent(
new Event(CMD_Pause));
return true;
case kMCNext:
m_pContext->target->AcceptEvent(
new Event(CMD_NextMediaPiece));
return true;
case kMCPrev:
m_pContext->target->AcceptEvent(
new Event(CMD_PrevMediaPiece));
return true;
case kMCExit:
m_pContext->target->AcceptEvent(
new Event(CMD_QuitPlayer));
return true;
}
return false;
}
void FreeAmpTheme::HandleMouseWheelChange(int iSteps)
{
string oControlName("Volume");
int iVol;
bool bEnabled;
m_pWindow->ControlEnable(oControlName, false, bEnabled);
if (bEnabled)
{
m_pWindow->ControlIntValue(oControlName, false, iVol);
iVol += iSteps * 5;
iVol = max(min(iVol, 100), 0);
SetVolume(iVol, m_iBalance);
}
}
void FreeAmpTheme::HandleMouseWheelClick(void)
{
int iState;
string oControlName("Mute");
if (m_iMuteVolume < 0)
{
m_iMuteVolume = m_iVolume;
m_iVolume = 0;
iState = 1;
}
else
{
m_iVolume = m_iMuteVolume;
m_iMuteVolume = -1;
iState = 0;
}
SetVolume(m_iVolume, m_iBalance);
m_pWindow->ControlIntValue(oControlName, true, iState);
}
void FreeAmpTheme::VolumeChanged(void)
{
if (!m_bVolumeChangeInProgress)
m_pContext->target->AcceptEvent(new Event(CMD_GetVolume));
}
void FreeAmpTheme::UpdateTimeDisplay(int iCurrentSeconds)
{
string oText;
char szText[20];
int iSeconds;
if (m_eTimeDisplayState == kTimeRemaining && m_iTotalSeconds >= 0)
{
iSeconds = m_iTotalSeconds - iCurrentSeconds - 1;
if (iSeconds > 3600)
sprintf(szText, "-%d:%02d:%02d",
iSeconds / 3600,
(iSeconds % 3600) / 60,
iSeconds % 60);
else
if (iSeconds <= 0)
sprintf(szText, "0:00");
else
sprintf(szText, "-%d:%02d",
(iSeconds % 3600) / 60,
iSeconds % 60);
}
else
if (iCurrentSeconds >= 0)
{
if (iCurrentSeconds > 3600)
sprintf(szText, "%d:%02d:%02d",
iCurrentSeconds / 3600,
(iCurrentSeconds % 3600) / 60,
iCurrentSeconds % 60);
else
sprintf(szText, "%d:%02d",
(iCurrentSeconds % 3600) / 60,
iCurrentSeconds % 60);
}
else
sprintf(szText, "0:00");
oText = string(szText);
if (m_eTimeDisplayState == kTimeRemaining &&
m_pWindow->DoesControlExist("TimeRemaining") &&
m_iTotalSeconds >= 0)
m_pWindow->ControlStringValue("TimeRemaining", true, oText);
else
m_pWindow->ControlStringValue("Time", true, oText);
}
void FreeAmpTheme::UpdateMetaData(const PlaylistItem *pItem)
{
if (pItem->GetMetaData().Title().length() > 0 ||
pItem->GetMetaData().Artist().length() > 0 ||
pItem->GetMetaData().Album().length() > 0)
{
string oText;
m_oTitle = pItem->GetMetaData().Title();
if (pItem->GetMetaData().Artist().length() > 0 &&
(m_eTitleDisplayState == kNameArtist ||
m_eTitleDisplayState == kNameArtistAlbum))
m_oTitle += string(" ~ ") + pItem->GetMetaData().Artist();
if (pItem->GetMetaData().Album().length() > 0 &&
m_eTitleDisplayState == kNameArtistAlbum)
m_oTitle += string(" ~ ") + pItem->GetMetaData().Album() +
string(" ~ ");;
oText = string(BRANDING": ") + m_oTitle;
m_pWindow->SetTitle(oText);
}
else
m_oTitle = "";
if (pItem->GetMetaData().Title().length() > 0)
{
m_oTrackName = pItem->GetMetaData().Title();
}
else
m_oTrackName = "Unknown";
if (pItem->GetMetaData().Artist().length() > 0)
{
m_oArtist = pItem->GetMetaData().Artist();
}
else
m_oArtist = "Unknown";
if (pItem->GetMetaData().Album().length() > 0)
{
m_oAlbum = pItem->GetMetaData().Album();
}
else
m_oAlbum = "Unknown";
if (pItem->GetMetaData().Year() > 0)
{
char szText[20];
sprintf(szText,"%d",pItem->GetMetaData().Year());
m_oYear = string(szText);
}
else
m_oYear = "";
if (pItem->GetMetaData().Track() > 0)
{
char szText[20];
sprintf(szText,"%d",pItem->GetMetaData().Track());
m_oTrackNo = string(szText);
}
else
m_oTrackNo = "";
if (pItem->GetMetaData().Genre().length() > 0)
{
m_oGenre = pItem->GetMetaData().Genre();
}
else
m_oGenre = "";
if (pItem->GetMetaData().Comment().length() > 0)
{
m_oComment = pItem->GetMetaData().Comment();
}
else
m_oComment = "";
m_pWindow->ControlStringValue(string("Title"), true, m_oTitle);
m_pWindow->ControlStringValue(string("TrackName"), true, m_oTrackName);
m_pWindow->ControlStringValue(string("TrackNo"), true, m_oTrackNo);
m_pWindow->ControlStringValue(string("Artist"), true, m_oArtist);
m_pWindow->ControlStringValue(string("Album"), true, m_oAlbum);
m_pWindow->ControlStringValue(string("Year"), true, m_oYear);
m_pWindow->ControlStringValue(string("Genre"), true, m_oGenre);
m_pWindow->ControlStringValue(string("Comment"), true, m_oComment);
}
void FreeAmpTheme::DropFiles(vector<string> *pFileList)
{
char *ext;
char *url;
uint32 length, countbefore;
vector<string>::iterator i;
bool bPlay;
bool bEmptied = false;
ext = new char[_MAX_PATH];
url = new char[_MAX_PATH + 7];
m_pContext->prefs->GetPrefBoolean(kPlayImmediatelyPref, &bPlay);
countbefore = m_pContext->plm->CountItems();
for(i = pFileList->begin(); i != pFileList->end(); i++)
{
char *pExtension = NULL;
vector<char*> fileList;
struct _stat st;
_stat((*i).c_str(), &st);
if(st.st_mode & _S_IFDIR)
{
vector<string> oList, oQuery;
oQuery.push_back(string("*.mp1"));
oQuery.push_back(string("*.mp2"));
oQuery.push_back(string("*.mp3"));
FindMusicFiles(i->c_str(), oList, oQuery);
if (oList.size() > 0)
{
if(bPlay && !bEmptied)
{
m_pContext->target->AcceptEvent(new Event(CMD_Stop));
m_pContext->plm->RemoveAll();
bEmptied = true;
}
m_pContext->plm->AddItems(oList);
}
}
else
{
PlaylistFormatInfo oInfo;
char ext[_MAX_PATH];
int j;
Error eRet = kError_NoErr;
pExtension = strrchr((*i).c_str(), '.');
if (!pExtension)
continue;
strcpy(ext, pExtension + 1);
ToUpper(ext);
for(j = 0; ; j++)
{
eRet = m_pContext->plm->GetSupportedPlaylistFormats(&oInfo, j);
if (IsError(eRet))
break;
if (strcasecmp(oInfo.GetExtension(), ext) == 0)
break;
}
if (!IsError(eRet))
{
length = _MAX_PATH + 7;
FilePathToURL((*i).c_str(), url, &length);
if (bPlay && !bEmptied)
{
m_pContext->target->AcceptEvent(new Event(CMD_Stop));
m_pContext->plm->RemoveAll();
bEmptied = true;
}
m_pContext->plm->ReadPlaylist(url);
}
else if (m_pContext->player->IsSupportedExtension(ext))
{
length = _MAX_PATH + 7;
FilePathToURL((*i).c_str(), url, &length);
if (bPlay && !bEmptied)
{
m_pContext->target->AcceptEvent(new Event(CMD_Stop));
m_pContext->plm->RemoveAll();
bEmptied = true;
}
m_pContext->plm->AddItem(url);
}
else if (!strcasecmp("fat", ext) ||
!strcasecmp("zip", ext))
{
length = _MAX_PATH + 7;
FilePathToURL((*i).c_str(), url, &length);
m_pContext->player->AddTheme(url);
}
}
}
if (countbefore == 0 || bPlay)
m_pContext->target->AcceptEvent(new Event(CMD_Play));
delete [] ext;
delete [] url;
}
void FreeAmpTheme::PostWindowCreate(void)
{
#ifdef WIN32
Int32PropValue *pProp;
pProp = new Int32PropValue((int)((Win32Window *)m_pWindow)->GetWindowHandle());
m_pContext->props->SetProperty("MainWindow", pProp);
#endif
string winTitle = string(BRANDING);
m_pWindow->SetTitle(winTitle);
}
void FreeAmpTheme::update_thread(void* arg)
{
FreeAmpTheme* _this = (FreeAmpTheme*)arg;
_this->UpdateThread();
}
void FreeAmpTheme::UpdateThread()
{
#ifdef WIN32
m_pUpdateMan->RetrieveLatestVersionInfo();
if(m_pUpdateMan->IsUpdateAvailable())
{
if(0 < DialogBoxParam(g_hinst,
MAKEINTRESOURCE(IDD_UPDATEAVAILABLE),
NULL,
::UpdateAvailableDlgProc,
(LPARAM) 0))
{
ShowOptions(4);
}
}
#endif
delete m_pUpdateThread;
}
void FreeAmpTheme::ShowOptions(uint32 defaultPage)
{
OptionsArgs *oArgs = new OptionsArgs;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -