Can now build to android apk
Need to fix: - Remove default android header bar - Fix rcss styling to work on small screens
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@@ -1,9 +1,11 @@
|
||||
#include "critter.hpp"
|
||||
#include "database.hpp"
|
||||
#include "ui.hpp"
|
||||
#include "sdl_file_interface.hpp"
|
||||
#include "../vendor/stb/stb_image.h"
|
||||
#include "../vendor/stb/stb_image_write.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Core/Core.h>
|
||||
#include <RmlUi/Debugger/Debugger.h>
|
||||
@@ -19,6 +21,7 @@ static std::map<int, Critter> critters;
|
||||
static std::vector<CritterEntry> critter_list;
|
||||
static Rml::ElementDocument *doc;
|
||||
static AppData app_data;
|
||||
static SDLFileInterface file_interface;
|
||||
void shutdown() {
|
||||
Rml::Shutdown();
|
||||
Backend::Shutdown();
|
||||
@@ -36,8 +39,14 @@ bool initialize() {
|
||||
std::cout << "[INFO] RmlUI Backend initialized.\n";
|
||||
Rml::SetSystemInterface(Backend::GetSystemInterface());
|
||||
Rml::SetRenderInterface(Backend::GetRenderInterface());
|
||||
Rml::SetFileInterface(&file_interface);
|
||||
Rml::Initialise();
|
||||
Rml::Lua::Initialise();
|
||||
std::cout << "[INFO] Preparing local DB...\n";
|
||||
if (!ensure_db_copied()) {
|
||||
std::cout << "[ERROR] Could not prepare local DB.\n";
|
||||
return false;
|
||||
}
|
||||
std::cout << "[INFO] Loading local DB...\n";
|
||||
if (!db_get_all_critters(critters)) {
|
||||
std::cout << "[ERROR] Local DB failed to initialize.\n";
|
||||
@@ -83,7 +92,6 @@ bool f8_was_pressed = false;
|
||||
void handle_input() {
|
||||
const bool *state = SDL_GetKeyboardState(NULL);
|
||||
if (state) {
|
||||
// Reload ui
|
||||
bool f5_state = state[SDL_SCANCODE_F5];
|
||||
if (f5_state && !f5_was_pressed) {
|
||||
f5_was_pressed = true;
|
||||
@@ -91,7 +99,6 @@ void handle_input() {
|
||||
} else if (!f5_state) {
|
||||
f5_was_pressed = false;
|
||||
}
|
||||
// Toggle debugger window
|
||||
bool f8_state = state[SDL_SCANCODE_F8];
|
||||
if (f8_state && !f8_was_pressed) {
|
||||
f8_was_pressed = true;
|
||||
@@ -102,7 +109,7 @@ void handle_input() {
|
||||
}
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
int main(int arc, char *argv[]) {
|
||||
std::cout << "[INFO] Starting CritterFolio...\n";
|
||||
is_initalized = initialize();
|
||||
if (!is_initalized) {
|
||||
@@ -121,7 +128,7 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
std::cout << "[INFO] Main page loaded.\n";
|
||||
|
||||
|
||||
while (is_running) {
|
||||
is_running = Backend::ProcessEvents(ctx);
|
||||
handle_input();
|
||||
|
||||
Reference in New Issue
Block a user