MusicMod: Stop function

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1787 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-01-05 04:08:18 +00:00
parent 906c8a5a63
commit b5ee01ea60
8 changed files with 129 additions and 87 deletions

View File

@ -50,10 +50,11 @@
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Start console window // Start console window
// ¯¯¯¯¯¯¯¯¯¯ /* ¯¯¯¯¯¯¯¯¯¯
// Width and height is the size of console window, if you specify fname, Width and height is the size of console window, if you specify fname, the output will
// the output will also be writton to this file. The file pointer is automatically closed also be writton to this file. The file pointer is automatically closed
// when you close the app when you close the application. */
// ---------------------
void StartConsoleWin(int width, int height, char* fname) void StartConsoleWin(int width, int height, char* fname)
{ {
#ifdef MM_DEBUG #ifdef MM_DEBUG
@ -64,13 +65,19 @@ void StartConsoleWin(int width, int height, char* fname)
AllocConsole(); AllocConsole();
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
//SetConsoleTitle("Debug Window"); // Set console window title
SetConsoleTitle(fname); SetConsoleTitle(fname);
// Get window handle to write to
__hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); __hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD co = {width,height}; // Create coordinates table
COORD co = {width, height};
// Set the innteral letter space
SetConsoleScreenBufferSize(__hStdOut, co); SetConsoleScreenBufferSize(__hStdOut, co);
// Set the window width and height
SMALL_RECT coo = {0,0, (width - 1),50}; // Top, left, right, bottom SMALL_RECT coo = {0,0, (width - 1),50}; // Top, left, right, bottom
SetConsoleWindowInfo(__hStdOut, TRUE, &coo); SetConsoleWindowInfo(__hStdOut, TRUE, &coo);
#endif #endif
@ -94,33 +101,36 @@ void StartConsoleWin(int width, int height, char* fname)
// ¯¯¯¯¯¯¯¯¯¯ // ¯¯¯¯¯¯¯¯¯¯
int wprintf(char *fmt, ...) int wprintf(char *fmt, ...)
{ {
#ifdef MM_DEBUG #ifdef MM_DEBUG
char s[300]; char s[500]; // Bigget message size
va_list argptr; va_list argptr;
int cnt; int cnt;
va_start(argptr, fmt); va_start(argptr, fmt);
cnt = vsprintf(s, fmt, argptr); cnt = vsprintf(s, fmt, argptr);
va_end(argptr); va_end(argptr);
DWORD cCharsWritten; DWORD cCharsWritten;
// --------------------------------------------------------------------------------- // ---------------------------------------------------
#ifndef MM_DEBUG_FILEONLY // Write to console
if(__hStdOut) // --------------
WriteConsole(__hStdOut, s, strlen(s), &cCharsWritten, NULL); #ifndef MM_DEBUG_FILEONLY
#endif if(__hStdOut)
// --------------------------------------------------------------------------------- WriteConsole(__hStdOut, s, strlen(s), &cCharsWritten, NULL);
#endif
// ----------------------------
// Write to file
if(__fStdOut) if(__fStdOut)
{ {
fprintf(__fStdOut, s); fprintf(__fStdOut, s);
fflush(__fStdOut); // Write file now //fflush(__fStdOut); // Write file now, don't wait
} }
return(cnt); return(cnt);
#else #else
return 0; return 0;
#endif #endif
} }
///////////////////////////// /////////////////////////////

View File

@ -297,18 +297,19 @@ CFrame::MM_UpdateGUI()
// =======================================================================================
// Play and stop music
// ---------------------------------------------------------------------------------------
void void
CFrame::MM_OnPlay() CFrame::MM_OnPlay()
{ {
//MessageBox(0, "CFrame::OnPlay > Begin", "", 0); //wprintf("\nCFrame::OnPlayMusicMod > Begin\n");
wprintf("\nCFrame::OnPlayMusicMod > Begin\n");
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
{ {
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::CORE_RUN)
{ {
wprintf("CFrame::OnPlayMusicMod > Pause\n"); //wprintf("CFrame::OnPlayMusicMod > Pause\n");
if(!MusicMod::GlobalPause) // we may has set this elsewhere if(!MusicMod::GlobalPause) // we may has set this elsewhere
{ {
MusicMod::GlobalPause = true; MusicMod::GlobalPause = true;
@ -316,12 +317,11 @@ CFrame::MM_OnPlay()
{ {
Player_Pause(); Player_Pause();
} }
} }
} }
else else
{ {
wprintf("CFrame::OnPlayMusicMod > Play\n"); //wprintf("CFrame::OnPlayMusicMod > Play\n");
if(MusicMod::GlobalPause) // we may has set this elsewhere if(MusicMod::GlobalPause) // we may has set this elsewhere
{ {
MusicMod::GlobalPause = false; MusicMod::GlobalPause = false;
@ -332,9 +332,15 @@ CFrame::MM_OnPlay()
} }
} }
} }
} }
void
CFrame::MM_OnStop()
{
Player_Stop();
MusicMod::GlobalPause = false;
}
// =======================================================================================
// ======================================================================================= // =======================================================================================

View File

