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: Sat, 08 Feb 2003 11:10:48 +0100

Raimar Falke wrote:

On Fri, Feb 07, 2003 at 07:39:00PM +0100, Andreas Røsdal wrote:
I've been experimenting with scrolling "The Freeciv Myth"
on the introscreen.

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.

Compiles and works. It should also show/continue if the client is
connected. It should also be possible to scroll by pixel and not by
line and make it smoother so.

I've added smooth by pixel scrolling, and it's now shown when
the client is connected, and removed when the game starts.
It's a bit more CPU intensive now..

Now about the difficult task: some people don't like it if the Myth is
shown. Either display doc/PEOPLE or some new written file.
Sure. Then doc/PEOPLE has to be read from file,
and some algorithm has to split it into chars that fit
on a line. Any ideas?

Andreas Røsdal
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,21 @@
 
 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_count = 0;                       /* counter for intro_scroll() */
+int scroll_linecount = 0;                   /* counter for linecontrol    */
+static gint scroll_timer_id;                /* timer for scrolling        */
+
+
+
 /***************************************************************************
 ...
 ***************************************************************************/
@@ -80,6 +89,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
 
 /**************************************************************************
 ...
@@ -162,6 +174,86 @@
   return;
 }
 
+
+/**************************************************************************
+Called from gui_main when the scrolling shall begin
+**************************************************************************/
+gint intro_scroll_init(gpointer data)
+{
+scroll_timer_id = gtk_timeout_add(500, intro_scroll, NULL);
+return FALSE;
+}
+
+
+/**************************************************************************
+Scroll text in intro, every time the text is to be moved one pixel.
+**************************************************************************/
+gint intro_scroll(gpointer data)
+{
+  if (!intro_gfx_sprite) {return FALSE;}
+
+  if (scroll_linecount < 61) {
+    gint height, width;
+    int tot;
+    GdkColor face;
+    GdkGC *face_gc;
+    SPRITE *scaled_myth_sprite;
+
+
+    /* 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 ,
+                    height);
+
+   /*  Draw each textline of the myth to scaled_myth_sprite */
+    scroll_count++;
+    if(scroll_count>7) {
+      scroll_count = 0;
+      scroll_linecount++;
+    }
+
+    int line = 0;
+     while (line < 16) {
+      gdk_draw_string(scaled_myth_sprite->pixmap, main_fontset,
+                     face_gc, width * 0.50 - 210,
+                     height * 0.8 - (18 * line) - (scroll_count*2),
+                     freeciv_myth(15 - line + scroll_linecount));
+      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);
+
+    /* free memory */
+    free_sprite(scaled_myth_sprite);
+    scaled_myth_sprite=NULL;
+    free_sprite(myth_gfx_sprite);
+    myth_gfx_sprite=NULL;
+
+
+  } else {
+    return FALSE;              /*   Timer is stopped when scroll_linecount<61  
 */
+
+  }
+
+  return TRUE;
+}
+
+
 /***************************************************************************
 return newly allocated sprite cropped from source
 ***************************************************************************/
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_init(gpointer data);
+gint intro_scroll(gpointer data);
 
 #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(5000, intro_scroll_init, NULL);
 
   map_canvas_store = gdk_pixmap_new(root_window,
                                  map_canvas_store_twidth * NORMAL_TILE_WIDTH,
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: 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,82 @@
   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.....")
+  };
+  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]