shithub: choc

Download patch

ref: 481b3391baff23f1682df009df7d3387d62f3d75
parent: 196e21dc30f6f2092992cdba5164a8985da41ecf
author: Simon Howard <[email protected]>
date: Fri Sep 29 07:49:30 EDT 2006

Use TXT_AddWidgets in setup for greatly enhanced readability.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 679

--- a/setup/compatibility.c
+++ b/setup/compatibility.c
@@ -34,9 +34,11 @@
 
         window = TXT_NewWindow("Compatibility");
 
-        TXT_AddWidget(window, TXT_NewCheckBox("Vanilla savegame limit",
-                                              &vanilla_savegame_limit));
-        TXT_AddWidget(window, TXT_NewCheckBox("Vanilla demo limit",
-                                              &vanilla_demo_limit));
+        TXT_AddWidgets(window, 
+                       TXT_NewCheckBox("Vanilla savegame limit",
+                                       &vanilla_savegame_limit),
+                       TXT_NewCheckBox("Vanilla demo limit",
+                                       &vanilla_demo_limit),
+                       NULL);
 }
 
--- a/setup/display.c
+++ b/setup/display.c
@@ -81,7 +81,9 @@
 void ConfigDisplay(void)
 {
     txt_window_t *window;
-    txt_table_t *table;
+    txt_table_t *windowed_table;
+    txt_table_t *fullscreen_table;
+    txt_table_t *misc_table;
     txt_radiobutton_t *rbutton;
     int i;
 
@@ -93,43 +95,39 @@
     
     window = TXT_NewWindow("Display Configuration");
 
-    TXT_AddWidget(window, TXT_NewSeparator("Windowed modes"));
+    TXT_AddWidgets(window, 
+                   TXT_NewSeparator("Fullscreen modes"),
+                   fullscreen_table = TXT_NewTable(2),
+                   TXT_NewSeparator("Windowed modes"),
+                   windowed_table = TXT_NewTable(2),
+                   TXT_NewSeparator("Misc."),
+                   TXT_NewCheckBox("Show ENDOOM screen", &show_endoom),
+                   misc_table = TXT_NewTable(2),
+                   NULL);
 
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 14, 14);
+    TXT_SetColumnWidths(windowed_table, 14, 14);
     
     for (i=0; modes[i].fullscreen == 0; ++i)
     {
         rbutton = TXT_NewRadioButton(modes[i].description, &vidmode, i);
-        TXT_AddWidget(table, rbutton);
+        TXT_AddWidget(windowed_table, rbutton);
         TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]);
     }
 
-    TXT_AddWidget(window, table);
+    TXT_SetColumnWidths(fullscreen_table, 14, 14);
 
-    TXT_AddWidget(window, TXT_NewSeparator("Fullscreen modes"));
-
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 14, 14);
-
     for (; modes[i].description != NULL; ++i)
     {
         rbutton = TXT_NewRadioButton(modes[i].description, &vidmode, i);
-        TXT_AddWidget(table, rbutton);
+        TXT_AddWidget(fullscreen_table, rbutton);
         TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]);
     }
 
-    TXT_AddWidget(window, table);
+    TXT_SetColumnWidths(misc_table, 22, 5);
 
-    TXT_AddWidget(window, TXT_NewSeparator("Misc."));
-    TXT_AddWidget(window, TXT_NewCheckBox("Show ENDOOM screen", &show_endoom));
-
-    table = TXT_NewTable(2);
-
-    TXT_SetColumnWidths(table, 22, 5);
-    TXT_AddWidget(table, TXT_NewLabel("Startup delay (ms)"));
-    TXT_AddWidget(table, TXT_NewIntInputBox(&startup_delay, 5));
-
-    TXT_AddWidget(window, table);
+    TXT_AddWidgets(misc_table,
+                   TXT_NewLabel("Startup delay (ms)"),
+                   TXT_NewIntInputBox(&startup_delay, 5),
+                   NULL);
 }
 
--- a/setup/keyboard.c
+++ b/setup/keyboard.c
@@ -72,36 +72,35 @@
 void ConfigKeyboard(void)
 {
     txt_window_t *window;
-    txt_table_t *table;
+    txt_table_t *movement_table;
+    txt_table_t *action_table;
 
     window = TXT_NewWindow("Keyboard configuration");
 
-    TXT_AddWidget(window, TXT_NewSeparator("Movement"));
+    TXT_AddWidgets(window, 
+                   TXT_NewSeparator("Movement"),
+                   movement_table = TXT_NewTable(2),
+                   TXT_NewCheckBox("Always run", &always_run),
 
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 20, 8);
+                   TXT_NewSeparator("Action"),
+                   action_table = TXT_NewTable(2),
+                   NULL);
 
