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 if (desktop_plugin->priv->scene){
31 GSList * tmp = desktop_plugin->priv->scene->actors;
33 destroy_actor(tmp->data);
34 tmp = g_slist_next(tmp);
38 desktop_plugin->priv->scene->actors = NULL;
39 if (desktop_plugin->priv->scene){
40 g_free(desktop_plugin->priv->scene);
41 desktop_plugin->priv->scene = NULL;
47 reload_scene(AWallpaperPlugin *desktop_plugin)
49 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
50 destroy_scene(desktop_plugin);
52 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
53 init_scene_Modern(desktop_plugin);
54 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
55 init_scene_Berlin(desktop_plugin);
56 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
57 init_scene_Matrix(desktop_plugin);
59 init_scene_theme(desktop_plugin);
64 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
69 gint now = time(NULL);
71 gint sizes[4] = {170, 229, 130, 150},
72 heights[4] = {0, 100, 200, 300},
75 scene = g_new0(Scene, 1);
77 desktop_plugin->priv->scene = scene;
79 actor = init_object(desktop_plugin, "background", "bg.png",
83 scene->actors = g_slist_append(scene->actors, actor);
85 child = g_ptr_array_sized_new(24);
90 str = g_strdup_printf("tape%i_%i.png", n+1, i);
91 actor = init_object(desktop_plugin, "tape", str,
92 fast_rnd(700), fast_rnd(430), 5+fast_rnd(20), 800, sizes[n],
95 scene->actors = g_slist_append(scene->actors, actor);
96 g_ptr_array_add(child, actor);
101 actor = init_object(desktop_plugin, "tape", "",
103 FALSE, FALSE, 100, 255,
104 (gpointer)&change_tape, NULL, child);
105 actor->time_start_animation = now;
106 actor->duration_animation = G_MAXINT;
107 scene->actors = g_slist_append(scene->actors, actor);
109 run_long_timeout(desktop_plugin);
113 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
118 gint now = time(NULL);
121 if (desktop_plugin->priv->rich_animation){
129 /* fprintf(stderr, "init scene2 \n"); */
130 scene = g_new0(Scene, 1);
131 //scene.daytime = get_daytime();
132 scene->actors = NULL;
133 desktop_plugin->priv->scene = scene;
135 actor = init_object(desktop_plugin, "background", "bg.png",
137 TRUE, TRUE, 100, 255,
139 scene->actors = g_slist_append(scene->actors, actor);
141 actor = init_object(desktop_plugin, "symbols", "symbols.png",
143 TRUE, TRUE, 100, 255,
145 scene->actors = g_slist_append(scene->actors, actor);
147 child = g_ptr_array_sized_new(4);
148 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
150 TRUE, TRUE, 100, 255,
152 //actor->time_start_animation = now;
153 //actor->duration_animation = G_MAXINT;
154 scene->actors = g_slist_append(scene->actors, actor);
155 g_ptr_array_add(child, actor);
157 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
159 TRUE, TRUE, 100, 255,
161 //actor->time_start_animation = now;
162 //actor->duration_animation = G_MAXINT;
163 scene->actors = g_slist_append(scene->actors, actor);
164 g_ptr_array_add(child, actor);
166 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
168 TRUE, TRUE, 100, 255,
170 //actor->time_start_animation = now;
171 //actor->duration_animation = G_MAXINT;
172 scene->actors = g_slist_append(scene->actors, actor);
173 g_ptr_array_add(child, actor);
175 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
177 TRUE, TRUE, 100, 255,
179 //actor->time_start_animation = now;
180 //actor->duration_animation = G_MAXINT;
181 scene->actors = g_slist_append(scene->actors, actor);
182 g_ptr_array_add(child, actor);
184 actor = init_object(desktop_plugin, "layers", "",
186 FALSE, FALSE, 100, 255,
187 (gpointer)&change_layer, NULL, child);
188 actor->time_start_animation = now;
189 actor->duration_animation = G_MAXINT;
190 scene->actors = g_slist_append(scene->actors, actor);
192 run_long_timeout(desktop_plugin);
196 /* Init Modern Scene */
198 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
202 gint now = time(NULL);
207 /* fprintf(stderr, "init scene \n"); */
208 scene = g_new0(Scene, 1);
209 scene->daytime = get_daytime();
210 scene->actors = NULL;
211 scene->wind_orientation = -1;
212 scene->wind_angle = 0.3;
213 /* init value for random */
214 scene->seed = time(NULL);
215 scene->notification = TRUE;
216 desktop_plugin->priv->scene = scene;
217 actor = init_object(desktop_plugin, "sky", "sky0.png",
219 TRUE , TRUE, 100, 255,
220 (gpointer)&change_static_actor, NULL, NULL);
221 scene->actors = g_slist_append(scene->actors, actor);
222 change_static_actor(actor, desktop_plugin);
224 actor = init_object(desktop_plugin, "sun", "sun.png",
226 FALSE, FALSE, 100, 255,
227 (gpointer)&change_sun, NULL, NULL);
228 actor->time_start_animation = now;
229 actor->duration_animation = G_MAXINT;
230 change_sun(actor, desktop_plugin);
231 scene->actors = g_slist_append(scene->actors, actor);
233 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
234 // TRUE, 100, 255, NULL, NULL);
235 //scene.actors = g_slist_append(scene.actors, actor);
237 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
238 0, fast_rnd(300)-97, 7, 150, 97,
239 FALSE, FALSE, 100, 255,
240 (gpointer)&change_cloud, NULL, NULL);
241 actor->time_start_animation = now + fast_rnd(20);
242 actor->duration_animation = 3*60;
243 scene->actors = g_slist_append(scene->actors, actor);
245 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
246 0, fast_rnd(300)-75, 7, 188, 75,
247 FALSE, FALSE, 100, 255,
248 (gpointer)&change_cloud, NULL, NULL);
249 actor->time_start_animation = now + fast_rnd(40)+10;
250 actor->duration_animation = 3*60;
251 scene->actors = g_slist_append(scene->actors, actor);
253 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
254 0, fast_rnd(300)-75, 7, 150, 75,
255 FALSE, FALSE, 100, 255,
256 (gpointer)&change_cloud, NULL, NULL);
257 actor->time_start_animation = now + fast_rnd(60) + 20;
258 actor->duration_animation = 5*60;
259 scene->actors = g_slist_append(scene->actors, actor);
262 actor = init_object(desktop_plugin, "town", "town0.png",
264 TRUE, TRUE, 100, 255,
265 (gpointer)&change_static_actor, NULL, NULL);
266 change_static_actor(actor, desktop_plugin);
267 scene->actors = g_slist_append(scene->actors, actor);
269 actor = init_object(desktop_plugin, "stend", "stend0.png",
270 452, 166, 9, 300, 305,
271 TRUE, TRUE, 100, 255,
272 (gpointer)&change_static_actor, NULL, NULL);
273 change_static_actor(actor, desktop_plugin);
274 scene->actors = g_slist_append(scene->actors, actor);
277 child = g_ptr_array_sized_new(4);
278 actor = init_object(desktop_plugin, "call", "call.png",
280 FALSE, TRUE, 100, 255,
282 scene->actors = g_slist_append(scene->actors, actor);
283 g_ptr_array_add(child, actor);
285 actor = init_object(desktop_plugin, "chat", "chat.png",
287 FALSE, TRUE, 100, 255,
289 scene->actors = g_slist_append(scene->actors, actor);
290 g_ptr_array_add(child, actor);
292 actor = init_object(desktop_plugin, "mail", "mail.png",
294 FALSE, TRUE, 100, 255,
296 scene->actors = g_slist_append(scene->actors, actor);
297 g_ptr_array_add(child, actor);
299 actor = init_object(desktop_plugin, "sms", "sms.png",
301 FALSE, TRUE, 100, 255,
303 scene->actors = g_slist_append(scene->actors, actor);
304 g_ptr_array_add(child, actor);
306 actor = init_object(desktop_plugin, "billboard_text", "",
307 470, 174, 9, 300, 108,
308 FALSE, FALSE, 100, 255,
309 (gpointer)&change_billboard, NULL, child);
310 create_hildon_actor_text(actor, desktop_plugin);
311 //actor->time_start_animation = time(NULL) + 20;
312 change_billboard(actor, desktop_plugin);
313 scene->actors = g_slist_append(scene->actors, actor);
315 actor = init_object(desktop_plugin, "tram", "tram.png",
316 -300, 225, 10, 350, 210,
317 FALSE, FALSE, 100, 255,
318 (gpointer)&change_tram, NULL, NULL);
319 actor->time_start_animation = time(NULL) + fast_rnd(10);
320 actor->duration_animation = 60;
321 scene->actors = g_slist_append(scene->actors, actor);
323 actor = init_object(desktop_plugin, "border", "border0.png",
324 0, 480-79, 11, 800, 79,
325 TRUE, TRUE, 100, 255,
326 (gpointer)&change_static_actor_with_corner, NULL, NULL);
327 change_static_actor_with_corner(actor, desktop_plugin);
328 scene->actors = g_slist_append(scene->actors, actor);
330 actor = init_object(desktop_plugin, "moon", "moon1.png",
332 FALSE, FALSE, 100, 255,
333 (gpointer)&change_moon, NULL, NULL);
334 change_moon(actor, desktop_plugin);
335 scene->actors = g_slist_append(scene->actors, actor);
337 actor = init_object(desktop_plugin, "wind", "",
339 FALSE, FALSE, 100, 255,
340 (gpointer)&change_wind, NULL, NULL);
341 change_wind(actor, desktop_plugin);
342 scene->actors = g_slist_append(scene->actors, actor);
344 /* windows in 4-th house */
384 for (i=0; i<13; i++){
385 actor = init_object(desktop_plugin, "window1", "window1.png",
386 winds[i][0], winds[i][1], 8, 8, 10,
387 FALSE, FALSE, 100, 255,
388 (gpointer)&change_window1, NULL, NULL);
389 //change_window1(actor, desktop_plugin);
390 actor->time_start_animation = now + fast_rnd(30);
391 scene->actors = g_slist_append(scene->actors, actor);
395 /* windows in 1-th house */
421 actor = init_object(desktop_plugin, "window2", "window2.png",
422 winds[i][0], winds[i][1], 8, 8, 10,
423 FALSE, FALSE, 100, 255,
424 (gpointer)&change_window1, NULL, NULL);
425 //change_window1(actor, desktop_plugin);
426 actor->time_start_animation = now + fast_rnd(30);
427 scene->actors = g_slist_append(scene->actors, actor);
431 /* windows in 3-th house */
463 for (i=0; i<10; i++){
464 actor = init_object(desktop_plugin, "window3", "window3.png",
465 winds[i][0], winds[i][1], 8, 8, 10,
466 FALSE, FALSE, 100, 255,
467 (gpointer)&change_window1, NULL, NULL);
468 //change_window1(actor, desktop_plugin);
469 actor->time_start_animation = now + fast_rnd(30);
470 scene->actors = g_slist_append(scene->actors, actor);
474 /* windows in 5-th house */
498 actor = init_object(desktop_plugin, "window4", "window4.png",
499 winds[i][0], winds[i][1], 8, 8, 10,
500 FALSE, FALSE, 100, 255,
501 (gpointer)&change_window1, NULL, NULL);
502 //change_window1(actor, desktop_plugin);
503 actor->time_start_animation = now + fast_rnd(30);
504 scene->actors = g_slist_append(scene->actors, actor);
508 /* windows in 6-th house */
529 actor = init_object(desktop_plugin, "window5", "window5.png",
530 winds[i][0], winds[i][1], 8, 8, 10,
531 FALSE, FALSE, 100, 255,
532 (gpointer)&change_window1, NULL, NULL);
533 //change_window1(actor, desktop_plugin);
534 actor->time_start_animation = now + fast_rnd(30);
535 scene->actors = g_slist_append(scene->actors, actor);
538 run_long_timeout(desktop_plugin);
541 anim = g_new0(Animation, 1);
544 anim->func_change = &change_tram;
545 anim->func_time = NULL;
546 anim->timestart = time(NULL);
549 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
553 /* Init Berlin Scene */
555 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
557 Actor *actor, *actor1, *actor2;
559 gint now = time(NULL);
562 GPtrArray *child = NULL;
564 scene = g_new0(Scene, 1);
565 scene->daytime = get_daytime();
566 scene->actors = NULL;
567 scene->wind_orientation = -1;
568 scene->wind_angle = 0.3;
569 /* init value for random */
570 scene->seed = time(NULL);
571 desktop_plugin->priv->scene = scene;
573 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
574 TRUE, TRUE, 100, 255,
575 (gpointer)&change_static_actor, NULL, NULL);
576 change_static_actor(actor, desktop_plugin);
577 scene->actors = g_slist_append(scene->actors, actor);
580 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
581 FALSE, FALSE, 100, 255,
582 (gpointer)&change_sun, NULL, NULL);
583 actor->time_start_animation = time(NULL);
584 actor->duration_animation = G_MAXINT;
585 change_sun(actor, desktop_plugin);
586 scene->actors = g_slist_append(scene->actors, actor);
589 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
590 TRUE, 100, 255, NULL, NULL);
591 scene.actors = g_slist_append(scene.actors, actor);
594 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
595 FALSE, FALSE, 100, 255,
596 (gpointer)&change_moon, NULL, NULL);
597 change_moon(actor, desktop_plugin);
598 scene->actors = g_slist_append(scene->actors, actor);
600 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
601 FALSE, FALSE, 100, 255,
602 (gpointer)&change_cloud, NULL, NULL);
603 actor->time_start_animation = now + fast_rnd(30) + 10;
604 actor->duration_animation = 3*60;
605 scene->actors = g_slist_append(scene->actors, actor);
607 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
608 FALSE, FALSE, 100, 255,
609 (gpointer)&change_cloud, NULL, NULL);
610 actor->time_start_animation = now + fast_rnd(10);
611 actor->duration_animation = 3*60;
612 scene->actors = g_slist_append(scene->actors, actor);
614 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
615 FALSE, FALSE, 100, 255,
616 (gpointer)&change_cloud, NULL, NULL);
617 actor->time_start_animation = now + fast_rnd(60) + 20;
618 actor->duration_animation = 5*60;
619 scene->actors = g_slist_append(scene->actors, actor);
622 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
623 FALSE, FALSE, 100, 255,
624 (gpointer)&change_plane2, NULL, NULL);
625 actor->time_start_animation = now + fast_rnd(40) + 20;
626 actor->duration_animation = 60;
627 scene->actors = g_slist_append(scene->actors, actor);
629 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
630 FALSE, FALSE, 100, 255,
631 (gpointer)&change_plane1, NULL, NULL);
632 actor->time_start_animation = now + fast_rnd(20);
633 actor->duration_animation = 30;
634 scene->actors = g_slist_append(scene->actors, actor);
636 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
637 TRUE, TRUE, 100, 255,
638 (gpointer)&change_static_actor_with_corner, NULL, NULL);
639 change_static_actor_with_corner(actor, desktop_plugin);
640 scene->actors = g_slist_append(scene->actors, actor);
642 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
643 FALSE, FALSE, 100, 255,
644 (gpointer)&change_wind, NULL, NULL);
645 change_wind(actor, desktop_plugin);
646 scene->actors = g_slist_append(scene->actors, actor);
648 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
649 486, 425, 10, 18, 38,
650 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
651 //actor->time_start_animation = now + fast_rnd(30) + 10;
652 scene->actors = g_slist_append(scene->actors, actor1);
654 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
655 486, 425, 10, 18, 38,
656 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
657 //actor->time_start_animation = now + fast_rnd(30) + 10;
658 scene->actors = g_slist_append(scene->actors, actor2);
659 child = g_ptr_array_sized_new(2);
660 g_ptr_array_add(child, actor1);
661 g_ptr_array_add(child, actor2);
662 actor = init_object(desktop_plugin, "signal", "",
663 486, 425, 10, 18, 38,
664 FALSE, FALSE, 100, 255,
665 (gpointer)&change_signal, NULL, child);
666 actor->time_start_animation = now + fast_rnd(30) + 10;
667 scene->actors = g_slist_append(scene->actors, actor);
708 for (i=0; i<13; i++){
709 actor = init_object(desktop_plugin, "window", "window.png",
710 winds[i][0], winds[i][1], 10, 8, 9,
711 FALSE, TRUE, 100, 255,
712 (gpointer)&change_window1, NULL, NULL);
713 //change_window1(actor, desktop_plugin);
714 actor->time_start_animation = now + fast_rnd(30);
715 scene->actors = g_slist_append(scene->actors, actor);
719 run_long_timeout(desktop_plugin);
724 init_scene_theme(AWallpaperPlugin *desktop_plugin)
726 void (*func)(gpointer);
727 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
729 (*func)(desktop_plugin);