Exemplo n.º 1
0
void cScreenMovieMaker::init()
{
	g_CurrentScreen = SCREEN_CREATEMOVIE;
	if(!g_InitWin)
		return;

	Focused();
	g_InitWin = false;
	
	// clear the lists
	ClearListBox(sceneslist_id);

	//get a list of all the column names, so we can find which data goes in that column
	vector<string> columnNames;
	m_ListBoxes[sceneslist_id]->GetColumnNames(columnNames);
	int numColumns = columnNames.size();
	string* Data = new string[numColumns];

	// Add scene to list
	for(int i=0; i<g_Studios.GetNumScenes(); i++)
	{
		sMovieScene* scene = g_Studios.GetScene(i);
		//if (selected_girl == gir)
		//	selection = i;
		unsigned int item_color = COLOR_BLUE;

		scene->OutputSceneRow(Data, columnNames);
		AddToListBox(sceneslist_id, i, Data, numColumns, item_color);
	}
	delete [] Data;
	
	lastNum = -1;
	g_InitWin = false;
}
void cScreenCentreManagement::RefreshJobList()
{
	ClearListBox(joblist_id);
	int job_filter = GetSelectedItemFromList(jobtypelist_id);

	if (job_filter == -1)
		return;

	string text = "";

	// populate Jobs listbox with jobs in the selected category
	for (unsigned int i = g_Centre.m_JobManager.JobFilterIndex[job_filter]; i < g_Centre.m_JobManager.JobFilterIndex[job_filter + 1]; i++)
	{
		if (g_Centre.m_JobManager.JobName[i] == "")
			continue;
		text = g_Centre.m_JobManager.JobDescriptionCount(i, g_CurrCentre, Day0Night1, false, false, false, true);
		AddToListBox(joblist_id, i, text);
	}

	if (selected_girl && selected_girl->m_YesterDayJob == JOB_REHAB && selected_girl->m_DayJob != JOB_REHAB && (selected_girl->m_WorkingDay > 0 || selected_girl->m_PrevWorkingDay > 0))
	{	// `J` added
		int sel_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
		SetSelectedItemInList(joblist_id, sel_job, false);
		EditTextItem(g_Centre.m_JobManager.JobDesc[sel_job]
			+ "\n** This girl was in Rehab, if you send her somewhere else, she will have to start her Rehab over."
			, jobdesc_id);
	}
	else if (selected_girl)
	{
		int sel_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
		SetSelectedItemInList(joblist_id, sel_job, false);
		EditTextItem(g_Centre.m_JobManager.JobDesc[sel_job], jobdesc_id);
	}
}
void cScreenGirlDetails::RefreshJobList()
{
	ClearListBox(joblist_id);
	int job_filter = GetSelectedItemFromList(jobtypelist_id);
	if (job_filter == -1) return;

	string text = "";
	// populate Jobs listbox with jobs in the selected category
	for (unsigned int i = g_Brothels.m_JobManager.JobFilterIndex[job_filter]; i<g_Brothels.m_JobManager.JobFilterIndex[job_filter + 1]; i++)
	{
		if (g_Brothels.m_JobManager.JobName[i] == "")
			continue;
		text = g_Brothels.m_JobManager.JobDescriptionCount(i, g_CurrBrothel, Day0Night1, selected_girl->m_InClinic, selected_girl->m_InStudio, selected_girl->m_InArena, selected_girl->m_InCentre, selected_girl->m_InHouse, selected_girl->m_InFarm);

		AddToListBox(joblist_id, i, text);
	}
	if (selected_girl)
	{
		int sel_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
		SetSelectedItemInList(joblist_id, sel_job, false);
	}
}
void cScreenGirlDetails::init()
{
	if (selected_girl == 0)
	{
		g_WinManager.Pop();
		g_InitWin = true;
		g_LogFile.write("ERROR - girl details screen, selected_girl is null");
		/*
		*		adding this because the game will crash if we
		*		go past this point with a null girl
		*
		*		Now as to why it was null in the first place ...
		*		-- doc
		*/
		return;
	}

	g_CurrentScreen = SCREEN_GIRLDETAILS;
	if (!g_InitWin) return;

	Focused();
	g_InitWin = false;

	////////////////////
	if (selected_girl->health() <= 0)
	{
		// `J` instead of removing dead girls from the list which breaks the game, just skip past her in the list.
		NextGirl();								// `J` currently this prevents scrolling backwards past her - need to fix that.
//		selected_girl = remove_selected_girl();
		if (selected_girl == 0)
		{
			g_WinManager.Pop();
			g_InitWin = true;
			return;
		}
	}

	u_int job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
	SetJob = true;

	EditTextItem(selected_girl->m_Realname, girlname_id);

	string detail;
	if (DetailLevel == 0)		detail = g_Girls.GetDetailsString(selected_girl);
	else if (DetailLevel == 1)	detail = g_Girls.GetMoreDetailsString(selected_girl);
	else						detail = g_Girls.GetThirdDetailsString(selected_girl);
	EditTextItem(detail, girldesc_id);

	if (selected_girl)
	{
		if (lastsexact != -1)
		{
			PrepareImage(girlimage_id, selected_girl, lastsexact, true, ImageNum);
			lastsexact = -1;
		}
		else
		{
			if (selected_girl->m_newRandomFixed >= 0)
			{
				PrepareImage(girlimage_id, selected_girl, IMGTYPE_PROFILE, false, selected_girl->m_newRandomFixed);
			}
			else
			{
				PrepareImage(girlimage_id, selected_girl, IMGTYPE_PROFILE, true, ImageNum);
			}
		}
	}

	SliderRange(houseperc_id, 0, 100, g_Girls.GetStat(selected_girl, STAT_HOUSE), 10);
	ss.str("");
	ss << gettext("House Percentage: ") << SliderValue(houseperc_id) << gettext("%");
	EditTextItem(ss.str(), housepercval_id);

	ClearListBox(jobtypelist_id);

	// `J` Replacing accom buttons with slider
	if (accomdown_id != -1)	DisableButton(accomdown_id, selected_girl->m_AccLevel < 1);
	if (accomup_id != -1)	DisableButton(accomup_id, selected_girl->m_AccLevel > 9);
	if (accom_id != -1)
	{
		SliderRange(accom_id, 0, 9, selected_girl->m_AccLevel, 1);
		SliderMarker(accom_id, g_Girls.PreferredAccom(selected_girl));
	}
	if (accomval_id != -1)
	{
		stringstream acc;
		acc << "Accommodation: " << g_Girls.Accommodation(SliderValue(accom_id));
		if (cfg.debug.log_extradetails())
		{
			int val = SliderValue(accom_id) - g_Girls.PreferredAccom(selected_girl);
			if (val != 0) acc << "  ( " << (val > 0 ? "+" : "") << val << " )";
		}
		EditTextItem(acc.str(), accomval_id);
	}
	DisableButton(interact_id, (g_TalkCount <= 0));
	DisableButton(takegold_id, (selected_girl->m_Money <= 0));
	SetCheckBox(antipreg_id, (selected_girl->m_UseAntiPreg));

	bool InMovieStudio = (selected_girl->m_InStudio);
	bool InArena = (selected_girl->m_InArena);
	bool InCentre = (selected_girl->m_InCentre);
	bool InClinic = (selected_girl->m_InClinic);
	bool InHouse = (selected_girl->m_InHouse);
	bool InFarm = (selected_girl->m_InFarm);
	bool InDungeon = (selected_girl->m_DayJob == JOB_INDUNGEON);
	DisableButton(reldungeon_id, !InDungeon);
	DisableButton(senddungeon_id, InDungeon);

	// Disable dungeon if selected girl is in a non-brothel building
//	if (InMovieStudio || InArena || InCentre || InClinic || InFarm || InHouse) 
//	{
//		DisableButton(senddungeon_id, true);
//	}

	if (InArena)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_ARENASTAFF, g_Arena.m_JobManager.JobFilterName[JOBFILTER_ARENASTAFF]);
		AddToListBox(jobtypelist_id, JOBFILTER_ARENA, g_Arena.m_JobManager.JobFilterName[JOBFILTER_ARENA]);
		RefreshJobList();
		if (job >= g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENA] && job < g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENA + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_ARENA);
		else // if (job >= g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENASTAFF] && job < g_Arena.m_JobManager.JobFilterIndex[JOBFILTER_ARENASTAFF + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_ARENASTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InClinic)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_CLINIC, g_Clinic.m_JobManager.JobFilterName[JOBFILTER_CLINIC]);
		AddToListBox(jobtypelist_id, JOBFILTER_CLINICSTAFF, g_Clinic.m_JobManager.JobFilterName[JOBFILTER_CLINICSTAFF]);
		RefreshJobList();
		if (job >= g_Clinic.m_JobManager.JobFilterIndex[JOBFILTER_CLINIC] && job < g_Clinic.m_JobManager.JobFilterIndex[JOBFILTER_CLINIC + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_CLINIC);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_CLINICSTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InCentre)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COMMUNITYCENTRE]);
		AddToListBox(jobtypelist_id, JOBFILTER_COUNSELINGCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COUNSELINGCENTRE]);
		RefreshJobList();
		if (job >= g_Centre.m_JobManager.JobFilterIndex[JOBFILTER_COUNSELINGCENTRE] && job < g_Centre.m_JobManager.JobFilterIndex[JOBFILTER_COUNSELINGCENTRE + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_COUNSELINGCENTRE);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InHouse)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_HOUSE, g_House.m_JobManager.JobFilterName[JOBFILTER_HOUSE]);
		SetSelectedItemInList(jobtypelist_id, JOBFILTER_HOUSE);
		RefreshJobList();
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else if (InMovieStudio)
	{
		Day0Night1 = SHIFT_NIGHT;
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_STUDIOCREW, g_Studios.m_JobManager.JobFilterName[JOBFILTER_STUDIOCREW]);
		AddToListBox(jobtypelist_id, JOBFILTER_MOVIESTUDIO, g_Studios.m_JobManager.JobFilterName[JOBFILTER_MOVIESTUDIO]);
		RefreshJobList();
		if (job >= g_Studios.m_JobManager.JobFilterIndex[JOBFILTER_MOVIESTUDIO] && job < g_Studios.m_JobManager.JobFilterIndex[JOBFILTER_MOVIESTUDIO + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_MOVIESTUDIO);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_STUDIOCREW);
		HideButton(day_id, true);
		HideButton(night_id, true);

	}
	else if (InFarm)
	{
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, JOBFILTER_FARMSTAFF, g_Farm.m_JobManager.JobFilterName[JOBFILTER_FARMSTAFF]);
		AddToListBox(jobtypelist_id, JOBFILTER_LABORERS, g_Farm.m_JobManager.JobFilterName[JOBFILTER_LABORERS]);
		AddToListBox(jobtypelist_id, JOBFILTER_PRODUCERS, g_Farm.m_JobManager.JobFilterName[JOBFILTER_PRODUCERS]);
		RefreshJobList();
		if (job >= g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_LABORERS] && job < g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_LABORERS + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_LABORERS);
		else if (job >= g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_PRODUCERS] && job < g_Farm.m_JobManager.JobFilterIndex[JOBFILTER_PRODUCERS + 1])
			SetSelectedItemInList(jobtypelist_id, JOBFILTER_PRODUCERS);
		else SetSelectedItemInList(jobtypelist_id, JOBFILTER_FARMSTAFF);
		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));

	}
	else if (!InDungeon)
	{  // if not in dungeon, set up job lists
		// add the job filters
		//	for(int i=0; i<NUMJOBTYPES; i++)  // loop through all job types
		for (unsigned int i = 0; i <= JOBFILTER_BROTHEL; i++)  // temporary limit to job types shown
		{
			AddToListBox(jobtypelist_id, i, g_Brothels.m_JobManager.JobFilterName[i]);
		}

		// set the job filter
		int jobtype = 0;
		for (unsigned int i = 0; i < NUMJOBTYPES; i++)
		{
			if (job >= g_Brothels.m_JobManager.JobFilterIndex[i] && job < g_Brothels.m_JobManager.JobFilterIndex[i + 1])
			{
				jobtype = i;
				break;
			}
		}
		SetSelectedItemInList(jobtypelist_id, jobtype);
		RefreshJobList();

		HideButton(day_id, false);
		HideButton(night_id, false);
		DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
		DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));
	}
	else
	{  // if in dungeon, effectively disable job lists
		ClearListBox(joblist_id);
		AddToListBox(jobtypelist_id, -1, gettext("Languish in dungeon"));
		HideButton(day_id, true);
		HideButton(night_id, true);
	}

	ClearListBox(traitlist_id);
	for (int i = 0; i < MAXNUM_TRAITS; i++)
	{
		if (selected_girl->m_Traits[i])
		{
			stringstream st;
			st << selected_girl->m_Traits[i]->m_Name;
			if (selected_girl->m_TempTrait[i] > 0) st << "   (" << selected_girl->m_TempTrait[i] << ")";
			AddToListBox(traitlist_id, i, g_Traits.GetTranslateName(st.str()));
		}
	}
	EditTextItem("", traitdesc_id);
}
Exemplo n.º 5
0
void cScreenGangs::init()
{
	g_CurrentScreen = SCREEN_GANGMANAGEMENT;
	if (!g_InitWin) return;
	Focused();
	g_InitWin = false;

	selection = GetLastSelectedItemFromList(ganglist_id);
	sel_recruit = GetLastSelectedItemFromList(recruitlist_id);

	ClearListBox(missionlist_id);
	AddToListBox(missionlist_id, 0, "GUARDING");
	AddToListBox(missionlist_id, 1, "SABOTAGE");
	AddToListBox(missionlist_id, 2, "SPY ON GIRLS");
	AddToListBox(missionlist_id, 3, "RECAPTURE");
	AddToListBox(missionlist_id, 4, "ACQUIRE TERRITORY");
	AddToListBox(missionlist_id, 5, "PETTY THEFT");
	AddToListBox(missionlist_id, 6, "GRAND THEFT");
	AddToListBox(missionlist_id, 7, "KIDNAPPING");
	AddToListBox(missionlist_id, 8, "CATACOMBS");
	AddToListBox(missionlist_id, 9, "TRAINING");
	AddToListBox(missionlist_id, 10, "RECRUITING");
	AddToListBox(missionlist_id, 11, "SERVICE");

	SetCheckBox(controlcatacombs_id, (g_Gangs.Control_Gangs()));
	SliderRange(girlspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls(), 1);
	SliderRange(itemspercslider_id, 0, 100, g_Gangs.Gang_Gets_Girls() + g_Gangs.Gang_Gets_Items(), 1);
	ss.str("");	ss << "Girls : " << g_Gangs.Gang_Gets_Girls() << "%";	EditTextItem(ss.str(), ganggetsgirls_id);
	ss.str("");	ss << "Items : " << g_Gangs.Gang_Gets_Items() << "%";	EditTextItem(ss.str(), ganggetsitems_id);
	ss.str("");	ss << "Beasts : " << g_Gangs.Gang_Gets_Beast() << "%";	EditTextItem(ss.str(), ganggetsbeast_id);

	SetCheckBox(netautobuy_id, (g_Gangs.GetNetRestock() > 0));
	SetCheckBox(healautobuy_id, (g_Gangs.GetHealingRestock() > 0));

	// weapon upgrades
	int *wlev = g_Gangs.GetWeaponLevel();
	ss.str("");	ss << "Weapon Level: " << *wlev;
	if ((*wlev) < 4)
	{
		EnableButton(weaponup_id);
		ss << " Next: " << tariff.goon_weapon_upgrade(*wlev) << "g";
	}
	else DisableButton(weaponup_id);
	g_LogFile.ss() << "weapon text = '" << ss.str() << "'" << endl; g_LogFile.ssend();
	EditTextItem(ss.str(), weaponlevel_id);

	int *nets = g_Gangs.GetNets();
	ss.str(""); ss << "Nets (" << tariff.nets_price(1) << "g each): " << *nets;
	EditTextItem(ss.str(), netdesc_id);
	DisableButton(netbuy_id, *nets >= 60);
	DisableButton(netbuy10_id, *nets >= 60);
	DisableButton(netbuy20_id, *nets >= 60);
	DisableCheckBox(netautobuy_id, *nets < 1);

	int *potions = g_Gangs.GetHealingPotions();
	ss.str(""); ss << "Heal Potions (" << tariff.healing_price(1) << "g each): " << *potions;
	EditTextItem(ss.str(), healdesc_id);
	DisableButton(healbuy_id, *potions >= 200);
	DisableButton(healbuy10_id, *potions >= 200);
	DisableButton(healbuy20_id, *potions >= 200);
	DisableCheckBox(healautobuy_id, *potions < 1);

	int cost = 0;
	if (g_Gangs.GetNumGangs() > 0)
	{
		for (int i = 0; i < g_Gangs.GetNumGangs(); i++)
		{
			sGang* g = g_Gangs.GetGang(i);
			if (g == 0) g = g_Gangs.GetGang(i - 1);
			cost += tariff.goon_mission_cost(g->m_MissionID);
		}
	}
	ss.str(""); ss << "Weekly Cost: " << cost;
	EditTextItem(ss.str(), totalcost_id);
	if (gold_id >= 0)
	{
		ss.str(""); ss << "Gold: " << g_Gold.ival();
		EditTextItem(ss.str(), gold_id);
	}

	ClearListBox(ganglist_id);
	int num = 0;
	sGang* current = g_Gangs.GetGang(0);

	// loop through the gangs, populating the list box
	g_LogFile.write("Setting gang mission descriptions\n");
	for (current = g_Gangs.GetGang(0); current; current = current->m_Next)
	{
		// format the string with the gang name, mission and number of men
		string Data[11];
		ss.str("");	ss << current->m_Name;								Data[0] = ss.str();
		ss.str("");	ss << current->m_Num;								Data[1] = ss.str();
		ss.str("");	ss << short_mission_desc(current->m_MissionID);		Data[2] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_COMBAT] << "%";		Data[3] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_MAGIC] << "%";		Data[4] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_INTELLIGENCE] << "%";	Data[5] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_AGILITY] << "%";		Data[6] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CONSTITUTION] << "%";	Data[7] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CHARISMA] << "%";		Data[8] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_STRENGTH] << "%";		Data[9] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_SERVICE] << "%";		Data[10] = ss.str();

		//		cerr << "Gang:\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
		//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << "\t" << Data[6] << endl;

		/*
		*			add the box to the list; red highlight gangs that are low on numbers
		*/
		int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE);
		if (current->m_Num < 6 && (current->m_MissionID == MISS_SERVICE || current->m_MissionID == MISS_TRAINING)) color = COLOR_YELLOW;
		AddToListBox(ganglist_id, num++, Data, 11, color);
	}

	ClearListBox(recruitlist_id);
	num = 0;
	current = g_Gangs.GetHireableGang(0);

	// loop through the gangs, populating the list box
	g_LogFile.write("Setting recruitable gang info\n");
	for (current = g_Gangs.GetHireableGang(0); current; current = current->m_Next)
	{
		// format the string with the gang name, mission and number of men
		string Data[10];
		ss.str("");	ss << current->m_Name;								Data[0] = ss.str();
		ss.str("");	ss << current->m_Num;								Data[1] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_COMBAT] << "%";		Data[2] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_MAGIC] << "%";		Data[3] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_INTELLIGENCE] << "%";	Data[4] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_AGILITY] << "%";		Data[5] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CONSTITUTION] << "%";	Data[6] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_CHARISMA] << "%";		Data[7] = ss.str();
		ss.str("");	ss << current->m_Stats[STAT_STRENGTH] << "%";		Data[8] = ss.str();
		ss.str("");	ss << current->m_Skills[SKILL_SERVICE] << "%";		Data[9] = ss.str();

		//		cerr << "Recruitable\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
		//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << endl;

		/*
		*			add the box to the list
		*/
		int color = (current->m_Num < 6 ? COLOR_RED : COLOR_BLUE);
		AddToListBox(recruitlist_id, num++, Data, 10, color);
	}

	if (selection == -1 && GetListBoxSize(ganglist_id) >= 1) selection = 0;

	if (selection >= 0)
	{
		while (selection > GetListBoxSize(ganglist_id) && selection != -1) selection--;
	}
	if (selection >= 0) SetSelectedItemInList(ganglist_id, selection);
	if (sel_recruit == -1 && GetListBoxSize(recruitlist_id) >= 1) sel_recruit = 0;
	if (sel_recruit >= 0) SetSelectedItemInList(recruitlist_id, sel_recruit);

	DisableButton(ganghire_id, (g_Gangs.GetNumHireableGangs() <= 0) || (g_Gangs.GetNumGangs() >= g_Gangs.GetMaxNumGangs()) || (sel_recruit == -1));
	DisableButton(gangfire_id, (g_Gangs.GetNumGangs() <= 0) || (selection == -1));

	potions = wlev = nets = 0;
}
void cScreenCentreManagement::init()
{

	if (FreeGirl)
	{
		if (g_ChoiceManager.GetChoice(0) == 0)
		{
			vector<int> girl_array;
			GetSelectedGirls(&girl_array);  // get and sort array of girls

			for (int i = girl_array.size(); i--> 0;)	// OK, we have the array, now step through it backwards
			{
				selected_girl = g_Centre.GetGirl(g_CurrCentre, girl_array[i]);
				if (GirlDead(selected_girl) || !selected_girl->is_slave()) continue;  // if dead or not a slave, can't free her
				if (selected_girl)
				{
					selected_girl->m_States &= ~(1 << STATUS_SLAVE);
					The_Player->disposition(5);
					g_Girls.UpdateStat(selected_girl, STAT_PCLOVE, 10);
					g_Girls.UpdateStat(selected_girl, STAT_PCFEAR, -20);
					g_Girls.UpdateStat(selected_girl, STAT_PCHATE, -25);
					g_Girls.UpdateStat(selected_girl, STAT_OBEDIENCE, 10);
					g_Girls.UpdateStat(selected_girl, STAT_HAPPINESS, 70);
					
					selected_girl->m_AccLevel = cfg.initial.girls_accom();
					selected_girl->m_Stats[STAT_HOUSE] = cfg.initial.girls_house_perc();
					g_InitWin = true;
				}
			}
		}
		g_ChoiceManager.Free();
		FreeGirl = false;
	}

	g_CurrentScreen = SCREEN_CENTRE;
	if (!g_InitWin) return;

	Focused();
	g_InitWin = false;


	////////////////////

	selection = GetSelectedItemFromList(girllist_id);
	string centre;
	centre += g_Centre.GetName(g_CurrCentre);
	EditTextItem(centre, curcentre_id);

	//selected_girl = 0;

	// clear the lists
	ClearListBox(girllist_id);
	ClearListBox(jobtypelist_id);

	// add the job filters
	//	for(int i=0; i<NUMJOBTYPES; i++)  // loop through all job types
	AddToListBox(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COMMUNITYCENTRE]);
	AddToListBox(jobtypelist_id, JOBFILTER_COUNSELINGCENTRE, g_Centre.m_JobManager.JobFilterName[JOBFILTER_COUNSELINGCENTRE]);
	RefreshJobList();
	SetSelectedItemInList(jobtypelist_id, JOBFILTER_COMMUNITYCENTRE);

	//get a list of all the column names, so we can find which data goes in that column
	vector<string> columnNames;
	m_ListBoxes[girllist_id]->GetColumnNames(columnNames);
	int numColumns = columnNames.size();
	string* Data = new string[numColumns];

	// Add girls to list
	for (int i = 0; i<g_Centre.GetNumGirls(g_CurrCentre); i++)
	{
		sGirl* gir = g_Centre.GetGirl(g_CurrCentre, i);
		if (selected_girl == gir)
			selection = i;

		unsigned int item_color = COLOR_BLUE;
		if (g_Girls.GetStat(gir, STAT_HEALTH) <= 30 || g_Girls.GetStat(gir, STAT_TIREDNESS) >= 80 || g_Girls.GetStat(gir, STAT_HAPPINESS) <= 30)
			item_color = COLOR_RED;

		gir->OutputGirlRow(Data, columnNames);
		AddToListBox(girllist_id, i, Data, numColumns, item_color);
	}
	delete[] Data;

	lastNum = -1;
	g_InitWin = false;

	if (selection >= 0)
	{
		while (selection > GetListBoxSize(girllist_id) && selection != -1)
			selection--;
	}
	if (selection >= 0)
		SetSelectedItemInList(girllist_id, selection);
	else
		SetSelectedItemInList(girllist_id, 0);

	DisableButton(day_id, (Day0Night1 == SHIFT_DAY));
	DisableButton(night_id, (Day0Night1 == SHIFT_NIGHT));

	update_image();
}
void cScreenGangs::init()
{
	if(!g_InitWin)
		return;

	Focused();
	g_InitWin = false;

////////////////////

	cConfig cfg;

	selection = GetLastSelectedItemFromList(ganglist_id);
	sel_recruit = GetLastSelectedItemFromList(recruitlist_id);

	int cost = tariff.goon_mission_cost(MISS_GUARDING);
	ss.str("");
	ss << "Gangs: " << cost << " gold / week";
	EditTextItem(ss.str(), gangcost_id);

	ClearListBox(missionlist_id);
	AddToListBox(missionlist_id, 0, "GUARDING");
	AddToListBox(missionlist_id, 1, "SABOTAGE");
	AddToListBox(missionlist_id, 2, "SPY ON GIRLS");
	AddToListBox(missionlist_id, 3, "RECAPTURE");
	AddToListBox(missionlist_id, 4, "ACQUIRE TERRITORY");
	AddToListBox(missionlist_id, 5, "PETTY THEFT");
	AddToListBox(missionlist_id, 6, "GRAND THEFT");
	AddToListBox(missionlist_id, 7, "KIDNAPPING");
	AddToListBox(missionlist_id, 8, "CATACOMBS");
	AddToListBox(missionlist_id, 9, "TRAINING");
	AddToListBox(missionlist_id, 10, "RECRUITING");

	SetCheckBox(netautobuy_id, (g_Gangs.GetNetRestock() > 0));
	SetCheckBox(healautobuy_id, (g_Gangs.GetHealingRestock() > 0));

	// weapon upgrades
	int *wlev = g_Gangs.GetWeaponLevel();
	ss.str("");
	ss << "Weapon Level: " << *wlev;
	if((*wlev) < 4)
	{
		EnableButton(weaponup_id);
		ss << " Next: "
		   << tariff.goon_weapon_upgrade(*wlev)
		   << "g";
	}
	else
		DisableButton(weaponup_id);
	std::string s = ss.str();
	g_LogFile.ss() << "weapon text = '" << s << "'" << std::endl;
	g_LogFile.ssend();
	EditTextItem(s, weaponlevel_id);

	int *nets = g_Gangs.GetNets();
	ss.str("");
	ss << "Nets ("
	   << tariff.nets_price(1)
	   << "g each): " << *nets;
	DisableButton(netbuy_id, *nets >= 60);
	DisableCheckBox(netautobuy_id, *nets < 1);
	EditTextItem(ss.str(), netdesc_id);

	int *potions = g_Gangs.GetHealingPotions();
	ss.str("");
	ss << "Heal Potions ("
	   << tariff.healing_price(1)
	   << "g each): " <<
	   *potions
	;
	EditTextItem(ss.str(), healdesc_id);
	DisableButton(healbuy_id, *potions >= 200);
	DisableCheckBox(healautobuy_id, *potions < 1);

    std::string message;
	buffer[0] = '\0';
	if(g_Gangs.GetNumGangs() > 0)
	{
		cost = 0;
		for(int i=0; i < g_Gangs.GetNumGangs(); i++)
		{
			sGang* g = g_Gangs.GetGang(i);
			if (g == nullptr)
				g = g_Gangs.GetGang(i-1);

			cost += tariff.goon_mission_cost(g->m_MissionID);
		}
		message = "Weekly Cost: ";
		message += toString(cost);
	}
	else
		message = "Weekly Cost: 0";

	EditTextItem(message, totalcost_id);

	ClearListBox(ganglist_id);

	int num = 0;
	sGang* current = g_Gangs.GetGang(0);

/*
 *		loop through the gangs, populating the list box
 */
	g_LogFile.ss() << "Setting gang mission descriptions" << std::endl;
	g_LogFile.ssend();
	for(current = g_Gangs.GetGang(0); current; current = current->m_Next)
	{
/*
 *			format the string with the gang name, mission and number of men
 */
		std::string Data[9];
		ss.str("");
		ss << current->m_Name;
		Data[0] = ss.str();
		ss.str("");
		ss << current->m_Num;
		Data[1] = ss.str();
		ss.str("");
		ss << short_mission_desc(current->m_MissionID);
		Data[2] = ss.str();
		ss.str("");
		ss << (int)current->m_Skills[SKILL_COMBAT] << "%";
		Data[3] = ss.str();
		ss.str("");
		ss << (int)current->m_Skills[SKILL_MAGIC] << "%";
		Data[4] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_INTELLIGENCE] << "%";
		Data[5] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_AGILITY] << "%";
		Data[6] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_CONSTITUTION] << "%";
		Data[7] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_CHARISMA] << "%";
		Data[8] = ss.str();