-    AddKeyControl(table, "Move Forward", &key_up);
-    AddKeyControl(table, "Move Backward", &key_down);
-    AddKeyControl(table, "Turn Left", &key_left);
-    AddKeyControl(table, "Turn Right", &key_right);
-    AddKeyControl(table, "Strafe Left", &key_strafeleft);
-    AddKeyControl(table, "Strafe Right", &key_straferight);
-    AddKeyControl(table, "Speed On", &key_speed);
-    AddKeyControl(table, "Strafe On", &key_strafe);
+    TXT_SetColumnWidths(movement_table, 20, 8);
 
-    TXT_AddWidget(window, table);
-    TXT_AddWidget(window, TXT_NewCheckBox("Always run", &always_run));
+    AddKeyControl(movement_table, "Move Forward", &key_up);
+    AddKeyControl(movement_table, "Move Backward", &key_down);
+    AddKeyControl(movement_table, "Turn Left", &key_left);
+    AddKeyControl(movement_table, "Turn Right", &key_right);
+    AddKeyControl(movement_table, "Strafe Left", &key_strafeleft);
+    AddKeyControl(movement_table, "Strafe Right", &key_straferight);
+    AddKeyControl(movement_table, "Speed On", &key_speed);
+    AddKeyControl(movement_table, "Strafe On", &key_strafe);
 
-    TXT_AddWidget(window, TXT_NewSeparator("Action"));
+    TXT_SetColumnWidths(action_table, 20, 8);
 
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 20, 8);
-
-    AddKeyControl(table, "Use", &key_use);
-    AddKeyControl(table, "Fire", &key_fire);
-
-    TXT_AddWidget(window, table);
+    AddKeyControl(action_table, "Use", &key_use);
+    AddKeyControl(action_table, "Fire", &key_fire);
 
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
 }
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -37,24 +37,23 @@
 {
     txt_window_t *window;
     txt_label_t *label;
-    txt_button_t *button;
+    txt_button_t *yes_button;
+    txt_button_t *no_button;
 
     window = TXT_NewWindow(NULL);
 
-    label = TXT_NewLabel("Save settings and\n"
-                         "quit setup?");
-    TXT_AddWidget(window, label);
-    TXT_AddWidget(window, TXT_NewStrut(24, 0));
+    TXT_AddWidgets(window, 
+                   label = TXT_NewLabel("Save settings and\n"
+                                        "quit setup?"),
+                   TXT_NewStrut(24, 0),
+                   yes_button = TXT_NewButton2("  Yes  ", DoQuit, DoQuit),
+                   no_button = TXT_NewButton2("  No   ", DoQuit, NULL),
+                   NULL);
+
     TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);
+    TXT_SetWidgetAlign(yes_button, TXT_HORIZ_CENTER);
+    TXT_SetWidgetAlign(no_button, TXT_HORIZ_CENTER);
 
-    button = TXT_NewButton2("  Yes  ", DoQuit, DoQuit);
-    TXT_SetWidgetAlign(button, TXT_HORIZ_CENTER);
-    TXT_AddWidget(window, button);
-
-    button = TXT_NewButton2("  No   ", DoQuit, NULL);
-    TXT_SetWidgetAlign(button, TXT_HORIZ_CENTER);
-    TXT_AddWidget(window, button);
-
     // Only an "abort" button in the middle.
     TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL);
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, 
@@ -78,35 +77,18 @@
 
     window = TXT_NewWindow("Main Menu");
 
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Configure display", ConfigDisplay, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Configure keyboard", ConfigKeyboard, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Configure mouse", ConfigMouse, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Configure sound", ConfigSound, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Compatibility", CompatibilitySettings, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton("Save parameters and launch DOOM"));
-
-    TXT_AddWidget(window, TXT_NewStrut(0, 1));
-    
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Start a Network game", StartMultiGame, NULL));
-
-    TXT_AddWidget(window,
-                  TXT_NewButton2("Join a Network game", JoinMultiGame, NULL));
-
-    TXT_AddWidget(window, 
-                  TXT_NewButton2("Multiplayer configuration", 
-                                 MultiplayerConfig, NULL));
+    TXT_AddWidgets(window,
+          TXT_NewButton2("Configure display", ConfigDisplay, NULL),
+          TXT_NewButton2("Configure keyboard", ConfigKeyboard, NULL),
+          TXT_NewButton2("Configure mouse", ConfigMouse, NULL),
+          TXT_NewButton2("Configure sound", ConfigSound, NULL),
+          TXT_NewButton2("Compatibility", CompatibilitySettings, NULL),
+          TXT_NewButton("Save parameters and launch DOOM"),
+          TXT_NewStrut(0, 1),
+          TXT_NewButton2("Start a Network game", StartMultiGame, NULL),
+          TXT_NewButton2("Join a Network game", JoinMultiGame, NULL),
+          TXT_NewButton2("Multiplayer configuration", MultiplayerConfig, NULL),
+          NULL);
 
     quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit");
     TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
