]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc
Sort menu classes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create_mapinfo.qc
1 #ifndef DIALOG_MULTIPLAYER_CREATE_MAPINFO_H
2 #define DIALOG_MULTIPLAYER_CREATE_MAPINFO_H
3 CLASS(XonoticMapInfoDialog, XonoticDialog)
4         METHOD(XonoticMapInfoDialog, fill, void(entity))
5         METHOD(XonoticMapInfoDialog, loadMapInfo, void(entity, float, entity))
6         ATTRIB(XonoticMapInfoDialog, title, string, _("Map Information"))
7         ATTRIB(XonoticMapInfoDialog, color, vector, SKINCOLOR_DIALOG_MAPINFO)
8         ATTRIB(XonoticMapInfoDialog, intendedWidth, float, 1.0)
9         ATTRIB(XonoticMapInfoDialog, rows, float, 11)
10         ATTRIB(XonoticMapInfoDialog, columns, float, 10)
11
12         ATTRIB(XonoticMapInfoDialog, previewImage, entity, NULL)
13         ATTRIB(XonoticMapInfoDialog, titleLabel, entity, NULL)
14         ATTRIB(XonoticMapInfoDialog, authorLabel, entity, NULL)
15         ATTRIB(XonoticMapInfoDialog, descriptionLabel, entity, NULL)
16         ATTRIB(XonoticMapInfoDialog, featuresLabel, entity, NULL)
17
18         ATTRIBARRAY(XonoticMapInfoDialog, typeLabels, entity, 24)
19
20         ATTRIB(XonoticMapInfoDialog, currentMapIndex, float, 0)
21         ATTRIB(XonoticMapInfoDialog, currentMapBSPName, string, string_null)
22         ATTRIB(XonoticMapInfoDialog, currentMapTitle, string, string_null)
23         ATTRIB(XonoticMapInfoDialog, currentMapAuthor, string, string_null)
24         ATTRIB(XonoticMapInfoDialog, currentMapDescription, string, string_null)
25         ATTRIB(XonoticMapInfoDialog, currentMapPreviewImage, string, string_null)
26 ENDCLASS(XonoticMapInfoDialog)
27 #endif
28
29 #ifdef IMPLEMENTATION
30 void XonoticMapInfoDialog_loadMapInfo(entity me, int 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         }
44         me.currentMapBSPName = strzone(MapInfo_Map_bspname);
45         me.currentMapTitle = strzone(strdecolorize(MapInfo_Map_title));
46         me.currentMapAuthor = strzone(strdecolorize(MapInfo_Map_author));
47         me.currentMapDescription = strzone(MapInfo_Map_description);
48         me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname));
49
50         me.frame.setText(me.frame, me.currentMapBSPName);
51         me.titleLabel.setText(me.titleLabel, me.currentMapTitle);
52         me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);
53         me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);
54         if(draw_PictureSize(me.currentMapPreviewImage) == '0 0 0')
55                 me.previewImage.src = "nopreview_map";
56         else
57                 me.previewImage.src = me.currentMapPreviewImage;
58
59         for(i = 0; i < GameType_GetCount(); ++i)
60         {
61                 entity e;
62                 e = me.(typeLabels[i]);
63                 e.disabled = !(MapInfo_Map_supportedGametypes & GameType_GetID(i));
64         }
65
66         MapInfo_ClearTemps();
67 }
68 void XonoticMapInfoDialog_fill(entity me)
69 {
70         entity e;
71         int i;
72         float w, wgt, n;
73         me.TR(me);
74                 me.TDempty(me, 0.2);
75                 me.TD(me, me.rows - 2, 3, e = makeXonoticImage(string_null, 4.0/3.0));
76                 me.previewImage = e;
77         me.gotoRC(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
78         w = me.columns - me.currentColumn;
79                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Title:")));
80                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
81                         e.colorL = SKINCOLOR_MAPLIST_TITLE;
82                         e.allowCut = 1;
83                         me.titleLabel = e;
84         me.TR(me);
85                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Author:")));
86                 me.TD(me, 1, w-1, e = makeXonoticTextLabel(0, ""));
87                         e.colorL = SKINCOLOR_MAPLIST_AUTHOR;
88                         e.allowCut = 1;
89                         me.authorLabel = e;
90         me.TR(me);
91                 me.TD(me, 1, w, e = makeXonoticTextLabel(0, _("Game types:")));
92
93         n = ceil(GameType_GetCount() / (me.rows - 6));
94         wgt = (w - 0.2) / n;
95         for(i = 0; i < GameType_GetCount(); ++i)
96         {
97                 if(mod(i, n) == 0)
98                 {
99                         me.TR(me);
100                         me.TDempty(me, 0.2);
101                 }
102                 me.TD(me, 1, wgt, e = makeXonoticTextLabel(0, MapInfo_Type_ToText(GameType_GetID(i))));
103                         me.(typeLabels[i]) = e;
104         }
105
106         me.gotoRC(me, me.rows - 2, 0);
107                 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
108                         e.allowCut = 1;
109                         me.descriptionLabel = e;
110
111         me.gotoRC(me, me.rows - 1, 0);
112                 me.TDempty(me, 0.5);
113
114                 me.TD(me, 1, me.columns - 5.5, e = makeXonoticButton(_("Close"), '0 0 0'));
115                         e.onClick = Dialog_Close;
116                         e.onClickEntity = me;
117                 me.TD(me, 1, me.columns - 5.5, me.startButton = e = makeXonoticButton(ZCTX(_("MAP^Play")), '0 0 0'));
118                         me.startButton.onClick = MapList_LoadMap;
119                         me.startButton.onClickEntity = NULL; // filled later
120 }
121 #endif