//		g_LogFile.ss() << "Gang:\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << "\t" << Data[6] << std::endl;
//      g_LogFile.ssend();

/*
 *			add the box to the list; red highlight gangs that are low on numbers
 */
		AddToListBox( ganglist_id, num++, Data, 9, (current->m_Num < 6 ? LISTBOX_RED : LISTBOX_BLUE) );
	}

	ClearListBox(recruitlist_id);

	num = 0;
	current = g_Gangs.GetHireableGang(0);

/*
 *		loop through the gangs, populating the list box
 */
	g_LogFile.ss() << "Setting recruitable gang info" << std::endl;
	g_LogFile.ssend();
	for(current = g_Gangs.GetHireableGang(0); current; current = current->m_Next)
	{
/*
 *			format the string with the gang name, mission and number of men
 */
		std::string Data[8];
		ss.str("");
		ss << current->m_Name;
		Data[0] = ss.str();
		ss.str("");
		ss << current->m_Num;
		Data[1] = ss.str();
		ss.str("");
		ss << (int)current->m_Skills[SKILL_COMBAT] << "%";
		Data[2] = ss.str();
		ss.str("");
		ss << (int)current->m_Skills[SKILL_MAGIC] << "%";
		Data[3] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_INTELLIGENCE] << "%";
		Data[4] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_AGILITY] << "%";
		Data[5] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_CONSTITUTION] << "%";
		Data[6] = ss.str();
		ss.str("");
		ss << (int)current->m_Stats[STAT_CHARISMA] << "%";
		Data[7] = ss.str();

