[Freeciv-Dev] (PR#2437) new graphics: improvements and technology
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2437) new graphics: improvements and technology |
From: |
"Jason Short via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Thu, 28 Nov 2002 01:56:13 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
This patch was sent to me by Rafal Burseg. It provides support for a
graphics sprite for each city improvement and technology advance. This
is supported in the rulesets, so there are changes to both client and
server and an added optional capability. The SDL client will have
support for drawing these graphics, and it may be added to other GUIs in
time.
This concept is very good.
There are some issues with this, however:
- Some trivial style issues. Most notably pImpr should probably be
pimpr,
- The capability string is set, but it is not checked. has_capability()
should be used for this.
- The client must not die if the graphics are not found. This needs to
be tested with both supporting and non-supporting tilesets.
- Support is needed for the tileset reloading case. I suspect this just
involves calling the setup functions as appropriate from within
tileset_reread.
- Comments describing the sprites should IMO be more specific. How big
is the sprite, and what exactly is it to be used for? Alternately, this
information may need to go into doc/README.graphics.
- We need an example tileset. Perhaps this is already in freeciv-test
somewhere, but if so I don't see it.
The only change I've made to the patch is to split it up into code and
data portions.
jason
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.263
diff -u -r1.263 packhand.c
--- client/packhand.c 2002/11/23 02:55:42 1.263
+++ client/packhand.c 2002/11/28 09:52:47
@@ -1783,6 +1783,8 @@
a = &advances[p->id];
sz_strlcpy(a->name, p->name);
+ sz_strlcpy(a->graphic_str, p->graphic_str);
+ sz_strlcpy(a->graphic_alt, p->graphic_alt);
a->req[0] = p->req[0];
a->req[1] = p->req[1];
a->flags = p->flags;
@@ -1790,6 +1792,8 @@
a->num_reqs = p->num_reqs;
a->helptext = p->helptext; /* pointer assignment */
+
+ tilespec_setup_tech_type(p->id);
}
/**************************************************************************
@@ -1808,6 +1812,8 @@
b = &improvement_types[p->id];
sz_strlcpy(b->name, p->name);
+ sz_strlcpy(b->graphic_str, p->graphic_str);
+ sz_strlcpy(b->graphic_alt, p->graphic_alt);
b->tech_req = p->tech_req;
b->bldg_req = p->bldg_req;
b->terr_gate = p->terr_gate; /* pointer assignment */
@@ -1948,6 +1954,8 @@
} impr_type_iterate_end;
}
#endif
+
+ tilespec_setup_impr_type(p->id);
}
/**************************************************************************
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.91
diff -u -r1.91 tilespec.c
--- client/tilespec.c 2002/11/21 02:26:48 1.91
+++ client/tilespec.c 2002/11/28 09:52:47
@@ -883,6 +883,37 @@
}
/**********************************************************************
+ Set improvement_type sprite value; should only happen after
+ tilespec_load_tiles().
+***********************************************************************/
+void tilespec_setup_impr_type(int id)
+{
+ struct impr_type *pImpr = get_improvement_type( id );
+
+ pImpr->sprite = lookup_sprite_tag_alt(pImpr->graphic_str, pImpr->graphic_alt,
+ improvement_exists(id), "impr_type",
+ pImpr->name);
+
+ /* should maybe do something if NULL, eg generic default? */
+}
+
+/**********************************************************************
+ Set tech_type sprite value; should only happen after
+ tilespec_load_tiles().
+***********************************************************************/
+void tilespec_setup_tech_type( int id )
+{
+
+ advances[id].sprite = lookup_sprite_tag_alt(advances[id].graphic_str,
+ advances[id].graphic_alt,
+ tech_exists(id) , "tech_type",
+ advances[id].name);
+
+ /* should maybe do something if NULL, eg generic default? */
+}
+
+
+/**********************************************************************
Set tile_type sprite values; should only happen after
tilespec_load_tiles().
***********************************************************************/
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.32
diff -u -r1.32 tilespec.h
--- client/tilespec.h 2002/11/19 23:04:28 1.32
+++ client/tilespec.h 2002/11/28 09:52:47
@@ -37,6 +37,8 @@
void tilespec_reread_callback(struct client_option *option);
void tilespec_setup_unit_type(int id);
+void tilespec_setup_impr_type(int id);
+void tilespec_setup_tech_type(int id);
void tilespec_setup_tile_type(int id);
void tilespec_setup_government(int id);
void tilespec_setup_nation_flag(int id);
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.115
diff -u -r1.115 capstr.c
--- common/capstr.c 2002/11/14 09:15:01 1.115
+++ common/capstr.c 2002/11/28 09:52:47
@@ -74,7 +74,7 @@
* are not directly related to the capability strings discussed here.)
*/
-#define CAPABILITY "+1.14.0 conn_info +occupied team"
+#define CAPABILITY "+1.14.0 conn_info +occupied team sdl"
/* "+1.14.0" is protocol for 1.14.0 release.
@@ -85,6 +85,8 @@
cities but instead use the occupied flag of short_city_info.
"team" is support for player teams
+
+ "sdl" is support for some sdlclient gfx load
*/
void init_our_capability(void)
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.14
diff -u -r1.14 improvement.h
--- common/improvement.h 2002/10/19 04:16:16 1.14
+++ common/improvement.h 2002/11/28 09:52:47
@@ -205,6 +205,8 @@
struct impr_type {
char name[MAX_LEN_NAME];
char name_orig[MAX_LEN_NAME]; /* untranslated */
+ char graphic_str[MAX_LEN_NAME]; /* city icon of improv. */
+ char graphic_alt[MAX_LEN_NAME]; /* city icon of improv. */
Tech_Type_id tech_req; /* A_LAST = never; A_NONE = always */
Impr_Type_id bldg_req; /* B_LAST = none required */
enum tile_terrain_type *terr_gate; /* list; T_LAST terminated */
@@ -219,6 +221,7 @@
int sabotage;
struct impr_effect *effect; /* list; .type==EFT_LAST terminated */
int variant; /* FIXME: remove when gen-impr obsoletes */
+ struct Sprite *sprite; /* Icon of Improvm. */
char *helptext;
char soundtag[MAX_LEN_NAME];
char soundtag_alt[MAX_LEN_NAME];
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.226
diff -u -r1.226 packets.c
--- common/packets.c 2002/11/14 09:15:02 1.226
+++ common/packets.c 2002/11/28 09:52:48
@@ -2038,6 +2038,8 @@
dio_put_uint32(&dout, packet->preset_cost);
dio_put_uint32(&dout, packet->num_reqs);
dio_put_string(&dout, packet->name);
+ dio_put_string(&dout, packet->graphic_str);
+ dio_put_string(&dout, packet->graphic_alt);
/* This must be last, so client can determine length: */
if(packet->helptext) {
@@ -2063,6 +2065,8 @@
dio_get_uint32(&din, &packet->preset_cost);
dio_get_uint32(&din, &packet->num_reqs);
dio_get_string(&din, packet->name, sizeof(packet->name));
+ dio_get_string(&din, packet->graphic_str, sizeof(packet->graphic_str));
+ dio_get_string(&din, packet->graphic_alt, sizeof(packet->graphic_alt));
len = dio_input_remaining(&din);
if (len > 0) {
@@ -2118,6 +2122,8 @@
}
dio_put_uint8(&dout, packet->variant); /* FIXME: remove when gen-impr
obsoletes */
dio_put_string(&dout, packet->name);
+ dio_put_string(&dout, packet->graphic_str);
+ dio_put_string(&dout, packet->graphic_alt);
dio_put_string(&dout, packet->soundtag);
dio_put_string(&dout, packet->soundtag_alt);
@@ -2170,6 +2176,8 @@
packet->effect[count].type = EFT_LAST;
dio_get_uint8(&din, &packet->variant); /* FIXME: remove when gen-impr
obsoletes */
dio_get_string(&din, packet->name, sizeof(packet->name));
+ dio_get_string(&din, packet->graphic_str, sizeof(packet->graphic_str));
+ dio_get_string(&din, packet->graphic_alt, sizeof(packet->graphic_alt));
dio_get_string(&din, packet->soundtag, sizeof(packet->soundtag));
dio_get_string(&din, packet->soundtag_alt, sizeof(packet->soundtag_alt));
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.129
diff -u -r1.129 packets.h
--- common/packets.h 2002/11/11 10:00:47 1.129
+++ common/packets.h 2002/11/28 09:52:48
@@ -638,6 +638,8 @@
int id, req[2]; /* indices for advances[] */
int flags;
char name[MAX_LEN_NAME];
+ char graphic_str[MAX_LEN_NAME];
+ char graphic_alt[MAX_LEN_NAME];
char *helptext; /* same as for packet_ruleset_unit, above */
int preset_cost;
int num_reqs;
@@ -646,6 +648,8 @@
struct packet_ruleset_building {
int id; /* index for improvement_types[] */
char name[MAX_LEN_NAME];
+ char graphic_str[MAX_LEN_NAME];
+ char graphic_alt[MAX_LEN_NAME];
Tech_Type_id tech_req;
Impr_Type_id bldg_req;
enum tile_terrain_type *terr_gate;
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.35
diff -u -r1.35 tech.h
--- common/tech.h 2002/11/01 17:40:46 1.35
+++ common/tech.h 2002/11/28 09:52:48
@@ -65,11 +65,15 @@
struct advance {
char name[MAX_LEN_NAME];
- char name_orig[MAX_LEN_NAME]; /* untranslated */
+ char name_orig[MAX_LEN_NAME]; /* untranslated */
+ char graphic_str[MAX_LEN_NAME]; /* icon of tech. */
+ char graphic_alt[MAX_LEN_NAME]; /* icon of tech. */
int req[2];
unsigned int flags;
char *helptext;
+ struct Sprite *sprite; /* icon of tech. */
+
/*
* Message displayed to the first player to get a bonus tech
*/
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.126
diff -u -r1.126 ruleset.c
--- server/ruleset.c 2002/11/26 12:24:56 1.126
+++ server/ruleset.c 2002/11/28 09:52:49
@@ -535,6 +535,11 @@
}
free(slist);
+ sz_strlcpy(a->graphic_str,
+ secfile_lookup_str(file, "%s.graphic", sec[i]));
+ sz_strlcpy(a->graphic_alt,
+ secfile_lookup_str(file, "%s.graphic_alt", sec[i]));
+
a->helptext = lookup_helptext(file, sec[i]);
a->bonus_message = lookup_string(file, sec[i], "bonus_message");
a->preset_cost =
@@ -1189,6 +1194,12 @@
/* FIXME: remove when gen-impr obsoletes */
b->variant = secfile_lookup_int_default(file, 0, "%s.variant", sec[i]);
+
+ sz_strlcpy(b->graphic_str,
+ secfile_lookup_str(file, "%s.graphic", sec[i]));
+ sz_strlcpy(b->graphic_alt,
+ secfile_lookup_str(file, "%s.graphic_alt", sec[i]));
+
sz_strlcpy(b->soundtag,
secfile_lookup_str_default(file, "-", "%s.sound", sec[i]));
sz_strlcpy(b->soundtag_alt,
@@ -2426,6 +2437,8 @@
for(a=advances; a<advances+game.num_tech_types; a++) {
packet.id = a-advances;
sz_strlcpy(packet.name, a->name_orig);
+ sz_strlcpy(packet.graphic_str, a->graphic_str);
+ sz_strlcpy(packet.graphic_alt, a->graphic_alt);
packet.req[0] = a->req[0];
packet.req[1] = a->req[1];
packet.flags = a->flags;
@@ -2449,6 +2462,8 @@
packet.id = i;
sz_strlcpy(packet.name, b->name_orig);
+ sz_strlcpy(packet.graphic_str, b->graphic_str);
+ sz_strlcpy(packet.graphic_alt, b->graphic_alt);
packet.tech_req = b->tech_req;
packet.bldg_req = b->bldg_req;
packet.terr_gate = b->terr_gate; /* pointer assignment */
extra_gfx-data.diff.gz
Description: extra_gfx-data.diff.gz
- [Freeciv-Dev] (PR#2437) new graphics: improvements and technology,
Jason Short via RT <=
|
|