srand(time(NULL));
return rand() % max;
}
-gint seed = 0;
+guint seed;
gint fast_rnd(gint max)
{
- gint offset = 12923;
- gint multiplier = 4079;
+ guint offset = 12923;
+ guint multiplier = 4079;
seed = seed * multiplier + offset;
return (gint)(seed % max);
}
+gint
+probability_sun()
+{
+ /* update sun position after ... second */
+ return 60;
+}
+
gint
probability_plane()
{
- gint t = (fast_rnd(10) + 1) * 60;
- fprintf(stderr, "probability_plane %d\n", t);
- return t;
+ return (fast_rnd(10) + 1) * 60;
}
void
char *newfile;
if (actor){
- if (scene.daytime == TIME_NIGHT){
+ if (get_daytime() == TIME_NIGHT){
if (!actor->visible){
actor->visible = TRUE;
phase = get_moon_phase();
fprintf(stderr, "destroy moon \n");
destroy_hildon_actor(actor);
/* TO DO make moonrise*/
- actor->time_start_animation = get_next_sunset();
+ actor->time_start_animation = 0;
}
}
double alt, azm;
gint x, y;
+ //fprintf(stderr, "change sun\n");
if (actor){
if (scene.daytime != TIME_NIGHT){
if (!actor->visible){
actor->visible = TRUE;
-
create_hildon_actor(actor, desktop_plugin);
}
get_sun_pos(&alt, &azm);
actor->x = x;
actor->y = y;
actor_set_position_full(actor->widget, x, y, actor->z);
- probability_sun(actor);
+ //probability_sun(actor);
+ actor->time_start_animation = time(NULL) + probability_sun();
}else if (actor->visible){
actor->visible = FALSE;
destroy_hildon_actor(actor);
- actor->time_start_animation = get_next_sunrise();
+ actor->time_start_animation = 0;
}
}
/* stop animation */
actor->visible = FALSE;
destroy_hildon_actor(actor);
- actor->time_start_animation = sec + 5*60;
+ actor->time_start_animation = sec + (fast_rnd(5) + 1)*60;
}
}
init_scene1(desktop_plugin);
}
-void
-probability_sun(Actor *actor)
-{
- actor->time_start_animation += 20 * 1;
- actor->duration_animation = G_MAXINT;
-}
-
/* Init Modern Scene */
static void
Actor *actor;
gint now = time(NULL);
- seed = time(NULL)%10;
scene.daytime = get_daytime();
scene.actors = NULL;
scene.actors = g_slist_append(scene.actors, actor);
- actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
- TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
- change_static_actor(actor, desktop_plugin);
- scene.actors = g_slist_append(scene.actors, actor);
-
actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
FALSE, 100, 255, (gpointer)&change_moon, NULL);
change_moon(actor, desktop_plugin);
scene.actors = g_slist_append(scene.actors, actor);
+ actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, fast_rnd(300), 11, 188, 75,
+ FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+ actor->time_start_animation = now + fast_rnd(3) * 60;
+ actor->duration_animation = 5*60;
+ scene.actors = g_slist_append(scene.actors, actor);
+
actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
FALSE, 100, 255, (gpointer)&change_plane2, NULL);
actor->time_start_animation = now + probability_plane();
actor->duration_animation = 30;
scene.actors = g_slist_append(scene.actors, actor);
- actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, 50, 7, 188, 75,
- FALSE, 100, 255, (gpointer)&change_cloud, NULL);
- actor->time_start_animation = now + 5;
- actor->duration_animation = 5*60;
+ actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
+ TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
+ change_static_actor(actor, desktop_plugin);
scene.actors = g_slist_append(scene.actors, actor);
+
}
return TRUE;
now = time(NULL);
+ //scene.daytime = daytime;
/* fprintf(stderr, "Short timer %d\n", now); */
tmp = scene.actors;
while (tmp != NULL){
}
tmp = g_slist_next(tmp);
}
- scene.daytime = daytime;
if (stop_flag){
desktop_plugin->priv->short_timer = 0;
return FALSE;
static gboolean
long_timeout (AWallpaperPlugin *desktop_plugin)
{
- gint daytime = get_daytime();
- GSList * tmp;
- void (*pfunc)(gpointer, gpointer);
- time_t now;
- Actor *actor;
+ gint daytime = get_daytime();
+ GSList * tmp;
+ void (*pfunc)(gpointer, gpointer);
+ time_t now;
+ Actor *actor;
/* TODO remove timeout */
if (!desktop_plugin->priv->visible)
return TRUE;
- //fprintf(stderr, "timer daytime=%d\n", daytime);
- if (scene.daytime != daytime){
- tmp = scene.actors;
- while (tmp != NULL){
- //change_actor(tmp->data);
- pfunc =((Actor*)tmp->data)->func_change;
- if (pfunc){
- (*pfunc)(tmp->data, desktop_plugin);
- }
- tmp = g_slist_next(tmp);
- }
- }
+ //fprintf(stderr, "timer daytime=%d\n", daytime);
+ if (scene.daytime != daytime){
+ tmp = scene.actors;
+ while (tmp != NULL){
+ //change_actor(tmp->data);
+ pfunc =((Actor*)tmp->data)->func_change;
+ if (pfunc){
+ (*pfunc)(tmp->data, desktop_plugin);
+ }
+ tmp = g_slist_next(tmp);
+ }
+ }
- now = time(NULL);
-//fprintf(stderr, "Now %d\n", now);
- tmp = scene.actors;
- while (tmp != NULL){
- actor = tmp->data;
- if (now >= actor->time_start_animation
- && actor->time_start_animation > 0
- && desktop_plugin->priv->short_timer == 0){
+ now = time(NULL);
+ //fprintf(stderr, "Now %d\n", now);
+ tmp = scene.actors;
+ while (tmp != NULL){
+ actor = tmp->data;
+ if (now >= actor->time_start_animation
+ && actor->time_start_animation > 0
+ && desktop_plugin->priv->short_timer == 0){
actor->time_start_animation = now;
/* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
}
tmp = g_slist_next(tmp);
- }
+ }
- scene.daytime = daytime;
+ scene.daytime = daytime;
- return TRUE; /* keep running this event */
+ return TRUE; /* keep running this event */
}
static void
gtk_container_add (GTK_CONTAINER (desktop_plugin), rich_animation);
init_applet_position();
+
+ /* start value for random */
+ seed = time(NULL);
+
fprintf(stderr, "!!!theme = %s\n", priv->theme);
if (!strcmp(priv->theme,"Modern"))
init_scene(desktop_plugin);