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