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