Skip to content

Commit 3bac0c9

Browse files
committed
swars: Remade show_cryo_agent_list()
While at it, modified the way of enabling or disabling agents in the 4-team. Now clicking any agent number will set the amount of agents, they do not have to be disabled one by one.
1 parent 9f3cbde commit 3bac0c9

File tree

1 file changed

+181
-0
lines changed

1 file changed

+181
-0
lines changed

src/fecryo.c

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,12 +1200,193 @@ ubyte show_cryo_blokey(struct ScreenBox *p_box)
12001200
return 0;
12011201
}
12021202

1203+
void switch_local_player_agents(ushort plagent1, ushort plagent2)
1204+
{
1205+
PlayerInfo *p_locplayer;
1206+
uint tmp;
1207+
ushort wepfp;
1208+
TbBool plagent1_female, plagent2_female;
1209+
1210+
p_locplayer = &players[local_player_no];
1211+
1212+
tmp = cryo_agents.RandomName[plagent2];
1213+
cryo_agents.RandomName[plagent2] = cryo_agents.RandomName[plagent1];
1214+
cryo_agents.RandomName[plagent1] = tmp;
1215+
1216+
tmp = cryo_agents.Weapons[plagent2];
1217+
cryo_agents.Weapons[plagent2] = cryo_agents.Weapons[plagent1];
1218+
cryo_agents.Weapons[plagent1] = tmp;
1219+
1220+
tmp = cryo_agents.Mods[plagent2].Mods;
1221+
cryo_agents.Mods[plagent2].Mods = cryo_agents.Mods[plagent1].Mods;
1222+
cryo_agents.Mods[plagent1].Mods = tmp;
1223+
1224+
for (wepfp = 0; wepfp < 5; wepfp++)
1225+
{
1226+
tmp = cryo_agents.FourPacks[plagent2].Amount[wepfp];
1227+
cryo_agents.FourPacks[plagent2].Amount[wepfp] = cryo_agents.FourPacks[plagent1].Amount[wepfp];
1228+
cryo_agents.FourPacks[plagent1].Amount[wepfp] = tmp;
1229+
1230+
p_locplayer->FourPacks[wepfp][plagent2] = cryo_agents.FourPacks[plagent2].Amount[wepfp];
1231+
if (plagent1 < 4) {
1232+
p_locplayer->FourPacks[wepfp][plagent1] = cryo_agents.FourPacks[plagent1].Amount[wepfp];
1233+
}
1234+
}
1235+
1236+
plagent2_female = cryo_agents.Sex & (1 << plagent2);
1237+
plagent1_female = cryo_agents.Sex & (1 << plagent1);
1238+
if ((plagent2_female && !plagent1_female) || (!plagent2_female && plagent1_female))
1239+
{
1240+
if (plagent2_female)
1241+
cryo_agents.Sex |= (1 << plagent1);
1242+
else
1243+
cryo_agents.Sex &= ~(1 << plagent1);
1244+
if (plagent1_female)
1245+
cryo_agents.Sex |= (1 << plagent2);
1246+
else
1247+
cryo_agents.Sex &= ~(1 << plagent2);
1248+
}
1249+
1250+
{
1251+
p_locplayer->Weapons[plagent2] = cryo_agents.Weapons[plagent2];
1252+
p_locplayer->Mods[plagent2] = cryo_agents.Mods[plagent2];
1253+
if (plagent1 < 4) {
1254+
p_locplayer->Weapons[plagent1] = cryo_agents.Weapons[plagent1];
1255+
p_locplayer->Mods[plagent1] = cryo_agents.Mods[plagent1];
1256+
}
1257+
}
1258+
}
1259+
12031260
ubyte show_cryo_agent_list(struct ScreenTextBox *p_box)
12041261
{
1262+
#if 0
12051263
ubyte ret;
12061264
asm volatile ("call ASM_show_cryo_agent_list\n"
12071265
: "=r" (ret) : "a" (p_box));
12081266
return ret;
1267+
#endif
1268+
int tx_width, ln_height;
1269+
int lines_y1, lines_y2, shift_x;
1270+
ushort plagent1;
1271+
short i;
1272+
short pos_y;
1273+
1274+
if ((p_box->Flags & 0x8000) == 0)
1275+
{
1276+
lbDisplay.DrawFlags = 0x0004;
1277+
draw_box_purple_list(text_window_x1, text_window_y1,
1278+
text_window_x2 - text_window_x1 + 1, text_window_y2 - text_window_y1 + 1, 56);
1279+
lbDisplay.DrawFlags = 0;
1280+
my_set_text_window(p_box->X + 4, p_box->Y + 4, p_box->Width - 8, p_box->Height - 8);
1281+
lbFontPtr = med_font;
1282+
tx_width = my_string_width(gui_strings[430]);
1283+
draw_text_purple_list2(((p_box->Width - tx_width) >> 1) - 3, 2, gui_strings[430], 0);
1284+
p_box->Flags |= 0x8000;
1285+
copy_box_purple_list(p_box->X + 4, p_box->Y - 3, p_box->Width - 20, p_box->Height + 6);
1286+
}
1287+
my_set_text_window(p_box->X + 4, p_box->ScrollWindowOffset + p_box->Y + 4,
1288+
p_box->Width - 20, p_box->ScrollWindowHeight + 23);
1289+
1290+
pos_y = 3;
1291+
lbFontPtr = med_font;
1292+
lbDisplay.DrawColour = 87;
1293+
ln_height = 25;
1294+
1295+
plagent1 = p_box->TextTopLine;
1296+
while (plagent1 < p_box->Lines && pos_y + 22 < p_box->ScrollWindowHeight + 23)
1297+
{
1298+
// Check for enabling/disabling a team member
1299+
lines_y1 = p_box->Y + pos_y + 31;
1300+
lines_y2 = p_box->Y + pos_y + 53;
1301+
if (plagent1 < 4 && mouse_down_over_box_coords(p_box->X + 7, lines_y1, p_box->X + 31, lines_y2))
1302+
{
1303+
if (lbDisplay.LeftButton)
1304+
{
1305+
lbDisplay.LeftButton = 0;
1306+
1307+
if (login_control__State != 5) {
1308+
PlayerInfo *p_locplayer;
1309+
1310+
play_sample_using_heap(0, 111, 127, 64, 100, 0, 2u);
1311+
1312+
p_locplayer = &players[local_player_no];
1313+
if ((p_locplayer->MissionAgents & (1 << plagent1)) == 0) {
1314+
for (i = 0; i <= plagent1; i++)
1315+
p_locplayer->MissionAgents |= (1 << i);
1316+
} else {
1317+
for (i = plagent1; i < 4; i++)
1318+
p_locplayer->MissionAgents &= ~(1 << i);
1319+
if (p_locplayer->MissionAgents == 0)
1320+
p_locplayer->MissionAgents |= (1 << plagent1);
1321+
}
1322+
} else {
1323+
play_sample_using_heap(0, 129, 127, 64, 100, 0, 2u);
1324+
}
1325+
}
1326+
}
1327+
1328+
// Check for replacing a team member with unused agent in cryo, or reordering team members
1329+
lines_y1 = text_window_y1 + pos_y - 1;
1330+
lines_y2 = text_window_y1 + pos_y + 23;
1331+
if (mouse_down_over_box_coords(text_window_x1, lines_y1, text_window_x2, lines_y2))
1332+
{
1333+
if (lbDisplay.LeftButton)
1334+
{
1335+
lbDisplay.LeftButton = 0;
1336+
1337+
if (login_control__State != 5 && selected_agent != -1) {
1338+
play_sample_using_heap(0, 111, 127, 64, 100, 0, 2u);
1339+
1340+
switch_local_player_agents(plagent1, selected_agent);
1341+
update_flic_mods(flic_mods);
1342+
for (i = 0; i < 4; i++)
1343+
{
1344+
if (old_flic_mods[i] != flic_mods[i])
1345+
mod_draw_states[i] |= 0x08;
1346+
}
1347+
} else {
1348+
play_sample_using_heap(0, 129, 127, 64, 100, 0, 2u);
1349+
}
1350+
}
1351+
}
1352+
1353+
lbDisplay.DrawFlags = 0x0004;
1354+
draw_box_purple_list(p_box->X + 7, pos_y + p_box->Y + 31, 0x18u, 0x16u, 56);
1355+
1356+
lbDisplay.DrawFlags = 0;
1357+
if (((1 << plagent1) & players[local_player_no].MissionAgents) != 0)
1358+
lbDisplay.DrawFlags |= 0x0040;
1359+
if (plagent1 < 4)
1360+
lbDisplay.DrawFlags |= 0x8000;
1361+
1362+
{
1363+
char locstr[16];
1364+
const char *text;
1365+
1366+
sprintf(locstr, "%d", plagent1 + 1);
1367+
tx_width = LbTextStringWidth(locstr);
1368+
shift_x = (24 - tx_width) >> 1;
1369+
text = loctext_to_gtext(locstr);
1370+
draw_text_purple_list2(4 + shift_x, pos_y + 6, text, 0);
1371+
}
1372+
1373+
lbDisplay.DrawFlags |= 0x8000;
1374+
if (background_type == 1)
1375+
{
1376+
if ((cryo_agents.Sex & (1 << plagent1)) != 0)
1377+
draw_text_purple_list2(30, pos_y + 6, gui_strings[227 + cryo_agents.RandomName[plagent1]], 0);
1378+
else
1379+
draw_text_purple_list2(30, pos_y + 6, gui_strings[177 + cryo_agents.RandomName[plagent1]], 0);
1380+
}
1381+
else
1382+
{
1383+
draw_text_purple_list2(30, pos_y + 6, gui_strings[77 + cryo_agents.RandomName[plagent1]], 0);
1384+
}
1385+
lbDisplay.DrawFlags = 0;
1386+
pos_y += ln_height;
1387+
plagent1++;
1388+
}
1389+
return 0;
12091390
}
12101391

12111392
TbBool cybmod_available_for_purchase(short mtype)

0 commit comments

Comments
 (0)