209 lines
5.4 KiB
C
209 lines
5.4 KiB
C
/* main.c
|
|
|
|
copy this crap, it's open source
|
|
2025 - OG:Battlegrounds
|
|
|
|
*/
|
|
|
|
/*
|
|
This is the main executable,
|
|
the objective of this project is to recreate/decompile the original pubg lite launcher,
|
|
with the aim of being lighter/more portable/and more compatible,
|
|
without the need for the .net crap,
|
|
this code is being developed to work with Windows XP Service pack 3 and higher , Linux and Macos.
|
|
|
|
|
|
the project is using CEF 2623 b1401 for windows systems, and CEF 2704 b1415 for linux and macos.
|
|
|
|
This program is focused on opening on your potato, so do not use 3D web elements like css3d, webgl etc,
|
|
because this program may be focused on working with coding in software mode, not on gpus
|
|
|
|
why do you want it to work on windows xp?
|
|
for experiments, and also good portability
|
|
|
|
|
|
|
|
Note! The original launcher uses CEF 3578 b1870 so some features may not be available.
|
|
|
|
cef libraries should be c only,
|
|
do not include c++ wrappers, they require boring libraries and use __stdcall differently than __cdecl
|
|
|
|
you can code this program with c++, but do not include the cef c++ libraries.
|
|
|
|
the code for this program must be written with C 89 or C++ 98,
|
|
for compatibility with other compilers, and for readability.
|
|
|
|
avoid specific compiler calls.
|
|
|
|
avoid compiler specific syntax
|
|
|
|
the code will use doxygen, so document the implemented code well
|
|
|
|
|
|
|
|
compatible compilers are Open Watcom 1.9, Visual Studio 2019/2022, clang for macos
|
|
|
|
I won't have access to the mac, so I'll leave that in someone else's hands.
|
|
|
|
|
|
|
|
maybe some original launcher implementations don't work on linux and macos,
|
|
like hiding the launcher window and leaving an icon in the tray
|
|
|
|
|
|
use or create abstractions so that the code is the same on multiple platforms
|
|
|
|
The CEF localization files for macOS are messier and uglier,
|
|
if you want to use Xcode or Cocoa it will look like this,
|
|
if not we will use the manual loading method.
|
|
|
|
|
|
Now an IMPORTANT note,
|
|
I put libcef 2623 as libcef_ in the include directory,
|
|
and I put libcef 2704 in its place,
|
|
in case the program presents any problem,
|
|
or some inclusion code for Windows gives problems,
|
|
just use a macro and include libcef_ in place of libcef : this feat was done by phikill
|
|
|
|
|
|
*/
|
|
|
|
#ifdef _WIN32
|
|
#include<windows.h>
|
|
#else
|
|
#include<X11/Xlib.h>
|
|
#include<unistd.h> // for sleep()
|
|
#endif
|
|
|
|
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
|
|
|
|
#include<libcef/capi/cef_app_capi.h>
|
|
#include<libcef/capi/cef_client_capi.h>
|
|
#include<libcef/capi/cef_browser_capi.h>
|
|
#include<libcef/capi/cef_life_span_handler_capi.h>
|
|
|
|
#include"display_manager/display_manager.h"
|
|
|
|
#include"cef_manager/cef_core.h"
|
|
|
|
//#include"fukAnimatedGif/fukAnimatedGif.h"
|
|
|
|
|
|
int programLoop = 1; // This is the main loop of the program, if you reset it the program will close
|
|
|
|
LE_Display *progDisplay; // defined structure of the window handler component
|
|
|
|
int cefInitialized = 0;
|
|
|
|
|
|
|
|
int LoginWindowWidth = 400;
|
|
int LoginWindowHeight = 630;
|
|
|
|
int MainWindowWidth = 1280;
|
|
int MainWindowHeight = 760;
|
|
|
|
|
|
|
|
|
|
// X11 error handlers
|
|
#ifdef __linux__
|
|
|
|
int XErrorHandlerImpl(Display* display, XErrorEvent* event)
|
|
{
|
|
fprintf(stderr, "X11 Error: type=%d, serial=%lu, code=%d, request=%d, minor=%d\n",
|
|
event->type, event->serial, event->error_code,
|
|
event->request_code, event->minor_code);
|
|
return 0;
|
|
}
|
|
#endif // __linux__
|
|
|
|
|
|
// Handler and client
|
|
cef_app_t g_app = {0};
|
|
//cef_client_t g_client = {0};
|
|
|
|
|
|
BrowserContext g_client;
|
|
MyLifeSpanHandler g_lifeSpanHandler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 346x30 ou 500x40
|
|
|
|
DragRegion *progDragRegion;
|
|
|
|
|
|
|
|
void progLoop()
|
|
{
|
|
|
|
cef_do_message_loop_work(); // process CEF events
|
|
//usleep(1000); // avoid 100% CPU usage
|
|
|
|
checkDragRegion(progDisplay, progDragRegion);
|
|
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
|
|
int result;
|
|
|
|
// Phase 1: Before the window (only if multiprocessor)
|
|
result = cef_setup_pre_display(NULL, argc, argv, &g_app);
|
|
if(result != 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//http://127.0.0.1/oidc/interaction/login
|
|
|
|
progDisplay = engineCreateDisplay("PUBG LITE Launcher",
|
|
LoginWindowWidth,
|
|
LoginWindowHeight); // create Program Display/Window
|
|
|
|
windowBorderless(progDisplay, 1, LoginWindowWidth, LoginWindowHeight);
|
|
setWindowCentered(progDisplay);
|
|
|
|
result = cef_setup_post_display(progDisplay->platformConnection, argc, argv, &g_app);
|
|
if (result != 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
progDragRegion = createDragRegion(0, 0, 346, 30);
|
|
|
|
|
|
// X11: configurar handlers de erro
|
|
#ifdef __linux__
|
|
XSetErrorHandler(XErrorHandlerImpl); // without this the x11 communication with the cef does not work
|
|
#endif
|
|
|
|
setup_lifespan_handler(&g_lifeSpanHandler);
|
|
setup_client(&g_client.client);
|
|
create_browser("http://127.0.0.1/oidc/interaction/login",
|
|
&g_client.client,
|
|
progDisplay->platformHandle,
|
|
LoginWindowWidth,
|
|
LoginWindowHeight);
|
|
|
|
//redirect_browser(g_client.browser, "https://google.com");
|
|
|
|
engineSetLoop(progDisplay, &programLoop, progLoop);
|
|
|
|
// CEF concludes
|
|
cef_quit_message_loop();
|
|
cef_shutdown();
|
|
|
|
deleteDragRegion(progDragRegion);
|
|
|
|
return 0;
|
|
}
|