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);
154 //fprintf(stderr, "init scene \n");
155 scene = g_new0(Scene, 1);
156 scene->daytime = get_daytime();
157 scene->actors = NULL;
158 scene->wind_orientation = -1;
159 scene->wind_angle = 0.3;
160 /* init value for random */
161 scene->seed = time(NULL);
162 scene->notification = TRUE;
163 desktop_plugin->priv->scene = scene;
166 actor = init_object(desktop_plugin, "sky", "sky0.png",
168 TRUE , TRUE, 100, 255,
169 (gpointer)&change_static_actor, NULL, NULL);
170 change_static_actor(actor, desktop_plugin);
171 scene->actors = g_slist_append(scene->actors, actor);
173 actor = init_object(desktop_plugin, "sun", "sun.png",
175 FALSE, FALSE, 100, 255,
176 (gpointer)&change_sun, NULL, NULL);
177 actor->time_start_animation = now;
178 actor->duration_animation = G_MAXINT;
179 change_sun(actor, desktop_plugin);
180 scene->actors = g_slist_append(scene->actors, actor);
182 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
183 // TRUE, 100, 255, NULL, NULL);
184 //scene.actors = g_slist_append(scene.actors, actor);
186 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
187 0, fast_rnd(300)-97, 7, 150, 97,
188 FALSE, FALSE, 100, 255,
189 (gpointer)&change_cloud, NULL, NULL);
190 actor->time_start_animation = now + fast_rnd(20);
191 actor->duration_animation = 3*60;
192 scene->actors = g_slist_append(scene->actors, actor);
194 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
195 0, fast_rnd(300)-75, 7, 188, 75,
196 FALSE, FALSE, 100, 255,
197 (gpointer)&change_cloud, NULL, NULL);
198 actor->time_start_animation = now + fast_rnd(40)+10;
199 actor->duration_animation = 3*60;
200 scene->actors = g_slist_append(scene->actors, actor);
202 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
203 0, fast_rnd(300)-75, 7, 150, 75,
204 FALSE, FALSE, 100, 255,
205 (gpointer)&change_cloud, NULL, NULL);
206 actor->time_start_animation = now + fast_rnd(60) + 20;
207 actor->duration_animation = 5*60;
208 scene->actors = g_slist_append(scene->actors, actor);
211 actor = init_object(desktop_plugin, "town", "town0.png",
213 TRUE, TRUE, 100, 255,
214 (gpointer)&change_static_actor, NULL, NULL);
215 change_static_actor(actor, desktop_plugin);
216 scene->actors = g_slist_append(scene->actors, actor);
218 actor = init_object(desktop_plugin, "stend", "stend0.png",
219 452, 166, 9, 300, 305,
220 TRUE, TRUE, 100, 255,
221 (gpointer)&change_static_actor, NULL, NULL);
222 change_static_actor(actor, desktop_plugin);
223 scene->actors = g_slist_append(scene->actors, actor);
226 child = g_ptr_array_sized_new(4);
227 actor = init_object(desktop_plugin, "call", "call.png",
229 FALSE, TRUE, 100, 255,
231 scene->actors = g_slist_append(scene->actors, actor);
232 g_ptr_array_add(child, actor);
234 actor = init_object(desktop_plugin, "chat", "chat.png",
236 FALSE, TRUE, 100, 255,
238 scene->actors = g_slist_append(scene->actors, actor);
239 g_ptr_array_add(child, actor);
241 actor = init_object(desktop_plugin, "mail", "mail.png",
243 FALSE, TRUE, 100, 255,
245 scene->actors = g_slist_append(scene->actors, actor);
246 g_ptr_array_add(child, actor);
248 actor = init_object(desktop_plugin, "sms", "sms.png",
250 FALSE, TRUE, 100, 255,
252 scene->actors = g_slist_append(scene->actors, actor);
253 g_ptr_array_add(child, actor);
255 actor = init_object(desktop_plugin, "billboard_text", "",
256 470, 174, 9, 300, 108,
257 FALSE, FALSE, 100, 255,
258 (gpointer)&change_billboard, NULL, child);
259 create_hildon_actor_text(actor, desktop_plugin);
260 //actor->time_start_animation = time(NULL) + 20;
261 change_billboard(actor, desktop_plugin);
262 scene->actors = g_slist_append(scene->actors, actor);
264 actor = init_object(desktop_plugin, "tram", "tram.png",
265 -300, 225, 10, 350, 210,
266 FALSE, FALSE, 100, 255,
267 (gpointer)&change_tram, NULL, NULL);
268 actor->time_start_animation = time(NULL) + fast_rnd(10);
269 actor->duration_animation = 60;
270 scene->actors = g_slist_append(scene->actors, actor);
272 actor = init_object(desktop_plugin, "border", "border0.png",
273 0, 480-79, 11, 800, 79,
274 TRUE, TRUE, 100, 255,
275 (gpointer)&change_static_actor_with_corner, NULL, NULL);
276 change_static_actor_with_corner(actor, desktop_plugin);
277 scene->actors = g_slist_append(scene->actors, actor);
279 actor = init_object(desktop_plugin, "moon", "moon1.png",
281 FALSE, FALSE, 100, 255,
282 (gpointer)&change_moon, NULL, NULL);
283 change_moon(actor, desktop_plugin);
284 scene->actors = g_slist_append(scene->actors, actor);
286 actor = init_object(desktop_plugin, "wind", "",
288 FALSE, FALSE, 100, 255,
289 (gpointer)&change_wind, NULL, NULL);
290 change_wind(actor, desktop_plugin);
291 scene->actors = g_slist_append(scene->actors, actor);
293 /* windows in 4-th house */
333 for (i=0; i<13; i++){
334 actor = init_object(desktop_plugin, "window1", "window1.png",
335 winds[i][0], winds[i][1], 8, 8, 10,
336 FALSE, FALSE, 100, 255,
337 (gpointer)&change_window1, NULL, NULL);
338 //change_window1(actor, desktop_plugin);
339 actor->time_start_animation = now + fast_rnd(30);
340 scene->actors = g_slist_append(scene->actors, actor);
344 /* windows in 1-th house */
370 actor = init_object(desktop_plugin, "window2", "window2.png",
371 winds[i][0], winds[i][1], 8, 8, 10,
372 FALSE, FALSE, 100, 255,
373 (gpointer)&change_window1, NULL, NULL);
374 //change_window1(actor, desktop_plugin);
375 actor->time_start_animation = now + fast_rnd(30);
376 scene->actors = g_slist_append(scene->actors, actor);
380 /* windows in 3-th house */
412 for (i=0; i<10; i++){
413 actor = init_object(desktop_plugin, "window3", "window3.png",
414 winds[i][0], winds[i][1], 8, 8, 10,
415 FALSE, FALSE, 100, 255,
416 (gpointer)&change_window1, NULL, NULL);
417 //change_window1(actor, desktop_plugin);
418 actor->time_start_animation = now + fast_rnd(30);
419 scene->actors = g_slist_append(scene->actors, actor);
423 /* windows in 5-th house */
447 actor = init_object(desktop_plugin, "window4", "window4.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);
457 /* windows in 6-th house */
478 actor = init_object(desktop_plugin, "window5", "window5.png",
479 winds[i][0], winds[i][1], 8, 8, 10,
480 FALSE, FALSE, 100, 255,
481 (gpointer)&change_window1, NULL, NULL);
482 //change_window1(actor, desktop_plugin);
483 actor->time_start_animation = now + fast_rnd(30);
484 scene->actors = g_slist_append(scene->actors, actor);
487 run_long_timeout(desktop_plugin);
490 anim = g_new0(Animation, 1);
493 anim->func_change = &change_tram;
494 anim->func_time = NULL;
495 anim->timestart = time(NULL);
498 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
502 /* Init Berlin Scene */
504 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
506 Actor *actor, *actor1, *actor2;
508 gint now = time(NULL);
511 GPtrArray *child = NULL;
513 scene = g_new0(Scene, 1);
514 scene->daytime = get_daytime();
515 scene->actors = NULL;
516 scene->wind_orientation = -1;
517 scene->wind_angle = 0.3;
518 /* init value for random */
519 scene->seed = time(NULL);
520 desktop_plugin->priv->scene = scene;
522 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
523 TRUE, TRUE, 100, 255,
524 (gpointer)&change_static_actor, NULL, NULL);
525 change_static_actor(actor, desktop_plugin);
526 scene->actors = g_slist_append(scene->actors, actor);
529 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
530 FALSE, FALSE, 100, 255,
531 (gpointer)&change_sun, NULL, NULL);
532 actor->time_start_animation = time(NULL);
533 actor->duration_animation = G_MAXINT;
534 change_sun(actor, desktop_plugin);
535 scene->actors = g_slist_append(scene->actors, actor);
538 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
539 TRUE, 100, 255, NULL, NULL);
540 scene.actors = g_slist_append(scene.actors, actor);
543 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
544 FALSE, FALSE, 100, 255,
545 (gpointer)&change_moon, NULL, NULL);
546 change_moon(actor, desktop_plugin);
547 scene->actors = g_slist_append(scene->actors, actor);
549 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
550 FALSE, FALSE, 100, 255,
551 (gpointer)&change_cloud, NULL, NULL);
552 actor->time_start_animation = now + fast_rnd(30) + 10;
553 actor->duration_animation = 3*60;
554 scene->actors = g_slist_append(scene->actors, actor);
556 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
557 FALSE, FALSE, 100, 255,
558 (gpointer)&change_cloud, NULL, NULL);
559 actor->time_start_animation = now + fast_rnd(10);
560 actor->duration_animation = 3*60;
561 scene->actors = g_slist_append(scene->actors, actor);
563 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
564 FALSE, FALSE, 100, 255,
565 (gpointer)&change_cloud, NULL, NULL);
566 actor->time_start_animation = now + fast_rnd(60) + 20;
567 actor->duration_animation = 5*60;
568 scene->actors = g_slist_append(scene->actors, actor);
571 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
572 FALSE, FALSE, 100, 255,
573 (gpointer)&change_plane2, NULL, NULL);
574 actor->time_start_animation = now + fast_rnd(40) + 20;
575 actor->duration_animation = 60;
576 scene->actors = g_slist_append(scene->actors, actor);
578 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
579 FALSE, FALSE, 100, 255,
580 (gpointer)&change_plane1, NULL, NULL);
581 actor->time_start_animation = now + fast_rnd(20);
582 actor->duration_animation = 30;
583 scene->actors = g_slist_append(scene->actors, actor);
585 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
586 TRUE, TRUE, 100, 255,
587 (gpointer)&change_static_actor_with_corner, NULL, NULL);
588 change_static_actor_with_corner(actor, desktop_plugin);
589 scene->actors = g_slist_append(scene->actors, actor);
591 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
592 FALSE, FALSE, 100, 255,
593 (gpointer)&change_wind, NULL, NULL);
594 change_wind(actor, desktop_plugin);
595 scene->actors = g_slist_append(scene->actors, actor);
597 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
598 486, 425, 10, 18, 38,
599 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
600 //actor->time_start_animation = now + fast_rnd(30) + 10;
601 scene->actors = g_slist_append(scene->actors, actor1);
603 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
604 486, 425, 10, 18, 38,
605 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
606 //actor->time_start_animation = now + fast_rnd(30) + 10;
607 scene->actors = g_slist_append(scene->actors, actor2);
608 child = g_ptr_array_sized_new(2);
609 g_ptr_array_add(child, actor1);
610 g_ptr_array_add(child, actor2);
611 actor = init_object(desktop_plugin, "signal", "",
612 486, 425, 10, 18, 38,
613 FALSE, FALSE, 100, 255,
614 (gpointer)&change_signal, NULL, child);
615 actor->time_start_animation = now + fast_rnd(30) + 10;
616 scene->actors = g_slist_append(scene->actors, actor);
657 for (i=0; i<13; i++){
658 actor = init_object(desktop_plugin, "window", "window.png",
659 winds[i][0], winds[i][1], 10, 8, 9,
660 FALSE, TRUE, 100, 255,
661 (gpointer)&change_window1, NULL, NULL);
662 //change_window1(actor, desktop_plugin);
663 actor->time_start_animation = now + fast_rnd(30);
664 scene->actors = g_slist_append(scene->actors, actor);
668 run_long_timeout(desktop_plugin);
673 init_scene_theme(AWallpaperPlugin *desktop_plugin)
675 void (*func)(gpointer);
676 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
678 (*func)(desktop_plugin);