// back-end static void DrawHistogram (int x, int y, int width, int value, int side) { int left, top, right, bottom; if( value > -appData.evalThreshold*range && value < +appData.evalThreshold*range ) return; left = x; right = left + width + 1; if( value > 0 ) { top = GetValueY( value ); bottom = y+1; } else { top = y; bottom = GetValueY( value ) + 1; } if( width == MIN_HIST_WIDTH ) { right--; DrawRectangle( left, top, right, bottom, side, FILLED ); } else { DrawRectangle( left, top, right, bottom, side, OPEN ); } }
ScreenSetTime::ScreenSetTime( CString sClassName ) : ScreenWithMenuElements( sClassName ) { LOG->Trace( "ScreenSetTime::ScreenSetTime()" ); m_Selection = hour; FOREACH_PlayerNumber( pn ) GAMESTATE->m_bSideIsJoined[pn] = true; FOREACH_SetTimeSelection( s ) { BitmapText &title = m_textTitle[s]; BitmapText &value = m_textValue[s]; title.LoadFromFont( THEME->GetPathToF("Common title") ); title.SetDiffuse( RageColor(1,1,1,1) ); title.SetText( SetTimeSelectionToString(s) ); title.SetXY( GetTitleX(s), GetTitleY(s) ); this->AddChild( &title ); value.LoadFromFont( THEME->GetPathToF("Common normal") ); value.SetDiffuse( RageColor(1,1,1,1) ); value.SetXY( GetValueX(s), GetValueY(s) ); this->AddChild( &value ); } m_TimeOffset = 0; m_Selection = (SetTimeSelection)0; ChangeSelection( 0 ); SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") ); this->SortByDrawOrder(); }
// back-end static void DrawHistograms () { VisualizationData vd; int i; double step = 1; if( InitVisualization( &vd ) ) { if( vd.hist_width < MIN_HIST_WIDTH ) { DrawHistogramAsDiagram( vd.cy, vd.paint_width, vd.hist_count ); step = 0.5*vd.paint_width / (((vd.hist_count | 7) + 1)/2 + 1.); } else { DrawHistogramFull( vd.cy, step = vd.hist_width, vd.hist_count ); } } if(!differentialView) return; differentialView = 0; DrawSegment( MarginX + MarginW, vd.cy, NULL, NULL, PEN_NONE ); for( i=0; i<vd.hist_count; i++ ) { int index = currFirst + i; int x = MarginX + MarginW + index * step + step/2; DrawSegment((int) x, GetValueY( GetPvScore(index) ), NULL, NULL, PEN_ANY ); } differentialView = 1; }
// the brush selection is made part of the DrawLine, by passing a style argument // the wrapper for doing the text output makes this back-end static void DrawAxisSegmentHoriz (int value, Boolean drawValue) { int y = GetValueY( range*value*100 ); if( drawValue ) { char buf[MSG_SIZ], *b = buf; if( value > 0 ) *b++ = '+'; sprintf(b, "%d", range*value); DrawEvalText(buf, strlen(buf), y); } // [HGM] counts on DrawEvalText to have select transparent background for dotted line! DrawLine( MarginX, y, MarginX + MarginW, y, PEN_BLACK ); // Y-axis tick marks DrawLine( MarginX + MarginW, y, nWidthPB - MarginW, y, PEN_DOTTED ); // hor grid }
/* Actually draw histogram as a diagram, cause there's too much data */ static void DrawHistogramAsDiagram (int cy, int paint_width, int hist_count) { double step; int i; /* Rescale the graph every few moves (as opposed to every move) */ hist_count -= hist_count % 8; hist_count += 8; hist_count /= 2; step = (double) paint_width / (hist_count + 1); for( i=0; i<2; i++ ) { int index = currFirst; int side = (currCurrent + i + 1) & 1; /* Draw current side last */ double x = MarginX + MarginW; if( (index & 1) != side ) { x += step / 2; index++; } DrawSegment( (int) x, cy, NULL, NULL, PEN_NONE ); index += 2; while( index < currLast ) { x += step; DrawSeparator( index, (int) x ); /* Extend line up to current point */ if( currPvInfo[index].depth > 0 ) { DrawSegment((int) x, GetValueY( GetPvScore(index) ), NULL, NULL, (side==0 ? PEN_BOLDWHITE: PEN_BOLDBLACK) ); } index += 2; } } }
void ScreenSetTime::Init() { ScreenWithMenuElements::Init(); m_Selection = hour; FOREACH_SetTimeSelection( s ) { BitmapText &title = m_textTitle[s]; BitmapText &value = m_textValue[s]; title.LoadFromFont( THEME->GetPathF("Common","title") ); title.SetDiffuse( RageColor(1,1,1,1) ); title.SetText( SetTimeSelectionToString(s) ); title.SetXY( GetTitleX(s), GetTitleY(s) ); this->AddChild( &title ); title.SetDiffuse( RageColor(1,1,1,0) ); title.BeginTweening( 0.3f, TWEEN_LINEAR ); title.SetDiffuse( RageColor(1,1,1,1) ); value.LoadFromFont( THEME->GetPathF("Common","normal") ); value.SetDiffuse( RageColor(1,1,1,1) ); value.SetXY( GetValueX(s), GetValueY(s) ); this->AddChild( &value ); value.SetDiffuse( RageColor(1,1,1,0) ); value.BeginTweening( 0.3f, TWEEN_LINEAR ); value.SetDiffuse( RageColor(1,1,1,1) ); } m_soundChangeSelection.Load( THEME->GetPathS("ScreenSetTime","ChangeSelection") ); m_soundChangeValue.Load( THEME->GetPathS("ScreenSetTime","ChangeValue") ); m_TimeOffset = 0; m_Selection = (SetTimeSelection)0; ChangeSelection( 0 ); }