Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: suggestion: myth about freeciv
Home

[Freeciv-Dev] Re: suggestion: myth about freeciv

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: suggestion: myth about freeciv
From: Andreas Røsdal <andrearo@xxxxxxxxxxxx>
Date: Fri, 07 Feb 2003 19:39:00 +0100

Raimar Falke wrote:

On Fri, Feb 07, 2003 at 06:05:03PM +0100, Andreas Røsdal wrote:
Raimar Falke wrote:

On Thu, Feb 06, 2003 at 11:49:04PM +0100, Andreas Røsdal wrote:


Hello!
I've been experimenting with scrolling "The Freeciv Myth"
on the introscreen.
It doesn't compile. At least if some stricter options (like "-Wall
-Wpointer-arith -Wcast-align -Wmissing-prototypes
-Wmissing-declarations -Werror) are used.

I fixed this. Now I got an access for index -1 on the myth array. The
assert I inserted triggered.
The while-loop in intro_scroll() was off by one.
It's fixed it in the attached file. Does it compile properly for you now?

Now it doesn't apply clean:
$ patch -p0 <myth3.diff patching file client/tilespec.c
patching file client/tilespec.h
patching file client/gui-gtk/graphics.c
patch: **** malformed patch at line 172: Index: client/gui-gtk/graphics.h


Sorry about that. I've fixed the malformed patch, and changed to N_() in the array
It compiles without any errors on my Red Hat 8.0.

Andreas Røsdal

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.110
diff -u -u -r1.110 tilespec.c
--- client/tilespec.c   2003/02/05 07:19:43     1.110
+++ client/tilespec.c   2003/02/07 15:34:08
@@ -54,6 +54,7 @@
 #define TILESPEC_SUFFIX ".tilespec"
 
 char *main_intro_filename;
+char *main_myth_filename;
 char *minimap_intro_filename;
 
 struct named_sprites sprites;
@@ -259,6 +260,10 @@
     free(main_intro_filename);
     main_intro_filename = NULL;
   }
