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);
63 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
68 gint now = time(NULL);
71 if (desktop_plugin->priv->rich_animation){
79 //fprintf(stderr, "init scene2 \n");
80 scene = g_new0(Scene, 1);
81 //scene.daytime = get_daytime();
83 desktop_plugin->priv->scene = scene;
85 actor = init_object(desktop_plugin, "background", "bg.png",
89 scene->actors = g_slist_append(scene->actors, actor);
91 actor = init_object(desktop_plugin, "symbols", "symbols.png",
95 scene->actors = g_slist_append(scene->actors, actor);
97 child = g_ptr_array_sized_new(4);
98 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
100 TRUE, TRUE, 100, 255,
102 //actor->time_start_animation = now;
103 //actor->duration_animation = G_MAXINT;
104 scene->actors = g_slist_append(scene->actors, actor);
105 g_ptr_array_add(child, actor);
107 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
109 TRUE, TRUE, 100, 255,
111 //actor->time_start_animation = now;
112 //actor->duration_animation = G_MAXINT;
113 scene->actors = g_slist_append(scene->actors, actor);
114 g_ptr_array_add(child, actor);
116 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
118 TRUE, TRUE, 100, 255,
120 //actor->time_start_animation = now;
121 //actor->duration_animation = G_MAXINT;
122 scene->actors = g_slist_append(scene->actors, actor);
123 g_ptr_array_add(child, actor);
125 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
127 TRUE, TRUE, 100, 255,
129 //actor->time_start_animation = now;
130 //actor->duration_animation = G_MAXINT;
131 scene->actors = g_slist_append(scene->actors, actor);
132 g_ptr_array_add(child, actor);
134 actor = init_object(desktop_plugin, "layers", "",
136 FALSE, FALSE, 100, 255,
137 (gpointer)&change_layer, NULL, child);
138 actor->time_start_animation = now;
139 actor->duration_animation = G_MAXINT;
140 scene->actors = g_slist_append(scene->actors, actor);
142 run_long_timeout(desktop_plugin);
146 /* Init Modern Scene */
148 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
152 gint now = time(NULL);
157 //fprintf(stderr, "init scene \n");
158 scene = g_new0(Scene, 1);
159 scene->daytime = get_daytime();
160 scene->actors = NULL;
161 scene->wind_orientation = -1;
162 scene->wind_angle = 0.3;
163 /* init value for random */
164 scene->seed = time(NULL);
165 scene->notification = TRUE;
166 desktop_plugin->priv->scene = scene;
167 actor = init_object(desktop_plugin, "sky", "sky0.png",
169 TRUE , TRUE, 100, 255,
170 (gpointer)&change_static_actor, NULL, NULL);
171 scene->actors = g_slist_append(scene->actors, actor);
172 change_static_actor(actor, desktop_plugin);
174 actor = init_object(desktop_plugin, "sun", "sun.png",
176 FALSE, FALSE, 100, 255,
177 (gpointer)&change_sun, NULL, NULL);
178 actor->time_start_animation = now;
179 actor->duration_animation = G_MAXINT;
180 change_sun(actor, desktop_plugin);
181 scene->actors = g_slist_append(scene->actors, actor);
183 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
184 // TRUE, 100, 255, NULL, NULL);
185 //scene.actors = g_slist_append(scene.actors, actor);
187 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
188 0, fast_rnd(300)-97, 7, 150, 97,
189 FALSE, FALSE, 100, 255,
190 (gpointer)&change_cloud, NULL, NULL);
191 actor->time_start_animation = now + fast_rnd(20);
192 actor->duration_animation = 3*60;
193 scene->actors = g_slist_append(scene->actors, actor);
195 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
196 0, fast_rnd(300)-75, 7, 188, 75,
197 FALSE, FALSE, 100, 255,
198 (gpointer)&change_cloud, NULL, NULL);
199 actor->time_start_animation = now + fast_rnd(40)+10;
200 actor->duration_animation = 3*60;
201 scene->actors = g_slist_append(scene->actors, actor);
203 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
204 0, fast_rnd(300)-75, 7, 150, 75,
205 FALSE, FALSE, 100, 255,
206 (gpointer)&change_cloud, NULL, NULL);
207 actor->time_start_animation = now + fast_rnd(60) + 20;
208 actor->duration_animation = 5*60;
209 scene->actors = g_slist_append(scene->actors, actor);
212 actor = init_object(desktop_plugin, "town", "town0.png",
214 TRUE, TRUE, 100, 255,
215 (gpointer)&change_static_actor, NULL, NULL);
216 change_static_actor(actor, desktop_plugin);
217 scene->actors = g_slist_append(scene->actors, actor);
219 actor = init_object(desktop_plugin, "stend", "stend0.png",
220 452, 166, 9, 300, 305,
221 TRUE, TRUE, 100, 255,
222 (gpointer)&change_static_actor, NULL, NULL);
223 change_static_actor(actor, desktop_plugin);
224 scene->actors = g_slist_append(scene->actors, actor);
227 child = g_ptr_array_sized_new(4);
228 actor = init_object(desktop_plugin, "call", "call.png",
230 FALSE, TRUE, 100, 255,
232 scene->actors = g_slist_append(scene->actors, actor);
233 g_ptr_array_add(child, actor);
235 actor = init_object(desktop_plugin, "chat", "chat.png",
237 FALSE, TRUE, 100, 255,
239 scene->actors = g_slist_append(scene->actors, actor);
240 g_ptr_array_add(child, actor);
242 actor = init_object(desktop_plugin, "mail", "mail.png",
244 FALSE, TRUE, 100, 255,
246 scene->actors = g_slist_append(scene->actors, actor);
247 g_ptr_array_add(child, actor);
249 actor = init_object(desktop_plugin, "sms", "sms.png",
251 FALSE, TRUE, 100, 255,
253 scene->actors = g_slist_append(scene->actors, actor);
254 g_ptr_array_add(child, actor);
256 actor = init_object(desktop_plugin, "billboard_text", "",
257 470, 174, 9, 300, 108,
258 FALSE, FALSE, 100, 255,
259 (gpointer)&change_billboard, NULL, child);
260 create_hildon_actor_text(actor, desktop_plugin);
261 //actor->time_start_animation = time(NULL) + 20;
262 change_billboard(actor, desktop_plugin);
263 scene->actors = g_slist_append(scene->actors, actor);
265 actor = init_object(desktop_plugin, "tram", "tram.png",
266 -300, 225, 10, 350, 210,
267 FALSE, FALSE, 100, 255,
268 (gpointer)&change_tram, NULL, NULL);
269 actor->time_start_animation = time(NULL) + fast_rnd(10);
270 actor->duration_animation = 60;
271 scene->actors = g_slist_append(scene->actors, actor);
273 actor = init_object(desktop_plugin, "border", "border0.png",
274 0, 480-79, 11, 800, 79,
275 TRUE, TRUE, 100, 255,
276 (gpointer)&change_static_actor_with_corner, NULL, NULL);
277 change_static_actor_with_corner(actor, desktop_plugin);
278 scene->actors = g_slist_append(scene->actors, actor);
280 actor = init_object(desktop_plugin, "moon", "moon1.png",
282 FALSE, FALSE, 100, 255,
283 (gpointer)&change_moon, NULL, NULL);
284 change_moon(actor, desktop_plugin);
285 scene->actors = g_slist_append(scene->actors, actor);
287 actor = init_object(desktop_plugin, "wind", "",
289 FALSE, FALSE, 100, 255,
290 (gpointer)&change_wind, NULL, NULL);
291 change_wind(actor, desktop_plugin);
292 scene->actors = g_slist_append(scene->actors, actor);
294 /* windows in 4-th house */
334 for (i=0; i<13; i++){
335 actor = init_object(desktop_plugin, "window1", "window1.png",
336 winds[i][0], winds[i][1], 8, 8, 10,
337 FALSE, FALSE, 100, 255,
338 (gpointer)&change_window1, NULL, NULL);
339 //change_window1(actor, desktop_plugin);
340 actor->time_start_animation = now + fast_rnd(30);
341 scene->actors = g_slist_append(scene->actors, actor);
345 /* windows in 1-th house */
371 actor = init_object(desktop_plugin, "window2", "window2.png",
372 winds[i][0], winds[i][1], 8, 8, 10,
373 FALSE, FALSE, 100, 255,
374 (gpointer)&change_window1, NULL, NULL);
375 //change_window1(actor, desktop_plugin);
376 actor->time_start_animation = now + fast_rnd(30);
377 scene->actors = g_slist_append(scene->actors, actor);
381 /* windows in 3-th house */
413 for (i=0; i<10; i++){
414 actor = init_object(desktop_plugin, "window3", "window3.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 5-th house */
448 actor = init_object(desktop_plugin, "window4", "window4.png",
449 winds[i][0], winds[i][1], 8, 8, 10,
450 FALSE, FALSE, 100, 255,
451 (gpointer)&change_window1, NULL, NULL);
452 //change_window1(actor, desktop_plugin);
453 actor->time_start_animation = now + fast_rnd(30);
454 scene->actors = g_slist_append(scene->actors, actor);
458 /* windows in 6-th house */
479 actor = init_object(desktop_plugin, "window5", "window5.png",
480 winds[i][0], winds[i][1], 8, 8, 10,
481 FALSE, FALSE, 100, 255,
482 (gpointer)&change_window1, NULL, NULL);
483 //change_window1(actor, desktop_plugin);
484 actor->time_start_animation = now + fast_rnd(30);
485 scene->actors = g_slist_append(scene->actors, actor);
488 run_long_timeout(desktop_plugin);
491 anim = g_new0(Animation, 1);
494 anim->func_change = &change_tram;
495 anim->func_time = NULL;
496 anim->timestart = time(NULL);
499 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
503 /* Init Berlin Scene */
505 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
507 Actor *actor, *actor1, *actor2;
509 gint now = time(NULL);
512 GPtrArray *child = NULL;
514 scene = g_new0(Scene, 1);
515 scene->daytime = get_daytime();
516 scene->actors = NULL;
517 scene->wind_orientation = -1;
518 scene->wind_angle = 0.3;
519 /* init value for random */
520 scene->seed = time(NULL);
521 desktop_plugin->priv->scene = scene;
523 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
524 TRUE, TRUE, 100, 255,
525 (gpointer)&change_static_actor, NULL, NULL);
526 change_static_actor(actor, desktop_plugin);
527 scene->actors = g_slist_append(scene->actors, actor);
530 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
531 FALSE, FALSE, 100, 255,
532 (gpointer)&change_sun, NULL, NULL);
533 actor->time_start_animation = time(NULL);
534 actor->duration_animation = G_MAXINT;
535 change_sun(actor, desktop_plugin);
536 scene->actors = g_slist_append(scene->actors, actor);
539 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
540 TRUE, 100, 255, NULL, NULL);
541 scene.actors = g_slist_append(scene.actors, actor);
544 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
545 FALSE, FALSE, 100, 255,
546 (gpointer)&change_moon, NULL, NULL);
547 change_moon(actor, desktop_plugin);
548 scene->actors = g_slist_append(scene->actors, actor);
550 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
551 FALSE, FALSE, 100, 255,
552 (gpointer)&change_cloud, NULL, NULL);
553 actor->time_start_animation = now + fast_rnd(30) + 10;
554 actor->duration_animation = 3*60;
555 scene->actors = g_slist_append(scene->actors, actor);
557 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
558 FALSE, FALSE, 100, 255,
559 (gpointer)&change_cloud, NULL, NULL);
560 actor->time_start_animation = now + fast_rnd(10);
561 actor->duration_animation = 3*60;
562 scene->actors = g_slist_append(scene->actors, actor);
564 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
565 FALSE, FALSE, 100, 255,
566 (gpointer)&change_cloud, NULL, NULL);
567 actor->time_start_animation = now + fast_rnd(60) + 20;
568 actor->duration_animation = 5*60;
569 scene->actors = g_slist_append(scene->actors, actor);
572 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
573 FALSE, FALSE, 100, 255,
574 (gpointer)&change_plane2, NULL, NULL);
575 actor->time_start_animation = now + fast_rnd(40) + 20;
576 actor->duration_animation = 60;
577 scene->actors = g_slist_append(scene->actors, actor);
579 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
580 FALSE, FALSE, 100, 255,
581 (gpointer)&change_plane1, NULL, NULL);
582 actor->time_start_animation = now + fast_rnd(20);
583 actor->duration_animation = 30;
584 scene->actors = g_slist_append(scene->actors, actor);
586 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
587 TRUE, TRUE, 100, 255,
588 (gpointer)&change_static_actor_with_corner, NULL, NULL);
589 change_static_actor_with_corner(actor, desktop_plugin);
590 scene->actors = g_slist_append(scene->actors, actor);
592 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
593 FALSE, FALSE, 100, 255,
594 (gpointer)&change_wind, NULL, NULL);
595 change_wind(actor, desktop_plugin);
596 scene->actors = g_slist_append(scene->actors, actor);
598 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
599 486, 425, 10, 18, 38,
600 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
601 //actor->time_start_animation = now + fast_rnd(30) + 10;
602 scene->actors = g_slist_append(scene->actors, actor1);
604 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
605 486, 425, 10, 18, 38,
606 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
607 //actor->time_start_animation = now + fast_rnd(30) + 10;
608 scene->actors = g_slist_append(scene->actors, actor2);
609 child = g_ptr_array_sized_new(2);
610 g_ptr_array_add(child, actor1);
611 g_ptr_array_add(child, actor2);
612 actor = init_object(desktop_plugin, "signal", "",
613 486, 425, 10, 18, 38,
614 FALSE, FALSE, 100, 255,
615 (gpointer)&change_signal, NULL, child);
616 actor->time_start_animation = now + fast_rnd(30) + 10;
617 scene->actors = g_slist_append(scene->actors, actor);
658 for (i=0; i<13; i++){
659 actor = init_object(desktop_plugin, "window", "window.png",
660 winds[i][0], winds[i][1], 10, 8, 9,
661 FALSE, TRUE, 100, 255,
662 (gpointer)&change_window1, NULL, NULL);
663 //change_window1(actor, desktop_plugin);
664 actor->time_start_animation = now + fast_rnd(30);
665 scene->actors = g_slist_append(scene->actors, actor);
669 run_long_timeout(desktop_plugin);
674 init_scene_theme(AWallpaperPlugin *desktop_plugin)
676 void (*func)(gpointer);
677 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
679 (*func)(desktop_plugin);