diff --git a/PianoFromAbove/Config.cpp b/PianoFromAbove/Config.cpp index b57f714..69b189a 100644 --- a/PianoFromAbove/Config.cpp +++ b/PianoFromAbove/Config.cpp @@ -218,6 +218,7 @@ void VizSettings::LoadDefaultValues() { this->sSplashMIDI = L""; this->bVisualizePitchBends = false; this->bDumpFrames = false; + this->iBarColor = 0x00FF0080; } void AudioSettings::LoadMIDIDevices() @@ -354,26 +355,34 @@ void ViewSettings::LoadConfigValues( TiXmlElement *txRoot ) } void VizSettings::LoadConfigValues(TiXmlElement* txRoot) { - TiXmlElement* txView = txRoot->FirstChildElement("Viz"); - if (!txView) + TiXmlElement* txViz = txRoot->FirstChildElement("Viz"); + if (!txViz) return; int iAttrVal; - if (txView->QueryIntAttribute("TickBased", &iAttrVal) == TIXML_SUCCESS) + if (txViz->QueryIntAttribute("TickBased", &iAttrVal) == TIXML_SUCCESS) bTickBased = (iAttrVal != 0); - if (txView->QueryIntAttribute("ShowMarkers", &iAttrVal) == TIXML_SUCCESS) + if (txViz->QueryIntAttribute("ShowMarkers", &iAttrVal) == TIXML_SUCCESS) bShowMarkers = (iAttrVal != 0); - if (txView->QueryIntAttribute("NerdStats", &iAttrVal) == TIXML_SUCCESS) + if (txViz->QueryIntAttribute("NerdStats", &iAttrVal) == TIXML_SUCCESS) bNerdStats = (iAttrVal != 0); - if (txView->QueryIntAttribute("VisualizePitchBends", &iAttrVal) == TIXML_SUCCESS) + if (txViz->QueryIntAttribute("VisualizePitchBends", &iAttrVal) == TIXML_SUCCESS) bVisualizePitchBends = (iAttrVal != 0); - if (txView->QueryIntAttribute("DumpFrames", &iAttrVal) == TIXML_SUCCESS) + if (txViz->QueryIntAttribute("DumpFrames", &iAttrVal) == TIXML_SUCCESS) bDumpFrames = (iAttrVal != 0); std::string sTempStr; - txView->QueryStringAttribute("SplashMIDI", &sTempStr); + txViz->QueryStringAttribute("SplashMIDI", &sTempStr); sSplashMIDI = Util::StringToWstring(sTempStr); - txView->QueryIntAttribute("MarkerEncoding", (int*)&eMarkerEncoding); + txViz->QueryIntAttribute("MarkerEncoding", (int*)&eMarkerEncoding); eMarkerEncoding = min(MarkerEncoding::CP1252, max(eMarkerEncoding, MarkerEncoding::UTF8)); + + int r, g, b = 0; + TiXmlElement* txBarColor = txViz->FirstChildElement("BarColor"); + if (txBarColor) + if (txBarColor->QueryIntAttribute("R", &r) == TIXML_SUCCESS && + txBarColor->QueryIntAttribute("G", &g) == TIXML_SUCCESS && + txBarColor->QueryIntAttribute("B", &b) == TIXML_SUCCESS) + iBarColor = ((r & 0xFF) << 0) | ((g & 0xFF) << 8) | ((b & 0xFF) << 16); } //----------------------------------------------------------------------------- @@ -479,5 +488,11 @@ bool VizSettings::SaveConfigValues(TiXmlElement* txRoot) { txViz->SetAttribute("SplashMIDI", Util::WstringToString(sSplashMIDI)); txViz->SetAttribute("VisualizePitchBends", bVisualizePitchBends); txViz->SetAttribute("DumpFrames", bDumpFrames); + + TiXmlElement* txBarColor = new TiXmlElement("BarColor"); + txViz->LinkEndChild(txBarColor); + txBarColor->SetAttribute("R", (iBarColor >> 0) & 0xFF); + txBarColor->SetAttribute("G", (iBarColor >> 8) & 0xFF); + txBarColor->SetAttribute("B", (iBarColor >> 16) & 0xFF); return true; } \ No newline at end of file diff --git a/PianoFromAbove/Config.h b/PianoFromAbove/Config.h index 8027269..0be3123 100644 --- a/PianoFromAbove/Config.h +++ b/PianoFromAbove/Config.h @@ -179,6 +179,7 @@ struct VizSettings : public ISettings { std::wstring sSplashMIDI; bool bVisualizePitchBends; bool bDumpFrames; + int iBarColor; }; class Config : public ISettings @@ -203,7 +204,7 @@ class Config : public ISettings const ControlsSettings& GetControlsSettings() const { return m_ControlsSettings; } PlaybackSettings& GetPlaybackSettings() { return m_PlaybackSettings; } ViewSettings& GetViewSettings() { return m_ViewSettings; } - const VizSettings& GetVizSettings() const { return m_VizSettings; } + VizSettings& GetVizSettings() { return m_VizSettings; } void SetVisualSettings(const VisualSettings &VisualSettings) { m_VisualSettings = VisualSettings; } void SetAudioSettings(const AudioSettings &audioSettings) { m_AudioSettings = audioSettings; } diff --git a/PianoFromAbove/ConfigProcs.cpp b/PianoFromAbove/ConfigProcs.cpp index 99a57b6..0de72a4 100644 --- a/PianoFromAbove/ConfigProcs.cpp +++ b/PianoFromAbove/ConfigProcs.cpp @@ -77,14 +77,14 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) // Config to fill out the form Config &config = Config::GetConfig(); - SetVisualProc( hWnd, config.GetVisualSettings() ); + SetVisualProc( hWnd, config.GetVisualSettings(), config.GetVizSettings() ); return TRUE; } // Draws the colored buttons case WM_DRAWITEM: { LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT)lParam; - if ( ( pdis->CtlID < IDC_COLOR1 || pdis->CtlID > IDC_COLOR6 ) && pdis->CtlID != IDC_BKGCOLOR ) + if ( ( pdis->CtlID < IDC_COLOR1 || pdis->CtlID > IDC_COLOR6 ) && pdis->CtlID != IDC_BKGCOLOR && pdis->CtlID != IDC_BARCOLOR ) return FALSE; SetDCBrushColor( pdis->hDC, (COLORREF)GetWindowLongPtr( pdis->hwndItem, GWLP_USERDATA ) ); @@ -111,6 +111,7 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) case IDC_COLOR1: case IDC_COLOR2: case IDC_COLOR3: case IDC_COLOR4: case IDC_COLOR5: case IDC_COLOR6: case IDC_BKGCOLOR: + case IDC_BARCOLOR: { static COLORREF acrCustClr[16] = { 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF }; @@ -135,8 +136,11 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) VisualSettings cVisualSettings; cVisualSettings.LoadDefaultValues(); + VizSettings cVizSettings; + cVizSettings.LoadDefaultValues(); + SendMessage( hWnd, WM_SETREDRAW, FALSE, 0 ); - SetVisualProc( hWnd, cVisualSettings ); + SetVisualProc( hWnd, cVisualSettings, cVizSettings ); SendMessage( hWnd, WM_SETREDRAW, TRUE, 0 ); InvalidateRect( hWnd, NULL, FALSE ); return TRUE; @@ -156,6 +160,7 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) Config &config = Config::GetConfig(); VisualSettings cVisual = config.GetVisualSettings(); ViewSettings &cView = config.GetViewSettings(); + VizSettings &cViz = config.GetVizSettings(); // VisualSettings struct bool bAlwaysShowControls = cVisual.bAlwaysShowControls; @@ -170,6 +175,7 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) for ( int i = 0; i < IDC_COLOR6 - IDC_COLOR1 + 1; i++ ) cVisual.colors[i] = (int)GetWindowLongPtr( GetDlgItem( hWnd, IDC_COLOR1 + i ), GWLP_USERDATA ); cVisual.iBkgColor = (int)GetWindowLongPtr( GetDlgItem( hWnd, IDC_BKGCOLOR ), GWLP_USERDATA ); + cViz.iBarColor = (int)GetWindowLongPtr(GetDlgItem(hWnd, IDC_BARCOLOR), GWLP_USERDATA); // Report success and return config.SetVisualSettings( cVisual ); @@ -187,7 +193,7 @@ INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) } // Sets the values in the playback settings dialog. Used at init and restoring defaults -VOID SetVisualProc( HWND hWnd, const VisualSettings &cVisual ) +VOID SetVisualProc( HWND hWnd, const VisualSettings &cVisual, const VizSettings& cViz ) { HWND hWndFirstKey = GetDlgItem( hWnd, IDC_FIRSTKEY ); HWND hWndLastKey = GetDlgItem( hWnd, IDC_LASTKEY ); @@ -204,6 +210,7 @@ VOID SetVisualProc( HWND hWnd, const VisualSettings &cVisual ) for ( int i = 0; i < IDC_COLOR6 - IDC_COLOR1 + 1; i++ ) SetWindowLongPtr( GetDlgItem( hWnd, IDC_COLOR1 + i ), GWLP_USERDATA, cVisual.colors[i] ); SetWindowLongPtr( GetDlgItem( hWnd, IDC_BKGCOLOR ), GWLP_USERDATA, cVisual.iBkgColor ); + SetWindowLongPtr( GetDlgItem( hWnd, IDC_BARCOLOR ), GWLP_USERDATA, cViz.iBarColor ); } INT_PTR WINAPI AudioProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) diff --git a/PianoFromAbove/ConfigProcs.h b/PianoFromAbove/ConfigProcs.h index 43beddf..27c81a3 100644 --- a/PianoFromAbove/ConfigProcs.h +++ b/PianoFromAbove/ConfigProcs.h @@ -20,7 +20,7 @@ VOID DoPreferences( HWND hWndOwner ); VOID Changed( HWND hWnd ); INT_PTR WINAPI VisualProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); -VOID SetVisualProc( HWND hWnd, const VisualSettings &cVisual ); +VOID SetVisualProc( HWND hWnd, const VisualSettings &cVisual, const VizSettings& cViz ); INT_PTR WINAPI NoteSpanProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); void MIDIInProc( unsigned char cStatus, unsigned char cParam1, unsigned char cParam2, int iMilliSecs, void *pUserData ); diff --git a/PianoFromAbove/GameState.cpp b/PianoFromAbove/GameState.cpp index 1aace1f..a92c59a 100644 --- a/PianoFromAbove/GameState.cpp +++ b/PianoFromAbove/GameState.cpp @@ -595,9 +595,12 @@ void MainScreen::InitNoteMap( const vector< MIDIEvent* > &vEvents ) // Display colors void MainScreen::InitColors() { + static Config& config = Config::GetConfig(); + static const VizSettings& cViz = config.GetVizSettings(); + m_csBackground.SetColor( 0x00464646, 0.7f, 1.3f ); m_csKBBackground.SetColor( 0x00999999, 0.4f, 0.0f ); - m_csKBRed.SetColor( 0x0000E6E6, 0.5f ); // "red" + m_csKBRed.SetColor(cViz.iBarColor, 0.5f); m_csKBWhite.SetColor( 0x00FFFFFF, 0.8f, 0.6f ); m_csKBSharp.SetColor( 0x00404040, 0.5f, 0.0f ); } @@ -961,6 +964,9 @@ GameState::GameError MainScreen::Logic( void ) static const VizSettings &cViz = config.GetVizSettings(); const MIDI::MIDIInfo &mInfo = m_MIDI.GetInfo(); + // people are probably going to yell at me if you can't change the bar color during playback + m_csKBRed.SetColor(cViz.iBarColor, 0.5f); + // Detect changes in state bool bPaused = cPlayback.GetPaused(); double dSpeed = cPlayback.GetSpeed(); diff --git a/PianoFromAbove/PianoFromAbove.rc b/PianoFromAbove/PianoFromAbove.rc index 396ff09..200eec6 100644 Binary files a/PianoFromAbove/PianoFromAbove.rc and b/PianoFromAbove/PianoFromAbove.rc differ diff --git a/PianoFromAbove/resource.h b/PianoFromAbove/resource.h index 522ed14..8c35ff7 100644 --- a/PianoFromAbove/resource.h +++ b/PianoFromAbove/resource.h @@ -34,6 +34,8 @@ #define IDC_COLOR5 1010 #define IDC_COLOR6 1011 #define IDC_BKGCOLOR 1012 +#define IDC_COLOR7 1013 +#define IDC_BARCOLOR 1013 #define IDC_SHOWALLKEYS 1020 #define IDC_SHOWSONGKEYS 1021 #define IDC_SHOWCUSTOMKEYS 1022 @@ -199,7 +201,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 157 +#define _APS_NEXT_RESOURCE_VALUE 158 #define _APS_NEXT_COMMAND_VALUE 40173 #define _APS_NEXT_CONTROL_VALUE 1108 #define _APS_NEXT_SYMED_VALUE 102