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);
40 reload_scene(AWallpaperPlugin *desktop_plugin)
42 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
43 destroy_scene(desktop_plugin);
44 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
45 init_scene(desktop_plugin);
46 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
47 init_scene1(desktop_plugin);
48 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
49 init_scene2(desktop_plugin);
53 init_scene2(AWallpaperPlugin *desktop_plugin)
58 gint now = time(NULL);
61 if (desktop_plugin->priv->rich_animation){
69 fprintf(stderr, "init scene2 \n");
70 scene = g_new0(Scene, 1);
71 //scene.daytime = get_daytime();
73 desktop_plugin->priv->scene = scene;
75 actor = init_object(desktop_plugin, "background", "bg.png",
79 scene->actors = g_slist_append(scene->actors, actor);
81 actor = init_object(desktop_plugin, "symbols", "symbols.png",
85 scene->actors = g_slist_append(scene->actors, actor);
87 child = g_ptr_array_sized_new(4);
88 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
92 //actor->time_start_animation = now;
93 //actor->duration_animation = G_MAXINT;
94 scene->actors = g_slist_append(scene->actors, actor);
95 g_ptr_array_add(child, actor);
97 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
101 //actor->time_start_animation = now;
102 //actor->duration_animation = G_MAXINT;
103 scene->actors = g_slist_append(scene->actors, actor);
104 g_ptr_array_add(child, actor);
106 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
108 TRUE, TRUE, 100, 255,
110 //actor->time_start_animation = now;
111 //actor->duration_animation = G_MAXINT;
112 scene->actors = g_slist_append(scene->actors, actor);
113 g_ptr_array_add(child, actor);
115 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
117 TRUE, TRUE, 100, 255,
119 //actor->time_start_animation = now;
120 //actor->duration_animation = G_MAXINT;
121 scene->actors = g_slist_append(scene->actors, actor);
122 g_ptr_array_add(child, actor);
124 actor = init_object(desktop_plugin, "layers", "",
126 FALSE, FALSE, 100, 255,
127 (gpointer)&change_layer, NULL, child);
128 actor->time_start_animation = now;
129 actor->duration_animation = G_MAXINT;
130 scene->actors = g_slist_append(scene->actors, actor);
132 run_long_timeout(desktop_plugin);
136 /* Init Modern Scene */
138 init_scene(AWallpaperPlugin *desktop_plugin)
142 gint now = time(NULL);
146 //fprintf(stderr, "init scene \n");
147 scene = g_new0(Scene, 1);
148 scene->daytime = get_daytime();
149 scene->actors = NULL;
150 scene->wind_orientation = -1;
151 scene->wind_angle = 0.3;
152 /* init value for random */
153 scene->seed = time(NULL);
154 desktop_plugin->priv->scene = scene;
156 actor = init_object(desktop_plugin, "sky", "sky0.png",
158 TRUE , TRUE, 100, 255,
159 (gpointer)&change_static_actor, NULL, NULL);
160 change_static_actor(actor, desktop_plugin);
161 scene->actors = g_slist_append(scene->actors, actor);
163 actor = init_object(desktop_plugin, "sun", "sun.png",
165 FALSE, FALSE, 100, 255,
166 (gpointer)&change_sun, NULL, NULL);
167 actor->time_start_animation = now;
168 actor->duration_animation = G_MAXINT;
169 change_sun(actor, desktop_plugin);
170 scene->actors = g_slist_append(scene->actors, actor);
172 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
173 // TRUE, 100, 255, NULL, NULL);
174 //scene.actors = g_slist_append(scene.actors, actor);
176 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
177 0, fast_rnd(300)-97, 7, 150, 97,
178 FALSE, FALSE, 100, 255,
179 (gpointer)&change_cloud, NULL, NULL);
180 actor->time_start_animation = now + fast_rnd(20);
181 actor->duration_animation = 3*60;
182 scene->actors = g_slist_append(scene->actors, actor);
184 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
185 0, fast_rnd(300)-75, 7, 188, 75,
186 FALSE, FALSE, 100, 255,
187 (gpointer)&change_cloud, NULL, NULL);
188 actor->time_start_animation = now + fast_rnd(40)+10;
189 actor->duration_animation = 3*60;
190 scene->actors = g_slist_append(scene->actors, actor);
192 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
193 0, fast_rnd(300)-75, 7, 150, 75,
194 FALSE, FALSE, 100, 255,
195 (gpointer)&change_cloud, NULL, NULL);
196 actor->time_start_animation = now + fast_rnd(60) + 20;
197 actor->duration_animation = 5*60;
198 scene->actors = g_slist_append(scene->actors, actor);
201 actor = init_object(desktop_plugin, "town", "town0.png",
203 TRUE, TRUE, 100, 255,
204 (gpointer)&change_static_actor, NULL, NULL);
205 change_static_actor(actor, desktop_plugin);
206 scene->actors = g_slist_append(scene->actors, actor);
208 actor = init_object(desktop_plugin, "stend", "stend0.png",
209 482, 146, 9, 300, 305,
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, "tram", "tram.png",
216 -300, 225, 10, 350, 210,
217 FALSE, FALSE, 100, 255,
218 (gpointer)&change_tram, NULL, NULL);
219 actor->time_start_animation = time(NULL) + fast_rnd(10);
220 actor->duration_animation = 60;
221 scene->actors = g_slist_append(scene->actors, actor);
223 actor = init_object(desktop_plugin, "border", "border0.png",
224 0, 480-79, 11, 800, 79,
225 TRUE, TRUE, 100, 255,
226 (gpointer)&change_static_actor_with_corner, NULL, NULL);
227 change_static_actor_with_corner(actor, desktop_plugin);
228 scene->actors = g_slist_append(scene->actors, actor);
230 actor = init_object(desktop_plugin, "moon", "moon1.png",
232 FALSE, FALSE, 100, 255,
233 (gpointer)&change_moon, NULL, NULL);
234 change_moon(actor, desktop_plugin);
235 scene->actors = g_slist_append(scene->actors, actor);
237 actor = init_object(desktop_plugin, "wind", "",
239 FALSE, FALSE, 100, 255,
240 (gpointer)&change_wind, NULL, NULL);
241 change_wind(actor, desktop_plugin);
242 scene->actors = g_slist_append(scene->actors, actor);
244 /* windows in 4-th house */
284 for (i=0; i<13; i++){
285 actor = init_object(desktop_plugin, "window1", "window1.png",
286 winds[i][0], winds[i][1], 8, 8, 10,
287 FALSE, FALSE, 100, 255,
288 (gpointer)&change_window1, NULL, NULL);
289 //change_window1(actor, desktop_plugin);
290 actor->time_start_animation = now + fast_rnd(30);
291 scene->actors = g_slist_append(scene->actors, actor);
295 /* windows in 1-th house */
321 actor = init_object(desktop_plugin, "window2", "window2.png",
322 winds[i][0], winds[i][1], 8, 8, 10,
323 FALSE, FALSE, 100, 255,
324 (gpointer)&change_window1, NULL, NULL);
325 //change_window1(actor, desktop_plugin);
326 actor->time_start_animation = now + fast_rnd(30);
327 scene->actors = g_slist_append(scene->actors, actor);
331 /* windows in 3-th house */
363 for (i=0; i<10; i++){
364 actor = init_object(desktop_plugin, "window3", "window3.png",
365 winds[i][0], winds[i][1], 8, 8, 10,
366 FALSE, FALSE, 100, 255,
367 (gpointer)&change_window1, NULL, NULL);
368 //change_window1(actor, desktop_plugin);
369 actor->time_start_animation = now + fast_rnd(30);
370 scene->actors = g_slist_append(scene->actors, actor);
374 /* windows in 5-th house */
398 actor = init_object(desktop_plugin, "window4", "window4.png",
399 winds[i][0], winds[i][1], 8, 8, 10,
400 FALSE, FALSE, 100, 255,
401 (gpointer)&change_window1, NULL, NULL);
402 //change_window1(actor, desktop_plugin);
403 actor->time_start_animation = now + fast_rnd(30);
404 scene->actors = g_slist_append(scene->actors, actor);
408 /* windows in 6-th house */
429 actor = init_object(desktop_plugin, "window5", "window5.png",
430 winds[i][0], winds[i][1], 8, 8, 10,
431 FALSE, FALSE, 100, 255,
432 (gpointer)&change_window1, NULL, NULL);
433 //change_window1(actor, desktop_plugin);
434 actor->time_start_animation = now + fast_rnd(30);
435 scene->actors = g_slist_append(scene->actors, actor);
438 run_long_timeout(desktop_plugin);
441 anim = g_new0(Animation, 1);
444 anim->func_change = &change_tram;
445 anim->func_time = NULL;
446 anim->timestart = time(NULL);
449 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
453 /* Init Berlin Scene */
455 init_scene1(AWallpaperPlugin *desktop_plugin)
457 Actor *actor, *actor1, *actor2;
459 gint now = time(NULL);
462 GPtrArray *child = NULL;
464 scene = g_new0(Scene, 1);
465 scene->daytime = get_daytime();
466 scene->actors = NULL;
467 scene->wind_orientation = -1;
468 scene->wind_angle = 0.3;
469 /* init value for random */
470 scene->seed = time(NULL);
471 desktop_plugin->priv->scene = scene;
473 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
474 TRUE, TRUE, 100, 255,
475 (gpointer)&change_static_actor, NULL, NULL);
476 change_static_actor(actor, desktop_plugin);
477 scene->actors = g_slist_append(scene->actors, actor);
480 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
481 FALSE, FALSE, 100, 255,
482 (gpointer)&change_sun, NULL, NULL);
483 actor->time_start_animation = time(NULL);
484 actor->duration_animation = G_MAXINT;
485 change_sun(actor, desktop_plugin);
486 scene->actors = g_slist_append(scene->actors, actor);
489 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
490 TRUE, 100, 255, NULL, NULL);
491 scene.actors = g_slist_append(scene.actors, actor);
494 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
495 FALSE, FALSE, 100, 255,
496 (gpointer)&change_moon, NULL, NULL);
497 change_moon(actor, desktop_plugin);
498 scene->actors = g_slist_append(scene->actors, actor);
500 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
501 FALSE, FALSE, 100, 255,
502 (gpointer)&change_cloud, NULL, NULL);
503 actor->time_start_animation = now + fast_rnd(30) + 10;
504 actor->duration_animation = 3*60;
505 scene->actors = g_slist_append(scene->actors, actor);
507 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
508 FALSE, FALSE, 100, 255,
509 (gpointer)&change_cloud, NULL, NULL);
510 actor->time_start_animation = now + fast_rnd(10);
511 actor->duration_animation = 3*60;
512 scene->actors = g_slist_append(scene->actors, actor);
514 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
515 FALSE, FALSE, 100, 255,
516 (gpointer)&change_cloud, NULL, NULL);
517 actor->time_start_animation = now + fast_rnd(60) + 20;
518 actor->duration_animation = 5*60;
519 scene->actors = g_slist_append(scene->actors, actor);
522 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
523 FALSE, FALSE, 100, 255,
524 (gpointer)&change_plane2, NULL, NULL);
525 actor->time_start_animation = now + fast_rnd(40) + 20;
526 actor->duration_animation = 60;
527 scene->actors = g_slist_append(scene->actors, actor);
529 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
530 FALSE, FALSE, 100, 255,
531 (gpointer)&change_plane1, NULL, NULL);
532 actor->time_start_animation = now + fast_rnd(20);
533 actor->duration_animation = 30;
534 scene->actors = g_slist_append(scene->actors, actor);
536 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
537 TRUE, TRUE, 100, 255,
538 (gpointer)&change_static_actor_with_corner, NULL, NULL);
539 change_static_actor_with_corner(actor, desktop_plugin);
540 scene->actors = g_slist_append(scene->actors, actor);
542 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
543 FALSE, FALSE, 100, 255,
544 (gpointer)&change_wind, NULL, NULL);
545 change_wind(actor, desktop_plugin);
546 scene->actors = g_slist_append(scene->actors, actor);
548 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
549 486, 425, 10, 18, 38,
550 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
551 //actor->time_start_animation = now + fast_rnd(30) + 10;
552 scene->actors = g_slist_append(scene->actors, actor1);
554 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
555 486, 425, 10, 18, 38,
556 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
557 //actor->time_start_animation = now + fast_rnd(30) + 10;
558 scene->actors = g_slist_append(scene->actors, actor2);
559 child = g_ptr_array_sized_new(2);
560 g_ptr_array_add(child, actor1);
561 g_ptr_array_add(child, actor2);
562 actor = init_object(desktop_plugin, "signal", "",
563 486, 425, 10, 18, 38,
564 FALSE, FALSE, 100, 255,
565 (gpointer)&change_signal, NULL, child);
566 actor->time_start_animation = now + fast_rnd(30) + 10;
567 scene->actors = g_slist_append(scene->actors, actor);
608 for (i=0; i<13; i++){
609 actor = init_object(desktop_plugin, "window", "window.png",
610 winds[i][0], winds[i][1], 10, 8, 9,
611 FALSE, TRUE, 100, 255,
612 (gpointer)&change_window1, NULL, NULL);
613 //change_window1(actor, desktop_plugin);
614 actor->time_start_animation = now + fast_rnd(30);
615 scene->actors = g_slist_append(scene->actors, actor);
619 run_long_timeout(desktop_plugin);