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 desktop_plugin->priv->scene = scene;
163 actor = init_object(desktop_plugin, "sky", "sky0.png",
165 TRUE , TRUE, 100, 255,
166 (gpointer)&change_static_actor, NULL, NULL);
167 change_static_actor(actor, desktop_plugin);
168 scene->actors = g_slist_append(scene->actors, actor);
170 actor = init_object(desktop_plugin, "sun", "sun.png",
172 FALSE, FALSE, 100, 255,
173 (gpointer)&change_sun, NULL, NULL);
174 actor->time_start_animation = now;
175 actor->duration_animation = G_MAXINT;
176 change_sun(actor, desktop_plugin);
177 scene->actors = g_slist_append(scene->actors, actor);
179 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
180 // TRUE, 100, 255, NULL, NULL);
181 //scene.actors = g_slist_append(scene.actors, actor);
183 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
184 0, fast_rnd(300)-97, 7, 150, 97,
185 FALSE, FALSE, 100, 255,
186 (gpointer)&change_cloud, NULL, NULL);
187 actor->time_start_animation = now + fast_rnd(20);
188 actor->duration_animation = 3*60;
189 scene->actors = g_slist_append(scene->actors, actor);
191 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
192 0, fast_rnd(300)-75, 7, 188, 75,
193 FALSE, FALSE, 100, 255,
194 (gpointer)&change_cloud, NULL, NULL);
195 actor->time_start_animation = now + fast_rnd(40)+10;
196 actor->duration_animation = 3*60;
197 scene->actors = g_slist_append(scene->actors, actor);
199 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
200 0, fast_rnd(300)-75, 7, 150, 75,
201 FALSE, FALSE, 100, 255,
202 (gpointer)&change_cloud, NULL, NULL);
203 actor->time_start_animation = now + fast_rnd(60) + 20;
204 actor->duration_animation = 5*60;
205 scene->actors = g_slist_append(scene->actors, actor);
208 actor = init_object(desktop_plugin, "town", "town0.png",
210 TRUE, TRUE, 100, 255,
211 (gpointer)&change_static_actor, NULL, NULL);
212 change_static_actor(actor, desktop_plugin);
213 scene->actors = g_slist_append(scene->actors, actor);
215 actor = init_object(desktop_plugin, "stend", "stend0.png",
216 452, 166, 9, 300, 305,
217 TRUE, TRUE, 100, 255,
218 (gpointer)&change_static_actor, NULL, NULL);
219 change_static_actor(actor, desktop_plugin);
220 scene->actors = g_slist_append(scene->actors, actor);
222 actor = init_object(desktop_plugin, "billboard_text", "",
223 460, 180, 9, 300, 108,
224 TRUE, FALSE, 100, 255,
225 (gpointer)&change_billboard, NULL, NULL);
226 create_hildon_actor_text(actor, desktop_plugin, "");
227 //actor->time_start_animation = time(NULL) + 20;
228 change_billboard(actor, desktop_plugin);
229 scene->actors = g_slist_append(scene->actors, actor);
231 actor = init_object(desktop_plugin, "tram", "tram.png",
232 -300, 225, 10, 350, 210,
233 FALSE, FALSE, 100, 255,
234 (gpointer)&change_tram, NULL, NULL);
235 actor->time_start_animation = time(NULL) + fast_rnd(10);
236 actor->duration_animation = 60;
237 scene->actors = g_slist_append(scene->actors, actor);
239 actor = init_object(desktop_plugin, "border", "border0.png",
240 0, 480-79, 11, 800, 79,
241 TRUE, TRUE, 100, 255,
242 (gpointer)&change_static_actor_with_corner, NULL, NULL);
243 change_static_actor_with_corner(actor, desktop_plugin);
244 scene->actors = g_slist_append(scene->actors, actor);
246 actor = init_object(desktop_plugin, "moon", "moon1.png",
248 FALSE, FALSE, 100, 255,
249 (gpointer)&change_moon, NULL, NULL);
250 change_moon(actor, desktop_plugin);
251 scene->actors = g_slist_append(scene->actors, actor);
253 actor = init_object(desktop_plugin, "wind", "",
255 FALSE, FALSE, 100, 255,
256 (gpointer)&change_wind, NULL, NULL);
257 change_wind(actor, desktop_plugin);
258 scene->actors = g_slist_append(scene->actors, actor);
260 /* windows in 4-th house */
300 for (i=0; i<13; i++){
301 actor = init_object(desktop_plugin, "window1", "window1.png",
302 winds[i][0], winds[i][1], 8, 8, 10,
303 FALSE, FALSE, 100, 255,
304 (gpointer)&change_window1, NULL, NULL);
305 //change_window1(actor, desktop_plugin);
306 actor->time_start_animation = now + fast_rnd(30);
307 scene->actors = g_slist_append(scene->actors, actor);
311 /* windows in 1-th house */
337 actor = init_object(desktop_plugin, "window2", "window2.png",
338 winds[i][0], winds[i][1], 8, 8, 10,
339 FALSE, FALSE, 100, 255,
340 (gpointer)&change_window1, NULL, NULL);
341 //change_window1(actor, desktop_plugin);
342 actor->time_start_animation = now + fast_rnd(30);
343 scene->actors = g_slist_append(scene->actors, actor);
347 /* windows in 3-th house */
379 for (i=0; i<10; i++){
380 actor = init_object(desktop_plugin, "window3", "window3.png",
381 winds[i][0], winds[i][1], 8, 8, 10,
382 FALSE, FALSE, 100, 255,
383 (gpointer)&change_window1, NULL, NULL);
384 //change_window1(actor, desktop_plugin);
385 actor->time_start_animation = now + fast_rnd(30);
386 scene->actors = g_slist_append(scene->actors, actor);
390 /* windows in 5-th house */
414 actor = init_object(desktop_plugin, "window4", "window4.png",
415 winds[i][0], winds[i][1], 8, 8, 10,
416 FALSE, FALSE, 100, 255,
417 (gpointer)&change_window1, NULL, NULL);
418 //change_window1(actor, desktop_plugin);
419 actor->time_start_animation = now + fast_rnd(30);
420 scene->actors = g_slist_append(scene->actors, actor);
424 /* windows in 6-th house */
445 actor = init_object(desktop_plugin, "window5", "window5.png",
446 winds[i][0], winds[i][1], 8, 8, 10,
447 FALSE, FALSE, 100, 255,
448 (gpointer)&change_window1, NULL, NULL);
449 //change_window1(actor, desktop_plugin);
450 actor->time_start_animation = now + fast_rnd(30);
451 scene->actors = g_slist_append(scene->actors, actor);
454 run_long_timeout(desktop_plugin);
457 anim = g_new0(Animation, 1);
460 anim->func_change = &change_tram;
461 anim->func_time = NULL;
462 anim->timestart = time(NULL);
465 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
469 /* Init Berlin Scene */
471 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
473 Actor *actor, *actor1, *actor2;
475 gint now = time(NULL);
478 GPtrArray *child = NULL;
480 scene = g_new0(Scene, 1);
481 scene->daytime = get_daytime();
482 scene->actors = NULL;
483 scene->wind_orientation = -1;
484 scene->wind_angle = 0.3;
485 /* init value for random */
486 scene->seed = time(NULL);
487 desktop_plugin->priv->scene = scene;
489 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
490 TRUE, TRUE, 100, 255,
491 (gpointer)&change_static_actor, NULL, NULL);
492 change_static_actor(actor, desktop_plugin);
493 scene->actors = g_slist_append(scene->actors, actor);
496 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
497 FALSE, FALSE, 100, 255,
498 (gpointer)&change_sun, NULL, NULL);
499 actor->time_start_animation = time(NULL);
500 actor->duration_animation = G_MAXINT;
501 change_sun(actor, desktop_plugin);
502 scene->actors = g_slist_append(scene->actors, actor);
505 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
506 TRUE, 100, 255, NULL, NULL);
507 scene.actors = g_slist_append(scene.actors, actor);
510 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
511 FALSE, FALSE, 100, 255,
512 (gpointer)&change_moon, NULL, NULL);
513 change_moon(actor, desktop_plugin);
514 scene->actors = g_slist_append(scene->actors, actor);
516 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
517 FALSE, FALSE, 100, 255,
518 (gpointer)&change_cloud, NULL, NULL);
519 actor->time_start_animation = now + fast_rnd(30) + 10;
520 actor->duration_animation = 3*60;
521 scene->actors = g_slist_append(scene->actors, actor);
523 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
524 FALSE, FALSE, 100, 255,
525 (gpointer)&change_cloud, NULL, NULL);
526 actor->time_start_animation = now + fast_rnd(10);
527 actor->duration_animation = 3*60;
528 scene->actors = g_slist_append(scene->actors, actor);
530 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
531 FALSE, FALSE, 100, 255,
532 (gpointer)&change_cloud, NULL, NULL);
533 actor->time_start_animation = now + fast_rnd(60) + 20;
534 actor->duration_animation = 5*60;
535 scene->actors = g_slist_append(scene->actors, actor);
538 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
539 FALSE, FALSE, 100, 255,
540 (gpointer)&change_plane2, NULL, NULL);
541 actor->time_start_animation = now + fast_rnd(40) + 20;
542 actor->duration_animation = 60;
543 scene->actors = g_slist_append(scene->actors, actor);
545 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
546 FALSE, FALSE, 100, 255,
547 (gpointer)&change_plane1, NULL, NULL);
548 actor->time_start_animation = now + fast_rnd(20);
549 actor->duration_animation = 30;
550 scene->actors = g_slist_append(scene->actors, actor);
552 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
553 TRUE, TRUE, 100, 255,
554 (gpointer)&change_static_actor_with_corner, NULL, NULL);
555 change_static_actor_with_corner(actor, desktop_plugin);
556 scene->actors = g_slist_append(scene->actors, actor);
558 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
559 FALSE, FALSE, 100, 255,
560 (gpointer)&change_wind, NULL, NULL);
561 change_wind(actor, desktop_plugin);
562 scene->actors = g_slist_append(scene->actors, actor);
564 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
565 486, 425, 10, 18, 38,
566 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
567 //actor->time_start_animation = now + fast_rnd(30) + 10;
568 scene->actors = g_slist_append(scene->actors, actor1);
570 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
571 486, 425, 10, 18, 38,
572 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
573 //actor->time_start_animation = now + fast_rnd(30) + 10;
574 scene->actors = g_slist_append(scene->actors, actor2);
575 child = g_ptr_array_sized_new(2);
576 g_ptr_array_add(child, actor1);
577 g_ptr_array_add(child, actor2);
578 actor = init_object(desktop_plugin, "signal", "",
579 486, 425, 10, 18, 38,
580 FALSE, FALSE, 100, 255,
581 (gpointer)&change_signal, NULL, child);
582 actor->time_start_animation = now + fast_rnd(30) + 10;
583 scene->actors = g_slist_append(scene->actors, actor);
624 for (i=0; i<13; i++){
625 actor = init_object(desktop_plugin, "window", "window.png",
626 winds[i][0], winds[i][1], 10, 8, 9,
627 FALSE, TRUE, 100, 255,
628 (gpointer)&change_window1, NULL, NULL);
629 //change_window1(actor, desktop_plugin);
630 actor->time_start_animation = now + fast_rnd(30);
631 scene->actors = g_slist_append(scene->actors, actor);
635 run_long_timeout(desktop_plugin);
640 init_scene_theme(AWallpaperPlugin *desktop_plugin)
642 void (*func)(gpointer);
643 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
645 (*func)(desktop_plugin);