+2002-10-20 Jordi Mallach <jordi@sindominio.net>
+
+ * Patches from James Antill with the following fixes.
+ * src/fields.c (fields_page_contents): change the attack/defense
+ box's minimum size, to avoid message wraps as much as possible.
+ * src/gtetrinet.c (keypress): check for modifier states.
+ (gtetrinet_key): change the toggle page keybinds from F1, F2 and F3
+ to Alt+1,2,3. The previous ones were normally captured by window
+ managers.
+ * src/misc.c (textbox_addtext): add continue in next:.
+ * src/misc.h: define colours for attack/defense messages...
+ * src/tetrinet.c (tetrinet_dospecial): ... and use them here,
+ depending on to whom affects the special and its type.
+ (tetrinet_addspecial): Fix the random order of added special blocks
+ when the player just has one.
+ Shorten attack/defense messages.
+
2002-10-19 Jordi Mallach <jordi@sindominio.net>
* Patch from Cougar <cougar@random.ee> which adds IPv6 support.
widget = leftlabel_new (_("Next piece:"));
gtk_widget_show (widget);
- gtk_box_pack_start (GTK_BOX(box), widget, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), widget, TRUE, TRUE, 0);
/* box that displays the next block */
border = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(border), GTK_SHADOW_IN);
gtk_widget_show (activewidget);
gtk_table_attach_defaults (GTK_TABLE(table2), activewidget, 1, 2, 3, 4);
gtk_widget_show (table2);
- gtk_box_pack_start (GTK_BOX(box), table2, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), table2, TRUE, TRUE, 0);
gtk_widget_show (box);
/* align it */
speciallabel = gtk_label_new ("");
gtk_widget_show (speciallabel);
fields_setspeciallabel (NULL);
- gtk_box_pack_start (GTK_BOX(box), speciallabel, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), speciallabel, TRUE, TRUE, 0);
border = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(border), GTK_SHADOW_IN);
specialwidget = gtk_drawing_area_new ();
box = gtk_vbox_new (FALSE, 0);
widget = gtk_label_new (_("Attacks and defenses:"));
gtk_widget_show (widget);
- gtk_box_pack_start (GTK_BOX(box), widget, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), widget, TRUE, TRUE, 0);
attdefwidget = gtk_text_new (NULL, NULL);
- gtk_widget_set_usize (attdefwidget, BLOCKSIZE*12, BLOCKSIZE*10);
+ gtk_widget_set_usize (attdefwidget, MAX(22*12, BLOCKSIZE*12), BLOCKSIZE*10);
gtk_text_set_word_wrap (GTK_TEXT(attdefwidget), TRUE);
GTK_WIDGET_UNSET_FLAGS (attdefwidget, GTK_CAN_FOCUS);
gtk_widget_show (attdefwidget);
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER(scroll), attdefwidget);
gtk_widget_show (scroll);
- gtk_box_pack_start (GTK_BOX(box), scroll, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(box), scroll, TRUE, TRUE, 0);
gtk_widget_show (box);
align = gtk_alignment_new (0.5, 0.5, 0.5, 0.0);
gtk_container_add (GTK_CONTAINER(align), box);
/* game messages */
table2 = gtk_table_new (1, 2, FALSE);
gmsgtext = gtk_text_new (NULL, NULL);
- gtk_widget_set_usize (gmsgtext, 0, 46);
+ gtk_widget_set_usize (gmsgtext, 0, 48);
gtk_widget_show (gmsgtext);
GTK_WIDGET_UNSET_FLAGS (gmsgtext, GTK_CAN_FOCUS);
scroll = gtk_scrolled_window_new (NULL, NULL);
#include "images/winlist.xpm"
static GtkWidget *pixmapdata_label (char **d, char *str);
-static int gtetrinet_key (int keyval);
+static int gtetrinet_key (int keyval, int mod);
gint keypress (GtkWidget *widget, GdkEventKey *key);
gint keyrelease (GtkWidget *widget, GdkEventKey *key);
gtk_timeout_remove (keytimeoutid);
if (tetrinet_key (key->keyval, key->string)) goto keyprocessed;
}
- if (gtetrinet_key(key->keyval)) goto keyprocessed;
+ if (gtetrinet_key(key->keyval, key->state & (GDK_MOD1_MASK |
+ GDK_CONTROL_MASK |
+ GDK_SHIFT_MASK)))
+ goto keyprocessed;
return FALSE;
keyprocessed:
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
/*
TODO: make this switch between detached pages too
*/
-int gtetrinet_key (int keyval)
+static int gtetrinet_key (int keyval, int mod)
{
+ if (mod != GDK_MOD1_MASK)
+ return (FALSE);
+
switch (keyval)
{
- case GDK_F1: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 0); break;
- case GDK_F2:
+ case GDK_1: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 0); break;
+ case GDK_2:
gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 1);
partyline_entryfocus();
break;
- case GDK_F3: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 2); break;
+ case GDK_3: gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 2); break;
default:
return FALSE;
}
gtk_label_set (GTK_LABEL(GTK_BIN(align)->child), str);
}
-/* returns a random number in the range 0 to n-1 */
+/* returns a random number in the range 0 to n-1 --
+ * Note both n==0 and n==1 always return 0 */
int randomnum (int n)
{
return (float)n*rand()/(RAND_MAX+1.0);
}
else gtk_text_insert (textbox, fonts[attr], color, NULL, &text[i], 1);
next:
+ continue;
}
/* scroll to bottom */
gtk_text_thaw (textbox);
#include <gtk/gtk.h>
+
extern GtkWidget *leftlabel_new (char *str);
extern void leftlabel_set (GtkWidget *align, char *str);
extern int randomnum (int n);
extern void adjust_bottom (GtkAdjustment *adj);
extern char *nocolor (char *str);
extern GtkWidget *pixmap_label (GdkPixmap *pm, GdkBitmap *mask, char *str);
+
+/* textbox codes ... */
+#define TETRI_TB_BOLD 0x2
+#define TETRI_TB_UNDERLINE 0x16
+
+/* colors... see colors[] in misc.c */
+#define TETRI_TB_C_CYAN 3
+#define TETRI_TB_C_BLACK 4
+#define TETRI_TB_C_BRIGHT_BLUE 5
+#define TETRI_TB_C_GREY 6
+
+#define TETRI_TB_C_MAGENTA 8
+
+/* #define TETRI_TB_C_GREY 11 -- dup */
+#define TETRI_TB_C_DARK_GREEN 12
+
+#define TETRI_TB_C_BRIGHT_GREEN 14
+#define TETRI_TB_C_LIGHT_GREY 15
+#define TETRI_TB_C_DARK_RED 16
+#define TETRI_TB_C_DARK_BLUE 17
+#define TETRI_TB_C_BROWN 18
+#define TETRI_TB_C_PURPLE 19
+#define TETRI_TB_C_BRIGHT_RED 20
+/* #define TETRI_TB_C_LIGHT_GREY 21 -- dup */
+
+#define TETRI_TB_C_DARK_CYAN 23
+#define TETRI_TB_C_WHITE 24
+#define TETRI_TB_C_YELLOW 25
#define S_BLOCKBOMB 11
struct sb sbinfo[] = {
- {"cs1", -1, "1 Line Added to All"},
- {"cs2", -1, "2 Lines Added to All"},
- {"cs4", -1, "4 Lines Added to All"},
+ {"cs1", -1, "1 Line Added"},
+ {"cs2", -1, "2 Lines Added"},
+ {"cs4", -1, "4 Lines Added"},
{"a", 6, "Add Line"},
{"c", 7, "Clear Line"},
{"n", 8, "Nuke Field"},
- {"r", 9, "Clear Random Blocks"},
+ {"r", 9, "Clear Random"},
{"s", 10, "Switch Fields"},
- {"b", 11, "Clear Special Blocks"},
+ {"b", 11, "Clear Specials"},
{"g", 12, "Block Gravity"},
{"q", 13, "Blockquake"},
{"o", 14, "Block Bomb"},
}
break;
default:
+ break;
}
}
{
int l, i;
if (specialblocknum >= specialcapacity) return; /* too many ! */
- /* add to a random location */
- l = randomnum(specialblocknum);
+
+ /* add to a random location between, 0 and last offset.
+ * Ie. If you have X sps already it gets added between 0 and X */
+ l = randomnum(++specialblocknum);
for (i = specialblocknum; i > l; i --)
specialblocks[i] = specialblocks[i-1];
specialblocks[l] = sb;
- specialblocknum ++;
tetrinet_setspeciallabel (specialblocks[0]);
}
n --;
}
next:
+ /* fall through */ ;
}
}
end:
{
FIELD field;
int x, y, i;
- char buf[256], buf2[256];
+ char buf[512], buf2[256];
+
+ switch (type)
+ {
+ case S_ADDALL1:
+ case S_ADDALL2:
+ case S_ADDALL4: /* bad for everyone ... */
+ g_assert(!to);
+ if (from == playernum)
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BLACK,
+ sbinfo[type].info,
+ TETRI_TB_C_BLACK,
+ TETRI_TB_BOLD);
+ else
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BRIGHT_RED,
+ sbinfo[type].info,
+ TETRI_TB_C_BRIGHT_RED,
+ TETRI_TB_BOLD);
+ break;
+
+ case S_ADDLINE:
+ case S_CLEARBLOCKS:
+ case S_CLEARSPECIAL:
+ case S_BLOCKQUAKE:
+ case S_BLOCKBOMB: /* badish stuff for someone */
+ if (to == playernum)
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BRIGHT_RED,
+ sbinfo[type].info,
+ TETRI_TB_C_BRIGHT_RED,
+ TETRI_TB_BOLD);
+ else if (from == playernum)
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BLACK,
+ sbinfo[type].info,
+ TETRI_TB_C_BLACK,
+ TETRI_TB_BOLD);
+ else
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_DARK_RED,
+ sbinfo[type].info,
+ TETRI_TB_C_DARK_RED,
+ TETRI_TB_BOLD);
+ break;
- sprintf (buf, "\02\023%s\023\02", sbinfo[type].info);
+ case S_CLEARLINE:
+ case S_NUKEFIELD:
+ case S_SWITCH:
+ case S_GRAVITY: /* goodish stuff for someone */
+ if (to == playernum)
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BRIGHT_GREEN,
+ sbinfo[type].info,
+ TETRI_TB_C_BRIGHT_GREEN,
+ TETRI_TB_BOLD);
+ else
+ sprintf (buf, "%c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_DARK_GREEN,
+ sbinfo[type].info,
+ TETRI_TB_C_DARK_GREEN,
+ TETRI_TB_BOLD);
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
if (to) {
- sprintf (buf2, " on \02\021%s\021\02", playernames[to]);
+ if (to == playernum)
+ sprintf (buf2, " on %c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BRIGHT_BLUE,
+ playernames[to],
+ TETRI_TB_C_BRIGHT_BLUE,
+ TETRI_TB_BOLD);
+ else
+ sprintf (buf2, " on %c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_DARK_BLUE,
+ playernames[to],
+ TETRI_TB_C_DARK_BLUE,
+ TETRI_TB_BOLD);
strcat (buf, buf2);
}
+ else
+ {
+ sprintf (buf2, " to All");
+ strcat (buf, buf2);
+ }
+
if (from) {
- sprintf (buf2, " by \02\021%s\021\02", playernames[from]);
+ if (from == playernum)
+ sprintf (buf2, " by %c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_BRIGHT_BLUE,
+ playernames[from],
+ TETRI_TB_C_BRIGHT_BLUE,
+ TETRI_TB_BOLD);
+ else
+ sprintf (buf2, " by %c%c%s%c%c",
+ TETRI_TB_BOLD,
+ TETRI_TB_C_DARK_BLUE,
+ playernames[from],
+ TETRI_TB_C_DARK_BLUE,
+ TETRI_TB_BOLD);
strcat (buf, buf2);
}
fields_attdefmsg (buf);
tetrinet_dospecial (playernum, 0, sbnum);
}
endremovelines:
+ /* end of if */ ;
}
/* give it a little delay in drawing */
gtk_timeout_add (40, (GtkFunction)tetrinet_removelinestimeout,