]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.c
auto-super.pl run
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mapinfo.c
1 #ifdef INTERFACE
2 CLASS(XonoticMapInfoDialog) EXTENDS(XonoticDialog)
3         METHOD(XonoticMapInfoDialog, fill, void(entity))
4         METHOD(XonoticMapInfoDialog, loadMapInfo, void(entity, float, entity))
5         ATTRIB(XonoticMapInfoDialog, title, string, "Map Information")
6         ATTRIB(XonoticMapInfoDialog, color, vector, SKINCOLOR_DIALOG_MAPINFO)
7         ATTRIB(XonoticMapInfoDialog, intendedWidth, float, 0.85)
8         ATTRIB(XonoticMapInfoDialog, rows, float, 9)
9         ATTRIB(XonoticMapInfoDialog, columns, float, 10)
10
11         ATTRIB(XonoticMapInfoDialog, previewImage, entity, NULL)
12         ATTRIB(XonoticMapInfoDialog, titleLabel, entity, NULL)
13         ATTRIB(XonoticMapInfoDialog, authorLabel, entity, NULL)
14         ATTRIB(XonoticMapInfoDialog, descriptionLabel, entity, NULL)
15         ATTRIB(XonoticMapInfoDialog, featuresLabel, entity, NULL)
16
17         ATTRIB(XonoticMapInfoDialog, typeDeathmatchLabel, entity, NULL)
18         ATTRIB(XonoticMapInfoDialog, typeTDMLabel, entity, NULL)
19         ATTRIB(XonoticMapInfoDialog, typeLMSLabel, entity, NULL)
20         ATTRIB(XonoticMapInfoDialog, typeArenaLabel, entity, NULL)
21         ATTRIB(XonoticMapInfoDialog, typeRuneLabel, entity, NULL)
22         ATTRIB(XonoticMapInfoDialog, typeDominationLabel, entity, NULL)
23         ATTRIB(XonoticMapInfoDialog, typeKeyHuntLabel, entity, NULL)
24         ATTRIB(XonoticMapInfoDialog, typeCTFLabel, entity, NULL)
25         ATTRIB(XonoticMapInfoDialog, typeCALabel, entity, NULL)
26         ATTRIB(XonoticMapInfoDialog, typeAssaultLabel, entity, NULL)
27         ATTRIB(XonoticMapInfoDialog, typeOnslaughtLabel, entity, NULL)
28         ATTRIB(XonoticMapInfoDialog, typeRaceLabel, entity, NULL)
29         ATTRIB(XonoticMapInfoDialog, typeCTSLabel, entity, NULL)
30         ATTRIB(XonoticMapInfoDialog, typeNexballLabel, entity, NULL)
31
32         ATTRIB(XonoticMapInfoDialog, currentMapIndex, float, 0)
33         ATTRIB(XonoticMapInfoDialog, currentMapBSPName, string, string_null)
34         ATTRIB(XonoticMapInfoDialog, currentMapTitle, string, string_null)
35         ATTRIB(XonoticMapInfoDialog, currentMapAuthor, string, string_null)
36         ATTRIB(XonoticMapInfoDialog, currentMapDescription, string, string_null)
37         ATTRIB(XonoticMapInfoDialog, currentMapPreviewImage, string, string_null)
38         ATTRIB(XonoticMapInfoDialog, currentMapFeaturesText, string, string_null)
39 ENDCLASS(XonoticMapInfoDialog)
40 #endif
41
42 #ifdef IMPLEMENTATION
43 void XonoticMapInfoDialog_loadMapInfo(entity me, float i, entity mlb)
44 {
45         me.currentMapIndex = i;
46         me.startButton.onClickEntity = mlb;
47         MapInfo_Get_ByID(i);
48
49         if(me.currentMapBSPName)
50         {
51                 strunzone(me.currentMapBSPName);
52                 strunzone(me.currentMapTitle);
53                 strunzone(me.currentMapAuthor);
54                 strunzone(me.currentMapDescription);
55                 strunzone(me.currentMapPreviewImage);
56                 strunzone(me.currentMapFeaturesText);
57         }
58         me.currentMapBSPName = strzone(MapInfo_Map_bspname);
59         me.currentMapTitle = strzone(MapInfo_Map_title);
60         me.currentMapAuthor = strzone(MapInfo_Map_author);
61         me.currentMapDescription = strzone(MapInfo_Map_description);
62         me.currentMapFeaturesText = strzone((MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) ? "Full item placement" : "MinstaGib only");
63         me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname));
64
65         me.frame.setText(me.frame, me.currentMapBSPName);
66         me.titleLabel.setText(me.titleLabel, me.currentMapTitle);
67         me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);
68         me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);
69         me.featuresLabel.setText(me.featuresLabel, me.currentMapFeaturesText);
70         me.previewImage.src = me.currentMapPreviewImage;
71
72         me.typeDeathmatchLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH);
73         me.typeTDMLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH);
74         me.typeLMSLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_LMS);
75         me.typeArenaLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ARENA);
76         me.typeDominationLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DOMINATION);
77         me.typeRuneLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RUNEMATCH);
78         me.typeKeyHuntLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_KEYHUNT);
79         me.typeCTFLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTF);
80         me.typeCALabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CA);
81         me.typeAssaultLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT);
82         me.typeOnslaughtLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ONSLAUGHT);
83         me.typeRaceLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE);
84         me.typeCTSLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTS);
85         me.typeNexballLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_NEXBALL);
86
87         MapInfo_ClearTemps();
88 }
89 void XonoticMapInfoDialog_fill(entity me)
90 {
91         entity e;
92         float w, wgt;
93         me.TR(me);
94                 me.TDempty(me, 0.2);
95                 me.TD(me, me.rows - 2, 3, e = makeXonoticImage(string_null, 4.0/3.0));
96                 me.previewImage = e;
97         me.gotoRC(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
98         w = me.columns - me.currentColumn;
99                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, "Title:"));
100                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
101                         e.colorL = SKINCOLOR_MAPLIST_TITLE;
102                         e.allowCut = 1;
103                         me.titleLabel = e;
104         me.TR(me);
105                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, "Author:"));
106                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
107                         e.colorL = SKINCOLOR_MAPLIST_AUTHOR;
108                         e.allowCut = 1;
109                         me.authorLabel = e;
110         me.TR(me);
111                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, "Features:"));
112                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
113                         e.allowCut = 1;
114                         me.featuresLabel = e;
115         me.TR(me);
116                 me.TD(me, 1, w, e = makeXonoticTextLabel(0, "Game types:"));
117         me.TR(me); wgt = (w-0.2)/5;
118                 me.TDempty(me, 0.2);
119                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "DM"));
120                         me.typeDeathmatchLabel = e;
121                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "TDM"));
122                         me.typeTDMLabel = e;
123                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "LMS"));
124                         me.typeLMSLabel = e;
125                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Arena"));
126                         me.typeArenaLabel = e;
127                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Rune"));
128                         me.typeRuneLabel = e;
129         me.TR(me);
130                 me.TDempty(me, 0.2);
131                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Domination"));
132                         me.typeDominationLabel = e;
133                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Key Hunt"));
134                         me.typeKeyHuntLabel = e;
135                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "CTF"));
136                         me.typeCTFLabel = e;
137                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "CA"));
138                         me.typeCALabel = e;
139                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Assault"));
140                         me.typeAssaultLabel = e;
141         me.TR(me);
142                 me.TDempty(me, 0.2);
143                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Onslaught"));
144                         me.typeOnslaughtLabel = e;
145                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Race"));
146                         me.typeRaceLabel = e;
147                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "CTS"));
148                         me.typeCTSLabel = e;
149                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, "Nexball"));
150                         me.typeNexballLabel = e;
151
152         me.gotoRC(me, me.rows - 2, 0);
153                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
154                         e.allowCut = 1;
155                         me.descriptionLabel = e;
156
157         me.gotoRC(me, me.rows - 1, 0);
158                 me.TDempty(me, 0.5);
159
160                 me.TD(me, 1, me.columns - 5.5, e = makeXonoticButton("Close", '0 0 0'));
161                         e.onClick = Dialog_Close;
162                         e.onClickEntity = me;
163                 me.TD(me, 1, me.columns - 5.5, me.startButton = e = makeXonoticButton("Play", '0 0 0'));
164                         me.startButton.onClick = MapList_LoadMap;
165                         me.startButton.onClickEntity = NULL; // filled later
166                 me.TDempty(me, 0.5);
167 }
168 #endif