]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc
9bc82ebc28754bb8bf5ebbb87c697a3d50b7f813
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mapinfo.qc
1 #include "dialog_multiplayer_create_mapinfo.qh"
2
3 #include "button.qh"
4 #include "image.qh"
5 #include "maplist.qh"
6 #include "textlabel.qh"
7 #include <common/mapinfo.qh>
8
9 void XonoticMapInfoDialog_loadMapInfo(entity me, int i, entity mlb)
10 {
11         me.currentMapIndex = i;
12         me.startButton.onClickEntity = mlb;
13         MapInfo_Get_ByID(i);
14
15         if(me.currentMapBSPName)
16         {
17                 strunzone(me.currentMapBSPName);
18                 strunzone(me.currentMapTitle);
19                 strunzone(me.currentMapAuthor);
20                 strunzone(me.currentMapDescription);
21                 strunzone(me.currentMapPreviewImage);
22         }
23         me.currentMapBSPName = strzone(MapInfo_Map_bspname);
24         me.currentMapTitle = strzone(strdecolorize(MapInfo_Map_title));
25         me.currentMapAuthor = strzone(strdecolorize(MapInfo_Map_author));
26         me.currentMapDescription = strzone(MapInfo_Map_description);
27         me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname));
28
29         me.frame.setText(me.frame, me.currentMapBSPName);
30         me.titleLabel.setText(me.titleLabel, me.currentMapTitle);
31         me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);
32         me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);
33         if(draw_PictureSize(me.currentMapPreviewImage) == '0 0 0')
34                 me.previewImage.src = "nopreview_map";
35         else
36                 me.previewImage.src = me.currentMapPreviewImage;
37
38         for(i = 0; i < GameType_GetCount(); ++i)
39         {
40                 entity e;
41                 e = me.(typeLabels[i]);
42                 e.disabled = !(MapInfo_Map_supportedGametypes & GameType_GetID(i));
43         }
44
45         MapInfo_ClearTemps();
46 }
47 void XonoticMapInfoDialog_fill(entity me)
48 {
49         entity e;
50         int i;
51         float w, wgt, n;
52         me.TR(me);
53                 me.TDempty(me, 0.2);
54                 me.TD(me, me.rows - 2, 3, e = makeXonoticImage(string_null, 4.0/3.0));
55                 me.previewImage = e;
56         me.gotoRC(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
57         w = me.columns - me.currentColumn;
58                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Title:")));
59                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
60                         e.colorL = SKINCOLOR_MAPLIST_TITLE;
61                         e.allowCut = 1;
62                         me.titleLabel = e;
63         me.TR(me);
64                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Author:")));
65                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
66                         e.colorL = SKINCOLOR_MAPLIST_AUTHOR;
67                         e.allowCut = 1;
68                         me.authorLabel = e;
69         me.TR(me);
70                 me.TD(me, 1, w, e = makeXonoticTextLabel(0, _("Game types:")));
71
72         n = ceil(GameType_GetCount() / (me.rows - 6));
73         wgt = (w - 0.2) / n;
74         for(i = 0; i < GameType_GetCount(); ++i)
75         {
76                 if(mod(i, n) == 0)
77                 {
78                         me.TR(me);
79                         me.TDempty(me, 0.2);
80                 }
81                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, MapInfo_Type_ToText(GameType_GetID(i))));
82                         me.(typeLabels[i]) = e;
83         }
84
85         me.gotoRC(me, me.rows - 2, 0);
86                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
87                         e.allowCut = 1;
88                         me.descriptionLabel = e;
89
90         me.gotoRC(me, me.rows - 1, 0);
91                 me.TDempty(me, 0.5);
92
93                 me.TD(me, 1, me.columns - 5.5, e = makeXonoticButton(_("Close"), '0 0 0'));
94                         e.onClick = Dialog_Close;
95                         e.onClickEntity = me;
96                 me.TD(me, 1, me.columns - 5.5, me.startButton = e = makeXonoticButton(ZCTX(_("MAP^Play")), '0 0 0'));
97                         me.startButton.onClick = MapList_LoadMap;
98                         me.startButton.onClickEntity = NULL; // filled later
99 }