From b3011e8d285b7fac4e992afe1cfb87a186add673 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sat, 23 Apr 2022 16:56:23 +0000 Subject: allow custom playlist images to still use datatable-based images --- .../mod/scripts/vscripts/ui/menu_playlist.nut | 58 ++++++++++++---------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_playlist.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_playlist.nut index 564af591..b498db46 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_playlist.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_playlist.nut @@ -64,54 +64,60 @@ bool function PlaylistButtonInit( var button, int elemNum ) } asset function GetPlaylistImage( string playlistName ) -{ +{ + var dataTable = GetDataTable( $"datatable/playlist_items.rpak" ) + string imageName = GetPlaylistVarOrUseValue( playlistName, "image", "default" ) asset levelImage - + if ( imageName == "custom" ) { - string customImage = GetPlaylistVarOrUseValue( playlistName, "custom_image", "" ) + imageName = GetPlaylistVarOrUseValue( playlistName, "custom_image", "" ) // ensure people aren't trying to do some fuckery with this - if ( customImage.find( "\"" ) != null ) - customImage = "" + if ( imageName.find( "\"" ) != null ) + imageName = "" - // hell on earth - levelImage = expect asset( compilestring( "return $\"" + customImage + "\"" )() ) - } - else - { - var dataTable = GetDataTable( $"datatable/playlist_items.rpak" ) - int row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) - levelImage = GetDataTableAsset( dataTable, row, GetDataTableColumnByName( dataTable, "image" ) ) + // if this is in the datatable, use the datatable image rather than the raw path + if ( GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) == -1 ) + { + // hell on earth + return expect asset( compilestring( "return $\"" + imageName + "\"" )() ) + } } + int row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) + levelImage = GetDataTableAsset( dataTable, row, GetDataTableColumnByName( dataTable, "image" ) ) + return levelImage } asset function GetPlaylistThumbnailImage( string playlistName ) { + var dataTable = GetDataTable( $"datatable/playlist_items.rpak" ) + string imageName = GetPlaylistVarOrUseValue( playlistName, "image", playlistName ) asset levelImage if ( imageName == "custom" ) { - string customImage = GetPlaylistVarOrUseValue( playlistName, "custom_thumbnail", "" ) + imageName = GetPlaylistVarOrUseValue( playlistName, "custom_thumbnail", "" ) // ensure people aren't trying to do some fuckery with this - if ( customImage.find( "\"" ) != null ) - customImage = "" + if ( imageName.find( "\"" ) != null ) + imageName = "" - // hell on earth - levelImage = expect asset( compilestring( "return $\"" + customImage + "\"" )() ) - } - else - { - var dataTable = GetDataTable( $"datatable/playlist_items.rpak" ) - int row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) - if ( row == -1 ) - row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), "default" ) - levelImage = GetDataTableAsset( dataTable, row, GetDataTableColumnByName( dataTable, "thumbnail" ) ) + // if this is in the datatable, use the datatable image rather than the raw path + if ( GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) == -1 ) + { + // hell on earth + return expect asset( compilestring( "return $\"" + imageName + "\"" )() ) + } } + int row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), imageName ) + if ( row == -1 ) + row = GetDataTableRowMatchingStringValue( dataTable, GetDataTableColumnByName( dataTable, "playlist" ), "default" ) + levelImage = GetDataTableAsset( dataTable, row, GetDataTableColumnByName( dataTable, "thumbnail" ) ) + return levelImage } -- cgit v1.2.3