Skip to content

Commit

Permalink
imgui adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Mar 10, 2024
1 parent 8464ca9 commit 910647f
Show file tree
Hide file tree
Showing 24 changed files with 12,849 additions and 81 deletions.
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ find_package(OpenSSL REQUIRED)
git_commit_hash(${CMAKE_CURRENT_SOURCE_DIR} CLIENT_GIT_COMMIT_HASH)
configure_file(src/build_info.h.in ${CMAKE_CURRENT_BINARY_DIR}/build_info/build_info.h)

add_executable(mcpelauncher-client src/main.cpp src/main.h src/window_callbacks.cpp src/window_callbacks.h src/xbox_live_helper.cpp src/xbox_live_helper.h src/splitscreen_patch.cpp src/splitscreen_patch.h src/cll_upload_auth_step.cpp src/cll_upload_auth_step.h src/gl_core_patch.cpp src/gl_core_patch.h src/hbui_patch.cpp src/hbui_patch.h src/utf8_util.h src/shader_error_patch.cpp src/shader_error_patch.h src/jni/jni_descriptors.cpp src/jni/java_types.h src/jni/main_activity.cpp src/jni/main_activity.h src/jni/store.cpp src/jni/store.h src/jni/cert_manager.cpp src/jni/cert_manager.h src/jni/http_stub.cpp src/jni/http_stub.h src/jni/package_source.cpp src/jni/package_source.h src/jni/jni_support.h src/jni/jni_support.cpp src/fake_looper.cpp src/fake_looper.h src/fake_window.cpp src/fake_window.h src/fake_assetmanager.cpp src/fake_assetmanager.h src/fake_egl.cpp src/fake_egl.h src/fake_inputqueue.cpp src/fake_inputqueue.h src/symbols.cpp src/symbols.h src/text_input_handler.cpp src/text_input_handler.h src/jni/xbox_live.cpp src/jni/xbox_live.h src/core_patches.cpp src/core_patches.h src/thread_mover.cpp src/thread_mover.h src/jni/lib_http_client.cpp src/jni/lib_http_client.h src/jni/lib_http_client_websocket.cpp src/jni/lib_http_client_websocket.h src/jni/accounts.cpp src/jni/accounts.h src/jni/arrays.cpp src/jni/arrays.h src/jni/ecdsa.cpp src/jni/ecdsa.h src/jni/jbase64.cpp src/jni/jbase64.h src/jni/locale.cpp src/jni/locale.h src/jni/securerandom.cpp src/jni/securerandom.h src/jni/shahasher.cpp src/jni/shahasher.h src/jni/signature.cpp src/jni/signature.h src/jni/uuid.cpp src/jni/uuid.h src/jni/webview.cpp src/jni/webview.h src/util.cpp src/util.h src/xal_webview_factory.cpp src/xal_webview_factory.h src/xal_webview.h)
add_executable(mcpelauncher-client src/main.cpp src/main.h src/window_callbacks.cpp src/window_callbacks.h src/xbox_live_helper.cpp src/xbox_live_helper.h src/splitscreen_patch.cpp src/splitscreen_patch.h src/cll_upload_auth_step.cpp src/cll_upload_auth_step.h src/gl_core_patch.cpp src/gl_core_patch.h src/hbui_patch.cpp src/hbui_patch.h src/utf8_util.h src/shader_error_patch.cpp src/shader_error_patch.h src/jni/jni_descriptors.cpp src/jni/java_types.h src/jni/main_activity.cpp src/jni/main_activity.h src/jni/store.cpp src/jni/store.h src/jni/cert_manager.cpp src/jni/cert_manager.h src/jni/http_stub.cpp src/jni/http_stub.h src/jni/package_source.cpp src/jni/package_source.h src/jni/jni_support.h src/jni/jni_support.cpp src/fake_looper.cpp src/fake_looper.h src/fake_window.cpp src/fake_window.h src/fake_assetmanager.cpp src/fake_assetmanager.h src/fake_egl.cpp src/fake_egl.h src/fake_inputqueue.cpp src/fake_inputqueue.h src/symbols.cpp src/symbols.h src/text_input_handler.cpp src/text_input_handler.h src/jni/xbox_live.cpp src/jni/xbox_live.h src/core_patches.cpp src/core_patches.h src/thread_mover.cpp src/thread_mover.h src/jni/lib_http_client.cpp src/jni/lib_http_client.h src/jni/lib_http_client_websocket.cpp src/jni/lib_http_client_websocket.h src/jni/accounts.cpp src/jni/accounts.h src/jni/arrays.cpp src/jni/arrays.h src/jni/ecdsa.cpp src/jni/ecdsa.h src/jni/jbase64.cpp src/jni/jbase64.h src/jni/locale.cpp src/jni/locale.h src/jni/securerandom.cpp src/jni/securerandom.h src/jni/shahasher.cpp src/jni/shahasher.h src/jni/signature.cpp src/jni/signature.h src/jni/uuid.cpp src/jni/uuid.h src/jni/webview.cpp src/jni/webview.h src/util.cpp src/util.h src/xal_webview_factory.cpp src/xal_webview_factory.h src/xal_webview.h src/settings.cpp src/settings.h )
target_link_libraries(mcpelauncher-client logger properties-parser mcpelauncher-core gamewindow filepicker msa-daemon-client daemon-server-utils cll-telemetry argparser baron android-support-headers libc-shim OpenSSL::Crypto ${CURL_LIBRARIES})
target_include_directories(mcpelauncher-client PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/build_info/ ${CURL_INCLUDE_DIRS})