+  if (main_myth_filename) {
+    free(main_myth_filename);
+    main_myth_filename = NULL;
+  }
   if (minimap_intro_filename) {
     free(minimap_intro_filename);
     minimap_intro_filename = NULL;
@@ -448,6 +453,10 @@
   main_intro_filename = tilespec_gfx_filename(c);
   freelog(LOG_DEBUG, "intro file %s", main_intro_filename);
   
+  c = secfile_lookup_str(file, "tilespec.main_myth_file");
+  main_myth_filename = tilespec_gfx_filename(c);
+  freelog(LOG_DEBUG, "myth file %s", main_myth_filename);
+
   c = secfile_lookup_str(file, "tilespec.minimap_intro_file");
   minimap_intro_filename = tilespec_gfx_filename(c);
   freelog(LOG_DEBUG, "radar file %s", minimap_intro_filename);
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.38
diff -u -u -r1.38 tilespec.h
--- client/tilespec.h   2003/02/02 00:15:52     1.38
+++ client/tilespec.h   2003/02/07 15:34:08
@@ -212,6 +212,7 @@
 
 /* full pathnames: */
 extern char *main_intro_filename;
+extern char *main_myth_filename;
 extern char *minimap_intro_filename;
 
 /* NOTE: The following comments are out of date and need to
Index: client/gui-gtk/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v
retrieving revision 1.48
diff -u -u -r1.48 graphics.c
--- client/gui-gtk/graphics.c   2003/01/29 05:10:49     1.48
+++ client/gui-gtk/graphics.c   2003/02/07 15:34:09
@@ -52,12 +52,18 @@
 
 SPRITE *               intro_gfx_sprite;
 SPRITE *               radar_gfx_sprite;
+SPRITE *               myth_gfx_sprite;
+SPRITE *               scaled_intro_sprite;
 
+
 GdkCursor *            goto_cursor;
 GdkCursor *            drop_cursor;
 GdkCursor *            nuke_cursor;
 GdkCursor *            patrol_cursor;
 
+int scroll_counter = 0;                        /* counter for intro_scroll() */
+
+
 /***************************************************************************
 ...
 ***************************************************************************/
@@ -80,6 +86,9 @@
 #define COLOR_MOTTO_FACE_R    0x2D
 #define COLOR_MOTTO_FACE_G    0x71
 #define COLOR_MOTTO_FACE_B    0xE3
+#define COLOR_MYTH_FACE_R     0xED
+#define COLOR_MYTH_FACE_G     0xED
+#define COLOR_MYTH_FACE_B     0xFF
 
 /**************************************************************************
 ...
@@ -159,6 +168,85 @@
                           tot / 2 - w / 2, y, word_version());
   /* done */
 
+  return;
+}
+
+
+
+
+/**************************************************************************
+Intro: The Myth of Freeciv (scrolling)
+It is called from gui_main every time the text is to be moved up
+**************************************************************************/
+gint intro_scroll(gpointer data)
+{
+  if (scroll_counter < 61) {
+    gint height, width;
+    int tot;
+    GdkColor face;
+    GdkGC *face_gc;
+    SPRITE *scaled_myth_sprite;
+
+    scroll_counter++;
+
+    /* get colors */
+    face.red = COLOR_MYTH_FACE_R << 8;
+    face.green = COLOR_MYTH_FACE_G << 8;
+    face.blue = COLOR_MYTH_FACE_B << 8;
+    gdk_imlib_best_color_get(&face);
+
+    /* Load the background image */
+    myth_gfx_sprite = load_gfxfile(main_myth_filename);
+    tot = myth_gfx_sprite->width;
+    face_gc = gdk_gc_new(root_window);
+
+    
+       
+    
+    gdk_gc_set_foreground(face_gc, &face);
+    gdk_window_get_size(map_canvas->window, &width, &height);
+    scaled_myth_sprite =
+       sprite_scale(myth_gfx_sprite, width + scroll_counter,
+                    height + scroll_counter);
+
+    int line = 0;
+    /*  Draw each textline of the myth to scaled_myth_sprite */
+    while (line < 16) {
+      gdk_draw_string(scaled_myth_sprite->pixmap, main_fontset,
+                     face_gc, width * 0.50 - 210,
+                     height * 0.8 - (18 * line),
+                     freeciv_myth(14 - line + scroll_counter));
+      line++;
+    }
+
+    /*  Draw scaled_myth_sprite to the screen */
+    gdk_gc_destroy(face_gc);
+    gdk_draw_pixmap(map_canvas->window, civ_gc,
+                   scaled_myth_sprite->pixmap, 0, 0, 0, 0, 1900, 1600);
+
+  } else {
+    return FALSE;              /*   Timer is stopped when scroll_counter<61   
*/
+
+  }
+
+  return TRUE;
+}
+
+
+/**************************************************************************
+Remove the Myth text and repaint the regular intro
+**************************************************************************/
+void intro_scroll_remove(int intro_timer_id)
+{
+  int height, width;
+
+  scroll_counter = 100;
+
+  gdk_window_get_size(map_canvas->window, &width, &height);
+  scaled_intro_sprite = sprite_scale(intro_gfx_sprite, width, height);
+
+  gdk_draw_pixmap(map_canvas->window, civ_gc,
+                 scaled_intro_sprite->pixmap, 0, 0, 0, 0, 1900, 1600);
   return;
 }
 
Index: client/gui-gtk/graphics.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.h,v
retrieving revision 1.11
diff -u -u -r1.11 graphics.h
--- client/gui-gtk/graphics.h   2002/09/28 03:33:09     1.11
+++ client/gui-gtk/graphics.h   2003/02/07 15:34:10
@@ -32,11 +32,13 @@
 
 extern SPRITE *    intro_gfx_sprite;
 extern SPRITE *    radar_gfx_sprite;
