void Character::draw() { if (move.position.y > move.target.y) { drawTarget(); drawCharacter(); } else { drawCharacter(); drawTarget(); } }
void CFont::drawFont(SDL_Surface* dst, const std::string& text, Uint16 xoff, Uint16 yoff, bool highlight) { unsigned int i,x=xoff,y=yoff; if(text.size() != 0) { for(i=0;i<text.size();i++) { unsigned char c = text[i]; if ( !endofText( text.substr(i) ) ) { if(highlight && !m_monochrome) c |= 128; drawCharacter(dst, c, x, y); x+=m_widthtable[c]; } else { x=xoff; y+=8; } } } }
u32 drawString(const char *string, bool isTopScreen, u32 posX, u32 posY, u32 color) { for(u32 i = 0, line_i = 0; i < strlen(string); i++) switch(string[i]) { case '\n': posY += SPACING_Y; line_i = 0; break; case '\t': line_i += 2; break; default: //Make sure we never get out of the screen if(line_i >= ((isTopScreen ? SCREEN_TOP_WIDTH : SCREEN_BOTTOM_WIDTH) - posX) / SPACING_X) { posY += SPACING_Y; line_i = 1; //Little offset so we know the same string continues if(string[i] == ' ') break; //Spaces at the start look weird } drawCharacter(string[i], isTopScreen, posX + line_i * SPACING_X, posY, color); line_i++; break; } return posY; }
void drawString(RGB *buf, int x, int y, char *str, RGBA color) { int offset_x = 0; while (*str != '\0') { offset_x += drawCharacter(buf, x + offset_x, y, *str, color); str++; } }
void drawString(char *s) { float distance=1.25; while(*s) { drawCharacter(*s++); glTranslatef(distance,0,0); } }
void drawString(int x, int y, char *str, u16 color) { while(*str !='\0') { drawCharacter(x, y, *str, color); y = y +6; str++; } }
void drawString(u8* fb, font_s* f, char* str, s16 x, s16 y, u16 w, u16 h) { if(!f || !fb || !str)return; int k; int dx=0, dy=0; int length=strlen(str); for(k=0;k<length;k++) { dx+=drawCharacter(fb,f,str[k],x+dx,y+dy,w,h); if(str[k]=='\n'){dx=0;dy-=f->height;} } }
void drawNode(NODE *node) { char ch[5]; //draw node circle drawCircle(node->xCenter, node->yCenter, RADIUS, node->color); //draw node label drawCharacter(node->xCenter-5, node->yCenter+8, node->id, BLACK); //draw node d and f values sprintf(ch, "%d", node->d); drawString(node->xCenter-3, node->yCenter-6, ch, BLACK); sprintf(ch, "%d", node->f); drawString(node->xCenter-3, node->yCenter-17, ch, BLACK); }
void drawString(u8* fb, char* str, u16 x, u16 y) { if(!str)return; y=232-y; int k; int dx=0, dy=0; for(k=0;k<strlen(str);k++) { if(str[k]>=32 && str[k]<128)drawCharacter(fb,str[k],x+dx,y+dy); dx+=8; if(str[k]=='\n'){dx=0;dy-=8;} } }
void onDraw(SkCanvas* canvas) override { SkScalar y = 20; SkPaint paint; paint.setAntiAlias(true); paint.setLCDRenderText(true); paint.setSubpixelText(true); paint.setTextSize(17); SkFontMgr* fm = fFM; int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); for (int i = 0; i < count; ++i) { SkString familyName; fm->getFamilyName(i, &familyName); paint.setTypeface(nullptr); (void)drawString(canvas, familyName, 20, y, paint); SkScalar x = 220; SkAutoTUnref<SkFontStyleSet> set(fm->createStyleSet(i)); for (int j = 0; j < set->count(); ++j) { SkString sname; SkFontStyle fs; set->getStyle(j, &fs, &sname); sname.appendf(" [%d %d %d]", fs.weight(), fs.width(), fs.slant()); SkSafeUnref(paint.setTypeface(set->createTypeface(j))); x = drawString(canvas, sname, x, y, paint) + 20; // check to see that we get different glyphs in japanese and chinese x = drawCharacter(canvas, 0x5203, x, y, paint, fm, familyName.c_str(), &zh, 1, fs); x = drawCharacter(canvas, 0x5203, x, y, paint, fm, familyName.c_str(), &ja, 1, fs); // check that emoji characters are found x = drawCharacter(canvas, 0x1f601, x, y, paint, fm, familyName.c_str(), nullptr,0, fs); } y += 24; } }
void SFMLGfx::drawText(const std::string &text, int xPos, int yPos) { for (const char &c : text) { if(c == ' ') { xPos += characterWidths['M']; } else { drawCharacter(c, xPos, yPos-baseline[c]); xPos += characterWidths[c]+1; } } }
void drawString(u8* fb, font_s* f, const std::string& str, s16 x, s16 y, u16 w, u16 h) { if (!f || !fb) return; int dx = 0, dy = 0; for (const char& c : str) { dx += drawCharacter(fb, f, c, x + dx, y + dy, w, h); if (c == '\n') { dx = 0; dy -= f->height; } } }
void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, int y) { if (!_data) { return; } x = CLIP(x, 0, _screenWidth - getTextWidth(text) + 1); y = CLIP(y, 0, _screenHeight - _maxHeight); const char *character = text.c_str(); while (*character != 0) { drawCharacter(*character, surface, x, y); x += _spacing1 + _characters[*character + 1]._width; character++; } }
void Font(int X, int Y, char *string) { unsigned char character; if (fntFont == 0) // if the font is defined return; for (character = -1; character != 0; character = (unsigned char) * (string++)) { if (character == 0x20) { X += spaceLenght; } else { stringLenght = *(fntFont + convertWFromLE(*((short int *)(fntFont + character * 4)))); // get the length of the character drawCharacter(X, Y, character); // draw the character on screen X += interCharSpace; // add the length of the space between 2 characters X += stringLenght; // add the length of the current character } } }
double Font::drawString( const char *inString, doublePair inPosition, TextAlignment inAlign ) { double scale = scaleFactor * mScaleFactor; unsigned int numChars = strlen( inString ); double x = inPosition.x; // compensate for extra headspace in accent-equipped font files double y = inPosition.y + scale * mSpriteHeight / 4; double stringWidth = 0; if( inAlign != alignLeft ) { stringWidth = measureString( inString ); } switch( inAlign ) { case alignCenter: x -= stringWidth / 2; break; case alignRight: x -= stringWidth; break; default: // left? do nothing break; } // character sprites are drawn on their centers, so the alignment // adjustments above aren't quite right. x += scale * mSpriteWidth / 2; for( unsigned int i=0; i<numChars; i++ ) { doublePair charPos = { x, y }; double charWidth = drawCharacter( (unsigned char)( inString[i] ), charPos ); x += charWidth + mCharSpacing * scale; } // no spacing after last character x -= mCharSpacing * scale; return x; }
/* ANSIEntryPanel::loadEntry * Loads an entry to the panel *******************************************************************/ bool ANSIEntryPanel::loadEntry(ArchiveEntry* entry) { // Check entry exists if (!entry) return false; if (entry->getSize() == DATASIZE) { memcpy(ansi_chardata, entry->getData(), DATASIZE); ansi_canvas->loadData(ansi_chardata); for (size_t i = 0; i < DATASIZE/2; i++) drawCharacter(i); Layout(); Refresh(); return true; } return false; }
void Scene::drawCharacters(QList<Character> characters, int z) { //Draw scrollbar to browse Characters if more then 5 Characters QScrollBar *scrollcharacters = new QScrollBar(Qt::Horizontal); if(characters.count() > max_characters_on_screen_) { scrollcharacters->setGeometry(0, this->height()*29/30, this->width(), this->height()/30); scrollcharacters->setRange(0, this->width()/(max_characters_on_screen_ + 1)); addWidget(scrollcharacters); } else scrollcharacters = NULL; //Draw Characters int position = 1; foreach(Character p, characters) { drawCharacter(p, position, z, characters.count(), scrollcharacters); position += 1; }
void printGame(LEVELDATA *this_level_data){ int s = 0, x = 0, y= 0, c= 0; int xOffset = 400/2 - this_level_data->width*15/2; int yOffset = 240/2 - this_level_data->height*15/2; for (s=0;s<2;s++){ gspWaitForVBlank(); clearScreen(GFX_TOP, GFX_LEFT); for (y = 0; y<this_level_data->height; y++) { char *level_data_line = this_level_data->levelDataLine[y]; for (x=0; x<this_level_data->width; x++) { char chara = *level_data_line++; for (c=0;c<sizeof(spriteData)/sizeof(SPRITEDATA);c++){ if(spriteData[c].chara == chara) break; } if (c < sizeof(spriteData)/sizeof(SPRITEDATA)) drawCharacter(GFX_TOP, GFX_LEFT, (u8*)spriteData[c].spriteDataPtr, x*15+xOffset,(this_level_data->height-y)*15+yOffset, spriteData[c].width, spriteData[c].height); } } gfxFlushBuffers(); gfxSwapBuffers(); } }
void DrawGLFont::drawAlignedLeft( string message, int offset = 0 ) { int index = 0; for( int i = 0; (unsigned)i < message.size(); i++ ) { unsigned char c = message[i]; if( colors.size() && colors[index].index+offset == i ) { glColor3f( colors[index].r, colors[index].g, colors[index].b ); index++; } c = c-32 + (bold ? 128 : 0); // Draw Current Character drawCharacter( c ); // Move Cursor over by character width plus some glTranslatef( widths[c]+kerning, 0, 0 ); } }
void DrawGLFont::drawAlignedRight( string message, int offset = 0 ) { int cIndex = colors.size()-1; for( int i = message.size()-1; i >= 0; i-- ) { unsigned char c = message[i]; if( (cIndex+1) && colors[cIndex].index+offset > i ) { glColor3f( colors[cIndex].r, colors[cIndex].g, colors[cIndex].b ); cIndex--; } c = c-32 + (bold ? 128 : 0); glTranslatef( -widths[c]-kerning, 0, 0 ); // Draw Current Character drawCharacter( c ); // Move Cursor over by character width plus some } }
void configureCFW(const char *configPath, const char *firm90Path){ initScreens(); drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE); const char *optionsText[] = { "( ) Updated SysNAND mode (A9LH-only)", "( ) Use pre-patched FIRMs", "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option options[optionsAmount]; //Read and parse the existing configuration u32 tempConfig = 0; fileRead(&tempConfig, configPath, 3); for(u32 i = 0; i < optionsAmount; i++) options[i].enabled = (tempConfig >> i) & 0x1; //Pre-select the first configuration option u32 selectedOption = 0; //Boring configuration menu while(1){ u16 pressed = 0; do{ for(u32 i = 0; i < optionsAmount; i++){ options[i].posY = drawString(optionsText[i], 10, !i ? 60 : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE); drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK); } pressed = waitInput(); } while(!(pressed & MENU_BUTTONS)); switch(pressed){ case BUTTON_UP: selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; break; case BUTTON_DOWN: selectedOption = selectedOption == optionsAmount - 1 ? 0 : selectedOption + 1; break; case BUTTON_LEFT: selectedOption = 0; break; case BUTTON_RIGHT: selectedOption = optionsAmount - 1; break; case BUTTON_A: options[selectedOption].enabled = !options[selectedOption].enabled; break; } if(pressed == BUTTON_START) break; } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM if(((tempConfig >> 16) & 0x1) && ((tempConfig & 0x1) != options[0].enabled)) fileDelete(firm90Path); //Preserve the last-used boot options (last 12 bits) tempConfig &= 0xFFF000; //Parse and write the selected options for(u32 i = 0; i < optionsAmount; i++) tempConfig |= options[i].enabled << i; fileWrite(&tempConfig, configPath, 3); //Zero the last booted FIRM flag CFG_BOOTENV = 0; //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); }
void configureCFW(const char *configPath, const char *patchedFirms[]) { initScreens(); drawString(CONFIG_TITLE, 10, 10, COLOR_TITLE); drawString("Press A to select, START to save and reboot", 10, 30, COLOR_WHITE); const char *optionsText[] = { "Screen-init brightness: 4( ) 3( ) 2( ) 1( )", "( ) Updated SysNAND mode (A9LH-only)", "( ) Use pre-patched FIRMs", "( ) Force A9LH detection", "( ) Use 9.0 FIRM as default", "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", "( ) Enable splash screen with no screen-init", "( ) Load loader from SD" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); struct option { int posY; u32 enabled; } options[optionsAmount]; //Parse the existing configuration options[0].enabled = CONFIG(10, 3); for(u32 i = optionsAmount; i; i--) options[i].enabled = CONFIG((i - 1), 1); //Pre-select the first configuration option u32 selectedOption = 1, oldSelectedOption = 0, optionChanged = 0; //Character to display a selected option char selected = 'x'; //Starting position options[0].posY = 52; //Display all the normal options in white, brightness will be displayed later for(u32 i = 1; i < optionsAmount; i++) { options[i].posY = drawString(optionsText[i], 10, options[i - 1].posY + SPACING_Y + (!(1 - i) * 7), COLOR_WHITE); if(options[i].enabled) drawCharacter(selected, 10 + SPACING_X, options[i].posY, COLOR_WHITE); } //Boring configuration menu while(1) { u32 pressed = 0; do { //The status of the selected option changed, black out the previously visible 'x' if needed if(optionChanged) { if(!selectedOption) drawCharacter(selected, 10 + (26 + 5 * (optionChanged - 1)) * SPACING_X, options[0].posY, COLOR_BLACK); else if(!options[selectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[selectedOption].posY, COLOR_BLACK); optionChanged = 0; } //The selected option changed, draw the new one in red and the old one (with its 'x') in white else if(selectedOption != oldSelectedOption) { drawString(optionsText[oldSelectedOption], 10, options[oldSelectedOption].posY, COLOR_WHITE); drawString(optionsText[selectedOption], 10, options[selectedOption].posY, COLOR_RED); if(!oldSelectedOption) drawCharacter(selected, 10 + (26 + 5 * options[0].enabled) * SPACING_X, options[0].posY, COLOR_WHITE); else if(options[oldSelectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[oldSelectedOption].posY, COLOR_WHITE); } //In any case, if the current option is enabled (or brightness is selected) we must display a red 'x' if(!selectedOption) drawCharacter(selected, 10 + (26 + 5 * options[0].enabled) * SPACING_X, options[0].posY, COLOR_RED); else if(options[selectedOption].enabled) drawCharacter(selected, 10 + SPACING_X, options[selectedOption].posY, COLOR_RED); pressed = waitInput(); } while(!(pressed & MENU_BUTTONS)); //Remember the previously selected option oldSelectedOption = selectedOption; switch(pressed) { case BUTTON_UP: selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; break; case BUTTON_DOWN: selectedOption = selectedOption == (optionsAmount - 1) ? 1 : selectedOption + 1; break; case BUTTON_LEFT: selectedOption = 1; break; case BUTTON_RIGHT: selectedOption = optionsAmount - 1; break; case BUTTON_A: optionChanged = 1; if(selectedOption) options[selectedOption].enabled = !options[selectedOption].enabled; else { optionChanged += options[0].enabled; options[0].enabled = options[0].enabled == 3 ? 0 : options[0].enabled + 1; } break; } if(pressed == BUTTON_START) break; } //If the user has been using A9LH and the "Updated SysNAND" setting changed, delete the patched 9.0 FIRM if(CONFIG(16, 1) && (CONFIG(0, 1) != options[1].enabled)) fileDelete(patchedFirms[3]); //If the "Show GBA boot screen in patched AGB_FIRM" setting changed, delete the patched AGB_FIRM if(CONFIG(6, 1) != options[7].enabled) fileDelete(patchedFirms[5]); //Preserve the last-used boot options (last 12 bits) config &= 0xFFF000; //Parse and write the new configuration config |= options[0].enabled << 10; for(u32 i = optionsAmount; i; i--) config |= options[i].enabled << (i - 1); fileWrite(&config, configPath, 3); //Zero the last booted FIRM flag CFG_BOOTENV = 0; //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); }
void Text::writeText(string text, GLint pixelSize) { for(string::iterator it = text.begin(); it != text.end(); ++it) { drawCharacter(*it, pixelSize); glTranslatef(pixelSize, 0.0f, 0.0f); } }