ref: 1531993b0570f1a0af92a0238f4b871d233fa46f
parent: 936e7e116d8860f858ce9d8b39b1bac39d7e66bf
author: Simon Howard <[email protected]>
date: Mon May 29 15:54:11 EDT 2006
Allow struts to force height as well as width. Hide "start game" button for players which are not the game controller. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 541
--- a/src/net_gui.c
+++ b/src/net_gui.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: net_gui.c 539 2006-05-29 19:22:51Z fraggle $
+// $Id: net_gui.c 541 2006-05-29 19:54:11Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -98,6 +98,7 @@
#include "txt_table.h"
#include "txt_window.h"
+static txt_window_t *window;
static txt_label_t *player_labels[MAXPLAYERS];
static txt_label_t *ip_labels[MAXPLAYERS];
@@ -115,10 +116,8 @@
static void BuildGUI(void)
{
char buf[50];
- txt_window_t *window;
txt_table_t *table;
txt_window_action_t *cancel;
- txt_window_action_t *startgame;
int i;
TXT_SetDesktopTitle(PACKAGE_STRING);
@@ -126,13 +125,12 @@
window = TXT_NewWindow("Waiting for game start...");
table = TXT_NewTable(3);
TXT_AddWidget(window, table);
- TXT_AddWidget(window, NULL);
// Add spacers
TXT_AddWidget(table, NULL);
- TXT_AddWidget(table, TXT_NewStrut(25));
- TXT_AddWidget(table, TXT_NewStrut(17));
+ TXT_AddWidget(table, TXT_NewStrut(25, 1));
+ TXT_AddWidget(table, TXT_NewStrut(17, 1));
// Player labels
@@ -146,18 +144,17 @@
TXT_AddWidget(table, ip_labels[i]);
}
+ TXT_AddWidget(window, TXT_NewStrut(0, 1));
+
cancel = TXT_NewWindowAction(KEY_ESCAPE, "Cancel");
TXT_SignalConnect(cancel, "pressed", EscapePressed, NULL);
- startgame = TXT_NewWindowAction(' ', "Start game");
- TXT_SignalConnect(startgame, "pressed", StartGame, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_LEFT, cancel);
- TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, startgame);
}
static void UpdateGUI(void)
{
- char buf[50];
+ txt_window_action_t *startgame;
int i;
for (i=0; i<MAXPLAYERS; ++i)
@@ -183,6 +180,18 @@
TXT_SetLabel(ip_labels[i], "");
}
}
+
+ if (net_client_controller)
+ {
+ startgame = TXT_NewWindowAction(' ', "Start game");
+ TXT_SignalConnect(startgame, "pressed", StartGame, NULL);
+ }
+ else
+ {
+ startgame = NULL;
+ }
+
+ TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, startgame);
}
void NET_WaitForStart(void)
--- a/textscreen/examples/guitest.c
+++ b/textscreen/examples/guitest.c
@@ -13,6 +13,7 @@
#include "txt_label.h"
#include "txt_radiobutton.h"
#include "txt_separator.h"
+#include "txt_strut.h"
#include "txt_table.h"
#include "txt_window.h"
@@ -104,7 +105,7 @@
TXT_AddWidget(table, TXT_NewButton(buf));
}
- TXT_AddWidget(window, TXT_NewLabel(""));
+ TXT_AddWidget(window, TXT_NewStrut(0, 1));
value_label = TXT_NewLabel("");
TXT_AddWidget(window, value_label);
--- a/textscreen/txt_strut.c
+++ b/textscreen/txt_strut.c
@@ -16,7 +16,7 @@
// Minimum width is the string length + two spaces for padding
*w = strut->width;
- *h = 0;
+ *h = strut->height;
}
static void TXT_StrutDrawer(TXT_UNCAST_ARG(strut), int w, int selected)
@@ -40,7 +40,7 @@
TXT_StrutDestructor,
};
-txt_strut_t *TXT_NewStrut(int width)
+txt_strut_t *TXT_NewStrut(int width, int height)
{
txt_strut_t *strut;
@@ -49,6 +49,7 @@
TXT_InitWidget(strut, &txt_strut_class);
strut->widget.selectable = 0;
strut->width = width;
+ strut->height = height;
return strut;
}
--- a/textscreen/txt_strut.h
+++ b/textscreen/txt_strut.h
@@ -30,7 +30,7 @@
#include "txt_widget.h"
//
-// A strut is used to force a table to a minimum width. It is not
+// A strut is used to force a table to a minimum width/height. It is not
// visible but it takes up space.
//
@@ -38,9 +38,10 @@
{
txt_widget_t widget;
int width;
+ int height;
};
-txt_strut_t *TXT_NewStrut(int width);
+txt_strut_t *TXT_NewStrut(int width, int height);
#endif /* #ifndef TXT_STRUT_H */
--- a/textscreen/txt_table.c
+++ b/textscreen/txt_table.c
@@ -92,7 +92,7 @@
// Empty spacer if widget is NULL
ww = 0;
- wh = 1;
+ wh = 0;
}
if (wh > row_heights[y])