Forum Thread
  Posts  
Hide Games (Forums : Suggestions : Hide Games) Locked
Thread Options
Oct 9 2013 Anchor

*Edit* I am not sure why the text is at the top, although I don't think it should be, I edited my post to fix it...but it didn't seems like the rendering code from desura messes with the site a bit

Some games you can't remove because you bought them, and some games you might want to keep associated with your account, but you want to hide it.

I came up with a very simple solution (which is a bit hacky at the moment)

basically, I added some js to my default theme that looks at a txt file (as I couldn't find a way to use the sqllite db's) and load a list of game id's I want to hide, then during the loading of the list if the item is on that list I tell it not to render it.

you can try it yourself 8)

this needs to go inside play.menu or another play.*.js file:

var hiddenValues = "";
function getHidden()
{
    xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 )
        {
            hiddenValues = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", "hidden.txt", false );
    xmlhttp.send();    
}
function isHidden(itemId)
{
var n=hiddenValues.split(",");
var hidden = false;
        for (var i = 0; i < n.length; i++) {
            if(n[i]== itemId)
   {
hidden=true;
break;
   }
}
return hidden;
}

then you need to replace "t_gameslist" from "html/playlist.html" with the following:

then you need to replace <script id="t_gameslist" type="text/html">...</script> with the following:

<script id="t_gameslist" type="text/html">

	<#for(game in games) { game = games[game];mods = sortList(desura.items.getMods(game)); getHidden(); if(!isHidden(game.getId())){ #>

		<tbody class="games" id="item_<#= game.getId() #>">

			<#= parseTemplate($("#t_gameheader").html(), {game: game, hasMods: (mods.length > 0)}) #>

		</tbody>

		<# if (mods.length > 0) { #>

			<tbody class="mods expand"<#= expandCache[game.getId()] ? ' style="display: none;"' : "" #>>

			<# count=0; for (mod in mods) { count++; #>

					<#= parseTemplate($("#t_listitem").html(), {count: count, iteminfo: mods[mod], ignoretab: false}) #>

			<# } #>

			</tbody>

		<# } #>

	<# }} #>
</script>

then you need a "hidden.txt" file that is comma seperated list of game id's with no spaces in the "html" folder
100432412,234120521,123402340

this should hide all of the games in the list, but it will be rather slow if that list gets too large, instead if there were a table much like the favorites one in the sqllite databse and a binding to call "item.isHidden()" and "item.setHidden(true)" it would be a much faster operation.

being able to hide a game and not remove it would be neat, and it seems like a pretty trivial thing to add (as I did it, minus the sql I can't find access to)

thanks.

Edited by: Krum110487

Jan 10 2014 Anchor

Here's a modified version which seems to work for me. I made some changes to suit my tastes and make it a bit simpler and more efficient:

  • Simplified the code where possible
  • Moved the heavy tasks before the game loop so that they only run once
  • Made hidden.txt a newline-separated file instead of comma-separated
  • Made hidden.txt use the names instead of IDs

Here's the code that's working for me:

First, add this to play.items.js:

hiddenGames = [];
hiddenGamesLoaded = false;

loadHiddenGames = function(textFile) {
	textFile = typeof textFile !== 'undefined' ? textFile : 'hidden.txt';
	
	var request = new XMLHttpRequest();
	request.open('GET', textFile, false);
	request.send();
	
	hiddenGames = request.responseText.split(/\r?\n/);
	hiddenGamesLoaded = true;
}

gameIsHidden = function(game) {
	if (!hiddenGamesLoaded) {
		loadHiddenGames();
	}
	
	return (hiddenGames.indexOf(getItemName(game)) > -1);
}

Next, change play.html. All you need to do is add one line at the start of the loop inside #t_gameslist. Here is the code containing the line with a little bit of context:

	<# for(game in games) { game = games[game]; mods = sortList(desura.items.getMods(game)); #>
		<# if (gameIsHidden(game)) continue; #>
		<tbody class="games" id="item_<#= game.getId() #>">

Note the only line added is the second (middle) one. The rest are already in the file.

Finally, put hidden.txt within the 'html' folder containing a newline-separated list of game names, such as this:

1000 Amps
Along Came A Spider
AI War: Light of the Spire

Note that right now the game names are probably case sensitive (match exactly what you see in the Desura games list). This would be pretty easy to change however.

Just a note that I currently have 210 games in my hidden.txt list and I don't notice any slowdown at all over the normal (slow) Desura loading. It seems to be working great so far!

Edited by: broken85

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.