Ejemplo n.º 1
0
std::map<std::string, string_map> tlobby_main::make_game_row_data(const game_info& game)
{
	std::map<std::string, string_map> data;

	std::string color_string;
	if(game.vacant_slots > 0) {
		color_string = (game.reloaded || game.started) ? "yellow" : "green";
	} else {
		color_string = game.observers ? "#ddd" : "red";
	}

	if(!game.have_era && (game.vacant_slots > 0 || game.observers)) {
		color_string = "#444";
	}

	add_label_data(data, "status", colorize(game.status, color_string));
	add_label_data(data, "name",   colorize(game.name, color_string));

	add_label_data(data, "era",             colorize(game.era, "#a69275"));
	add_label_data(data, "era_short",       game.era_short);
	add_label_data(data, "mods",            colorize(game.mod_info, "#a69275"));
	add_label_data(data, "map_info",        game.map_info);
	add_label_data(data, "scenario",        game.scenario);
	add_label_data(data, "map_size_text",   game.map_size_info);
	add_label_data(data, "time_limit",      game.time_limit);
	add_label_data(data, "gold_text",       game.gold);
	add_label_data(data, "xp_text",         game.xp);
	add_label_data(data, "vision_text",     game.vision);
	add_label_data(data, "time_limit_text", game.time_limit);
	add_label_data(data, "status",          game.status);

	if(game.observers) {
		add_label_data(data, "observer_icon", "misc/eye.png");
		add_tooltip_data(data, "observer_icon", _("Observers allowed"));
	} else {
		add_label_data(data, "observer_icon", "misc/no_observer.png");
		add_tooltip_data(data, "observer_icon", _("Observers not allowed"));
	}

	std::string vision_icon;
	if(game.fog) {
		vision_icon = game.shroud ? "misc/vision-fog-shroud.png" : "misc/vision-fog.png";
	} else {
		vision_icon = game.shroud ? "misc/vision-shroud.png" : "misc/vision-none.png";
	}

	add_label_data(data, "vision_icon", vision_icon);
	add_tooltip_data(data, "vision_icon", game.vision);
	return data;
}
Ejemplo n.º 2
0
std::string tricolorization_(
    std::vector<int> red,
    std::vector<int> other,
    const std::vector<int>& data)
{
    if (red.size() == 0) {
        return "";
    }

    if (checkSelectedIsHalfOfOther(red, other)) {
        std::string otherColor = twocolorization(other);
        if (otherColor != "") {
            return colorize(other, data, 'R', otherColor);
        }
    }

    for (int i = 0; i < red.size(); ++i) {
        std::vector<int> nextRed(red);
        std::vector<int> nextOther(other);

        std::swap(nextRed[i], nextRed.back());
        nextRed.pop_back();
        nextOther.push_back(red[i]);
        std::string result = tricolorization_(nextRed, nextOther, data);
        if (result != "") {
            return result;
        }
    }

    return "";
}
Ejemplo n.º 3
0
QImage KIconEffect::apply(const QImage &img, int effect, float value,
                          const QColor &col, const QColor &col2, bool trans) const
{
    QImage image = img;
    if (effect >= LastEffect) {
        qWarning() << "Illegal icon effect: " << effect;
        return image;
    }
    if (value > 1.0) {
        value = 1.0;
    } else if (value < 0.0) {
        value = 0.0;
    }
    switch (effect) {
    case ToGray:
        toGray(image, value);
        break;
    case DeSaturate:
        deSaturate(image, value);
        break;
    case Colorize:
        colorize(image, col, value);
        break;
    case ToGamma:
        toGamma(image, value);
        break;
    case ToMonochrome:
        toMonochrome(image, col, col2, value);
        break;
    }
    if (trans == true) {
        semiTransparent(image);
    }
    return image;
}
Ejemplo n.º 4
0
void CtrlrMIDIBuffer::resized()
{
    //[UserPreResize] Add your own custom resize code here..
    //[/UserPreResize]

    documentEditor->setBounds (0, 88, getWidth() - 0, getHeight() - 104);
    bufferSource->setBounds (8, 8, proportionOfWidth (0.4000f), 24);
    label->setBounds (8, 40, 32, 16);
    prefixLengthLabel->setBounds (8, 56, 32, 24);
    nameLengthLabel->setBounds (80, 56, 32, 24);
    dataOffsetLabel->setBounds (120, 56, 32, 24);
    suffixLengthLabel->setBounds (192, 56, 32, 24);
    label7->setBounds (48, 40, 64, 16);
    label8->setBounds (120, 40, 64, 16);
    label9->setBounds (192, 40, 32, 16);
    nameOffsetLabel->setBounds (48, 56, 32, 24);
    dataLengthLabel->setBounds (152, 56, 32, 24);
    reloadButton->setBounds (8 + proportionOfWidth (0.4000f), 8, proportionOfWidth (0.1537f), 24);
    status->setBounds (0, getHeight() - 16, getWidth() - 0, 16);
    //[UserResized] Add your own custom resize handling here..
	const int columnsVisible	= documentEditor->getNumColumnsOnScreen();

	if (lastNumberOfColumns != columnsVisible)
	{
		lastNumberOfColumns = columnsVisible;
		colorize();
	}
    //[/UserResized]
}
Ejemplo n.º 5
0
void ImageView::refresh()
{
	if (isAnimation) {
		return;
	}

	if (GData::scaledWidth) {
		displayImage = origImage.scaled(GData::scaledWidth, GData::scaledHeight,
											Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
	} else {
		displayImage = origImage;
	}

	transform();

	if (GData::colorsActive || GData::keepTransform) {
		colorize();
	}

	if (mirrorLayout) {
		mirror();
	}

	displayPixmap = QPixmap::fromImage(displayImage);
	imageLabel->setPixmap(displayPixmap);
	resizeImage();
}
Ejemplo n.º 6
0
// callback
float *compute (unsigned iterations)
{
  static int step = 0;
   reset_change();
  for (unsigned i = 0; i < iterations; i++)
    {
        step++;
        for (int y = 0; y < DIM; y++)
	    {
	        for (int x = 0; x < DIM; x++)
	        {
	            if (ocean[x][y] >= 4)
		        {
		  
		            ocean[x+1][y] += 1;		  
		            ocean[x-1][y] += 1;
		            ocean[x][y+1] += 1;
		            ocean[x][y-1] += 1;

                    ocean[x][y] -= 4;
                    changed[x][y] = 1;
		        }
	        }
	    }
    }
//  return DYNAMIC_COLORING; // altitude-based coloring
    colorize();
    return couleurs;
}
Ejemplo n.º 7
0
QString MessageFormatter::prettyUser(const IrcSender& sender)
{
    const QString name = sender.name();
    if (sender.isValid())
        return colorize(name);
    return name;
}
Ejemplo n.º 8
0
int
write_to_descriptor (DESCRIPTOR_DATA * d, const char *txt)
{
  int sofar;
  int thisround;
  int total;
  char ansi_buf[MAX_STRING_LENGTH * 2];

  colorize (txt, ansi_buf, d);

  total = strlen (ansi_buf);
  sofar = 0;

  do
    {
      thisround = write (d->hSocketFD, ansi_buf + sofar, total - sofar);
      if (thisround < 0)
	{
	  perror ("Write to socket");
	  return -1;
	}

      sofar += thisround;

    }
  while (sofar < total);

  return 0;
}
Ejemplo n.º 9
0
std::string twocolorization_(
    std::vector<int> green,
    std::vector<int> other,
    const std::vector<int> data)
{
    if (green.size() == 0) {
        return "";
    }

    if (checkSelectedIsEqualToOther(green, other)) {
        std::string color(green.size(), 'G');
        return colorize(green, data, 'B', color);
    }

    for (int i = 0; i < green.size(); ++i) {
        std::vector<int> nextGreen(green);
        std::vector<int> nextOther(other);

        std::swap(nextGreen[i], nextGreen.back());
        nextGreen.pop_back();
        nextOther.push_back(green[i]);
        std::string result = twocolorization_(nextGreen, nextOther, data);
        if (result != "") {
            return result;
        }
    }

    return "";
}
Ejemplo n.º 10
0
void Point::setPoint(float x, float y, float z) {
	point[0] = x;
	point[1] = y;
	point[2] = z;
	modified = true;
	
	colorize();
}
Ejemplo n.º 11
0
void TextBuffer::colorizeAll()
{
  if (testFlag(EditFlags::HiliteOff) ||
      !syntax->highlighting())
    return;
  else
    colorize(bufferMin(), bufferMax(), false);
}
Ejemplo n.º 12
0
 string_t reporter::mebbe_colorize(const Color color, const string_t &string) const {
   if (options_.colorize) {
     return colorize(color, string);
   }
   else {
     return string;
   }
 }
Ejemplo n.º 13
0
t_hs		create_prompt(void)
{
  t_hs		user;
  t_hs		host;
  t_hs		pwd;
  t_hs		prompt;

  user = env_get_default(hs("USER"), hs("nobody"));
  pwd = env_get_default(hs("PWD"), hs(""));
  host = get_hostname();
  if (env_contains(hs("HOME")))
    pwd = format_pwd(pwd, env_get(hs("HOME")));
  prompt = hs_format("%hs%hs%hs:%hs$ ",
		     colorize("red bold", user),
		     colorize("red bold", hs("@")),
		     colorize("red bold", host),
		     colorize("blue bold", pwd));
  return (prompt);
}
Ejemplo n.º 14
0
unsigned char *tx(float *points,
                  float *weights,
                  int cPoints,
                  int w, int h,
                  int dotsize,
                  int *scheme,
                  unsigned char *pix_color,
                  int opacity,
                  int boundsOverride,
                  float minX, float minY, float maxX, float maxY)
{
    unsigned char *pixels_bw = NULL;

    //basic sanity checks to keep from segfaulting
    if (NULL == points || NULL == weights || NULL == scheme || NULL == pix_color ||
        w <= 0 || h <= 0 || cPoints <= 1 || opacity < 0 || dotsize <= 0)
    {
        fprintf(stderr, "Invalid parameter; aborting.\n");
        return NULL;
    }


    DOTSIZE = dotsize;
    WIDTH = w;
    HEIGHT = h;

    // get min/max x/y values from point list
    if (boundsOverride == 1)
    {
        MAX_X = maxX; MIN_X = minX;
        MAX_Y = maxY; MIN_Y = minY;
    }
    else
    {
        getBounds(points, cPoints);
    }

    #ifdef DEBUG
    printf("min: (%.2f, %.2f) max: (%.2f, %.2f)\n", MIN_X, MIN_Y, MAX_X, MAX_Y);
    #endif

    //iterate through points, place a dot at each center point
    //and set pix value from 0 - 255 using multiply method for radius [dotsize].
    pixels_bw = calcDensity(points, weights, cPoints);

    //using provided color scheme and opacity, update pixel value to RGBA values
    pix_color = colorize(pixels_bw, scheme, pix_color, opacity);

    free(pixels_bw);
    pixels_bw = NULL;

    //return list of RGBA values
    return pix_color;
}
Ejemplo n.º 15
0
void
alarmclock(void)
{
  f_alarm = 0;
  logintime += 5;
  sleeptimes += 5;
  alarm(mybtmp->time + (logintime + 5) * 60 - (msg->t = time(0)));
  xcount = xcount > logintime * 4 ? xcount : logintime * 4;
  postcount = postcount > logintime * 2 ? postcount : logintime * 2;

  if (!ouruser && nonew >= 0)
  {
    colorize("\n\n\a@CYou have exceeded the time limit for entering your name and password.\n\n");
    my_exit(10);
  }
  else if (nonew < 0 && logintime == 30)
  {
    colorize("\n\n\a@CYou have exceeded the time limit for entering your information.\n\n");
    my_exit(10);
  }
  else if (sleeptimes == 20 + 40 * !(!client))
  {
    colorize("\n\n\a@CYou have been logged out due to inactivity.\n\n");
    my_exit(10);
  }
  else if (logintime == 240)
  {
    colorize("\n\n\a@CYou have been on four hours.  That is plenty long enough.  Goodbye.\n\n");
    my_exit(10);
  }
  else if (logintime == 225)
  { 
    colorize("\n\n\a@YYou have 15 minutes left before you are logged out!\n\n");
    fflush(stdout);
  }
  else if (logintime == 235)
  {
    colorize("\n\n\a@YYou have 5 minutes left before you are logged out!\n\n");
    fflush(stdout);
  }
  if (sleeptimes == 15 + 40 * (client > 0))
  {
    colorize("\n\n\a@YHello???  Is anyone out there?\n@RYou will be logged off unless you start looking more alive!\n\n\a");
    fflush(stdout);
  }
  else if (client && sleeptimes >= 15)
  {
    dead = 1;
    putchar(IAC);
    putchar(CLIENT);
    fflush(stdout);
  } 

  if (ouruser && !guest && !(logintime % 30))
    msync((caddr_t)ouruser, sizeof(struct user), MS_ASYNC);
}
Ejemplo n.º 16
0
void CLogSyntaxHighlighter::highlightBlock(const QString &AText)
{
	if (AText.isEmpty())
		return;

	{
		QTextCharFormat fmt;
		fmt.setBackground(QColor::fromRgb(255, 220, 220));

		QRegExp re("^.*\\[ERROR\\].*$");
		colorize(AText, fmt, re);
	}
	{
		QTextCharFormat fmt;
		fmt.setForeground(QColor::fromRgb(50, 100, 220));
		fmt.setFontItalic(true);

		QRegExp re("^\\[[^\\]]*\\] \\[[^\\]]*\\] ");
		colorize(AText, fmt, re);
	}
}
Ejemplo n.º 17
0
CPicture * CWindowObject::createBg(std::string imageName, bool playerColored)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;

	if (imageName.empty())
		return nullptr;

	auto image = new CPicture(imageName);
	if (playerColored)
		image->colorize(LOCPLINT->playerID);
	return image;
}
int __print_tests_summary(int tests) {
  int non_passing = __error_count__ + __pending_count__;
  int result_color = COLOR_GREEN;
  if(non_passing > 0) {
    fprintf(stdout,"\n");
  }
	
  if(__error_count__ == 0) {
    fprintf(stdout, "%s %d Tests successful!\n", colorize("OK:\t\t", COLOR_BACKGROUND), tests-non_passing);
    if(__pending_count__ > 0) {
    	fprintf(stdout, "%s %d test(s) pending...\n", colorize("Pending:\t", COLOR_YELLOW), __pending_count__);
    }
  } else {
  	fprintf(stdout, "%s %d test(s) FAILED.\n", colorize("FAILURES:\t", COLOR_RED), __error_count__);
  	if(__pending_count__ > 0) {
    	fprintf(stdout, "%s %d test(s) Pending.\n", colorize("Pending:\t", COLOR_BACKGROUND), __pending_count__);
    }
    fprintf(stdout, "%s %d test(s) succesful.\n", colorize("ok:\t\t", COLOR_BACKGROUND), tests-non_passing);
  }
  
  fprintf(stdout, "--------------------------------------\n");
  if(__error_count__ > 0) {
  	result_color = COLOR_RED;
  } else if(__pending_count__ > 0) {
  	result_color = COLOR_YELLOW;
  }
  
  fprintf(stdout, "%s %d test(s)\n", colorize("TOTAL:\t\t", result_color), tests);

  return __error_count__;
}
Ejemplo n.º 19
0
Archivo: output.c Proyecto: Cappar/bard
static void separator(jmp_buf jmpBuf, struct Output* output, const char* separator) {
	if(separator == NULL) {
		output->separator = "";
		return;
	}
	output->separator = malloc(strlen(separator) * sizeof(char));
	if(output->separator == NULL)
		longjmp(jmpBuf, MYERR_ALLOCFAIL);
	char* colors;
	colorize(jmpBuf, separator, &colors);
	strcpy(output->separator, colors);
	free(colors);
}
Ejemplo n.º 20
0
void
tag_lvitem::set_on(bool b)
{
  treeWidget()->blockSignals(true);
  if ((checkState(0)==Qt::Unchecked && b==true) ||
      (checkState(0)==Qt::Checked && b==false)) {
    DBG_PRINTF(5, "set_on changes state");
    setCheckState(0, b ? Qt::Checked : Qt::Unchecked);
    last_known_state = (b ? Qt::Checked : Qt::Unchecked);
    colorize();
  }
  treeWidget()->blockSignals(false);
}
 std::string describe( const Character *ch ) const override {
     vpart_position part_pos( cur.veh, cur.part );
     std::string res;
     if( auto label = part_pos.get_label() ) {
         res = colorize( *label, c_light_blue ) + " ";
     }
     if( auto cargo_part = part_pos.part_with_feature( "CARGO", true ) ) {
         res += cargo_part->part().name();
     } else {
         debugmsg( "item in vehicle part without cargo storage" );
     }
     if( ch ) {
         res += " " + direction_suffix( ch->pos(), part_pos.pos() );
     }
     return res;
 }
