From 858b1e35aed8b3a37f138138910327f7259d1251 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 3 Oct 2012 00:29:59 +0200 Subject: Spot light angle fix --- src/object/object.cpp | 4 ++-- src/object/task/taskbuild.cpp | 3 +-- src/object/task/taskshield.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/object') diff --git a/src/object/object.cpp b/src/object/object.cpp index ec8b3c5..77a7c25 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -2264,7 +2264,7 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color) light.attenuation0 = 1.0f; light.attenuation1 = 0.0f; light.attenuation2 = 0.0f; - light.spotAngle = 90; + light.spotAngle = 90.0f*Math::PI/180.0f; m_shadowLight = m_lightMan->CreateLight(); if ( m_shadowLight == -1 ) return false; @@ -2307,7 +2307,7 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color) light.attenuation0 = 1.0f; light.attenuation1 = 0.0f; light.attenuation2 = 0.0f; - light.spotAngle = 90; + light.spotAngle = 90.0f*Math::PI/180.0f; m_effectLight = m_lightMan->CreateLight(); if ( m_effectLight == -1 ) return false; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index 469e9cb..d82874c 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -153,8 +153,7 @@ void CTaskBuild::CreateLight() light.attenuation0 = 1.0f; light.attenuation1 = 0.0f; light.attenuation2 = 0.0f; - //TODO Is this value correct - light.spotAngle = 90; + light.spotAngle = 90.0f*Math::PI/180.0f; m_lightMan->SetLight(m_lightRank[i], light); color.r = -1.0f; diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp index 682bcb1..93afd62 100644 --- a/src/object/task/taskshield.cpp +++ b/src/object/task/taskshield.cpp @@ -499,7 +499,7 @@ bool CTaskShield::CreateLight(Math::Vector pos) light.attenuation0 = 1.0f; light.attenuation1 = 0.0f; light.attenuation2 = 0.0f; - light.spotAngle = 90; + light.spotAngle = 90.0f*Math::PI/180.0f; m_effectLight = m_lightMan->CreateLight(); if ( m_effectLight == -1 ) return false; -- cgit v1.2.3-1-g7c22 From 37302a2504811bf410b2485dbf65d5dedd8ba164 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 5 Oct 2012 15:26:24 +0200 Subject: CLightning rewrite --- src/object/object.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/object') diff --git a/src/object/object.cpp b/src/object/object.cpp index 77a7c25..5a1631f 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -2995,7 +2995,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height, m_character.posPower = Math::Vector(5.0f, 3.0f, 0.0f); CreateShadowCircle(6.0f, 1.0f); - m_showLimitRadius = Gfx::BLITZPARA; + m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS; } if ( m_type == OBJECT_NUCLEAR ) @@ -3048,7 +3048,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height, SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f); CreateShadowCircle(21.0f, 1.0f); - m_showLimitRadius = Gfx::BLITZPARA; + m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS; } if ( m_type == OBJECT_SAFE ) -- cgit v1.2.3-1-g7c22 From b5a7708f992d6b51790a574bbaced5a06012f459 Mon Sep 17 00:00:00 2001 From: adiblol Date: Fri, 5 Oct 2012 20:37:20 +0200 Subject: Refactoring: changed UNIT to g_unit in CRobotMain class --- src/object/robotmain.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/object') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 226bd57..82eac2b 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -730,7 +730,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app) g_build = 0; g_researchDone = 0; // no research done g_researchEnable = 0; - g_unit = 4.0f; + g_unit = UNIT; m_gamerName[0] = 0; /* TODO: profile @@ -3889,8 +3889,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "DeepView") && !resetObject) { - m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*UNIT, 0, true); - m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*UNIT, 1, true); + m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*g_unit, 0, true); + m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*g_unit, 1, true); } if (Cmd(line, "FogStart") && !resetObject) @@ -3951,7 +3951,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_terrain->Generate(OpInt(line, "mosaic", 20), OpInt(line, "brick", 3), OpFloat(line, "size", 20.0f), - OpFloat(line, "vision", 500.0f)*UNIT, + OpFloat(line, "vision", 500.0f)*g_unit, OpInt(line, "depth", 2), OpFloat(line, "hard", 0.5f)); } @@ -3983,7 +3983,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) name, OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpFloat(line, "level", 100.0f)*UNIT, + OpFloat(line, "level", 100.0f)*g_unit, OpFloat(line, "glint", 1.0f), pos); m_colorNewWater = OpColor(line, "color", m_colorRefWater); @@ -3999,14 +3999,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_cloud->Create(name, OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpFloat(line, "level", 500.0f) * UNIT); + OpFloat(line, "level", 500.0f) * g_unit); } if (Cmd(line, "TerrainBlitz") && !resetObject) { m_lightning->Create(OpFloat(line, "sleep", 0.0f), OpFloat(line, "delay", 3.0f), - OpFloat(line, "magnetic", 50.0f) * UNIT); + OpFloat(line, "magnetic", 50.0f) * g_unit); } if (Cmd(line, "TerrainInitTextures") && !resetObject) @@ -4059,8 +4059,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } m_terrain->GenerateMaterials(id, - OpFloat(line, "min", 0.0f)*UNIT, - OpFloat(line, "max", 100.0f)*UNIT, + OpFloat(line, "min", 0.0f)*g_unit, + OpFloat(line, "max", 100.0f)*g_unit, OpFloat(line, "slope", 5.0f), OpFloat(line, "freq", 100.0f), OpPos(line, "center")*g_unit, -- cgit v1.2.3-1-g7c22 From 7818d5d0963f6e57540b1abdf83408ea6009c296 Mon Sep 17 00:00:00 2001 From: adiblol Date: Sat, 6 Oct 2012 23:35:27 +0200 Subject: Setting speed now works. Added ability to set 4x and 8x using "speed4" and "speed8" cheat codes respectively. --- src/object/robotmain.cpp | 28 +++++++++++++++++++++++----- src/object/robotmain.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src/object') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 82eac2b..1a8c934 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1956,6 +1956,17 @@ void CRobotMain::ExecuteCmd(char *cmd) return; } + if (strcmp(cmd, "speed4") == 0) { + SetSpeed(4.0f); + UpdateSpeedLabel(); + return; + } + if (strcmp(cmd, "speed8") == 0) { + SetSpeed(8.0f); + UpdateSpeedLabel(); + return; + } + if (m_phase == PHASE_SIMUL) m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f)); } @@ -6615,9 +6626,20 @@ void CRobotMain::ChangePause(bool pause) //! Changes game speed void CRobotMain::SetSpeed(float speed) { - // TODO: m_app->SetSimulationSpeed(speed); + m_app->SetSimulationSpeed(speed); + UpdateSpeedLabel(); +} + +float CRobotMain::GetSpeed() +{ + return m_app->GetSimulationSpeed(); +} +void CRobotMain::UpdateSpeedLabel() +{ Ui::CButton* pb = dynamic_cast(m_interface->SearchControl(EVENT_SPEED)); + float speed = m_app->GetSimulationSpeed(); + if (pb != nullptr) { if (speed == 1.0f) @@ -6632,11 +6654,7 @@ void CRobotMain::SetSpeed(float speed) pb->SetState(Ui::STATE_VISIBLE); } } -} -float CRobotMain::GetSpeed() -{ - return m_app->GetSimulationSpeed(); } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 70fbc8d..dddd6d4 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -383,6 +383,7 @@ protected: void StopDisplayVisit(); void ExecuteCmd(char *cmd); bool TestGadgetQuantity(int rank); + void UpdateSpeedLabel(); protected: CInstanceManager* m_iMan; -- cgit v1.2.3-1-g7c22 From 97f44035f1b3ebd2681236c23f14c4d3ea7f09ac Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 7 Oct 2012 00:46:46 +0200 Subject: Changing and saving input bindings --- src/object/brain.cpp | 4 +- src/object/robotmain.cpp | 210 +++++++++++++++++++++++------------------------ src/object/robotmain.h | 10 +-- 3 files changed, 112 insertions(+), 112 deletions(-) (limited to 'src/object') diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 7b580d7..5403903 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -203,8 +203,8 @@ bool CBrain::EventProcess(const Event &event) action = EVENT_NULL; if ( event.type == EVENT_KEY_DOWN && - (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).key || - event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).joy ) && + (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).primary || + event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).secondary ) && !m_main->GetEditLock() ) { pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1a8c934..954d676 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -878,7 +878,7 @@ void CRobotMain::SetDefaultInputBindings() { for (int i = 0; i < INPUT_SLOT_MAX; i++) { - m_inputBindings[i].key = m_inputBindings[i].joy = KEY_INVALID; + m_inputBindings[i].primary = m_inputBindings[i].secondary = KEY_INVALID; } for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++) @@ -887,34 +887,34 @@ void CRobotMain::SetDefaultInputBindings() m_joyAxisBindings[i].invert = false; } - m_inputBindings[INPUT_SLOT_LEFT ].key = KEY(LEFT); - m_inputBindings[INPUT_SLOT_RIGHT ].key = KEY(RIGHT); - m_inputBindings[INPUT_SLOT_UP ].key = KEY(UP); - m_inputBindings[INPUT_SLOT_DOWN ].key = KEY(DOWN); - m_inputBindings[INPUT_SLOT_GUP ].key = VIRTUAL_KMOD(SHIFT); - m_inputBindings[INPUT_SLOT_GDOWN ].key = VIRTUAL_KMOD(CTRL); - m_inputBindings[INPUT_SLOT_CAMERA ].key = KEY(SPACE); - m_inputBindings[INPUT_SLOT_CAMERA ].joy = VIRTUAL_JOY(2); - m_inputBindings[INPUT_SLOT_DESEL ].key = KEY(KP0); - m_inputBindings[INPUT_SLOT_DESEL ].joy = VIRTUAL_JOY(6); - m_inputBindings[INPUT_SLOT_ACTION ].key = KEY(RETURN); - m_inputBindings[INPUT_SLOT_ACTION ].joy = VIRTUAL_JOY(1); - m_inputBindings[INPUT_SLOT_NEAR ].key = KEY(KP_PLUS); - m_inputBindings[INPUT_SLOT_NEAR ].joy = VIRTUAL_JOY(5); - m_inputBindings[INPUT_SLOT_AWAY ].key = KEY(KP_MINUS); - m_inputBindings[INPUT_SLOT_AWAY ].joy = VIRTUAL_JOY(4); - m_inputBindings[INPUT_SLOT_NEXT ].key = KEY(TAB); - m_inputBindings[INPUT_SLOT_NEXT ].joy = VIRTUAL_JOY(3); - m_inputBindings[INPUT_SLOT_HUMAN ].key = KEY(HOME); - m_inputBindings[INPUT_SLOT_HUMAN ].joy = VIRTUAL_JOY(7); - m_inputBindings[INPUT_SLOT_QUIT ].key = KEY(ESCAPE); - m_inputBindings[INPUT_SLOT_HELP ].key = KEY(F1); - m_inputBindings[INPUT_SLOT_PROG ].key = KEY(F2); - m_inputBindings[INPUT_SLOT_CBOT ].key = KEY(F3); - m_inputBindings[INPUT_SLOT_VISIT ].key = KEY(KP_PERIOD); - m_inputBindings[INPUT_SLOT_SPEED10].key = KEY(F4); - m_inputBindings[INPUT_SLOT_SPEED15].key = KEY(F5); - m_inputBindings[INPUT_SLOT_SPEED20].key = KEY(F6); + m_inputBindings[INPUT_SLOT_LEFT ].primary = KEY(LEFT); + m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT); + m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP); + m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN); + m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT); + m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL); + m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE); + m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2); + m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0); + m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6); + m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN); + m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1); + m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS); + m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5); + m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS); + m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4); + m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB); + m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3); + m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME); + m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7); + m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE); + m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1); + m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2); + m_inputBindings[INPUT_SLOT_CBOT ].primary = KEY(F3); + m_inputBindings[INPUT_SLOT_VISIT ].primary = KEY(KP_PERIOD); + m_inputBindings[INPUT_SLOT_SPEED10].primary = KEY(F4); + m_inputBindings[INPUT_SLOT_SPEED15].primary = KEY(F5); + m_inputBindings[INPUT_SLOT_SPEED20].primary = KEY(F6); m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0; m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1; @@ -1214,33 +1214,33 @@ bool CRobotMain::EventProcess(Event &event) if (event.type == EVENT_KEY_DOWN) { - if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = -1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = -1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = -1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = -1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = -1.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = -1.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = -1.0f; } else if (event.type == EVENT_KEY_UP) { - if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = 0.0f; - if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = 0.0f; + if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = 0.0f; } else if (event.type == EVENT_JOY_AXIS) { @@ -1356,10 +1356,10 @@ bool CRobotMain::EventProcess(Event &event) if (event.type == EVENT_KEY_DOWN) { - if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || - event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy || - event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || - event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy || + if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary || + event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary || + event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary || + event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary || event.key.key == KEY(ESCAPE)) { StopDisplayInfo(); @@ -1394,14 +1394,14 @@ bool CRobotMain::EventProcess(Event &event) } if (m_editLock) // current edition? { - if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || - event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary || + event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary) { StartDisplayInfo(SATCOM_HUSTON, false); return false; } - if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || - event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary || + event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary) { StartDisplayInfo(SATCOM_PROG, false); return false; @@ -1410,8 +1410,8 @@ bool CRobotMain::EventProcess(Event &event) } if (m_movieLock) // current movie? { - if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || - event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy || + if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary || event.key.key == KEY(ESCAPE)) { AbortMovie(); @@ -1420,21 +1420,21 @@ bool CRobotMain::EventProcess(Event &event) } if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT) { - if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key || - event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary) { StartDisplayVisit(EVENT_NULL); } - if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || - event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy || + if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary || event.key.key == KEY(ESCAPE)) { StopDisplayVisit(); } return false; } - if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || - event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary) { if (m_movie->IsExist()) StartDisplayInfo(SATCOM_HUSTON, false); @@ -1454,55 +1454,55 @@ bool CRobotMain::EventProcess(Event &event) ChangePause(!m_engine->GetPause()); } } - if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).key || - event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary || + event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).secondary) { ChangeCamera(); } - if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).key || - event.key.key == GetInputBinding(INPUT_SLOT_DESEL).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).primary || + event.key.key == GetInputBinding(INPUT_SLOT_DESEL).secondary) { if (m_shortCut) DeselectObject(); } - if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).key || - event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).primary || + event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).secondary) { SelectHuman(); } - if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).key || - event.key.key == GetInputBinding(INPUT_SLOT_NEXT).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_NEXT).secondary) { if (m_shortCut) m_short->SelectNext(); } - if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || - event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary || + event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary) { StartDisplayInfo(SATCOM_HUSTON, true); } - if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || - event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary || + event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary) { StartDisplayInfo(SATCOM_PROG, true); } - if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key || - event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary || + event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary) { StartDisplayVisit(EVENT_NULL); } - if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).key || - event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).primary || + event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).secondary) { SetSpeed(1.0f); } - if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).key || - event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).primary || + event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).secondary) { SetSpeed(1.5f); } - if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).key || - event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).joy) + if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).primary || + event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).secondary) { SetSpeed(2.0f); } @@ -3109,26 +3109,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key) if (type == EVENT_KEY_UP) { - if (key == GetInputBinding(INPUT_SLOT_LEFT).key || - key == GetInputBinding(INPUT_SLOT_LEFT).joy) + if (key == GetInputBinding(INPUT_SLOT_LEFT).primary || + key == GetInputBinding(INPUT_SLOT_LEFT).secondary) { m_cameraPan = 0.0f; } - if (key == GetInputBinding(INPUT_SLOT_RIGHT).key || - key == GetInputBinding(INPUT_SLOT_RIGHT).joy) + if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary || + key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) { m_cameraPan = 0.0f; } - if (key == GetInputBinding(INPUT_SLOT_UP).key || - key == GetInputBinding(INPUT_SLOT_UP).joy) + if (key == GetInputBinding(INPUT_SLOT_UP).primary || + key == GetInputBinding(INPUT_SLOT_UP).secondary) { m_cameraZoom = 0.0f; } - if (key == GetInputBinding(INPUT_SLOT_DOWN).key || - key == GetInputBinding(INPUT_SLOT_DOWN).joy) + if (key == GetInputBinding(INPUT_SLOT_DOWN).primary || + key == GetInputBinding(INPUT_SLOT_DOWN).secondary) { m_cameraZoom = 0.0f; } @@ -3144,26 +3144,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key) if (type == EVENT_KEY_DOWN) { - if (key == GetInputBinding(INPUT_SLOT_LEFT).key || - key == GetInputBinding(INPUT_SLOT_LEFT).joy) + if (key == GetInputBinding(INPUT_SLOT_LEFT).primary || + key == GetInputBinding(INPUT_SLOT_LEFT).secondary) { m_cameraPan = -1.0f; } - if (key == GetInputBinding(INPUT_SLOT_RIGHT).key || - key == GetInputBinding(INPUT_SLOT_RIGHT).joy) + if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary || + key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) { m_cameraPan = 1.0f; } - if (key == GetInputBinding(INPUT_SLOT_UP).key || - key == GetInputBinding(INPUT_SLOT_UP).joy) + if (key == GetInputBinding(INPUT_SLOT_UP).primary || + key == GetInputBinding(INPUT_SLOT_UP).secondary) { m_cameraZoom = -1.0f; } - if (key == GetInputBinding(INPUT_SLOT_DOWN).key || - key == GetInputBinding(INPUT_SLOT_DOWN).joy) + if (key == GetInputBinding(INPUT_SLOT_DOWN).primary || + key == GetInputBinding(INPUT_SLOT_DOWN).secondary) { m_cameraZoom = 1.0f; } diff --git a/src/object/robotmain.h b/src/object/robotmain.h index dddd6d4..e475c43 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -148,12 +148,12 @@ const int SATCOM_MAX = 6; */ struct InputBinding { - //! Keyboard binding code (can be regular or virtual) - unsigned int key; - //! Joystick binding code (virtual) - unsigned int joy; + //! Primary and secondary bindings + //! Can be regular key, virtual key or virtual joystick button + unsigned int primary, secondary; - InputBinding() : key(KEY_INVALID), joy(KEY_INVALID) {} + InputBinding(unsigned int p = KEY_INVALID, unsigned int s = KEY_INVALID) + : primary(p), secondary(s) {} }; /** -- cgit v1.2.3-1-g7c22