diff --git a/Guitar Player/Guitar Player.vcxproj b/Guitar Player/Guitar Player.vcxproj index 8059327..f256667 100644 --- a/Guitar Player/Guitar Player.vcxproj +++ b/Guitar Player/Guitar Player.vcxproj @@ -146,6 +146,7 @@ + diff --git a/Guitar Player/Guitar Player.vcxproj.filters b/Guitar Player/Guitar Player.vcxproj.filters index 86aacb8..6a3318c 100644 --- a/Guitar Player/Guitar Player.vcxproj.filters +++ b/Guitar Player/Guitar Player.vcxproj.filters @@ -86,6 +86,9 @@ Header Files + + Header Files + diff --git a/Guitar Player/Midifile/Options.cpp b/Guitar Player/Midifile/Options.cpp index 3f336df..b1927a5 100644 --- a/Guitar Player/Midifile/Options.cpp +++ b/Guitar Player/Midifile/Options.cpp @@ -19,7 +19,6 @@ #include #include - namespace smf { /////////////////////////////////////////////////////////////////////////// diff --git a/Guitar Player/PlayerFunctionality.h b/Guitar Player/PlayerFunctionality.h index 20e6dbf..9ff8112 100644 --- a/Guitar Player/PlayerFunctionality.h +++ b/Guitar Player/PlayerFunctionality.h @@ -16,6 +16,7 @@ #include #include "WindowsUtility.h" #include "InputBlocker.h" +#include "globals.h" @@ -345,7 +346,10 @@ void PlaySong(const std::filesystem::path& songPath, bool& isPlaying, bool& isPa double accumulatedTime = currentProgress; auto lastUpdateTime = std::chrono::high_resolution_clock::now(); InputBlocker inputBlocker; - inputBlocker.Start(targetWindow); + + if (obstruction) { + inputBlocker.Start(targetWindow); + } while (isPlaying) { // Handle pausing if (isPaused) { diff --git a/Guitar Player/Source.cpp b/Guitar Player/Source.cpp index 58016bf..c5c3052 100644 --- a/Guitar Player/Source.cpp +++ b/Guitar Player/Source.cpp @@ -11,6 +11,7 @@ #include "PlayerFunctionality.h" #include "resource.h" #include "VersionNum.h" +#include "globals.h" #ifdef __WXMSW__ #include @@ -19,6 +20,7 @@ #pragma comment(lib, "dwmapi.lib") #endif +bool obstruction = true; class DarkPanel : public wxPanel { public: @@ -404,10 +406,13 @@ class MainFrame : public wxFrame { searchBox = new DarkSearchBox(groupPanelSongs, wxID_ANY); refreshButton = new DarkButton(groupPanelSongs, wxID_ANY, "Refresh"); + obstructionButton = new DarkButton(groupPanelSongs, wxID_ANY, "Obstruct"); // Add search box and refresh button to the horizontal sizer + searchSizer->Add(obstructionButton, 0, wxEXPAND | wxRIGHT, 5); searchSizer->Add(searchBox, 1, wxEXPAND | wxRIGHT, 5); - searchSizer->Add(refreshButton, 0, wxEXPAND); + searchSizer->Add(refreshButton, 0, wxEXPAND | wxRIGHT, 5); + listBox = new DarkListBox(groupPanelSongs, wxID_ANY); @@ -468,6 +473,7 @@ class MainFrame : public wxFrame { listBox->Bind(wxEVT_LISTBOX, &MainFrame::OnSongSelect, this); progressBar->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MainFrame::OnSeek, this); refreshButton->Bind(wxEVT_BUTTON, &MainFrame::OnRefresh, this); + obstructionButton->Bind(wxEVT_BUTTON, &MainFrame::OnObstruction, this); // Create timer for progress updates progressTimer = new wxTimer(this); @@ -483,6 +489,7 @@ class MainFrame : public wxFrame { timeLabel->SetFont(customFont); currentSongLabel->SetFont(customFont); refreshButton->SetFont(customFont); + obstructionButton->SetFont(customFont); // Bind the close event Bind(wxEVT_CLOSE_WINDOW, &MainFrame::OnClose, this); @@ -501,6 +508,18 @@ class MainFrame : public wxFrame { RefreshButtonsInWindow(this); } + void OnObstruction(wxCommandEvent& event) { + if (obstruction) { + obstruction = false; + WindowsUtility::showMessageBox("This is not recommended and will cause playback to be substantially lower quality.", "Warning", MB_OK | MB_ICONWARNING); + } + else { + obstruction = true; + } + RefreshAllButtons(); + UpdateButtonStates(); + } + void OnRefresh(wxCommandEvent& event) { wxString currentSearch = searchBox->GetValue(); LoadSongs("songs"); @@ -768,10 +787,15 @@ class MainFrame : public wxFrame { pauseButton->SetBackgroundColour(activeColor); playButton->SetBackgroundColour(inactiveColor); } + else if (obstruction) { + //If input blocking is disabled + obstructionButton->SetBackgroundColour(activeColor); + } else { // Stopped state playButton->SetBackgroundColour(inactiveColor); pauseButton->SetBackgroundColour(inactiveColor); + obstructionButton->SetBackgroundColour(inactiveColor); } stopButton->SetBackgroundColour(inactiveColor); @@ -780,6 +804,7 @@ class MainFrame : public wxFrame { playButton->ForceRefresh(); pauseButton->ForceRefresh(); stopButton->ForceRefresh(); + obstructionButton->ForceRefresh(); } void OnClose(wxCloseEvent& event) { @@ -792,6 +817,7 @@ class MainFrame : public wxFrame { DarkButton* pauseButton; DarkButton* stopButton; DarkButton* refreshButton; + DarkButton* obstructionButton; CustomProgressBar* progressBar; wxStaticText* timeLabel; wxTimer* progressTimer; @@ -834,5 +860,4 @@ class MusicPlayerApp : public wxApp { return true; } }; - wxIMPLEMENT_APP(MusicPlayerApp); \ No newline at end of file diff --git a/Guitar Player/globals.h b/Guitar Player/globals.h new file mode 100644 index 0000000..6077f59 --- /dev/null +++ b/Guitar Player/globals.h @@ -0,0 +1,9 @@ +#pragma once +// globals.h +#ifndef GLOBALS_H +#define GLOBALS_H + +// Declare the global variable +extern bool obstruction; + +#endif // GLOBALS_H