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