Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes & Cleanup #120

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1246dc2
Bugfixes & Cleanup
BrentDaMage Apr 17, 2024
44dd588
Fixed incomplete "Texture::field_C" to "Texture::m_hasAlpha" rename
BrentDaMage Apr 17, 2024
faeb113
Bugfixes for Windows SDL2 Visual Studio compilation
BrentDaMage Apr 17, 2024
6f6dc66
Added Panorama Toggle
BrentDaMage Apr 20, 2024
8005f60
Documentation & Decompilation
BrentDaMage Apr 22, 2024
2331caa
Partial Network Protocol v3 Support
BrentDaMage Apr 28, 2024
77562ff
Documentation & More Backporting
BrentDaMage Apr 29, 2024
e1734d4
Minor Additions
BrentDaMage Apr 29, 2024
80d56f4
Fix typo in CMakeLists.txt
BrentDaMage Apr 29, 2024
becd1fe
Survival Mode Bugfixes
BrentDaMage Apr 30, 2024
e8d83fe
Cleanup
BrentDaMage May 2, 2024
e22ee57
Fix un-renamed Texture.m_hasAlpha that loved to hang around for some …
BrentDaMage May 5, 2024
7f63d78
Fixed minor bugs that gave compile errors :(
BrentDaMage May 5, 2024
8fc8a38
Updated .gitignore for 0.7.0 assets
BrentDaMage May 6, 2024
8ac4093
* Fixed cloud scroll speed
BrentDaMage May 7, 2024
04ef855
macOS & iOS Bugfixes
BrentDaMage May 7, 2024
b566faf
* Added /summon command
BrentDaMage May 9, 2024
616ac37
Bugfixes & Cleanup
BrentDaMage May 11, 2024
745c790
Standardized coordinate structs
BrentDaMage Jun 19, 2024
6e55bc9
* Fixed various PR issues
BrentDaMage Jul 21, 2024
b7a35aa
Fixed instance of VS rename feature being braindamaged
BrentDaMage Jul 21, 2024
a6a9112
* Removed Facing.cpp
BrentDaMage Jul 21, 2024
01a8608
Minor fixes in Entity and ControllerMoveInput
BrentDaMage Jul 21, 2024
256d7a4
Fixed Mob travel bug
BrentDaMage Jul 21, 2024
acca80c
Remove Facing.cpp from CMakeLists.txt
BrentDaMage Jul 21, 2024
46c83a5
Fix Level::getCubes ambiguous TilePos constructor call
BrentDaMage Jul 21, 2024
7656781
Fixed various bugs & building for macOS + iOS
BrentDaMage Jul 22, 2024
84affa5
Minor compatibility bugfixes
BrentDaMage Jul 23, 2024
c798f79
Fixed Xcode project settings
BrentDaMage Jul 23, 2024
dfa73f8
Additional nullptr #ifndef check
BrentDaMage Jul 23, 2024
411ee02
Documentation + Bug Fixes
BrentDaMage Aug 7, 2024
c725488
Fixed PR stuff
BrentDaMage Aug 7, 2024
5a1a99c
Visual Improvements
BrentDaMage Sep 11, 2024
daabf48
Xcode & Mobile Bugfixes
BrentDaMage Sep 12, 2024
5b2da61
Minor Fixes
BrentDaMage Sep 12, 2024
4839ebd
Update CMakeLists.txt
BrentDaMage Sep 12, 2024
e0b986d
Merge branch 'master' into bugfix-cleanup
BrentDaMage Oct 17, 2024
0d01899
Update TextInputBox.hpp
BrentDaMage Oct 17, 2024
215f918
Update Screen.cpp
BrentDaMage Oct 17, 2024
dc63b0d
Update TextInputBox.hpp
BrentDaMage Oct 17, 2024
5da6f3d
Update TextInputBox.cpp
BrentDaMage Oct 17, 2024
0ce830d
Update TextInputBox.cpp
BrentDaMage Oct 17, 2024
6f66cdd
Update TextInputBox.cpp
BrentDaMage Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ xcuserdata/
/game/assets/gui/feedback_fill.png
/game/assets/gui/feedback_outer.png
/game/assets/snow.png
# Ignore all native iOS UI assets.
/game/assets/app/ios/
# 0.7.0
/game/assets/armor/chain_1.png
/game/assets/armor/chain_2.png
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion platforms/android/AppPlatform_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void AppPlatform_android::initSoundSystem()
LOG_E("Trying to initialize SoundSystem more than once!");
}

bool AppPlatform_android::isTouchscreen()
bool AppPlatform_android::isTouchscreen() const
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/AppPlatform_android.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AppPlatform_android : public AppPlatform

SoundSystem* const getSoundSystem() const override;
void initSoundSystem() override;
bool isTouchscreen() override;
bool isTouchscreen() const override;

