Exemplo n.º 1
0
static void draw(void)
{
	drawBackground(background);
	
	drawStars();
	
	blit(earthTexture, earth.x, earth.y, 1);
	
	drawFighters();
	
	drawEffects();
	
	blit(logo, SCREEN_WIDTH / 2, 50, 1);
	
	blit(pandoranWar, SCREEN_WIDTH / 2, 110, 1);
	
	drawText(10, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2016");
	drawText(SCREEN_WIDTH - 10, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "Version %.2f.%d", VERSION, REVISION);
	
	switch (show)
	{
		case SHOW_TITLE:
			drawWidgets("title");
			break;
			
		case SHOW_STATS:
			drawStats();
			break;
			
		case SHOW_OPTIONS:
			drawOptions();
			break;
	}
}
Exemplo n.º 2
0
// ****************************************************************************
void MolDraw2DSVG::clearDrawing() {
  std::string col = DrawColourToSVG(drawOptions().backgroundColour);
  d_os << "<rect";
  d_os << " style='opacity:1.0;fill:" << col << ";stroke:none'";
  d_os << " width='" << width() << "' height='" << height() << "'";
  d_os << " x='0' y='0'";
  d_os << "> </rect>\n";
}
Exemplo n.º 3
0
void MolDraw2D::drawMolecule(const ROMol &mol,
                             const vector<int> *highlight_atoms,
                             const vector<int> *highlight_bonds,
                             const map<int, DrawColour> *highlight_atom_map,
                             const map<int, DrawColour> *highlight_bond_map,
                             const std::map<int, double> *highlight_radii,
                             int confId) {
  if (drawOptions().clearBackground) {
    clearDrawing();
  }
  extractAtomCoords(mol, confId);
  extractAtomSymbols(mol);
  calculateScale();
  // make sure the font doesn't end up too large (the constants are empirical)
  if (scale_ <= 40.) {
    setFontSize(font_size_);
  } else {
    setFontSize(font_size_ * 30. / scale_);
  }
  // std::cerr << "scale: " << scale_ << " font_size_: " << font_size_
  //           << std::endl;
  if (drawOptions().includeAtomTags) {
    tagAtoms(mol);
  }
  if (drawOptions().atomRegions.size()) {
    BOOST_FOREACH (const std::vector<int> &region, drawOptions().atomRegions) {
      if (region.size() > 1) {
        Point2D minv = at_cds_[region[0]];
        Point2D maxv = at_cds_[region[0]];
        BOOST_FOREACH (int idx, region) {
          const Point2D &pt = at_cds_[idx];
          minv.x = std::min(minv.x, pt.x);
          minv.y = std::min(minv.y, pt.y);
          maxv.x = std::max(maxv.x, pt.x);
          maxv.y = std::max(maxv.y, pt.y);
        }
        Point2D center = (maxv + minv) / 2;
        Point2D size = (maxv - minv);
        size *= 0.2;
        minv -= size / 2;
        maxv += size / 2;
        setColour(DrawColour(.8, .8, .8));
        // drawEllipse(minv,maxv);
        drawRect(minv, maxv);
      }
    }
Exemplo n.º 4
0
int displayWelcome()
{
	renderWindow("\30" "\31" " Select option\t<ENTER> Accept selected option",
			"WELCOME",
			OPTION_WIDTH, WELCOME_OPT_COUNT,
			&startX, &startY);
	
	drawOptions();
	
	while (1)
	{
		uint8_t c;
		if (read(0, &c, 1) != 1) continue;
		
		if (c == 0x8B)
		{
			// up arrow
			if (selected != 0)
			{
				selected--;
				drawOptions();
			};
		}
		else if (c == 0x8C)
		{
			// down arrow
			if (selected != (WELCOME_OPT_COUNT-1))
			{
				selected++;
				drawOptions();
			};
		}
		else if (c == '\n')
		{
			break;
		};
	};
	
	return selected;
};
Exemplo n.º 5
0
void loop()
{
	if(deviceStatus == STOPPED)
	{
		if(LCD.getTouchActivity() == TOUCH_UP)
		{
			LCD.getTouchXY(x, y);
			if(oneMinuteButton.isClicked(x, y))
			{
				pumpEndMillis = millis() + 300;
				digitalWrite(VALVE_CONTROL1, LOW);
				digitalWrite(VALVE_CONTROL2, HIGH);
				initializePolling();
			}
			else if(fiveMinuteButton.isClicked(x, y))
			{
				pumpEndMillis = millis() + 300000;
				digitalWrite(VALVE_CONTROL1, LOW);
				digitalWrite(VALVE_CONTROL2, HIGH)
				initializePolling();
			}
			else if(tenMinuteButton.isClicked(x, y))
			{
				pumpEndMillis = millis() + 600000;
				digitalWrite(VALVE_CONTROL1, LOW);
				digitalWrite(VALVE_CONTROL2, HIGH);
				initializePolling();
			}
		}
	}
	else if(deviceStatus != STOPPED)
	{
		checkInput();
		readGPS();
		checkInput();
		readChip();
		checkInput();
		readTempHumid();
		checkInput();

		if(viewOptions)
		{
			drawOptions();
		}
		
		checkTime();
	}
}
Exemplo n.º 6
0
static void draw(void)
{
	drawBackground(background);

	blit(planetTexture, planet.x, planet.y, 1);

	drawStars();
	
	drawText(SCREEN_WIDTH / 2, 40, 28, TA_CENTER, colors.white, CHALLENGES_TEXT);
	drawText(SCREEN_WIDTH / 2, 83, 16, TA_CENTER, colors.lightGrey, COMPLETED_TEXT, game.completedChallenges, game.totalChallenges);
	drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, PAGE_TEXT, page + 1, (int)maxPages);

	drawChallenges();

	switch (show)
	{
		case SHOW_CHALLENGES:
			drawWidgets("challenges");
			break;

		case SHOW_MENU:
			drawMenu();
			break;

		case SHOW_STATS:
			drawStats();
			break;
			
		case SHOW_TROPHIES:
			drawTrophies();
			break;

		case SHOW_OPTIONS:
			drawOptions();
			break;
			
		case SHOW_FIGHTER_DB:
			drawFighterDatabase();
			break;
	}
}
Exemplo n.º 7
0
void MolDraw2D::doContinuousHighlighting(
    const ROMol &mol, const vector<int> *highlight_atoms,
    const vector<int> *highlight_bonds,
    const map<int, DrawColour> *highlight_atom_map,
    const map<int, DrawColour> *highlight_bond_map,
    const std::map<int, double> *highlight_radii) {
  int orig_lw = lineWidth();
  int tgt_lw = lineWidth() * 8;
  // try to scale lw to reflect the overall scaling:
  tgt_lw = max(
      orig_lw * 2,
      min(tgt_lw,
          (int)(scale_ / 25. * tgt_lw)));  // the 25 here is extremely empirical
  bool orig_fp = fillPolys();
  ROMol::VERTEX_ITER this_at, end_at;
  if (highlight_bonds) {
    boost::tie(this_at, end_at) = mol.getVertices();
    while (this_at != end_at) {
      int this_idx = mol[*this_at]->getIdx();
      ROMol::OEDGE_ITER nbr, end_nbr;
      boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get());
      while (nbr != end_nbr) {
        const Bond* bond = mol[*nbr];
        ++nbr;
        int nbr_idx = bond->getOtherAtomIdx(this_idx);
        if (nbr_idx < static_cast<int>(at_cds_.size()) && nbr_idx > this_idx) {
          if (std::find(highlight_bonds->begin(), highlight_bonds->end(),
                        bond->getIdx()) != highlight_bonds->end()) {
            DrawColour col = drawOptions().highlightColour;
            if (highlight_bond_map &&
                highlight_bond_map->find(bond->getIdx()) !=
                    highlight_bond_map->end()) {
              col = highlight_bond_map->find(bond->getIdx())->second;
            }
            setLineWidth(tgt_lw);
            Point2D at1_cds = at_cds_[this_idx];
            Point2D at2_cds = at_cds_[nbr_idx];
            drawLine(at1_cds, at2_cds, col, col);
          }
        }
      }
      ++this_at;
    }
  }
  if (highlight_atoms) {
    boost::tie(this_at, end_at) = mol.getVertices();
    while (this_at != end_at) {
      int this_idx = mol[*this_at]->getIdx();
      if (std::find(highlight_atoms->begin(), highlight_atoms->end(),
                    this_idx) != highlight_atoms->end()) {
        DrawColour col = drawOptions().highlightColour;
        if (highlight_atom_map &&
            highlight_atom_map->find(this_idx) != highlight_atom_map->end()) {
          col = highlight_atom_map->find(this_idx)->second;
        }
        Point2D p1 = at_cds_[this_idx];
        Point2D p2 = at_cds_[this_idx];
        double radius = 0.4;
        if (highlight_radii &&
            highlight_radii->find(this_idx) != highlight_radii->end()) {
          radius = highlight_radii->find(this_idx)->second;
        }
        Point2D offset(radius, radius);
        p1 -= offset;
        p2 += offset;
        setColour(col);
        setFillPolys(true);
        setLineWidth(1);
        drawEllipse(p1, p2);
      }
      ++this_at;
    }
  }
  setLineWidth(orig_lw);
  setFillPolys(orig_fp);
}
Exemplo n.º 8
0
void options(char ip[])
{
    int quit = 0;
    int menu_choice = 0;
    //fps
    struct timer_t2 fps;

    init_options();
    init_font();

    //wait for user to continue or exit
    while( quit != 1 )
    {
        //Start the frame timer
        timer_start(&fps);
        //While there are events to handle
        while( SDL_PollEvent( &event ) )
        {

            if( event.type == SDL_QUIT )
            {
                //exit
                clean_up();
                exit(0);
            }
            if( event.type == SDL_KEYDOWN )
            {
                switch(event.key.keysym.sym)
                {
                    case SDLK_ESCAPE:
                        quit = 1; break;
                }
            }

            mouse_over_options(event.button.x, event.button.y);

            if( event.type == SDL_MOUSEBUTTONDOWN)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        press_options(event.button.x, event.button.y);
                        break;
                }
            }


            if( event.type == SDL_MOUSEBUTTONUP)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        menu_choice = press_options(event.button.x, event.button.y);
                        break;
                }
            }

            switch(menu_choice)
            {
                case 1:
                    handle_input(event,ip);
                    printf("String in graphics.c (%s)\n",ip);
                    break;
                case 2:
                    quit = 1;
                    printf("Försöker bryta ut ur options\n");
                    break;
                default:
                    break;
            }
        }
        apply_letter(ip);
        apply_texture();

        startDraw();
        //draw menu
        drawOptions(SCREEN_WIDTH, SCREEN_HEIGHT);
        drawBack();
        endDraw();

        if( timer_get_ticks(&fps) < 1000 / FRAMES_PER_SECOND )
        {
            //delay the as much time as we need to get desired frames per second
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - timer_get_ticks(&fps) );
        }
    }
}