本文整理汇总了C++中drawString函数的典型用法代码示例。如果您正苦于以下问题:C++ drawString函数的具体用法?C++ drawString怎么用?C++ drawString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
void Bond::output_torsion(ofstream &out){
out << "r " << 0.01* abs(moment_torsion) << endl;
drawString(out);
}
示例2: _main
//.........这里部分代码省略.........
// Define struct for global variables!
struct cGlobals caveGlobals;
// Variables n stuff!
caveGlobals.food = 0;
caveGlobals.row = 1;
caveGlobals.col = 1;
caveGlobals.level = 1;
caveGlobals.dogsteps = 0;
caveGlobals.dogalive = 1;
caveGlobals.mysteps = 0;
caveGlobals.maxhealth = 10;
caveGlobals.curhealth = 10;
// Start at level 1 (obviously!)
changelevel(&caveGlobals);
// Draw Buffers and Initial Screen
__os_snprintf(caveGlobals.mystat, 64, " ");
doclearstuff();
drawstuff(&caveGlobals);
flipBuffers();
int err;
while(1) {
VPADRead(0, &vpad_data, 1, &err);
// Quit
if (vpad_data.btn_trigger & BUTTON_HOME) {
doclearstuff();
__os_snprintf(caveGlobals.endgame, 256, "Thanks for Playing!\nYour Final Level: %d \n\n\nBy: SonyUSA", caveGlobals.level);
drawString(0, 0, caveGlobals.endgame);
flipBuffers();
t1 = 0x50000000;
while(t1--) ;
//Maybe fix for exit crash?
doclearstuff();
flipBuffers();
doclearstuff();
flipBuffers();
//Ape escape!
SYSLaunchMenu();
_Exit();
}
//Grab Stuff (A)
if (vpad_data.btn_release & BUTTON_A) {
//Checks for Food
if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 8) {
doclearstuff();
__os_snprintf(caveGlobals.mystat, 64, "Got it!");
drawString(25, 17, caveGlobals.mystat);
caveGlobals.food += 1;
caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2;
drawstuff(&caveGlobals);
flipBuffers();
}
//Check for Potions
if (caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] == 11) {
doclearstuff();
__os_snprintf(caveGlobals.mystat, 64, "*Gulp!*");
drawString(25, 17, caveGlobals.mystat);
caveGlobals.curhealth += 5;
caveGlobals.nMapArray[caveGlobals.col][caveGlobals.row] = 2;
//Make sure we don't go over health limit
示例3: drawSample
static void
drawSample(int x, int y, int w, int h,
struct formatInfo *format, struct envModeInfo *envMode)
{
glViewport(x, y, w, h);
glScissor(x, y, w, h);
glClearColor(0.1, 0.1, 0.1, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
begin2D(w, h);
drawString(format->name, 10, h - 15, labelInfoColor);
drawString(envMode->name, 10, 5, labelInfoColor);
end2D();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, envMode->mode);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, envColors[envColor]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
loadTexture(textureWidth, textureHeight, format);
if (drawBackground) {
drawCheck(15, 15, lightCheck, darkCheck);
}
if (drawBlended) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
}
if (drawSmooth) {
glShadeModel(GL_SMOOTH);
}
if (drawTextured) {
glEnable(GL_TEXTURE_2D);
}
glBegin(GL_QUADS);
glColor4f(1.0, 0.0, 0.0, 1.0);
glTexCoord2f(0.0, 0.0);
glVertex2f(-0.8, -0.8);
glColor4f(0.0, 1.0, 0.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex2f(0.8, -0.8);
glColor4f(0.0, 0.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex2f(0.8, 0.8);
glColor4f(1.0, 1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex2f(-0.8, 0.8);
glEnd();
glDisable(GL_BLEND);
glShadeModel(GL_FLAT);
glDisable(GL_TEXTURE_2D);
if (displayLevelInfo) {
GLint width, height, border, components;
#if GL_EXT_texture
GLint redSize, greenSize, blueSize, alphaSize;
GLint luminanceSize, intensitySize;
#endif
char buf[255];
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_HEIGHT, &height);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_BORDER, &border);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_COMPONENTS, &components);
#if GL_EXT_texture
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_RED_SIZE_EXT, &redSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_GREEN_SIZE_EXT, &greenSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_BLUE_SIZE_EXT, &blueSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_ALPHA_SIZE_EXT, &alphaSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_LUMINANCE_SIZE_EXT, &luminanceSize);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_INTENSITY_SIZE_EXT, &intensitySize);
#endif
begin2D(w, h);
sprintf(buf, "dimensions: %d x %d", width, height);
drawStringOutline(buf, 15, h / 2 + 20, labelLevelColor0, labelLevelColor1);
sprintf(buf, "border: %d", border);
drawStringOutline(buf, 15, h / 2 + 10, labelLevelColor0, labelLevelColor1);
sprintf(buf, "components: 0x%04X", components);
drawStringOutline(buf, 15, h / 2, labelLevelColor0, labelLevelColor1);
sprintf(buf, "sizes:");
//.........这里部分代码省略.........
示例4: drawString
Vec2i drawString (const String& str, const Vec2f& pos, U32 abgr) { return drawString(str, Vec4f(pos, 0.0f, 1.0f), 0.5f, abgr); }
示例5: switch
//-----------------------------------------------------------------------------
// name: render_2()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleFaceShredder::render_2( t_CKFLOAT delta )
{
Shred_Stat * stat = NULL;
Shred_Data * data = NULL;
Color4D c;
Point3D p, v, a;
Point3D b;
t_CKFLOAT theta;
static char buffer[2048];
char * t;
char * d;
int i;
// loop through
t_CKFLOAT y = 1.15;
for( i = 0; i < m_stats.size(); i++ )
{
stat = m_stats[i];
data = (Shred_Data *)stat->data;
data->pos2[1] = y;
y -= .15;
}
// loop through
Shred_Stat * s;
t_CKFLOAT srate = Digitalio::sampling_rate() / 1000.0;
for( i = 0; i < m_stats.size(); i++ )
{
s = m_stats[i];
data = m_stats[i]->data;
c = data->color;
p = data->pos2;
switch( s->state )
{
case 0: t = "inactive"; break;
case 1: t = "active"; break;
case 2: t = "waiting"; break;
case 3: t = "done"; break;
default: t = "none"; break;
}
sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)",
s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate );
// push the name
glPushName( data->name );
glPushMatrix();
glColor4f( c[0], c[1], c[2], c[3] );
glTranslatef( p[0], p[1], p[2] );
glutSolidSphere( data->radius2, 15, 15 );
glTranslatef( .1, -.033, 0.0 );
glPushMatrix();
glColor4f( 0.0, 0.0, 0.0, 1.0 );
scaleFont( .052 );
drawString( buffer );
glPopMatrix();
glPopMatrix();
glPopName();
}
// loop through
map<Shred_Stat *, Shred_Stat *>::iterator iter;
for( iter = m_done.begin(); iter != m_done.end(); iter++ )
{
s = (*iter).second;
data = (Shred_Data *)(*iter).second->data;
c = data->color;
data->pos2[1] = y;
y -= .15;
p = data->pos2;
switch( s->state )
{
case 0: t = "inactive"; break;
case 1: t = "active"; break;
case 2: t = "waiting"; break;
case 3: t = "done"; break;
default: t = "none"; break;
}
sprintf( buffer, "%i - %s - %s - %s - cycle(%i) - acts(%i) - c/a(%.2f) - avg(%.2fms)",
s->id, t, s->name.c_str(), s->source.c_str(), s->cycles, s->activations, s->average_cycles, s->average_ctrl / srate );
// push the name
glPushName( data->name );
glPushMatrix();
glColor4f( c[0], c[1], c[2], c[3] );
glTranslatef( p[0], p[1], p[2] );
glutSolidSphere( data->radius2, 15, 15 );
glTranslatef( .1, -.033, 0.0 );
glPushMatrix();
glDisable( GL_LIGHTING );
glColor4f( 0.4, 0.4, 0.4, 1.0 );
scaleFont( .052 );
drawString( buffer );
glEnable( GL_LIGHTING );
//.........这里部分代码省略.........
示例6: twodigit
void SettingsSetTimeScreen::renderHour()
{
// numToStr(GetHour());
twodigit(buf, GetHour());
drawString(110, 175, buf, WHITE, BLACK, 2);
}
示例7: tsCalibCenterText
void tsCalibCenterText(char* text, uint16_t y, uint16_t color) {
drawString((lcdGetWidth() - drawGetStringWidth(&dejaVuSans9ptFontInfo, text)) / 2, y, color, &dejaVuSans9ptFontInfo, text);
}
示例8: pt
gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, gfx::Color fg, gfx::Color bg, const gfx::Rect& rc, int align, bool draw)
{
gfx::Point pt(0, rc.y);
if ((align & (JI_MIDDLE | JI_BOTTOM)) != 0) {
gfx::Size preSize = doUIStringAlgorithm(str, gfx::ColorNone, gfx::ColorNone, rc, 0, false);
if (align & JI_MIDDLE)
pt.y = rc.y + rc.h/2 - preSize.h/2;
else if (align & JI_BOTTOM)
pt.y = rc.y + rc.h - preSize.h;
}
gfx::Size calculatedSize(0, 0);
size_t beg, end, new_word_beg, old_end;
std::string line;
// Draw line-by-line
for (beg=end=0; end != std::string::npos; ) {
pt.x = rc.x;
// Without word-wrap
if ((align & JI_WORDWRAP) == 0) {
end = str.find('\n', beg);
}
// With word-wrap
else {
old_end = std::string::npos;
for (new_word_beg=beg;;) {
end = str.find_first_of(" \n", new_word_beg);
// If we have already a word to print (old_end != npos), and
// we are out of the available width (rc.w) using the new "end",
if ((old_end != std::string::npos) &&
(pt.x+m_font->textLength(str.substr(beg, end-beg).c_str()) > rc.w)) {
// We go back to the "old_end" and paint from "beg" to "end"
end = old_end;
break;
}
// If we have more words to print...
else if (end != std::string::npos) {
// Force line break, now we have to paint from "beg" to "end"
if (str[end] == '\n')
break;
// White-space, this is a beginning of a new word.
new_word_beg = end+1;
}
// We are in the end of text
else
break;
old_end = end;
}
}
// Get the entire line to be painted
line = str.substr(beg, end-beg);
gfx::Size lineSize(
m_font->textLength(line.c_str()),
m_font->height());
calculatedSize.w = MAX(calculatedSize.w, lineSize.w);
// Render the text
if (draw) {
int xout;
if ((align & JI_CENTER) == JI_CENTER)
xout = pt.x + rc.w/2 - lineSize.w/2;
else if ((align & JI_RIGHT) == JI_RIGHT)
xout = pt.x + rc.w - lineSize.w;
else
xout = pt.x;
drawString(line, fg, bg, gfx::Point(xout, pt.y));
if (!gfx::is_transparent(bg))
fillAreaBetweenRects(bg,
gfx::Rect(rc.x, pt.y, rc.w, lineSize.h),
gfx::Rect(xout, pt.y, lineSize.w, lineSize.h));
}
pt.y += lineSize.h;
calculatedSize.h += lineSize.h;
beg = end+1;
}
// Fill bottom area
if (draw && !gfx::is_transparent(bg)) {
if (pt.y < rc.y+rc.h)
fillRect(bg, gfx::Rect(rc.x, pt.y, rc.w, rc.y+rc.h-pt.y));
}
return calculatedSize;
}
示例9: drawPause
void drawPause() {
char *psChr = "PAUSE";
if ( (psCnt&63) < 32 ) {
drawString(psChr, 252, LAYER_HEIGHT/3, 20, 0, 200, 200, 180);
}
}
示例10: main
int main(void)
{
//video mode 3, activate background 2
*REG_DISPCNT = MODE3 | BG2_ENABLE;
paddle.x = 113;
oldPaddle.x = 113;
//ball starts on top of paddle
setBallOnPaddle();
lives = 3;
bricksLeft = NUM_OF_BRICKS;
sprintf(livesString, "%d", lives); //store lives as a string
sprintf(bricksString, "%d", bricksLeft); //store bricks left as a string
drawBackground3(startscreen);
drawString(10, 125, "Press any key", WHITE);
drawString(10, 135, "to start", WHITE);
while(!ANY_KEY_DOWN)
{
//press key to advance
}
fillScreen(BLACK);
waitForVblank();
drawRect(GAME_WIDTH, 0, SCREEN_WIDTH - GAME_WIDTH, SCREEN_HEIGHT, RGB(6, 0, 6));
instantiateBrickArray();
drawString(205, 20, "Lives", WHITE);
drawString(215, 35, livesString, WHITE);
drawString(202, 60, "Bricks", WHITE);
drawString(208, 70, "left", WHITE);
drawString(215, 85, bricksString, WHITE);
while(lives > 0 && bricksLeft > 0)
{
updatePositions();
drawEverything();
}
if (bricksLeft <= 0)
{
drawBackground3(win);
}
else
{
drawBackground3(lose);
}
while(TRUE)
{
//do nothing
}
}
示例11: beginSprite
/**
* CBitmapFont::drawStringView
* @date Modified Apr 04, 2006
*/
void CBitmapFont::drawStringView(CString str, RECT rView, unsigned int unOffset, D3DCOLOR dwColor, bool bHandleSprite)
{
std::vector<CString> vLines, vWords, vColors;
unsigned int unWidth = rView.right - rView.left,
unHeight = rView.bottom - rView.top,
unWordWidth = 0;
RECT rWord;
float fX = (float)rView.left, fY = (float)rView.top;
str.ToList(vLines, "\r\n");
if(bHandleSprite)
beginSprite();
// Calculate max number of lines
unsigned int unLineCount = unHeight / m_cLineHeight;
// Iterate lines in string.
size_t i = ((vLines.size() <= unLineCount) ? 0 : max(vLines.size() - unOffset - unLineCount, 0));
for(; i < ((vLines.size() <= unLineCount) ? vLines.size() : vLines.size() - unOffset); ++i)
{
// Iterate words in string.
vLines[i].ToList(vWords, " ");
for(size_t j = 0; j < vWords.size(); ++j)
{
bool bFirst = false;
vWords[j].ToList(vColors, "{}");
if(vWords[j].GetChar(0) == '{')
bFirst = true;
if(vColors.size())
{
for(size_t k = 0; k < vColors.size(); ++k)
{
if((bFirst && k % 2 == 0) || (!bFirst && k % 2 == 1))
{
dwColor = vColors[k].ToUlongFromHex();
continue;
}
// Take line length into consideration
unWordWidth = measureString(vColors[k], &rWord);
if(fX + unWordWidth >= unWidth)
{
fX = (float)rView.left;
fY += m_cLineHeight;
drawString(vColors[k], fX, fY, dwColor, false);
}
else
{
drawString(vColors[k], fX, fY, dwColor, false);
fX += unWordWidth + m_mCharMap[' '];
}
}
}
else
{
// Take line length into consideration
unWordWidth = measureString(vWords[j], &rWord);
if(fX + unWordWidth >= unWidth)
{
fX = (float)rView.left;
fY += m_cLineHeight;
drawString(vWords[j], fX, fY, dwColor, false);
}
else
{
drawString(vWords[j], fX, fY, dwColor, false);
fX += unWordWidth + m_mCharMap[' '];
}
}
}
fX = (float)rView.left;
fY += m_cLineHeight;
}
if(bHandleSprite)
endSprite();
}
示例12: updatePositions
void updatePositions()
{
oldPaddle = paddle;
oldBall = ball;
if (KEY_DOWN_NOW(BUTTON_RIGHT))
{
paddle.x = min(paddle.x + PADDLE_SPEED, GAME_WIDTH - PADDLE_WIDTH);
if (ball.onPaddle)
ball.x = paddle.x + PADDLE_WIDTH / 2;
}
if (KEY_DOWN_NOW(BUTTON_LEFT))
{
paddle.x = max(paddle.x - PADDLE_SPEED, 0);
if (ball.onPaddle)
ball.x = paddle.x + PADDLE_WIDTH / 2;
}
//release ball from paddle
if (ball.onPaddle && KEY_DOWN_NOW(BUTTON_A))
{
ball.onPaddle = FALSE;
ball.xspeed = 1;
ball.yspeed = -3;
ball.y -= 1; //give it one pixel of space so it doesn't "collide" with paddle right away
}
//--------------------------CHECK FOR COLLISIONS-------------------------------//
//check collision with right boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, GAME_WIDTH, 0, GAME_WIDTH + 10, GAME_HEIGHT))
{
ball.xspeed = -ball.xspeed;
ball.x -= 2;
}
//check collision with top boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, 0, -10, GAME_WIDTH, 0))
{
ball.yspeed = -ball.yspeed;
ball.y += 2;
}
//check collision with left boundary
if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, -10, 0, 0, GAME_HEIGHT))
{
ball.xspeed = -ball.xspeed;
ball.x += 2;
}
//check collision with bricks
for (int i = 0; i < NUM_OF_BRICKS; i++)
{
if (brickArray[i].health && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, brickArray[i].x, brickArray[i].y,
brickArray[i].x + BRICK_WIDTH, brickArray[i].y + BRICK_HEIGHT))
{
int ballxmid = ball.x + BALL_SIZE/2;
int ballymid = ball.y + BALL_SIZE/2;
int brickxmid = brickArray[i].x + BRICK_WIDTH/2;
int brickymid = brickArray[i].y + BRICK_HEIGHT/2;
//slope of the vector pointing from the ball to the brick
int deltax = brickxmid - ballxmid;
int deltay = brickymid - ballymid;
//below or above brick
if (abs(deltax) < 2 * abs(deltay) + 2) // abs(dy/dx) > 1/2 (visual->) \_____/
{
ball.yspeed = -ball.yspeed;
ball.y += signOf(ball.yspeed) * 2; //"push it out of brick just a bit"
}
//side of brick
else
{
ball.xspeed = -ball.xspeed;
ball.x += signOf(ball.xspeed) * 2; //"push it out of brick just a bit"
}
brickArray[i].health -= 1;
if (!brickArray[i].health)
{
//draw part of the background image that was previously hidden
drawImageExt3(brickArray[i].x, brickArray[i].y, brickArray[i].x, brickArray[i].y, BRICK_WIDTH, BRICK_HEIGHT, gtech);
bricksLeft --;
sprintf(bricksString, "%d", bricksLeft); //store lives as a string
waitForVblank();
drawRect(215, 85, 12, 8, RGB(6, 0, 6));
drawString(215, 85, bricksString, WHITE);
}
}
}
//.........这里部分代码省略.........
示例13: getWindowPos
void
Hud::Rebuild(int width, int height)
{
_requiresRebuildStatic = false;
_windowWidth = width;
_windowHeight = height;
_staticVboSource.clear();
int x, y;
// add UI elements
for (std::vector<Item>::const_iterator it = _labels.begin();
it != _labels.end(); ++it) {
getWindowPos(*it, &x, &y);
drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str());
}
for (std::vector<RadioButton>::const_iterator it = _radioButtons.begin();
it != _radioButtons.end(); ++it) {
getWindowPos(*it, &x, &y);
if (it->checked) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_RADIO_BUTTON_ON);
drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str());
} else {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, ' ');
drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str());
}
}
for (std::vector<CheckBox>::const_iterator it = _checkBoxes.begin();
it != _checkBoxes.end(); ++it) {
getWindowPos(*it, &x, &y);
if (it->checked) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_ON);
drawString(_staticVboSource, x, y, 1, 1, 0, it->label.c_str());
} else {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_CHECK_BOX_OFF);
drawString(_staticVboSource, x, y, .5f, .5f, .5f, it->label.c_str());
}
}
for (std::vector<Slider>::const_iterator it = _sliders.begin();
it != _sliders.end(); ++it) {
getWindowPos(*it, &x, &y);
int sx = x;
x = drawString(_staticVboSource, x, y, 1, 1, 1, it->label.c_str());
char value[16];
snprintf(value, 16, " : %.2f", it->value);
drawString(_staticVboSource, x, y, 1, 1, 1, value);
// new line
y += FONT_CHAR_HEIGHT;
x = sx;
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_LEFT);
int nw = it->w / FONT_CHAR_WIDTH;
for (int i = 1; i < nw; ++i) {
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_MIDDLE);
}
drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_RIGHT);
int pos = (int)((it->value/float(it->max-it->min))*it->w);
drawChar(_staticVboSource, sx+pos, y, 1, 1, 0, FONT_SLIDER_CURSOR);
}
drawString(_staticVboSource, _windowWidth-80, _windowHeight-48, .5, .5, .5,
"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f");
drawString(_staticVboSource, _windowWidth-80, _windowHeight-32, .5, .5, .5,
"\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
}
示例14: configureCFW
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);
}
示例15: color565
void StatusScreen::render()
{
uint16_t stacolor = color565(51,153,204); //blue
fillScreen(stacolor);
makeRectangle(5,5, 225,310, BLACK, 4);
char* status = "STATUS";
drawString(225,50 , status, BLACK, stacolor, 2);
makeRectangle(85,15, 135, 300, BLACK, 3);
makeRectangle(15,15, 75, 300, BLACK, 3);
drawString(210, 20, "Adapters", BLACK, stacolor, 2);
drawString(85, 20, "Sensors ", BLACK, stacolor, 2);
makeRectangle(100,50, 50,45, BLUE, 3);
makeRectangle(100,95, 50,45, BLUE, 3);
makeRectangle(100,180, 50,45, BLUE, 3);
makeRectangle(100,225, 50,45, BLUE, 3);
makeRectangle(155,50, 50,45, BLUE, 3);
makeRectangle(155,95, 50,45, BLUE, 3);
makeRectangle(155,180, 50,45, BLUE, 3);
makeRectangle(155,225, 50,45, BLUE, 3);
drawString(120, 58, "-3-", BLACK, stacolor,2);
drawString(120, 188, "-4-", BLACK, stacolor, 2);
drawString(178, 58, "-1-", BLACK, stacolor, 2);
drawString(178, 188, "-2-", BLACK, stacolor, 2);
drawString(120, 113, "ON", BLACK, stacolor,2);
drawString(120, 233, "OFF", BLACK, stacolor, 2);
drawString(178 , 102, "AUT", BLACK, stacolor, 2);
drawString(178, 233, "OFF", BLACK, stacolor, 2);
drawString(20, 30 , "2. ", BLACK, stacolor, 2);
drawString(50, 30, "1. ", BLACK, stacolor, 2);
drawString(20, 55, "ENABLED", BLACK, stacolor, 2);
drawString(50, 55, "DISABLED", BLACK, stacolor, 2);
}