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