Merge branch 'master' into linux
443
CMakeLists.txt
|
|
@ -1,443 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8.11)
|
||||
Project(mkxp)
|
||||
|
||||
## Setup options ##
|
||||
|
||||
option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF)
|
||||
option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
|
||||
option(FORCE32 "Force 32bit compile on 64bit OS" OFF)
|
||||
set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, NULL)")
|
||||
set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix")
|
||||
|
||||
## Misc setup ##
|
||||
|
||||
include(cmake/PrepUtils.cmake)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
IF("${CMAKE_SYSTEM}" MATCHES "Linux")
|
||||
SET(LINUX ON)
|
||||
ENDIF()
|
||||
|
||||
IF(WORKDIR_CURRENT)
|
||||
list(APPEND DEFINES
|
||||
WORKDIR_CURRENT
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(FORCE32)
|
||||
if(APPLE)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "i386")
|
||||
else()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
|
||||
|
||||
IF(LINUX)
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE32) )
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86_64")
|
||||
set(BIN_RPATH "\$ORIGIN/lib64")
|
||||
set(LIB_PATH "lib64")
|
||||
else()
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86")
|
||||
set(BIN_RPATH "\$ORIGIN/lib")
|
||||
set(LIB_PATH "lib")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
SET(BIN_RPATH "@executable_path/../Frameworks")
|
||||
set(LIB_PATH "lib")
|
||||
endif()
|
||||
|
||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
||||
|
||||
## Locate core libs ##
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if (EXTERNAL_LIB_PATH)
|
||||
set(CMAKE_PREFIX_PATH ${EXTERNAL_LIB_PATH})
|
||||
|
||||
if(EXISTS "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
||||
SET(ENV{PKG_CONFIG_PATH} "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/")
|
||||
endif()
|
||||
if(APPLE)
|
||||
set(PLATFORM_SHARED_LIBS
|
||||
libSDL2.dylib libSDL2_image-2.0.0.dylib libSDL2_ttf-2.0.0.dylib libSDL_sound-1.0.1.dylib
|
||||
libfreetype.6.dylib libsigc-2.0.0.dylib
|
||||
CACHE STRING "List of shared libraries that need to be copied into the OS X bundle")
|
||||
foreach(lib ${PLATFORM_SHARED_LIBS})
|
||||
if(EXISTS ${EXTERNAL_LIB_PATH}/lib/${lib})
|
||||
list(APPEND PLATFORM_COPY_LIBS
|
||||
${EXTERNAL_LIB_PATH}/lib/${lib}
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
pkg_check_modules(SIGCXX REQUIRED sigc++-2.0)
|
||||
pkg_check_modules(PIXMAN REQUIRED pixman-1)
|
||||
pkg_check_modules(PHYSFS REQUIRED physfs>=2.1)
|
||||
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
|
||||
pkg_check_modules(SDL2 REQUIRED sdl2)
|
||||
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
|
||||
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
|
||||
pkg_check_modules(SDL_SOUND REQUIRED SDL_sound)
|
||||
|
||||
find_package(Boost 1.49 COMPONENTS program_options REQUIRED)
|
||||
find_package(OpenAL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
## Setup main source ##
|
||||
|
||||
set(MAIN_HEADERS
|
||||
src/quadarray.h
|
||||
src/audio.h
|
||||
src/binding.h
|
||||
src/bitmap.h
|
||||
src/disposable.h
|
||||
src/etc.h
|
||||
src/etc-internal.h
|
||||
src/eventthread.h
|
||||
src/flashable.h
|
||||
src/font.h
|
||||
src/input.h
|
||||
src/plane.h
|
||||
src/scene.h
|
||||
src/sprite.h
|
||||
src/table.h
|
||||
src/texpool.h
|
||||
src/tilequad.h
|
||||
src/transform.h
|
||||
src/viewport.h
|
||||
src/window.h
|
||||
src/serializable.h
|
||||
src/shader.h
|
||||
src/glstate.h
|
||||
src/quad.h
|
||||
src/tilemap.h
|
||||
src/tilemap-common.h
|
||||
src/graphics.h
|
||||
src/gl-debug.h
|
||||
src/global-ibo.h
|
||||
src/exception.h
|
||||
src/filesystem.h
|
||||
src/serial-util.h
|
||||
src/intrulist.h
|
||||
src/binding.h
|
||||
src/gl-util.h
|
||||
src/util.h
|
||||
src/config.h
|
||||
src/settingsmenu.h
|
||||
src/keybindings.h
|
||||
src/tileatlas.h
|
||||
src/sharedstate.h
|
||||
src/al-util.h
|
||||
src/boost-hash.h
|
||||
src/debugwriter.h
|
||||
src/gl-fun.h
|
||||
src/gl-meta.h
|
||||
src/vertex.h
|
||||
src/soundemitter.h
|
||||
src/aldatasource.h
|
||||
src/alstream.h
|
||||
src/audiostream.h
|
||||
src/rgssad.h
|
||||
src/window.h
|
||||
src/tilemapvx.h
|
||||
src/tileatlasvx.h
|
||||
src/sharedmidistate.h
|
||||
src/fluid-fun.h
|
||||
src/sdl-util.h
|
||||
)
|
||||
|
||||
set(MAIN_SOURCE
|
||||
src/main.cpp
|
||||
src/audio.cpp
|
||||
src/bitmap.cpp
|
||||
src/eventthread.cpp
|
||||
src/filesystem.cpp
|
||||
src/font.cpp
|
||||
src/input.cpp
|
||||
src/plane.cpp
|
||||
src/scene.cpp
|
||||
src/sprite.cpp
|
||||
src/table.cpp
|
||||
src/tilequad.cpp
|
||||
src/viewport.cpp
|
||||
src/window.cpp
|
||||
src/texpool.cpp
|
||||
src/shader.cpp
|
||||
src/glstate.cpp
|
||||
src/tilemap.cpp
|
||||
src/autotiles.cpp
|
||||
src/graphics.cpp
|
||||
src/gl-debug.cpp
|
||||
src/etc.cpp
|
||||
src/config.cpp
|
||||
src/settingsmenu.cpp
|
||||
src/keybindings.cpp
|
||||
src/tileatlas.cpp
|
||||
src/sharedstate.cpp
|
||||
src/gl-fun.cpp
|
||||
src/gl-meta.cpp
|
||||
src/vertex.cpp
|
||||
src/soundemitter.cpp
|
||||
src/sdlsoundsource.cpp
|
||||
src/alstream.cpp
|
||||
src/audiostream.cpp
|
||||
src/rgssad.cpp
|
||||
src/bundledfont.cpp
|
||||
src/vorbissource.cpp
|
||||
src/window.cpp
|
||||
src/tilemapvx.cpp
|
||||
src/tileatlasvx.cpp
|
||||
src/autotilesvx.cpp
|
||||
src/midisource.cpp
|
||||
src/fluid-fun.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND MAIN_HEADERS windows/resource.h)
|
||||
list(APPEND MAIN_SOURCE windows/resource.rc)
|
||||
endif()
|
||||
|
||||
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
||||
|
||||
## Setup embedded source ##
|
||||
|
||||
set(EMBEDDED_INPUT
|
||||
shader/common.h
|
||||
shader/transSimple.frag
|
||||
shader/trans.frag
|
||||
shader/hue.frag
|
||||
shader/sprite.frag
|
||||
shader/plane.frag
|
||||
shader/gray.frag
|
||||
shader/bitmapBlit.frag
|
||||
shader/flatColor.frag
|
||||
shader/simple.frag
|
||||
shader/simpleColor.frag
|
||||
shader/simpleAlpha.frag
|
||||
shader/simpleAlphaUni.frag
|
||||
shader/flashMap.frag
|
||||
shader/minimal.vert
|
||||
shader/simple.vert
|
||||
shader/simpleColor.vert
|
||||
shader/sprite.vert
|
||||
shader/tilemap.vert
|
||||
shader/tilemapvx.vert
|
||||
shader/blur.frag
|
||||
shader/blurH.vert
|
||||
shader/blurV.vert
|
||||
shader/simpleMatrix.vert
|
||||
assets/liberation.ttf
|
||||
assets/icon.png
|
||||
)
|
||||
|
||||
if (RGSS2)
|
||||
list(APPEND DEFINES
|
||||
RGSS2
|
||||
)
|
||||
endif()
|
||||
|
||||
if (SHARED_FLUID)
|
||||
pkg_check_modules(FLUID REQUIRED fluidsynth)
|
||||
list(APPEND DEFINES
|
||||
SHARED_FLUID
|
||||
)
|
||||
endif()
|
||||
|
||||
## Process Embeddeds ##
|
||||
|
||||
find_program(XXD_EXE xxd
|
||||
DOC "Location of the xxd executable"
|
||||
)
|
||||
|
||||
macro(ProcessWithXXD outvar inputfile outdir)
|
||||
get_filename_component(basefile ${inputfile} NAME)
|
||||
set(outputfile ${outdir}/${basefile}.xxd)
|
||||
set_source_files_properties(${outputfile} PROPERTIES HEADER_ONLY TRUE)
|
||||
add_custom_command(
|
||||
OUTPUT ${outputfile}
|
||||
COMMAND ${XXD_EXE} -i ${inputfile} ${outputfile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${inputfile}
|
||||
COMMENT "Generating XXD for ${inputfile}"
|
||||
)
|
||||
list(APPEND ${outvar}
|
||||
${outputfile}
|
||||
)
|
||||
endmacro()
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/xxdhack)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/xxdhack
|
||||
)
|
||||
|
||||
foreach(item ${EMBEDDED_INPUT})
|
||||
ProcessWithXXD(EMBEDDED_SOURCE ${item} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endforeach()
|
||||
|
||||
source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE})
|
||||
|
||||
## Setup binding source ##
|
||||
|
||||
if (BINDING STREQUAL "MRI")
|
||||
set(MRIVERSION "2.3" CACHE STRING "Version of MRI to link with")
|
||||
pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
|
||||
list(APPEND DEFINES
|
||||
BINDING_MRI
|
||||
)
|
||||
set(BINDING_HEADERS
|
||||
binding-mri/binding-util.h
|
||||
binding-mri/binding-types.h
|
||||
binding-mri/serializable-binding.h
|
||||
binding-mri/disposable-binding.h
|
||||
binding-mri/sceneelement-binding.h
|
||||
binding-mri/viewportelement-binding.h
|
||||
binding-mri/flashable-binding.h
|
||||
)
|
||||
set(BINDING_SOURCE
|
||||
binding-mri/binding-mri.cpp
|
||||
binding-mri/binding-util.cpp
|
||||
binding-mri/table-binding.cpp
|
||||
binding-mri/etc-binding.cpp
|
||||
binding-mri/bitmap-binding.cpp
|
||||
binding-mri/font-binding.cpp
|
||||
binding-mri/graphics-binding.cpp
|
||||
binding-mri/input-binding.cpp
|
||||
binding-mri/sprite-binding.cpp
|
||||
binding-mri/viewport-binding.cpp
|
||||
binding-mri/plane-binding.cpp
|
||||
binding-mri/window-binding.cpp
|
||||
binding-mri/tilemap-binding.cpp
|
||||
binding-mri/audio-binding.cpp
|
||||
binding-mri/module_rpg.cpp
|
||||
binding-mri/filesystem-binding.cpp
|
||||
binding-mri/window-binding.cpp
|
||||
binding-mri/tilemap-binding.cpp
|
||||
)
|
||||
elseif(BINDING STREQUAL "MRUBY")
|
||||
message(FATAL_ERROR "Mruby support in CMake needs to be finished")
|
||||
list(APPEND DEFINES
|
||||
BINDING_MRUBY
|
||||
)
|
||||
set(BINDING_HEADERS
|
||||
binding-mruby/binding-util.h
|
||||
binding-mruby/disposable-binding.h
|
||||
binding-mruby/flashable-binding.h
|
||||
binding-mruby/binding-types.h
|
||||
binding-mruby/sceneelement-binding.h
|
||||
binding-mruby/viewportelement-binding.h
|
||||
binding-mruby/serializable-binding.h
|
||||
binding-mruby/mrb-ext/file.h
|
||||
binding-mruby/mrb-ext/rwmem.h
|
||||
binding-mruby/mrb-ext/marshal.h
|
||||
)
|
||||
set(BINDING_SOURCE
|
||||
binding-mruby/binding-mruby.cpp
|
||||
binding-mruby/binding-util.cpp
|
||||
binding-mruby/window-binding.cpp
|
||||
binding-mruby/bitmap-binding.cpp
|
||||
binding-mruby/sprite-binding.cpp
|
||||
binding-mruby/font-binding.cpp
|
||||
binding-mruby/viewport-binding.cpp
|
||||
binding-mruby/plane-binding.cpp
|
||||
binding-mruby/audio-binding.cpp
|
||||
binding-mruby/tilemap-binding.cpp
|
||||
binding-mruby/etc-binding.cpp
|
||||
binding-mruby/graphics-binding.cpp
|
||||
binding-mruby/input-binding.cpp
|
||||
binding-mruby/table-binding.cpp
|
||||
binding-mruby/module_rpg.c
|
||||
binding-mruby/mrb-ext/file.cpp
|
||||
binding-mruby/mrb-ext/marshal.cpp
|
||||
binding-mruby/mrb-ext/rwmem.cpp
|
||||
binding-mruby/mrb-ext/kernel.cpp
|
||||
binding-mruby/mrb-ext/time.cpp
|
||||
)
|
||||
elseif(BINDING STREQUAL "NULL")
|
||||
set(BINDING_SOURCE
|
||||
binding-null/binding-null.cpp
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Must choose a valid binding type. MRI, MRUBY, or NULL")
|
||||
endif()
|
||||
|
||||
source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
|
||||
|
||||
## Setup main executable ##
|
||||
|
||||
if(APPLE)
|
||||
find_library(CARBON_LIBRARY Carbon)
|
||||
find_library(IOKIT_LIBRARY IOKit)
|
||||
mark_as_advanced(CARBON_LIBRARY IOKIT_LIBRARY)
|
||||
list(APPEND PLATFORM_LIBRARIES
|
||||
${CARBON_LIBRARY}
|
||||
${IOKIT_LIBRARY}
|
||||
"-liconv"
|
||||
)
|
||||
endif()
|
||||
|
||||
link_directories(
|
||||
${SIGCXX_LIBRARY_DIRS}
|
||||
${PIXMAN_LIBRARY_DIRS}
|
||||
${PHYSFS_LIBRARY_DIRS}
|
||||
${SDL2_LIBRARY_DIRS} # Blindly assume other SDL bits are in same directory
|
||||
${Boost_LIBRARY_DIR}
|
||||
${MRI_LIBDIR}
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} MACOSX_BUNDLE
|
||||
${MAIN_HEADERS}
|
||||
${MAIN_SOURCE}
|
||||
${BINDING_HEADERS}
|
||||
${BINDING_SOURCE}
|
||||
${EMBEDDED_SOURCE}
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
${DEFINES}
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
src
|
||||
windows
|
||||
${SIGCXX_INCLUDE_DIRS}
|
||||
${PIXMAN_INCLUDE_DIRS}
|
||||
${PHYSFS_INCLUDE_DIRS}
|
||||
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
||||
${Boost_INCLUDE_DIR}
|
||||
${MRI_INCLUDE_DIRS}
|
||||
${VORBISFILE_INCLUDE_DIRS}
|
||||
${FLUID_INCLUDE_DIRS}
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
${SIGCXX_LIBRARIES}
|
||||
${SDL2_LIBRARIES}
|
||||
${SDL2_IMAGE_LIBRARIES}
|
||||
${SDL2_TTF_LIBRARIES}
|
||||
${SDL_SOUND_LIBRARIES}
|
||||
${PHYSFS_LIBRARIES}
|
||||
${PIXMAN_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${MRI_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES}
|
||||
${FLUID_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
|
||||
${PLATFORM_LIBRARIES}
|
||||
)
|
||||
|
||||
PostBuildMacBundle(${PROJECT_NAME} "" "${PLATFORM_COPY_LIBS}")
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#include "journal-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "pipe.h"
|
||||
|
|
@ -6,17 +7,7 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
//OS-Specific code
|
||||
#if defined _WIN32
|
||||
#define OS_W32
|
||||
#elif defined __APPLE__ || __linux__
|
||||
#define LINUX
|
||||
#ifdef __APPLE__
|
||||
#define OS_OSX
|
||||
#else
|
||||
#define OS_LINUX
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -25,22 +16,7 @@
|
|||
#endif
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#error "Operating system not detected."
|
||||
#endif
|
||||
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
static SDL_Thread *thread = NULL;
|
||||
static SDL_mutex *mutex = NULL;
|
||||
static volatile char lang_buffer[BUFFER_SIZE];
|
||||
static volatile char message_buffer[BUFFER_SIZE];
|
||||
static volatile bool active = false;
|
||||
static volatile int message_len = 0;
|
||||
|
||||
#ifdef LINUX
|
||||
#define PIPE_PATH "/tmp/oneshot-pipe"
|
||||
static volatile int out_pipe = -1;
|
||||
void cleanup_pipe()
|
||||
{
|
||||
unlink(PIPE_PATH);
|
||||
|
|
|
|||
49
binding-mri/journal-binding.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "pipe.h"
|
||||
#include "debugwriter.h"
|
||||
#include "i18n.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
//OS-Specific code
|
||||
#if defined _WIN32
|
||||
#define OS_W32
|
||||
#elif defined __APPLE__ || __linux__
|
||||
#define LINUX
|
||||
#ifdef __APPLE__
|
||||
#define OS_OSX
|
||||
#else
|
||||
#define OS_LINUX
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef OS_LINUX
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#error "Operating system not detected."
|
||||
#endif
|
||||
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
static SDL_Thread *thread = NULL;
|
||||
static SDL_mutex *mutex = NULL;
|
||||
static volatile char lang_buffer[BUFFER_SIZE];
|
||||
static volatile char message_buffer[BUFFER_SIZE];
|
||||
static volatile bool active = false;
|
||||
static volatile int message_len = 0;
|
||||
|
||||
#ifdef LINUX
|
||||
#define PIPE_PATH "/tmp/oneshot-pipe"
|
||||
static volatile int out_pipe = -1;
|
||||
void cleanup_pipe();
|
||||
#endif
|
||||
|
||||
int server_thread(void *data);
|
||||
|
|
@ -14,7 +14,14 @@
|
|||
#define OS_LINUX
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef OS_LINUX
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
|
|
@ -25,6 +32,91 @@ namespace syswm {
|
|||
#define NIKO_X (320 - 16)
|
||||
#define NIKO_Y ((13 * 16) * 2)
|
||||
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
static SDL_Thread *thread = NULL;
|
||||
static SDL_mutex *mutex = NULL;
|
||||
static volatile char message_buffer[BUFFER_SIZE];
|
||||
static volatile bool active = false;
|
||||
static volatile int message_len = 0;
|
||||
|
||||
#ifdef LINUX
|
||||
#define PIPE_PATH "/tmp/oneshot-pipe"
|
||||
static volatile int out_pipe = -1;
|
||||
void niko_cleanup_pipe()
|
||||
{
|
||||
unlink(PIPE_PATH);
|
||||
remove(PIPE_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
int niko_server_thread(void *data)
|
||||
{
|
||||
(void)data;
|
||||
#if defined OS_W32
|
||||
HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game",
|
||||
PIPE_ACCESS_OUTBOUND,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
BUFFER_SIZE,
|
||||
BUFFER_SIZE,
|
||||
0,
|
||||
NULL);
|
||||
for (;;) {
|
||||
ConnectNamedPipe(pipe, NULL);
|
||||
SDL_LockMutex(mutex);
|
||||
DWORD written;
|
||||
WriteFile(pipe, (const void*)message_buffer, BUFFER_SIZE, &written, NULL);
|
||||
active = true;
|
||||
SDL_UnlockMutex(mutex);
|
||||
FlushFileBuffers(pipe);
|
||||
DisconnectNamedPipe(pipe);
|
||||
}
|
||||
CloseHandle(pipe);
|
||||
#else
|
||||
if (FILE *file = fopen(PIPE_PATH, "r")) {
|
||||
fclose(file);
|
||||
out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
SDL_LockMutex(mutex);
|
||||
active = true;
|
||||
if (message_len > 0)
|
||||
write(out_pipe, (char*)message_buffer, message_len);
|
||||
SDL_UnlockMutex(mutex);
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
RB_METHOD(nikoPrepare)
|
||||
{
|
||||
// Prime native window info
|
||||
syswm::SDL_SysWMinfo syswindow;
|
||||
SDL_VERSION(&syswindow.version);
|
||||
SDL_GetWindowWMInfo(shState->rtData().window, &syswindow);
|
||||
|
||||
#ifdef LINUX
|
||||
char path[PATH_MAX];
|
||||
std::string journal;
|
||||
|
||||
// Get current path
|
||||
getcwd(path, sizeof(path));
|
||||
|
||||
#ifdef OS_OSX
|
||||
journal = std::string(path) + std::string("/_______.app/Contents/MacOS/_______");
|
||||
#else
|
||||
journal = std::string(path) + std::string("_______");
|
||||
#endif
|
||||
|
||||
// Run the binary
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
execl(journal.c_str(), journal.c_str(), (char*)"niko", (char*)0);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(nikoStart)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
|
@ -58,30 +150,31 @@ RB_METHOD(nikoStart)
|
|||
SDL_GetWindowPosition(shState->rtData().window, &x, &y);
|
||||
x += NIKO_X;
|
||||
y += NIKO_Y;
|
||||
char x_str[16];
|
||||
char y_str[16];
|
||||
sprintf(x_str, "%d", x);
|
||||
sprintf(y_str, "%d", y);
|
||||
char message[32];
|
||||
sprintf(message, "%d,%d", x, y);
|
||||
|
||||
char path[PATH_MAX];
|
||||
std::string journal;
|
||||
SDL_LockMutex(mutex);
|
||||
message_len = strlen(message);
|
||||
strcpy((char*)message_buffer, message);
|
||||
SDL_UnlockMutex(mutex);
|
||||
|
||||
// Get current path
|
||||
if (getcwd(path, sizeof(path)) == NULL) {
|
||||
return Qnil;
|
||||
// Clean up connection thread
|
||||
if (thread != NULL && out_pipe != -1) {
|
||||
SDL_WaitThread(thread, NULL);
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
#ifdef OS_OSX
|
||||
journal = std::string(path) + "/_______.app/Contents/MacOS/_______";
|
||||
#else
|
||||
journal = std::string(path) + "/_______";
|
||||
#endif
|
||||
|
||||
// Run the binary
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
execl(journal.c_str(), journal.c_str(), x_str, y_str, (char*)0);
|
||||
exit(1);
|
||||
if (out_pipe == -1) {
|
||||
// We don't have a pipe open, so spawn the connection thread
|
||||
thread = SDL_CreateThread(niko_server_thread, "journal", NULL);
|
||||
}
|
||||
// Attempt to send it over the tubes
|
||||
if (out_pipe != -1) {
|
||||
// We have a connection, so send it over
|
||||
if (write(out_pipe, (char*)message_buffer, message_len) <= 0) {
|
||||
// In the case of an error, close
|
||||
close(out_pipe);
|
||||
out_pipe = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Qnil;
|
||||
|
|
@ -89,8 +182,15 @@ RB_METHOD(nikoStart)
|
|||
|
||||
void nikoBindingInit()
|
||||
{
|
||||
mutex = SDL_CreateMutex();
|
||||
#if defined __linux
|
||||
mkfifo(PIPE_PATH, 0666);
|
||||
atexit(niko_cleanup_pipe);
|
||||
#endif
|
||||
|
||||
VALUE module = rb_define_module("Niko");
|
||||
|
||||
//Functions
|
||||
_rb_define_module_function(module, "get_ready", nikoPrepare);
|
||||
_rb_define_module_function(module, "do_your_thing", nikoStart);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,11 @@ echo "-> ${cyan}Removing old OneShot apps...${color_reset}"
|
|||
rm -rf "$ONESHOT_PATH/OneShot.app"
|
||||
rm -rf "$ONESHOT_PATH/_______.app"
|
||||
rm -f "$ONESHOT_PATH/Data/xScripts.rxdata"
|
||||
rm -rf "$ONESHOT_PATH/*.exe"
|
||||
rm -rf "$ONESHOT_PATH/*.dll"
|
||||
|
||||
echo "-> ${cyan}Install OneShot apps to Steam directory...${color_reset}"
|
||||
cp -f "./xScripts.rxdata" "$ONESHOT_PATH/Data/xScripts.rxdata"
|
||||
cp -f "./CommonEvents.rxdata" "$ONESHOT_PATH/Data/CommonEvents.rxdata"
|
||||
cp -rf "./OneShot.app" "$ONESHOT_PATH"
|
||||
cp -rf "./_______.app" "$ONESHOT_PATH"
|
||||
cp -R "./Graphics/" "$ONESHOT_PATH/Wallpaper"
|
||||
cp -rf "./*" "$ONESHOT_PATH"
|
||||
ln -sfh "$ONESHOT_PATH/OneShot.app" "$HOME/Applications/OneShot.app"
|
||||
|
||||
rm -f /tmp/oneshot-pipe # Important for pre-release version cleanup
|
||||
|
|
|
|||
|
|
@ -27,28 +27,49 @@ class WatchPipe(QThread):
|
|||
|
||||
def run(self):
|
||||
while True:
|
||||
while True:
|
||||
if os.path.exists(pipe_path): break
|
||||
else: time.sleep(0.1)
|
||||
while not os.path.exists(pipe_path): time.sleep(0.1)
|
||||
|
||||
pipe = open(pipe_path, 'r')
|
||||
pipe.flush()
|
||||
|
||||
while True:
|
||||
if not os.path.exists(pipe_path):
|
||||
break # Handle game quitting cleanup
|
||||
was_nonzero = False
|
||||
|
||||
while os.path.exists(pipe_path): # Make sure the file still exists and wasn't cleaned up by SyngleChance
|
||||
message = os.read(pipe.fileno(), 256)
|
||||
if len(message) > 0:
|
||||
was_nonzero = True
|
||||
self.change_image.emit(message.decode())
|
||||
else:
|
||||
st = os.stat(pipe_path)
|
||||
if st.st_size == 0 and was_nonzero:
|
||||
self.change_image.emit("CLOSE")
|
||||
|
||||
time.sleep(0.05)
|
||||
time.sleep(0.05)
|
||||
|
||||
class AnimationTimer(QThread):
|
||||
next_frame = pyqtSignal()
|
||||
start_animation = pyqtSignal(int, int)
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self.next_frame.emit()
|
||||
time.sleep(1.0 / 60)
|
||||
while not os.path.exists(pipe_path): time.sleep(0.1)
|
||||
|
||||
pipe = open(pipe_path, 'r')
|
||||
pipe.flush()
|
||||
|
||||
while os.path.exists(pipe_path): # Make sure the file still exists and wasn't cleaned up by SyngleChance
|
||||
message = os.read(pipe.fileno(), 256)
|
||||
if len(message) > 0:
|
||||
m = message.decode()
|
||||
if not "," in m: pass
|
||||
x, y = m.split(",")
|
||||
self.start_animation.emit(int(x), int(y))
|
||||
|
||||
while True:
|
||||
self.next_frame.emit()
|
||||
time.sleep(1.0 / 60)
|
||||
|
||||
time.sleep(0.05)
|
||||
|
||||
class Journal(QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -95,20 +116,24 @@ class Journal(QWidget):
|
|||
self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600)
|
||||
|
||||
def change_image(self, image):
|
||||
if image == "CLOSE":
|
||||
self.app.quit()
|
||||
return
|
||||
if not "_" in image: return
|
||||
|
||||
name, lang = image.split('_', 1)
|
||||
if lang == 'en':
|
||||
img = os.path.join(base_path, 'images', '{}.png'.format(name))
|
||||
else:
|
||||
img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name))
|
||||
if lang == 'en': img = os.path.join(base_path, 'images', '{}.png'.format(name))
|
||||
else: img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name))
|
||||
if not os.path.exists(img): return
|
||||
|
||||
self.pixmap = QPixmap(img)
|
||||
self.label.setPixmap(self.pixmap)
|
||||
|
||||
class Niko(QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.x, self.y, self.start_y, self.app, self.thread = kwargs['x'], kwargs['y'], kwargs['y'], kwargs['app'], kwargs['thread']
|
||||
self.app, self.thread = kwargs['app'], kwargs['thread']
|
||||
self.screen_height = kwargs['screen_height']
|
||||
del kwargs['x'], kwargs['y'], kwargs['screen_height'], kwargs['app'], kwargs['thread']
|
||||
del kwargs['screen_height'], kwargs['app'], kwargs['thread']
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
|
@ -121,9 +146,12 @@ class Niko(QWidget):
|
|||
self.frames = [QPixmap(os.path.join(base_path, 'images', 'niko{}.png'.format(n))) for n in range(1,4)]
|
||||
self.label.setPixmap(self.frames[1])
|
||||
|
||||
self.show()
|
||||
def start(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.start_y = y
|
||||
|
||||
self.thread.start()
|
||||
self.show()
|
||||
|
||||
def getFrame(self):
|
||||
if ((self.y - self.start_y) % 32 >= 16): return 1
|
||||
|
|
@ -144,15 +172,15 @@ class Niko(QWidget):
|
|||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "niko":
|
||||
# "Niko-leaves-the-screen" mode
|
||||
x, y = int(sys.argv[1]), int(sys.argv[2])
|
||||
|
||||
thread = AnimationTimer()
|
||||
|
||||
niko = Niko(x = x, y = y, screen_height = app.primaryScreen().size().height(), app = app, thread = thread)
|
||||
niko = Niko(screen_height = app.primaryScreen().size().height(), app = app, thread = thread)
|
||||
|
||||
thread.start_animation.connect(niko.start)
|
||||
thread.next_frame.connect(niko.update)
|
||||
thread.start()
|
||||
|
||||
else:
|
||||
# Author's Journal mode
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ set -e
|
|||
cd `dirname $0`
|
||||
|
||||
# User-configurable variables
|
||||
mac_version="1.0.0"
|
||||
mac_version="1.0.1"
|
||||
make_threads=8
|
||||
ONESHOT_PATH=$HOME/Library/Application\ Support/Steam/steamapps/common/OneShot
|
||||
|
||||
|
|
|
|||
3
mkxp.pro
|
|
@ -271,7 +271,8 @@ BINDING_MRI {
|
|||
binding-mri/disposable-binding.h \
|
||||
binding-mri/sceneelement-binding.h \
|
||||
binding-mri/viewportelement-binding.h \
|
||||
binding-mri/flashable-binding.h
|
||||
binding-mri/flashable-binding.h \
|
||||
binding-mri/journal-binding.h
|
||||
|
||||
SOURCES += \
|
||||
binding-mri/binding-mri.cpp \
|
||||
|
|
|
|||
BIN
patches/assets/Data/CommonEvents.rxdata
Normal file
BIN
patches/assets/Data/Map004.rxdata
Normal file
BIN
patches/assets/Data/Map005.rxdata
Normal file
BIN
patches/assets/Data/Map061.rxdata
Normal file
BIN
patches/assets/Data/Map243.rxdata
Normal file
BIN
patches/assets/Data/Map255.rxdata
Normal file
BIN
patches/assets/Graphics/Pictures/es/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
patches/assets/Graphics/Pictures/fr/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
patches/assets/Graphics/Pictures/jp/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
patches/assets/Graphics/Pictures/ko/pj_portal.png
Normal file
|
After Width: | Height: | Size: 201 KiB |
BIN
patches/assets/Graphics/Pictures/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
patches/assets/Graphics/Pictures/pt_BR/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
patches/assets/Graphics/Pictures/zh_CN/pj_portal.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 789 KiB After Width: | Height: | Size: 789 KiB |
|
Before Width: | Height: | Size: 782 KiB After Width: | Height: | Size: 782 KiB |
|
Before Width: | Height: | Size: 794 KiB After Width: | Height: | Size: 794 KiB |
|
Before Width: | Height: | Size: 780 KiB After Width: | Height: | Size: 780 KiB |
|
Before Width: | Height: | Size: 783 KiB After Width: | Height: | Size: 783 KiB |
|
Before Width: | Height: | Size: 787 KiB After Width: | Height: | Size: 787 KiB |
|
Before Width: | Height: | Size: 783 KiB After Width: | Height: | Size: 783 KiB |
|
|
@ -277,9 +277,9 @@ int main(int argc, char *argv[])
|
|||
SDL_Window *win;
|
||||
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS; //| SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
#ifdef __APPLE__
|
||||
winFlags |= SDL_WINDOW_RESIZABLE;
|
||||
#endif
|
||||
// #ifdef __APPLE__
|
||||
// winFlags |= SDL_WINDOW_RESIZABLE;
|
||||
// #endif
|
||||
|
||||
if (conf.fullscreen)
|
||||
winFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
|
|
|
|||