From 9d5cf883b49ff08738e437514a4d0eb978c23647 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 4 Feb 2010 22:46:41 +0100 Subject: [PATCH] Use right mouse button to view seek ads Right down-click does the same as left down-click, right up-click simulates a left up-click off board (so it misses all dots). Use right-click miss to refresh Seek Graph The 'moving' parameter had to be made into an int for this, to indicate right clicks with code 2. Right press now already pushes the clicked ad to the back, so that the up-click will display an underlying one. Bugfix pushing back seek ads on right-click On a right button press the previous in stead of currently hit ad was receiving the penalty. Indicate seek-ad multiplicity If more than one seek ad is inside the capture range of the mouse pointer, an exclamation point is printed before the seek-ad text. Some fixes to make seek-ad suppression work in WinBoard In WinBoard the z-depth was immediately erased by redrawing the graph; the clearing of zlist had to be moved from PlotSeekAd() to AddAd() (where it really belongs). Also aging of z-depth is now suppressed on mere pointer motion. --- backend.c | 46 ++++++++++++++++++++++++++++++++++------------ backend.h | 2 +- winboard/winboard.c | 2 +- xboard.c | 2 +- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/backend.c b/backend.c index dedf333..4abf619 100644 --- a/backend.c +++ b/backend.c @@ -2082,7 +2082,6 @@ PlotSeekAd(int i) { int x, y, color = 0, r = ratingList[i]; float tc = tcList[i]; xList[i] = yList[i] = -100; // outside graph, so cannot be clicked - zList[i] = 0; if(r < minRating+100 && r >=0 ) r = minRating+100; if(r > maxRating) r = maxRating; if(tc < 1.) tc = 1.; @@ -2117,6 +2116,7 @@ AddAd(char *handle, char *rating, int base, int inc, char rated, char *type, in sscanf(rating, "%d", &ratingList[nrOfSeekAds]); tcList[nrOfSeekAds] = base + (2./3.)*inc; seekNrList[nrOfSeekAds] = nr; + zList[nrOfSeekAds] = 0; seekAdList[nrOfSeekAds++] = StrSave(buf); if(plot) PlotSeekAd(nrOfSeekAds-1); } @@ -2209,9 +2209,9 @@ DrawSeekGraph() return TRUE; } -int SeekGraphClick(ClickType click, int x, int y, Boolean moving) +int SeekGraphClick(ClickType click, int x, int y, int moving) { - static int lastDown = 0; + static int lastDown = 0, displayed = 0, lastSecond; if(!seekGraphUp) { // initiate cration of seek graph by requesting seek-ad list if(click == Release || moving) return FALSE; nrOfSeekAds = 0; @@ -2219,23 +2219,39 @@ int SeekGraphClick(ClickType click, int x, int y, Boolean moving) SendToICS(ics_prefix); SendToICS("sought\n"); // should this be "sought all"? } else { // issue challenge based on clicked ad - int dist = 10000; int i, closest = 0; + int dist = 10000; int i, closest = 0, second = 0; for(i=0; i0) zList[i] *= 0.8; // age priority + second += (d - zList[i] < 120); // count in-range ads + if(click == Press && moving != 1 && zList[i]>0) zList[i] *= 0.8; // age priority } - if(dist < 300) { + if(dist < 120) { char buf[MSG_SIZ]; - if(lastDown != closest) DisplayMessage(seekAdList[closest], ""); + second = (second > 1); + if(displayed != closest || second != lastSecond) { + DisplayMessage(second ? "!" : "", seekAdList[closest]); + lastSecond = second; displayed = closest; + } sprintf(buf, "play %d\n", seekNrList[closest]); - if(click == Press) { lastDown = closest; return TRUE; } // on press 'hit', only show info + if(click == Press) { + if(moving == 2) zList[closest] = 100; // right-click; push to back on press + lastDown = closest; + return TRUE; + } // on press 'hit', only show info + if(moving == 2) return TRUE; // ignore right up-clicks on dot SendToICS(ics_prefix); SendToICS(buf); // should this be "sought all"? } else if(click == Release) { // release 'miss' is ignored - zList[lastDown] = 200; // make future selection of the rejected ad more difficult + zList[lastDown] = 100; // make future selection of the rejected ad more difficult + if(moving == 2) { // right up-click + nrOfSeekAds = 0; // refresh graph + soughtPending = TRUE; + SendToICS(ics_prefix); + SendToICS("sought\n"); // should this be "sought all"? + } return TRUE; - } else if(moving) { if(lastDown >= 0) DisplayMessage("", ""); lastDown = -1; return TRUE; } + } else if(moving) { if(displayed >= 0) DisplayMessage("", ""); displayed = -1; return TRUE; } // press miss or release hit 'pop down' seek graph seekGraphUp = FALSE; DrawPosition(TRUE, NULL); @@ -5976,7 +5992,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) if(appData.seekGraph && appData.icsActive && loggedOn && (gameMode == BeginningOfGame || gameMode == IcsIdle)) { - SeekGraphClick(clickType, xPix, yPix, FALSE); + SeekGraphClick(clickType, xPix, yPix, 0); return; } @@ -6184,10 +6200,16 @@ int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) { // front-end-free part taken out of PieceMenuPopup int whichMenu; int xSqr, ySqr; + if(seekGraphUp) { // [HGM] seekgraph + if(action == Press) SeekGraphClick(Press, x, y, 2); // 2 indicates right-click: no pop-down on miss + if(action == Release) SeekGraphClick(Release, x, y, 2); // and no challenge on hit + return -2; + } + xSqr = EventToSquare(x, BOARD_WIDTH); ySqr = EventToSquare(y, BOARD_HEIGHT); if (action == Release) UnLoadPV(); // [HGM] pv - if (action != Press) return -2; + if (action != Press) return -2; // return code to be ignored switch (gameMode) { case IcsExamining: if(xSqr < BOARD_LEFT || xSqr >= BOARD_RGHT) return -1; diff --git a/backend.h b/backend.h index dd0bec0..e2b967b 100644 --- a/backend.h +++ b/backend.h @@ -139,7 +139,7 @@ int LoadPosition P((FILE *f, int n, char *title)); int ReloadPosition P((int offset)); int SavePosition P((FILE *f, int dummy, char *dummy2)); int DrawSeekGraph P(()); -int SeekGraphClick P((ClickType click, int x, int y, Boolean moving)); +int SeekGraphClick P((ClickType click, int x, int y, int moving)); void EditPositionEvent P((void)); void FlipViewEvent P((void)); void MachineWhiteEvent P((void)); diff --git a/winboard/winboard.c b/winboard/winboard.c index 0958d00..29f7981 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -3773,7 +3773,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_MOUSEMOVE: - if(SeekGraphClick(Press, pt.x - boardRect.left, pt.y - boardRect.top, TRUE)) break; + if(SeekGraphClick(Press, pt.x - boardRect.left, pt.y - boardRect.top, 1)) break; MovePV(pt.x - boardRect.left, pt.y - boardRect.top, boardRect.bottom - boardRect.top); if ((appData.animateDragging || appData.highlightDragging) && (wParam & MK_LBUTTON) diff --git a/xboard.c b/xboard.c index 2102837..7e30187 100644 --- a/xboard.c +++ b/xboard.c @@ -4224,7 +4224,7 @@ void EventProc(widget, unused, event) XDrawPosition(widget, True, NULL); break; case MotionNotify: - if(SeekGraphClick(Press, event->xbutton.x, event->xbutton.y, TRUE)) break; + if(SeekGraphClick(Press, event->xbutton.x, event->xbutton.y, 1)) break; default: return; } -- 1.7.0.4