r3234 - software/ui/src

Miriam Ruiz baby-guest at alioth.debian.org
Wed Jul 4 14:21:43 UTC 2007


Author: baby-guest
Date: 2007-07-04 14:21:43 +0000 (Wed, 04 Jul 2007)
New Revision: 3234

Modified:
   software/ui/src/games.cpp
   software/ui/src/pkgbrowser.cpp
Log:
Visual popcon viewer



Modified: software/ui/src/games.cpp
===================================================================
--- software/ui/src/games.cpp	2007-07-04 14:11:15 UTC (rev 3233)
+++ software/ui/src/games.cpp	2007-07-04 14:21:43 UTC (rev 3234)
@@ -205,9 +205,10 @@
 		string desc = rec.package() + "\t" + rec.shortDescription();
 		if (engine.popcon().hasData())
 		{
-			desc += "\t#";
-			int stars = (int)rintf(i->popcon * 4 / engine.popconLocalMax());
-			for (int j = 0; j < stars; ++j) desc += '*';
+			desc += "\t";
+			char stars[16];
+			snprintf(stars, sizeof(stars), "%%%d ", (int)rintf(i->popcon * 100 / engine.popconLocalMax()));
+			desc += stars;
 			printf ("%s (%s): POPCON=%f\n", rec.package().c_str(), rec.shortDescription().c_str(), i->popcon);
 		}
 		ui.ResultsBrowser->add(desc.c_str(), userData);

Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp	2007-07-04 14:11:15 UTC (rev 3233)
+++ software/ui/src/pkgbrowser.cpp	2007-07-04 14:21:43 UTC (rev 3234)
@@ -59,7 +59,11 @@
 	//colsepcolor(FL_RED);
 	column_char('\t'); // tabs as column delimiters
 	stars_on = new Fl_PNG_Image(FILE_STARS_ON);
+	if (stars_on && !stars_on->count())
+		printf(_("Cannot open file '%s'\n"), FILE_STARS_ON);
 	stars_off = new Fl_PNG_Image(FILE_STARS_OFF);
+	if (stars_off && !stars_off->count())
+		printf(_("Cannot open file '%s'\n"), FILE_STARS_OFF);
 }
 
 PackageBrowser::~PackageBrowser()
@@ -234,10 +238,16 @@
 		}
 
 	BREAK:
-		if (*str=='#')
+		if (*str=='%' && '0'<*str+1<'9')
 		{
+			int percent = atoi(str+1);
+			if (percent < 0) percent = 0;
+			if (percent > 100) percent = 100;
+			int active = stars_on->w()*percent/100;
+			if (stars_off)
+				stars_off->draw(x + active + 3, y, min(stars_off->w() - active, w1 - active - 6), h, active, 0);
 			if (stars_on)
-				stars_on->draw(x + 3, y, w1-6, h, 0, 0);
+				stars_on->draw(x + 3, y, min(active, w1 - 6), h, 0, 0);
 		}
 		else
 		{




More information about the Pkg-games-commits mailing list