Esempio n. 1
0
void w_plugins::draw_item(Plugins::iterator it, SDL_Surface* s, int16 x,
                          int16 y, uint16 width,
                          bool selected) const
{
  y += font->get_ascent();
  set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width);
  uint32 color;
  if (selected) {
    color = get_theme_color(ITEM_WIDGET, ACTIVE_STATE);
  }
  else if (it->enabled && it->compatible()) {
    color = get_theme_color(ITEM_WIDGET, DEFAULT_STATE);
  }
  else
  {
    color = get_theme_color(ITEM_WIDGET, DISABLED_STATE);
  }

  std::string enabled;
  if (!it->compatible()) {
    enabled = " Incompatible";
  }
  else if (it->enabled) {
    enabled = " Enabled";
  }
  else
  {
    enabled = " Disabled";
  }

  int right_text_width = text_width(enabled.c_str(), font, style);

  set_drawing_clip_rectangle(0, x, static_cast<short>(s->h),
                             x + width - right_text_width);
  std::string name_and_version = it->name + " " + it->version;
  draw_text(s, name_and_version.c_str(), x, y, color, font, style);

  set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width);
  draw_text(s,
            enabled.c_str(), x + width - right_text_width, y, color, font,
            style);

  set_drawing_clip_rectangle(SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);

  y += font->get_ascent() + 1;
  if (it->description.size()) {
    draw_text(s, it->description.c_str(), x, y, color, font, style);
  }
  else {
    draw_text(s, "No description", x, y, color, font, style);
  }
}
void w_plugins::draw_item(Plugins::iterator it, SDL_Surface* s, int16 x, int16 y, uint16 width, bool selected) const 
{
	y += font->get_ascent();
	set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width);
	uint32 color;
	if (selected)
	{
		color = get_theme_color(ITEM_WIDGET, ACTIVE_STATE);
	} 
	else if (it->enabled && it->compatible() && it->allowed())
	{
		color = get_theme_color(ITEM_WIDGET, DEFAULT_STATE);
	}
	else
	{
		color = get_theme_color(ITEM_WIDGET, DISABLED_STATE);
	}

	std::string enabled;
	if (!it->compatible()) 
	{
		enabled = " Incompatible";
	}
	else if (!it->allowed())
	{
		enabled = " Disallowed";
	}
	else if (it->enabled)
	{
		enabled = " Enabled";
	}
	else 
	{
		enabled = " Disabled";
	}

	int right_text_width = text_width(enabled.c_str(), font, style);

	set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width - right_text_width);
	std::string name_and_version = it->name + " " + it->version;
	draw_text(s, name_and_version.c_str(), x, y, color, font, style);

	set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width);
	draw_text(s, enabled.c_str(), x + width - right_text_width, y, color, font, style);

	y += font->get_ascent() + 1;
	std::string types;
	if (it->solo_lua.size()) {
		types += ", Solo Lua";
	}
	if (it->hud_lua.size()) {
		types += ", HUD";
	}
	if (it->theme.size()) {
		types += ", Theme";
	}
	if (it->shapes_patches.size()) {
		types += ", Shapes Patch";
	}
	if (it->mmls.size()) {
		types += ", MML";
	}
	if (it->stats_lua.size()) {
		types += ", Stats";
	}
	types.erase(0, 2);
	right_text_width = text_width(types.c_str(), font, style | styleItalic);
	set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width);
	draw_text(s, types.c_str(), x + width - right_text_width, y, color, font, style | styleItalic);
	
	set_drawing_clip_rectangle(0, x, static_cast<short>(s->h), x + width - right_text_width);
	if (it->description.size()) {
		draw_text(s, it->description.c_str(), x, y, color, font, style);
	} else {
		draw_text(s, "No description", x, y, color, font, style);
	}
	
	set_drawing_clip_rectangle(SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX);
}