InspectorState pluginSelectorDo(PluginSelectorState *state) { if (Common_BtnDown(BTN_UP)) { state->cursor = (state->cursor - 1 + state->numplugins) % state->numplugins; } if (Common_BtnDown(BTN_DOWN)) { state->cursor = (state->cursor + 1) % state->numplugins; } if (Common_BtnDown(BTN_RIGHT)) { return PARAMETER_VIEWER; } drawTitle(); drawDSPList(state); return PLUGIN_SELECTOR; }
void draw() { background(224,224,224,255); //background(pLightGray); //background(aliceblue); // plot area as white box fill(255); rectMode(CORNERS); noStroke(); rect(plotX1, plotY1, plotX2, plotY2); drawTitle(); // plot the actual columnar data stroke(0x56, 0x79, 0xc1, 255); strokeWeight(5); drawDataPoints(currentColumn); drawYearLabels(); drawVolumeLabels(); drawAxisLabels(); }
void FBReaderNode::paint(ZLPaintContext &context, int vOffset) { if (!myIsInitialized) { init(); myIsInitialized = true; } removeAllHyperlinks(); drawCover(context, vOffset); drawTitle(context, vOffset); drawSummary(context, vOffset); int left = 0; int auxLeft = 0; for (std::vector<std::pair<shared_ptr<ZLRunnableWithKey>,bool> >::const_iterator it = myActions.begin(); it != myActions.end(); ++it) { if (it->first->makesSense()) { if (it->second) { drawHyperlink(context, auxLeft, vOffset, it->first, true); } else { drawHyperlink(context, left, vOffset, it->first); } } } }
/** * @brief * * @param * * @return */ static void drawLayer(screen scr, layer l) { int itr_x, itr_y; char c; int y_boundary = MIN(l->y + l->y_offset, scr->y); int x_boundary = MIN(l->x + l->x_offset, scr->x); if (!(l->mode & LYR_HIDDEN)){ for (itr_y = l->y_offset; itr_y < y_boundary; itr_y++){ for (itr_x = l->x_offset; itr_x < x_boundary; itr_x++){ if (itr_y >= 0 && itr_x >= 0 && itr_y - l->y_offset >= 0 && \ itr_x - l->x_offset >= 0 && (c = \ l->matrix[itr_y - l->y_offset][itr_x - l->x_offset]) != 0) scr->buffer[itr_y][itr_x] = c; } } if (l->mode & LYR_DRAW_MARGINS) drawMargins(scr, l); if (l->mode & LYR_DRAW_TITLE) drawTitle(scr, l); } }
void DateSelectionScreen::show() { int day = result.getDay(); int month = result.getMonth(); int year = result.getYear(); bool completed = false; do { cancelled = false; drawTitle(); cout << "(y)ear: " << year << endl; cout << "(m)onth: " << month << endl; cout << "(d)ay: " << day << endl; cout << "(f)inish selection" << endl; cout << "(c)ancel selection" << endl; string cmd = readCommand("[y,m,d,f,c] > "); if(cmd == "y") { string y = readCommand("year > "); stringstream conv(y); conv >> year; } else if(cmd == "m") { string m = readCommand("month > "); stringstream conv(m); conv >> month; }
void RunningDraw::drawTeams(bool start){ Settings* s = Settings::getInstance(); ofPushMatrix(); ofTranslate(Settings::getInstance()->getPlayerMargin(), Settings::getInstance()->getHeaderHeight()); vector<Team*> teams = running_model->getTeams(); std::vector<Team*>::const_iterator t; for(t=teams.begin(); t!=teams.end(); ++t){ (*t)->draw(start); ofTranslate(s->getWidth() - s->getPlayerMargin()*2, 0); ofScale(-1, 1); } ofPopMatrix(); if (start){ drawTeamScores(); ofSetColor(0); ofRect(s->getCentralImageX() - s->getPlayerCentralImageSeparation(), s->getHeaderHeight() , s->getCentralImageWidth() + 2 * s->getPlayerCentralImageSeparation(), s->getPlayerHeight()*2 + s->getPlayerSeparation()); } ofSetColor(255); if (start){ drawNavigate(); drawLateralBands(); drawTitle(s->getTitleImage()); } //drawGrid(); //drawGrid(); }
void testApp::draw(){ ofSetMinMagFilters(GL_NEAREST, GL_NEAREST); ofBackground(0); ofSetColor(255); if(playerCount == 0) { float rescale = ofMap(sin(ofGetElapsedTimef() * 5), -1, 1, .8, 1.2); ofSetColor(magenta); drawTitle("WAITING FOR PLAYER", rescale); } else if(playerCount == 1) { ofVec2f offset(ofRandomf(), ofRandomf()); offset *= 5; ofSetColor(cyan); ofPushMatrix(); ofTranslate(offset.x, offset.y); drawTitle("AWAITING CHALLENGER"); ofPopMatrix(); } else if(playerCount == 2) { for(int i = 0; i < projectiles.size(); i++) { projectiles[i].draw(); } ofSetColor(255); for(int i = 0; i < players.size(); i++) { if(players[i].life > 0) { ofPushMatrix(); ofTranslate((int) players[i].position.x, (int) players[i].position.y); ofScale(2, 2); if(players[i].position.x > ofGetWidth() / 2) { ofScale(-1, 1); } if(i == 0) { maskedDraw(ryu); } else { maskedDraw(ken); } ofPopMatrix(); } } } int winner = 0; if(playerCount == 2) { bool done = false; for(int i = 0; i < players.size(); i++) { drawLife(i); if(players[i].life <= 0) { done = true; } else { winner = i; } } if(done && !lastDone) { youWin.play(); } lastDone = done; } if(playerCount == 2 && lastDone) { bool flash = sin(2. * ofGetElapsedTimef() * TWO_PI) > 0; ofSetColor(flash ? yellow : 0); drawTitle("PLAYER " + ofToString(winner + 1) + " WINS"); } if(panel.getValueB("debug")) { ofSetColor(255); for(int i = 0; i < players.size(); i++) { ofCircle(players[i].position, 32); } } }
// the main function void _main(void) { unsigned int difficulty = NORMAL; short int key=0; short int keys[8]; unsigned int level_num = 1; unsigned short int score = 0; int done = 0; unsigned int money = 0; int cannon_level = 1; int missile_level = 0; char map[12][MAP_SIZE]; // seed the random numbers randomize(); // get the key masks getKeyMasks(keys); INT_HANDLER interrupt1 = GetIntVec(AUTO_INT_1); // this will save auto int 1 // draw title screen and wait for keypress GrayOn(); drawTitle(2); ngetchx(); //draw background title screen and menu drawTitle(1); drawWords(difficulty); POSITION pointer = {10,0}; drawPointer(pointer); // the menu loop while (1) { key = ngetchx(); if (key == KEY_ENTER && pointer.y != OPTIONS) { if (pointer.y == PLAY) break; if (pointer.y == HIGH_SCORES) printHiScores(); if (pointer.y == HELP) doHelp(); if (pointer.y == ABOUT) { SetIntVec(AUTO_INT_1,interrupt1); GrayOff(); exit(0); } GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawWords(difficulty); pointer=(POSITION) { 10,0 }; drawPointer(pointer); } if (key == KEY_LEFT && pointer.y == OPTIONS && difficulty < VERY_EASY) { difficulty+=1; GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawPointer(pointer); drawWords(difficulty); } if (key == KEY_RIGHT && pointer.y == OPTIONS && difficulty > IMPOSSIBLE) { difficulty-=1; GraySetAMSPlane(LIGHT_PLANE); clrscr(); GraySetAMSPlane(DARK_PLANE); clrscr(); drawTitle(1); drawPointer(pointer); drawWords(difficulty); } if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer); if (key == KEY_UP && pointer.y > 0) pointer.y--; if (key == KEY_DOWN && pointer.y < 4) pointer.y++; if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer); } key = 0; // turn off gray, so we can destroy auto-int-1 and not mess it up GrayOff(); // DESTROY auto-interrupt 1 so as not to mess up _rowread SetIntVec(AUTO_INT_1,DUMMY_HANDLER); // turn gray back on GrayOn(); // randomize the map randomMap(difficulty, map, level_num); //the main game loop while (!quit() && !done) { done = 0; int fin = 0; int win = 0; int forward = 0; int map_x_location = 0; int laser = 0; int justLaser = 0; int missile = 0; int justMissile = 0; int missileSlow = 2; POSITION laserPos; POSITION oldLaserPos; POSITION missilePos; POSITION oldMissilePos; POSITION oldShip; POSITION ShipPos = {0,5}; // we need to disable gray temporarily to do the shop screen... GrayOff(); SetIntVec(AUTO_INT_1, interrupt1); shop(&money, &cannon_level, &missile_level); SetIntVec(AUTO_INT_1, DUMMY_HANDLER); GrayOn(); // draws the level Draw_Map(map_x_location, map, ShipPos, laserPos, laser, missilePos, missile); // the loop for the action in the level while (!quit()) { // if the user has a missile out, deal with it if (missile && missileSlow == 2) { missileSlow = 1; oldMissilePos = missilePos; missilePos.x++; missilePos.y+=missile; if (missilePos.x > map_x_location + 20) missile = 0; if (missilePos.y < 0 || missilePos.y > 12) { missile = 0; eraseMissile(missilePos, map_x_location); } if (blowWall(missilePos,map)) { if (map[missilePos.y][missilePos.x] < 4) { map[missilePos.y][missilePos.x]-=3; if (map[missilePos.y][missilePos.x] == 0) { score++; money+=BLOCK_VALUE; } } if (map[missilePos.y][missilePos.x] < 0) map[missilePos.y][missilePos.x] = 0; missile = 0; justMissile = 0; Draw_Map(map_x_location,map,ShipPos,laserPos,laser,missilePos,missile); } // if the shot was just fired, then there wont be one to erase if (!justMissile && missile == 1) { moveMissile(oldMissilePos,missilePos,map_x_location); } else if (missile == 1) { drawMissile(missilePos,map_x_location); justMissile = 0; } else if (!justMissile && missile == -1) { moveUpMissile(oldMissilePos, missilePos, map_x_location); } else if (missile == -1) { drawUpMissile(missilePos, map_x_location); justMissile = 0; } } else { missileSlow++; } // if the user has a laser shot that is still going, continue it if (laser) { oldLaserPos = laserPos; laserPos.x++; if (laserPos.x > map_x_location + 20) laser=0; if (blowWall(laserPos,map)) { if (map[laserPos.y][laserPos.x] < 4) { map[laserPos.y][laserPos.x]-=cannon_level; if (map[laserPos.y][laserPos.x] <= 0) { score++; money+=BLOCK_VALUE; map[laserPos.y][laserPos.x] = 0; } } else if (map[laserPos.y][laserPos.x] == 4 && cannon_level == 4) { map[laserPos.y][laserPos.x] = 1; } laser = 0; justLaser = 0; Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile); } // if the shot was just fired, then there wont be one to erase if (!justLaser && laser) { moveLaser(oldLaserPos,laserPos,map_x_location); } else if (laser) { drawLaser(laserPos,map_x_location); justLaser = 0; } } // scroll the screen forward one block every (difficulty) time through the main loop if (forward == difficulty) { map_x_location++; ShipPos.x++; forward = 0; if (map_x_location >= MAP_SIZE - 20) { win = 1; level_num++; break; } // if you ran into a wall, quit if (detectWall(ShipPos,map)) { win = 1; score /= 2 ; break; } Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile); } else { forward++; } // if you ran into a wall, quit if (detectWall(ShipPos,map)) { win = 1; score = 0; break; } if (_rowread(~((short)(1<<1))) & (1<<6) && _rowread(~((short)(1<<2))) & (1<<6)) { win = 1; level_num++; break; } // get keypresses key = _rowread(ARROW_ROW); // if the user pressed right, move the ship right if (key & keys[RIGHT]) { oldShip = ShipPos; ShipPos.x++; if (ShipPos.x > map_x_location + 18) ShipPos.x--; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // If the user pressed left, move the ship left if (key & keys[LEFT]) { oldShip = ShipPos; ShipPos.x--; if (ShipPos.x < map_x_location) ShipPos.x++; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if the user pressed up, move the ship up if (key & keys[UP]) { oldShip = ShipPos; if (ShipPos.y - 1 < 0) { ShipPos.y = 0; } else { ShipPos.y--; } if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if the user pressed down, move the ship down if (key & keys[DOWN]) { oldShip = ShipPos; ShipPos.y++; if (ShipPos.y > 10) ShipPos.y = 10; if (!detectWall(ShipPos,map)) { moveShip(oldShip,ShipPos,map_x_location); } else { win = 1; score = 0; break; } } // if 2nd was pushed, fire the laser if (key & keys[SECOND]) { if (!laser) { justLaser = 1; laser = 1; laserPos.x = ShipPos.x + 1; laserPos.y = ShipPos.y; } } // if diamond was pushed fire the downward missiles if (key & keys[DIAMOND]) { if (missile_level == 3 || missile_level == 1) { if (!missile) { justMissile = 1; missile = 1; missileSlow = 2; missilePos.x = ShipPos.x; missilePos.y = ShipPos.y; } } } // if shift was pushed fire the upward missiles if (key & keys[SHIFT]) { if (missile_level == 2 || missile_level == 3) { if (!missile) { justMissile = 1; missile = -1; missileSlow = 2; missilePos.x = ShipPos.x; missilePos.y = ShipPos.y; } } } /*if (key & keys[ALPHA]) { score += 10; }*/ // slow down the program because _rowread is too fast delay(); } // back to the overall game loop if (win) { if (level_num <= LEVEL_NUM) { won(difficulty, map, level_num); } else { fin = 1; break; } } } // the user left, either by winning or quitting, so make sure everything is reset so the calc will be fine GrayOff(); SetIntVec(AUTO_INT_1,interrupt1); hiScoresGo(score, difficulty, level_num); }
void SDL_GUI_MainWindow::draw(SDL_Surface* targetSurface_in, unsigned int offsetX_in, unsigned int offsetY_in) { RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::draw")); // sanity check(s) SDL_Surface* target_surface = (targetSurface_in ? targetSurface_in : inherited::screen_); ACE_ASSERT(target_surface); ACE_ASSERT(static_cast<int>(offsetX_in) <= target_surface->w); ACE_ASSERT(static_cast<int>(offsetY_in) <= target_surface->h); // *NOTE*: drawBorder() does its own locking // step1: draw borders drawBorder(target_surface, offsetX_in, offsetY_in); lock(); // step2: draw title drawTitle(myTitleFont, title_, target_surface); // step3: fill central area SDL_Rect prev_clip_rect, clip_rect, dirty_region; SDL_GetClipRect (target_surface, &prev_clip_rect); clip_rect.x = static_cast<Sint16> (offsetX_in + borderLeft_); clip_rect.y = static_cast<Sint16> (offsetY_in + borderTop_); clip_rect.w = static_cast<Uint16> (target_surface->w - offsetX_in - (borderLeft_ + borderRight_)); clip_rect.h = static_cast<Uint16> (target_surface->h - offsetY_in - (borderTop_ + borderBottom_)); if (!SDL_SetClipRect (target_surface, &clip_rect)) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"), ACE_TEXT(SDL_GetError()))); // clean up unlock(); return; } // end IF RPG_Graphics_InterfaceElementsConstIterator_t iterator; iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_CENTER); ACE_ASSERT(iterator != myElementGraphics.end()); for (unsigned int i = (offsetY_in + borderTop_); i < (target_surface->h - borderBottom_); i += (*iterator).second->h) for (unsigned int j = (offsetX_in + borderLeft_); j < (target_surface->w - borderRight_); j += (*iterator).second->w) { RPG_Graphics_Surface::put(std::make_pair(j, i), *(*iterator).second, target_surface, dirty_region); invalidate (clip_rect); } // end FOR if (!SDL_SetClipRect(target_surface, &prev_clip_rect)) { ACE_DEBUG((LM_ERROR, ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"), ACE_TEXT(SDL_GetError()))); // clean up unlock(); return; } // end IF unlock(); // init clipping clip(target_surface, offsetX_in, offsetY_in); // step4: realize hotspots (and any other children) for (RPG_Graphics_WindowsIterator_t iterator = children_.begin(); iterator != children_.end(); iterator++) { try { (*iterator)->draw(target_surface, offsetX_in, offsetY_in); } catch (...) { ACE_DEBUG((LM_ERROR, ACE_TEXT("caught exception in RPG_Graphics_IWindow::draw(), continuing\n"))); } } // end FOR // restore previous clipping area unclip(target_surface); // remember position of last realization lastAbsolutePosition_ = std::make_pair(offsetX_in, offsetY_in); }
void runCredits(SDL_Surface* screen) { switch(cm->state) { case MSGSTATE_TITLE_SLIDING_IN: cm->rTitle.x -= 10; if( cm->rTitle.x <= (HSCREENW-(cm->surfTitle->w/2)) ) { cm->rTitle.x=(HSCREENW-(cm->surfTitle->w/2)); cm->stateTicks += getTicks(); //wait 250 ms if(cm->stateTicks >= 250) { cm->state=MSGSTATE_NAME_SLIDING_IN; cm->stateTicks=0; } } drawTitle(screen, cm); break; case MSGSTATE_NAME_SLIDING_IN: //Draw title drawTitle(screen, cm); //Slide in name cm->nameWaving.x += 7; if( cm->nameWaving.x >= ( HSCREENW-cm->nameWaving.img->w/2 ) ) { cm->nameWaving.x = ( HSCREENW-cm->nameWaving.img->w/2 ); cm->state=MSGSTATE_NAME_DECREASE_WAVE; } waveImg( &cm->nameWaving ); break; case MSGSTATE_NAME_DECREASE_WAVE: //Draw title SDL_BlitSurface( cm->surfTitle, 0, screen, &cm->rTitle ); cm->stateTicks += getTicks(); if(cm->stateTicks > 0) { cm->stateTicks=0; cm->nameWaving.amount--; if(cm->nameWaving.amount==0) { cm->stateTicks=0; cm->state=MSGSTATE_NAME_SHAKING; //Set r.x=cm->nameWaving.x; r.y=cm->nameWaving.y; } } waveImg( &cm->nameWaving ); break; case MSGSTATE_NAME_SHAKING: if(cm->stateTicks<500) SDL_BlitSurface( cm->surfTitle, 0, screen, &cm->rTitle ); //shake cm->nWander.x=((rand()%6000)-3000)/1000; cm->nWander.y=((rand()%4000)-2000)/1000; if( abs(cm->nameWaving.x - (r.x+cm->nWander.x)) > 5) cm->nWander.x *=-1; if( abs(cm->nameWaving.y - (r.y+cm->nWander.y)) > 3) cm->nWander.y *=-1; r.x += cm->nWander.x; r.y += cm->nWander.y; if(cm->stateTicks <1500) SDL_BlitSurface( cm->nameWaving.img, 0, screen, &r ); cm->stateTicks += getTicks(); if(cm->stateTicks >= 500 && cm->stateTicks-getTicks() <= 500) { ps.layer=PSYS_LAYER_TOP; ps.vel=200; ps.life=1000; ps.lifeVar=500; spawnParticleSystem( &ps ); spawnParticleSystem( &ps ); spawnParticleSystem( &ps ); spawnParticleSystem( &ps ); } else if(cm->stateTicks >= 1500 && cm->stateTicks-getTicks() <= 1500) { ps.layer=PSYS_LAYER_TOP; ps.vel=400; ps.life=1500; ps.lifeVar=500; ps.x=cm->nameWaving.x; ps.y=cm->nameWaving.y; ps.srcImg=cm->nameWaving.img; ps.srcRect.w=cm->nameWaving.img->w; ps.srcRect.h=cm->nameWaving.img->h; spawnParticleSystem( &ps ); spawnParticleSystem( &ps ); } else if(cm->stateTicks > 3000) { //Next cm->state=MSGSTATE_NEXT_MSG; } break; case MSGSTATE_NEXT_MSG: //Update current msg currentMsgIndex++; if(currentMsgIndex == msgList->count) currentMsgIndex=0; setCurrent(); break; }; }
int menu_more() { int i = 0; menu_index = 0; while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_DOWN) { menu_index++; if (menu_index >= menu_count) menu_index = 0; } if (kDown & KEY_UP) { menu_index--; if (menu_index < 0) menu_index = menu_count - 1; } if (kDown & KEY_A) { if (menu_index == 0 && menu_choose() == 0) { return 0; } else if (menu_index == 1 && menu_netloader() == 0) { return 0; } else if (menu_index == 2) { menu_config(); } else if (menu_index == 3) { reboot(); } else if (menu_index == 4) { poweroff(); } } if (kDown & KEY_B) { return -1; } drawBg(); drawTitle("*** Select an option ***"); for (i = 0; i < menu_count; i++) { drawItem(i == menu_index, 16 * i, menu_item[i]); } // draw "help" switch (menu_index) { case 0: drawInfo("Browse for a file to boot or add a boot entry"); break; case 1: drawInfo("Netload a file (3dsx) from the computer with 3dslink"); break; case 2: drawInfo("Edit boot settings"); break; case 3: drawInfo("Reboot the 3ds..."); break; case 4: drawInfo("Shutdown the 3ds..."); break; default: break; } gfxSwap(); } return -1; }
void pick_file(file_s *picked, const char *path) { picker = malloc(sizeof(picker_s)); get_dir(path); // key repeat timer static time_t t_start = 0, t_end = 0, t_elapsed = 0; while (aptMainLoop()) { hidScanInput(); u32 kHeld = hidKeysHeld(); u32 kDown = hidKeysDown(); if (hidKeysUp()) { time(&t_start); // reset held timer } if (kDown & KEY_DOWN) { picker->file_index++; if (picker->file_index >= picker->file_count) picker->file_index = 0; time(&t_start); } else if (kHeld & KEY_DOWN) { time(&t_end); t_elapsed = t_end - t_start; if (t_elapsed > 0) { picker->file_index++; if (picker->file_index >= picker->file_count) picker->file_index = 0; svcSleep(100); } } if (kDown & KEY_UP) { picker->file_index--; if (picker->file_index < 0) picker->file_index = picker->file_count - 1; time(&t_start); } else if (kHeld & KEY_UP) { time(&t_end); t_elapsed = t_end - t_start; if (t_elapsed > 0) { picker->file_index--; if (picker->file_index < 0) picker->file_index = picker->file_count - 1; svcSleep(100); } } if (kDown & KEY_A) { if (picker->file_count > 0) { int index = picker->file_index; if (!picker->files[index].isDir) { if (confirm(0, "Launch \"%s\" ?", picker->files[index].name)) { strncpy(picked->name, picker->files[index].name, 512); strncpy(picked->path, picker->files[index].path, 512); picked->isDir = picker->files[index].isDir; picked->size = picker->files[index].size; break; } } else { get_dir(picker->files[index].path); } } } else if (kDown & KEY_X) { int index = picker->file_index; if (!picker->files[index].isDir) { const char *ext = get_filename_ext(picker->files[index].name); if (strcasecmp(ext, "3dsx") == 0) { if (confirm(3, "Add entry to boot menu: \"%s\" ?", picker->files[index].name)) { if (config->count > CONFIG_MAX_ENTRIES - 1) { debug("Maximum entries reached (%i)\n", CONFIG_MAX_ENTRIES); } else if (configAddEntry(picker->files[index].name, picker->files[index].path, 0) == 0) { debug("Added entry: %s\n", picker->files[index].name); } else { debug("Error adding entry: %s\n", picker->files[index].name); } } } } } else if (kDown & KEY_B) { // exit if we can't go back if (strlen(picker->now_path) <= 1) break; // remove slash if needed if (end_with(picker->now_path, '/')) picker->now_path[strlen(picker->now_path) - 1] = '\0'; // build path char *slash = strrchr(picker->now_path, '/'); if (slash == NULL) break; int len = (int) (slash - picker->now_path); picker->now_path[len] = '\0'; // enter new dir get_dir(picker->now_path); } drawBg(); drawTitle("*** Select a file ***"); int i, y = 0; int page = picker->file_index / MAX_LINE; for (i = page * MAX_LINE; i < page * MAX_LINE + MAX_LINE; i++) { if (i >= picker->file_count) break; drawItemN(i == picker->file_index, 47, 16 * i, picker->files[i].name); if (i == picker->file_index && !picker->files[i].isDir) { drawInfo("Press (A) to launch\nPress (X) to add to boot menu"); } y++; } gfxSwap(); } free(picker); }
void TButton::drawState(Boolean down) { ushort cButton, cShadow; char ch; int i; TDrawBuffer b; if( (state & sfDisabled) != 0 ) cButton = getColor(0x0404); else { cButton = getColor(0x0501); if( (state & sfActive) != 0 ) if( (state & sfSelected) != 0 ) cButton = getColor(0x0703); else if( amDefault ) cButton = getColor(0x0602); } cShadow = getColor(8); int s = size.x-1; int T = size.y / 2 - 1; for( int y = 0; y <= size.y-2; y++ ) { b.moveChar( 0, ' ', cButton, size.x ); b.putAttribute( 0, cShadow ); if( down ) { b.putAttribute( 1, cShadow ); ch = ' '; i = 2; } else { b.putAttribute( s, cShadow ); if( showMarkers == True ) ch = ' '; else { if( y == 0 ) b.putChar( s, shadows[0] ); else b.putChar( s, shadows[1] ); ch = shadows[2]; } i = 1; } if( y == T && title != 0 ) drawTitle( b, s, i, cButton, down ); if( showMarkers && !down ) { b.putChar( 1, markers[0] ); b.putChar( s-1, markers[1] ); } writeLine( 0, y, size.x, 1, b ); } b.moveChar( 0, ' ', cShadow, 2 ); b.moveChar( 2, ch, cShadow, s-1 ); writeLine( 0, size.y-1, size.x, 1, b ); }
void PuzzleWin::mainDraw() { PuzzleGame *game; std::string titlePic("Choose your Picture"); std::string titleDiff("Choose your Difficulty"); sf::Event event; sf::Event last; bool isIn = true; std::list<sf::Sprite*> spr; getWindow().clear(); if (getPicSet() == false) { drawTitle(titlePic); getWindow().display(); setPicSet(true); loadPic(spr); getWindow().display(); sleep(1); while (isIn == true) { getWindow().pollEvent(event); if (event.type != 15 && event.type != 10) isIn = gestEvent(event); if (event.type != 10 && last.type == 10) isIn = gestMove(last); last = event; drawTitle(titlePic); drawPic(spr); getWindow().display(); usleep(40000); } } else if (getDiffSet() == false) { drawTitle(titleDiff); getWindow().display(); drawDiff(); setDiffSet(true); while (isIn == true) { getWindow().pollEvent(event); if (event.type != 15 && event.type != 10) isIn = gestEvent(event); if (event.type != 10 && last.type == 10) isIn = gestMove(last); last = event; drawTitle(titleDiff); getWindow().display(); usleep(40000); } this->setType(GAME); } else { game = new PuzzleGame(getWindow()); game->mainGame(_pic, _diff); setPicSet(false); setDiffSet(false); this->setType(GAME); } }
void KWMThemeClient::paintEvent( QPaintEvent *) { QPainter p; p.begin(widget()); int x,y; // first the corners int w1 = framePixmaps[FrameTopLeft]->width(); int h1 = framePixmaps[FrameTopLeft]->height(); if (w1 > width()/2) w1 = width()/2; if (h1 > height()/2) h1 = height()/2; p.drawPixmap(0,0,*framePixmaps[FrameTopLeft], 0,0,w1, h1); int w2 = framePixmaps[FrameTopRight]->width(); int h2 = framePixmaps[FrameTopRight]->height(); if (w2 > width()/2) w2 = width()/2; if (h2 > height()/2) h2 = height()/2; p.drawPixmap(width()-w2,0,*framePixmaps[FrameTopRight], framePixmaps[FrameTopRight]->width()-w2,0,w2, h2); int w3 = framePixmaps[FrameBottomLeft]->width(); int h3 = framePixmaps[FrameBottomLeft]->height(); if (w3 > width()/2) w3 = width()/2; if (h3 > height()/2) h3 = height()/2; p.drawPixmap(0,height()-h3,*framePixmaps[FrameBottomLeft], 0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3); int w4 = framePixmaps[FrameBottomRight]->width(); int h4 = framePixmaps[FrameBottomRight]->height(); if (w4 > width()/2) w4 = width()/2; if (h4 > height()/2) h4 = height()/2; p.drawPixmap(width()-w4,height()-h4,*(framePixmaps[FrameBottomRight]), framePixmaps[FrameBottomRight]->width()-w4, framePixmaps[FrameBottomRight]->height()-h4, w4, h4); QPixmap pm; QWMatrix m; int n,s,w; //top pm = *framePixmaps[FrameTop]; if (pm.width() > 0){ s = width()-w2-w1; n = s/pm.width(); w = n>0?s/n:s; m.reset(); m.scale(w/(float)pm.width(), 1); pm = pm.xForm(m); x = w1; while (1){ if (pm.width() < width()-w2-x){ p.drawPixmap(x,maxExtent-pm.height()-1, pm); x += pm.width(); } else { p.drawPixmap(x,maxExtent-pm.height()-1, pm, 0,0,width()-w2-x,pm.height()); break; } } } //bottom pm = *framePixmaps[FrameBottom]; if (pm.width() > 0){ s = width()-w4-w3; n = s/pm.width(); w = n>0?s/n:s; m.reset(); m.scale(w/(float)pm.width(), 1); pm = pm.xForm(m); x = w3; while (1){ if (pm.width() < width()-w4-x){ p.drawPixmap(x,height()-maxExtent+1,pm); x += pm.width(); } else { p.drawPixmap(x,height()-maxExtent+1,pm, 0,0,width()-w4-x,pm.height()); break; } } } //left pm = *framePixmaps[FrameLeft]; if (pm.height() > 0){ s = height()-h3-h1; n = s/pm.height(); w = n>0?s/n:s; m.reset(); m.scale(1, w/(float)pm.height()); pm = pm.xForm(m); y = h1; while (1){ if (pm.height() < height()-h3-y){ p.drawPixmap(maxExtent-pm.width()-1, y, pm); y += pm.height(); } else { p.drawPixmap(maxExtent-pm.width()-1, y, pm, 0,0, pm.width(), height()-h3-y); break; } } } //right pm = *framePixmaps[FrameRight]; if (pm.height() > 0){ s = height()-h4-h2; n = s/pm.height(); w = n>0?s/n:s; m.reset(); m.scale(1, w/(float)pm.height()); pm = pm.xForm(m); y = h2; while (1){ if (pm.height() < height()-h4-y){ p.drawPixmap(width()-maxExtent+1, y, pm); y += pm.height(); } else { p.drawPixmap(width()-maxExtent+1, y, pm, 0,0, pm.width(), height()-h4-y); break; } } } drawTitle(p); QColor c = widget()->colorGroup().background(); // KWM evidently had a 1 pixel border around the client window. We // emulate it here, but should be removed at some point in order to // seamlessly mesh widget themes p.setPen(c); p.drawRect(maxExtent-1, maxExtent-1, width()-(maxExtent-1)*2, height()-(maxExtent-1)*2); // We fill the area behind the wrapped widget to ensure that // shading animation is drawn as smoothly as possible QRect r(layout->cellGeometry(2, 1)); p.fillRect( r.x(), r.y(), r.width(), r.height(), c); p.end(); }
void MainMenu::show() { bool quit = false; do { stringstream cmdstring; //cmdstring << "["; const User* currentUser = app->getCurrentUser(); drawTitle(); cout << "Logged in as: " << currentUser->getName() << endl; UserLevel level = currentUser ->getLevel(); if(level == UserLevel::Guest) { cout << "(r)egister" << endl; cout << "(l)ist offers" << endl; cmdstring << ",r,l"; } else { cout << "add (a)dvert" << endl; cout << "(e)dit advert" << endl; cout << "(d)elete advert" << endl; cout << "(l)ist adverts" << endl; cmdstring << ",a,e,d,l"; if(level == UserLevel::Reviewer || level == UserLevel::Admin) { cout << "(l)ist (a)ll adverts" << endl; cout << "(r)eview advert" << endl; cout << "add (n)ewspaper" << endl; cout << "(e)dit (n)ewspaper" << endl; cout << "(d)elete (n)ewspaper" << endl; cmdstring << ",r,n,en"; } cout << "(l)ist (n)ewspaper" << endl; cmdstring << ",ln"; if(level == UserLevel::Admin) { cout << "(a)dd (u)ser" << endl; cout << "(e)dit (u)ser" << endl; cout << "(d)elete (u)ser" << endl; cmdstring << ",au,eu,du"; } } cout << "(q)uit" << endl; cmdstring << ",q] > "; string prompt = cmdstring.str(); prompt[0] = '['; string cmd = readCommand(prompt); if(cmd == "q") { quit = true; }else{ if(level == UserLevel::Guest) { if(cmd == "r") { app->registerUser(); }else if(cmd == "l") { app->listNewspapers(); } }else{ if(cmd == "a") { app->addAdvert(); }else if(cmd == "e") { app->editAdvert(); }else if(cmd == "d") { app->deleteAdvert(); }else if(cmd == "l") { app->listAdvert(); }else if(cmd == "ln") { app->listNewspapers(); } if(level == UserLevel::Reviewer || level == UserLevel::Admin) { if(cmd == "r") { app->reviewAdvert(); }else if(cmd == "n") { app->addNewspaper(); }else if(cmd == "en") { app->editNewspaper(); }else if(cmd == "dn") { app->deleteNewspaper(); }else if(cmd == "la") { app->listAllAdvert(); } } if(level == UserLevel::Admin) { if(cmd == "au") { app->addUser(); }else if(cmd == "eu") { app->editUser(); }else if(cmd == "du") { app->deleteUser(); } } } } }while(!quit); }
} QList<Atom> atomList = createAtomList( rootItem, mSplitLayer ); setColumns( atomList ); double maxColumnWidth = 0; if ( mEqualColumnWidth ) { foreach ( Atom atom, atomList ) { maxColumnWidth = qMax( atom.size.width(), maxColumnWidth ); } } QSizeF titleSize = drawTitle(); // Using mGroupSpace as space between legend title and first atom in column double columnTop = mBoxSpace + titleSize.height() + mGroupSpace; QPointF point( mBoxSpace, columnTop ); bool firstInColumn = true; double columnMaxHeight = 0; double columnWidth = 0; int column = 0; foreach ( Atom atom, atomList ) { if ( atom.column > column ) { // Switch to next column if ( mEqualColumnWidth ) {
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; int move = 30; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case ID_FILE_NEW: gameOver();//Runs gameOver, so gameover gets set to false, and starts our game over. break; case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); DrawEnclosure(hWnd, hdc);//Draws our background, and Rectangle enclosure. DrawBlocks(hWnd, hdc);//Draws falling blocks and checks for collisions. drawUser(hWnd, hdc);//Draws the user's block. drawTitle(hWnd, hdc);//Draws the level, and updates the speed of the falling block. EndPaint(hWnd, &ps); break; case WM_TIMER: InvalidateRect(hWnd, NULL, true); break; case WM_KEYDOWN: switch (wParam) { case VK_LEFT://If the left arrow key is pressed. moveLeft();//Moves the user's block left. break; case VK_RIGHT://If the right arrow key is pressed. moveRight();//Moves the user's block right. break; } InvalidateRect(hWnd, NULL, TRUE); UpdateWindow(hWnd); return 0; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }