Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Shared :: "menuGenerator.php"
- include_once("{$GENERATOR_PATH}filter releases.php");
- include_once("{$GENERATOR_PATH}iconGenerator.php");
- foreach(['meta','css','js'] as $obj){
- $$obj = "";
- }
- $list = [];
- $allReleases = [];
- $allGames = [];
- // Fetch the releases
- $releases = explode("\r\n", file_get_contents("http://{$_SERVER['HTTP_HOST']}/Shared/scripts/php/Generators/listGenerator.php?release="));
- // Collect all games and releases
- foreach ($releases as $release) {
- $parts = uriParts($release);
- $releaseName = isset($parts['release']) ? $parts['release'] : '';
- $js .= "console.log(`Processed: \"{$releaseName}\"`)";
- // Store release names
- $allReleases[] = $releaseName;
- $games = explode("\r\n", file_get_contents("http://{$_SERVER['HTTP_HOST']}/Shared/scripts/php/Generators/listGenerator.php?release={$releaseName}"));
- foreach ($games as $game) {
- $parts = uriParts($game);
- $gameName = isset($parts['game']) ? $parts['game'] : '';
- $js .= "console.log(`Processed: \"{$gameName} ({$releaseName})\"`)";
- // Store game names
- $allGames[] = $gameName;
- // Structure list as [gameName => [release1, release2, ...]]
- if (!isset($list[$gameName])) {
- $list[$gameName] = [];
- }
- $list[$gameName][] = $releaseName;
- }
- }
- // Remove duplicates from releases and games arrays
- $allReleases = array_unique($allReleases);
- $allGames = array_unique($allGames);
- $allReleases = filter($allReleases);
- $allGames = filter($allGames);
- $menu = "";
- $xouterspan = 150;
- $youterspan = 100; // Increase this value to add more space between rows
- $xinnerspan = 128;
- $yinnerspan = 64;
- $ratio = 0.18;
- $x = 0;
- $y = 0; // Start y-position at 0
- // First row, first column should be "Main" with Main.png icon
- $mainIcon = "http://{$_SERVER['HTTP_HOST']}/Shared/assets/Sprites/generated/Main.png";
- $menu .= "<div style=\"position: absolute; left: 0px; top: 0px; width: {$xinnerspan}px; height: {$yinnerspan}px; display: flex; align-items: center; justify-content: center; text-align: center; font-family: Impact; font-size: calc({$xinnerspan}px * {$ratio});\">";
- $menu .= "<img style=\"max-width: 100%; max-height: 100%; object-fit: contain;\" src=\"{$mainIcon}\" alt=\"Main\">";
- $menu .= "</div>";
- // Render release headers starting from the second column
- foreach ($allReleases as $releaseIndex => $releaseName) {
- $x = ($releaseIndex + 1) * $xouterspan; // Position for each release
- $releaseIcon = "http://{$_SERVER['HTTP_HOST']}/Shared/assets/Sprites/generated/{$releaseName}.png";
- // Display release name and icon
- $menu .= "<div style=\"position: absolute; left: {$x}px; top: {$y}px; width: {$xinnerspan}px; height: {$yinnerspan}px; display: flex; align-items: center; justify-content: center; text-align: center; font-family: Impact; font-size: calc({$xinnerspan}px * {$ratio});\">";
- $menu .= "<img style=\"max-width: 100%; max-height: 100%; object-fit: contain;\" src=\"{$releaseIcon}\" alt=\"{$releaseName}\">";
- $menu .= "</div>";
- }
- $y += $youterspan; // Move down to start the game rows
- // Render games and their presence under each release
- foreach ($allGames as $gameIndex => $gameName) {
- $x = 0; // Reset x-position for each game row
- // Display the game name in the first column
- $menu .= "<div style=\"position: absolute; left: {$x}px; top: {$y}px; width: {$xinnerspan}px; height: {$yinnerspan}px; display: flex; align-items: center; justify-content: center; text-align: center; font-family: Impact; font-size: calc({$xinnerspan}px * {$ratio});\">";
- $menu .= "<div>{$gameName}</div></div>";
- foreach ($allReleases as $releaseIndex => $releaseName) {
- $x = ($releaseIndex + 1) * $xouterspan; // Position for each release column
- // Check if this game = part of the current release
- if (in_array($releaseName, $list[$gameName])) {
- $js .= "console.log(`Processed: \"{$gameName} ({$releaseName})\" (in Menu)`)";
- if(is_file("{$_SERVER['DOCUMENT_ROOT']}/Shared/assets/Sprites/icon/{$gameName}.png")){
- $icon = "/Shared/assets/Sprites/icon/{$gameName}.png";
- }elseif($gameName!==""){
- $icon = "/Shared/assets/Sprites/generated/{$releaseName} {$gameName}.png";
- }else{
- continue;
- }
- $menu .= "<div style=\"position: absolute; left: {$x}px; top: {$y}px; width: {$xinnerspan}px; height: {$yinnerspan}px; display: flex; align-items: center; justify-content: center; text-align: center; font-family: Impact; font-size: calc({$xinnerspan}px * {$ratio});\">";
- $menu .= "<a href=\"http://{$_SERVER['HTTP_HOST']}/?release={$releaseName}&game={$gameName}\">";
- $embedded = embedIcon($icon);
- $menu .= "<img style=\"max-width: 100%; max-height: 100%; object-fit: contain;\" src=\"{$embedded}\" alt=\"{$releaseName}: {$gameName}\">";
- $menu .= "</a></div>";
- }
- }
- $y += $youterspan; // Move down for the next game row
- }
- $pagedata = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/Shared/scripts/html/menu.html");
- include_once("{$GENERATOR_PATH}styles.php");
- $pagedata = styles($pagedata);
- $html = $menu;
- foreach(['meta','css','js'] as $obj){
- if(is_file("{$_SERVER['DOCUMENT_ROOT']}/Shared/scripts/{$obj}/menu.{$obj}")){
- $$obj .= file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/Shared/scripts/{$obj}/menu.{$obj}");
- }
- }
- foreach(['html','meta','css','js'] as $obj){
- $pagedata = str_replace("{{ {$obj} }}", $$obj, $pagedata);
- }
- echo $pagedata;
- exit;
- function embedIcon($icon){
- return
- "data:image/png;base64,".
- str_replace("=","",
- base64_encode(
- file_get_contents(
- $_SERVER["DOCUMENT_ROOT"].
- $icon
- )
- )
- );
- }
Add Comment
Please, Sign In to add comment