void script_2059(int arg0) {
	int ivar1;
	int ivar2;
	int ivar3;
	int ivar4;
	int ivar5;
	int ivar6;
	int ivar7;
	int ivar8;
	int ivar9;
	int ivar10;
	int ivar11;
	int ivar12;
	int ivar13;
	int ivar14;
	int ivar15;
	int ivar16;
	int ivar17;
	int ivar18;
	ivar1 = -1;
	ivar2 = 0;
	if (((boolean)script_1119())) {
		ivar1 = cs2method_3408(105, 74, 728, bitconfig_357);
		ivar2 = 1;
	} else {
		ivar1 = cs2method_3408(105, 74, 2162, bitconfig_357);
	}
	ivar3 = 0;
	globalarray_0 = new int[4];
	switch (bitconfig_357) {
		case 0:
			ivar3 = bitconfig_5822;
			globalarray_0[0] = bitconfig_6459;
			globalarray_0[1] = bitconfig_6460;
			globalarray_0[2] = bitconfig_6461;
			globalarray_0[3] = bitconfig_6462;
			break;
		case 1:
			ivar3 = bitconfig_5823;
			globalarray_0[0] = bitconfig_6466;
			globalarray_0[1] = 0;
			globalarray_0[2] = 0;
			globalarray_0[3] = bitconfig_6467;
			break;
		case 2:
			ivar3 = bitconfig_5824;
			globalarray_0[0] = bitconfig_6463;
			globalarray_0[1] = 0;
			globalarray_0[2] = bitconfig_6464;
			globalarray_0[3] = bitconfig_6465;
			break;
		case 3:
			ivar3 = bitconfig_7347;
			globalarray_0[0] = bitconfig_7348;
			globalarray_0[1] = bitconfig_7349;
			globalarray_0[2] = bitconfig_7350;
			globalarray_0[3] = bitconfig_7351;
	}
	if (arg0 != -1) {
		if (ivar3 != arg0) {
			playSoundEffect(5845, 1, 0);
		}
		ivar3 = arg0;
	}
	globalint_631 = ivar3;
	ivar4 = cs2method_3408(105, 103, getOtherCommonData(ivar1, 662), ivar3);
	ivar5 = getOtherCommonData(ivar1, 654);
	ivar6 = getOtherCommonData(ivar1, 655);
	ivar7 = getCommonDefinitionSize(ivar4);
	ivar8 = 0;
	ivar9 = 0;
	ivar10 = -1;
	ivar11 = 0;
	ivar12 = 0;
	ivar13 = 0;
	ivar14 = -1;
	ivar15 = -1;
	ivar16 = -1;
	while (ivar9 < ivar7) {
		ivar10 = cs2method_3408(105, 103, ivar4, ivar9);
		if (ivar10 != -1) {
			ivar8 = getCommonDefinitionSize(ivar10);
			ivar11 = 0;
			ivar13 = 0;
			while (ivar11 < ivar8) {
				ivar14 = ((int)cs2method_3408(105, 73, ivar10, ivar13));
				if (ivar14 != -1) {
					ivar11 = add(ivar11, 1);
					ivar15 = cs2method_3408(73, 105, 727, ivar14);
					if (((ivar15 == -1) || ((boolean)globalarray_0[ivar15])) && (isMember() || ((boolean)cs2method_3408(73, 105, 743, ivar14)))) {
						ivar12 = add(ivar12, 1);
						setWidgetPosition(ivar6, ivar5, 0, 0, new WidgetPointer(ivar14));
						setWidgetIsHidden(false, new WidgetPointer(ivar14));
						ivar6 = add(ivar6, add(getOtherCommonData(ivar1, 657), getOtherCommonData(ivar1, 658)));
						if (((boolean)mod(ivar12, getOtherCommonData(ivar1, 660)))) {
							ivar5 = add(ivar5, add(getOtherCommonData(ivar1, 656), getOtherCommonData(ivar1, 659)));
							ivar6 = getOtherCommonData(ivar1, 655);
						}
						ivar16 = cs2method_3408(73, 64, 209, ivar14);
						if (ivar16 != -1) {
							cs2method2308(ivar16, 36, new WidgetPointer(ivar14));
						}
					} else {
						setWidgetIsHidden(true, new WidgetPointer(ivar14));
					}
				}
				ivar13 = add(ivar13, 1);
				if (ivar13 > 997) {
					return;
				}
			}
		}
		ivar9 = add(ivar9, 1);
	}
	if (((boolean)ivar2)) {
		setWidgetScrollMax(getWidgetActualWidth(new WidgetPointer(getOtherCommonData(ivar1, 316))), add(add(ivar5, getOtherCommonData(ivar1, 656)), getOtherCommonData(ivar1, 654)), new WidgetPointer(getOtherCommonData(ivar1, 316)));
		script_31(getOtherCommonData(ivar1, 684), getOtherCommonData(ivar1, 316), 792, 789, 790, 791, 773, 788);
	} else {
		if (setWidgetRegister(new WidgetPointer(getOtherCommonData(ivar1, 316)))) {
			cs2method1100(0, 0);
			deleteAllExtraChilds(new WidgetPointer(getOtherCommonData(ivar1, 684)));
		}
	}
	ivar17 = getOtherCommonData(ivar1, 663);
	ivar18 = 0;
	if (ivar17 != -1) {
		ivar18 = getCommonDefinitionSize(ivar17);
		ivar13 = 0;
		while (ivar13 < ivar18) {
			if (ivar13 == ivar3) {
				setWidgetSprite(1703, cs2method_3408(105, 73, ivar17, ivar13));
			} else {
				setWidgetSprite(1701, cs2method_3408(105, 73, ivar17, ivar13));
			}
			ivar13 = add(ivar13, 1);
		}
	}
	script_1121();
	deleteAllExtraChilds(new WidgetPointer(getOtherCommonData(ivar1, 688)));
	return;
}
