set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
- add_integer_with_range( CFG_PREFIX "rows", 4, 1, 128, NULL,
+ add_integer_with_range( CFG_PREFIX "rows", 4, 2, 16, NULL,
ROWS_TEXT, ROWS_LONGTEXT, false )
- add_integer_with_range( CFG_PREFIX "cols", 4, 1, 128, NULL,
+ add_integer_with_range( CFG_PREFIX "cols", 4, 2, 16, NULL,
COLS_TEXT, COLS_LONGTEXT, false )
- add_bool( CFG_PREFIX "black-slot", 0, NULL,
+ add_bool( CFG_PREFIX "black-slot", false, NULL,
BLACKSLOT_TEXT, BLACKSLOT_LONGTEXT, false )
set_callbacks( Open, Close )
var_AddCallback( p_filter, CFG_PREFIX "black-slot", PuzzleCallback, p_sys );
p_filter->pf_video_filter = Filter;
- p_filter->pf_mouse = Mouse;
+ p_filter->pf_video_mouse = Mouse;
return VLC_SUCCESS;
}
const int i_rows = p_sys->i_rows;
const int i_cols = p_sys->i_cols;
- /* */
+ /* Draw each piece of the puzzle at the right place */
for( int i_plane = 0; i_plane < p_outpic->i_planes; i_plane++ )
{
const plane_t *p_in = &p_pic->p[i_plane];
i_row *= p_in->i_lines / i_rows;
i_last_row *= p_in->i_lines / i_rows;
- if( p_sys->b_blackslot && p_sys->b_finished && i == p_sys->i_selected )
+ if( p_sys->b_blackslot && !p_sys->b_finished && i == p_sys->i_selected )
{
uint8_t color = ( i_plane == Y_PLANE ? 0x0 : 0x80 );
for( ; i_row < i_last_row; i_row++, i_orow++ )
}
}
+ /* Draw the borders of the selected slot */
if( p_sys->i_selected != -1 && !p_sys->b_blackslot )
{
const plane_t *p_in = &p_pic->p[Y_PLANE];
0xff, i_pitch / i_cols );
}
+ /* Draw the 'Shuffle' button if the puzzle is finished */
if( p_sys->b_finished )
{
plane_t *p_out = &p_outpic->p[Y_PLANE];
filter_sys_t *p_sys = p_filter->p_sys;
const video_format_t *p_fmt = &p_filter->fmt_in.video;
+ /* Only take events inside the puzzle erea */
if( p_new->i_x < 0 || p_new->i_x >= (int)p_fmt->i_width ||
p_new->i_y < 0 || p_new->i_y >= (int)p_fmt->i_height )
return VLC_EGENERIC;
/* */
const bool b_clicked = vlc_mouse_HasPressed( p_old, p_new, MOUSE_BUTTON_LEFT );
+ /* If the puzzle is finished, shuffle it if needed */
if( p_sys->b_finished )
{
if( b_clicked &&
|| p_sys->i_selected == i_pos + p_sys->i_cols
|| p_sys->i_selected == i_pos - p_sys->i_cols )
{
+ /* Swap two pieces */
int a = p_sys->pi_order[ p_sys->i_selected ];
p_sys->pi_order[ p_sys->i_selected ] = p_sys->pi_order[ i_pos ];
p_sys->pi_order[ i_pos ] = a;
- if( p_sys->b_blackslot )
- p_sys->i_selected = i_pos;
- else
- p_sys->i_selected = -1;
-
+ p_sys->i_selected = p_sys->b_blackslot ? i_pos : -1;
p_sys->b_finished = IsFinished( p_sys );
}
return VLC_EGENERIC;
{
const int i_count = p_sys->i_cols * p_sys->i_rows;
- if( p_sys->b_blackslot )
+ if( !p_sys->b_blackslot )
return true;
int d = 0;
}
p_sys->b_finished = IsFinished( p_sys );
- } while( p_sys->b_finished || IsValid( p_sys ) );
+ } while( p_sys->b_finished || !IsValid( p_sys ) );
if( p_sys->b_blackslot )
{