Daily Lucky Numbers:
8
11
19
29
40
42

Arcade Toolbar Block

Started by Chen Zhen, July 06, 2013, 03:19:22 PM

Previous topic - Next topic

Chen Zhen

SMF ARCADE - PHP Portal Block - Toolbar


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, $modSettings, $settings;
$modSettings['arcadeEnableDownload'] = !empty($modSettings['arcadeEnableDownload']) ? $modSettings['arcadeEnableDownload'] : false;
$id_of_game = isset($_REQUEST['game']) ? (int)$_REQUEST['game'] : 0;
$image_width = 30;
$image_height = 30;
$candown = allowedTo('arcade_download') && !empty($modSettings['arcadeEnableDownload']) ? true : false;
$admin_only = array('admin', 'category', 'edit', 'maintain');
$no_guest = array('arena', 'download', 'favorites');
$id = 0;
$button_icons = array(
    'home' => array('action=arcade;sort=name;desc=DESC', 'arcade_home.png'),
    'stats' => array('action=arcade;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'),
    'arena' => array('action=arcade;sa=arena', 'arcade_arena.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 or Simple Portal 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.


aquarius

I'd love to see a screenshot of what this does... I'll apply it and update this thread

Chen Zhen


You always have the option of installing a localhost platform on your PC/Mac to test things.
This way you can install SMF, the Arcade & a portal.
Install a few games at that point, perhaps briefly play a few of them to create scores in the database.
After all that you can copy & paste all these blocks to see if they work & how they look.

Most of these posted blocks were for an older version of the arcade but they should work.
If any of them give you trouble just post in the appropriate thread & I can take a look.

Chen Zhen

If you are not familiar with localhost servers, just search for Xampp or Wampserver.
Both can be used on a PC but only Xampp is available for Mac OSX or Unix.

Vincent Titus

wheres the attachment for this please

Vincent Titus

Quote from: vince on August 12, 2020, 07:09:11 PMwheres the attachment for this please
maybe have this centered aswell it would look better...

Chen Zhen

This block is obsolete & will no longer work with the upcoming release.

Chen Zhen


I updated this block to work with the latest version of the Arcade.
You will need to download the zip file & install it via your packages manager so that it can add icons to your arc_icons folder.