Push backspace fonctionnel
This commit is contained in:
parent
06cd890506
commit
ff10207257
@ -759,14 +759,21 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
std::ostringstream ss;
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (m_charChanged && m_currentInputString.size() < 26) {
|
||||
m_currentInputString += m_inputChar;
|
||||
if (m_charChanged) {
|
||||
if (m_keyBackspace) {
|
||||
if (!m_currentInputString.empty()) {
|
||||
m_currentInputString.pop_back();
|
||||
}
|
||||
m_keyBackspace = false;
|
||||
}
|
||||
else if (m_currentInputString.size() < 26) {
|
||||
m_currentInputString += m_inputChar;
|
||||
}
|
||||
}
|
||||
|
||||
ss << m_currentInputString;
|
||||
m_charChanged = false;
|
||||
|
||||
|
||||
if (lobbyTime < onInterval) {
|
||||
ss << "_";
|
||||
}
|
||||
@ -794,6 +801,10 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
||||
|
||||
}
|
||||
|
||||
void Engine::SetLobbyUsername() {
|
||||
|
||||
}
|
||||
|
||||
void Engine::DisplayMainMenu() {
|
||||
GLint viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
@ -1691,50 +1702,19 @@ void Engine::KeyReleaseEvent(unsigned char key) {
|
||||
case 57: // Espace - Stop sauter
|
||||
m_keySpace = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::MouseMoveEvent(int x, int y) {
|
||||
if (m_gamestate == GameState::PLAY) {
|
||||
m_player.TurnLeftRight(x - (Width() / 2));
|
||||
m_player.TurnTopBottom(y - (Height() / 2));
|
||||
|
||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
||||
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
|
||||
// MouseMoveEvent, etc
|
||||
if (x == (Width() / 2) && y == (Height() / 2))
|
||||
return;
|
||||
}
|
||||
else if (m_gamestate == GameState::MAIN_MENU) {
|
||||
DisplayMainMenu();
|
||||
}
|
||||
else if (m_gamestate == GameState::OPTIONS) {
|
||||
float centerX = Width() * 0.5f;
|
||||
float centerY = Height() * 0.5f;
|
||||
float leftBar = centerX - Width() * 0.15f;
|
||||
float rightBar = centerX + Width() * 0.3f;
|
||||
|
||||
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
||||
m_volPrincipal = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
||||
m_volMusique = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
||||
m_volEffets = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
||||
m_volSensible = x - leftBar;
|
||||
}
|
||||
case 58: // Enter - comfirm input
|
||||
m_keyEnter = false;
|
||||
break;
|
||||
case 59: // backspace - remove char
|
||||
m_keyBackspace = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char Engine::SimulateKeyboard(unsigned char key) {
|
||||
switch (key) {
|
||||
case 0: // A
|
||||
if (!m_keyShift) { m_inputChar = 'a'; }
|
||||
if (!m_keyShift) { m_inputChar = 'a'; }
|
||||
else { m_inputChar = 'A'; }
|
||||
break;
|
||||
case 1: // B
|
||||
@ -1890,6 +1870,12 @@ char Engine::SimulateKeyboard(unsigned char key) {
|
||||
case 57: // SPACE
|
||||
m_inputChar = ' ';
|
||||
break;
|
||||
case 58: // ENTER
|
||||
m_keyEnter = true;
|
||||
break;
|
||||
case 59: // BACKSPACE
|
||||
m_keyBackspace = true;
|
||||
break;
|
||||
default:
|
||||
m_invalidChar = true;
|
||||
break;
|
||||
@ -1904,6 +1890,44 @@ char Engine::SimulateKeyboard(unsigned char key) {
|
||||
return m_inputChar;
|
||||
}
|
||||
|
||||
|
||||
void Engine::MouseMoveEvent(int x, int y) {
|
||||
if (m_gamestate == GameState::PLAY) {
|
||||
m_player.TurnLeftRight(x - (Width() / 2));
|
||||
m_player.TurnTopBottom(y - (Height() / 2));
|
||||
|
||||
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
|
||||
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
|
||||
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
|
||||
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
|
||||
// MouseMoveEvent, etc
|
||||
if (x == (Width() / 2) && y == (Height() / 2))
|
||||
return;
|
||||
}
|
||||
else if (m_gamestate == GameState::MAIN_MENU) {
|
||||
DisplayMainMenu();
|
||||
}
|
||||
else if (m_gamestate == GameState::OPTIONS) {
|
||||
float centerX = Width() * 0.5f;
|
||||
float centerY = Height() * 0.5f;
|
||||
float leftBar = centerX - Width() * 0.15f;
|
||||
float rightBar = centerX + Width() * 0.3f;
|
||||
|
||||
if (m_selectedOption == 0 && m_selectedOptAudioMainBar) {
|
||||
m_volPrincipal = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioMusicBar) {
|
||||
m_volMusique = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 0 && m_selectedOptAudioSfxBar) {
|
||||
m_volEffets = x - leftBar;
|
||||
}
|
||||
else if (m_selectedOption == 2 && m_selectedGameplaySensitivityBar) {
|
||||
m_volSensible = x - leftBar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||
m_mousemx = x;
|
||||
m_mousemy = y;
|
||||
|
@ -62,13 +62,16 @@ private:
|
||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||
|
||||
void DisplaySplashScreen();
|
||||
void DisplayLobbyMenu(float elapsedTime);
|
||||
|
||||
void DisplayMainMenu();
|
||||
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
|
||||
void DrawMainMenuButtons(float centerX, float centerY);
|
||||
void DrawSingleMultiButtons(float centerX, float centerY);
|
||||
|
||||
void DisplayLobbyMenu(float elapsedTime);
|
||||
void SetLobbyUsername();
|
||||
void SetLobbyServerAddress();
|
||||
|
||||
void DisplayOptionsMenu();
|
||||
void DisplayAudioMenu(float centerX, float centerY);
|
||||
void DisplayGraphicsMenu(float centerX, float centerY);
|
||||
@ -77,7 +80,6 @@ private:
|
||||
void DisplayBarPercentValue(float centerX, float centerY, float posX, float posY, float minVal, float maxVal, float value);
|
||||
void DrawSlider(float centerX, float centerY, float value, float minVal, float maxVal, float bottomSideValue, float topSideValue);
|
||||
|
||||
|
||||
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||
void ProcessNotificationQueue();
|
||||
char SimulateKeyboard(unsigned char key);
|
||||
@ -207,6 +209,8 @@ private:
|
||||
char m_inputChar = 0;
|
||||
bool m_invalidChar = false;
|
||||
bool m_charChanged = false;
|
||||
bool m_settingUsername = false;
|
||||
bool m_settingServer = false;
|
||||
|
||||
bool m_key1 = false;
|
||||
bool m_key2 = false;
|
||||
@ -219,6 +223,7 @@ private:
|
||||
bool m_keyEnter = false;
|
||||
bool m_keySpace = false;
|
||||
bool m_keyShift = false;
|
||||
bool m_keyBackspace = false;
|
||||
|
||||
bool m_mouseL = false;
|
||||
bool m_mouseR = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user