SelectionXlat.cpp 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // SelectionXlat.cpp
  24. // Message stream translator
  25. // Author: Michael S. Booth, January 2001
  26. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  27. #include "Common/ActionManager.h"
  28. #include "Common/GameAudio.h"
  29. #include "Common/GameEngine.h"
  30. #include "Common/MessageStream.h"
  31. #include "Common/MiscAudio.h"
  32. #include "Common/Player.h"
  33. #include "Common/PlayerList.h"
  34. #include "Common/ThingTemplate.h"
  35. #include "GameLogic/Damage.h"
  36. #include "GameLogic/GameLogic.h"
  37. #include "GameLogic/Object.h"
  38. #include "GameLogic/Squad.h"
  39. #include "GameLogic/Module/BodyModule.h"
  40. #include "GameLogic/Module/ContainModule.h"
  41. #include "GameLogic/Module/UpdateModule.h"
  42. #include "GameClient/ControlBar.h"
  43. #include "GameClient/Display.h"
  44. #include "GameClient/Drawable.h"
  45. #include "GameClient/GameClient.h"
  46. #include "GameClient/GameText.h"
  47. #include "GameClient/GameWindowManager.h"
  48. #include "GameClient/Keyboard.h"
  49. #include "GameClient/SelectionInfo.h"
  50. #include "GameClient/SelectionXlat.h"
  51. #include "GameClient/TerrainVisual.h"
  52. #ifdef _INTERNAL
  53. // for occasional debugging...
  54. //#pragma optimize("", off)
  55. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  56. #endif
  57. //-----------------------------------------------------------------------------
  58. //-----------------------------------------------------------------------------
  59. //-----------------------------------------------------------------------------
  60. #if defined(_DEBUG) || defined(_INTERNAL)
  61. static Bool TheHurtSelectionMode = false;
  62. static Bool TheHandOfGodSelectionMode = false;
  63. static Bool TheDebugSelectionMode = false;
  64. #endif
  65. //-----------------------------------------------------------------------------
  66. static Bool currentlyLookingForSelection( )
  67. {
  68. // This needs to check if we are currently targetting for special weapons fire.
  69. return TheInGameUI->getGUICommand() == NULL;
  70. }
  71. //-----------------------------------------------------------------------------
  72. static Bool areAllSelected( const DrawableList& listToCheck )
  73. {
  74. DrawableListCIt it;
  75. for ( it = listToCheck.begin(); it != listToCheck.end(); ++it ) {
  76. if (!*it)
  77. continue;
  78. if (!(*it)->isSelected())
  79. return FALSE;
  80. }
  81. return TRUE;
  82. }
  83. //-----------------------------------------------------------------------------
  84. struct SFWRec
  85. {
  86. SelectionTranslator *translator;
  87. GameMessage *createTeamMsg;
  88. Bool dragSelecting;
  89. };
  90. //-----------------------------------------------------------------------------
  91. /*friend*/ Bool selectFriendsWrapper( Drawable *draw, void *userData )
  92. {
  93. SFWRec *info = (SFWRec *)userData;
  94. return info->translator->selectFriends(draw, info->createTeamMsg, info->dragSelecting) != 0;
  95. } // end selectFriendsWrapper
  96. /*friend*/ Bool killThemKillThemAllWrapper( Drawable *draw, void *userData )
  97. {
  98. SFWRec *info = (SFWRec *)userData;
  99. info->translator->killThemKillThemAll( draw, info->createTeamMsg );
  100. return true;
  101. }
  102. //-----------------------------------------------------------------------------
  103. /**
  104. * Returns true if the drawable can be selected under the current rules
  105. * of the system
  106. */
  107. Bool CanSelectDrawable( const Drawable *draw, Bool dragSelecting )
  108. {
  109. if(!draw || !draw->getObject())
  110. {
  111. return FALSE; // can't select
  112. }
  113. const Object *obj = draw->getObject();
  114. if( obj->isEffectivelyDead() && !obj->isKindOf(KINDOF_ALWAYS_SELECTABLE))
  115. {
  116. //Don't select dead/dying units.
  117. return FALSE;
  118. }
  119. //Added this to support attacking cargo planes without being able to select them.
  120. //I added the KINDOF_FORCEATTACKABLE to them, but unsure if it's possible to select
  121. //something without the KINDOF_SELECTABLE -- so doing a LATE code change. My gut
  122. //says we should simply have the KINDOF_SELECTABLE check only... but best to be safe.
  123. if( !obj->isKindOf( KINDOF_SELECTABLE ) && obj->isKindOf( KINDOF_FORCEATTACKABLE ) )
  124. {
  125. return FALSE;
  126. }
  127. // hidden objects cannot be selected
  128. if( draw->isDrawableEffectivelyHidden() )
  129. {
  130. return FALSE; // can't select
  131. }
  132. // ignore objects obscured by the GUI
  133. GameWindow *window = NULL;
  134. if (TheWindowManager)
  135. {
  136. const Coord3D *c = draw->getPosition();
  137. ICoord2D c2;
  138. TheTacticalView->worldToScreen(c, &c2);
  139. window = TheWindowManager->getWindowUnderCursor(c2.x, c2.y);
  140. }
  141. while (window)
  142. {
  143. // check to see if it or any of its parents are opaque. If so, we can't select anything.
  144. if (!BitTest( window->winGetStatus(), WIN_STATUS_SEE_THRU ))
  145. {
  146. return FALSE;
  147. }
  148. window = window->winGetParent();
  149. }
  150. //
  151. // structures cannot be selected by a drag select, you must individually pick them
  152. // NOTE that this is really a convenience for the multi select context sensitive UI,
  153. // later we might want to allow you to drag select buildings if only one building is
  154. // actually in the selection area, but don't forget complications like holding down
  155. // a key to "add" to an already existing selection list
  156. //
  157. // not allowing you to have multiple buildings selected drastically simplifies the
  158. // user interface ... including all those context sensitive commands that we
  159. // can just assume are for a single building selected.
  160. //
  161. if( dragSelecting && draw->isKindOf( KINDOF_STRUCTURE ) )
  162. {
  163. return FALSE;
  164. }
  165. // You cannot select something that has a logic override of unselectability or masked
  166. if( BitTest( obj->getStatusBits(), OBJECT_STATUS_UNSELECTABLE | OBJECT_STATUS_MASKED ) )
  167. {
  168. return FALSE;
  169. }
  170. if (!obj->isSelectable())
  171. {
  172. return false;
  173. }
  174. //Now allowing the selection of everything including enemies... but only if not drag selecting.
  175. //In fact the only way you can drag select is if the unit is on your team.
  176. if( dragSelecting && !obj->isLocallyControlled() )
  177. {
  178. return FALSE;
  179. }
  180. //Now we can select anything that is selectable.
  181. return TRUE;
  182. } // end canSelect
  183. //-----------------------------------------------------------------------------
  184. static Bool canSelectWrapper( Drawable *draw, void *userData )
  185. {
  186. Bool dragSelecting = *((Bool *)userData);
  187. return CanSelectDrawable( draw, dragSelecting );
  188. }
  189. //-----------------------------------------------------------------------------
  190. /**
  191. * Deselect all drawables, and emit a "TEAM_DESTROY" message, since
  192. * the "team" was the group of currently selected units.
  193. */
  194. static void deselectAll()
  195. {
  196. // deselect it all
  197. TheInGameUI->deselectAllDrawables();
  198. }
  199. //-----------------------------------------------------------------------------
  200. /**
  201. * Select the given drawable, without playing its sound.
  202. * Returns true.
  203. */
  204. static Bool selectSingleDrawableWithoutSound( Drawable *draw )
  205. {
  206. // since we are single selecting a drawable, unselect everything else
  207. deselectAll();
  208. // do the drawble selection
  209. TheInGameUI->selectDrawable( draw );
  210. Object *obj = draw->getObject();
  211. if (obj != NULL) {
  212. GameMessage *msg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP_NO_SOUND);
  213. msg->appendBooleanArgument(TRUE);
  214. msg->appendObjectIDArgument(obj->getID());
  215. }
  216. return true;
  217. }
  218. SelectionTranslator *TheSelectionTranslator = NULL;
  219. //-----------------------------------------------------------------------------
  220. //-----------------------------------------------------------------------------
  221. //-----------------------------------------------------------------------------
  222. //-----------------------------------------------------------------------------
  223. SelectionTranslator::SelectionTranslator()
  224. {
  225. m_leftMouseButtonIsDown = FALSE;
  226. m_dragSelecting = FALSE;
  227. m_lastGroupSelTime = 0;
  228. m_lastGroupSelGroup = -1;
  229. m_selectFeedbackAnchor.x = 0;
  230. m_selectFeedbackAnchor.y = 0;
  231. m_deselectFeedbackAnchor.x = 0;
  232. m_deselectFeedbackAnchor.y = 0;
  233. m_lastClick = 0;
  234. //Added By Sadullah Nader
  235. //Initializtion(s) inserted
  236. m_deselectDownCameraPosition.zero();
  237. m_displayedMaxWarning = FALSE;
  238. //
  239. m_selectCountMap.clear();
  240. TheSelectionTranslator = this;
  241. }
  242. //-----------------------------------------------------------------------------
  243. SelectionTranslator::~SelectionTranslator()
  244. {
  245. }
  246. //-----------------------------------------------------------------------------
  247. /**
  248. * If this drawable is a 'friend' of mine, select it.
  249. */
  250. Bool SelectionTranslator::selectFriends( Drawable *draw, GameMessage *createTeamMsg,
  251. Bool dragSelecting )
  252. {
  253. if (CanSelectDrawable( draw, dragSelecting ))
  254. {
  255. // enforce an optional selection size limit
  256. if (TheInGameUI->getMaxSelectCount() > 0 && TheInGameUI->getSelectCount() >= TheInGameUI->getMaxSelectCount())
  257. {
  258. if (!m_displayedMaxWarning)
  259. {
  260. m_displayedMaxWarning = TRUE;
  261. UnicodeString msg;
  262. msg.format(TheGameText->fetch("GUI:MaxSelectionSize").str(), TheInGameUI->getMaxSelectCount());
  263. TheInGameUI->message(msg);
  264. }
  265. return false;
  266. }
  267. TheInGameUI->selectDrawable( draw );
  268. m_selectCountMap[draw->getTemplate()]++;
  269. // add to message's argument list if an object is present
  270. if( draw->getObject() && createTeamMsg )
  271. createTeamMsg->appendObjectIDArgument( draw->getObject()->getID() );
  272. return true; // selected
  273. } // end if
  274. return false; // not selected
  275. } // end selectFriends
  276. //-----------------------------------------------------------------------------
  277. Bool SelectionTranslator::killThemKillThemAll( Drawable *draw, GameMessage *killThemAllMsg )
  278. {
  279. if( draw )
  280. {
  281. Object *obj = draw->getObject();
  282. if( obj )
  283. {
  284. // enforce an optional selection size limit
  285. if (TheInGameUI->getMaxSelectCount() > 0 && TheInGameUI->getSelectCount() >= TheInGameUI->getMaxSelectCount())
  286. {
  287. if (!m_displayedMaxWarning)
  288. {
  289. m_displayedMaxWarning = TRUE;
  290. UnicodeString msg;
  291. msg.format(TheGameText->fetch("GUI:MaxSelectionSize").str(), TheInGameUI->getMaxSelectCount());
  292. TheInGameUI->message(msg);
  293. }
  294. return false;
  295. }
  296. // add to message's argument list if an object is present
  297. if( killThemAllMsg )
  298. {
  299. killThemAllMsg->appendObjectIDArgument( draw->getObject()->getID() );
  300. }
  301. return true; // selected
  302. }
  303. }
  304. return false;
  305. } // end selectFriends
  306. //-----------------------------------------------------------------------------
  307. /**
  308. * The SelectionTranslator is responsible for all selection semantics,
  309. * including click selection, area drag selection, right-click de-selection,
  310. * and CTRL-key group selection.
  311. * NOTE: This handler changes the event semantics for mouse buttons from
  312. * LEFT_DOWN -> LEFT_UP to LEFT_DOWN -> { LEFT_UP, AREA_SELECTION, or DRAWABLE_PICKED }
  313. */
  314. GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessage *msg)
  315. {
  316. GameMessageDisposition disp = KEEP_MESSAGE;
  317. if( !TheInGameUI->getInputEnabled() )
  318. {
  319. //Keep the message so the other translaters (WindowXlat) can handle.
  320. if( m_dragSelecting )
  321. {
  322. //Turn off drag select
  323. m_dragSelecting = FALSE;
  324. TheInGameUI->setSelecting( FALSE );
  325. TheInGameUI->endAreaSelectHint(NULL);
  326. TheTacticalView->setMouseLock( FALSE );
  327. }
  328. return KEEP_MESSAGE;
  329. }
  330. GameMessage::Type t = msg->getType();
  331. switch (t)
  332. {
  333. case GameMessage::MSG_META_BEGIN_FORCEATTACK:
  334. TheInGameUI->setForceAttackMode( true );
  335. break;
  336. case GameMessage::MSG_META_END_FORCEATTACK:
  337. TheInGameUI->setForceAttackMode( false );
  338. break;
  339. //-----------------------------------------------------------------------------
  340. case GameMessage::MSG_RAW_MOUSE_POSITION:
  341. {
  342. ICoord2D pixel;
  343. pixel = msg->getArgument( 0 )->pixel;
  344. // modifier appears to be unused, and the argument doesn't exist. jba.
  345. //Int modifier = msg->getArgument( 1 )->integer;
  346. if (m_leftMouseButtonIsDown)
  347. {
  348. ICoord2D delta;
  349. delta.x = abs(pixel.x - m_selectFeedbackAnchor.x);
  350. delta.y = abs(pixel.y - m_selectFeedbackAnchor.y);
  351. // if mouse has moved while left button is down, begin drag selection
  352. if (delta.x > TheMouse->m_dragTolerance || delta.y > TheMouse->m_dragTolerance)
  353. {
  354. if (m_dragSelecting == false)
  355. {
  356. m_dragSelecting = true;
  357. TheTacticalView->setMouseLock( TRUE );
  358. TheInGameUI->setSelecting( TRUE );
  359. }
  360. }
  361. // create "hint" messages defining selection region under construction
  362. if (m_dragSelecting)
  363. {
  364. // insert area selection "hint" message into stream
  365. GameMessage *hintMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION_HINT );
  366. // build rectangular region defined by the drag selection
  367. IRegion2D pixelRegion;
  368. buildRegion( &m_selectFeedbackAnchor, &pixel, &pixelRegion );
  369. hintMsg->appendPixelRegionArgument( pixelRegion );
  370. }
  371. }
  372. else //left button is not down (not drag select)
  373. {
  374. // insert Mouseover hint into stream for CommandTranslator and HintSpy to see.
  375. GameMessage *mouseoverMessage;
  376. //Kris: We want to show information such as the popup text on objects that are forceattackable even
  377. // when we're not in force attackable mode!
  378. UnsignedInt pickType = getPickTypesForContext( true /*TheInGameUI->isInForceAttackMode()*/ );
  379. Drawable *underCursor = TheTacticalView->pickDrawable( &pixel, TheInGameUI->isInForceAttackMode(), (PickType) pickType );
  380. Object *objUnderCursor = underCursor ? underCursor->getObject() : NULL;
  381. if( objUnderCursor && (!objUnderCursor->isEffectivelyDead() || objUnderCursor->isKindOf( KINDOF_ALWAYS_SELECTABLE )) )
  382. {
  383. mouseoverMessage = TheMessageStream->appendMessage( GameMessage::MSG_MOUSEOVER_DRAWABLE_HINT );
  384. mouseoverMessage->appendDrawableIDArgument( underCursor->getID() );
  385. }
  386. else// else this is a mouseover terrain
  387. {
  388. Coord3D position;
  389. TheTacticalView->screenToTerrain( &pixel, &position );
  390. mouseoverMessage = TheMessageStream->appendMessage( GameMessage::MSG_MOUSEOVER_LOCATION_HINT );
  391. mouseoverMessage->appendLocationArgument( position );
  392. }
  393. }
  394. break;
  395. }
  396. //-----------------------------------------------------------------------------
  397. case GameMessage::MSG_MOUSE_LEFT_DOUBLE_CLICK:
  398. {
  399. Int modifiers = msg->getArgument(1)->integer;
  400. // Pressing ctrl is disallowed for double clicking
  401. if (TheInGameUI->isInForceAttackMode())
  402. break;
  403. const IRegion2D& region = msg->getArgument(0)->pixelRegion;
  404. // Single point. If there's a unit in there, double click will select all of them.
  405. if (region.height() == 0 && region.width() == 0)
  406. {
  407. Bool selectAcrossMap = (BitTest(modifiers, KEY_STATE_ALT) ? TRUE : FALSE);
  408. // only allow things that are selectable. Also, we aren't allowed to
  409. Drawable *picked = TheTacticalView->pickDrawable( &region.lo, FALSE, PICK_TYPE_SELECTABLE);
  410. // If there wasn't anyone to pick, then we want to propagate this double click.
  411. if (picked == NULL)
  412. break;
  413. if (!picked->isMassSelectable())
  414. break;
  415. Object *pickedObj = picked->getObject();
  416. // We have to have an object in order to be able to do interesting double click stuff on
  417. // him. Also, if it is a structure, it is already selected, so don't select all the units
  418. // like him.
  419. if (pickedObj == NULL || !pickedObj->isLocallyControlled())
  420. break;
  421. // Ok. The logic is a little bit weird here. What we need to do is deselect everything
  422. // except for this one picked thing. Store off the old selection, pick the single clicked thing.
  423. // Then if
  424. DrawableList listOfSelectedDrawables;
  425. if (TheInGameUI->isInPreferSelectionMode()) {
  426. listOfSelectedDrawables = *TheInGameUI->getAllSelectedDrawables();
  427. }
  428. // Pick just that one guy.
  429. selectSingleDrawableWithoutSound(picked);
  430. // Yay. Either select across the screen or the world depending on selectAcrossMap
  431. if (selectAcrossMap)
  432. TheInGameUI->selectAcrossMap();
  433. else
  434. TheInGameUI->selectAcrossScreen();
  435. // emit "picked" message
  436. GameMessage *pickMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION );
  437. pickMsg->appendDrawableIDArgument( picked->getID() ); /// note we are putting in a drawable id
  438. if (TheInGameUI->isInPreferSelectionMode() && !listOfSelectedDrawables.empty()) {
  439. GameMessage *selectMore = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP_NO_SOUND );
  440. selectMore->appendBooleanArgument(FALSE);
  441. for (DrawableListIt it = listOfSelectedDrawables.begin(); it != listOfSelectedDrawables.end(); ++it) {
  442. Drawable *draw = *it;
  443. if (draw && draw->isSelectable()) {
  444. TheInGameUI->selectDrawable(draw);
  445. selectMore->appendObjectIDArgument(draw->getObject()->getID());
  446. }
  447. }
  448. }
  449. disp = DESTROY_MESSAGE;
  450. }
  451. break;
  452. }
  453. //-----------------------------------------------------------------------------
  454. case GameMessage::MSG_MOUSEOVER_DRAWABLE_HINT:
  455. {
  456. if (TheInGameUI->isScrolling()) {
  457. // dont show this now.
  458. break;
  459. }
  460. DrawableID id = msg->getArgument(0)->drawableID;
  461. Drawable *draw = TheGameClient->findDrawableByID(id);
  462. if (!draw) {
  463. break;
  464. }
  465. GameMessage::Type msgType = TheGameClient->evaluateContextCommand(draw, draw->getPosition(), CommandTranslator::EVALUATE_ONLY);
  466. if( msgType == GameMessage::MSG_INVALID )
  467. {
  468. TheInGameUI->createMouseoverHint(msg); // this sets the cursor
  469. disp = DESTROY_MESSAGE;
  470. const CommandButton *command = TheInGameUI->getGUICommand();
  471. Bool ignoreCommand = FALSE;
  472. if( command )
  473. {
  474. if( command->getCommandType() == GUI_COMMAND_ATTACK_MOVE ||
  475. command->getCommandType() == GUI_COMMAND_GUARD ||
  476. command->getCommandType() == GUI_COMMAND_GUARD_WITHOUT_PURSUIT ||
  477. command->getCommandType() == GUI_COMMAND_GUARD_FLYING_UNITS_ONLY )
  478. {
  479. //These GUI commands can take care of themselves -- don't let
  480. //the selection translator meddle.
  481. ignoreCommand = TRUE;
  482. }
  483. }
  484. if( !ignoreCommand && !draw->getTemplate()->isKindOf( KINDOF_SHRUBBERY ) )
  485. {
  486. if( CanSelectDrawable( draw, FALSE ) )
  487. {
  488. TheMouse->setCursor(Mouse::SELECTING);
  489. }
  490. else
  491. {
  492. TheMouse->setCursor( Mouse::ARROW );
  493. }
  494. }
  495. }
  496. break;
  497. }
  498. //-----------------------------------------------------------------------------
  499. case GameMessage::MSG_MOUSE_LEFT_CLICK:
  500. {
  501. // If the quit menu is visible, we need to not process left clicks through the selection translator.
  502. if (TheInGameUI->isQuitMenuVisible())
  503. {
  504. disp = DESTROY_MESSAGE;
  505. break;
  506. }
  507. // Basically, we need to first determine if there are any drawables in the region of interest.
  508. // If there aren't then this click should move forward.
  509. IRegion2D selectionRegion = msg->getArgument(0)->pixelRegion;
  510. Bool isPoint = (selectionRegion.height() == 0 && selectionRegion.width() == 0);
  511. DrawableList drawablesThatWillSelect;
  512. PickDrawableStruct pds;
  513. pds.drawableListToFill = &drawablesThatWillSelect;
  514. TheTacticalView->iterateDrawablesInRegion(&selectionRegion, addDrawableToList, &pds);
  515. if (drawablesThatWillSelect.empty())
  516. {
  517. break;
  518. }
  519. // if there were drawables in the region, then we should determine if there is a context
  520. // sensitive command that should take place. If there is, then this isn't a selection thing
  521. const DrawableList *currentList = TheInGameUI->getAllSelectedDrawables();
  522. if (!currentlyLookingForSelection())
  523. {
  524. break;
  525. }
  526. SelectionInfo si;
  527. if (contextCommandForNewSelection(currentList, &drawablesThatWillSelect, &si, isPoint))
  528. {
  529. break;
  530. }
  531. // There isn't a context command, so this is a selection thing. Now, based on the keys,
  532. // determine whether or not we should create a new group, or append these guys to our existing
  533. // group.
  534. Bool addToGroup = TheInGameUI->isInPreferSelectionMode();
  535. if (si.currentCountEnemies > 0 ||
  536. si.currentCountCivilians > 0 ||
  537. si.currentCountFriends > 0 ||
  538. si.currentCountMineBuildings > 0)
  539. {
  540. // force a new group creation
  541. addToGroup = FALSE;
  542. }
  543. // If there are any of my units, then select those.
  544. if (si.newCountMine > 0)
  545. {
  546. si.selectMine = TRUE;
  547. if (si.newCountMine == 1 && si.newCountMineBuildings == 1)
  548. {
  549. addToGroup = FALSE;
  550. si.selectMineBuildings = TRUE;
  551. }
  552. }
  553. else if (si.newCountEnemies > 0 && si.newCountCivilians > 0 && si.newCountFriends > 0)
  554. {
  555. // No go here
  556. break;
  557. }
  558. else if (si.newCountEnemies == 1)
  559. {
  560. addToGroup = FALSE;
  561. si.selectEnemies = TRUE;
  562. }
  563. else if (si.newCountCivilians == 1)
  564. {
  565. addToGroup = FALSE;
  566. si.selectCivilians = TRUE;
  567. }
  568. else if (si.newCountFriends == 1)
  569. {
  570. addToGroup = FALSE;
  571. si.selectFriends = TRUE;
  572. }
  573. // If we're not going to select anything, just bail now.
  574. if (!(si.selectMine || si.selectEnemies || si.selectCivilians || si.selectFriends))
  575. {
  576. break;
  577. }
  578. // If we've made it here, its time to do some selecting.
  579. disp = DESTROY_MESSAGE;
  580. // Whenever we manually select something, reset the last selected group.
  581. m_lastGroupSelGroup = -1;
  582. if (TheInGameUI->isInPreferSelectionMode() && isPoint && areAllSelected(drawablesThatWillSelect))
  583. {
  584. // If this was a point, shift was pressed and we already have that unit selected, then we
  585. // need to deselect those units.
  586. GameMessage *newMsg = TheMessageStream->appendMessage(GameMessage::MSG_REMOVE_FROM_SELECTED_GROUP);
  587. Drawable *draw = NULL;
  588. DrawableListIt it;
  589. for (it = drawablesThatWillSelect.begin(); it != drawablesThatWillSelect.end(); ++it)
  590. {
  591. draw = *it;
  592. if (!draw)
  593. {
  594. continue;
  595. }
  596. Object *objToDeselect = draw->getObject();
  597. if (!objToDeselect)
  598. {
  599. continue;
  600. }
  601. newMsg->appendObjectIDArgument(objToDeselect->getID());
  602. TheInGameUI->deselectDrawable(draw);
  603. }
  604. }
  605. else
  606. {
  607. if (!addToGroup)
  608. {
  609. deselectAll();
  610. }
  611. GameMessage *newMsg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP);
  612. newMsg->appendBooleanArgument(!addToGroup);
  613. Player *localPlayer = ThePlayerList->getLocalPlayer();
  614. Int newDrawablesSelected = 0;
  615. Drawable *draw = NULL;
  616. DrawableListIt it;
  617. for (it = drawablesThatWillSelect.begin(); it != drawablesThatWillSelect.end(); ++it)
  618. {
  619. draw = *it;
  620. if (!draw)
  621. {
  622. continue;
  623. }
  624. Object *obj = draw->getObject();
  625. if (!obj)
  626. {
  627. continue;
  628. }
  629. if (obj && obj->getContainedBy() != NULL)
  630. {
  631. // we're contained, and so we shouldn't be selectable.
  632. continue;
  633. }
  634. Drawable *drawToSelect = NULL;
  635. ObjectID objToAppend = INVALID_ID;
  636. if (si.selectMine && obj->isLocallyControlled())
  637. {
  638. if (!obj->isKindOf(KINDOF_STRUCTURE) || si.selectMineBuildings)
  639. {
  640. drawToSelect = draw;
  641. objToAppend = obj->getID();
  642. }
  643. }
  644. else
  645. {
  646. Relationship rel = localPlayer->getRelationship(obj->getTeam());
  647. if (si.selectEnemies && rel == ENEMIES)
  648. {
  649. drawToSelect = draw;
  650. objToAppend = obj->getID();
  651. }
  652. else if (si.selectCivilians && rel == NEUTRAL)
  653. {
  654. drawToSelect = draw;
  655. objToAppend = obj->getID();
  656. }
  657. else if (si.selectFriends && rel == ALLIES)
  658. {
  659. drawToSelect = draw;
  660. objToAppend = obj->getID();
  661. }
  662. }
  663. if (drawToSelect && objToAppend != INVALID_ID)
  664. {
  665. newMsg->appendObjectIDArgument(objToAppend);
  666. TheInGameUI->selectDrawable(drawToSelect);
  667. ++newDrawablesSelected;
  668. }
  669. }
  670. if (newDrawablesSelected == 1 && draw)
  671. {
  672. #if defined(_DEBUG) || defined(_INTERNAL)
  673. if (TheHandOfGodSelectionMode && draw)
  674. {
  675. Object* obj = draw->getObject();
  676. if (obj)
  677. {
  678. TheAudio->addAudioEvent(&TheAudio->getMiscAudio()->m_noCanDoSound);
  679. GameMessage* msg = TheMessageStream->appendMessage( GameMessage::MSG_DEBUG_KILL_OBJECT );
  680. msg->appendObjectIDArgument(obj->getID());
  681. }
  682. disp = DESTROY_MESSAGE;
  683. break;
  684. }
  685. else if (TheHurtSelectionMode && draw)
  686. {
  687. Object* obj = draw->getObject();
  688. if (obj)
  689. {
  690. TheAudio->addAudioEvent(&TheAudio->getMiscAudio()->m_noCanDoSound);
  691. GameMessage* msg = TheMessageStream->appendMessage( GameMessage::MSG_DEBUG_HURT_OBJECT );
  692. msg->appendObjectIDArgument(obj->getID());
  693. }
  694. disp = DESTROY_MESSAGE;
  695. break;
  696. }
  697. #ifdef DEBUG_OBJECT_ID_EXISTS
  698. if (TheDebugSelectionMode && draw && draw->getObject())
  699. {
  700. if (TheObjectIDToDebug == 0)
  701. {
  702. TheObjectIDToDebug = draw->getObject()->getID();
  703. AsciiString msg;
  704. msg.format("Item %s %08x selected for debugging",draw->getTemplate()->getName().str(),TheObjectIDToDebug);
  705. UnicodeString msgu;
  706. msgu.translate(msg);
  707. TheInGameUI->message(msgu);
  708. disp = DESTROY_MESSAGE;
  709. break;
  710. }
  711. }
  712. #endif
  713. #endif
  714. }
  715. }
  716. if (disp == DESTROY_MESSAGE)
  717. TheInGameUI->clearAttackMoveToMode();
  718. break;
  719. }
  720. //-----------------------------------------------------------------------------
  721. // Note that the raw left messages are only used to draw feedback now when
  722. // appropriate. All actual selection code takes place in
  723. // MSG_MOUSE_LEFT_CLICK & MSG_MOUSE_LEFT_DOUBLE_CLICK
  724. case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:
  725. {
  726. // cannot actually start area selection yet - have to wait for cursor to move a bit
  727. m_leftMouseButtonIsDown = true;
  728. m_selectFeedbackAnchor = msg->getArgument( 0 )->pixel;
  729. break;
  730. }
  731. //-----------------------------------------------------------------------------
  732. // Note that the raw left messages are only used to draw feedback now when
  733. // appropriate. All actual selection code takes place in
  734. // MSG_MOUSE_LEFT_CLICK & MSG_MOUSE_LEFT_DOUBLE_CLICK
  735. case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP:
  736. {
  737. m_leftMouseButtonIsDown = FALSE;
  738. if (m_dragSelecting) {
  739. // Stop drag selecting now, thanks.
  740. m_dragSelecting = FALSE;
  741. TheTacticalView->setMouseLock( FALSE );
  742. TheInGameUI->setSelecting( FALSE );
  743. TheInGameUI->endAreaSelectHint(NULL);
  744. // insert area selection message into stream
  745. GameMessage *dragMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION );
  746. IRegion2D selectionRegion;
  747. buildRegion( &m_selectFeedbackAnchor, &msg->getArgument(0)->pixel, &selectionRegion );
  748. dragMsg->appendPixelRegionArgument( selectionRegion );
  749. }
  750. break;
  751. }
  752. //-----------------------------------------------------------------------------
  753. case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN:
  754. {
  755. // There are three ways in which we can ignore this as a deselect:
  756. // 1) 2-D position on screen
  757. // 2) Time has exceeded the time which we allow for this to be a click.
  758. // 3) 3-D camera position has changed
  759. m_deselectFeedbackAnchor = msg->getArgument( 0 )->pixel;
  760. m_lastClick = (UnsignedInt) msg->getArgument( 2 )->integer;
  761. TheTacticalView->getPosition(&m_deselectDownCameraPosition);
  762. break;
  763. }
  764. //-----------------------------------------------------------------------------
  765. case GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP:
  766. {
  767. ICoord2D delta, pixel;
  768. UnsignedInt currentTime;
  769. Coord3D cameraPos;
  770. TheTacticalView->getPosition(&cameraPos);
  771. cameraPos.sub(&m_deselectDownCameraPosition);
  772. pixel = msg->getArgument( 0 )->pixel;
  773. currentTime = (UnsignedInt) msg->getArgument( 2 )->integer;
  774. delta.x = m_deselectFeedbackAnchor.x - pixel.x;
  775. delta.y = m_deselectFeedbackAnchor.y - pixel.y;
  776. Bool isClick = TRUE;
  777. if (isClick &&
  778. abs(delta.x) > TheMouse->m_dragTolerance ||
  779. abs(delta.y) > TheMouse->m_dragTolerance)
  780. {
  781. isClick = FALSE;
  782. }
  783. if (isClick &&
  784. currentTime - m_lastClick > TheMouse->m_dragToleranceMS)
  785. {
  786. isClick = FALSE;
  787. }
  788. if (isClick &&
  789. cameraPos.length() > TheMouse->m_dragTolerance3D)
  790. {
  791. isClick = FALSE;
  792. }
  793. // right click behavior (not right drag)
  794. if (isClick)
  795. {
  796. //Added support to cancel the GUI command without deselecting the unit(s) involved
  797. //when you right click.
  798. if( TheInGameUI->getGUICommand() )
  799. {
  800. //Cancel GUI command mode... don't deselect units.
  801. TheInGameUI->setGUICommand( NULL );
  802. //With a GUI command cancel, we want no other behavior.
  803. disp = DESTROY_MESSAGE;
  804. TheInGameUI->setScrolling( FALSE );
  805. }
  806. else
  807. {
  808. //No GUI command mode, so deselect everyone if we're in regular mouse mode.
  809. //In alternate mouse mode, right click still cancels building placement.
  810. if (! TheGlobalData->m_useAlternateMouse || TheInGameUI->getPendingPlaceSourceObjectID() != INVALID_ID)
  811. {
  812. deselectAll();
  813. }
  814. }
  815. }
  816. break;
  817. }
  818. //-----------------------------------------------------------------------------
  819. case GameMessage::MSG_META_CREATE_TEAM0:
  820. case GameMessage::MSG_META_CREATE_TEAM1:
  821. case GameMessage::MSG_META_CREATE_TEAM2:
  822. case GameMessage::MSG_META_CREATE_TEAM3:
  823. case GameMessage::MSG_META_CREATE_TEAM4:
  824. case GameMessage::MSG_META_CREATE_TEAM5:
  825. case GameMessage::MSG_META_CREATE_TEAM6:
  826. case GameMessage::MSG_META_CREATE_TEAM7:
  827. case GameMessage::MSG_META_CREATE_TEAM8:
  828. case GameMessage::MSG_META_CREATE_TEAM9:
  829. {
  830. Int group = t - GameMessage::MSG_META_CREATE_TEAM0;
  831. if ( group >= 0 && group < 10 )
  832. {
  833. DEBUG_LOG(("META: create team %d\n",group));
  834. // Assign selected items to a group
  835. GameMessage *newmsg = TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_CREATE_TEAM0 + group));
  836. Drawable *drawable = TheGameClient->getDrawableList();
  837. while (drawable != NULL)
  838. {
  839. if (drawable->isSelected() && drawable->getObject() && drawable->getObject()->isLocallyControlled())
  840. {
  841. newmsg->appendObjectIDArgument(drawable->getObject()->getID());
  842. }
  843. drawable = drawable->getNextDrawable();
  844. }
  845. }
  846. disp = DESTROY_MESSAGE;
  847. break;
  848. }
  849. //-----------------------------------------------------------------------------
  850. case GameMessage::MSG_META_SELECT_TEAM0:
  851. case GameMessage::MSG_META_SELECT_TEAM1:
  852. case GameMessage::MSG_META_SELECT_TEAM2:
  853. case GameMessage::MSG_META_SELECT_TEAM3:
  854. case GameMessage::MSG_META_SELECT_TEAM4:
  855. case GameMessage::MSG_META_SELECT_TEAM5:
  856. case GameMessage::MSG_META_SELECT_TEAM6:
  857. case GameMessage::MSG_META_SELECT_TEAM7:
  858. case GameMessage::MSG_META_SELECT_TEAM8:
  859. case GameMessage::MSG_META_SELECT_TEAM9:
  860. {
  861. Int group = t - GameMessage::MSG_META_SELECT_TEAM0;
  862. if ( group >= 0 && group < 10 )
  863. {
  864. DEBUG_LOG(("META: select team %d\n",group));
  865. UnsignedInt now = TheGameLogic->getFrame();
  866. if ( m_lastGroupSelTime == 0 )
  867. {
  868. m_lastGroupSelTime = now;
  869. }
  870. // check for double-press to jump view
  871. if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )
  872. {
  873. DEBUG_LOG(("META: DOUBLETAP select team %d\n",group));
  874. Player *player = ThePlayerList->getLocalPlayer();
  875. if (player)
  876. {
  877. Squad *selectedSquad = player->getHotkeySquad(group);
  878. if (selectedSquad != NULL)
  879. {
  880. VecObjectPtr objlist = selectedSquad->getLiveObjects();
  881. Int numObjs = objlist.size();
  882. if (numObjs > 0)
  883. {
  884. // if theres someone in the group, center the camera on them.
  885. TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );
  886. }
  887. }
  888. }
  889. }
  890. else
  891. {
  892. TheInGameUI->deselectAllDrawables( false ); //No need to post message because we're just creating a new group!
  893. // no need to send two messages for selecting the same group.
  894. TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_SELECT_TEAM0 + group));
  895. Player *player = ThePlayerList->getLocalPlayer();
  896. if (player)
  897. {
  898. Squad *selectedSquad = player->getHotkeySquad(group);
  899. if (selectedSquad != NULL)
  900. {
  901. VecObjectPtr objlist = selectedSquad->getLiveObjects();
  902. Int numObjs = objlist.size();
  903. for (Int i = 0; i < numObjs; ++i)
  904. {
  905. if( objlist[i]->getControllingPlayer() == player )
  906. {
  907. TheInGameUI->selectDrawable(objlist[i]->getDrawable());
  908. }
  909. }
  910. }
  911. }
  912. }
  913. m_lastGroupSelTime = now;
  914. m_lastGroupSelGroup = group;
  915. }
  916. disp = DESTROY_MESSAGE;
  917. break;
  918. }
  919. case GameMessage::MSG_META_ADD_TEAM0:
  920. case GameMessage::MSG_META_ADD_TEAM1:
  921. case GameMessage::MSG_META_ADD_TEAM2:
  922. case GameMessage::MSG_META_ADD_TEAM3:
  923. case GameMessage::MSG_META_ADD_TEAM4:
  924. case GameMessage::MSG_META_ADD_TEAM5:
  925. case GameMessage::MSG_META_ADD_TEAM6:
  926. case GameMessage::MSG_META_ADD_TEAM7:
  927. case GameMessage::MSG_META_ADD_TEAM8:
  928. case GameMessage::MSG_META_ADD_TEAM9:
  929. {
  930. Int group = t - GameMessage::MSG_META_ADD_TEAM0;
  931. if ( group >= 0 && group < 10 )
  932. {
  933. DEBUG_LOG(("META: select team %d\n",group));
  934. UnsignedInt now = TheGameLogic->getFrame();
  935. if ( m_lastGroupSelTime == 0 )
  936. {
  937. m_lastGroupSelTime = now;
  938. }
  939. // check for double-press to jump view
  940. if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )
  941. {
  942. DEBUG_LOG(("META: DOUBLETAP select team %d\n",group));
  943. Player *player = ThePlayerList->getLocalPlayer();
  944. if (player)
  945. {
  946. Squad *selectedSquad = player->getHotkeySquad(group);
  947. if (selectedSquad != NULL)
  948. {
  949. VecObjectPtr objlist = selectedSquad->getLiveObjects();
  950. Int numObjs = objlist.size();
  951. if (numObjs > 0)
  952. {
  953. // if theres someone in the group, center the camera on them.
  954. TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );
  955. }
  956. }
  957. }
  958. }
  959. else
  960. {
  961. // no need to send two messages for selecting the same group.
  962. TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_ADD_TEAM0 + group));
  963. Player *player = ThePlayerList->getLocalPlayer();
  964. if (player)
  965. {
  966. Squad *selectedSquad = player->getHotkeySquad(group);
  967. if (selectedSquad != NULL)
  968. {
  969. VecObjectPtr objlist = selectedSquad->getLiveObjects();
  970. Int numObjs = objlist.size();
  971. for (Int i = 0; i < numObjs; ++i)
  972. {
  973. TheInGameUI->selectDrawable(objlist[i]->getDrawable());
  974. }
  975. }
  976. }
  977. }
  978. m_lastGroupSelTime = now;
  979. m_lastGroupSelGroup = group;
  980. }
  981. disp = DESTROY_MESSAGE;
  982. break;
  983. }
  984. //-----------------------------------------------------------------------------
  985. case GameMessage::MSG_META_VIEW_TEAM0:
  986. case GameMessage::MSG_META_VIEW_TEAM1:
  987. case GameMessage::MSG_META_VIEW_TEAM2:
  988. case GameMessage::MSG_META_VIEW_TEAM3:
  989. case GameMessage::MSG_META_VIEW_TEAM4:
  990. case GameMessage::MSG_META_VIEW_TEAM5:
  991. case GameMessage::MSG_META_VIEW_TEAM6:
  992. case GameMessage::MSG_META_VIEW_TEAM7:
  993. case GameMessage::MSG_META_VIEW_TEAM8:
  994. case GameMessage::MSG_META_VIEW_TEAM9:
  995. {
  996. Int group = t - GameMessage::MSG_META_VIEW_TEAM0;
  997. if ( group >= 1 && group <= 10 )
  998. {
  999. DEBUG_LOG(("META: view team %d\n",group));
  1000. Player *player = ThePlayerList->getLocalPlayer();
  1001. if (player)
  1002. {
  1003. Squad *selectedSquad = player->getHotkeySquad(group);
  1004. if (selectedSquad != NULL)
  1005. {
  1006. VecObjectPtr objlist = selectedSquad->getLiveObjects();
  1007. Int numObjs = objlist.size();
  1008. if (numObjs > 0)
  1009. {
  1010. // if theres someone in the group, center the camera on them.
  1011. TheTacticalView->lookAt( objlist[ numObjs-1 ]->getDrawable()->getPosition() );
  1012. }
  1013. }
  1014. }
  1015. }
  1016. disp = DESTROY_MESSAGE;
  1017. break;
  1018. }
  1019. //-----------------------------------------------------------------------------------------
  1020. case GameMessage::MSG_META_OPTIONS:
  1021. {
  1022. // stop drawing selection feedback, as we're going to ignore the selection.
  1023. m_leftMouseButtonIsDown = FALSE;
  1024. // let this message drop through, the commandXLat will show the options screen itself.
  1025. break;
  1026. }
  1027. #if defined(_DEBUG) || defined(_INTERNAL)
  1028. //-----------------------------------------------------------------------------------------
  1029. case GameMessage::MSG_META_DEMO_TOGGLE_HAND_OF_GOD_MODE:
  1030. {
  1031. TheHandOfGodSelectionMode = !TheHandOfGodSelectionMode;
  1032. TheInGameUI->message( UnicodeString( L"Hand-Of-God Mode is %s" ), TheHandOfGodSelectionMode ? L"ON" : L"OFF" );
  1033. disp = DESTROY_MESSAGE;
  1034. break;
  1035. }
  1036. #endif
  1037. #if defined(_DEBUG) || defined(_INTERNAL)
  1038. //-----------------------------------------------------------------------------------------
  1039. case GameMessage::MSG_META_DEMO_TOGGLE_HURT_ME_MODE:
  1040. {
  1041. TheHurtSelectionMode = !TheHurtSelectionMode;
  1042. TheInGameUI->message( UnicodeString( L"Hurt-Me Mode is %s" ), TheHurtSelectionMode ? L"ON" : L"OFF" );
  1043. disp = DESTROY_MESSAGE;
  1044. break;
  1045. }
  1046. #endif
  1047. #if defined(_DEBUG) || defined(_INTERNAL)
  1048. //-----------------------------------------------------------------------------------------
  1049. case GameMessage::MSG_META_DEMO_DEBUG_SELECTION:
  1050. {
  1051. TheDebugSelectionMode = !TheDebugSelectionMode;
  1052. TheInGameUI->message( UnicodeString( L"Debug-Selected-Item Mode is %s" ), TheDebugSelectionMode ? L"ON" : L"OFF" );
  1053. #ifdef DEBUG_OBJECT_ID_EXISTS
  1054. TheObjectIDToDebug = INVALID_ID;
  1055. #endif
  1056. disp = DESTROY_MESSAGE;
  1057. break;
  1058. }
  1059. #endif
  1060. }
  1061. return disp;
  1062. }
  1063. //Added By Sadullah Nader
  1064. //setDragSelecting(Bool dragSelect)
  1065. //Added to fix the drag selection problem in control bar
  1066. ////////////////////////////////////////////////////////////////////////
  1067. void SelectionTranslator::setDragSelecting(Bool dragSelect)
  1068. {
  1069. m_dragSelecting = dragSelect;
  1070. }
  1071. //setLeftMouseButton(Bool state)
  1072. //Added to turn of Left button down when left button goes up
  1073. ////////////////////////////////////////////////////////////////////////
  1074. void SelectionTranslator::setLeftMouseButton(Bool state)
  1075. {
  1076. m_leftMouseButtonIsDown = state;
  1077. }