Arcade Toolbar Block

Started by Chen Zhen, September 13, 2024, 12:55:07 PM

Previous topic - Next topic

Chen Zhen

SMF ARCADE - PHP Portal Block - Toolbar
Version: SMF-Arcade v2.7.0.2+

Create a php block titled: Arcade Toolbar

Put the following code in it:
/*  SMF Arcade Toolbar  */
/* For use with a PHP portal block or insert into your arcade template  */

global $scripturl, $context, $arcadeModSettings, $settings;
$arcadeModSettings['arcadeEnableDownload'] = !empty($arcadeModSettings['arcadeEnableDownload']) ? $arcadeModSettings['arcadeEnableDownload'] : false;
$id_of_game = isset($_REQUEST['game']) ? (int)$_REQUEST['game'] : 0;
$image_width = 30;
$image_height = 30;
$admin_only = array('admin', 'category', 'edit', 'maintain');
$no_guest = array('arena', 'download', 'favorites');
$id = 0;
$gameTypes = 0;
$action = isset($_REQUEST['action']) && $_REQUEST['action'] == 'retro_arch' ? 'retro_arch' : 'arcade';
$candown = $action == 'arcade' && allowedTo('arcade_download') && !empty($arcadeModSettings['arcadeEnableDownload']) ? true : (allowedTo('arcade_download_rom') && !empty($arcadeModSettings['arcadeEnableDownload']) ? true : false);
// 'arena' => array('action=arcade;sa=arena', 'arcade_arena.png'),
$button_icons = array(
    'home' => array('action=' . $action . ';sort=name;desc=DESC', 'arcade_home.png'),
    'stats' => array('action=' . $action . ';sa=stats', 'arcade_stats.jpg'),
    'admin' => array('action=admin;area=arcade;sa=main', 'arcade_admin.jpg'),
    'edit' => array('action=admin;area=managegames;sa=main', 'arcade_edit.png'),
    'category' => array('action=admin;area=arcadecategory;sa=list', 'arcade_category.png'),
    'maintain' => array('action=admin;area=arcademaintenance;sa=main', 'arcade_maintain.png'),   
    'download' => array('action=arcade;sa=download;game=' . $id_of_game, 'arcade_download.png'),
    'most_played' => array('action=arcade;sortby=plays;desc=DESC', 'arcade_most_played.png'),
    'favorites' => array('action=arcade;favorites', 'arcade_favorites.jpg'),
    'new' => array('action=arcade;sortby=age;desc=DESC', 'arcade_newgames.jpg'),
);

$tabStart = '
        <div class="windowbg2" style="white-space: nowrap;border-spacing: 0px;display: table-cell;cursor: pointer; font-size: 11px; padding: 6px 10px 6px 10px;border: solid 1px #ADADAD;border-top: 0px; border-bottom:0px; border-left:0px;text-align:center;vertical-align:top;" onmouseover="this.style.backgroundPosition=\'0 -5px\'" onmouseout="this.style.backgroundPosition=\'0 0px\'">';
$tabLast = '
        <div class="windowbg2" style="white-space: nowrap;border-spacing: 0px;display: table-cell;cursor: pointer; font-size: 11px; padding: 6px 10px 6px 10px;  border-top: 0px; border-bottom:0px; border-left:0px;text-align:center;vertical-align:top;">';
$tabEnd = '
        </div>';
$viewit = '
    <div summary="arcade_toolbar" style="overflow:hidden;display: table;border: 0px;padding: 0px;margin: 0 auto;width: 100%;">
        <div style="display: table-row;vertical-align: top;text-align: left;">';

foreach ($button_icons as $bname => $button) {
    if (in_array($bname, $admin_only) && !allowedTo('arcade_admin'))
        continue;
    if (in_array($bname, $no_guest) && $context['user']['is_guest'])
        continue;
    if ($bname == 'download' && !$candown && !allowedTo('arcade_admin'))
        continue;
    if ($bname == 'download' && empty($id_of_game))
        continue;

    $viewit    .=    (array_key_last($button_icons) == $bname ? $tabLast : $tabStart) . '
                <a href="' . $scripturl . '?' . $button[0] . '">
                    <img id="arcadeButtonBar' . $id . '" onmouseover="arcadeButtonOver(\'arcadeButtonBar' . $id . '\')" onmouseout="arcadeButtonOut(\'arcadeButtonBar' . $id . '\')" src="' . $settings['default_theme_url'] . '/images/arc_icons/' . $button[1] . '" style="width: ' . $image_width . 'px;height: ' . $image_height . 'px" title="ARCADE ' . strtoupper($bname) . '" alt="" />
                </a>
            ' . $tabEnd;
    $id++;
}

$viewit .= '
        </div>
    </div>
    <span style="display: block;line-height: 1em;"></span>
    <span style="display: block;line-height: 1em;"></span>
    <span style="display: block;line-height: 1em;"></span>
    <script type="text/javascript">
        function arcadeButtonOver(buttonLinkId) {
            document.getElementById(buttonLinkId).style.width = "' . ($image_width * 1.2) . 'px";
            document.getElementById(buttonLinkId).style.height = "' . ($image_height * 1.2) . 'px";
        }
        function arcadeButtonOut(buttonLinkId) {
            document.getElementById(buttonLinkId).style.width = "' . $image_width . 'px";
            document.getElementById(buttonLinkId).style.height = "' . $image_height . 'px";
        }
    </script>';

echo $viewit;



For EhPortal use 'Display Options' by choosing advanced and set custom display to:
~action|arcade

Download the attachment and install it into your SMF packages manager.
It will add icons to your ../arc_icons folder path.
The block code is also displayed during the installation process.