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);
48 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
49 init_scene(desktop_plugin);
50 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
51 init_scene1(desktop_plugin);
52 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
53 init_scene2(desktop_plugin);
57 init_scene2(AWallpaperPlugin *desktop_plugin)
62 gint now = time(NULL);
65 if (desktop_plugin->priv->rich_animation){
73 fprintf(stderr, "init scene2 \n");
74 scene = g_new0(Scene, 1);
75 //scene.daytime = get_daytime();
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 actor = init_object(desktop_plugin, "symbols", "symbols.png",
89 scene->actors = g_slist_append(scene->actors, actor);
91 child = g_ptr_array_sized_new(4);
92 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
96 //actor->time_start_animation = now;
97 //actor->duration_animation = G_MAXINT;
98 scene->actors = g_slist_append(scene->actors, actor);
99 g_ptr_array_add(child, actor);
101 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
103 TRUE, TRUE, 100, 255,
105 //actor->time_start_animation = now;
106 //actor->duration_animation = G_MAXINT;
107 scene->actors = g_slist_append(scene->actors, actor);
108 g_ptr_array_add(child, actor);
110 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
112 TRUE, TRUE, 100, 255,
114 //actor->time_start_animation = now;
115 //actor->duration_animation = G_MAXINT;
116 scene->actors = g_slist_append(scene->actors, actor);
117 g_ptr_array_add(child, actor);
119 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
121 TRUE, TRUE, 100, 255,
123 //actor->time_start_animation = now;
124 //actor->duration_animation = G_MAXINT;
125 scene->actors = g_slist_append(scene->actors, actor);
126 g_ptr_array_add(child, actor);
128 actor = init_object(desktop_plugin, "layers", "",
130 FALSE, FALSE, 100, 255,
131 (gpointer)&change_layer, NULL, child);
132 actor->time_start_animation = now;
133 actor->duration_animation = G_MAXINT;
134 scene->actors = g_slist_append(scene->actors, actor);
136 run_long_timeout(desktop_plugin);
140 /* Init Modern Scene */
142 init_scene(AWallpaperPlugin *desktop_plugin)
146 gint now = time(NULL);
150 //fprintf(stderr, "init scene \n");
151 scene = g_new0(Scene, 1);
152 scene->daytime = get_daytime();
153 scene->actors = NULL;
154 scene->wind_orientation = -1;
155 scene->wind_angle = 0.3;
156 /* init value for random */
157 scene->seed = time(NULL);
158 desktop_plugin->priv->scene = scene;
160 actor = init_object(desktop_plugin, "sky", "sky0.png",
162 TRUE , TRUE, 100, 255,
163 (gpointer)&change_static_actor, NULL, NULL);
164 change_static_actor(actor, desktop_plugin);
165 scene->actors = g_slist_append(scene->actors, actor);
167 actor = init_object(desktop_plugin, "sun", "sun.png",
169 FALSE, FALSE, 100, 255,
170 (gpointer)&change_sun, NULL, NULL);
171 actor->time_start_animation = now;
172 actor->duration_animation = G_MAXINT;
173 change_sun(actor, desktop_plugin);
174 scene->actors = g_slist_append(scene->actors, actor);
176 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
177 // TRUE, 100, 255, NULL, NULL);
178 //scene.actors = g_slist_append(scene.actors, actor);
180 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
181 0, fast_rnd(300)-97, 7, 150, 97,
182 FALSE, FALSE, 100, 255,
183 (gpointer)&change_cloud, NULL, NULL);
184 actor->time_start_animation = now + fast_rnd(20);
185 actor->duration_animation = 3*60;
186 scene->actors = g_slist_append(scene->actors, actor);
188 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
189 0, fast_rnd(300)-75, 7, 188, 75,
190 FALSE, FALSE, 100, 255,
191 (gpointer)&change_cloud, NULL, NULL);
192 actor->time_start_animation = now + fast_rnd(40)+10;
193 actor->duration_animation = 3*60;
194 scene->actors = g_slist_append(scene->actors, actor);
196 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
197 0, fast_rnd(300)-75, 7, 150, 75,
198 FALSE, FALSE, 100, 255,
199 (gpointer)&change_cloud, NULL, NULL);
200 actor->time_start_animation = now + fast_rnd(60) + 20;
201 actor->duration_animation = 5*60;
202 scene->actors = g_slist_append(scene->actors, actor);
205 actor = init_object(desktop_plugin, "town", "town0.png",
207 TRUE, TRUE, 100, 255,
208 (gpointer)&change_static_actor, NULL, NULL);
209 change_static_actor(actor, desktop_plugin);
210 scene->actors = g_slist_append(scene->actors, actor);
212 actor = init_object(desktop_plugin, "stend", "stend0.png",
213 482, 146, 9, 300, 305,
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, "tram", "tram.png",
220 -300, 225, 10, 350, 210,
221 FALSE, FALSE, 100, 255,
222 (gpointer)&change_tram, NULL, NULL);
223 actor->time_start_animation = time(NULL) + fast_rnd(10);
224 actor->duration_animation = 60;
225 scene->actors = g_slist_append(scene->actors, actor);
227 actor = init_object(desktop_plugin, "border", "border0.png",
228 0, 480-79, 11, 800, 79,
229 TRUE, TRUE, 100, 255,
230 (gpointer)&change_static_actor_with_corner, NULL, NULL);
231 change_static_actor_with_corner(actor, desktop_plugin);
232 scene->actors = g_slist_append(scene->actors, actor);
234 actor = init_object(desktop_plugin, "moon", "moon1.png",
236 FALSE, FALSE, 100, 255,
237 (gpointer)&change_moon, NULL, NULL);
238 change_moon(actor, desktop_plugin);
239 scene->actors = g_slist_append(scene->actors, actor);
241 actor = init_object(desktop_plugin, "wind", "",
243 FALSE, FALSE, 100, 255,
244 (gpointer)&change_wind, NULL, NULL);
245 change_wind(actor, desktop_plugin);
246 scene->actors = g_slist_append(scene->actors, actor);
248 /* windows in 4-th house */
288 for (i=0; i<13; i++){
289 actor = init_object(desktop_plugin, "window1", "window1.png",
290 winds[i][0], winds[i][1], 8, 8, 10,
291 FALSE, FALSE, 100, 255,
292 (gpointer)&change_window1, NULL, NULL);
293 //change_window1(actor, desktop_plugin);
294 actor->time_start_animation = now + fast_rnd(30);
295 scene->actors = g_slist_append(scene->actors, actor);
299 /* windows in 1-th house */
325 actor = init_object(desktop_plugin, "window2", "window2.png",
326 winds[i][0], winds[i][1], 8, 8, 10,
327 FALSE, FALSE, 100, 255,
328 (gpointer)&change_window1, NULL, NULL);
329 //change_window1(actor, desktop_plugin);
330 actor->time_start_animation = now + fast_rnd(30);
331 scene->actors = g_slist_append(scene->actors, actor);
335 /* windows in 3-th house */
367 for (i=0; i<10; i++){
368 actor = init_object(desktop_plugin, "window3", "window3.png",
369 winds[i][0], winds[i][1], 8, 8, 10,
370 FALSE, FALSE, 100, 255,
371 (gpointer)&change_window1, NULL, NULL);
372 //change_window1(actor, desktop_plugin);
373 actor->time_start_animation = now + fast_rnd(30);
374 scene->actors = g_slist_append(scene->actors, actor);
378 /* windows in 5-th house */
402 actor = init_object(desktop_plugin, "window4", "window4.png",
403 winds[i][0], winds[i][1], 8, 8, 10,
404 FALSE, FALSE, 100, 255,
405 (gpointer)&change_window1, NULL, NULL);
406 //change_window1(actor, desktop_plugin);
407 actor->time_start_animation = now + fast_rnd(30);
408 scene->actors = g_slist_append(scene->actors, actor);
412 /* windows in 6-th house */
433 actor = init_object(desktop_plugin, "window5", "window5.png",
434 winds[i][0], winds[i][1], 8, 8, 10,
435 FALSE, FALSE, 100, 255,
436 (gpointer)&change_window1, NULL, NULL);
437 //change_window1(actor, desktop_plugin);
438 actor->time_start_animation = now + fast_rnd(30);
439 scene->actors = g_slist_append(scene->actors, actor);
442 run_long_timeout(desktop_plugin);
445 anim = g_new0(Animation, 1);
448 anim->func_change = &change_tram;
449 anim->func_time = NULL;
450 anim->timestart = time(NULL);
453 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
457 /* Init Berlin Scene */
459 init_scene1(AWallpaperPlugin *desktop_plugin)
461 Actor *actor, *actor1, *actor2;
463 gint now = time(NULL);
466 GPtrArray *child = NULL;
468 scene = g_new0(Scene, 1);
469 scene->daytime = get_daytime();
470 scene->actors = NULL;
471 scene->wind_orientation = -1;
472 scene->wind_angle = 0.3;
473 /* init value for random */
474 scene->seed = time(NULL);
475 desktop_plugin->priv->scene = scene;
477 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
478 TRUE, TRUE, 100, 255,
479 (gpointer)&change_static_actor, NULL, NULL);
480 change_static_actor(actor, desktop_plugin);
481 scene->actors = g_slist_append(scene->actors, actor);
484 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
485 FALSE, FALSE, 100, 255,
486 (gpointer)&change_sun, NULL, NULL);
487 actor->time_start_animation = time(NULL);
488 actor->duration_animation = G_MAXINT;
489 change_sun(actor, desktop_plugin);
490 scene->actors = g_slist_append(scene->actors, actor);
493 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
494 TRUE, 100, 255, NULL, NULL);
495 scene.actors = g_slist_append(scene.actors, actor);
498 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
499 FALSE, FALSE, 100, 255,
500 (gpointer)&change_moon, NULL, NULL);
501 change_moon(actor, desktop_plugin);
502 scene->actors = g_slist_append(scene->actors, actor);
504 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
505 FALSE, FALSE, 100, 255,
506 (gpointer)&change_cloud, NULL, NULL);
507 actor->time_start_animation = now + fast_rnd(30) + 10;
508 actor->duration_animation = 3*60;
509 scene->actors = g_slist_append(scene->actors, actor);
511 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
512 FALSE, FALSE, 100, 255,
513 (gpointer)&change_cloud, NULL, NULL);
514 actor->time_start_animation = now + fast_rnd(10);
515 actor->duration_animation = 3*60;
516 scene->actors = g_slist_append(scene->actors, actor);
518 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
519 FALSE, FALSE, 100, 255,
520 (gpointer)&change_cloud, NULL, NULL);
521 actor->time_start_animation = now + fast_rnd(60) + 20;
522 actor->duration_animation = 5*60;
523 scene->actors = g_slist_append(scene->actors, actor);
526 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
527 FALSE, FALSE, 100, 255,
528 (gpointer)&change_plane2, NULL, NULL);
529 actor->time_start_animation = now + fast_rnd(40) + 20;
530 actor->duration_animation = 60;
531 scene->actors = g_slist_append(scene->actors, actor);
533 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
534 FALSE, FALSE, 100, 255,
535 (gpointer)&change_plane1, NULL, NULL);
536 actor->time_start_animation = now + fast_rnd(20);
537 actor->duration_animation = 30;
538 scene->actors = g_slist_append(scene->actors, actor);
540 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
541 TRUE, TRUE, 100, 255,
542 (gpointer)&change_static_actor_with_corner, NULL, NULL);
543 change_static_actor_with_corner(actor, desktop_plugin);
544 scene->actors = g_slist_append(scene->actors, actor);
546 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
547 FALSE, FALSE, 100, 255,
548 (gpointer)&change_wind, NULL, NULL);
549 change_wind(actor, desktop_plugin);
550 scene->actors = g_slist_append(scene->actors, actor);
552 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
553 486, 425, 10, 18, 38,
554 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
555 //actor->time_start_animation = now + fast_rnd(30) + 10;
556 scene->actors = g_slist_append(scene->actors, actor1);
558 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
559 486, 425, 10, 18, 38,
560 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
561 //actor->time_start_animation = now + fast_rnd(30) + 10;
562 scene->actors = g_slist_append(scene->actors, actor2);
563 child = g_ptr_array_sized_new(2);
564 g_ptr_array_add(child, actor1);
565 g_ptr_array_add(child, actor2);
566 actor = init_object(desktop_plugin, "signal", "",
567 486, 425, 10, 18, 38,
568 FALSE, FALSE, 100, 255,
569 (gpointer)&change_signal, NULL, child);
570 actor->time_start_animation = now + fast_rnd(30) + 10;
571 scene->actors = g_slist_append(scene->actors, actor);
612 for (i=0; i<13; i++){
613 actor = init_object(desktop_plugin, "window", "window.png",
614 winds[i][0], winds[i][1], 10, 8, 9,
615 FALSE, TRUE, 100, 255,
616 (gpointer)&change_window1, NULL, NULL);
617 //change_window1(actor, desktop_plugin);
618 actor->time_start_animation = now + fast_rnd(30);
619 scene->actors = g_slist_append(scene->actors, actor);
623 run_long_timeout(desktop_plugin);