1 /*vim: set sw=4 ts=4 et: */
3 * This file is part of Live Wallpaper (livewp)
5 * Copyright (C) 2010 Vlad Vasiliev
6 * Copyright (C) 2010 Tanya Makova
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This software is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 /*******************************************************************************/
25 #include "livewp-scene.h"
28 destroy_scene(AWallpaperPlugin *desktop_plugin)
30 GSList * tmp = desktop_plugin->priv->scene->actors;
32 destroy_actor(tmp->data);
33 tmp = g_slist_next(tmp);
36 desktop_plugin->priv->scene->actors = NULL;
37 if (desktop_plugin->priv->scene){
38 g_free(desktop_plugin->priv->scene);
39 desktop_plugin->priv->scene = NULL;
44 reload_scene(AWallpaperPlugin *desktop_plugin)
46 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
47 destroy_scene(desktop_plugin);
49 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
50 init_scene_Modern(desktop_plugin);
51 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
52 init_scene_Berlin(desktop_plugin);
53 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
54 init_scene_Matrix(desktop_plugin);
56 init_scene_theme(desktop_plugin);
60 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
65 gint now = time(NULL);
68 if (desktop_plugin->priv->rich_animation){
76 fprintf(stderr, "init scene2 \n");
77 scene = g_new0(Scene, 1);
78 //scene.daytime = get_daytime();
80 desktop_plugin->priv->scene = scene;
82 actor = init_object(desktop_plugin, "background", "bg.png",
86 scene->actors = g_slist_append(scene->actors, actor);
88 actor = init_object(desktop_plugin, "symbols", "symbols.png",
92 scene->actors = g_slist_append(scene->actors, actor);
94 child = g_ptr_array_sized_new(4);
95 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
99 //actor->time_start_animation = now;
100 //actor->duration_animation = G_MAXINT;
101 scene->actors = g_slist_append(scene->actors, actor);
102 g_ptr_array_add(child, actor);
104 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
106 TRUE, TRUE, 100, 255,
108 //actor->time_start_animation = now;
109 //actor->duration_animation = G_MAXINT;
110 scene->actors = g_slist_append(scene->actors, actor);
111 g_ptr_array_add(child, actor);
113 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
115 TRUE, TRUE, 100, 255,
117 //actor->time_start_animation = now;
118 //actor->duration_animation = G_MAXINT;
119 scene->actors = g_slist_append(scene->actors, actor);
120 g_ptr_array_add(child, actor);
122 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
124 TRUE, TRUE, 100, 255,
126 //actor->time_start_animation = now;
127 //actor->duration_animation = G_MAXINT;
128 scene->actors = g_slist_append(scene->actors, actor);
129 g_ptr_array_add(child, actor);
131 actor = init_object(desktop_plugin, "layers", "",
133 FALSE, FALSE, 100, 255,
134 (gpointer)&change_layer, NULL, child);
135 actor->time_start_animation = now;
136 actor->duration_animation = G_MAXINT;
137 scene->actors = g_slist_append(scene->actors, actor);
139 run_long_timeout(desktop_plugin);
143 /* Init Modern Scene */
145 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
149 gint now = time(NULL);
153 //fprintf(stderr, "init scene \n");
154 scene = g_new0(Scene, 1);
155 scene->daytime = get_daytime();
156 scene->actors = NULL;
157 scene->wind_orientation = -1;
158 scene->wind_angle = 0.3;
159 /* init value for random */
160 scene->seed = time(NULL);
161 scene->notification = TRUE;
162 desktop_plugin->priv->scene = scene;
165 actor = init_object(desktop_plugin, "sky", "sky0.png",
167 TRUE , TRUE, 100, 255,
168 (gpointer)&change_static_actor, NULL, NULL);
169 change_static_actor(actor, desktop_plugin);
170 scene->actors = g_slist_append(scene->actors, actor);
172 actor = init_object(desktop_plugin, "sun", "sun.png",
174 FALSE, FALSE, 100, 255,
175 (gpointer)&change_sun, NULL, NULL);
176 actor->time_start_animation = now;
177 actor->duration_animation = G_MAXINT;
178 change_sun(actor, desktop_plugin);
179 scene->actors = g_slist_append(scene->actors, actor);
181 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
182 // TRUE, 100, 255, NULL, NULL);
183 //scene.actors = g_slist_append(scene.actors, actor);
185 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
186 0, fast_rnd(300)-97, 7, 150, 97,
187 FALSE, FALSE, 100, 255,
188 (gpointer)&change_cloud, NULL, NULL);
189 actor->time_start_animation = now + fast_rnd(20);
190 actor->duration_animation = 3*60;
191 scene->actors = g_slist_append(scene->actors, actor);
193 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
194 0, fast_rnd(300)-75, 7, 188, 75,
195 FALSE, FALSE, 100, 255,
196 (gpointer)&change_cloud, NULL, NULL);
197 actor->time_start_animation = now + fast_rnd(40)+10;
198 actor->duration_animation = 3*60;
199 scene->actors = g_slist_append(scene->actors, actor);
201 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
202 0, fast_rnd(300)-75, 7, 150, 75,
203 FALSE, FALSE, 100, 255,
204 (gpointer)&change_cloud, NULL, NULL);
205 actor->time_start_animation = now + fast_rnd(60) + 20;
206 actor->duration_animation = 5*60;
207 scene->actors = g_slist_append(scene->actors, actor);
210 actor = init_object(desktop_plugin, "town", "town0.png",
212 TRUE, TRUE, 100, 255,
213 (gpointer)&change_static_actor, NULL, NULL);
214 change_static_actor(actor, desktop_plugin);
215 scene->actors = g_slist_append(scene->actors, actor);
217 actor = init_object(desktop_plugin, "stend", "stend0.png",
218 452, 166, 9, 300, 305,
219 TRUE, TRUE, 100, 255,
220 (gpointer)&change_static_actor, NULL, NULL);
221 change_static_actor(actor, desktop_plugin);
222 scene->actors = g_slist_append(scene->actors, actor);
224 actor = init_object(desktop_plugin, "billboard_text", "",
225 470, 174, 9, 300, 108,
226 TRUE, FALSE, 100, 255,
227 (gpointer)&change_billboard, NULL, NULL);
228 create_hildon_actor_text(actor, desktop_plugin);
229 //actor->time_start_animation = time(NULL) + 20;
230 change_billboard(actor, desktop_plugin);
231 scene->actors = g_slist_append(scene->actors, actor);
233 actor = init_object(desktop_plugin, "tram", "tram.png",
234 -300, 225, 10, 350, 210,
235 FALSE, FALSE, 100, 255,
236 (gpointer)&change_tram, NULL, NULL);
237 actor->time_start_animation = time(NULL) + fast_rnd(10);
238 actor->duration_animation = 60;
239 scene->actors = g_slist_append(scene->actors, actor);
241 actor = init_object(desktop_plugin, "border", "border0.png",
242 0, 480-79, 11, 800, 79,
243 TRUE, TRUE, 100, 255,
244 (gpointer)&change_static_actor_with_corner, NULL, NULL);
245 change_static_actor_with_corner(actor, desktop_plugin);
246 scene->actors = g_slist_append(scene->actors, actor);
248 actor = init_object(desktop_plugin, "moon", "moon1.png",
250 FALSE, FALSE, 100, 255,
251 (gpointer)&change_moon, NULL, NULL);
252 change_moon(actor, desktop_plugin);
253 scene->actors = g_slist_append(scene->actors, actor);
255 actor = init_object(desktop_plugin, "wind", "",
257 FALSE, FALSE, 100, 255,
258 (gpointer)&change_wind, NULL, NULL);
259 change_wind(actor, desktop_plugin);
260 scene->actors = g_slist_append(scene->actors, actor);
262 /* windows in 4-th house */
302 for (i=0; i<13; i++){
303 actor = init_object(desktop_plugin, "window1", "window1.png",
304 winds[i][0], winds[i][1], 8, 8, 10,
305 FALSE, FALSE, 100, 255,
306 (gpointer)&change_window1, NULL, NULL);
307 //change_window1(actor, desktop_plugin);
308 actor->time_start_animation = now + fast_rnd(30);
309 scene->actors = g_slist_append(scene->actors, actor);
313 /* windows in 1-th house */
339 actor = init_object(desktop_plugin, "window2", "window2.png",
340 winds[i][0], winds[i][1], 8, 8, 10,
341 FALSE, FALSE, 100, 255,
342 (gpointer)&change_window1, NULL, NULL);
343 //change_window1(actor, desktop_plugin);
344 actor->time_start_animation = now + fast_rnd(30);
345 scene->actors = g_slist_append(scene->actors, actor);
349 /* windows in 3-th house */
381 for (i=0; i<10; i++){
382 actor = init_object(desktop_plugin, "window3", "window3.png",
383 winds[i][0], winds[i][1], 8, 8, 10,
384 FALSE, FALSE, 100, 255,
385 (gpointer)&change_window1, NULL, NULL);
386 //change_window1(actor, desktop_plugin);
387 actor->time_start_animation = now + fast_rnd(30);
388 scene->actors = g_slist_append(scene->actors, actor);
392 /* windows in 5-th house */
416 actor = init_object(desktop_plugin, "window4", "window4.png",
417 winds[i][0], winds[i][1], 8, 8, 10,
418 FALSE, FALSE, 100, 255,
419 (gpointer)&change_window1, NULL, NULL);
420 //change_window1(actor, desktop_plugin);
421 actor->time_start_animation = now + fast_rnd(30);
422 scene->actors = g_slist_append(scene->actors, actor);
426 /* windows in 6-th house */
447 actor = init_object(desktop_plugin, "window5", "window5.png",
448 winds[i][0], winds[i][1], 8, 8, 10,
449 FALSE, FALSE, 100, 255,
450 (gpointer)&change_window1, NULL, NULL);
451 //change_window1(actor, desktop_plugin);
452 actor->time_start_animation = now + fast_rnd(30);
453 scene->actors = g_slist_append(scene->actors, actor);
456 run_long_timeout(desktop_plugin);
459 anim = g_new0(Animation, 1);
462 anim->func_change = &change_tram;
463 anim->func_time = NULL;
464 anim->timestart = time(NULL);
467 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
471 /* Init Berlin Scene */
473 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
475 Actor *actor, *actor1, *actor2;
477 gint now = time(NULL);
480 GPtrArray *child = NULL;
482 scene = g_new0(Scene, 1);
483 scene->daytime = get_daytime();
484 scene->actors = NULL;
485 scene->wind_orientation = -1;
486 scene->wind_angle = 0.3;
487 /* init value for random */
488 scene->seed = time(NULL);
489 desktop_plugin->priv->scene = scene;
491 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
492 TRUE, TRUE, 100, 255,
493 (gpointer)&change_static_actor, NULL, NULL);
494 change_static_actor(actor, desktop_plugin);
495 scene->actors = g_slist_append(scene->actors, actor);
498 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
499 FALSE, FALSE, 100, 255,
500 (gpointer)&change_sun, NULL, NULL);
501 actor->time_start_animation = time(NULL);
502 actor->duration_animation = G_MAXINT;
503 change_sun(actor, desktop_plugin);
504 scene->actors = g_slist_append(scene->actors, actor);
507 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
508 TRUE, 100, 255, NULL, NULL);
509 scene.actors = g_slist_append(scene.actors, actor);
512 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
513 FALSE, FALSE, 100, 255,
514 (gpointer)&change_moon, NULL, NULL);
515 change_moon(actor, desktop_plugin);
516 scene->actors = g_slist_append(scene->actors, actor);
518 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
519 FALSE, FALSE, 100, 255,
520 (gpointer)&change_cloud, NULL, NULL);
521 actor->time_start_animation = now + fast_rnd(30) + 10;
522 actor->duration_animation = 3*60;
523 scene->actors = g_slist_append(scene->actors, actor);
525 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
526 FALSE, FALSE, 100, 255,
527 (gpointer)&change_cloud, NULL, NULL);
528 actor->time_start_animation = now + fast_rnd(10);
529 actor->duration_animation = 3*60;
530 scene->actors = g_slist_append(scene->actors, actor);
532 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
533 FALSE, FALSE, 100, 255,
534 (gpointer)&change_cloud, NULL, NULL);
535 actor->time_start_animation = now + fast_rnd(60) + 20;
536 actor->duration_animation = 5*60;
537 scene->actors = g_slist_append(scene->actors, actor);
540 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
541 FALSE, FALSE, 100, 255,
542 (gpointer)&change_plane2, NULL, NULL);
543 actor->time_start_animation = now + fast_rnd(40) + 20;
544 actor->duration_animation = 60;
545 scene->actors = g_slist_append(scene->actors, actor);
547 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
548 FALSE, FALSE, 100, 255,
549 (gpointer)&change_plane1, NULL, NULL);
550 actor->time_start_animation = now + fast_rnd(20);
551 actor->duration_animation = 30;
552 scene->actors = g_slist_append(scene->actors, actor);
554 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
555 TRUE, TRUE, 100, 255,
556 (gpointer)&change_static_actor_with_corner, NULL, NULL);
557 change_static_actor_with_corner(actor, desktop_plugin);
558 scene->actors = g_slist_append(scene->actors, actor);
560 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
561 FALSE, FALSE, 100, 255,
562 (gpointer)&change_wind, NULL, NULL);
563 change_wind(actor, desktop_plugin);
564 scene->actors = g_slist_append(scene->actors, actor);
566 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
567 486, 425, 10, 18, 38,
568 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
569 //actor->time_start_animation = now + fast_rnd(30) + 10;
570 scene->actors = g_slist_append(scene->actors, actor1);
572 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
573 486, 425, 10, 18, 38,
574 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
575 //actor->time_start_animation = now + fast_rnd(30) + 10;
576 scene->actors = g_slist_append(scene->actors, actor2);
577 child = g_ptr_array_sized_new(2);
578 g_ptr_array_add(child, actor1);
579 g_ptr_array_add(child, actor2);
580 actor = init_object(desktop_plugin, "signal", "",
581 486, 425, 10, 18, 38,
582 FALSE, FALSE, 100, 255,
583 (gpointer)&change_signal, NULL, child);
584 actor->time_start_animation = now + fast_rnd(30) + 10;
585 scene->actors = g_slist_append(scene->actors, actor);
626 for (i=0; i<13; i++){
627 actor = init_object(desktop_plugin, "window", "window.png",
628 winds[i][0], winds[i][1], 10, 8, 9,
629 FALSE, TRUE, 100, 255,
630 (gpointer)&change_window1, NULL, NULL);
631 //change_window1(actor, desktop_plugin);
632 actor->time_start_animation = now + fast_rnd(30);
633 scene->actors = g_slist_append(scene->actors, actor);
637 run_long_timeout(desktop_plugin);
642 init_scene_theme(AWallpaperPlugin *desktop_plugin)
644 void (*func)(gpointer);
645 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
647 (*func)(desktop_plugin);