Interval between effects and between colors configurable from Settings

This commit is contained in:
Duilio Protti 2016-06-25 16:15:49 -03:00
parent 911fa7ba10
commit a73c91e35d
2 changed files with 25 additions and 16 deletions

View File

@ -38,8 +38,12 @@ static const char about_text[] =
"https://github.com/dprotti/infinity-plugin"; "https://github.com/dprotti/infinity-plugin";
static const PreferencesWidget prefs_fps[] = { static const PreferencesWidget prefs_fps[] = {
WidgetLabel ("<b>Maximum Frames per Second</b>"), WidgetLabel ("<b>Frames per second</b>"),
WidgetSpin ("Rate:", WidgetInt (CFGID, "max_fps"), {10, 120, 1, "fps"}) WidgetSpin ("Max. :", WidgetInt (CFGID, "max_fps"), {10, 120, 1, "fps"}),
WidgetLabel ("<b>How often change effect</b>"),
WidgetSpin ("Every", WidgetInt (CFGID, "effect_time"), {50, 500, 5, "frames "}),
WidgetLabel ("<b>How often change colors</b>"),
WidgetSpin ("Every", WidgetInt (CFGID, "palette_time"), {50, 500, 5, "frames "})
}; };
static const PreferencesWidget prefs_widgets[] = { static const PreferencesWidget prefs_widgets[] = {

View File

@ -49,18 +49,12 @@ extern "C" {
#define next_effect() (t_last_effect++) #define next_effect() (t_last_effect++)
#define next_color() (t_last_color++) #define next_color() (t_last_color++)
typedef struct t_general_parameters {
gint32 t_between_effects;
gint32 t_between_colors;
} t_general_parameters;
typedef gint32 t_color; typedef gint32 t_color;
typedef gint32 t_num_effect; typedef gint32 t_num_effect;
static t_screen_parameters scr_par; static t_screen_parameters scr_par;
static t_effect current_effect; static t_effect current_effect;
static t_general_parameters gen_par;
static t_color color, old_color, t_last_color; static t_color color, old_color, t_last_color;
static t_num_effect t_last_effect; static t_num_effect t_last_effect;
@ -109,9 +103,6 @@ void renderer_init(void)
scr_par.height = config_get_yres(); scr_par.height = config_get_yres();
scr_par.scale = config_get_sres(); scr_par.scale = config_get_sres();
gen_par.t_between_effects = config_get_teff();
gen_par.t_between_colors = config_get_tcol();
old_color = 0; old_color = 0;
color = 0; color = 0;
@ -424,7 +415,7 @@ static void check_events()
// log calling line to improve bug reports // log calling line to improve bug reports
static gint32 calculate_frame_length(gint32 fps, int line) { static gint32 calculate_frame_length(gint32 fps, int line) {
gint32 frame_length = frame_length = (gint32)(((1.0 / fps) * 1000)); gint32 frame_length = (gint32)(((1.0 / fps) * 1000));
g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", line, fps); g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", line, fps);
return frame_length; return frame_length;
} }
@ -435,9 +426,12 @@ static int renderer(void *arg)
gint32 frame_length; gint32 frame_length;
gint32 idle_time; gint32 idle_time;
gint32 fps, new_fps; gint32 fps, new_fps;
gint32 t_between_effects, t_between_colors;
fps = aud_get_int(CFGID, "max_fps"); fps = aud_get_int(CFGID, "max_fps");
frame_length = calculate_frame_length(fps, __LINE__); frame_length = calculate_frame_length(fps, __LINE__);
t_between_effects = aud_get_int(CFGID, "effect_time");
t_between_colors = aud_get_int(CFGID, "palette_time");
initializing = FALSE; initializing = FALSE;
for (;; ) { /* ever... */ for (;; ) { /* ever... */
if (!visible) { if (!visible) {
@ -467,28 +461,32 @@ static int renderer(void *arg)
change_color(old_color, color, t_last_color * 8); change_color(old_color, color, t_last_color * 8);
next_color(); next_color();
next_effect(); next_effect();
if (t_last_effect % gen_par.t_between_effects == 0) { if (t_last_effect % t_between_effects == 0) {
#ifdef INFINITY_DEBUG #ifdef INFINITY_DEBUG
if (!mode_interactif) { if (!mode_interactif) {
display_load_random_effect(&current_effect); display_load_random_effect(&current_effect);
t_last_effect = 0; t_last_effect = 0;
t_between_effects = aud_get_int(CFGID, "effect_time");
} }
#else #else
display_load_random_effect(&current_effect); display_load_random_effect(&current_effect);
t_last_effect = 0; t_last_effect = 0;
t_between_effects = aud_get_int(CFGID, "effect_time");
#endif #endif
} }
if (t_last_color % gen_par.t_between_colors == 0) { if (t_last_color % t_between_colors == 0) {
#ifdef INFINITY_DEBUG #ifdef INFINITY_DEBUG
if (!mode_interactif) { if (!mode_interactif) {
old_color = color; old_color = color;
color = rand() % NB_PALETTES; color = rand() % NB_PALETTES;
t_last_color = 0; t_last_color = 0;
t_between_colors = aud_get_int(CFGID, "palette_time");
} }
#else #else
old_color = color; old_color = color;
color = rand() % NB_PALETTES; color = rand() % NB_PALETTES;
t_last_color = 0; t_last_color = 0;
t_between_colors = aud_get_int(CFGID, "palette_time");
#endif #endif
} }
@ -513,9 +511,12 @@ static int renderer_mmx(void *arg)
gint32 frame_length; gint32 frame_length;
gint32 idle_time; gint32 idle_time;
gint32 fps, new_fps; gint32 fps, new_fps;
gint32 t_between_effects, t_between_colors;
fps = aud_get_int(CFGID, "max_fps"); fps = aud_get_int(CFGID, "max_fps");
frame_length = calculate_frame_length(fps, __LINE__); frame_length = calculate_frame_length(fps, __LINE__);
t_between_effects = aud_get_int(CFGID, "effect_time");
t_between_colors = aud_get_int(CFGID, "palette_time");
initializing = FALSE; initializing = FALSE;
for (;; ) { /* ever... */ for (;; ) { /* ever... */
if (!visible) { if (!visible) {
@ -545,28 +546,32 @@ static int renderer_mmx(void *arg)
change_color(old_color, color, t_last_color * 8); change_color(old_color, color, t_last_color * 8);
next_color(); next_color();
next_effect(); next_effect();
if (t_last_effect % gen_par.t_between_effects == 0) { if (t_last_effect % t_between_effects == 0) {
#ifdef INFINITY_DEBUG #ifdef INFINITY_DEBUG
if (!mode_interactif) { if (!mode_interactif) {
display_load_random_effect(&current_effect); display_load_random_effect(&current_effect);
t_last_effect = 0; t_last_effect = 0;
t_between_effects = aud_get_int(CFGID, "effect_time");
} }
#else #else
display_load_random_effect(&current_effect); display_load_random_effect(&current_effect);
t_last_effect = 0; t_last_effect = 0;
t_between_effects = aud_get_int(CFGID, "effect_time");
#endif #endif
} }
if (t_last_color % gen_par.t_between_colors == 0) { if (t_last_color % t_between_colors == 0) {
#ifdef INFINITY_DEBUG #ifdef INFINITY_DEBUG
if (!mode_interactif) { if (!mode_interactif) {
old_color = color; old_color = color;
color = rand() % NB_PALETTES; color = rand() % NB_PALETTES;
t_last_color = 0; t_last_color = 0;
t_between_colors = aud_get_int(CFGID, "palette_time");
} }
#else #else
old_color = color; old_color = color;
color = rand() % NB_PALETTES; color = rand() % NB_PALETTES;
t_last_color = 0; t_last_color = 0;
t_between_colors = aud_get_int(CFGID, "palette_time");
#endif #endif
} }