--- a/setup/mouse.c
+++ b/setup/mouse.c
@@ -74,43 +74,43 @@
 void ConfigMouse(void)
 {
     txt_window_t *window;
-    txt_table_t *table;
+    txt_table_t *motion_table;
+    txt_table_t *button_table;
 
     window = TXT_NewWindow("Mouse configuration");
 
-    TXT_AddWidget(window, TXT_NewCheckBox("Enable mouse", &use_mouse));
+    TXT_AddWidgets(window,
+                   TXT_NewCheckBox("Enable mouse", &use_mouse),
+                   TXT_NewInvertedCheckBox("Allow vertical mouse movement", 
+                                           &novert),
+                   TXT_NewCheckBox("Grab mouse in windowed mode", 
+                                          &grabmouse),
 
-    TXT_AddWidget(window, 
-                  TXT_NewInvertedCheckBox("Allow vertical mouse movement", 
-                                          &novert));
-    TXT_AddWidget(window, TXT_NewCheckBox("Grab mouse in windowed mode", 
-                                          &grabmouse));
+                   TXT_NewSeparator("Mouse motion"),
+                   motion_table = TXT_NewTable(2),
+    
+                   TXT_NewSeparator("Mouse buttons"),
 
-    TXT_AddWidget(window, TXT_NewSeparator("Mouse motion"));
+                   button_table = TXT_NewTable(2),
+                   NULL);
 
-    table = TXT_NewTable(2);
+    TXT_SetColumnWidths(motion_table, 27, 5);
 
-    TXT_SetColumnWidths(table, 27, 5);
-    TXT_AddWidget(table, TXT_NewLabel("Speed"));
-    TXT_AddWidget(table, TXT_NewSpinControl(&speed, 1, 256));
-    TXT_AddWidget(table, TXT_NewLabel("Acceleration"));
-    TXT_AddWidget(table, TXT_NewSpinControl(&accel, 1, 5));
-    TXT_AddWidget(table, TXT_NewLabel("Acceleration threshold"));
-    TXT_AddWidget(table, TXT_NewSpinControl(&threshold, 0, 32));
+    TXT_AddWidgets(motion_table,
+                   TXT_NewLabel("Speed"),
+                   TXT_NewSpinControl(&speed, 1, 256),
+                   TXT_NewLabel("Acceleration"),
+                   TXT_NewSpinControl(&accel, 1, 5),
+                   TXT_NewLabel("Acceleration threshold"),
+                   TXT_NewSpinControl(&threshold, 0, 32),
+                   NULL);
 
-    TXT_AddWidget(window, table);
-    
-    TXT_AddWidget(window, TXT_NewSeparator("Mouse buttons"));
+    TXT_SetColumnWidths(button_table, 27, 5);
 
-    table = TXT_NewTable(2);
-
-    TXT_SetColumnWidths(table, 27, 5);
-    AddMouseControl(table, "Fire weapon", &mouseb_fire);
-    AddMouseControl(table, "Move forward", &mouseb_forward);
-    AddMouseControl(table, "Strafe on", &mouseb_strafe);
+    AddMouseControl(button_table, "Fire weapon", &mouseb_fire);
+    AddMouseControl(button_table, "Move forward", &mouseb_forward);
+    AddMouseControl(button_table, "Strafe on", &mouseb_strafe);
     
-    TXT_AddWidget(window, table);
-
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction());
 }
 
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -249,52 +249,49 @@
 void StartMultiGame(void)
 {
     txt_window_t *window;
-    txt_table_t *table;
-    txt_button_t *button;
+    txt_table_t *gameopt_table;
+    txt_table_t *advanced_table;
 
     window = TXT_NewWindow("Start multiplayer game");
 
+    TXT_AddWidgets(window, 
+                   gameopt_table = TXT_NewTable(2),
+                   TXT_NewSeparator("Monsters"),
+                   TXT_NewInvertedCheckBox("Monsters", &nomonsters),
+                   TXT_NewCheckBox("Fast monsters", &fast),
+                   TXT_NewCheckBox("Respawning monsters", &respawn),
+                   TXT_NewSeparator("Advanced"),
+                   advanced_table = TXT_NewTable(2),
+                   TXT_NewButton2("Add extra parameters...", 
+                                  OpenExtraParamsWindow, NULL),
+                   NULL);
+
     TXT_SetWindowAction(window, TXT_HORIZ_CENTER, WadWindowAction());
     TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction());
     
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 12, 12);
-    TXT_AddWidget(table, TXT_NewLabel("Skill"));
-    TXT_AddWidget(table, TXT_NewDropdownList(&skill, skills, 5));
-    TXT_AddWidget(table, TXT_NewLabel("Game type"));
-    TXT_AddWidget(table, TXT_NewDropdownList(&deathmatch, gamemodes, 3));
+    TXT_SetColumnWidths(gameopt_table, 12, 12);
 