Expand Down Expand Up @@ -59,6 +59,30 @@ if(USE_SNMALLOC)
target_link_libraries(mcpelauncher-client PRIVATE snmalloc)
target_sources(mcpelauncher-client PRIVATE ${snmalloc_ext_SOURCE_DIR}/src/snmalloc/override/new.cc)
endif()
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../imgui" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui.cpp")
target_sources(mcpelauncher-client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui_demo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui_tables.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/backends/imgui_impl_opengl3.cpp
src/glad.c
src/imgui_ui.cpp
src/imgui_ui.h
)

target_include_directories(mcpelauncher-client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../imgui
${CMAKE_CURRENT_SOURCE_DIR}/../imgui/backends
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_compile_definitions(mcpelauncher-client PRIVATE
IMGUI_IMPL_OPENGL_ES2
USE_IMGUI
)
endif()

install(TARGETS mcpelauncher-client RUNTIME COMPONENT mcpelauncher-client DESTINATION bin)
include(CPackSettings.cmake)
4 changes: 4 additions & 0 deletions src/GLES2/gl2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include "../glad/glad.h"
#undef GL_POLYGON_MODE
#undef GL_UNPACK_ROW_LENGTH
4 changes: 4 additions & 0 deletions src/GLES2/gl2ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include "../glad/glad.h"
#undef GL_POLYGON_MODE
#undef GL_UNPACK_ROW_LENGTH
21 changes: 19 additions & 2 deletions src/fake_egl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "fake_egl.h"
#include "gl_core_patch.h"
#include "settings.h"
#include "imgui_ui.h"
#include <map>

#define __ANDROID__
Expand All @@ -12,7 +14,6 @@
#ifdef USE_ARMHF_SUPPORT
#include "armhf_support.h"
#endif

namespace fake_egl {

static thread_local EGLSurface currentDrawSurface;
Expand Down Expand Up @@ -95,6 +96,9 @@ EGLBoolean eglDestroyContext(EGLDisplay display, EGLContext context) {
EGLBoolean eglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context) {
if(draw != nullptr) {
((GameWindow *)draw)->makeCurrent(true);
#ifdef USE_IMGUI
ImGuiUIInit((GameWindow*)draw);
#endif
} else {
((GameWindow *)currentDrawSurface)->makeCurrent(false);
}
Expand All @@ -104,6 +108,9 @@ EGLBoolean eglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read,

EGLBoolean eglSwapBuffers(EGLDisplay display, EGLSurface surface) {
// Log::trace("FakeEGL", "eglSwapBuffers");
#ifdef USE_IMGUI
ImGuiUIDrawFrame((GameWindow*)surface);
#endif
((GameWindow *)surface)->swapBuffers();
return EGL_TRUE;
}
Expand All @@ -117,7 +124,7 @@ EGLBoolean eglQuerySurface(EGLDisplay display, EGLSurface surface, EGLint attrib
if(attribute == EGL_WIDTH || attribute == EGL_HEIGHT) {
int w, h;
((GameWindow *)surface)->getWindowSize(w, h);
*value = (attribute == EGL_WIDTH ? w : h);
*value = (attribute == EGL_WIDTH ? w : h - Settings::menubarsize);
return EGL_TRUE;
}
Log::warn("FakeEGL", "eglQuerySurface %x", attribute);
Expand Down Expand Up @@ -169,6 +176,16 @@ void FakeEGL::setupGLOverrides() {
#ifdef USE_ARMHF_SUPPORT
ArmhfSupport::install(fake_egl::hostProcOverrides);
#endif
// fake_egl::hostProcOverrides["glViewport"] = (void *)+[](int x,
// int y,
// int width,
// int height) {
// ((void (*)(int x,
// int y,
// int width,
// int height))(fake_egl::hostProcAddrFn("glViewport")))(x, y, width, height);

// };
// MESA 23.1 blackscreen Workaround Start for 1.18.30+, bgfy will disable the extension and the game works
fake_egl::hostProcOverrides["glDrawElementsInstancedOES"] = nullptr;
fake_egl::hostProcOverrides["glDrawArraysInstancedOES"] = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/fake_inputqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void FakeInputQueue::initHybrisHooks(std::unordered_map<std::string, void *> &sy
return (int32_t)0;
};
syms["AKeyEvent_getMetaState"] = (void *)+[](const AInputEvent *event) {
return (int32_t)0;
return ((const FakeKeyEvent *)(const void *)event)->metaState;
};
syms["AMotionEvent_getAction"] = (void *)+[](const AInputEvent *event) {
return ((const FakeMotionEvent *)(const void *)event)->action;
Expand Down
8 changes: 4 additions & 4 deletions src/fake_inputqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ struct FakeInputEvent {
};

struct FakeKeyEvent : FakeInputEvent {
int32_t action, keyCode;
int32_t action, keyCode, metaState;

FakeKeyEvent(int32_t action, int32_t keyCode) : FakeInputEvent(AINPUT_SOURCE_KEYBOARD, AINPUT_EVENT_TYPE_KEY), action(action), keyCode(keyCode) {}
FakeKeyEvent(int32_t source, int32_t deviceId, int32_t action, int32_t keyCode) : FakeInputEvent(source, AINPUT_EVENT_TYPE_KEY, deviceId), action(action), keyCode(keyCode) {}
FakeKeyEvent() : FakeKeyEvent(0, 0) {}
FakeKeyEvent(int32_t action, int32_t keyCode, int32_t metaState) : FakeInputEvent(AINPUT_SOURCE_KEYBOARD, AINPUT_EVENT_TYPE_KEY), action(action), keyCode(keyCode), metaState(metaState) {}
FakeKeyEvent(int32_t source, int32_t deviceId, int32_t action, int32_t keyCode) : FakeInputEvent(source, AINPUT_EVENT_TYPE_KEY, deviceId), action(action), keyCode(keyCode), metaState(0) {}
FakeKeyEvent() : FakeKeyEvent(0, 0, 0) {}
};

struct FakeMotionEvent : FakeInputEvent {
Expand Down
1 change: 1 addition & 0 deletions src/fake_looper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class FakeLooper {
static thread_local std::unique_ptr<FakeLooper> currentLooper;
bool prepared = false;
bool textInput = false;
int menuSize = 0;

struct EventEntry {
int fd, ident, events;
Expand Down
3 changes: 2 additions & 1 deletion src/fake_window.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "fake_window.h"
#include "settings.h"
#include <game_window.h>

void FakeWindow::initHybrisHooks(std::unordered_map<std::string, void*>& syms) {
Expand All @@ -10,6 +11,6 @@ void FakeWindow::initHybrisHooks(std::unordered_map<std::string, void*>& syms) {
syms["ANativeWindow_getHeight"] = (void*)+[](void* window) -> int32_t {
int width, height;
((GameWindow*)window)->getWindowSize(width, height);
return height;
return height - Settings::menubarsize;
};
}
Loading

0 comments on commit 910647f

Please sign in to comment.