Latest Games Block

Started by Chen Zhen, September 10, 2024, 12:37:47 AM

Previous topic - Next topic

Chen Zhen

Latest Games Block
Arcade version: SMF Arcade v2.7.0.2+



Create a new php block...

Enter this for custom display options:
(For viewing on portal - leave this line blank)
~action|arcade

Change '$icons_per_row' to equal the amount preferred
Change '$limit' to equal the amount preferred

Main code:
// Latest games block for SMF Arcade version 2.7.0.2 or newer
/**************************
    set $gameTypes
    0 = Permission based
    1 = Flash/HTML
    2 = ROM only
    3 = All game types
**************************/
global $db_prefix, $scripturl, $arcadeModSettings, $boardurl, $smcFunc;

$icons_per_row = 4;
$limit = 44;
$gameTypes = 0;

switch($gameTypes) {
    case 1:
        $where = ' WHERE game.rom_flag = {int:romflag}';
        $romflag = 0;
        break;
    case 2:
        $where = ' WHERE game.rom_flag = {int:romflag}';
        $romflag = 1;
        break;
    case 3:
        $where = '';
        $romflag = 0;
        break;
    default:
        $romflag = 0;
        if (allowedTo('arcade_view_retro_arch')) {
            $where = '';
        }
        else {
            $where = ' WHERE game.rom_flag = {int:romflag}';
        }
}

$arcade = '
<div style="overflow: hidden;">
    <div style="display: table;margin: 0 auto;padding: 1px;overflow: hidden;">
        <div style="display: table-row;">';
list($count1, $imgFile) = array(0, '');

$request = $smcFunc['db_query']('', '
    SELECT game.id_game, game.game_name, game.game_directory, game.thumbnail, game.rom_flag
    FROM {db_prefix}arcade_games AS game' . $where . '
    ORDER BY game.id_game DESC
    LIMIT {int:mylimit}', array('mylimit' => $limit, 'romflag' => $romflag)
);

while ($row = $smcFunc['db_fetch_assoc']($request)) {
$imgFile = isset($row['game_directory']) && $row['game_directory'] != '' ? $row['game_directory'] . '/' . $row['thumbnail'] : $row['thumbnail'];
$action = !empty($row['rom_flag']) ? 'retro_arch' : 'arcade';
if ($count1 > ($icons_per_row - 1)) {
$count1 = 0;
$arcade .= '
</div>
<div style="display: table-row;">';
}
$count1++;
$arcade .= '
<div style="display: table-cell;text-align: center;margin: 0 auto;border-spacing: 1px;">
<a href="' . $scripturl . '?action=' . $action . ';sa=play;game=' . $row['id_game'] . '">
<img style="width:42px; height:42px;" src="' . (!empty($row['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl']) . '/' . $imgFile . '" alt="' . $row['game_name'] . '" title="' . $row['game_name'] . '" />
</a>
</div>';
}

$smcFunc['db_free_result']($request);

$arcade .= '
        </div>
    </div>
</div>';

if (!allowedTo('arcade_view') && $gameTypes == 0)
    $arcade = '';

echo $arcade;