GUI rendered in usable window area, and multiplayer working on android

This commit is contained in:
Yousef Khadadeh 2026-02-24 21:13:34 +03:00
parent 18b73a5926
commit b8b00145af
4 changed files with 38 additions and 32 deletions

View file

@ -55,9 +55,7 @@
<!-- Allow access to Internet -->
<!-- if you want to connect to the network or internet, uncomment this. -->
<!--
<uses-permission android:name="android.permission.INTERNET" />
-->
<!-- Create a Java class extending SDLActivity and place it in a
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java

View file

@ -30,11 +30,11 @@
inkscape:zoom="8.0000002"
inkscape:cx="36.749999"
inkscape:cy="62.624998"
inkscape:window-width="3440"
inkscape:window-height="1354"
inkscape:window-width="1136"
inkscape:window-height="1240"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:window-maximized="0"
inkscape:current-layer="layer1"
showgrid="true">
<inkscape:grid

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Before After
Before After

View file

@ -7,9 +7,11 @@
#include <variant>
#include <vector>
#include <Helpers/Random.hpp>
#include "Helpers/StringHelpers.hpp"
#include "NetClient.hpp"
#include "NetServer.hpp"
#include <bit>
#include <SDL3/SDL_iostream.h>
std::atomic<bool> NetLibrary::alreadyInitialized = false;
std::string NetLibrary::signalingAddr;
@ -28,12 +30,17 @@ NetLibrary::LoadP2PSettingsInPathResult NetLibrary::load_p2p_settings_in_path(co
config.iceServers.clear();
signalingAddr.clear();
std::ifstream f(p2pConfigPath);
std::string fileData;
if(f.is_open()) {
try {
nlohmann::json j;
f >> j;
fileData = read_file_to_string(p2pConfigPath);
}
catch(...) {
return LoadP2PSettingsInPathResult::FAILED_TO_OPEN;
}
try {
nlohmann::json j = nlohmann::json::parse(fileData);
j.at("signalingServer").get_to<std::string>(signalingAddr);
@ -50,11 +57,6 @@ NetLibrary::LoadP2PSettingsInPathResult NetLibrary::load_p2p_settings_in_path(co
catch(...) {
return LoadP2PSettingsInPathResult::FAILED_TO_READ;
}
}
else
return LoadP2PSettingsInPathResult::FAILED_TO_OPEN;
f.close();
return LoadP2PSettingsInPathResult::SUCCESS;
}
@ -89,7 +91,7 @@ void NetLibrary::init(const std::filesystem::path& p2pConfigPath) {
// Not sure why, but TLS verification fails on mac
// Should be fixed later, but for now this is fine, as the signaling server doesn't have
// critical information
#ifdef __APPLE__
#if defined(__APPLE__) || defined(__ANDROID__)
rtc::WebSocket::Configuration wsConfig;
wsConfig.disableTlsVerification = true;
ws = std::make_shared<rtc::WebSocket>(wsConfig);

View file

@ -70,7 +70,6 @@ void Toolbar::load_icons_at(const std::filesystem::path& pathToLoad) {
std::filesystem::path filePath = pathToLoad / std::filesystem::path(filesInPath[i]);
SDL_PathInfo fileInfo;
if(SDL_GetPathInfo(filePath.c_str(), &fileInfo) && fileInfo.type == SDL_PATHTYPE_FILE) {
Logger::get().log("INFO", filePath.string());
std::string iconRelativePath = filePath.relative_path().string();
std::replace(iconRelativePath.begin(), iconRelativePath.end(), '\\', '/');
std::string iconData = read_file_to_string(iconRelativePath);
@ -2264,8 +2263,15 @@ void Toolbar::initialize_io_before_update() {
}
void Toolbar::start_gui() {
SDL_Rect windowRect;
if(SDL_GetWindowSafeArea(main.window.sdlWindow, &windowRect)) {
gui.windowPos = {windowRect.x, windowRect.y};
gui.windowSize = Vector2f{windowRect.w, windowRect.h} / final_gui_scale();
}
else {
gui.windowPos = Vector2f{0.0f, 0.0f};
gui.windowSize = main.window.size.cast<float>() / final_gui_scale();
}
gui.io = io;
io->hoverObstructed = false;
gui.begin();