From 70bf37327154c2947ae23d240cde5dbe3a34abc5 Mon Sep 17 00:00:00 2001 From: RadialApps Date: Tue, 8 Aug 2017 16:07:43 +0530 Subject: [PATCH] Fix things for Android --- .gitignore | 1 + Android.mk | 88 +++++++++++++++++++++++++++++++++ make_xxd.sh | 9 ++++ src/config.cpp | 87 +++++++++++++++++++++++++++++++- src/config.h | 47 ++++++++++++++++++ src/eventthread.cpp | 2 + src/graphics.cpp | 48 ++++++++++++++++++ src/input.cpp | 118 ++++++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 1 + src/sharedstate.cpp | 5 +- 10 files changed, 402 insertions(+), 4 deletions(-) create mode 100644 Android.mk create mode 100644 make_xxd.sh diff --git a/.gitignore b/.gitignore index 81a3690..6e4700b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.xxd *.o *.pro.* *.bak diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..062fcb7 --- /dev/null +++ b/Android.mk @@ -0,0 +1,88 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE:= mkxp +LOCAL_CPPFLAGS:=-DSHARED_FLUID -DGLES2_HEADER -DFULL_MKXP_PATH=\"/data/data/com.radial.exitfate/files/mkxp.conf\" + +ifeq ($(TARGET_ARCH_ABI), armeabi) + LOCAL_CPPFLAGS += -DARCH_32BIT +else ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) + LOCAL_CPPFLAGS += -DARCH_32BIT +else ifeq ($(TARGET_ARCH_ABI), x86) + LOCAL_CPPFLAGS += -DARCH_32BIT +else ifeq ($(TARGET_ARCH_ABI), mips) + LOCAL_CPPFLAGS += -DARCH_32BIT +endif + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../OpenAL $(LOCAL_PATH)/../SDL_sound \ + $(LOCAL_PATH)/../libsigc++ $(LOCAL_PATH) \ + $(LOCAL_PATH)/../boost_headers $(LOCAL_PATH)/../pixman/pixman/pixman \ + $(LOCAL_PATH)/../OpenAL/include/AL $(LOCAL_PATH)/../physfs/src \ + $(LOCAL_PATH)/../vorbis-include $(LOCAL_PATH)/src $(LOCAL_PATH)/shader \ + $(LOCAL_PATH)/assets $(LOCAL_PATH)/../ruby/include $(LOCAL_PATH)/../fluidsynth/include +LOCAL_SRC_FILES := \ + $(LOCAL_PATH)/src/main.cpp \ + $(LOCAL_PATH)/src/audio.cpp \ + $(LOCAL_PATH)/src/bitmap.cpp \ + $(LOCAL_PATH)/src/eventthread.cpp \ + $(LOCAL_PATH)/src/filesystem.cpp \ + $(LOCAL_PATH)/src/font.cpp \ + $(LOCAL_PATH)/src/input.cpp \ + $(LOCAL_PATH)/src/plane.cpp \ + $(LOCAL_PATH)/src/scene.cpp \ + $(LOCAL_PATH)/src/sprite.cpp \ + $(LOCAL_PATH)/src/table.cpp \ + $(LOCAL_PATH)/src/tilequad.cpp \ + $(LOCAL_PATH)/src/viewport.cpp \ + $(LOCAL_PATH)/src/window.cpp \ + $(LOCAL_PATH)/src/texpool.cpp \ + $(LOCAL_PATH)/src/shader.cpp \ + $(LOCAL_PATH)/src/glstate.cpp \ + $(LOCAL_PATH)/src/tilemap.cpp \ + $(LOCAL_PATH)/src/autotiles.cpp \ + $(LOCAL_PATH)/src/graphics.cpp \ + $(LOCAL_PATH)/src/gl-debug.cpp \ + $(LOCAL_PATH)/src/etc.cpp \ + $(LOCAL_PATH)/src/config.cpp \ + $(LOCAL_PATH)/src/settingsmenu.cpp \ + $(LOCAL_PATH)/src/keybindings.cpp \ + $(LOCAL_PATH)/src/tileatlas.cpp \ + $(LOCAL_PATH)/src/sharedstate.cpp \ + $(LOCAL_PATH)/src/gl-fun.cpp \ + $(LOCAL_PATH)/src/gl-meta.cpp \ + $(LOCAL_PATH)/src/vertex.cpp \ + $(LOCAL_PATH)/src/soundemitter.cpp \ + $(LOCAL_PATH)/src/sdlsoundsource.cpp \ + $(LOCAL_PATH)/src/alstream.cpp \ + $(LOCAL_PATH)/src/audiostream.cpp \ + $(LOCAL_PATH)/src/rgssad.cpp \ + $(LOCAL_PATH)/src/bundledfont.cpp \ + $(LOCAL_PATH)/src/vorbissource.cpp \ + $(LOCAL_PATH)/src/windowvx.cpp \ + $(LOCAL_PATH)/src/tilemapvx.cpp \ + $(LOCAL_PATH)/src/tileatlasvx.cpp \ + $(LOCAL_PATH)/src/autotilesvx.cpp \ + $(LOCAL_PATH)/src/midisource.cpp \ + $(LOCAL_PATH)/src/fluid-fun.cpp \ + $(LOCAL_PATH)/binding-mri/binding-mri.cpp \ + $(LOCAL_PATH)/binding-mri/binding-util.cpp \ + $(LOCAL_PATH)/binding-mri/bitmap-binding.cpp \ + $(LOCAL_PATH)/binding-mri/table-binding.cpp \ + $(LOCAL_PATH)/binding-mri/etc-binding.cpp \ + $(LOCAL_PATH)/binding-mri/font-binding.cpp \ + $(LOCAL_PATH)/binding-mri/graphics-binding.cpp \ + $(LOCAL_PATH)/binding-mri/input-binding.cpp \ + $(LOCAL_PATH)/binding-mri/sprite-binding.cpp \ + $(LOCAL_PATH)/binding-mri/viewport-binding.cpp \ + $(LOCAL_PATH)/binding-mri/plane-binding.cpp \ + $(LOCAL_PATH)/binding-mri/window-binding.cpp \ + $(LOCAL_PATH)/binding-mri/tilemap-binding.cpp \ + $(LOCAL_PATH)/binding-mri/audio-binding.cpp \ + $(LOCAL_PATH)/binding-mri/module_rpg.cpp \ + $(LOCAL_PATH)/binding-mri/filesystem-binding.cpp \ + $(LOCAL_PATH)/binding-mri/windowvx-binding.cpp \ + $(LOCAL_PATH)/binding-mri/tilemapvx-binding.cpp \ + +LOCAL_STATIC_LIBRARIES:=vorbis physfs sigc++ pixman boost_program_options ruby SDL2_static SDL2_ttf SDL2_sound SDL2_image fluidsynth ogg OpenAL +LOCAL_LDLIBS:=-lz -llog -ldl -lm -lOpenSLES +include $(BUILD_SHARED_LIBRARY) diff --git a/make_xxd.sh b/make_xxd.sh new file mode 100644 index 0000000..511366f --- /dev/null +++ b/make_xxd.sh @@ -0,0 +1,9 @@ +#!/bin/sh +rm -f shader/*.xxd* +for i in $(ls shader); do + xxd -i "shader/$i" "shader/$i.xxd" +done +rm -f assets/*.xxd* +for i in $(ls assets); do + xxd -i "assets/$i" "assets/$i.xxd" +done diff --git a/src/config.cpp b/src/config.cpp index 33d8160..775316c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include @@ -143,7 +145,7 @@ std::set setFromVec(const std::vector &vec) typedef std::vector StringVec; namespace po = boost::program_options; -#define CONF_FILE "mkxp.conf" +#define CONF_FILE FULL_MKXP_PATH Config::Config() {} @@ -175,14 +177,15 @@ void Config::read(int argc, char *argv[]) PO_DESC(dataPathOrg, std::string, "") \ PO_DESC(dataPathApp, std::string, "") \ PO_DESC(iconPath, std::string, "") \ + PO_DESC(overlayPath, std::string, "") \ PO_DESC(execName, std::string, "Game") \ PO_DESC(titleLanguage, std::string, "") \ PO_DESC(midi.soundFont, std::string, "") \ PO_DESC(midi.chorus, bool, false) \ PO_DESC(midi.reverb, bool, false) \ PO_DESC(SE.sourceCount, int, 6) \ - PO_DESC(customScript, std::string, "") \ PO_DESC(pathCache, bool, true) \ + PO_DESC(customScript, std::string, "") \ PO_DESC(useScriptNames, bool, false) // Not gonna take your shit boost @@ -406,3 +409,83 @@ void Config::readGameINI() setupScreenSize(*this); } + +using namespace boost::property_tree; +using namespace boost::property_tree::json_parser; +static void +parseOverlayButtonDesc(const ptree &pt, TouchOverlay::Button &out) +{ + out.id = pt.get("id"); + out.target = pt.get("target"); + out.x = pt.get("x"); + out.y = pt.get("y"); + + const std::string &shape = pt.get("shape"); + + if (shape == "rectangle") + { + out.shape = TouchOverlay::Button::Rectangle; + out.u.r.width = pt.get("width"); + out.u.r.height = pt.get("height"); + } + else if (shape == "circle") + { + out.shape = TouchOverlay::Button::Circle; + out.u.c.radius = pt.get("radius"); + } + else if (shape == "triangle") + { + out.shape = TouchOverlay::Button::Triangle; + out.u.t.x1 = pt.get("x1"); + out.u.t.y1 = pt.get("y1"); + out.u.t.x2 = pt.get("x2"); + out.u.t.y2 = pt.get("y2"); + } + else + { + throw std::logic_error("unknown button shape: " + shape); + } +} + +static void +parseOverlayDesc(const ptree &pt, TouchOverlay &out) +{ + out.image = pt.get("image"); + + const ptree &buttons = pt.get_child("buttons"); + for (ptree::const_iterator ci = buttons.begin(); ci != buttons.end(); ++ci) + { + const ptree &c = ci->second; + TouchOverlay::Button button; + + parseOverlayButtonDesc(c, button); + out.buttons.push_back(button); + } +} + +void Config::readOverlayDesc() +{ + SDLRWStream descFile(overlayPath.c_str(), "r"); + + if (descFile) + { + try + { + ptree json; + read_json(descFile.stream(), json); + + TouchOverlay ol; + parseOverlayDesc(json, ol); + + touchOverlay = ol; + } + catch (const std::exception &e) + { + Debug() << "Error parsing overlay descrption: " << e.what(); + } + } + else + { + Debug() << "Didn't parse overlay desc cuz no file"; + } +} diff --git a/src/config.h b/src/config.h index d2d4650..5bc7261 100644 --- a/src/config.h +++ b/src/config.h @@ -26,6 +26,49 @@ #include #include +struct TouchOverlay +{ + std::string image; + + struct Button + { + enum Shape + { + Rectangle, + Circle, + Triangle + }; + + std::string id; + std::string target; + Shape shape; + + int x; + int y; + + union + { + struct + { + int width; + int height; + } r; + + struct + { + int radius; + } c; + struct + { + int x1, y1; + int x2, y2; + } t; + } u; + }; + + std::vector