Permalink
Browse files

Map categories update

Added more categories
Made so that last loaded map saves
More strict category checking
  • Loading branch information...
1 parent 8b88dcd commit 99c130656609c31264489e6506c2c0b76b34f91e @robotboy655 robotboy655 committed Nov 27, 2013
Showing with 72 additions and 31 deletions.
  1. +22 −3 garrysmod/html/js/menu/control.NewGame.js
  2. +50 −28 garrysmod/lua/menu/getmaps.lua
@@ -4,15 +4,17 @@ var scope = null;
function ControllerNewGame( $scope, $element, $rootScope, $location )
{
- $scope.CurrentCategory = "Sandbox";
+ lua.Run( "LoadLastMap()" );
for ( var i = 0; i < gScope.MapList.length; i++ )
{
if ( gScope.MapList[i][ "category" ] == "Favourites" )
{
- $scope.CurrentCategory = "Favourites";
+ if ( !$scope.CurrentCategory ) $scope.CurrentCategory = "Favourites";
}
- }
+ }
+
+ if ( !$scope.CurrentCategory ) $scope.CurrentCategory = "Sandbox";
$scope.Players =
[
@@ -42,6 +44,7 @@ function ControllerNewGame( $scope, $element, $rootScope, $location )
if ( !$rootScope.Map ) $rootScope.Map = "gm_flatgrass";
if ( !$rootScope.MaxPlayers ) $rootScope.MaxPlayers = 1;
if ( !$rootScope.ServerSettings ) $rootScope.ServerSettings = ServerSettings;
+ if ( !$scope.LastCategory ) $scope.LastCategory = $scope.CurrentCategory;
lua.Run( "UpdateServerSettings()" );
@@ -72,6 +75,7 @@ function ControllerNewGame( $scope, $element, $rootScope, $location )
$scope.SelectMap = function ( m )
{
$rootScope.Map = m;
+ $scope.LastCategory = $scope.CurrentCategory
}
$scope.ClickMap = function ( m )
@@ -102,6 +106,8 @@ function ControllerNewGame( $scope, $element, $rootScope, $location )
$scope.StartGame = function()
{
+ lua.Run( 'SaveLastMap( "' + $rootScope.Map + '", "' + $scope.LastCategory + '" )' );
+
lua.Run( 'hook.Run( "StartGame" )' )
lua.Run( 'RunConsoleCommand( "progress_enable" )' )
@@ -163,6 +169,19 @@ function ControllerNewGame( $scope, $element, $rootScope, $location )
}
}
+function SetLastMap( map, category )
+{
+ CurrentCategory = category
+ Map = map
+
+ if ( scope )
+ {
+ scope.CurrentCategory = category;
+ scope.Map = map;
+ UpdateDigest( scope, 0 );
+ }
+}
+
function UpdateServerSettings( sttngs )
{
sttngs.CheckBox = []
@@ -10,25 +10,28 @@ local function UpdateMapPatterns()
MapPatterns[ "^de_" ] = "Counter-Strike"
MapPatterns[ "^cs_" ] = "Counter-Strike"
MapPatterns[ "^es_" ] = "Counter-Strike"
+ MapPatterns[ "^ar_" ] = "Counter-Strike"
+ MapPatterns[ "^fy_" ] = "Counter-Strike"
+
MapPatterns[ "^cp_" ] = "Team Fortress 2"
- MapPatterns[ "^ctf_" ] = "Team Fortress 2"
- MapPatterns[ "^mvm_" ] = "Team Fortress 2"
MapPatterns[ "^sd_" ] = "Team Fortress 2"
MapPatterns[ "^tc_" ] = "Team Fortress 2"
MapPatterns[ "^tr_" ] = "Team Fortress 2"
MapPatterns[ "^pl_" ] = "Team Fortress 2"
+ MapPatterns[ "^ctf_" ] = "Team Fortress 2"
+ MapPatterns[ "^mvm_" ] = "Team Fortress 2"
MapPatterns[ "^plr_" ] = "Team Fortress 2"
- MapPatterns[ "^arena_" ] = "Team Fortress 2"
MapPatterns[ "^koth_" ] = "Team Fortress 2"
+ MapPatterns[ "^arena_" ] = "Team Fortress 2"
MapPatterns[ "itemtest" ] = "Team Fortress 2"
MapPatterns[ "^dod_" ] = "Day Of Defeat"
MapPatterns[ "^d1_" ] = "Half-Life 2"
MapPatterns[ "^d2_" ] = "Half-Life 2"
MapPatterns[ "^d3_" ] = "Half-Life 2"
- MapPatterns[ "credits" ] = "Half-Life 2"
MapPatterns[ "intro" ] = "Half-Life 2"
+ MapPatterns[ "credits" ] = "Half-Life 2"
MapPatterns[ "^ep1_" ] = "Half-Life 2: Episode 1"
MapPatterns[ "^ep2_" ] = "Half-Life 2: Episode 2"
@@ -47,60 +50,62 @@ local function UpdateMapPatterns()
MapPatterns[ "^c5a" ] = "Half-Life: Source"
MapPatterns[ "^t0a" ] = "Half-Life: Source"
- MapPatterns[ "boot_camp" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "bounce" ] = "Half-Life: Source Deathmatch"
- MapPatterns[ "crossfire" ] = "Half-Life: Source Deathmatch"
- MapPatterns[ "datacore" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "frenzy" ] = "Half-Life: Source Deathmatch"
+ MapPatterns[ "snarkpit" ] = "Half-Life: Source Deathmatch"
+ MapPatterns[ "datacore" ] = "Half-Life: Source Deathmatch"
+ MapPatterns[ "undertow" ] = "Half-Life: Source Deathmatch"
+ MapPatterns[ "boot_camp" ] = "Half-Life: Source Deathmatch"
+ MapPatterns[ "crossfire" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "rapidcore" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "stalkyard" ] = "Half-Life: Source Deathmatch"
- MapPatterns[ "snarkpit" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "subtransit" ] = "Half-Life: Source Deathmatch"
- MapPatterns[ "undertow" ] = "Half-Life: Source Deathmatch"
MapPatterns[ "lambda_bunker" ] = "Half-Life: Source Deathmatch"
- MapPatterns[ "dm_" ] = "Half-Life 2 Deathmatch"
+ MapPatterns[ "^dm_" ] = "Half-Life 2: Deathmatch"
- MapPatterns[ "^dys_" ] = "Dystopia"
MapPatterns[ "^pb_" ] = "Dystopia"
+ MapPatterns[ "^dys_" ] = "Dystopia"
MapPatterns[ "dys_lobby" ] = "Dystopia"
MapPatterns[ "^ins_" ] = "Insurgency"
- MapPatterns[ "^aoc_" ] = "Age Of Chivalry"
+ MapPatterns[ "^aoc_" ] = "Age of Chivalry"
+
MapPatterns[ "^mp_coop_" ] = "Portal 2"
+ MapPatterns[ "^sp_a" ] = "Portal 2"
+ MapPatterns[ "e1912" ] = "Portal 2"
MapPatterns[ "^ur_" ] = "DIPRIP"
- MapPatterns[ "dm_village" ] = "DIPRIP"
- MapPatterns[ "dm_supermarket" ] = "DIPRIP"
- MapPatterns[ "dm_refinery" ] = "DIPRIP"
MapPatterns[ "dm_dam" ] = "DIPRIP"
- MapPatterns[ "dm_city" ] = "DIPRIP"
MapPatterns[ "de_dam" ] = "DIPRIP"
+ MapPatterns[ "dm_city" ] = "DIPRIP"
+ MapPatterns[ "dm_village" ] = "DIPRIP"
+ MapPatterns[ "dm_refinery" ] = "DIPRIP"
+ MapPatterns[ "dm_supermarket" ] = "DIPRIP"
MapPatterns[ "^tw_" ] = "Pirates, Vikings and Knights II"
MapPatterns[ "^bt_" ] = "Pirates, Vikings and Knights II"
- MapPatterns[ "^lts_" ] = "Pirates, Vikings and Knights II"
MapPatterns[ "^te_" ] = "Pirates, Vikings and Knights II"
+ MapPatterns[ "^lts_" ] = "Pirates, Vikings and Knights II"
MapPatterns[ "^zps_" ] = "Zombie Panic! Source"
MapPatterns[ "^zpa_" ] = "Zombie Panic! Source"
MapPatterns[ "^zpo_" ] = "Zombie Panic! Source"
MapPatterns[ "^zpl_" ] = "Zombie Panic! Source"
+ MapPatterns[ "^surf_" ] = "Surf"
MapPatterns[ "^rp_" ] = "Roleplay"
+ MapPatterns[ "^sb_" ] = "Spacebuild"
+ MapPatterns[ "^achievement_" ] = "Achievement"
MapPatterns[ "^zs_" ] = "Zombie Survival"
+ MapPatterns[ "^dr_" ] = "Deathrun"
+ MapPatterns[ "^deathrun_" ] = "Deathrun"
MapPatterns[ "^jb_" ] = "Jailbreak"
MapPatterns[ "^ba_jail_" ] = "Jailbreak"
- MapPatterns[ "^deathrun_" ] = "Deathrun"
- MapPatterns[ "^dr_" ] = "Deathrun"
- MapPatterns[ "^surf_" ] = "Surf"
- MapPatterns[ "^sb_" ] = "Spacebuild"
MapPatterns[ "^asi-" ] = "Alien Swarm"
MapPatterns[ "lobby" ] = "Alien Swarm"
- MapPatterns[ "tutorial_standards" ] = "Left 4 Dead 2"
- MapPatterns[ "tutorial_standards_vs" ] = "Left 4 Dead 2"
MapPatterns[ "^c1m" ] = "Left 4 Dead 2"
MapPatterns[ "^c2m" ] = "Left 4 Dead 2"
MapPatterns[ "^c3m" ] = "Left 4 Dead 2"
@@ -114,6 +119,8 @@ local function UpdateMapPatterns()
MapPatterns[ "^c11m" ] = "Left 4 Dead 2"
MapPatterns[ "^c12m" ] = "Left 4 Dead 2"
MapPatterns[ "^c13m" ] = "Left 4 Dead 2"
+ MapPatterns[ "tutorial_standards" ] = "Left 4 Dead 2"
+ MapPatterns[ "tutorial_standards_vs" ] = "Left 4 Dead 2"
local GamemodeList = engine.GetGamemodes()
@@ -145,8 +152,6 @@ end
local IgnoreMaps = { "background", "^test_", "^styleguide", "^devtest" }
-matNoIcon = Material( "maps/noicon" )
-
local function RefreshMaps()
UpdateMapPatterns();
@@ -173,15 +178,16 @@ local function RefreshMaps()
local lowername = string.lower( v )
for pattern, category in pairs( MapPatterns ) do
- if ( string.find( lowername, pattern ) ) then
+ if ( ( string.StartWith( pattern, "^" ) || string.EndsWith( pattern, "_" ) || string.EndsWith( pattern, "-" ) ) && string.find( lowername, pattern ) ) then
Category = category
end
end
if ( MapPatterns[ name ] ) then Category = MapPatterns[ name ] end
if ( table.HasValue( favmaps, name ) ) then
- Category = "Favourites"
+ -- Hackity hack
+ g_MapList[ v .. " " ] = { Name = name, Category = "Favourites" }
end
g_MapList[ v ] = { Name = name, Category = Category }
@@ -230,4 +236,20 @@ function ToggleFavourite(map)
UpdateMapList()
-end
+end
+
+function SaveLastMap( map, cat )
+ local t = string.Explode( ";", cookie.GetString( "lastmap", "" ) )
+ if ( !map ) then map = t[ 1 ] or "" end
+ if ( !cat ) then cat = t[ 2 ] or "" end
+
+ cookie.Set( "lastmap", map .. ";" .. cat )
+end
+
+function LoadLastMap()
+ local t = string.Explode( ";", cookie.GetString( "lastmap", "" ) )
+ local map = t[ 1 ] or ""
+ local cat = t[ 2 ] or ""
+
+ pnlMainMenu:Call( "SetLastMap('" .. map .. "','" .. cat .. "')" );
+end

0 comments on commit 99c1306

Please sign in to comment.