]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.c
Merge branch 'tzork/gm_nexball' of git://de.git.xonotic.org/xonotic/xonotic-data...
[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, 1.0)
8         ATTRIB(XonoticMapInfoDialog, rows, float, 12)
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         ATTRIBARRAY(XonoticMapInfoDialog, typeLabels, entity, 24)
18
19         ATTRIB(XonoticMapInfoDialog, currentMapIndex, float, 0)
20         ATTRIB(XonoticMapInfoDialog, currentMapBSPName, string, string_null)
21         ATTRIB(XonoticMapInfoDialog, currentMapTitle, string, string_null)
22         ATTRIB(XonoticMapInfoDialog, currentMapAuthor, string, string_null)
23         ATTRIB(XonoticMapInfoDialog, currentMapDescription, string, string_null)
24         ATTRIB(XonoticMapInfoDialog, currentMapPreviewImage, string, string_null)
25         ATTRIB(XonoticMapInfoDialog, currentMapFeaturesText, string, string_null)
26 ENDCLASS(XonoticMapInfoDialog)
27 #endif
28
29 #ifdef IMPLEMENTATION
30 void XonoticMapInfoDialog_loadMapInfo(entity me, float i, entity mlb)
31 {
32         me.currentMapIndex = i;
33         me.startButton.onClickEntity = mlb;
34         MapInfo_Get_ByID(i);
35
36         if(me.currentMapBSPName)
37         {
38                 strunzone(me.currentMapBSPName);
39                 strunzone(me.currentMapTitle);
40                 strunzone(me.currentMapAuthor);
41                 strunzone(me.currentMapDescription);
42                 strunzone(me.currentMapPreviewImage);
43                 strunzone(me.currentMapFeaturesText);
44         }
45         me.currentMapBSPName = strzone(MapInfo_Map_bspname);
46         me.currentMapTitle = strzone(MapInfo_Map_title);
47         me.currentMapAuthor = strzone(MapInfo_Map_author);
48         me.currentMapDescription = strzone(MapInfo_Map_description);
49         me.currentMapFeaturesText = strzone((MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) ? _("Full item placement") : _("MinstaGib only"));
50         me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname));
51
52         me.frame.setText(me.frame, me.currentMapBSPName);
53         me.titleLabel.setText(me.titleLabel, me.currentMapTitle);
54         me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);
55         me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);
56         me.featuresLabel.setText(me.featuresLabel, me.currentMapFeaturesText);
57         if(draw_PictureSize(me.currentMapPreviewImage) == '0 0 0')
58                 me.previewImage.src = "nopreview_map";
59         else
60                 me.previewImage.src = me.currentMapPreviewImage;
61
62         for(i = 0; i < GameType_GetCount(); ++i)
63         {
64                 entity e;
65                 e = me.(typeLabels[i]);
66                 e.disabled = !(MapInfo_Map_supportedGametypes & GameType_GetID(i));
67         }
68
69         MapInfo_ClearTemps();
70 }
71 void XonoticMapInfoDialog_fill(entity me)
72 {
73         entity e;
74         float w, wgt, i, n;
75         me.TR(me);
76                 me.TDempty(me, 0.2);
77                 me.TD(me, me.rows - 2, 3, e = makeXonoticImage(string_null, 4.0/3.0));
78                 me.previewImage = e;
79         me.gotoRC(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
80         w = me.columns - me.currentColumn;
81                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Title:")));
82                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
83                         e.colorL = SKINCOLOR_MAPLIST_TITLE;
84                         e.allowCut = 1;
85                         me.titleLabel = e;
86         me.TR(me);
87                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Author:")));
88                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
89                         e.colorL = SKINCOLOR_MAPLIST_AUTHOR;
90                         e.allowCut = 1;
91                         me.authorLabel = e;
92         me.TR(me);
93                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Features:")));
94                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
95                         e.allowCut = 1;
96                         me.featuresLabel = e;
97         me.TR(me);
98                 me.TD(me, 1, w, e = makeXonoticTextLabel(0, _("Game types:")));
99
100         n = ceil(GameType_GetCount() / (me.rows - 6));
101         wgt = (w - 0.2) / n;
102         for(i = 0; i < GameType_GetCount(); ++i)
103         {
104                 if(mod(i, n) == 0)
105                 {
106                         me.TR(me);
107                         me.TDempty(me, 0.2);
108                 }
109                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, MapInfo_Type_ToText(GameType_GetID(i))));
110                         me.(typeLabels[i]) = e;
111         }
112
113         me.gotoRC(me, me.rows - 2, 0);
114                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
115                         e.allowCut = 1;
116                         me.descriptionLabel = e;
117
118         me.gotoRC(me, me.rows - 1, 0);
119                 me.TDempty(me, 0.5);
120
121                 me.TD(me, 1, me.columns - 5.5, e = makeXonoticButton(_("Close"), '0 0 0'));
122                         e.onClick = Dialog_Close;
123                         e.onClickEntity = me;
124                 me.TD(me, 1, me.columns - 5.5, me.startButton = e = makeXonoticButton(ZCTX(_("MAP^Play")), '0 0 0'));
125                         me.startButton.onClick = MapList_LoadMap;
126                         me.startButton.onClickEntity = NULL; // filled later
127 }
128 #endif