@ -79,7 +79,6 @@ void StructSort (std::vector <MyFilesStructure> &MyFiles)
{ {
for (int j = i + 1; j < MyFiles.size(); j++) for (int j = i + 1; j < MyFiles.size(); j++)
{ {
//if (printerStock[ i ].brand > printerStock[ j ].brand) //comparing brands
if (MyFiles[ i ].offset > MyFiles[ j ].offset) //comparing cost if (MyFiles[ i ].offset > MyFiles[ j ].offset) //comparing cost
{ {
temp = MyFiles[ i ]; // Swapping entire struct temp = MyFiles[ i ]; // Swapping entire struct
@ -92,7 +91,6 @@ void StructSort (std::vector <MyFilesStructure> &MyFiles)
for (long i=1; i<(long)MyFiles.size(); ++i) for (long i=1; i<(long)MyFiles.size(); ++i)
{ {
//cout << printerStock.at(i).brand.c_str() << printerStock.at(i).cost << "\n";
std::cout << i << " " << MyFiles[i].path.c_str() << "#" << MyFiles[i].offset << "\n"; std::cout << i << " " << MyFiles[i].path.c_str() << "#" << MyFiles[i].offset << "\n";
} }
@ -122,19 +120,21 @@ void Main(std::string FileName)
MyFiles.at(i).path = my_pFileSystem->m_FileInfoVector.at(i).m_FullPath; MyFiles.at(i).path = my_pFileSystem->m_FileInfoVector.at(i).m_FullPath;
} }
// Sort the files by offset
StructSort(MyFiles); StructSort(MyFiles);
// These things below will not need to be updated after a new game is started // These things below will not need to be updated after a new game is started
if (dllloaded) return; if (dllloaded) return;
Player_Main(bShowConsole); // Call the DLL for the first time // Call the DLL for the first time
Player_Main(bShowConsole);
//play_file("c:\\demo36_02.ast"); //play_file("c:\\demo36_02.ast");
wprintf("DLL loaded\n"); wprintf("DLL loaded\n");
dllloaded = true; // Do this once dllloaded = true; // Do this once
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
// Make Music directory // Make Music directory
// -------------------------
LPSECURITY_ATTRIBUTES attr; LPSECURITY_ATTRIBUTES attr;
attr = NULL; attr = NULL;
MusicPath = "Music\\"; MusicPath = "Music\\";
@ -272,13 +272,10 @@ void CheckFile(u64 offset, u64 size)
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
} }
} }
//wprintf("Blob.cpp:Read <%i> <%i> <%i> <%i>\n", offset, size, out_ptr);
} // This ends the entire filescan } // This ends the entire filescan
// ======================================================================================= // =======================================================================================
} }
} // end of namespace } // end of namespace

View File

@ -87,6 +87,18 @@ void Player_Play(char * FileName)
GlobalPause = false; GlobalPause = false;
} }
void Player_Stop()
{
Playback::Stop();
//wprintf("Stop\n");
playlist->RemoveAll();
CurrentlyPlayingFile = "";
GlobalPause = false;
}
void Player_Pause() void Player_Pause()
{ {
if (!GlobalPause) if (!GlobalPause)
@ -146,7 +158,7 @@ void Player_Volume(int a)
void ShowConsole() void ShowConsole()
{ {
StartConsoleWin(100, 2000, "MusicMod"); // give room for 2000 rows //StartConsoleWin(100, 2000, "MusicMod"); // give room for 2000 rows
} }

View File

@ -41,6 +41,7 @@ void MakeTime();
EXPORT void Player_Main(bool Console); EXPORT void Player_Main(bool Console);
EXPORT void Player_Console(bool Console); EXPORT void Player_Console(bool Console);
EXPORT void Player_Play(char *); EXPORT void Player_Play(char *);
EXPORT void Player_Stop();
EXPORT void Player_Pause(); EXPORT void Player_Pause();
EXPORT void Player_Unpause(); EXPORT void Player_Unpause();
EXPORT void Player_Mute(); EXPORT void Player_Mute();

View File

@ -246,9 +246,11 @@ EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage)
EVT_TIMER(wxID_ANY, CFrame::OnTimer) EVT_TIMER(wxID_ANY, CFrame::OnTimer)
#endif #endif
END_EVENT_TABLE() END_EVENT_TABLE()
/////////////////////////////////////////////////
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// implementation // Creation and close, quit functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
CFrame::CFrame(wxFrame* parent, CFrame::CFrame(wxFrame* parent,
@ -350,6 +352,24 @@ CFrame::~CFrame()
#endif #endif
} }
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
{
Close(true);
}
void CFrame::OnClose(wxCloseEvent& event)
{
// Don't forget the skip of the window won't be destroyed
event.Skip();
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
Core::Stop();
UpdateGUI();
}
}
/////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Input and host messages // Input and host messages

View File

