void PokemonString::fromUTF8(const char * str) { str = (str == NULL) ? "" : str; strSz = std::strlen(str) + 1; resizeStr(); dataSz = strSz; resizeData(); dataSz = 0; int s = 0; size_t offset = 0; while (offset < strSz - 1) { u32 c; s = utf8_mbtowc(NULL, &c, (const unsigned char*)str + offset, strSz - 1); if (s < 0) break; offset += s; if (c == 0) break; s = pkmgba_wctomb(NULL, _data + dataSz, c, 2, _japanese); if (s < 0) break; dataSz += s; } _data[dataSz++] = 0xff; hasChanged = true; }
void PathDesignScreen::removeWaypoint( QPointF p1 ) { if (guiPath_.empty() ) return; const double VICINITY = 1.0; // in meters // check if click is near the latest waypoint int lastIndex = guiPath_.size() - 1; QPointF p2; p2 = guiPath_[lastIndex].position; double dist = sqrt ( (p1.x()-p2.x()) * (p1.x()-p2.x()) + (p1.y()-p2.y()) * (p1.y()-p2.y()) ); if (dist<VICINITY) { // delete the last element resizeData( lastIndex ); } // if the waypoint was in focus before, reset to no focus if (waypointInFocus_==lastIndex) waypointInFocus_=-1; }
void PokemonString::load(u8 * data, size_t nb) { dataSz = nb; resizeData(); std::copy(data, data + dataSz, _data); }