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