void cScreenCentreManagement::check_events()
{
	// no events means we can go home
	if (g_InterfaceEvents.GetNumEvents() == 0)
		return;

	// if it's the back button, pop the window off the stack and we're done
	if (g_InterfaceEvents.CheckButton(back_id)) {
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	if (g_InterfaceEvents.CheckButton(viewdetails_id))
	{
		ViewSelectedGirl();
	}


	if (g_InterfaceEvents.CheckButton(day_id))
	{
		DisableButton(day_id, true);
		DisableButton(night_id, false);
		Day0Night1 = SHIFT_DAY;
		RefreshSelectedJobType();
	}
	if (g_InterfaceEvents.CheckButton(night_id))
	{
		DisableButton(day_id, false);
		DisableButton(night_id, true);
		Day0Night1 = SHIFT_NIGHT;
		RefreshSelectedJobType();
	}
	if (g_InterfaceEvents.CheckListbox(jobtypelist_id))
	{
		selection = GetSelectedItemFromList(jobtypelist_id);

		if (selection == -1)
			EditTextItem("Nothing Selected", jobtypedesc_id);
		else
		{
			// populate Jobs listbox with jobs in the selected category
			RefreshJobList();
			string jdmessage = g_Centre.m_JobManager.JobFilterDesc[selection];

			if ((g_Centre.GetNumGirlsOnJob(g_CurrCentre, JOB_COUNSELOR, 0) < 1 &&
				g_Centre.GetNumberPatients(0) > 0) ||
				(g_Centre.GetNumGirlsOnJob(g_CurrCentre, JOB_COUNSELOR, 1) < 1 &&
				g_Centre.GetNumberPatients(1) > 0))
			{
				jdmessage += gettext("\n*** A Counselor is required to guide Rehab and Therapy patients. ");
			}
			EditTextItem(jdmessage, jobtypedesc_id);
		}
	}
	if (g_InterfaceEvents.CheckListbox(joblist_id))
	{
		bool fulltime = g_CTRLDown;

		selection = GetSelectedItemFromList(joblist_id);
		if (selection != -1)
		{
			// first handle the descriptions
			EditTextItem(g_Centre.m_JobManager.JobDesc[selection], jobdesc_id);

			// Now assign the job to all the selected girls
			int pos = 0;
			int GSelection = GetNextSelectedItemFromList(girllist_id, 0, pos);
			while (GSelection != -1)
			{
				u_int new_job = selection;
				selected_girl = g_Centre.GetGirl(g_CurrCentre, GSelection);
				if (selected_girl)
				{
					int old_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);

					// handle special job requirements and assign
					// if HandleSpecialJobs returns true, the job assignment was modified or cancelled

					if (g_Centre.m_JobManager.HandleSpecialJobs(g_CurrCentre, selected_girl, new_job, old_job, Day0Night1, fulltime))
					{
						new_job = (Day0Night1 ? selected_girl->m_NightJob : selected_girl->m_DayJob);
						SetSelectedItemInList(joblist_id, new_job, false);
					}

					// update the girl's listing to reflect the job change
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_DayJob];
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->DayJobColumn());
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_NightJob];
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->NightJobColumn());

					// refresh job worker counts for former job and current job
					SetSelectedItemText(joblist_id, old_job, g_Centre.m_JobManager.JobDescriptionCount(old_job, 0, Day0Night1, false, false, false, true));
					SetSelectedItemText(joblist_id, new_job, g_Centre.m_JobManager.JobDescriptionCount(new_job, 0, Day0Night1, false, false, false, true));
				}
				if (selected_girl->m_DayJob == JOB_REHAB)	// `J` added
				{
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_DayJob] << " (" << 3 - selected_girl->m_WorkingDay << ")";
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->DayJobColumn());
				}
				else if (selected_girl->m_YesterDayJob == JOB_REHAB && selected_girl->m_DayJob != JOB_REHAB && ((selected_girl->m_WorkingDay > 0) || selected_girl->m_PrevWorkingDay > 0))
				{
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_DayJob] << " **";
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->DayJobColumn());
				}

				if (selected_girl->m_NightJob == JOB_REHAB)	// `J` added
				{
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_NightJob] << " (" << 3 - selected_girl->m_WorkingDay << ")";
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->NightJobColumn());
				}
				else if (selected_girl->m_YesterNightJob == JOB_REHAB && selected_girl->m_NightJob != JOB_REHAB && ((selected_girl->m_WorkingDay > 0) || selected_girl->m_PrevWorkingDay > 0))
				{
					ss.str("");
					ss << g_Centre.m_JobManager.JobName[selected_girl->m_NightJob] << " **";
					SetSelectedItemColumnText(girllist_id, GSelection, ss.str(), m_ListBoxes[girllist_id]->NightJobColumn());
				}
				if (selected_girl && selected_girl->m_YesterDayJob == JOB_REHAB && new_job != JOB_REHAB && (selected_girl->m_WorkingDay > 0 || selected_girl->m_PrevWorkingDay > 0))
				{	// `J` added
					EditTextItem(g_Centre.m_JobManager.JobDesc[new_job]
						+ "\n** This girl was in Rehab, if you send her somewhere else, she will have to start her Rehab over."
						, jobdesc_id);
				}
				GSelection = GetNextSelectedItemFromList(girllist_id, pos + 1, pos);
			}
		}
		else	EditTextItem("Nothing Selected", jobdesc_id);
	}

	if (g_InterfaceEvents.CheckListbox(girllist_id))
	{
		selection = GetSelectedItemFromList(girllist_id);
		if (selection != -1)
		{
			selected_girl = g_Centre.GetGirl(g_CurrCentre, selection);
			if (ListDoubleClicked(girllist_id)) ViewSelectedGirl();		// If double-clicked, try to bring up girl details
			DisableButton(freeslave_id, selected_girl->is_free());
			DisableButton(viewdetails_id, false);
			RefreshSelectedJobType();
		}
		else
		{
			DisableButton(freeslave_id, true);
			DisableButton(viewdetails_id, true);
			selected_girl = 0;
			selection = -1;
		}
		lastNum = -2;
		update_image();
		return;
	}
	if (g_InterfaceEvents.CheckButton(freeslave_id))
	{
		if (selected_girl)
		{
			if (IsMultiSelected(girllist_id))
			{  // multiple girls selected
				g_MessageQue.AddToQue("Are you sure you wish to give these girls their freedom?", 0);
				g_ChoiceManager.CreateChoiceBox(224, 112, 352, 384, 0, 2, 32, strlen("Keep as a slaves"));
				g_ChoiceManager.AddChoice(0, "Grant Freedom", 0);
				g_ChoiceManager.AddChoice(0, "Keep as a slaves", 1);
				g_ChoiceManager.SetActive(0);
				FreeGirl = true;
			}
			else  // only one girl selected
			{
				if (GirlDead(selected_girl)) return;
				g_MessageQue.AddToQue("Are you sure you wish to give " + selected_girl->m_Realname + " her freedom?", 0);
				g_ChoiceManager.CreateChoiceBox(224, 112, 352, 384, 0, 2, 32, strlen("Keep as a slave"));
				g_ChoiceManager.AddChoice(0, "Grant Freedom", 0);
				g_ChoiceManager.AddChoice(0, "Keep as a slave", 1);
				g_ChoiceManager.SetActive(0);
				FreeGirl = true;
			}
		}
		return;
	}
	if (g_InterfaceEvents.CheckButton(transfer_id))
	{
		g_InitWin = true;
		g_WinManager.Push(TransferGirls, &g_TransferGirls);
		return;
	}
}
예제 #2
0
void cScreenTown::init()
{
	if (BuyClinic != -1)
	{
		(g_ChoiceManager.GetChoice(0) == 0 ? GetClinic = true : BuyClinic = -1);
		g_ChoiceManager.Free();
	}
	if (GetClinic)
	{
		static_brothel_data *bpt = clinic_data + BuyClinic;
		g_Gold.brothel_cost(bpt->price);
		g_Clinic.NewBrothel(bpt->rooms, bpt->maxrooms);
		g_Clinic.SetName(0, gettext("Clinic"));
		GetClinic = false;
		BuyClinic = -1;
	}
	if (BuyCentre != -1)
	{
		(g_ChoiceManager.GetChoice(0) == 0 ? GetCentre = true : BuyCentre = -1);
		g_ChoiceManager.Free();
	}
	if (GetCentre)
	{
		static_brothel_data *bpt = centre_data + BuyCentre;
		g_Gold.brothel_cost(bpt->price);
		g_Centre.NewBrothel(bpt->rooms, bpt->maxrooms);
		g_Centre.SetName(0, gettext("Centre"));
		GetCentre = false;
		BuyCentre = -1;
	}
	if (BuyArena != -1)
	{
		(g_ChoiceManager.GetChoice(0) == 0 ? GetArena = true : BuyArena = -1);
		g_ChoiceManager.Free();
	}
	if (GetArena)
	{
		static_brothel_data *bpt = arena_data + BuyArena;

		g_Gold.brothel_cost(bpt->price);
		g_Arena.NewBrothel(bpt->rooms, bpt->maxrooms);
		g_Arena.SetName(0, gettext("Arena"));

		GetArena = false;
		BuyArena = -1;
	}
	if (BuyStudio != -1)
	{
		(g_ChoiceManager.GetChoice(0) == 0 ? GetStudio = true : BuyStudio = -1);
		g_ChoiceManager.Free();
	}
	if (GetStudio)
	{
		static_brothel_data *bpt = studio_data + BuyStudio;
		g_Gold.brothel_cost(bpt->price);
		g_Studios.NewBrothel(bpt->rooms, bpt->maxrooms);
		g_Studios.SetName(0, gettext("Studio"));
		GetStudio = false;
		BuyStudio = -1;
	}
	if (BuyFarm != -1)
	{
		(g_ChoiceManager.GetChoice(0) == 0 ? GetFarm = true : BuyFarm = -1);
		g_ChoiceManager.Free();
	}
	if (GetFarm)
	{
		static_brothel_data *bpt = farm_data + BuyFarm;
		g_Gold.brothel_cost(bpt->price);
		g_Farm.NewBrothel(bpt->rooms, bpt->maxrooms);
		g_Farm.SetName(0, gettext("Farm"));
		GetFarm = false;
		BuyFarm = -1;
	}
	if (GetName)
	{
		if (g_ReturnText != "")
		{
			if (g_Brothels.GetObjective() && g_Brothels.GetObjective()->m_Objective == OBJECTIVE_GETNEXTBROTHEL) 
				g_Brothels.PassObjective();
			static_brothel_data *bpt = brothel_data + BuyBrothel;
			g_Gold.brothel_cost(bpt->price);
			g_Brothels.NewBrothel(bpt->rooms, bpt->maxrooms);
			g_Brothels.SetName(g_Brothels.GetNumBrothels() - 1, g_ReturnText);
			g_InitWin = true;
		}
		GetName = false;
		BuyBrothel = -1;
	}
	if (BuyBrothel != -1)
	{
		if (g_ChoiceManager.GetChoice(0) == 0)
		{
			g_MessageQue.AddToQue("Enter a name for your new brothel.", 0);
			GetName = true;
			g_InitWin = true;
			g_WinManager.Push(GetString, &g_GetString);
		}
		else BuyBrothel = -1;
		g_ChoiceManager.Free();
		if (!GetName) BuyBrothel = -1;
		return;
	}
	g_CurrentScreen = SCREEN_TOWN;
	if (!g_InitWin) return;

	Focused();
	g_InitWin = false;

	// buttons enable/disable
	DisableButton(walk_id, g_WalkAround);

	HideButton(brothel2_id, (g_Brothels.GetBrothel(1) == 0));
	HideButton(brothel3_id, (g_Brothels.GetBrothel(2) == 0));
	HideButton(brothel4_id, (g_Brothels.GetBrothel(3) == 0));
	HideButton(brothel5_id, (g_Brothels.GetBrothel(4) == 0));
	HideButton(brothel6_id, (g_Brothels.GetBrothel(5) == 0));

	string brothel = "Current Brothel: ";
	brothel += g_Brothels.GetName(g_CurrBrothel);
	EditTextItem(brothel, curbrothel_id);
}