Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- desc:Playback Counter
- @init
- playback_count = 0;
- last_play_state = 0;
- @block
- // Check play state changes
- current_play_state = play_state;
- // Detect when playback starts
- current_play_state == 1 && last_play_state != 1 ? (
- playback_count += 1;
- );
- last_play_state = current_play_state;
- @gfx 200 100
- // Set minimum size
- gfx_w = max(gfx_w, 200);
- gfx_h = max(gfx_h, 100);
- // Deep slate background (dark blue-gray)
- gfx_r = 0.15;
- gfx_g = 0.20;
- gfx_b = 0.25;
- gfx_a = 1;
- gfx_rect(0, 0, gfx_w, gfx_h);
- // Set white text color
- gfx_r = 1;
- gfx_g = 1;
- gfx_b = 1;
- gfx_a = 1;
- // Calculate font size based on window size
- font_size = min(gfx_w * 0.15, gfx_h * 0.4);
- font_size = max(font_size, 12);
- gfx_setfont(1, "Arial", font_size);
- // Format the count text
- count_text = sprintf(#, "%d", playback_count);
- // Calculate text position (centered)
- str_width = 0;
- str_height = 0;
- gfx_measurestr(count_text, str_width, str_height);
- text_x = (gfx_w - str_width) * 0.5;
- text_y = (gfx_h - str_height) * 0.5;
- // Draw the count
- gfx_x = text_x;
- gfx_y = text_y;
- gfx_drawstr(count_text);
- // Draw label below the count
- label_font_size = font_size * 0.4;
- gfx_setfont(1, "Arial", label_font_size);
- label_text = "Playback Count";
- label_width = 0;
- label_height = 0;
- gfx_measurestr(label_text, label_width, label_height);
- label_x = (gfx_w - label_width) * 0.5;
- label_y = text_y + str_height + 5;
- gfx_x = label_x;
- gfx_y = label_y;
- gfx_drawstr(label_text);
Advertisement
Add Comment
Please, Sign In to add comment