+extern SPRITE *    myth_gfx_sprite;
 extern GdkCursor * goto_cursor;
 extern GdkCursor * drop_cursor;
 extern GdkCursor * nuke_cursor;
 extern GdkCursor * patrol_cursor;
 
+
 void gtk_draw_shadowed_string(GdkDrawable *drawable,
                              GdkFont *fontset,
                              GdkGC *black_gc,
@@ -50,5 +52,7 @@
 void sprite_get_bounding_box(SPRITE * sprite, int *start_x,
                             int *start_y, int *end_x, int *end_y);
 SPRITE *crop_blankspace(SPRITE *s);
+gint intro_scroll(gpointer data);
+void intro_scroll_remove(int intro_timer_id);
 
 #endif  /* FC__GRAPHICS_H */
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.127
diff -u -u -r1.127 gui_main.c
--- client/gui-gtk/gui_main.c   2003/02/05 07:23:47     1.127
+++ client/gui-gtk/gui_main.c   2003/02/07 15:34:13
@@ -132,6 +132,7 @@
 
 static enum Display_color_type display_color_type;  /* practically unused */
 static gint timer_id;                               /*       ditto        */
+static gint intro_timer_id;                         /* timer for intro    */
 static gint gdk_input_id;
 
 
@@ -906,6 +907,7 @@
   setup_widgets();
   load_intro_gfx();
   load_cursors();
+  intro_scroll(NULL);
 
   genlist_init(&history_list);
   history_pos = -1;
@@ -913,6 +915,7 @@
   gtk_widget_show(toplevel);
 
   timer_id = gtk_timeout_add(TIMER_INTERVAL, timer_callback, NULL);
+  intro_timer_id = gtk_timeout_add(3400, intro_scroll, NULL);
 
   map_canvas_store = gdk_pixmap_new(root_window,
                                  map_canvas_store_twidth * NORMAL_TILE_WIDTH,
@@ -1133,9 +1136,11 @@
 **************************************************************************/
 void add_net_input(int sock)
 {
-  gdk_input_id = gdk_input_add(sock, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
+ gdk_input_id = gdk_input_add(sock, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
                               get_net_input, NULL);
   aconnection.notify_of_writable_data = set_wait_for_writable_socket;
+
+  intro_scroll_remove(intro_timer_id);   /* Stop the scrolling intro */
 }
 
 /**************************************************************************
Index: common/shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.c,v
retrieving revision 1.98
diff -u -u -r1.98 shared.c
--- common/shared.c     2002/12/18 17:36:19     1.98
+++ common/shared.c     2003/02/07 15:34:16
@@ -1222,6 +1222,85 @@
   return _("'Cause civilization should be free!");
 }
 
+
+/***************************************************************************
+  Return the Freeciv Myth.
+  (The myth is common code)
+***************************************************************************/
+char *freeciv_myth(int i)
+{
+
+  char *myth[] =
+      {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " 
",
+" ",
+    N_("                      The Freeciv Myth"),
+    N_("In the beginning, before Earth came to be, there existed two"),
+    N_("worlds: The first world was shrouded in a freezing mist. It"),
+    N_("was called Niflheim, or House of the Mist. Near a well in the"),
+    N_("House of the Mist lived a dragon by the name of Nidbug."),
+    N_("Inside the well itself, there lived hordes of snakes which"),
+    N_("let loose their venom into the water. The venomous water"),
+    N_("overflowed the well and gushed out as a large river of icy"),
+    N_("poison."),
+    " ",
+    N_("In the second world there existed a sea of flames. This was"),
+    N_("called Muspelheim, or House of the Flames. In Muspelheim there"),
+    N_("ruled a creature, a genie named Surt. This creature possessed"),
+    N_("a huge flaming sword from which a biting heat radiated."),
+    N_("Besides Surt, Nidbug, and the snakes, there existed nothing"),
+    N_("that could be considered life."),
+    " ",
+    N_("Between the two worlds was a yawning void called Ginnungagab."),
+    N_("Into this the freezing streams from Niflheim ran until the"),
+    N_("void was filled with mountains of ice."),
+    " ",
+    N_("Surt of Muspelheim swung his sword through the air, and the"),
+    N_("flames licked at the mountains of ice in Ginnungagab."),
+    N_("The desolated and absolutely silent void began to be covered"),
+    N_("with a mysterious haze. At this exact place odd things began"),
+    N_("to happen, and it was at this place that Earth came to be!"),
+    " ",
+    N_("The first thing that ever moved in Ginnungagab was Ymer."),
+    N_("Above Ymer's head stood a cow-like creature named Oedhumle."),
+    N_("From the udder of this creature came a stream of milk which"),
+    N_("flowed down over Ymer's head. Ymer had a drinking orgy and"),
+    N_("then started to doze off. While asleep, Ymer started to sweat"),
+    N_("Suddenly, his left arm gave birth to a female giant, and his"),
+    N_("right arm gave birth to a male giant. Even his legs together"),
+    N_("had a son!"),
+    " ",
+    N_("Meanwhile, Oedhumle, the cow-like creature, stood calmly,"),
+    N_("fully concentrated on licking the iceberg below. One day a"),
+    N_("person was also brought to light. The giants were as ugly as"),
+    N_("ugly could be, but this person was very handsome. His name was"),
+    N_("Bor, and he married the female giant Bestle. Eventually, she"),
+    N_("gave birth to three great, handsome sons: Odin, Ve and Vile."),
+    N_("Odin, Ve and Vile grew up to be wise and strong men, and Odin"),
+    N_("soon came to realize that their destiny was to do away with"),
+    N_("Ymer. They killed him, and his blood flooded the world of"),
+    N_("Ginnungagab leaving nothing but an ocean of blood around them."),
+    N_("When they realized that everything was flooded they decided"),
+    N_("to use Ymer's flesh as land. They tossed the huge bones onto"),
+    N_("the fleshy land and mountains were created. Ymer's skull was"),
+    N_("big enough to build a firmament above the land, and his brain"),
+    N_("was torn apart and tossed into the sky where the pieces began"),
+    N_("to orbit as huge clouds. The left-overs, teeth and small"),
+    N_("fragments of bones, were sprinkled on the land as stones."),
+    " ",
+    N_("Earth was created, and a kind of creature with a mixture of"),
+    N_("giant and human genes was living this new earth with no"),
+    N_("clothing and nothing on its mind but to survive. There was"),
+    N_("a genuine need for some supernatural intervention, but above"),
+    N_("all else what they really needed was one tough leader to"),
+    N_("show them the way to a Freeciv-ilization.....")
+  };
+
+  assert(i>=0 && i<ARRAY_SIZE(myth));
+  freelog(LOG_NORMAL, "%d -> '%s'",i,myth[i]);
+  return _(myth[i]);
+}
+
+
 /***************************************************************************
  Return whether two vectors: vec1 and vec2 have common
  bits. I.e. (vec1 & vec2) != 0.
Index: common/shared.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.h,v
retrieving revision 1.110
diff -u -u -r1.110 shared.h
--- common/shared.h     2002/12/18 19:05:22     1.110
+++ common/shared.h     2003/02/07 15:34:17
@@ -203,5 +203,6 @@
                               int *ind_result);
 
 const char *freeciv_motto(void);
+char *freeciv_myth(int i);
 
 #endif  /* FC__SHARED_H */
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.8
diff -u -u -r1.8 isotrident.tilespec
--- data/isotrident.tilespec    2003/02/02 00:15:53     1.8
+++ data/isotrident.tilespec    2003/02/07 15:34:17
@@ -33,6 +33,7 @@
 ; These are special because they get freed and reloaded
 ; as required:
 main_intro_file    = "misc/intro"
+main_myth_file     = "misc/myth"
 minimap_intro_file = "misc/radar"
 
 ; Below, the graphics spec files; must be somewhere (anywhere) in 

[Prev in Thread] Current Thread [Next in Thread]