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