-    TXT_AddWidget(table, TXT_NewLabel("Level warp"));
+    TXT_AddWidgets(gameopt_table,
+           TXT_NewLabel("Skill"),
+           TXT_NewDropdownList(&skill, skills, 5),
+           TXT_NewLabel("Game type"),
+           TXT_NewDropdownList(&deathmatch, gamemodes, 3),
+           TXT_NewLabel("Level warp"),
+           warpbutton = TXT_NewButton2("????", LevelSelectDialog, NULL),
+           TXT_NewLabel("Time limit"),
+           TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2),
+                           TXT_NewLabel("minutes"),
+                           NULL),
+           NULL);
 
-    warpbutton = TXT_NewButton("????");
-    TXT_AddWidget(table, warpbutton);
-    TXT_SignalConnect(warpbutton, "pressed", LevelSelectDialog, NULL);
-    UpdateWarpButton();
+    TXT_SetColumnWidths(advanced_table, 12, 12);
 
-    TXT_AddWidget(table, TXT_NewLabel("Time limit"));
-    TXT_AddWidget(table, TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2),
-                                         TXT_NewLabel("minutes"),
-                                         NULL));
+    TXT_AddWidgets(advanced_table, 
+                   TXT_NewLabel("UDP port"),
+                   TXT_NewIntInputBox(&udpport, 5),
+                   NULL);
 
-    TXT_AddWidget(window, table);
-
-    TXT_AddWidget(window, TXT_NewSeparator("Monsters"));
-    TXT_AddWidget(window, TXT_NewInvertedCheckBox("Monsters", &nomonsters));
-    TXT_AddWidget(window, TXT_NewCheckBox("Fast monsters", &fast));
-    TXT_AddWidget(window, TXT_NewCheckBox("Respawning monsters", &respawn));
-
-    TXT_AddWidget(window, TXT_NewSeparator("Advanced"));
-    table = TXT_NewTable(2);
-    TXT_SetColumnWidths(table, 12, 12);
-
-    TXT_AddWidget(table, TXT_NewLabel("UDP port"));
-    TXT_AddWidget(table, TXT_NewIntInputBox(&udpport, 5));
-    TXT_AddWidget(window, table);
-
-    button = TXT_NewButton("Add extra parameters...");
-    TXT_SignalConnect(button, "pressed", OpenExtraParamsWindow, NULL);
-    TXT_AddWidget(window, button);
-    
+    UpdateWarpButton();
 }
 
 void JoinMultiGame(void)
@@ -303,14 +300,14 @@
 
     window = TXT_NewWindow("Join multiplayer game");
 
-    TXT_AddWidget(window, TXT_NewLabel("Connect to address: "));
-    TXT_AddWidget(window, TXT_NewInputBox(&connect_address, 40));
-    TXT_AddWidget(window, TXT_NewStrut(0, 1));
+    TXT_AddWidgets(window, 
+        TXT_NewLabel("Connect to address: "),
+        TXT_NewInputBox(&connect_address, 40),
+        TXT_NewStrut(0, 1),
+        TXT_NewButton2("Add extra parameters...", OpenExtraParamsWindow, NULL),
+        TXT_NewButton2("Add WADs...", OpenWadsWindow, NULL),
+        NULL);
 
-    TXT_AddWidget(window, TXT_NewButton2("Add extra parameters...",
-                                         OpenExtraParamsWindow, NULL));
-    TXT_AddWidget(window, TXT_NewButton2("Add WADs...", OpenWadsWindow, NULL));
-
     TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction());
 }
 
@@ -373,19 +370,17 @@
 
     window = TXT_NewWindow("Multiplayer Configuration");
 