Ejemplo n.º 22
0
pixel *flatten(int *deck) {
    int rows = ROWS();
    int cols = COLS();
    pixel *flat = XCALLOC(rows * cols * sizeof(pixel));
    int i, j;
    for (i = 0; i < rows; i++) {
        for (j = 0; j < cols; j++) {
            pixel *pp = &flat[(i * cols) + j];
            *pp = colorize(deck[j / CARD_WIDTH]);
            if (!(pp->red > 0 || pp->green > 0 || pp->blue > 0)) {
                printf("Pixel %d,%d (#%d) failed\n", i,j, j/CARD_WIDTH);
            }
        }
    }
    return flat;
}
Ejemplo n.º 23
0
float *compute2(unsigned iterations) {
    reset_change();

   for (int i = 0; i < DIM; i++) {
        for (int j = 0; j < DIM; j++) {
            old[i][j] = ocean[i][j];
        }
    }
  
    for (int ite = 0; ite < iterations; ite++) {
        for (int x = 0; x < DIM; x++) {
            for (int y = 0; y < DIM; y++) {

                if ( ocean[x+1][y] >= 4) {
                    old[x][y] += 1;
                    old[x+1][y] -= 1;
                    changed[x+1][y] = 1;
                } 
                if ( ocean[x-1][y] >= 4) {
                    old[x][y] += 1;
                    old[x-1][y] -= 1;
                    changed[x-1][y] = 1;
                }
                 if ( ocean[x][y+1] >= 4) {
                    old[x][y] += 1;
                    old[x][y+1] -= 1;
                    changed[x][y+1] = 1;
                }

               if ( ocean[x][y-1] >= 4) {
                    old[x][y] += 1;
                    old[x][y-1] -= 1;
                    changed[x][y-1] = 1;
                }

            }
        }
    }
    
   for (int i = 0; i < DIM; i++) {
        for (int j = 0; j < DIM; j++) {
            ocean[i][j] = old[i][j];
        }
    }
    colorize();
    return couleurs;
}
Ejemplo n.º 24
0
/* Entry point ... */
int main(int argc, char *argv[]){
    FILE *fp = stdin;

    if(argc == 2){      /* work off a file */
        fp = fopen(argv[1], "r");
        if(!fp){
            fprintf(stderr, "Unable to open file: %s\n", argv[1]);
            return 1;
        }
    }
    
    if(fp!=stdin){
        fclose(fp);
    }
    colorize(fp);
    return 0;
}
Ejemplo n.º 25
0
void CtrlrMIDIBuffer::reloadEditor(const String &_dataToDisplay, const bool resetPositions)
{
	dataToDisplay		= _dataToDisplay;
	dataToDisplaySize	= dataToDisplay.length();

	if (resetPositions)
	{
		prefixLengthLabel->setText ("4", sendNotification);
		nameLengthLabel->setText ("16", sendNotification);
		nameOffsetLabel->setText ("4", sendNotification);
		dataLengthLabel->setText ("16", sendNotification);
		dataOffsetLabel->setText ("20", sendNotification);
		suffixLengthLabel->setText ("4", sendNotification);
	}

	colorize();
}
Ejemplo n.º 26
0
Point::Point(float x, float y, float z) {
	point[0] = x;
	point[1] = y;
	point[2] = z;

	color[0] = 1.0;
	color[1] = 1.0;
	color[2] = 1.0;

	normal[0] = 0;
	normal[1] = 0;
	normal[2] = 0;

	modified = false;

	colorize();
}
Ejemplo n.º 27
0
void tShootRay(const ray& r, float color[3])
{
	color[0] = 1.f;
	color[1] = 0.f;
	color[2] = 0.f;

	float BG[2] = {0};

	Vector3	Origin  = {r.origin.X,		r.origin.Y, 	r.origin.Z};
	Vector3 Dir 	= {r.direction.X, 	r.direction.Y,  r.direction.Z};

	int index 	= -1;
	float t 	= FLT_MAX;

	if(rIntersection(Origin, Dir, gKDTree[0], index, t, BG))
	{
		colorize(Origin, Dir, index, t, BG, color);	
	}
}
Ejemplo n.º 28
0
int main(){
  int instancias, cidades,a,b;
  scanf("%d", &instancias);
  for(int counter=0; counter< instancias; counter++ ){
    scanf("%d", &cidades);
    for(int i=0; i<cidades; i++){
      mapa[i][SIZE]=0;
      color[i]= 0;
    }
    for(int i=0; i< cidades-1; i++){
      scanf("%d %d",&a, &b);a--;b--;
      mapa[a][mapa[a][SIZE]]= b;
      mapa[a][SIZE]++;
      mapa[b][mapa[b][SIZE]]= a;
      mapa[b][SIZE]++;
    }
    printf("%d\n", colorize(0, -1));
  }
}
Ejemplo n.º 29
0
Archivo: fab.c Proyecto: ryansb/libfab
char *image_to_string(const xcolor_image_t *image) {
    fab_buffer_t *buffer;
    if((buffer = malloc(sizeof(fab_buffer_t))) == NULL) {
        perror("malloc");
        exit(EXIT_FAILURE);
    }
    init_buffer(buffer);
    for(size_t y = 0; y < image->y; y++) {
        for(size_t x = 0; x < image->x; x++) {
            const char *color_block = colorize(escape(3, 48, 5, image->pixels[y][x]), escape(1, 49), " ");
            append_buffer(buffer, color_block);
            free((void *)color_block);
        }
        append_buffer(buffer, "\n");
    }
    truncate_buffer(buffer);
    char *string = buffer->buffer;
    free(buffer);
    return string;
}
Ejemplo n.º 30
0
int colorize(int city, int parent ){
  int val=0;
  int paint=1;
  if( mapa[city][SIZE]> 1 || parent == -1){
    for(int i=0; i<mapa[city][SIZE]; i++){
      if (mapa[city][i] != parent)
        val+=colorize( mapa[city][i], city);
      paint= paint && !color[mapa[city][i]];
    }
    if (paint){
      val++;
      color[city]=1;
    }
  }
  else{
    color[city]=1;
    return 1;
  }
  return val;
}