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