Skip to content

Commit 7995070

Browse files
committed
check multimouse on activity start
1 parent 85ab6ec commit 7995070

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

Source/Entities/Activity.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,17 @@ int Activity::Start() {
313313
}
314314

315315
// Intentionally doing all players, all need controllers
316+
std::vector<int> playerControlled;
316317
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
317318
m_ViewState[player] = ViewState::Normal;
318319

319320
m_PlayerController[player].Reset();
320321
m_PlayerController[player].Create(Controller::CIM_PLAYER, player);
321322
m_PlayerController[player].SetTeam(m_Team[player]);
322323

324+
if (m_IsHuman[player]) {
325+
playerControlled.push_back(player);
326+
}
323327
m_MessageTimer[player].Reset();
324328

325329
if (int screenId = ScreenOfPlayer(player); screenId != -1) {
@@ -336,6 +340,8 @@ int Activity::Start() {
336340
}
337341
}
338342

343+
g_UInputMan.CheckMultiMouseKeyboardEnabled(playerControlled);
344+
339345
return 0;
340346
}
341347

Source/Managers/ActivityMan.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ void ActivityMan::ResumeActivity() {
330330
m_InActivity = true;
331331
m_ActivityNeedsResume = false;
332332

333+
std::vector<int> humanPlayers;
334+
for (int player = 0; player < MaxPlayerCount; player++) {
335+
if (m_Activity->PlayerHuman(player)) {
336+
humanPlayers.push_back(player);
337+
}
338+
}
339+
g_UInputMan.CheckMultiMouseKeyboardEnabled(humanPlayers);
333340
PauseActivity(false);
334341
g_TimerMan.PauseSim(false);
335342
g_PerformanceMan.ResetPerformanceTimings();

Source/Menus/ScenarioActivityConfigGUI.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,18 @@ bool ScenarioActivityConfigGUI::HandleInputEvents() {
426426
g_GUISound.BackButtonPressSound()->Play();
427427
SetEnabled(false);
428428
} else if (guiEvent.GetControl() == m_StartGameButton) {
429-
g_GUISound.ButtonPressSound()->Play();
430-
StartGame();
431-
SetEnabled(false);
432-
return true;
429+
// Make sure all players have known input devices if multimouse is enabled.
430+
std::vector humanPlayers = GetHumanPlayers();
431+
if (g_UInputMan.CheckMultiMouseKeyboardEnabled(humanPlayers) && g_UInputMan.AllPlayerInputDevicesKnown(humanPlayers)) {
432+
g_GUISound.ButtonPressSound()->Play();
433+
StartGame();
434+
SetEnabled(false);
435+
return true;
436+
} else {
437+
// TODO: Show message and device selection.
438+
g_GUISound.UserErrorSound()->Play();
439+
return false;
440+
}
433441
}
434442
} else if (guiEvent.GetType() == GUIEvent::Notification) {
435443
if (guiEvent.GetControl() == m_ActivityDifficultySlider) {
@@ -454,6 +462,21 @@ bool ScenarioActivityConfigGUI::HandleInputEvents() {
454462
return false;
455463
}
456464

465+
std::vector<int> ScenarioActivityConfigGUI::GetHumanPlayers() {
466+
std::vector<int> humanPlayers;
467+
for (int player = Players::PlayerOne; player < PlayerColumns::PlayerColumnCount; ++player) {
468+
for (int team = Activity::Teams::TeamOne; team < Activity::Teams::MaxTeamCount; ++team) {
469+
if (m_PlayerBoxes.at(player).at(team)->GetDrawType() == GUICollectionBox::Image) {
470+
if (player != PlayerColumns::PlayerCPU) {
471+
humanPlayers.push_back(player);
472+
break;
473+
}
474+
}
475+
}
476+
}
477+
return humanPlayers;
478+
}
479+
457480
void ScenarioActivityConfigGUI::Draw() {
458481
m_GUIControlManager->Draw();
459482

Source/Menus/ScenarioActivityConfigGUI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ namespace RTE {
101101
/// Fills each team's Tech ComboBox with all valid Tech DataModules.
102102
void PopulateTechComboBoxes();
103103

104+
/// Helper function for multimouse support. Creates a list of human controlled players.
105+
std::vector<int> GetHumanPlayers();
106+
104107
/// Resets the configuration screen to the selected Activity's default settings and enables/disables attribute settings accordingly, making the configuration screen ready for interaction.
105108
void ResetActivityConfigBox();
106109

0 commit comments

Comments
 (0)