2
0

AdventureMapButton.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. #include "AdventureMapButton.h"
  2. #include "CAdvmapInterface.h"
  3. #include "SDL_Extensions.h"
  4. #include "../hch/CDefHandler.h"
  5. #include "CGameInfo.h"
  6. #include "../hch/CLodHandler.h"
  7. #include "../hch/CGeneralTextHandler.h"
  8. #include "../hch/CTownHandler.h"
  9. #include "../CCallback.h"
  10. #include "CConfigHandler.h"
  11. #include "Graphics.h"
  12. #include "CBattleInterface.h"
  13. #include "CPlayerInterface.h"
  14. #include "CMessage.h"
  15. /*
  16. * AdevntureMapButton.cpp, part of VCMI engine
  17. *
  18. * Authors: listed in file AUTHORS in main folder
  19. *
  20. * License: GNU General Public License v2.0 or later
  21. * Full text of license available in license.txt file, in main folder
  22. *
  23. */
  24. CButtonBase::CButtonBase()
  25. {
  26. bitmapOffset = 0;
  27. curimg=0;
  28. type=-1;
  29. abs=false;
  30. //active=false;
  31. notFreeButton = false;
  32. ourObj=NULL;
  33. state=0;
  34. text = NULL;
  35. }
  36. CButtonBase::~CButtonBase()
  37. {
  38. delete text;
  39. if(notFreeButton)
  40. return;
  41. for(int i =0; i<imgs.size();i++)
  42. for(int j=0;j<imgs[i].size();j++)
  43. SDL_FreeSurface(imgs[i][j]);
  44. }
  45. void CButtonBase::show(SDL_Surface * to)
  46. {
  47. int img = std::min(state+bitmapOffset,int(imgs[curimg].size()-1));
  48. img = std::max(0, img);
  49. if (abs)
  50. {
  51. blitAt(imgs[curimg][img],pos.x,pos.y,to);
  52. if(text)
  53. {//using "state" instead of "state == 1" screwed up hoverable buttons with text
  54. CSDL_Ext::printAt(text->text, text->x + pos.x + (state == 1), text->y + pos.y + (state == 1), text->font, text->color, to);
  55. }
  56. }
  57. else
  58. {
  59. blitAt(imgs[curimg][img],pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
  60. }
  61. }
  62. void CButtonBase::showAll( SDL_Surface * to )
  63. {
  64. show(to);
  65. }
  66. void CButtonBase::addTextOverlay( const std::string Text, EFonts font, SDL_Color color)
  67. {
  68. text = new TextOverlay;
  69. text->text = Text;
  70. const Font *f = graphics->fonts[font];
  71. text->x = pos.w/2 - f->getWidth(Text.c_str())/2;
  72. text->y = pos.h/2 - f->height/2;
  73. text->font = font;
  74. text->color = color;
  75. }
  76. AdventureMapButton::AdventureMapButton ()
  77. {
  78. type=2;
  79. abs=true;
  80. hoverable = false;
  81. //active=false;
  82. ourObj=NULL;
  83. state=0;
  84. blocked = actOnDown = false;
  85. used = LCLICK | RCLICK | HOVER | KEYBOARD;
  86. }
  87. //AdventureMapButton::AdventureMapButton( std::string Name, std::string HelpBox, boost::function<void()> Callback, int x, int y, std::string defName, bool activ, std::vector<std::string> * add, bool playerColoredButton)
  88. //{
  89. // init(Callback, Name, HelpBox, playerColoredButton, defName, add, x, y, activ);
  90. //}
  91. AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName,int key, std::vector<std::string> * add, bool playerColoredButton )
  92. {
  93. std::map<int,std::string> pom;
  94. pom[0] = Name;
  95. init(Callback, pom, HelpBox, playerColoredButton, defName, add, x, y, key);
  96. }
  97. AdventureMapButton::AdventureMapButton( const std::map<int,std::string> &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
  98. {
  99. init(Callback, Name, HelpBox, playerColoredButton, defName, add, x, y, key);
  100. }
  101. AdventureMapButton::AdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key/*=0*/ )
  102. {
  103. std::map<int,std::string> pom;
  104. pom[0] = Name;
  105. init(Callback, pom, HelpBox, info->playerColoured, info->defName, &info->additionalDefs, info->x, info->y, key);
  106. }
  107. AdventureMapButton::AdventureMapButton( const std::pair<std::string, std::string> help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
  108. {
  109. std::map<int,std::string> pom;
  110. pom[0] = help.first;
  111. init(Callback, pom, help.second, playerColoredButton, defName, add, x, y, key);
  112. }
  113. void AdventureMapButton::clickLeft(tribool down, bool previousState)
  114. {
  115. if(blocked)
  116. return;
  117. if (down)
  118. {
  119. CGI->soundh->playSound(soundBase::button);
  120. state = 1;
  121. }
  122. else if(hoverable && hovered)
  123. state = 3;
  124. else
  125. state = 0;
  126. show(screenBuf);
  127. if (actOnDown && down)
  128. {
  129. callback();
  130. }
  131. else if (!actOnDown && previousState && (down==false))
  132. {
  133. callback();
  134. }
  135. }
  136. void AdventureMapButton::clickRight(tribool down, bool previousState)
  137. {
  138. if(down && helpBox.size()) //there is no point to show window with nothing inside...
  139. CRClickPopup::createAndPush(helpBox);
  140. }
  141. void AdventureMapButton::hover (bool on)
  142. {
  143. if(hoverable)
  144. {
  145. if(on)
  146. state = 3;
  147. else
  148. state = 0;
  149. }
  150. if(pressedL)
  151. {
  152. if(on)
  153. state = 1;
  154. else
  155. state = hoverable ? 3 : 0;
  156. }
  157. ////Hoverable::hover(on);
  158. std::string *name = (vstd::contains(hoverTexts,state))
  159. ? (&hoverTexts[state])
  160. : (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : NULL);
  161. if(name && name->size() && blocked!=1) //if there is no name, there is nohing to display also
  162. {
  163. if (LOCPLINT && LOCPLINT->battleInt) //for battle buttons
  164. {
  165. if(on && LOCPLINT->battleInt->console->alterTxt == "")
  166. {
  167. LOCPLINT->battleInt->console->alterTxt = *name;
  168. LOCPLINT->battleInt->console->whoSetAlter = 1;
  169. }
  170. else if (LOCPLINT->battleInt->console->alterTxt == *name)
  171. {
  172. LOCPLINT->battleInt->console->alterTxt = "";
  173. LOCPLINT->battleInt->console->whoSetAlter = 0;
  174. }
  175. }
  176. else if(GH.statusbar) //for other buttons
  177. {
  178. if (on)
  179. GH.statusbar->print(*name);
  180. else if ( GH.statusbar->getCurrent()==(*name) )
  181. GH.statusbar->clear();
  182. }
  183. }
  184. }
  185. void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
  186. {
  187. used = LCLICK | RCLICK | HOVER | KEYBOARD;
  188. callback = Callback;
  189. blocked = actOnDown = false;
  190. type=2;
  191. abs=true;
  192. hoverable = false;
  193. //active=false;
  194. ourObj=NULL;
  195. assignedKeys.insert(key);
  196. state=0;
  197. hoverTexts = Name;
  198. helpBox=HelpBox;
  199. setDef(defName, playerColoredButton);
  200. if (add && add->size())
  201. {
  202. imgs.resize(imgs.size()+add->size());
  203. for (size_t i=0; i<add->size();i++)
  204. {
  205. CDefHandler *temp = CDefHandler::giveDef((*add)[i]);
  206. temp->notFreeImgs = true;
  207. for (size_t j=0;j<temp->ourImages.size();j++)
  208. {
  209. imgs[i+1].push_back(temp->ourImages[j].bitmap);
  210. if(playerColoredButton)
  211. {
  212. graphics->blueToPlayersAdv(imgs[1+i][j],LOCPLINT->playerID);
  213. }
  214. }
  215. delete temp;
  216. }
  217. //delete add;
  218. }
  219. pos.x += x;
  220. pos.y += y;
  221. pos.w = imgs[curimg][0]->w;
  222. pos.h = imgs[curimg][0]->h -1;
  223. }
  224. void AdventureMapButton::block( ui8 on )
  225. {
  226. blocked = on;
  227. state = 0;
  228. bitmapOffset = on ? 2 : 0;
  229. show(screenBuf);
  230. }
  231. void AdventureMapButton::setDef(const std::string & defName, bool playerColoredButton)
  232. {
  233. CDefHandler * temp = CDefHandler::giveDef(defName);
  234. temp->notFreeImgs = true;
  235. for (size_t i=0;i<temp->ourImages.size();i++)
  236. {
  237. imgs.resize(1);
  238. imgs[0].push_back(temp->ourImages[i].bitmap);
  239. if(playerColoredButton)
  240. {
  241. graphics->blueToPlayersAdv(imgs[curimg][i],LOCPLINT->playerID);
  242. }
  243. }
  244. delete temp;
  245. }
  246. void AdventureMapButton::setPlayerColor(int player)
  247. {
  248. for(int i =0; i<imgs.size();i++)
  249. for(int j=0;j<imgs[i].size();j++)
  250. graphics->blueToPlayersAdv(imgs[i][j],player);
  251. }
  252. void CHighlightableButton::select(bool on)
  253. {
  254. selected = on;
  255. state = selected ? 3 : 0;
  256. if(selected)
  257. callback();
  258. else
  259. callback2();
  260. if(hoverTexts.size()>1)
  261. {
  262. hover(false);
  263. hover(true);
  264. }
  265. }
  266. void CHighlightableButton::clickLeft(tribool down, bool previousState)
  267. {
  268. if(blocked)
  269. return;
  270. if (down)
  271. {
  272. CGI->soundh->playSound(soundBase::button);
  273. state = 1;
  274. }
  275. else
  276. state = selected ? 3 : 0;
  277. show(screenBuf);
  278. if(previousState && down == false)
  279. {
  280. if(!onlyOn || !selected)
  281. select(!selected);
  282. }
  283. }
  284. CHighlightableButton::CHighlightableButton( const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
  285. : onlyOn(false), selected(false), callback2(onDeselect)
  286. {
  287. init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,key);
  288. }
  289. CHighlightableButton::CHighlightableButton( const std::pair<std::string, std::string> help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
  290. : onlyOn(false), selected(false) // TODO: callback2(???)
  291. {
  292. ID = myid;
  293. std::map<int,std::string> pom;
  294. pom[0] = help.first;
  295. init(onSelect, pom, help.second, playerColoredButton, defName, add, x, y, key);
  296. }
  297. CHighlightableButton::CHighlightableButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
  298. : onlyOn(false), selected(false) // TODO: callback2(???)
  299. {
  300. ID = myid;
  301. std::map<int,std::string> pom;
  302. pom[0] = Name;
  303. init(onSelect, pom,HelpBox, playerColoredButton, defName, add, x, y, key);
  304. }
  305. void CHighlightableButtonsGroup::addButton(CHighlightableButton* bt)
  306. {
  307. bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
  308. bt->onlyOn = true;
  309. buttons.push_back(bt);
  310. }
  311. void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect, int key)
  312. {
  313. CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
  314. if(musicLike)
  315. {
  316. bt->bitmapOffset = buttons.size() - 3;
  317. }
  318. bt->ID = uid;
  319. bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
  320. bt->onlyOn = true;
  321. buttons.push_back(bt);
  322. }
  323. CHighlightableButtonsGroup::CHighlightableButtonsGroup(const CFunctionList2<void(int)> &OnChange, bool musicLikeButtons)
  324. : musicLike(musicLikeButtons), onChange(OnChange)
  325. {}
  326. CHighlightableButtonsGroup::~CHighlightableButtonsGroup()
  327. {
  328. for(size_t i=0;i<buttons.size();i++)
  329. {
  330. delete buttons[i];
  331. }
  332. }
  333. void CHighlightableButtonsGroup::activate()
  334. {
  335. for(size_t i=0;i<buttons.size();i++)
  336. {
  337. buttons[i]->activate();
  338. }
  339. }
  340. void CHighlightableButtonsGroup::deactivate()
  341. {
  342. for(size_t i=0;i<buttons.size();i++)
  343. {
  344. buttons[i]->deactivate();
  345. }
  346. }
  347. void CHighlightableButtonsGroup::select(int id, bool mode)
  348. {
  349. CHighlightableButton *bt = NULL;
  350. if(mode)
  351. {
  352. for(size_t i=0;i<buttons.size() && !bt; ++i)
  353. if (buttons[i]->ID == id)
  354. bt = buttons[i];
  355. }
  356. else
  357. {
  358. bt = buttons[id];
  359. }
  360. bt->select(true);
  361. selectionChanged(bt->ID);
  362. }
  363. void CHighlightableButtonsGroup::selectionChanged(int to)
  364. {
  365. for(size_t i=0;i<buttons.size(); ++i)
  366. if(buttons[i]->ID!=to && buttons[i]->selected)
  367. buttons[i]->select(false);
  368. onChange(to);
  369. }
  370. void CHighlightableButtonsGroup::show(SDL_Surface * to )
  371. {
  372. for(size_t i=0;i<buttons.size(); ++i)
  373. {
  374. if(!musicLike || (musicLike && buttons[i]->selected)) //if musicLike, print only selected button
  375. buttons[i]->show(to);
  376. }
  377. }
  378. void CHighlightableButtonsGroup::showAll( SDL_Surface * to )
  379. {
  380. show(to);
  381. }
  382. void CHighlightableButtonsGroup::block( ui8 on )
  383. {
  384. for(size_t i=0;i<buttons.size(); ++i)
  385. {
  386. buttons[i]->block(on);
  387. }
  388. }
  389. void CSlider::sliderClicked()
  390. {
  391. if(!(active & MOVE))
  392. {
  393. activateMouseMove();
  394. used |= MOVE;
  395. }
  396. }
  397. void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent)
  398. {
  399. float v = 0;
  400. if(horizontal)
  401. {
  402. if( std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2+40 || std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2 )
  403. return;
  404. v = sEvent.x - pos.x - 24;
  405. v *= positions;
  406. v /= (pos.w - 48);
  407. }
  408. else
  409. {
  410. if(std::abs(sEvent.x-(pos.x+pos.w/2)) > pos.w/2+40 || std::abs(sEvent.y-(pos.y+pos.h/2)) > pos.h/2 )
  411. return;
  412. v = sEvent.y - pos.y - 24;
  413. v *= positions;
  414. v /= (pos.h - 48);
  415. }
  416. v += 0.5f;
  417. if(v!=value)
  418. {
  419. moveTo(v);
  420. redrawSlider();
  421. }
  422. }
  423. void CSlider::redrawSlider()
  424. {
  425. //slider->show(screenBuf);
  426. }
  427. void CSlider::moveLeft()
  428. {
  429. moveTo(value-1);
  430. }
  431. void CSlider::moveRight()
  432. {
  433. moveTo(value+1);
  434. }
  435. void CSlider::moveTo(int to)
  436. {
  437. amax(to, 0);
  438. amin(to, positions);
  439. //same, old position?
  440. if(value == to)
  441. return;
  442. value = to;
  443. if(horizontal)
  444. {
  445. if(positions)
  446. {
  447. float part = (float)to/positions;
  448. part*=(pos.w-48);
  449. slider->pos.x = part + pos.x + 16;
  450. }
  451. else
  452. slider->pos.x = pos.x+16;
  453. }
  454. else
  455. {
  456. if(positions)
  457. {
  458. float part = (float)to/positions;
  459. part*=(pos.h-48);
  460. slider->pos.y = part + pos.y + 16;
  461. }
  462. else
  463. slider->pos.y = pos.y+16;
  464. }
  465. if(moved)
  466. moved(to);
  467. }
  468. void CSlider::clickLeft(tribool down, bool previousState)
  469. {
  470. if(down && !slider->blocked)
  471. {
  472. float pw = 0;
  473. float rw = 0;
  474. if(horizontal)
  475. {
  476. pw = GH.current->motion.x-pos.x-25;
  477. rw = pw / ((float)(pos.w-48));
  478. }
  479. else
  480. {
  481. pw = GH.current->motion.y-pos.y-24;
  482. rw = pw / ((float)(pos.h-48));
  483. }
  484. if(pw < -8 || pw > (horizontal ? pos.w : pos.h) - 40)
  485. return;
  486. // if (rw>1) return;
  487. // if (rw<0) return;
  488. slider->clickLeft(true, slider->pressedL);
  489. moveTo(rw * positions + 0.5f);
  490. return;
  491. }
  492. if(active & MOVE)
  493. {
  494. deactivateMouseMove();
  495. used &= ~MOVE;
  496. }
  497. }
  498. CSlider::~CSlider()
  499. {
  500. delete imgs;
  501. }
  502. CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
  503. :capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
  504. {
  505. OBJ_CONSTRUCTION_CAPTURING_ALL;
  506. setAmount(amount);
  507. used = LCLICK;
  508. strongInterest = true;
  509. left = new AdventureMapButton;
  510. right = new AdventureMapButton;
  511. slider = new AdventureMapButton;
  512. pos.x += x;
  513. pos.y += y;
  514. if(horizontal)
  515. {
  516. left->pos.y = slider->pos.y = right->pos.y = pos.y;
  517. left->pos.x = pos.x;
  518. right->pos.x = pos.x + totalw - 16;
  519. }
  520. else
  521. {
  522. left->pos.x = slider->pos.x = right->pos.x = pos.x;
  523. left->pos.y = pos.y;
  524. right->pos.y = pos.y + totalw - 16;
  525. }
  526. left->callback = boost::bind(&CSlider::moveLeft,this);
  527. right->callback = boost::bind(&CSlider::moveRight,this);
  528. slider->callback = boost::bind(&CSlider::sliderClicked,this);
  529. left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
  530. if(horizontal)
  531. {
  532. pos.h = 16;
  533. pos.w = totalw;
  534. }
  535. else
  536. {
  537. pos.w = 16;
  538. pos.h = totalw;
  539. }
  540. if(style == 0)
  541. {
  542. if (horizontal)
  543. imgs = CDefHandler::giveDefEss("IGPCRDIV.DEF");
  544. else
  545. imgs = CDefHandler::giveDefEss("OVBUTN2.DEF");
  546. left->imgs.resize(1); right->imgs.resize(1); slider->imgs.resize(1);
  547. left->imgs[0].push_back(imgs->ourImages[0].bitmap); left->imgs[0].push_back(imgs->ourImages[1].bitmap);
  548. right->imgs[0].push_back(imgs->ourImages[2].bitmap); right->imgs[0].push_back(imgs->ourImages[3].bitmap);
  549. slider->imgs[0].push_back(imgs->ourImages[4].bitmap);
  550. left->notFreeButton = right->notFreeButton = slider->notFreeButton = true;
  551. }
  552. else
  553. {
  554. imgs = NULL;
  555. left->setDef(horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF", false);
  556. right->setDef(horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF", false);
  557. slider->setDef("SCNRBSL.DEF", false);
  558. }
  559. slider->actOnDown = true;
  560. value = -1;
  561. moveTo(Value);
  562. }
  563. void CSlider::block( bool on )
  564. {
  565. left->block(on);
  566. right->block(on);
  567. slider->block(on);
  568. }
  569. void CSlider::setAmount( int to )
  570. {
  571. amount = to;
  572. positions = to - capacity;
  573. amax(positions, 0);
  574. }
  575. void CSlider::showAll(SDL_Surface * to)
  576. {
  577. SDL_FillRect(to, &pos, 0);
  578. CIntObject::showAll(to);
  579. }
  580. void CSlider::wheelScrolled(bool down, bool in)
  581. {
  582. moveTo(value + 3 * (down ? +1 : -1));
  583. }
  584. void CSlider::keyPressed(const SDL_KeyboardEvent & key)
  585. {
  586. if(key.state != SDL_PRESSED) return;
  587. int moveDest = 0;
  588. switch(key.keysym.sym)
  589. {
  590. case SDLK_UP:
  591. moveDest = value - 1;
  592. break;
  593. case SDLK_DOWN:
  594. moveDest = value + 1;
  595. break;
  596. case SDLK_PAGEUP:
  597. moveDest = value - capacity + 1;
  598. break;
  599. case SDLK_PAGEDOWN:
  600. moveDest = value + capacity - 1;
  601. break;
  602. case SDLK_HOME:
  603. moveDest = 0;
  604. break;
  605. case SDLK_END:
  606. moveDest = amount - capacity;
  607. break;
  608. default:
  609. return;
  610. }
  611. moveTo(moveDest);
  612. }