Add alternative views in serverbrowser and improve favourites

Alternative views in the serverbrowser are implemented with use favourites.
Categories (names) of favourite servers, which will be displayed on the
views, have to be included in "serverbrowseraltviews" alias (accessible
in menu).
Switching between views is possible with use Alt + Mouse wheel and
Alt + Up/Down (or eventually "[" and "]", if they are dedicated keys
on your keyboard).

The commit also:
1. adds MATCH category to favourites;
2. shows category name in settings of favourites;
3. shows weights in serverbrowser instead of favourites image,
when showweights = 1;
4. cleans up some tabs.
This commit is contained in:
aurhat
2014-11-11 21:07:19 +01:00
parent 170f377262
commit b6a5418c24
4 changed files with 55 additions and 6 deletions
+33 -1
View File
@@ -877,6 +877,30 @@ const char *favcatcheck(serverinfo &si, const char *ckeys, char *autokeys = NULL
return res ? nkeys : NULL;
}
void serverbrowseralternativeviews(int shiftdirection)
{
const char *ckeys = getalias("serverbrowseraltviews");
if(!ckeys) return;
const char *sep = " \t\n\r";
char *keys = newstring(ckeys), *k = strtok(keys, sep);
vector<int> cats;
cats.add(0);
while(k)
{
loopv(favcats) if(!strcmp(favcats[i], k)) cats.add(i + 1);
k = strtok(NULL, sep);
}
delete[] keys;
if(cats.length())
{
loopv(cats)
{
if(cats[i] == showonlyfavourites) { showonlyfavourites = cats[(i + shiftdirection + cats.length()) % cats.length()]; return; }
}
}
showonlyfavourites = 0;
}
vector<const char *> favcattags;
bool assignserverfavourites()
@@ -1049,7 +1073,7 @@ void refreshservers(void *menu, bool init)
}
else
{
if(!hidefavicons && showfavtag && si.favcat > -1) favimage = getalias(favcatargname(favcats[si.favcat], FC_IMAGE));
if(!hidefavicons && !showweights && showfavtag && si.favcat > -1) favimage = getalias(favcatargname(favcats[si.favcat], FC_IMAGE));
filterrichtext(text, si.favcat > -1 && !favimage ? favcattags[si.favcat] : "");
if(showweights) concatformatstring(text, "(%d)", si.weight);
formatstring(si.full)(showfavtag ? (favimage ? "\t" : "\fs%s\fr\t") : "", text);
@@ -1189,6 +1213,14 @@ bool serverskey(void *menu, int code, bool isdown, int unicode)
serversort = (serversort+1) % NUMSERVSORT;
return true;
case SDLK_LEFTBRACKET:
serverbrowseralternativeviews(-1);
return true;
case SDLK_RIGHTBRACKET:
serverbrowseralternativeviews(1);
return true;
case SDLK_F5:
updatefrommaster(1);
return true;