Push backspace fonctionnel
This commit is contained in:
parent
06cd890506
commit
ff10207257
@ -759,14 +759,21 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
|||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
if (m_charChanged && m_currentInputString.size() < 26) {
|
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;
|
m_currentInputString += m_inputChar;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ss << m_currentInputString;
|
ss << m_currentInputString;
|
||||||
m_charChanged = false;
|
m_charChanged = false;
|
||||||
|
|
||||||
|
|
||||||
if (lobbyTime < onInterval) {
|
if (lobbyTime < onInterval) {
|
||||||
ss << "_";
|
ss << "_";
|
||||||
}
|
}
|
||||||
@ -794,6 +801,10 @@ void Engine::DisplayLobbyMenu(float elapsedTime) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::SetLobbyUsername() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::DisplayMainMenu() {
|
void Engine::DisplayMainMenu() {
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
@ -1691,43 +1702,12 @@ void Engine::KeyReleaseEvent(unsigned char key) {
|
|||||||
case 57: // Espace - Stop sauter
|
case 57: // Espace - Stop sauter
|
||||||
m_keySpace = false;
|
m_keySpace = false;
|
||||||
break;
|
break;
|
||||||
}
|
case 58: // Enter - comfirm input
|
||||||
}
|
m_keyEnter = false;
|
||||||
|
break;
|
||||||
void Engine::MouseMoveEvent(int x, int y) {
|
case 59: // backspace - remove char
|
||||||
if (m_gamestate == GameState::PLAY) {
|
m_keyBackspace = false;
|
||||||
m_player.TurnLeftRight(x - (Width() / 2));
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1890,6 +1870,12 @@ char Engine::SimulateKeyboard(unsigned char key) {
|
|||||||
case 57: // SPACE
|
case 57: // SPACE
|
||||||
m_inputChar = ' ';
|
m_inputChar = ' ';
|
||||||
break;
|
break;
|
||||||
|
case 58: // ENTER
|
||||||
|
m_keyEnter = true;
|
||||||
|
break;
|
||||||
|
case 59: // BACKSPACE
|
||||||
|
m_keyBackspace = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_invalidChar = true;
|
m_invalidChar = true;
|
||||||
break;
|
break;
|
||||||
@ -1904,6 +1890,44 @@ char Engine::SimulateKeyboard(unsigned char key) {
|
|||||||
return m_inputChar;
|
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) {
|
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
|
||||||
m_mousemx = x;
|
m_mousemx = x;
|
||||||
m_mousemy = y;
|
m_mousemy = y;
|
||||||
|
@ -62,13 +62,16 @@ private:
|
|||||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||||
|
|
||||||
void DisplaySplashScreen();
|
void DisplaySplashScreen();
|
||||||
void DisplayLobbyMenu(float elapsedTime);
|
|
||||||
|
|
||||||
void DisplayMainMenu();
|
void DisplayMainMenu();
|
||||||
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
|
void DrawButtonBackgrounds(float centerX, float centerY, int iterations);
|
||||||
void DrawMainMenuButtons(float centerX, float centerY);
|
void DrawMainMenuButtons(float centerX, float centerY);
|
||||||
void DrawSingleMultiButtons(float centerX, float centerY);
|
void DrawSingleMultiButtons(float centerX, float centerY);
|
||||||
|
|
||||||
|
void DisplayLobbyMenu(float elapsedTime);
|
||||||
|
void SetLobbyUsername();
|
||||||
|
void SetLobbyServerAddress();
|
||||||
|
|
||||||
void DisplayOptionsMenu();
|
void DisplayOptionsMenu();
|
||||||
void DisplayAudioMenu(float centerX, float centerY);
|
void DisplayAudioMenu(float centerX, float centerY);
|
||||||
void DisplayGraphicsMenu(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 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 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 PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||||
void ProcessNotificationQueue();
|
void ProcessNotificationQueue();
|
||||||
char SimulateKeyboard(unsigned char key);
|
char SimulateKeyboard(unsigned char key);
|
||||||
@ -207,6 +209,8 @@ private:
|
|||||||
char m_inputChar = 0;
|
char m_inputChar = 0;
|
||||||
bool m_invalidChar = false;
|
bool m_invalidChar = false;
|
||||||
bool m_charChanged = false;
|
bool m_charChanged = false;
|
||||||
|
bool m_settingUsername = false;
|
||||||
|
bool m_settingServer = false;
|
||||||
|
|
||||||
bool m_key1 = false;
|
bool m_key1 = false;
|
||||||
bool m_key2 = false;
|
bool m_key2 = false;
|
||||||
@ -219,6 +223,7 @@ private:
|
|||||||
bool m_keyEnter = false;
|
bool m_keyEnter = false;
|
||||||
bool m_keySpace = false;
|
bool m_keySpace = false;
|
||||||
bool m_keyShift = false;
|
bool m_keyShift = false;
|
||||||
|
bool m_keyBackspace = false;
|
||||||
|
|
||||||
bool m_mouseL = false;
|
bool m_mouseL = false;
|
||||||
bool m_mouseR = false;
|
bool m_mouseR = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user