@ -105,7 +105,7 @@ class CFrame : public wxFrame
wxToolBarToolBase* mm_ToolMute, * mm_ToolPlay, * mm_ToolLog; wxToolBarToolBase* mm_ToolMute, * mm_ToolPlay, * mm_ToolLog;
void MM_UpdateGUI(); void MM_PopulateGUI(); void MM_InitBitmaps(int Theme); void MM_UpdateGUI(); void MM_PopulateGUI(); void MM_InitBitmaps(int Theme);
void MM_OnPlay(); void MM_OnPlay(); void MM_OnStop();
void MM_OnMute(wxCommandEvent& event); void MM_OnMute(wxCommandEvent& event);
void MM_OnPause(wxCommandEvent& event); void MM_OnPause(wxCommandEvent& event);
void MM_OnVolume(wxScrollEvent& event); void MM_OnVolume(wxScrollEvent& event);
@ -169,7 +169,7 @@ class CFrame : public wxFrame
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event); void OnHelp(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event); void DoOpen(bool Boot); // File void OnOpen(wxCommandEvent& event); void DoOpen(bool Boot); // File menu
void OnRefresh(wxCommandEvent& event); void OnRefresh(wxCommandEvent& event);
void OnBrowse(wxCommandEvent& event); void OnBrowse(wxCommandEvent& event);

View File

@ -138,10 +138,10 @@ void CFrame::CreateMenu()
pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP settings")); pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP settings"));
pOptionsMenu->Append(IDM_CONFIG_PAD_PLUGIN, _T("&Pad settings")); pOptionsMenu->Append(IDM_CONFIG_PAD_PLUGIN, _T("&Pad settings"));
pOptionsMenu->Append(IDM_CONFIG_WIIMOTE_PLUGIN, _T("&Wiimote settings")); pOptionsMenu->Append(IDM_CONFIG_WIIMOTE_PLUGIN, _T("&Wiimote settings"));
#ifdef _WIN32 #ifdef _WIN32
pOptionsMenu->AppendSeparator(); pOptionsMenu->AppendSeparator();
pOptionsMenu->Append(IDM_TOGGLE_FULLSCREEN, _T("&Fullscreen\tAlt+Enter")); pOptionsMenu->Append(IDM_TOGGLE_FULLSCREEN, _T("&Fullscreen\tAlt+Enter"));
#endif #endif
m_pMenuBar->Append(pOptionsMenu, _T("&Options")); m_pMenuBar->Append(pOptionsMenu, _T("&Options"));
// Misc menu // Misc menu
@ -422,41 +422,18 @@ void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED (event))
// ============= // =============
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event)) void CFrame::OnRefresh(wxCommandEvent& WXUNUSED (event))
{ {
Close(true); if (m_GameListCtrl)
}
void CFrame::OnClose(wxCloseEvent& event)
{
// Don't forget the skip of the window won't be destroyed
event.Skip();
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{ {
Core::Stop(); m_GameListCtrl->Update();
UpdateGUI();
} }
} }
void CFrame::OnHelp(wxCommandEvent& event)
void CFrame::OnBrowse(wxCommandEvent& WXUNUSED (event))
{ {
switch (event.GetId()) m_GameListCtrl->BrowseForDirectory();
{
case IDM_HELPABOUT:
{
AboutDolphin frame(this);
frame.ShowModal();
break;
}
case IDM_HELPWEBSITE:
File::Launch("http://www.dolphin-emu.com/");
break;
case IDM_HELPGOOGLECODE:
File::Launch("http://code.google.com/p/dolphin-emu/");
break;
}
} }
@ -509,8 +486,13 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
} }
// ============= // =============
void CFrame::DoStop() void CFrame::DoStop()
{ {
#ifdef MUSICMOD // Music modification
MM_OnStop();
#endif
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
{ {
Core::Stop(); Core::Stop();
@ -545,15 +527,6 @@ void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
} }
void CFrame::OnRefresh(wxCommandEvent& WXUNUSED (event))
{
if (m_GameListCtrl)
{
m_GameListCtrl->Update();
}
}
void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event)) void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event))
{ {
CConfigMain ConfigMain(this); CConfigMain ConfigMain(this);
@ -595,10 +568,31 @@ void CFrame::OnPluginWiimote(wxCommandEvent& WXUNUSED (event))
); );
} }
void CFrame::OnBrowse(wxCommandEvent& WXUNUSED (event))
void CFrame::OnHelp(wxCommandEvent& event)
{ {
m_GameListCtrl->BrowseForDirectory(); switch (event.GetId())
{
case IDM_HELPABOUT:
{
AboutDolphin frame(this);
frame.ShowModal();
break;
}
case IDM_HELPWEBSITE:
File::Launch("http://www.dolphin-emu.com/");
break;
case IDM_HELPGOOGLECODE:
File::Launch("http://code.google.com/p/dolphin-emu/");
break;
}
} }
// ========= // Toolbar
// =======================================================
// Miscellaneous menu
// -------------
void CFrame::OnMemcard(wxCommandEvent& WXUNUSED (event)) void CFrame::OnMemcard(wxCommandEvent& WXUNUSED (event))
{ {
@ -610,6 +604,8 @@ void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event))
{ {
CheatsWindow = new wxCheatsWindow(this, wxDefaultPosition, wxSize(600, 390)); CheatsWindow = new wxCheatsWindow(this, wxDefaultPosition, wxSize(600, 390));
} }
// =============
// ======================================================= // =======================================================