1
0

CCTextFieldTTF.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #include "2d/CCTextFieldTTF.h"
  22. #include "base/CCDirector.h"
  23. #include "platform/CCFileUtils.h"
  24. #include "base/ccUTF8.h"
  25. #include "2d/CCSprite.h"
  26. NS_CC_BEGIN
  27. #define CURSOR_TIME_SHOW_HIDE 0.5f
  28. #define CURSOR_DEFAULT_CHAR '|'
  29. #define PASSWORD_STYLE_TEXT_DEFAULT "\xe2\x80\xa2"
  30. static std::size_t _calcCharCount(const char * text)
  31. {
  32. int n = 0;
  33. char ch = 0;
  34. while ((ch = *text))
  35. {
  36. CC_BREAK_IF(! ch);
  37. if (0x80 != (0xC0 & ch))
  38. {
  39. ++n;
  40. }
  41. ++text;
  42. }
  43. return n;
  44. }
  45. bool TextFieldDelegate::onTextFieldAttachWithIME(TextFieldTTF* /*sender*/)
  46. {
  47. return false;
  48. }
  49. bool TextFieldDelegate::onTextFieldDetachWithIME(TextFieldTTF* /*sender*/)
  50. {
  51. return false;
  52. }
  53. bool TextFieldDelegate::onTextFieldInsertText(TextFieldTTF* /*sender*/, const char* /*text*/, size_t /*nLen*/)
  54. {
  55. return false;
  56. }
  57. bool TextFieldDelegate::onTextFieldDeleteBackward(TextFieldTTF* /*sender*/, const char* /*delText*/, size_t /*nLen*/)
  58. {
  59. return false;
  60. }
  61. bool TextFieldDelegate::onVisit(TextFieldTTF* /*sender*/, Renderer* /*renderer*/, const Mat4& /*transform*/, uint32_t /*flags*/)
  62. {
  63. return false;
  64. }
  65. //////////////////////////////////////////////////////////////////////////
  66. // constructor and destructor
  67. //////////////////////////////////////////////////////////////////////////
  68. TextFieldTTF::TextFieldTTF()
  69. : _delegate(0)
  70. , _charCount(0)
  71. , _inputText("")
  72. , _placeHolder("") // prevent Label initWithString assertion
  73. , _colorText(Color4B::WHITE)
  74. , _secureTextEntry(false)
  75. , _passwordStyleText(PASSWORD_STYLE_TEXT_DEFAULT)
  76. , _cursorEnabled(false)
  77. , _cursorPosition(0)
  78. , _cursorChar(CURSOR_DEFAULT_CHAR)
  79. , _cursorShowingTime(0.0f)
  80. , _isAttachWithIME(false)
  81. {
  82. _colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127;
  83. _colorSpaceHolder.a = 255;
  84. }
  85. TextFieldTTF::~TextFieldTTF()
  86. {
  87. }
  88. //////////////////////////////////////////////////////////////////////////
  89. // static constructor
  90. //////////////////////////////////////////////////////////////////////////
  91. TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
  92. {
  93. TextFieldTTF *ret = new (std::nothrow) TextFieldTTF();
  94. if(ret && ret->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
  95. {
  96. ret->autorelease();
  97. if (placeholder.size()>0)
  98. {
  99. ret->setPlaceHolder(placeholder);
  100. }
  101. return ret;
  102. }
  103. CC_SAFE_DELETE(ret);
  104. return nullptr;
  105. }
  106. TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
  107. {
  108. TextFieldTTF *ret = new (std::nothrow) TextFieldTTF();
  109. if(ret && ret->initWithPlaceHolder("", fontName, fontSize))
  110. {
  111. ret->autorelease();
  112. if (placeholder.size()>0)
  113. {
  114. ret->setPlaceHolder(placeholder);
  115. }
  116. return ret;
  117. }
  118. CC_SAFE_DELETE(ret);
  119. return nullptr;
  120. }
  121. //////////////////////////////////////////////////////////////////////////
  122. // initialize
  123. //////////////////////////////////////////////////////////////////////////
  124. bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
  125. {
  126. setDimensions(dimensions.width, dimensions.height);
  127. setAlignment(alignment, TextVAlignment::CENTER);
  128. return initWithPlaceHolder(placeholder, fontName, fontSize);
  129. }
  130. bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
  131. {
  132. _placeHolder = placeholder;
  133. do
  134. {
  135. // If fontName is ttf file and it corrected, use TTFConfig
  136. if (FileUtils::getInstance()->isFileExist(fontName))
  137. {
  138. TTFConfig ttfConfig(fontName, fontSize, GlyphCollection::DYNAMIC);
  139. if (setTTFConfig(ttfConfig))
  140. {
  141. break;
  142. }
  143. }
  144. setSystemFontName(fontName);
  145. setSystemFontSize(fontSize);
  146. } while (false);
  147. Label::setTextColor(_colorSpaceHolder);
  148. Label::setString(_placeHolder);
  149. #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
  150. // On desktop default enable cursor
  151. if (_currentLabelType == LabelType::TTF)
  152. {
  153. setCursorEnabled(true);
  154. }
  155. #endif
  156. return true;
  157. }
  158. //////////////////////////////////////////////////////////////////////////
  159. // IMEDelegate
  160. //////////////////////////////////////////////////////////////////////////
  161. bool TextFieldTTF::attachWithIME()
  162. {
  163. bool ret = IMEDelegate::attachWithIME();
  164. if (ret)
  165. {
  166. // open keyboard
  167. auto pGlView = Director::getInstance()->getOpenGLView();
  168. if (pGlView)
  169. {
  170. pGlView->setIMEKeyboardState(true);
  171. }
  172. }
  173. return ret;
  174. }
  175. bool TextFieldTTF::detachWithIME()
  176. {
  177. bool ret = IMEDelegate::detachWithIME();
  178. if (ret)
  179. {
  180. // close keyboard
  181. auto glView = Director::getInstance()->getOpenGLView();
  182. if (glView)
  183. {
  184. glView->setIMEKeyboardState(false);
  185. }
  186. }
  187. return ret;
  188. }
  189. void TextFieldTTF::didAttachWithIME()
  190. {
  191. setAttachWithIME(true);
  192. }
  193. void TextFieldTTF::didDetachWithIME()
  194. {
  195. setAttachWithIME(false);
  196. }
  197. bool TextFieldTTF::canAttachWithIME()
  198. {
  199. return (_delegate) ? (! _delegate->onTextFieldAttachWithIME(this)) : true;
  200. }
  201. bool TextFieldTTF::canDetachWithIME()
  202. {
  203. return (_delegate) ? (! _delegate->onTextFieldDetachWithIME(this)) : true;
  204. }
  205. void TextFieldTTF::insertText(const char * text, size_t len)
  206. {
  207. std::string insert(text, len);
  208. // insert \n means input end
  209. int pos = static_cast<int>(insert.find((char)TextFormatter::NewLine));
  210. if ((int)insert.npos != pos)
  211. {
  212. len = pos;
  213. insert.erase(pos);
  214. }
  215. if (len > 0)
  216. {
  217. if (_delegate && _delegate->onTextFieldInsertText(this, insert.c_str(), len))
  218. {
  219. // delegate doesn't want to insert text
  220. return;
  221. }
  222. std::size_t countInsertChar = _calcCharCount(insert.c_str());
  223. _charCount += countInsertChar;
  224. if (_cursorEnabled)
  225. {
  226. StringUtils::StringUTF8 stringUTF8;
  227. stringUTF8.replace(_inputText);
  228. stringUTF8.insert(_cursorPosition, insert);
  229. setCursorPosition(_cursorPosition + countInsertChar);
  230. setString(stringUTF8.getAsCharSequence());
  231. }
  232. else
  233. {
  234. std::string sText(_inputText);
  235. sText.append(insert);
  236. setString(sText);
  237. }
  238. }
  239. if ((int)insert.npos == pos) {
  240. return;
  241. }
  242. // '\n' inserted, let delegate process first
  243. if (_delegate && _delegate->onTextFieldInsertText(this, "\n", 1))
  244. {
  245. return;
  246. }
  247. // if delegate hasn't processed, detach from IME by default
  248. detachWithIME();
  249. }
  250. void TextFieldTTF::deleteBackward()
  251. {
  252. size_t len = _inputText.length();
  253. if (! len)
  254. {
  255. // there is no string
  256. return;
  257. }
  258. // get the delete byte number
  259. size_t deleteLen = 1; // default, erase 1 byte
  260. while(0x80 == (0xC0 & _inputText.at(len - deleteLen)))
  261. {
  262. ++deleteLen;
  263. }
  264. if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + len - deleteLen, static_cast<int>(deleteLen)))
  265. {
  266. // delegate doesn't want to delete backwards
  267. return;
  268. }
  269. // if all text deleted, show placeholder string
  270. if (len <= deleteLen)
  271. {
  272. _inputText = "";
  273. _charCount = 0;
  274. setCursorPosition(0);
  275. setString(_inputText);
  276. return;
  277. }
  278. // set new input text
  279. if (_cursorEnabled)
  280. {
  281. if (_cursorPosition)
  282. {
  283. setCursorPosition(_cursorPosition - 1);
  284. StringUtils::StringUTF8 stringUTF8;
  285. stringUTF8.replace(_inputText);
  286. stringUTF8.deleteChar(_cursorPosition);
  287. _charCount = stringUTF8.length();
  288. setString(stringUTF8.getAsCharSequence());
  289. }
  290. }
  291. else
  292. {
  293. std::string text(_inputText.c_str(), len - deleteLen);
  294. setString(text);
  295. }
  296. }
  297. const std::string& TextFieldTTF::getContentText()
  298. {
  299. return _inputText;
  300. }
  301. void TextFieldTTF::setCursorPosition(std::size_t cursorPosition)
  302. {
  303. if (_cursorEnabled && cursorPosition <= (std::size_t)_charCount)
  304. {
  305. _cursorPosition = cursorPosition;
  306. _cursorShowingTime = CURSOR_TIME_SHOW_HIDE * 2.0f;
  307. }
  308. }
  309. void TextFieldTTF::setCursorFromPoint(const Vec2 &point, const Camera* camera)
  310. {
  311. if (_cursorEnabled)
  312. {
  313. // Reset Label, no cursor
  314. bool oldIsAttachWithIME = _isAttachWithIME;
  315. _isAttachWithIME = false;
  316. updateCursorDisplayText();
  317. Rect rect;
  318. rect.size = getContentSize();
  319. if (isScreenPointInRect(point, camera, getWorldToNodeTransform(), rect, nullptr))
  320. {
  321. int latterPosition = 0;
  322. for (; latterPosition < _lengthOfString; ++latterPosition)
  323. {
  324. if (_lettersInfo[latterPosition].valid)
  325. {
  326. auto sprite = getLetter(latterPosition);
  327. rect.size = sprite->getContentSize();
  328. if (isScreenPointInRect(point, camera, sprite->getWorldToNodeTransform(), rect, nullptr))
  329. {
  330. setCursorPosition(latterPosition);
  331. break;
  332. }
  333. }
  334. }
  335. if (latterPosition == _lengthOfString)
  336. {
  337. setCursorPosition(latterPosition);
  338. }
  339. }
  340. // Set cursor
  341. _isAttachWithIME = oldIsAttachWithIME;
  342. updateCursorDisplayText();
  343. }
  344. }
  345. void TextFieldTTF::setAttachWithIME(bool isAttachWithIME)
  346. {
  347. if (isAttachWithIME != _isAttachWithIME)
  348. {
  349. _isAttachWithIME = isAttachWithIME;
  350. if (_isAttachWithIME)
  351. {
  352. setCursorPosition(_charCount);
  353. }
  354. updateCursorDisplayText();
  355. }
  356. }
  357. void TextFieldTTF::setTextColor(const Color4B &color)
  358. {
  359. _colorText = color;
  360. if (!_inputText.empty())
  361. {
  362. Label::setTextColor(_colorText);
  363. }
  364. }
  365. void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
  366. {
  367. if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentFlags))
  368. {
  369. return;
  370. }
  371. Label::visit(renderer,parentTransform,parentFlags);
  372. }
  373. void TextFieldTTF::update(float delta)
  374. {
  375. if (_cursorEnabled && _isAttachWithIME)
  376. {
  377. _cursorShowingTime -= delta;
  378. if (_cursorShowingTime < -CURSOR_TIME_SHOW_HIDE)
  379. {
  380. _cursorShowingTime = CURSOR_TIME_SHOW_HIDE;
  381. }
  382. // before cursor inserted '\b', need next letter
  383. auto sprite = getLetter((int)_cursorPosition + 1);
  384. if (sprite)
  385. {
  386. if (_cursorShowingTime >= 0.0f)
  387. {
  388. sprite->setOpacity(255);
  389. }
  390. else
  391. {
  392. sprite->setOpacity(0);
  393. }
  394. sprite->setDirty(true);
  395. }
  396. }
  397. }
  398. const Color4B& TextFieldTTF::getColorSpaceHolder()
  399. {
  400. return _colorSpaceHolder;
  401. }
  402. void TextFieldTTF::setColorSpaceHolder(const Color3B& color)
  403. {
  404. _colorSpaceHolder.r = color.r;
  405. _colorSpaceHolder.g = color.g;
  406. _colorSpaceHolder.b = color.b;
  407. _colorSpaceHolder.a = 255;
  408. if (_inputText.empty())
  409. {
  410. Label::setTextColor(_colorSpaceHolder);
  411. }
  412. }
  413. void TextFieldTTF::setColorSpaceHolder(const Color4B& color)
  414. {
  415. _colorSpaceHolder = color;
  416. if (_inputText.empty())
  417. {
  418. Label::setTextColor(_colorSpaceHolder);
  419. }
  420. }
  421. //////////////////////////////////////////////////////////////////////////
  422. // properties
  423. //////////////////////////////////////////////////////////////////////////
  424. // input text property
  425. void TextFieldTTF::setString(const std::string &text)
  426. {
  427. std::string displayText;
  428. std::size_t charCount = 0;
  429. if (!text.empty())
  430. {
  431. _inputText = text;
  432. displayText = _inputText;
  433. charCount = _calcCharCount(_inputText.c_str());
  434. if (_secureTextEntry)
  435. {
  436. displayText = "";
  437. size_t length = charCount;
  438. while (length)
  439. {
  440. displayText.append(_passwordStyleText);
  441. --length;
  442. }
  443. }
  444. }
  445. else
  446. {
  447. _inputText = "";
  448. }
  449. if (_cursorEnabled && charCount != _charCount)
  450. {
  451. _cursorPosition = charCount;
  452. }
  453. if (_cursorEnabled)
  454. {
  455. // Need for recreate all letters in Label
  456. Label::removeAllChildrenWithCleanup(false);
  457. }
  458. // if there is no input text, display placeholder instead
  459. if (_inputText.empty() && (!_cursorEnabled || !_isAttachWithIME))
  460. {
  461. Label::setTextColor(_colorSpaceHolder);
  462. Label::setString(_placeHolder);
  463. }
  464. else
  465. {
  466. makeStringSupportCursor(displayText);
  467. Label::setTextColor(_colorText);
  468. Label::setString(displayText);
  469. }
  470. _charCount = charCount;
  471. }
  472. void TextFieldTTF::appendString(const std::string& text)
  473. {
  474. insertText(text.c_str(), text.length());
  475. }
  476. void TextFieldTTF::makeStringSupportCursor(std::string& displayText)
  477. {
  478. if (_cursorEnabled && _isAttachWithIME)
  479. {
  480. if (displayText.empty())
  481. {
  482. // \b - Next char not change x position
  483. displayText.push_back((char)TextFormatter::NextCharNoChangeX);
  484. displayText.push_back(_cursorChar);
  485. }
  486. else
  487. {
  488. StringUtils::StringUTF8 stringUTF8;
  489. stringUTF8.replace(displayText);
  490. if (_cursorPosition > stringUTF8.length())
  491. {
  492. _cursorPosition = stringUTF8.length();
  493. }
  494. std::string cursorChar;
  495. // \b - Next char not change x position
  496. cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
  497. cursorChar.push_back(_cursorChar);
  498. stringUTF8.insert(_cursorPosition, cursorChar);
  499. displayText = stringUTF8.getAsCharSequence();
  500. }
  501. }
  502. }
  503. void TextFieldTTF::updateCursorDisplayText()
  504. {
  505. // Update Label content
  506. setString(_inputText);
  507. }
  508. void TextFieldTTF::setCursorChar(char cursor)
  509. {
  510. if (_cursorChar != cursor)
  511. {
  512. _cursorChar = cursor;
  513. updateCursorDisplayText();
  514. }
  515. }
  516. void TextFieldTTF::controlKey(EventKeyboard::KeyCode keyCode)
  517. {
  518. if (_cursorEnabled)
  519. {
  520. switch (keyCode)
  521. {
  522. case EventKeyboard::KeyCode::KEY_HOME:
  523. case EventKeyboard::KeyCode::KEY_KP_HOME:
  524. setCursorPosition(0);
  525. updateCursorDisplayText();
  526. break;
  527. case EventKeyboard::KeyCode::KEY_END:
  528. setCursorPosition(_charCount);
  529. updateCursorDisplayText();
  530. break;
  531. case EventKeyboard::KeyCode::KEY_DELETE:
  532. case EventKeyboard::KeyCode::KEY_KP_DELETE:
  533. if (_cursorPosition < (std::size_t)_charCount)
  534. {
  535. StringUtils::StringUTF8 stringUTF8;
  536. stringUTF8.replace(_inputText);
  537. stringUTF8.deleteChar(_cursorPosition);
  538. setCursorPosition(_cursorPosition);
  539. _charCount = stringUTF8.length();
  540. setString(stringUTF8.getAsCharSequence());
  541. }
  542. break;
  543. case EventKeyboard::KeyCode::KEY_LEFT_ARROW:
  544. if (_cursorPosition)
  545. {
  546. setCursorPosition(_cursorPosition - 1);
  547. updateCursorDisplayText();
  548. }
  549. break;
  550. case EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
  551. if (_cursorPosition < (std::size_t)_charCount)
  552. {
  553. setCursorPosition(_cursorPosition + 1);
  554. updateCursorDisplayText();
  555. }
  556. break;
  557. case EventKeyboard::KeyCode::KEY_ESCAPE:
  558. detachWithIME();
  559. break;
  560. default:
  561. break;
  562. }
  563. }
  564. }
  565. const std::string& TextFieldTTF::getString() const
  566. {
  567. return _inputText;
  568. }
  569. // place holder text property
  570. void TextFieldTTF::setPlaceHolder(const std::string& text)
  571. {
  572. _placeHolder = text;
  573. if (_inputText.empty())
  574. {
  575. Label::setTextColor(_colorSpaceHolder);
  576. Label::setString(_placeHolder);
  577. }
  578. }
  579. const std::string& TextFieldTTF::getPlaceHolder() const
  580. {
  581. return _placeHolder;
  582. }
  583. void TextFieldTTF::setCursorEnabled(bool enabled)
  584. {
  585. if (_currentLabelType == LabelType::TTF)
  586. {
  587. if (_cursorEnabled != enabled)
  588. {
  589. _cursorEnabled = enabled;
  590. if (_cursorEnabled)
  591. {
  592. _cursorPosition = _charCount;
  593. scheduleUpdate();
  594. }
  595. else
  596. {
  597. _cursorPosition = 0;
  598. unscheduleUpdate();
  599. }
  600. }
  601. }
  602. else
  603. {
  604. CCLOG("TextFieldTTF cursor worked only LabelType::TTF");
  605. }
  606. }
  607. // secureTextEntry
  608. void TextFieldTTF::setSecureTextEntry(bool value)
  609. {
  610. if (_secureTextEntry != value)
  611. {
  612. _secureTextEntry = value;
  613. setString(_inputText);
  614. }
  615. }
  616. void TextFieldTTF::setPasswordTextStyle(const std::string &text)
  617. {
  618. if (text.length() < 1)
  619. {
  620. return;
  621. }
  622. if (text != _passwordStyleText) {
  623. _passwordStyleText = text;
  624. setString(_inputText);
  625. }
  626. }
  627. const std::string& TextFieldTTF::getPasswordTextStyle() const
  628. {
  629. return _passwordStyleText;
  630. }
  631. bool TextFieldTTF::isSecureTextEntry() const
  632. {
  633. return _secureTextEntry;
  634. }
  635. NS_CC_END