-    TXT_AddWidget(window, TXT_NewStrut(0, 1));
+    TXT_AddWidgets(window, 
+                   TXT_NewStrut(0, 1),
+                   TXT_NewHorizBox(TXT_NewLabel("Player name:  "),
+                                   TXT_NewInputBox(&player_name, 25),
+                                   NULL),
+                   TXT_NewStrut(0, 1),
+                   TXT_NewSeparator("Chat macros"),
+                   NULL);
 
     table = TXT_NewTable(2);
 
-    TXT_AddWidget(table, TXT_NewLabel("Player name:  "));
-    TXT_AddWidget(table, TXT_NewInputBox(&player_name, 25));
-
-    TXT_AddWidget(window, table);
-    TXT_AddWidget(window, TXT_NewStrut(0, 1));
-    TXT_AddWidget(window, TXT_NewSeparator("Chat macros"));
-
-    table = TXT_NewTable(2);
-
     for (i=0; i<10; ++i)
     {
         sprintf(buf, "#%i ", i + 1);
@@ -392,8 +387,11 @@
 
         label = TXT_NewLabel(buf);
         TXT_SetFGColor(label, TXT_COLOR_BRIGHT_CYAN);
-        TXT_AddWidget(table, label);
-        TXT_AddWidget(table, TXT_NewInputBox(&chatmacros[i], 40));
+
+        TXT_AddWidgets(table,
+                       label,
+                       TXT_NewInputBox(&chatmacros[i], 40),
+                       NULL);
     }
     
     TXT_AddWidget(window, table);
--- a/setup/sound.c
+++ b/setup/sound.c
@@ -35,45 +35,34 @@
 void ConfigSound(void)
 {
         txt_window_t *window;
-        txt_table_t *table;
-        txt_checkbox_t *checkbox;
-        txt_spincontrol_t *spincontrol;
+        txt_table_t *sfx_table;
+        txt_table_t *music_table;
 
         window = TXT_NewWindow("Sound configuration");
 
-        TXT_AddWidget(window, TXT_NewSeparator("Sound effects"));
+        TXT_AddWidgets(window,
+                   TXT_NewSeparator("Sound effects"),
+                   TXT_NewCheckBox("Sound effects enabled", &snd_sfxenabled),
+                   sfx_table = TXT_NewTable(2),
+                   TXT_NewSeparator("Music"),
+                   TXT_NewCheckBox("Music enabled", &snd_musicenabled),
+                   music_table = TXT_NewTable(2),
+                   NULL);
 
-        checkbox = TXT_NewCheckBox("Sound effects enabled", &snd_sfxenabled);
-        TXT_AddWidget(window, checkbox);
-        
-        table = TXT_NewTable(2);
-        TXT_SetColumnWidths(table, 20, 5);
+        TXT_SetColumnWidths(sfx_table, 20, 5);
 
-        TXT_AddWidget(table, TXT_NewLabel("Sound channels"));
+        TXT_AddWidgets(sfx_table, 
+                       TXT_NewLabel("Sound channels"),
+                       TXT_NewSpinControl(&snd_channels, 1, 8),
+                       TXT_NewLabel("SFX volume"),
+                       TXT_NewSpinControl(&sfx_volume, 0, 15),
+                       NULL);
 
-        spincontrol = TXT_NewSpinControl(&snd_channels, 1, 8);
-        TXT_AddWidget(table, spincontrol);
+        TXT_SetColumnWidths(music_table, 20, 5);
 
-        TXT_AddWidget(table, TXT_NewLabel("SFX volume"));
-
-        spincontrol = TXT_NewSpinControl(&sfx_volume, 0, 15);
-        TXT_AddWidget(table, spincontrol);
-
-        TXT_AddWidget(window, table);
-
-        TXT_AddWidget(window, TXT_NewSeparator("Music"));
-
-        checkbox = TXT_NewCheckBox("Music enabled", &snd_musicenabled);
-        TXT_AddWidget(window, checkbox);
-
-        table = TXT_NewTable(2);
-        TXT_SetColumnWidths(table, 20, 5);
-
-        TXT_AddWidget(table, TXT_NewLabel("Music volume"));
-        
-        spincontrol = TXT_NewSpinControl(&music_volume, 0, 15);
-        TXT_AddWidget(table, spincontrol);
-
-        TXT_AddWidget(window, table);
+        TXT_AddWidgets(music_table,
+                       TXT_NewLabel("Music volume"),
+                       TXT_NewSpinControl(&music_volume, 0, 15),
+                       NULL);
 }