<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <title>Iron Horse Game Development</title>
    <meta name="description" content="Game and Software development division of Halbear Networking & Software Ltd">
    <meta name="keywords" content="Games, Gaming, Halbear.Net, Halbear, Iron Horse Game Development, Iron Horse, Plane Building, Lost Contact, War Horse, Iostiler, Expedition Emberleaf">
    <link rel="stylesheet"href="StyleSheets/MainStyle.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Boldonse&family=DotGothic16&family=Lexend:wght@600&display=swap" rel="stylesheet">
</head>
<body>
<div class="Content">
    <?php
    $dir = "SubPages/Games";
    $Apps = scandir($dir);
    $iterator = 0;
    $ImageList = "";
    $Title = "";
    $ImageURL = "";
    $Content = "";
    $index = 0;
    $ID = "";
    foreach ($Apps as $App) {
        $filePath = $dir . '/' . $App;
        if (is_file($filePath)) {
            $ImageList = "";
            $Title = "";
            $ImageURL = "";
            $Content = "";
            $Data = file_get_contents($filePath);
            $Lines = explode("\n", $Data);
            $MultipleImages = false;
            foreach($Lines as $Line) {
                if (str_contains($Line,"BGImage") && str_contains($Line, '#')) {
                    $MultipleImages = true;
                }
            }
            $NewGame = "SubPages/LeftSide.php";
            if ($MultipleImages) {
                $NewGame ="SubPages/LeftSideMultiImage.php";
            }
            if ($iterator % 2 != 0) {
                $NewGame = "SubPages/RightSide.php";
                    if ($MultipleImages) {$NewGame = "SubPages/RightSideMultiImage.php";
                }
            }
            foreach($Lines as $Line) {
                $content = explode("->", $Line);
                switch($content[0]) {
                    case "Title":
                        $Title = $content[1];
                        break;
                    case "BGImage":
                        if ($MultipleImages){
                            $Images = explode("#", $content[1]);
                            $ImageURL = $Images[0];
                            $ImagePreset = file_get_contents("SubPages/Image.html");
                            $ImageIterator = 0;
                            foreach ($Images as $Image) {
                                $NewImage = str_replace("[imageSRC]", $Images[$ImageIterator], $ImagePreset);
                                $NewImage = str_replace("[Function]", "'GameDisplay".$index."','".$Images[$ImageIterator], $NewImage);
                                $ImageList = $ImageList.$NewImage;
                                $ImageIterator++;
                            }
                        }
                        else $ImageURL =  $content[1];
                        break;
                    case "Content":
                        $Content = $content[1];
                        break;
                }
            }
            $iterator++;
            $ID = "GameDisplay".$index;
            require($NewGame);
            $index++;
        }
    }
    ?>

    <div style="height: 20vh; width: 100%; display: flex; flex-direction: row; align-content: space-between; justify-content: space-between">
        <div style="height: 100%; width: 40%; display: flex; flex-direction: column; align-content: space-evenly; justify-content: space-evenly; ">
            <a style="font-family: 'Boldonse', system-ui; font-size: 1.5vh;margin-top: 2vh;margin-left: 5vh; color: white">©Halbear Networking & Software Ltd 2025</a>
            <a style="font-family: 'Boldonse', system-ui; font-size: 1vh;margin-left: 5vh;color: white; cursor: pointer" onclick="this.href='https://halbear.net/'">Visit Halbear.net</a>
            <a style="font-family: 'Boldonse', system-ui; font-size: 1vh;margin-bottom: 2vh;margin-left: 5vh;color: white; cursor: pointer;" onclick="this.href='https://halbear.net/termsAndConditions.html'">HalbearNet User Agreement</a>
        </div>
        <div style="height: 100%; display: flex; flex-direction: column; align-content: space-evenly; justify-content: space-evenly; ">
            <a style="font-family: 'Boldonse', system-ui; font-size: 1vh; margin-top: 2vh;margin-right: 5vh; color: white">Support</a>
            <a style="font-family: 'Boldonse', system-ui; font-size: 1vh;margin-right: 5vh;color: white">Forums</a>
            <a style="font-family: 'Boldonse', system-ui; font-size: 1vh;margin-bottom: 2vh;margin-right: 5vh;color: white">User Agreement</a>
        </div>
    </div>
</div>
<?php
$Page = "Games";
require_once("Hotbar.php");
?>
<script>
    var Button = document.getElementById("<?php echo($Page); ?>");
    Button.onclick = function(){document.location.href='index.php';};
    Button.innerHTML = "Home";
    function SwitchImage(ParentElement, imageSrc) {
        var parsedImage =  "SiteAssets/" + imageSrc;
        var GameBox = document.getElementById(ParentElement);
        GameBox.style.backgroundImage = "url('" + parsedImage + "')";
    }
</script>
</body>
</html>