void setScreenSize(int width, int height);
void initAndroidApp(android_app* ptr);
Expand Down
2 changes: 1 addition & 1 deletion platforms/ios/AppPlatform_iOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AppPlatform_iOS : public AppPlatform
int getScreenHeight() const override;
Texture loadTexture(const std::string& path, bool b = false) override;
int getUserInputStatus() override;
bool isTouchscreen() override;
bool isTouchscreen() const override;
std::string getAssetPath(const std::string &path) const override;
std::string getPatchData() override;
SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; }
Expand Down
2 changes: 1 addition & 1 deletion platforms/ios/AppPlatform_iOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
return -1;
}

bool AppPlatform_iOS::isTouchscreen()
bool AppPlatform_iOS::isTouchscreen() const
{
return true;
}
Expand Down
13 changes: 1 addition & 12 deletions platforms/openal/SoundSystemAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ SoundSystemAL::SoundSystemAL()
{
_initialized = false;
_listenerVolume = 1.0;
_audioMuted = false;

startEngine();
}
Expand Down Expand Up @@ -190,7 +189,7 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
return;
}

if (_audioMuted || volume <= 0.0f)
if (volume <= 0.0f)
return;

bool bIsGUI = AL_FALSE;
Expand Down Expand Up @@ -346,14 +345,4 @@ void SoundSystemAL::stopEngine()
_initialized = false;
}

void SoundSystemAL::muteAudio()
{
_audioMuted = true;
}

void SoundSystemAL::unMuteAudio()
{
_audioMuted = false;
}

#endif
3 changes: 0 additions & 3 deletions platforms/openal/SoundSystemAL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class SoundSystemAL : public SoundSystem

virtual void startEngine();
virtual void stopEngine();
virtual void muteAudio();
virtual void unMuteAudio();

private:
void delete_sources();
Expand All @@ -55,7 +53,6 @@ class SoundSystemAL : public SoundSystem

Vec3 _lastListenerPos;
float _listenerVolume;
bool _audioMuted;
};

#endif
126 changes: 118 additions & 8 deletions platforms/sdl/base/AppPlatform_sdl_base.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "AppPlatform_sdl_base.hpp"

#include <sstream>
#include <fstream>
#include <sys/stat.h>
#include <cstdlib>

#include "AppPlatform_sdl_base.hpp"

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#else
Expand All @@ -13,7 +13,9 @@

#include "common/Utils.hpp"

#include "platforms/openal/SoundSystemAL.hpp"
#include "SoundSystemAL.hpp"

#include "client/player/input/Controller.hpp"

void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window)
{
Expand Down Expand Up @@ -53,6 +55,9 @@ void AppPlatform_sdl_base::_init(std::string storageDir, SDL_Window *window)
m_bIsTouchscreen = false;
}
}

// Look for a pre-existing controller
_controller = findGameController();
}

void AppPlatform_sdl_base::initSoundSystem()
Expand Down Expand Up @@ -112,6 +117,17 @@ AppPlatform_sdl_base::~AppPlatform_sdl_base()
SAFE_DELETE(m_pLogger);
}

SDL_GameController* AppPlatform_sdl_base::findGameController()
{
for (int i = 0; i < SDL_NumJoysticks(); i++) {
if (SDL_IsGameController(i)) {
return SDL_GameControllerOpen(i);
}
}

return nullptr;
}

SDL_Surface* AppPlatform_sdl_base::getSurfaceForTexture(const Texture* const texture)
{
if (!texture) return nullptr;
Expand Down Expand Up @@ -233,9 +249,9 @@ int AppPlatform_sdl_base::getUserInputStatus()
return -1;
}

MouseButtonType AppPlatform_sdl_base::GetMouseButtonType(SDL_Event event)
MouseButtonType AppPlatform_sdl_base::GetMouseButtonType(SDL_MouseButtonEvent event)
{
switch (event.button.button)
switch (event.button)
{
case SDL_BUTTON_LEFT:
return BUTTON_LEFT;
Expand Down Expand Up @@ -283,9 +299,9 @@ bool AppPlatform_sdl_base::GetMouseButtonState(SDL_Event event)
return result;
}

Keyboard::KeyState AppPlatform_sdl_base::GetKeyState(SDL_Event event)
Keyboard::KeyState AppPlatform_sdl_base::GetKeyState(uint8_t state)
{
switch (event.key.state)
switch (state)
{
case SDL_RELEASED:
return Keyboard::UP;
Expand Down Expand Up @@ -318,6 +334,100 @@ void AppPlatform_sdl_base::hideKeyboard()
}
}

bool AppPlatform_sdl_base::isTouchscreen() {
bool AppPlatform_sdl_base::isTouchscreen() const
{
return m_bIsTouchscreen;
}

bool AppPlatform_sdl_base::hasGamepad() const
{
return _controller != nullptr;
}

void AppPlatform_sdl_base::gameControllerAdded(int32_t index)
{
if (!getPrimaryGameController())
{
setPrimaryGameController(SDL_GameControllerOpen(index));
Controller::reset();
}
}

void AppPlatform_sdl_base::gameControllerRemoved(int32_t index)
{
SDL_GameController* controller = getPrimaryGameController();
SDL_JoystickID joystickId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller));
// Check if current controller has been removed
if (controller && index == joystickId)
{
SDL_GameControllerClose(controller);
// Hunt for a new primary controller
setPrimaryGameController(findGameController());
}
}

