Пример #1
0
void cArenaTry::process()
{
	if (!ids_set) set_ids();							// we need to make sure the ID variables are set
	init();
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home

	/*
	*	otherwise, compare event IDs
	*
	*	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;
	}
	else if (g_InterfaceEvents.CheckButton(walk_id))
	{
		do_walk();
		if (!g_Cheats) g_TryOuts = true;
		g_InitWin = true;
	}
}
Пример #2
0
void cListBox::SetSelected(int ID, bool ev, bool deselect_others)
{
	cListItem* current = m_Items;
	m_LastSelected = 0;
	m_HeaderClicked = "";

	if (!current) return;

	// special case if ID "-2" is sent, select first actual list item (not based on ID)
	if (ID == -2)
	{
		current->m_Selected = true;
		m_LastSelected = current;
		m_Position = 0;
		m_ScrollBar->SetTopValue(m_Position);
		if (ev) g_InterfaceEvents.AddEvent(EVENT_SELECTIONCHANGE, m_ID);
		return;
	}

	int count = 0; int posit = 0;
	while (current)
	{
		if (current->m_ID == ID)
		{
			if (ev) g_InterfaceEvents.AddEvent(EVENT_SELECTIONCHANGE, m_ID);
			current->m_Selected = true;
			m_LastSelected = current;
			posit = count;
			if (!deselect_others) break;
		}
		else
		{
			if (deselect_others) current->m_Selected = false;
		}
		count++;
		current = current->m_Next;
	}

	if (count <= m_NumDrawnElements)
	{
		m_Position = 0;
	}
	else
	{
		if (m_Position >= posit)
			m_Position = posit - 1;
		else if (m_Position + m_NumDrawnElements - 1 <= posit)
			m_Position = posit - m_NumDrawnElements + 2;
	}

	if (m_Position > count - m_NumDrawnElements) m_Position = count - m_NumDrawnElements;
	if (m_Position < 0) m_Position = 0;

	m_ScrollBar->SetTopValue(m_Position);
}
Пример #3
0
void cScreenHouse::check_events()
{
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home

	// 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;
	}
}
void cInterfaceWindow::Focused()
{
	// clear any events
	g_InterfaceEvents.ClearEvents();
	// clear edit boxes and set the first one as focused
	for (unsigned int i = 0; i < m_EditBoxes.size(); i++)		m_EditBoxes[i]->ClearText();
	if (!m_EditBoxes.empty())	m_EditBoxes[0]->m_HasFocus = true;
}
Пример #5
0
void cScreenMayor::check_events()
{
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home

	if (g_InterfaceEvents.CheckButton(back_id)) 		// if it's the back button, pop the window off the stack and we're done
	{
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	if (g_InterfaceEvents.CheckButton(bribe_id))
	{
		SetBribe = true;
		g_GetInput.ModeGetInt();
		g_WinManager.push("GetInput");
		g_InitWin = true;
		return;
	}
}
Пример #6
0
bool cButton::ButtonClicked(int x, int y)
{
	if (m_Disabled || m_Hidden) return false;
	if (IsOver(x, y))
	{
		g_InterfaceEvents.AddEvent(EVENT_BUTTONCLICKED, m_ID);
		return true;
	}
	return false;
}
Пример #7
0
void cListBox::OnClicked(int x, int y, bool mouseWheelDown, bool mouseWheelUp)
{
	cListItem* current = 0;
	if (m_NumElements == 0)	// it doesn't matter if there are no items in the list
		return;

	// if user clicked on "un-sort" header, do that
	if (m_ShowHeaders && m_HeaderClicksSort
		&& x > m_XPos + m_eWidth - 16
		&& x <= m_XPos + m_eWidth
		&& y > m_YPos + m_BorderSize
		&& y <= m_YPos + m_BorderSize + LISTBOX_ITEMHEIGHT
		)
	{
		UnSortList();
		return;
	}

	if (IsOver(x, y))
	{
		if (mouseWheelDown)
		{
			ScrollDown();
			return;
		}

		if (mouseWheelUp)
		{
			ScrollUp();
			return;
		}

		if (m_EnableEvents)
			g_InterfaceEvents.AddEvent(EVENT_SELECTIONCHANGE, m_ID);

		// See if a header was clicked
		m_HeaderClicked = "";
		if (m_ShowHeaders && y > m_YPos + m_BorderSize && y <= m_YPos + m_BorderSize + LISTBOX_ITEMHEIGHT)
		{
			int x_start = 0, x_end = 0;
			for (int i = 0; i < m_ColumnCount; i++)
			{
				if (m_SkipColumn[i]) continue;

				x_start = m_ColumnOffset[i] - 3;

				if (i < m_ColumnCount - 1)
					x_end = m_ColumnOffset[i + 1] - 3;
				else
					x_end = m_eWidth;

				if (x >= m_XPos + x_start && x <= m_XPos + x_end)
				{
					// then set it as clicked
					m_HeaderClicked = m_ColumnName[i];

					// should we re-sort list based on header?
					if (m_HeaderClicksSort)
					{
						if (m_SortedColumn == m_ColumnName[i])
							m_SortedDescending = !m_SortedDescending;
						else
						{
							m_SortedColumn = m_ColumnName[i];
							m_SortedDescending = false;
						}
						ReSortList();
					}
					return;
				}
			}
		}

		bool deselect = false;
		if (m_MultiSelect == true)
		{
			if (g_ShiftDown == false && g_CTRLDown == false)
			{
				m_HasMultiSelect = false;
				deselect = true;
			}
			else m_HasMultiSelect = true;
		}
		else deselect = true;

		// first unselect any currently selected items
		if (deselect)
		{
			m_LastSelected = 0;
			current = m_Items;
			while (current)
			{
				current->m_Selected = false;
				current = current->m_Next;
			}
		}

		bool singleSelect = true;
		if (m_MultiSelect == true)
		{
			if (g_ShiftDown == true)
				singleSelect = false;
		}
		else singleSelect = true;

		if (singleSelect)	// find the first element displayed
		{
			current = m_Items;
			int count = 0;
			while (current)
			{
				if (count == m_Position) break;
				count++;
				current = current->m_Next;
			}

			// Check each element to see if mouse is over it
			int temp = 0;
			while (current)
			{
				if ((count - m_Position) >= m_NumDrawnElements)	// stop if running past the visible list
					break;

				int cX = m_XPos + m_BorderSize;
				int cY = (m_YPos + m_BorderSize) + (LISTBOX_ITEMHEIGHT*temp);
				if (m_ShowHeaders) // Account for headers if shown
					cY += LISTBOX_ITEMHEIGHT;

				// Check if over the item
				if (x > cX && y > cY && x < cX + m_eWidth && y <= cY + m_eHeight)
				{
					// then select it
					current->m_Selected = !current->m_Selected;
					m_LastSelected = current;

					// update info for tracking double-clicks
					m_LastClickTime = m_CurrentClickTime;
					m_LastClickX = m_CurrentClickX;
					m_LastClickY = m_CurrentClickY;
					m_CurrentClickTime = SDL_GetTicks();
					m_CurrentClickX = x;
					m_CurrentClickY = y;

					break;
				}

				count++; temp++;
				current = current->m_Next;
			}
		}
		else
		{
			if (g_ShiftDown == true)	// select from first to last
			{
				current = m_Items;
				cListItem* select_first = 0;
				cListItem* select_last = 0;
				int count = 0;
				// scan through to find both last-clicked-on item and currently-clicked-on item
				while (current)
				{
					if (select_first && select_last)  // if we have both now, we're done here
						break;

					// was this the last item the user clicked on earlier?
					if (current == m_LastSelected)
					{
						if (!select_first)
							select_first = current;
						else
							select_last = current;
					}

					// is this the current item the user just clicked on?
					if (count >= m_Position && count - m_Position < m_NumDrawnElements)
					{
						int cX = m_XPos + m_BorderSize;
						int cY = (m_YPos + m_BorderSize) + (LISTBOX_ITEMHEIGHT*(count - m_Position));
						if (m_ShowHeaders) // Account for headers if shown
							cY += LISTBOX_ITEMHEIGHT;

						// Check if over the item
						if (x > cX && y > cY && x < cX + m_eWidth && y <= cY + m_eHeight)
						{
							if (!select_first)
								select_first = current;
							else
								select_last = current;
						}
					}

					count++;
					current = current->m_Next;
				}

				current = select_first;
				while (current)	// now simply select each one ranging from first to last
				{
					current->m_Selected = true;	// select the item
					if (current == select_last)
					{
						m_LastSelected = current;
						break;
					}
					current = current->m_Next;
				}
			}
		}
	}
}
Пример #8
0
void cScreenGangs::check_events()
{
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home
	if (g_InterfaceEvents.CheckButton(back_id))			// if it's the back button, pop the window off the stack and we're done
	{
		g_InitWin = true;
		g_WinManager.Pop();
		return;
	}
	if (g_InterfaceEvents.CheckButton(ganghire_id))
	{
		hire_recruitable();
		return;
	}
	if (g_InterfaceEvents.CheckButton(weaponup_id))
	{
		int cost = 0;
		int *wlev = g_Gangs.GetWeaponLevel();
		cost = tariff.goon_weapon_upgrade(*wlev);
		if (g_Gold.item_cost(cost) == true)
		{
			*wlev += 1;
			g_InitWin = true;
		}
		wlev = 0;
		return;
	}

	int buynets = 0;
	if (g_InterfaceEvents.CheckButton(netbuy_id))	buynets = 1;
	if (g_InterfaceEvents.CheckButton(netbuy10_id))	buynets = 10;
	if (g_InterfaceEvents.CheckButton(netbuy20_id))	buynets = 20;
	if (buynets > 0)
	{
		int cost = 0;
		int amount = buynets;
		int *nets = g_Gangs.GetNets();
		if (((*nets) + buynets) > 60) amount = 60 - (*nets);
		cost = tariff.nets_price(amount);
		if (g_Gold.item_cost(cost) == true)
		{
			*nets += amount;
			if (IsCheckboxOn(netautobuy_id)) g_Gangs.KeepNetStocked(*nets);
			g_InitWin = true;
		}
		nets = 0;
		buynets = 0;
		return;
	}

	int buypots = 0;
	if (g_InterfaceEvents.CheckButton(healbuy_id))		buypots = 1;
	if (g_InterfaceEvents.CheckButton(healbuy10_id))	buypots = 10;
	if (g_InterfaceEvents.CheckButton(healbuy20_id))	buypots = 20;
	if (buypots > 0)
	{
		int cost = 0;
		int amount = buypots;
		int *potions = g_Gangs.GetHealingPotions();
		if (((*potions) + buypots) > 200)	amount = 200 - (*potions);
		cost = tariff.healing_price(amount);
		if (g_Gold.item_cost(cost) == true)
		{
			*potions += amount;
			if (IsCheckboxOn(healautobuy_id)) g_Gangs.KeepHealStocked(*potions);
			g_InitWin = true;
		}
		potions = 0;
		buypots = 0;
		return;
	}
	if (g_InterfaceEvents.CheckCheckbox(netautobuy_id))
	{
		int *nets = g_Gangs.GetNets();
		g_Gangs.KeepNetStocked(IsCheckboxOn(netautobuy_id) ? *nets : 0);
	}
	if (g_InterfaceEvents.CheckCheckbox(healautobuy_id))
	{
		int *potions = g_Gangs.GetHealingPotions();
		g_Gangs.KeepHealStocked(IsCheckboxOn(healautobuy_id) ? *potions : 0);
	}
	if (g_InterfaceEvents.CheckButton(gangfire_id))
	{
		selection = GetLastSelectedItemFromList(ganglist_id);
		if (selection != -1)
		{
			g_Gangs.FireGang(selection);
			g_InitWin = true;
		}
		return;
	}
	if (g_InterfaceEvents.CheckListbox(recruitlist_id))
	{
		string ClickedHeader = HeaderClicked(recruitlist_id);
		if (ClickedHeader != "")
		{
			g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Recruit listbox" << endl; g_LogFile.ssend();
			return;
		}

		g_LogFile.ss() << "selected recruitable gang changed" << endl; g_LogFile.ssend();
		sel_recruit = GetLastSelectedItemFromList(recruitlist_id);

		if (ListDoubleClicked(recruitlist_id))
		{
			g_LogFile.ss() << "User double-clicked recruitable gang! Hiring if possible." << endl; g_LogFile.ssend();
			hire_recruitable();
			return;
		}
		//		g_InitWin = true;
	}

	// this is what gets called it you change the selected gang
	if (g_InterfaceEvents.CheckListbox(ganglist_id))
	{
		string ClickedHeader = HeaderClicked(ganglist_id);
		if (ClickedHeader != "")
		{
			g_LogFile.ss() << "User clicked \"" << ClickedHeader << "\" column header on Gangs listbox" << endl; g_LogFile.ssend();
			return;
		}

		g_LogFile.write("selected gang changed");
		selection = GetLastSelectedItemFromList(ganglist_id);
		if (selection != -1)
		{
			sGang* gang = g_Gangs.GetGang(selection);
			ss.str(""); ss << "Name: " << gang->m_Name << "\n" << "Number: " << gang->m_Num << "\n" << "Combat: " << gang->m_Skills[SKILL_COMBAT] << "%\n" << "Magic: " << gang->m_Skills[SKILL_MAGIC] << "%\n" << "Intelligence: " << gang->m_Stats[STAT_INTELLIGENCE] << "%\n";
			EditTextItem(ss.str(), gangdesc_id);
			SetSelectedItemInList(missionlist_id, gang->m_MissionID, false);
			set_mission_desc(gang->m_MissionID);		// set the long description for the mission
		}
	}
	if (g_InterfaceEvents.CheckListbox(missionlist_id))
	{
		// get the index into the missions list
		int mission_id = GetLastSelectedItemFromList(missionlist_id);
		g_LogFile.ss() << "selchange: mid = " << mission_id << endl; g_LogFile.ssend();
		set_mission_desc(mission_id);		// set the textfield with the long description and price for this mission
		g_LogFile.ss() << "selection change: rebuilding gang list box" << endl; g_LogFile.ssend();
		for (int selection = multi_first(); selection != -1; selection = multi_next())
		{
			sGang* gang = g_Gangs.GetGang(selection);
			/*
			*				make sure we found the gang - pretty catastrophic
			*				if not, so log it if we do
			*/
			if (gang == 0)
			{
				g_LogFile.ss() << "Error: No gang for index " << selection; g_LogFile.ssend();
				continue;
			}
			/*
			*				if the mission id is -1, nothing else to do
			*				(moving this to before the recruitment check
			*				since -1 most likely means nothing selected in
			*				the missions list)
			*/
			if (mission_id == -1) { continue; }
			/*
			*				if the gang is already doing <whatever>
			*				then let them get on with it
			*/
			if (gang->m_MissionID == u_int(mission_id)) { continue; }
			/*
			*				if they were recruiting, turn off the
			*				auto-recruit flag
			*/
			if (gang->m_MissionID == MISS_RECRUIT && gang->m_AutoRecruit)
			{
				gang->m_AutoRecruit = false;
				gang->m_LastMissID = -1;
			}
			gang->m_MissionID = mission_id;
			/*
			*				format the display line
			*/
			g_InitWin = true;
		}

		int cost = 0;
		if (g_Gangs.GetNumGangs() > 0)
		{
			for (int i = 0; i < g_Gangs.GetNumGangs(); i++)
			{
				sGang* g = g_Gangs.GetGang(i);
				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);
		}

	}

	if (g_InterfaceEvents.CheckCheckbox(controlcatacombs_id))
	{
		g_Gangs.Control_Gangs(IsCheckboxOn(controlcatacombs_id));
	}
	bool dosliders = false;
	if (g_InterfaceEvents.CheckSlider(girlspercslider_id))
	{
		int s1 = SliderValue(girlspercslider_id);
		int s2 = SliderValue(itemspercslider_id);
		if (s2 < s1)
		{
			s2 = s1;
			SliderRange(itemspercslider_id, 0, 100, s2, 1);
		}
		dosliders = true;
	}
	if (g_InterfaceEvents.CheckSlider(itemspercslider_id))
	{
		int s1 = SliderValue(itemspercslider_id);
		int s2 = SliderValue(girlspercslider_id);
		if (s1 < s2)
		{
			s2 = s1;
			SliderRange(girlspercslider_id, 0, 100, s2, 1);
		}
		dosliders = true;
	}
	if (dosliders)
	{
		int s1 = SliderValue(girlspercslider_id);
		int s2 = SliderValue(itemspercslider_id);
		g_Gangs.Gang_Gets_Girls(s1);
		g_Gangs.Gang_Gets_Items(s2 - s1);
		g_Gangs.Gang_Gets_Beast(100 - s2);
		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);
		return;
	}
}
Пример #9
0
void cClinicScreen::process()
{
	/*
	*	we need to make sure the ID variables are set
	*/
	if (!ids_set) set_ids();
	init();

	if (g_InitWin)
	{
		EditTextItem(g_Clinic.GetBrothelString(0), clinicdetails_id);
		g_InitWin = false;
	}
	/*
	*	no events means we can go home
	*/
	if (g_InterfaceEvents.GetNumEvents() == 0) return;

	/*
	*	otherwise, compare event IDs
	*
	*	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;
	}
	else if (g_InterfaceEvents.CheckButton(walk_id))
	{
		g_InitWin = true;
		g_WinManager.push("Clinic Try");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(girls_id))
	{
		g_InitWin = true;
		g_WinManager.push("Clinic");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(staff_id))
	{
		g_InitWin = true;
		g_WinManager.push("Gangs");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(turns_id))
	{
		g_InitWin = true;
		g_WinManager.push("TurnSummary");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(setup_id))
	{
		g_Building = BUILDING_CLINIC;
		g_InitWin = true;
		g_WinManager.push("Building Setup");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(dungeon_id))
	{
		g_InitWin = true;
		g_WinManager.push("Dungeon");
		return;
	}
	else if (g_InterfaceEvents.CheckButton(weeks_id))
	{
		g_InitWin = true;
		if (!g_CTRLDown) { g_CTRLDown = false; AutoSaveGame(); }
		NextWeek();
		g_WinManager.push("TurnSummary");
		return;
	}
}
Пример #10
0
void cScreenTown::process()
{
	if (!ids_set)set_ids();								// we need to make sure the ID variables are set
	init();
	if (g_InterfaceEvents.GetNumEvents() == 0) return;	// no events means we can go home
	if (girlimage_id != -1 && !eventrunning)	HideImage(girlimage_id, true);

	/*
	*	otherwise, compare event IDs
	*
	*	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; }
	else if (g_InterfaceEvents.CheckButton(slavemarket_id)) { g_InitWin = true;		g_WinManager.push("Slave Market");	return; }
	else if (g_InterfaceEvents.CheckButton(prison_id))		{ g_InitWin = true;		g_WinManager.push("Prison");		return; }
	else if (g_InterfaceEvents.CheckButton(house_id))		{ g_Building = BUILDING_HOUSE;	g_CurrHouse = 0;	g_InitWin = true;	g_WinManager.push("Player House");	return; }
	else if (g_InterfaceEvents.CheckButton(clinic_id))		{ check_clinic(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(studio_id))		{ check_studio(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(arena_id))		{ check_arena(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(centre_id))		{ check_centre(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(farm_id))		{ check_farm(0);		g_InitWin = true;			return; }
	else if (g_InterfaceEvents.CheckButton(mayor_id))		{ g_InitWin = true;		g_WinManager.push("Mayor");	return; }
	else if (g_InterfaceEvents.CheckButton(bank_id))		{ g_InitWin = true;		g_WinManager.push("Bank");	return; }
	else if (g_InterfaceEvents.CheckButton(shop_id))		{ g_InitWin = true;		g_AllTogle = false;	g_WinManager.push("Item Management");	return; }
	else if (g_InterfaceEvents.CheckButton(brothel0_id))	{ check_brothel(0);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel1_id))	{ check_brothel(1);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel2_id))	{ check_brothel(2);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel3_id))	{ check_brothel(3);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel4_id))	{ check_brothel(4);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel5_id))	{ check_brothel(5);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(brothel6_id))	{ check_brothel(6);		g_InitWin = true;	return; }
	else if (g_InterfaceEvents.CheckButton(walk_id))		{ do_walk();			if (!g_Cheats) g_WalkAround = true;	g_InitWin = true; }
	else if (g_InterfaceEvents.CheckButton(setup_id))		{ g_InitWin = true;		g_WinManager.push("Property Management");		return; }	// `J` added

}