From: H.G. Muller Date: Thu, 7 Jul 2011 17:28:04 +0000 (+0200) Subject: Print 50-move counter in Engine-Output title X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=56310c5b198bc521e0a715377c68378b7bcf10a5;p=xboard.git Print 50-move counter in Engine-Output title --- diff --git a/engineoutput.c b/engineoutput.c index 463f652..a21282e 100644 --- a/engineoutput.c +++ b/engineoutput.c @@ -43,6 +43,7 @@ #include "common.h" #include "frontend.h" #include "backend.h" +#include "moves.h" #include "engineoutput.h" typedef struct { @@ -75,6 +76,25 @@ static char header[MSG_SIZ]; #define MAX_VAR 400 static int scores[MAX_VAR], textEnd[MAX_VAR], curDepth[2], nrVariations[2]; +void MakeEngineOutputTitle() +{ + static char buf[MSG_SIZ]; + static char oldTitle[MSG_SIZ]; + char *title = "Engine Output"; + extern int initialRulePlies; + int count; + // figure out value of 50-move counter + count = currentMove; + while( (signed char)boards[count][EP_STATUS] <= EP_NONE && count > backwardMostMove ) count--; + if( count == backwardMostMove ) count -= initialRulePlies; + count += 2*appData.ruleMoves - currentMove; + snprintf(buf, MSG_SIZ, "%s (%d ply to draw)", title, count); + if(count <= 40) title = buf; + if(!strcmp(oldTitle, title)) return; + safeStrCpy(oldTitle, title, MSG_SIZ); + SetEngineOutputTitle(title); +} + // back end, due to front-end wrapper for SetWindowText, and new SetIcon arguments void SetEngineState( int which, int state, char * state_data ) { diff --git a/engineoutput.h b/engineoutput.h index 03c9442..292cb93 100644 --- a/engineoutput.h +++ b/engineoutput.h @@ -66,4 +66,5 @@ void InsertIntoMemo( int which, char * text, int where ); void DoClearMemo(int which); void ResizeWindowControls( int mode ); int EngineOutputDialogExists(); +void SetEngineOutputTitle( char *title ); diff --git a/winboard/wengineoutput.c b/winboard/wengineoutput.c index 301d4f6..f2c0e56 100644 --- a/winboard/wengineoutput.c +++ b/winboard/wengineoutput.c @@ -274,6 +274,11 @@ void DoSetWindowText(int which, int field, char *s_label) SetWindowText( outputField[which][field], s_label ); } +void SetEngineOutputTitle(char *title) +{ + SetWindowText( engineOutputDialog, title ); +} + // This seems pure front end LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { diff --git a/winboard/winboard.c b/winboard/winboard.c index cf66f76..87b1830 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -9824,6 +9824,8 @@ HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) MoveHistorySet( movelist, first, last, current, pvInfoList ); EvalGraphSet( first, last, current, pvInfoList ); + + MakeEngineOutputTitle(); } void diff --git a/xengineoutput.c b/xengineoutput.c index 3067fc1..11b0695 100644 --- a/xengineoutput.c +++ b/xengineoutput.c @@ -167,6 +167,13 @@ void DoSetWindowText(int which, int field, char *s_label) XtSetValues(outputField[which][field], &arg, 1); } +void SetEngineOutputTitle(char *title) +{ + Arg arg; + XtSetArg(arg, XtNtitle, (XtArgVal) title); + XtSetValues(engineOutputShell, &arg, 1); +} + void InsertIntoMemo( int which, char * text, int where ) { XawTextBlock t; diff --git a/xhistory.c b/xhistory.c index d79e7e8..e8dd0b4 100644 --- a/xhistory.c +++ b/xhistory.c @@ -176,5 +176,7 @@ HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) MoveHistorySet( movelist, first, last, current, pvInfoList ); EvalGraphSet( first, last, current, pvInfoList ); + + MakeEngineOutputTitle(); }