[Freeciv-Dev] (PR#3357) Re: Re: suggestion: myth about freeciv
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Jason Dorje Short wrote:
> Andreas Røsdal wrote:
>
>> Raimar Falke wrote:
>
>
>>> 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?
>
>
> It would be nice to let the tileset specify what file is to be used.
> However, this runs into problems with translation (it's hard to have
> it done automatically). Another alternative is to let the tileset
> specify the string itself that is to be used for the intro. Here the
> string would look something like the nation legends from
> data/nation/*.ruleset.
>
> Either way, you will have to handle newlines yourself unless the GUI can.
>
> IMO the current 'myth' text is quite uninspiring, and doc/PEOPLE is
> even worse. So we need someone to write something exciting :-). Even
> without this, the code could still be good if it let the tileset
> specify what to do - so that once somebody writes something cool later
> the tilesets will be able to take advantage of the code. But we will
> need at least one tileset to demonstrate the feature.
>
> You should send your (next) patch to RT, our bug/patch tracker:
> rt@xxxxxxxxxxxxxx.
>
> jason
>
>
I've updated the patch so it can get the introtext from a string (making
it possible to add ruleset-reading).
The patch requires introstory.png (rename myth.png from myth.tar.bz2 in
/incoming)
Andreas R.
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,20 @@
SPRITE * intro_gfx_sprite;
SPRITE * radar_gfx_sprite;
+SPRITE * introstory_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 intro_timer_id; /* timer for intro */
+
+
+
/***************************************************************************
...
***************************************************************************/
@@ -80,6 +88,9 @@
#define COLOR_MOTTO_FACE_R 0x2D
#define COLOR_MOTTO_FACE_G 0x71
#define COLOR_MOTTO_FACE_B 0xE3
+#define COLOR_INTROSTORY_FACE_R 0xED
+#define COLOR_INTROSTORY_FACE_G 0xED
+#define COLOR_INTROSTORY_FACE_B 0xFF
/**************************************************************************
...
@@ -162,6 +173,110 @@
return;
}
+
+/**************************************************************************
+Scroll the intro story
+**************************************************************************/
+gint intro_scroll(gpointer data)
+{
+ if (!intro_gfx_sprite) {
+ return FALSE;
+ }
+
+ if (scroll_linecount!=-1) {
+ gint height, width;
+ int currentline, counter, screenline = 0;;
+ GdkColor face;
+ GdkGC *face_gc;
+ SPRITE *scaled_introstory_sprite;
+
+
+ /* get colors */
+ face.red = COLOR_INTROSTORY_FACE_R << 8;
+ face.green = COLOR_INTROSTORY_FACE_G << 8;
+ face.blue = COLOR_INTROSTORY_FACE_B << 8;
+ gdk_imlib_best_color_get(&face);
+
+ /* Load the background image */
+ introstory_gfx_sprite = load_gfxfile(main_introstory_filename);
+
+ face_gc = gdk_gc_new(root_window);
+
+ gdk_gc_set_foreground(face_gc, &face);
+ gdk_window_get_size(map_canvas->window, &width, &height);
+ scaled_introstory_sprite = sprite_scale(introstory_gfx_sprite,
+ width,height);
+
+ /* Draw each textline to background sprite */
+ scroll_count++;
+ if(scroll_count>7) {
+ scroll_count = 0;
+ scroll_linecount++;
+ }
+
+
+ while (screenline!=16) {
+ currentline = 15 - screenline + scroll_linecount;
+ counter = 0;
+ const char *story = freeciv_introstory();
+ char str[10000];
+ strcpy(str, story);
+ char * pch = strtok (str,"-");
+
+ while (counter!=(currentline)) {
+ pch = strtok(NULL, "-");
+ counter++;
+ }
+
+ if((pch==NULL)) {
+ return FALSE;
+ }
+
+ gdk_draw_string(scaled_introstory_sprite->pixmap, main_fontset,
+ face_gc, width * 0.50 - 210,
+ height * 0.8 - (18 * screenline) - (scroll_count*2), pch);
+ screenline++;
+ }
+
+ /* Draw scaled_introstory_sprite to the screen */
+ gdk_gc_destroy(face_gc);
+ gdk_draw_pixmap(map_canvas->window, civ_gc,
+ scaled_introstory_sprite->pixmap, 0, 0, 0, 0, 1900, 1600);
+
+ /* free memory */
+ free_sprite(scaled_introstory_sprite);
+ scaled_introstory_sprite=NULL;
+ free_sprite(introstory_gfx_sprite);
+ introstory_gfx_sprite=NULL;
+
+
+ } else {
+ return FALSE; /* Timer is stopped when scroll_linecount<61
*/
+
+ }
+
+ return TRUE;
+}
+
+
+/**************************************************************************
+Stop the intro story
+**************************************************************************/
+void intro_scroll_stop(gpointer data)
+{
+ scroll_linecount=-1;
+}
+
+/**************************************************************************
+Start the intro story
+**************************************************************************/
+void intro_scroll_start(gpointer data)
+{
+ scroll_linecount=0;
+ intro_timer_id = gtk_timeout_add(600, intro_scroll, NULL);
+}
+
+
/***************************************************************************
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 * introstory_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,8 @@
void sprite_get_bounding_box(SPRITE * sprite, int *start_x,
int *start_y, int *end_x, int *end_y);
SPRITE *crop_blankspace(SPRITE *s);
+void intro_scroll_start(gpointer data);
+void intro_scroll_stop(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
@@ -906,6 +906,7 @@
setup_widgets();
load_intro_gfx();
load_cursors();
+ intro_scroll(NULL);
genlist_init(&history_list);
history_pos = -1;
@@ -1136,6 +1137,9 @@
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_start(NULL);
+
}
/**************************************************************************
@@ -1146,4 +1150,6 @@
{
gdk_input_remove(gdk_input_id);
gdk_window_set_cursor(root_window, NULL);
+ intro_scroll_stop(NULL);
+
}
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_introstory_filename;
char *minimap_intro_filename;
struct named_sprites sprites;
@@ -259,6 +260,10 @@
free(main_intro_filename);
main_intro_filename = NULL;
}
+ if (main_introstory_filename) {
+ free(main_introstory_filename);
+ main_introstory_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_introstory_file");
+ main_introstory_filename = tilespec_gfx_filename(c);
+ freelog(LOG_DEBUG, "introstory file %s", main_introstory_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_introstory_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,17 @@
return _("'Cause civilization should be free!");
}
+
+/***************************************************************************
+ Return the Freeciv Introstory.
+ Newline delimiter: -
+***************************************************************************/
+const char *freeciv_introstory(void)
+{
+ return _("- - - - - - - - - - - - - - - -In the dawn of history, savage
tribes of men roamed the earth.-Cruelty and chaos ruled the day. No law or
custom guided the-minds of these primitives. They lived like the animals.-
-But then one day, a great leader stepped forward. The tribes-were forged into
a mighty nation. No longer living hand to-mouth, the people now had time to
dream... to explore, to build,-to learn... or to conquer.- -You are the
leader. The nation is yours. What will be your dream?- - - - - - - - - - - - -
- - - - -");
+}
+
+
/***************************************************************************
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);
+const char *freeciv_introstory(void);
#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_introstory_file = "misc/introstory"
minimap_intro_file = "misc/radar"
; Below, the graphics spec files; must be somewhere (anywhere) in
- [Freeciv-Dev] Re: suggestion: myth about freeciv, (continued)
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Andreas Røsdal, 2003/02/07
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Andreas Røsdal, 2003/02/07
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Raimar Falke, 2003/02/07
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Andreas Røsdal, 2003/02/07
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Raimar Falke, 2003/02/07
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Andreas Røsdal, 2003/02/08
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Christian Knoke, 2003/02/08
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Jason Dorje Short, 2003/02/08
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Andreas Røsdal, 2003/02/08
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Greg Wooledge, 2003/02/08
- Message not available
- [Freeciv-Dev] (PR#3357) Re: Re: suggestion: myth about freeciv,
andrearo@xxxxxxxxxxxx via RT <=
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Reinier Post, 2003/02/09
- [Freeciv-Dev] Re: suggestion: myth about freeciv, Raimar Falke, 2003/02/10
|
|