//		g_LogFile.ss() << "Recruitable\t" << Data[0] << "\t" << Data[1] << "\t" << Data[2]
//			<< "\t" << Data[3] << "\t" << Data[4] << "\t" << Data[5] << std::endl;
//      g_LogFile.ssend();

/*
 *			add the box to the list
 */
		AddToListBox( recruitlist_id, num++, Data, 8, (current->m_Num < 6 ? LISTBOX_RED : LISTBOX_BLUE) );
	}

	if(selection == -1 && GetListBoxSize(ganglist_id) >= 1)
		selection = 0;

	if(selection >= 0)
	{
		while(selection > GetListBoxSize(ganglist_id) && selection != -1)
			selection--;
	}
	if(selection >= 0)
		SetSelectedItemInList(ganglist_id, selection);

	if(sel_recruit == -1 && GetListBoxSize(recruitlist_id) >= 1)
		sel_recruit = 0;
	if(sel_recruit >= 0)
		SetSelectedItemInList(recruitlist_id, sel_recruit);

	DisableButton(ganghire_id, (g_Gangs.GetNumHireableGangs() <= 0)
							|| (g_Gangs.GetNumGangs() >= 8)
							|| (sel_recruit == -1));
	DisableButton(gangfire_id, (g_Gangs.GetNumGangs() <= 0)
							|| (selection == -1));

	potions = nullptr;
	wlev = nullptr;
	nets = nullptr;
}