Exemple #1
0
int amx_menu_doevents(AMX *amx)
{
    if (!peek_keys(ANY_KEY))
        return 0;

    int status;
    cell retval;
    
    if (b1_func != -1 && get_keys(BUTTON1))
    {
        status = amx_Exec(amx, &retval, b1_func);
        if (status != 0) return status;
    }
    
    if (b2_func != -1 && get_keys(BUTTON2))
    {
        status = amx_Exec(amx, &retval, b2_func);
        if (status != 0) return status;
    }
    
    if (b3_func != -1 && get_keys(BUTTON3))
    {
        status = amx_Exec(amx, &retval, b3_func);
        if (status != 0) return status;
    }
    
    if (b3_func != -1 && get_keys(BUTTON4))
    {
        status = amx_Exec(amx, &retval, b4_func);
        if (status != 0) return status;
    }
    
    if (s1_func != -1 && peek_keys(SCROLL1_PRESS | SCROLL1_LEFT | SCROLL1_RIGHT))
    {
        int param = 0;
        
        if (get_keys(SCROLL1_PRESS))
            param = 0;
        else if (get_keys(SCROLL1_LEFT))
            param = -scroller_speed();
        else if (get_keys(SCROLL1_RIGHT))
            param = scroller_speed();
        
        amx_Push(amx, param);
        status = amx_Exec(amx, &retval, s1_func);
        if (status != 0) return status;
    }
    
    if (s2_func != -1 && peek_keys(SCROLL2_PRESS | SCROLL2_LEFT | SCROLL2_RIGHT))
    {
        int param = 0;
        
        if (get_keys(SCROLL2_PRESS))
            param = 0;
        else if (get_keys(SCROLL2_LEFT))
            param = -scroller_speed();
        else if (get_keys(SCROLL2_RIGHT))
            param = scroller_speed();
        
        amx_Push(amx, param);
        status = amx_Exec(amx, &retval, s2_func);
        if (status != 0) return status;
    }
    
    return 0;
}
Exemple #2
0
void select_file(char result[13])
{
    static int page = 0; // Remember selections while the program runs
    static int index = 0;
    int maxindex = 0;
    
    bool rerender = true;
    
    for(;;)
    {
        if (get_keys(BUTTON1) && index >= 0)
        {
            // File selected, get the name and return
            if (get_name(result, page, index))
                return;
            else
                rerender = true; // Couldn't find file, maybe fs has changed?
        }
        
        if (get_keys(BUTTON2))
        {
            // Refresh
            //f_flush(&fatfs);
            rerender = true;
        }
        
        if (get_keys(BUTTON4))
        {
            show_msgbox("About PAWN_APP",
                        "Pawn scripting language for DSO Quad\n"
                        "(C) 2012 Petteri Aimonen <*****@*****.**>\n"
                        "\n"
                        "Built " __DATE__ " at " __TIME__ "\n"
                        "Git id " COMMITID "\n"
                        "GCC version " __VERSION__
            );
            rerender = true;
        }
        
        if (peek_keys(SCROLL1_LEFT | SCROLL1_RIGHT | SCROLL2_LEFT | SCROLL2_RIGHT))
        {
            // Clear old cursor
            show_cursor(index, 0);
            
            // Update index
            if (get_keys(SCROLL1_LEFT)) index -= 4;
            if (get_keys(SCROLL1_RIGHT)) index += 4;
            if (get_keys(SCROLL2_LEFT)) index -= 1;
            if (get_keys(SCROLL2_RIGHT)) index += 1;
            
            if (index < 0)
            {
                if (page > 0)
                {
                    page--;
                    render_screen(page, &maxindex);
                    index += 12;
                }
                else
                {
                    index = 0;
                }
            }
            
            if (index >= maxindex)
            {
                if (maxindex > ICONS_ON_SCREEN)
                {
                    page++;
                    index -= 12;
                    rerender = true;
                }
                else
                {
                    index = maxindex - 1;
                }
            }
            
            // Draw new cursor
            show_cursor(index, RGB(128, 128, 255));
        }
        
        if (rerender)
        {
            render_screen(page, &maxindex);
            show_cursor(index, RGB(128, 128, 255));
            rerender = false;
            
            if (index >= maxindex)
                index = maxindex - 1;
        }
    }
}