]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/dialog_multiplayer_create_mapinfo.c
fix divisions by zero
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / nexuiz / dialog_multiplayer_create_mapinfo.c
1 #ifdef INTERFACE
2 CLASS(NexuizMapInfoDialog) EXTENDS(NexuizDialog)
3         METHOD(NexuizMapInfoDialog, fill, void(entity))
4         METHOD(NexuizMapInfoDialog, loadMapInfo, void(entity, float))
5         ATTRIB(NexuizMapInfoDialog, title, string, "Map Information")
6         ATTRIB(NexuizMapInfoDialog, color, vector, SKINCOLOR_DIALOG_MAPINFO)
7         ATTRIB(NexuizMapInfoDialog, intendedWidth, float, 0.75)
8         ATTRIB(NexuizMapInfoDialog, rows, float, 9)
9         ATTRIB(NexuizMapInfoDialog, columns, float, 9)
10
11         ATTRIB(NexuizMapInfoDialog, previewImage, entity, NULL)
12         ATTRIB(NexuizMapInfoDialog, titleLabel, entity, NULL)
13         ATTRIB(NexuizMapInfoDialog, authorLabel, entity, NULL)
14         ATTRIB(NexuizMapInfoDialog, descriptionLabel, entity, NULL)
15         ATTRIB(NexuizMapInfoDialog, featuresLabel, entity, NULL)
16
17         ATTRIB(NexuizMapInfoDialog, typeDeathmatchLabel, entity, NULL)
18         ATTRIB(NexuizMapInfoDialog, typeTDMLabel, entity, NULL)
19         ATTRIB(NexuizMapInfoDialog, typeLMSLabel, entity, NULL)
20         ATTRIB(NexuizMapInfoDialog, typeArenaLabel, entity, NULL)
21         ATTRIB(NexuizMapInfoDialog, typeRuneLabel, entity, NULL)
22         ATTRIB(NexuizMapInfoDialog, typeDominationLabel, entity, NULL)
23         ATTRIB(NexuizMapInfoDialog, typeKeyHuntLabel, entity, NULL)
24         ATTRIB(NexuizMapInfoDialog, typeCTFLabel, entity, NULL)
25         ATTRIB(NexuizMapInfoDialog, typeAssaultLabel, entity, NULL)
26         ATTRIB(NexuizMapInfoDialog, typeOnslaughtLabel, entity, NULL)
27
28         ATTRIB(NexuizMapInfoDialog, currentMapIndex, float, 0)
29         ATTRIB(NexuizMapInfoDialog, currentMapBSPName, string, string_null)
30         ATTRIB(NexuizMapInfoDialog, currentMapTitle, string, string_null)
31         ATTRIB(NexuizMapInfoDialog, currentMapAuthor, string, string_null)
32         ATTRIB(NexuizMapInfoDialog, currentMapDescription, string, string_null)
33         ATTRIB(NexuizMapInfoDialog, currentMapPreviewImage, string, string_null)
34         ATTRIB(NexuizMapInfoDialog, currentMapFeaturesText, string, string_null)
35 ENDCLASS(NexuizMapInfoDialog)
36 #endif
37
38 #ifdef IMPLEMENTATION
39 void loadMapInfoNexuizMapInfoDialog(entity me, float i)
40 {
41         me.currentMapIndex = i;
42         MapInfo_Get_ByID(i);
43
44         if(me.currentMapBSPName)
45         {
46                 strunzone(me.currentMapBSPName);
47                 strunzone(me.currentMapTitle);
48                 strunzone(me.currentMapAuthor);
49                 strunzone(me.currentMapDescription);
50                 strunzone(me.currentMapPreviewImage);
51                 strunzone(me.currentMapFeaturesText);
52         }
53         me.currentMapBSPName = strzone(MapInfo_Map_bspname);
54         me.currentMapTitle = strzone(MapInfo_Map_title);
55         me.currentMapAuthor = strzone(MapInfo_Map_author);
56         me.currentMapDescription = strzone(MapInfo_Map_description);
57         me.currentMapFeaturesText = strzone((MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) ? "Full item placement" : "MinstaGib only");
58         me.currentMapPreviewImage = strzone(strcat("/maps/", MapInfo_Map_bspname));
59
60         me.frame.setText(me.frame, me.currentMapBSPName);
61         me.titleLabel.setText(me.titleLabel, me.currentMapTitle);
62         me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);
63         me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);
64         me.featuresLabel.setText(me.featuresLabel, me.currentMapFeaturesText);
65         me.previewImage.src = me.currentMapPreviewImage;
66
67         me.typeDeathmatchLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH);
68         me.typeTDMLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH);
69         me.typeLMSLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_LMS);
70         me.typeArenaLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ARENA);
71         me.typeRuneLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RUNEMATCH);
72         me.typeKeyHuntLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_KEYHUNT);
73         me.typeCTFLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_CTF);
74         if(me.typeAssaultLabel)
75                 me.typeAssaultLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT);
76         if(me.typeOnslaughtLabel)
77                 me.typeOnslaughtLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ONSLAUGHT);
78 }
79 void fillNexuizMapInfoDialog(entity me)
80 {
81         entity e;
82         me.TR(me);
83                 me.TD(me, me.rows - 2, 3, e = makeNexuizImage(string_null, 4.0/3.0));
84                 me.previewImage = e;
85         me.gotoXY(me, 0, 3.5); me.setFirstColumn(me, me.currentColumn);
86                 me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Title:"));
87                 me.TD(me, 1, 4.5, e = makeNexuizTextLabel(0, ""));
88                         e.alpha = 1;
89                         e.colorL = SKINCOLOR_MAPLIST_TITLE;
90                         e.allowCut = 1;
91                         me.titleLabel = e;
92         me.TR(me);
93                 me.TD(me, 1, 1, e = makeNexuizTextLabel(0, "Author:"));
94                 me.TD(me, 1, 4.5, e = makeNexuizTextLabel(0, ""));
95                         e.alpha = 1;
96                         e.colorL = SKINCOLOR_MAPLIST_AUTHOR;
97                         e.allowCut = 1;
98                         me.authorLabel = e;
99         me.TR(me);
100                 me.TD(me, 1, 5.5, e = makeNexuizTextLabel(0, ""));
101                         e.allowCut = 1;
102                         me.featuresLabel = e;
103         me.TR(me);
104                 me.TD(me, 1, 5.5, e = makeNexuizTextLabel(0, "Game types:"));
105         me.TR(me);
106                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Deathmatch"));
107                         me.typeDeathmatchLabel = e;
108                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "TDM"));
109                         me.typeTDMLabel = e;
110                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "LMS"));
111                         me.typeLMSLabel = e;
112                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Arena"));
113                         me.typeArenaLabel = e;
114         me.TR(me);
115                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Rune"));
116                         me.typeRuneLabel = e;
117                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Domination"));
118                         me.typeDominationLabel = e;
119                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Key Hunt"));
120                         me.typeKeyHuntLabel = e;
121                 me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "CTF"));
122                         me.typeCTFLabel = e;
123         me.TR(me);
124                 if(cvar("developer"))
125                 {
126                         me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Assault"));
127                                 me.typeAssaultLabel = e;
128                         me.TD(me, 1, 5.5/4, e = makeNexuizTextLabel(0, "Onslaught"));
129                                 me.typeOnslaughtLabel = e;
130                 }
131
132         me.gotoXY(me, me.rows - 2, 0);
133                 me.TD(me, 1, me.columns, e = makeNexuizTextLabel(0.5, ""));
134                         e.allowCut = 1;
135                         me.descriptionLabel = e;
136
137         me.gotoXY(me, me.rows - 1, 0);
138                 me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0'));
139                         e.onClick = Dialog_Close;
140                         e.onClickEntity = me;
141 }
142 #endif