Skip to content

Commit 412a844

Browse files
committed
Lots of fixes.
1 parent 12bd6de commit 412a844

7 files changed

Lines changed: 15 additions & 11 deletions

File tree

client/source/ClientApplication.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void ClientApplication::init() {
2727

2828
m_window.create(sf::VideoMode(Config::screenWidth, Config::screenHeight), "R-Type", sf::Style::Close);
2929

30+
m_keyboardHandler.loadKeysFromFile("resources/config/keys.xml");
3031
gk::GamePad::init(m_keyboardHandler);
3132

3233
m_resourceHandler.loadConfigFile<AudioLoader>("resources/config/audio.xml");

client/source/graphics/Button.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Button::Button(const std::string &text) {
2525
m_text.setCharacterSize(25);
2626
m_text.setString(text);
2727
m_text.setPosition(m_image.width() / 2.0f - m_text.getLocalBounds().width / 2.0f,
28-
m_image.height() / 2.0f - m_text.getLocalBounds().height / 2.0f);
28+
m_image.height() / 2.0f - m_text.getLocalBounds().height / 2.0f - 4);
2929
}
3030

3131
Button::Button(const std::string &text, int posX, int posY) : Button(text) {
@@ -44,12 +44,12 @@ void Button::onEvent(const sf::Event &event) {
4444
sf::IntRect rect{{(int)getPosition().x, (int)getPosition().y}, {m_image.width(), m_image.height()}};
4545
if (event.type == sf::Event::MouseButtonPressed) {
4646
if (event.mouseButton.button == sf::Mouse::Left)
47-
m_isPressed = gk::Mouse::isInRect(rect);
47+
m_isPressed = rect.contains(event.mouseButton.x, event.mouseButton.y);
4848
}
4949

5050
if (m_isPressed && event.type == sf::Event::MouseButtonReleased) {
5151
if (event.mouseButton.button == sf::Mouse::Left) {
52-
m_hasReleased = gk::Mouse::isInRect(rect);
52+
m_hasReleased = rect.contains(event.mouseButton.x, event.mouseButton.y);
5353
m_isPressed = false;
5454

5555
if (m_hasReleased)

client/source/graphics/TextInput.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ void TextInput::setSize(u16 width, u16 height) {
3838
}
3939

4040
void TextInput::onEvent(const sf::Event &event) {
41-
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Backspace && !m_content.empty()) {
42-
m_content.erase(m_content.begin() + m_content.length() - 1);
43-
gk::AudioPlayer::playSound("sound-keyboard");
44-
45-
m_text.setString(m_content + "|");
46-
}
41+
// if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Backspace && !m_content.empty()) {
42+
// m_content.erase(m_content.begin() + m_content.length() - 1);
43+
// gk::AudioPlayer::playSound("sound-keyboard");
44+
//
45+
// m_text.setString(m_content + "|");
46+
// }
4747

4848
// if (event.type == SDL_TEXTINPUT) {
4949
// std::string text = event.text.text;

client/source/states/GameEndState.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ GameEndState::GameEndState(bool isWinner) {
3232
m_leave.setPosition(Config::screenWidth / 2.0f - m_leave.width() / 2.0, 240);
3333
m_exit.setPosition(Config::screenWidth / 2.0f - m_exit.width() / 2.0, 240 + m_exit.height() + 20);
3434

35+
gk::AudioPlayer::pauseMusic();
3536
gk::AudioPlayer::playMusic(isWinner ? "music-victory" : "music-gameover");
3637
}
3738

client/source/states/GameState.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
GameState::GameState(const sf::IpAddress &serverAddress, u16 serverPort) {
2828
m_client.connect(serverAddress, serverPort);
2929

30+
gk::AudioPlayer::pauseMusic();
3031
gk::AudioPlayer::playMusic("music-game");
3132

3233
m_background2.setPosition(m_background.width() - 2.0f, 0);

client/source/states/TitleScreenState.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ TitleScreenState::TitleScreenState() {
3232
m_play.setPosition(Config::screenWidth / 2.0f - m_play.width() / 2.0, 240);
3333
m_exit.setPosition(Config::screenWidth / 2.0f - m_exit.width() / 2.0, 240 + m_exit.height() + 20);
3434

35+
gk::AudioPlayer::pauseMusic();
3536
gk::AudioPlayer::playMusic("music-theme");
3637
}
3738

resources/config/keys.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Key names are defined here: https://wiki.libsdl.org/SDL_Keycode -->
1+
<!-- Key names are defined here: https://www.sfml-dev.org/documentation/2.5.1-fr/classsf_1_1Keyboard.php#acb4cacd7cc5802dec45724cf3314a142 -->
22
<keys>
33
<Left key="Left"/>
44
<Right key="Right"/>
@@ -9,5 +9,5 @@
99
<B key="W"/>
1010

1111
<Start key="Return"/>
12-
<Select key="Backspace"/>
12+
<Select key="BackSpace"/>
1313
</keys>

0 commit comments

Comments
 (0)