]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c
Add blank crosshair and model settings dialogs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_playersetup.c
1 #ifdef INTERFACE
2 CLASS(XonoticPlayerSettingsTab) EXTENDS(XonoticTab)
3         METHOD(XonoticPlayerSettingsTab, fill, void(entity))
4         METHOD(XonoticPlayerSettingsTab, draw, void(entity))
5         ATTRIB(XonoticPlayerSettingsTab, title, string, _("Player Setup"))
6         ATTRIB(XonoticPlayerSettingsTab, intendedWidth, float, 0.9)
7         ATTRIB(XonoticPlayerSettingsTab, rows, float, 22)
8         ATTRIB(XonoticPlayerSettingsTab, columns, float, 6.2) // added extra .2 for center space 
9         ATTRIB(XonoticPlayerSettingsTab, playerNameLabel, entity, NULL)
10         ATTRIB(XonoticPlayerSettingsTab, playerNameLabelAlpha, float, 0)
11 ENDCLASS(XonoticPlayerSettingsTab)
12 entity makeXonoticPlayerSettingsTab();
13 void HUDSetup_Start(entity me, entity btn);
14 #endif
15
16 #ifdef IMPLEMENTATION
17 void HUDSetup_Check_Gamestatus(entity me, entity btn)
18 {
19         if not(gamestatus & (GAME_CONNECTED | GAME_ISSERVER)) // we're not in a match, ask the player if they want to start one anyway
20         {
21                 DialogOpenButton_Click(me, main.hudconfirmDialog);
22         }
23         else // already in a match, lets just cut to the point and open up the hud editor directly
24         {
25                 HUDSetup_Start(me, btn);
26         }
27 }
28 entity makeXonoticPlayerSettingsTab()
29 {
30         entity me;
31         me = spawnXonoticPlayerSettingsTab();
32         me.configureDialog(me);
33         return me;
34 }
35 void XonoticPlayerSettingsTab_draw(entity me)
36 {
37         if(cvar_string("_cl_name") == "Player")
38                 me.playerNameLabel.alpha = ((mod(time * 2, 2) < 1) ? 1 : 0);
39         else
40                 me.playerNameLabel.alpha = me.playerNameLabelAlpha;
41         SUPER(XonoticPlayerSettingsTab).draw(me);
42 }
43 void XonoticPlayerSettingsTab_fill(entity me)
44 {
45         entity e, pms, sl, label, e0, box;
46         float i, r, m, n;
47
48         me.TR(me);
49                 me.TD(me, 1, 0.5, me.playerNameLabel = makeXonoticTextLabel(0, _("Name:")));
50                         me.playerNameLabelAlpha = me.playerNameLabel.alpha;
51                 me.TD(me, 1, 2.5, label = makeXonoticTextLabel(0, string_null));
52                         label.allowCut = 1;
53                         label.allowColors = 1;
54                         label.alpha = 1;
55         me.TR(me);
56                 me.TD(me, 1, 3.0, box = makeXonoticInputBox(1, "_cl_name"));
57                         box.forbiddenCharacters = "\r\n\\\"$"; // don't care, isn't getting saved
58                         box.maxLength = -127; // negative means encoded length in bytes
59                         box.saveImmediately = 1;
60                         label.textEntity = box;
61         me.TR(me);
62                 me.TD(me, 5, 1, e = makeXonoticColorpicker(box));
63                 me.TD(me, 5, 2, e = makeXonoticCharmap(box));
64         me.TR(me);
65         me.TR(me);
66         me.TR(me);
67         me.TR(me);
68         me.TR(me);
69         me.TR(me);
70         me.gotoRC(me, 8, 0.0);
71                 pms = makeXonoticPlayerModelSelector();
72                 me.TD(me, 1, 0.6, e = makeXonoticTextLabel(1, _("Model:")));
73                 me.TD(me, 1, 0.3, e = makeXonoticButton("<<", '0 0 0'));
74                         e.onClick = PlayerModelSelector_Prev_Click;
75                         e.onClickEntity = pms;
76                 me.TD(me, me.rows - (me.currentRow + 3), 1.8, pms);
77                 me.TD(me, 1, 0.3, e = makeXonoticButton(">>", '0 0 0'));
78                         e.onClick = PlayerModelSelector_Next_Click;
79                         e.onClickEntity = pms;
80         me.TR(me);
81                 r = me.currentRow;
82                 m = me.rows - (r + 4);
83                 n = 16 - !cvar("developer");
84                 m = m / (n - 1);
85                 for(i = 0; i < n; ++i)
86                 {
87                         me.gotoRC(me, r + i * m, 0.1);
88                         me.TDNoMargin(me, m, 0.2, e = makeXonoticColorButton(1, 0, i), '0 1 0');
89                 }
90                 for(i = 0; i < n; ++i)
91                 {
92                         me.gotoRC(me, r + i * m, 0.4);
93                         me.TDNoMargin(me, m, 0.2, e = makeXonoticColorButton(2, 1, i), '0 1 0');
94                 }
95
96
97         // crosshair_enabled: 0 = no crosshair options, 1 = no crosshair selection, but everything else enabled, 2 = all crosshair options enabled
98         // FIXME: In the future, perhaps make one global crosshair_type cvar which has 0 for disabled, 1 for custom, 2 for per weapon, etc?
99         me.gotoRC(me, 0, 3.2); me.setFirstColumn(me, me.currentColumn);
100                 me.TD(me, 1, 3, e = makeXonoticRadioButton(3, "crosshair_enabled", "0", _("No crosshair")));
101         me.TR(me);
102                 me.TD(me, 1, 3, e = makeXonoticRadioButton(3, "crosshair_per_weapon", string_null, _("Per weapon crosshair")));
103                 makeMulti(e, "crosshair_enabled");
104         me.TR(me);
105                 me.TD(me, 1, 3, e = makeXonoticRadioButton(3, "crosshair_enabled", "2", _("Custom crosshair")));
106         me.TR(me);
107                 me.TDempty(me, 0.1);
108                 for(i = 1; i <= 14; ++i) {
109                         me.TDNoMargin(me, 1, 2 / 14, e = makeXonoticCrosshairButton(4, i), '1 1 0');
110                                 setDependentAND(e, "crosshair_per_weapon", 0, 0, "crosshair_enabled", 1, 2);
111                 }
112                 // show a larger preview of the selected crosshair
113                 me.TDempty(me, 0.1);
114                 me.TDNoMargin(me, 3, 0.8, e = makeXonoticCrosshairButton(7, -1), '1 1 0'); // crosshair -1 makes this a preview
115                         setDependentAND(e, "crosshair_per_weapon", 0, 0, "crosshair_enabled", 1, 2);
116         me.TR(me);
117                 me.TDempty(me, 0.1);
118                 for(i = 15; i <= 28; ++i) {
119                         me.TDNoMargin(me, 1, 2 / 14, e = makeXonoticCrosshairButton(4, i), '1 1 0');
120                                 setDependentAND(e, "crosshair_per_weapon", 0, 0, "crosshair_enabled", 1, 2);
121                 }
122         me.TR(me);
123         me.TR(me);
124                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Crosshair size:")));
125                         setDependent(e, "crosshair_enabled", 1, 2);
126                 me.TD(me, 1, 2, e = makeXonoticSlider(0.1, 1.0, 0.01, "crosshair_size"));
127                         setDependent(e, "crosshair_enabled", 1, 2);
128         me.TR(me);
129                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Crosshair alpha:")));
130                         setDependent(e, "crosshair_enabled", 1, 2);
131                 me.TD(me, 1, 2, e = makeXonoticSlider(0, 1, 0.1, "crosshair_alpha"));
132                         setDependent(e, "crosshair_enabled", 1, 2);
133         me.TR(me);
134         me.TR(me);
135                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Crosshair color:")));
136                         setDependent(e, "crosshair_enabled", 1, 2);
137                 me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_per_weapon", string_null, _("Per weapon")));
138                         setDependent(e, "crosshair_enabled", 1, 2);
139                 me.TD(me, 1, 1, e = makeXonoticRadioButton(5, "crosshair_color_by_health", string_null, _("By health")));
140                         setDependent(e, "crosshair_enabled", 1, 2);
141         me.TR(me);
142                 me.TDempty(me, 0.1);
143                 me.TD(me, 1, 0.8, e = makeXonoticRadioButton(5, string_null, string_null, _("Custom")));
144                         setDependent(e, "crosshair_enabled", 1, 2);
145                 me.TD(me, 2, 2, e = makeXonoticColorpickerString("crosshair_color", "crosshair_color"));
146                         setDependentAND3(e, "crosshair_color_per_weapon", 0, 0, "crosshair_color_by_health", 0, 0, "crosshair_enabled", 1, 2);
147         me.TR(me);
148         me.TR(me);
149         me.TR(me);
150                 me.TDempty(me, 0.5);
151                 me.TD(me, 1, 2, e = makeXonoticButton(_("Other crosshair settings"), '0 0 0'));
152                         e.onClick = DialogOpenButton_Click;
153                         e.onClickEntity = main.crosshairDialog;
154                 setDependent(e, "crosshair_enabled", 1, 2);
155                 // TODO: show status of crosshair dot and hittest and pickups and such here with text
156         me.TR(me);
157         me.TR(me);
158                 me.TDempty(me, 0.5);
159                 me.TD(me, 1, 2, e = makeXonoticButton(_("Model settings"), '0 0 0'));
160                         e.onClick = DialogOpenButton_Click;
161                         e.onClickEntity = main.modelDialog;
162                 // TODO: show csqc model settings like forcemyplayer and deglowing/ghosting bodies with text here
163         me.TR(me);
164                 me.TDempty(me, 0.5);
165                 me.TD(me, 1, 2, e = makeXonoticButton(_("View settings"), '0 0 0'));
166                         e.onClick = DialogOpenButton_Click;
167                         e.onClickEntity = main.viewDialog;
168                 // TODO: show fov and other settings with text here
169         me.TR(me);
170                 me.TDempty(me, 0.5);
171                 me.TD(me, 1, 2, e = makeXonoticButton(_("Weapon settings"), '0 0 0'));
172                         e.onClick = DialogOpenButton_Click;
173                         e.onClickEntity = main.weaponsDialog;
174                 // I don't really think this is useful as is, and especially it doesn't look very clean...
175                 // In the future, if ALL of these buttons had some information, then it would be justified/clean
176                 //me.TD(me, 1, 1, e0 = makeXonoticTextLabel(0, string_null)); 
177                 //      e0.textEntity = main.weaponsDialog;
178                 //      e0.allowCut = 1;
179         me.TR(me);
180                 me.TDempty(me, 0.5);
181                 me.TD(me, 1, 2, e = makeXonoticButton(_("HUD settings"), '0 0 0'));
182                         e.onClick = HUDSetup_Check_Gamestatus;
183                         e.onClickEntity = me;
184                 // TODO: show hud config name with text here 
185
186         me.gotoRC(me, me.rows - 1, 0);
187                 me.TD(me, 1, me.columns, makeXonoticCommandButton(_("Apply immediately"), '0 0 0', "color -1 -1;name \"$_cl_name\";cl_cmd sendcvar cl_weaponpriority;sendcvar cl_zoomfactor;sendcvar cl_zoomspeed;sendcvar cl_autoswitch;sendcvar cl_forceplayermodelsfromxonotic;sendcvar cl_forceplayermodels;playermodel $_cl_playermodel;playerskin $_cl_playerskin", COMMANDBUTTON_APPLY));
188 }
189 #endif