void AppPlatform_sdl_base::handleKeyEvent(int key, uint8_t state)
{
// This really should be handled somewhere else.
// Unforunately, there is no global keyboard handler.
// Keyboard events are either handled in Screen::keyboardEvent
// when a Screen is visible, or in Minecraft::tickInput
// when LocalPlayer exists.
switch (key)
{
case SDLVK_F2:
if (state == SDL_PRESSED)
saveScreenshot("", -1, -1);
return;
case SDLVK_AC_BACK:
// Android Back Button
// @TODO: handleBack function in AppPlatform that calls back to App via function pointer
//g_pApp->handleBack(event.key.state == SDL_PRESSED);
BrentDaMage marked this conversation as resolved.
Show resolved Hide resolved
return;
case SDLVK_BACKSPACE:
// Text Editing
/*if (state == SDL_PRESSED)
g_pApp->handleCharInput('\b');*/
break;
case SDLVK_LSHIFT:
case SDLVK_RSHIFT:
setShiftPressed(state == SDL_PRESSED, key == SDLVK_LSHIFT);
break;
}

// Normal Key Press
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(state), key);
}

void AppPlatform_sdl_base::handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state)
{
// Normal Key Press
Keyboard::feed(AppPlatform_sdl_base::GetKeyState(state), button);
}

void AppPlatform_sdl_base::handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value)
{
float val = value / 30000.0f; // -32768 to 32767
BrentDaMage marked this conversation as resolved.
Show resolved Hide resolved

switch (axis)
{
case SDL_CONTROLLER_AXIS_LEFTX:
Controller::feedStickX(1, 1, val);
break;
case SDL_CONTROLLER_AXIS_LEFTY:
Controller::feedStickY(1, 1, val);
break;
case SDL_CONTROLLER_AXIS_RIGHTX:
Controller::feedStickX(2, 1, val);
break;
case SDL_CONTROLLER_AXIS_RIGHTY:
Controller::feedStickY(2, 1, val);
break;
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
Controller::feedTrigger(1, val);
break;
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
Controller::feedTrigger(2, val);
break;
}
}
20 changes: 17 additions & 3 deletions platforms/sdl/base/AppPlatform_sdl_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,30 @@ class AppPlatform_sdl_base : public AppPlatform
bool shiftPressed() override;
void setShiftPressed(bool b, bool isLeft);

static MouseButtonType GetMouseButtonType(SDL_Event event);
static MouseButtonType GetMouseButtonType(SDL_MouseButtonEvent event);
static bool GetMouseButtonState(SDL_Event event);
static Keyboard::KeyState GetKeyState(SDL_Event event);
static Keyboard::KeyState GetKeyState(uint8_t state);

// On-screen keyboard
void showKeyboard(int x, int y, int w, int h) override;
void hideKeyboard() override;

// Configure Touchscreen
bool isTouchscreen() override;
bool isTouchscreen() const override;

// Game controller
bool hasGamepad() const override;
SDL_GameController* getPrimaryGameController() const { return _controller; }
void setPrimaryGameController(SDL_GameController* controller) { _controller = controller; }
void gameControllerAdded(int32_t index);
void gameControllerRemoved(int32_t index);

void handleKeyEvent(int key, uint8_t state);
void handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state);
void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value);
private:
SDL_Window *_window;
SDL_GameController* _controller;

const Texture *_iconTexture;
SDL_Surface *_icon;
Expand All @@ -71,6 +83,8 @@ class AppPlatform_sdl_base : public AppPlatform

bool m_bIsTouchscreen;

SDL_GameController* findGameController();

static SDL_Surface* getSurfaceForTexture(const Texture* const texture);
protected:
std::string _storageDir;
Expand Down
8 changes: 4 additions & 4 deletions platforms/sdl/desktop/AppPlatform_sdl.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "AppPlatform_sdl.hpp"

#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <cerrno>

#include "thirdparty/stb_image/include/stb_image.h"
#include "thirdparty/stb_image/include/stb_image_write.h"
#include "stb_image.h"
#include "stb_image_write.h"

#include "AppPlatform_sdl.hpp"

#include "thirdparty/GL/GL.hpp"

Expand Down
Loading