diff --git a/.gitignore b/.gitignore index 8244ae2..06f9e34 100644 --- a/.gitignore +++ b/.gitignore @@ -3,13 +3,16 @@ *.bak *.xxd *.exe +*.bmp /Makefile* /oneshot /steamshim_parent/steamshim -/build +/build* +/debug +/release object_script.* rpgscript.bat diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 2dcd0b9..5883a4c 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -73,8 +73,9 @@ void graphicsBindingInit(); void fileIntBindingInit(); -void screenBindingInit(); +void journalBindingInit(); void wallpaperBindingInit(); +void nikoBindingInit(); void oneshotBindingInit(); void steamBindingInit(); @@ -106,8 +107,9 @@ static void mriBindingInit() graphicsBindingInit(); fileIntBindingInit(); - screenBindingInit(); + journalBindingInit(); wallpaperBindingInit(); + nikoBindingInit(); oneshotBindingInit(); steamBindingInit(); diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp new file mode 100644 index 0000000..96fc713 --- /dev/null +++ b/binding-mri/journal-binding.cpp @@ -0,0 +1,76 @@ +#include "binding-util.h" +#include "binding-types.h" +#include "pipe.h" +#include "debugwriter.h" + +#include + +#define OUT_BUFFER_SIZE 256 + +static SDL_Thread *thread = NULL; +static SDL_mutex *mutex = NULL; +static volatile char message_buffer[OUT_BUFFER_SIZE]; +static volatile int message_len = 0; + +int server_thread(void *data) +{ + (void)data; + HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-journal-to-game", + PIPE_ACCESS_OUTBOUND, + PIPE_TYPE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + OUT_BUFFER_SIZE, + OUT_BUFFER_SIZE, + 0, + NULL); + for (;;) { + ConnectNamedPipe(pipe, NULL); + SDL_LockMutex(mutex); + WriteFile(pipe, (const void*)message_buffer, OUT_BUFFER_SIZE, NULL, NULL); + SDL_UnlockMutex(mutex); + FlushFileBuffers(pipe); + DisconnectNamedPipe(pipe); + } + + CloseHandle(pipe); + + return 0; +} + +RB_METHOD(journalSet) +{ + RB_UNUSED_PARAM; + const char *name; + int len; + rb_get_args(argc, argv, "s", &name, &len RB_ARG_END); +#ifdef _WIN32 + if (thread == NULL) { + thread = SDL_CreateThread(server_thread, "journal", NULL); + } + HANDLE pipe = CreateFileW(L"\\\\.\\pipe\\oneshot-game-to-journal", + GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + 0, + NULL); + SDL_LockMutex(mutex); + strcpy((char*)message_buffer, name); + message_len = len; + SDL_UnlockMutex(mutex); + if (pipe != INVALID_HANDLE_VALUE) { + WriteFile(pipe, (const void*)message_buffer, OUT_BUFFER_SIZE, NULL, NULL); + FlushFileBuffers(pipe); + CloseHandle(pipe); + } +#endif + return Qnil; +} + +void journalBindingInit() +{ + mutex = SDL_CreateMutex(); + + VALUE module = rb_define_module("Journal"); + _rb_define_module_function(module, "set", journalSet); +} diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp new file mode 100644 index 0000000..4e315c5 --- /dev/null +++ b/binding-mri/niko-binding.cpp @@ -0,0 +1,52 @@ +#include "binding-util.h" +#include "binding-types.h" +#include "sharedstate.h" +#include "eventthread.h" +#include "debugwriter.h" + +#ifdef _WIN32 +#include +#endif + +#include +#include + +RB_METHOD(nikoStart) +{ + RB_UNUSED_PARAM; + // Calculate where to stick the window + POINT pos; + pos.x = (9 * 16 - 4) * 2; + pos.y = (13 * 16) * 2; + SDL_SysWMinfo syswindow; + SDL_VERSION(&syswindow.version); + SDL_GetWindowWMInfo(shState->rtData().window, &syswindow); + ClientToScreen(syswindow.info.win.window, &pos); + // Start process +#ifdef _WIN32 + WCHAR path[MAX_PATH]; + WCHAR args[MAX_PATH]; + GetModuleFileNameW(NULL, path, MAX_PATH); + PathRemoveFileSpecW(path); + wcscat(path, L"\\journal.exe"); + wsprintfW(args, L"journal.exe %d %d", pos.x, pos.y); + STARTUPINFOW si; + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + PROCESS_INFORMATION pi; + CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); +#else +#ifdef linux +#else +#endif +#endif + return Qnil; +} + +void nikoBindingInit() +{ + VALUE module = rb_define_module("Niko"); + + //Functions + _rb_define_module_function(module, "do_your_thing", nikoStart); +} diff --git a/journal/journal.cpp b/journal/journal.cpp new file mode 100644 index 0000000..7540b9d --- /dev/null +++ b/journal/journal.cpp @@ -0,0 +1,169 @@ +#include + +#define DEFAULT_WIDTH 800 +#define DEFAULT_HEIGHT 600 +#define IN_BUFFER_SIZE 256 + +static const WCHAR journal_classname[] = L"journal"; + +static HBITMAP image_handle = NULL; +static HANDLE image_mutex = NULL; + +static HWND window = NULL; + +static void loadImage(const char *name) { + if (image_handle) { + DeleteObject(image_handle); + } + image_handle = LoadBitmapA(GetModuleHandleW(NULL), name); +} + +// Window procedure +LRESULT CALLBACK journal_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_PAINT: { + PAINTSTRUCT ps; + HDC hdc; + HDC hdcMem; + + WaitForSingleObject(image_mutex, INFINITE); + hdc = BeginPaint(hwnd, &ps); + hdcMem = CreateCompatibleDC(hdc); + HANDLE oldBitmap = SelectObject(hdcMem, image_handle); + BitBlt(hdc, 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT, hdcMem, 0, 0, SRCCOPY); + SelectObject(hdcMem, oldBitmap); + DeleteDC(hdcMem); + EndPaint(hwnd, &ps); + ReleaseMutex(image_mutex); + } break; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return 0; +} + +// IPC thread +#include +DWORD WINAPI ipc_thread(LPVOID lpParam) +{ + (void)lpParam; + + char message[IN_BUFFER_SIZE]; + DWORD len; + + HANDLE pipe = CreateNamedPipeW(L"\\\\.\\pipe\\oneshot-game-to-journal", + PIPE_ACCESS_INBOUND, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + IN_BUFFER_SIZE, + IN_BUFFER_SIZE, + 0, + NULL); + + for (;;) { + if (!ConnectNamedPipe(pipe, NULL)) + continue; + for (;;) { + if (ReadFile(pipe, (void*)message, IN_BUFFER_SIZE, &len, NULL) + && len == IN_BUFFER_SIZE) + { + WaitForSingleObject(image_mutex, INFINITE); + if (strcmp(message, "default") == 0) { + exit(0); + } + loadImage(message); + InvalidateRect(window, NULL, FALSE); + ReleaseMutex(image_mutex); + } else { + break; + } + } + DisconnectNamedPipe(pipe); + } + + CloseHandle(pipe); + + return 0; +} + +int do_journal() +{ + // Create + HINSTANCE module = GetModuleHandleW(NULL); + + loadImage("default"); + + // Initial image + char message[IN_BUFFER_SIZE]; + DWORD len; + HANDLE pipe = CreateFileW(L"\\\\.\\pipe\\oneshot-journal-to-game", + GENERIC_READ, + 0, + NULL, + OPEN_EXISTING, + 0, + NULL); + if (pipe != INVALID_HANDLE_VALUE) { + if (ReadFile(pipe, (void*)message, IN_BUFFER_SIZE, &len, NULL) + && len == IN_BUFFER_SIZE) + { + loadImage(message); + } + CloseHandle(pipe); + } + + WNDCLASSEXW wc; + wc.cbSize = sizeof(wc); + wc.style = 0; + wc.lpfnWndProc = journal_proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = module; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = journal_classname; + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + if (!RegisterClassEx(&wc)) + return 1; + + if (!(window = CreateWindowExW(WS_EX_COMPOSITED | WS_EX_LAYERED | WS_EX_TOPMOST, + journal_classname, + L"", + WS_OVERLAPPEDWINDOW ^ (WS_THICKFRAME | WS_MAXIMIZEBOX), + CW_USEDEFAULT, CW_USEDEFAULT, + DEFAULT_WIDTH, DEFAULT_HEIGHT, + NULL, NULL, module, NULL))) { + return 1; + } + + SetLayeredWindowAttributes(window, RGB(0, 255, 0), 0, LWA_COLORKEY); + + ShowWindow(window, SW_SHOWNOACTIVATE); + UpdateWindow(window); + + image_mutex = CreateMutexW(NULL, NULL, NULL); + HANDLE thread = CreateThread(NULL, 0, ipc_thread, NULL, 0, NULL); + + // Dispatch messages + for (;;) { + MSG msg; + if (GetMessage(&msg, window, 0, 0) > 0) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + break; + } + } + + // TODO make this less messy? + TerminateThread(thread, 0); + + DestroyWindow(window); + + return 0; +} diff --git a/journal/journal.pro b/journal/journal.pro new file mode 100644 index 0000000..15b2533 --- /dev/null +++ b/journal/journal.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +CONFIG += c++11 +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += main.cpp \ + niko.cpp \ + journal.cpp + +LIBS += -lgdi32 + +RC_FILE = resources.rc diff --git a/journal/main.cpp b/journal/main.cpp new file mode 100644 index 0000000..28e46e7 --- /dev/null +++ b/journal/main.cpp @@ -0,0 +1,27 @@ +#include + +extern int do_niko(int x, int y); +extern int do_journal(); + +int WINAPI WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + (void)hInstance; + (void)hPrevInstance; + (void)lpCmdLine; + (void)nCmdShow; + + int argc; + LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); + + // argc == 3, assume niko + if (argc == 3) { + int x = _wtoi(argv[1]); + int y = _wtoi(argv[2]); + return do_niko(x, y); + } + // assume journal + return do_journal(); +} diff --git a/journal/niko.cpp b/journal/niko.cpp new file mode 100644 index 0000000..af195a0 --- /dev/null +++ b/journal/niko.cpp @@ -0,0 +1,130 @@ +#include + +static const WCHAR niko_classname[] = L"niko"; +static HWND niko = NULL; +static HBITMAP niko_bmps[3] = {NULL}; +static int niko_offset = 0; + +// Window procedure +LRESULT CALLBACK niko_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_CLOSE: + return 0; + + case WM_PAINT: { + static int frame = 0; + if (niko_offset % 32 >= 16) { + frame = 1; + } else { + if ((niko_offset / 32) % 2) + frame = 0; + else + frame = 2; + } + + PAINTSTRUCT ps; + HDC hdc; + BITMAP bitmap; + HDC hdcMem; + HGDIOBJ oldBitmap; + + hdc = BeginPaint(hwnd, &ps); + + hdcMem = CreateCompatibleDC(hdc); + oldBitmap = SelectObject(hdcMem, niko_bmps[frame]); + + GetObject(niko_bmps[frame], sizeof(bitmap), &bitmap); + BitBlt(hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY); + + SelectObject(hdcMem, oldBitmap); + DeleteDC(hdcMem); + + EndPaint(hwnd, &ps); + } + break; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return 0; +} + +int do_niko(int x, int y) +{ + // Create + HINSTANCE module = GetModuleHandleW(NULL); + niko_bmps[0] = LoadBitmapW(module, L"NIKO1"); + niko_bmps[1] = LoadBitmapW(module, L"NIKO2"); + niko_bmps[2] = LoadBitmapW(module, L"NIKO3"); + + WNDCLASSEXW wc; + wc.cbSize = sizeof(wc); + wc.style = 0; + wc.lpfnWndProc = niko_proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = module; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = niko_classname; + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + if (!RegisterClassEx(&wc)) + return 1; + + if (!(niko = CreateWindowExW(WS_EX_COMPOSITED | WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW, + niko_classname, + L"Niko", + WS_POPUP, + x, y, + 24 * 2, 32 * 2, + NULL, NULL, module, NULL))) { + return 1; + } + + SetLayeredWindowAttributes(niko, RGB(0, 255, 0), 0, LWA_COLORKEY); + + ShowWindow(niko, SW_SHOWNOACTIVATE); + UpdateWindow(niko); + + // Thread + int screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + + // Get starting position + RECT area; + GetWindowRect(niko, &area); + + // Just keep walking down + for (;;) { + // Dispatch messages + unsigned long tick = GetTickCount(); + for (;;) { + MSG msg; + if (PeekMessage(&msg, niko, 0, 0, PM_REMOVE) > 0) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + if (GetTickCount() - tick >= 1000 / 60) + break; + } + } + + niko_offset += 2; + if (area.top + niko_offset >= screenHeight) + break; + SetWindowPos(niko, NULL, area.left, area.top + niko_offset, 0, 0, SWP_NOSIZE); + InvalidateRect(niko, NULL, FALSE); + } + + DestroyWindow(niko); + + for (int i = 0; i < 3; i++) { + if (niko_bmps[i]) + DeleteObject(niko_bmps[i]); + } + + return 0; +} diff --git a/journal/resources.rc b/journal/resources.rc new file mode 100644 index 0000000..e5e1a0c --- /dev/null +++ b/journal/resources.rc @@ -0,0 +1,29 @@ +#include +NIKO1 BITMAP "niko1.bmp" +NIKO2 BITMAP "niko2.bmp" +NIKO3 BITMAP "niko3.bmp" + +default BITMAP "default.bmp" +t1 BITMAP "t1.bmp" +t2 BITMAP "t2.bmp" +t3 BITMAP "t3.bmp" +t4 BITMAP "t4.bmp" +t5 BITMAP "t5.bmp" +t6 BITMAP "t6.bmp" +t7 BITMAP "t7.bmp" +t8 BITMAP "t8.bmp" +t9 BITMAP "t9.bmp" +t10 BITMAP "t10.bmp" +t11 BITMAP "t11.bmp" +t12 BITMAP "t12.bmp" +t13 BITMAP "t13.bmp" +t14 BITMAP "t14.bmp" +t15 BITMAP "t15.bmp" +t16 BITMAP "t16.bmp" +c1 BITMAP "c1.bmp" +c2 BITMAP "c2.bmp" +c3 BITMAP "c3.bmp" +c4 BITMAP "c4.bmp" +c5 BITMAP "c5.bmp" +c6 BITMAP "c6.bmp" +c7 BITMAP "c7.bmp" diff --git a/mkxp.pro b/mkxp.pro index 2436627..49f54e0 100644 --- a/mkxp.pro +++ b/mkxp.pro @@ -1,299 +1,300 @@ - - -TEMPLATE = app -QT = -TARGET = oneshot -DEPENDPATH += src shader assets -INCLUDEPATH += . src - -CONFIG -= qt -CONFIG += link_pkgconfig - -CONFIG(release, debug|release): DEFINES += NDEBUG - -isEmpty(BINDING) { - BINDING = MRI -} - -contains(BINDING, MRI) { - contains(_HAVE_BINDING, YES) { - error("Only one binding may be selected") - } - _HAVE_BINDING = YES - - CONFIG += BINDING_MRI -} - -contains(BINDING, MRUBY) { - contains(_HAVE_BINDING, YES) { - error("Only one binding may be selected") - } - _HAVE_BINDING = YES - - CONFIG += BINDING_MRUBY -} - -contains(BINDING, NULL) { - contains(_HAVE_BINDING, YES) { - error("Only one binding may be selected") - } - _HAVE_BINDING = YES - - CONFIG += BINDING_NULL -} - -unix { - CONFIG += c++11 - PKGCONFIG += sigc++-2.0 pixman-1 vorbisfile \ - sdl2 SDL2_image SDL2_ttf SDL_sound physfs - LIBS += -ldl - macx: { - CONFIG -= app_bundle - INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers - LIBS += -framework OpenAL - } - !macx: { - PKGCONFIG += openal zlib - INCLUDEPATH += /usr/include/AL /usr/local/include/AL - } -} - -win32 { - QMAKE_CXXFLAGS += -std=gnu++11 - QMAKE_LFLAGS += -std=gnu++11 - - PKGCONFIG += sigc++-2.0 pixman-1 zlib \ - sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile freetype2 - LIBS += -lphysfs -lsecur32 - - release { - RC_FILE = assets/resources.rc - } -} - -# Deal with boost paths... -isEmpty(BOOST_I) { - BOOST_I = $$(BOOST_I) -} -isEmpty(BOOST_I) {} -else { - INCLUDEPATH += $$BOOST_I -} - -isEmpty(BOOST_L) { - BOOST_L = $$(BOOST_L) -} -isEmpty(BOOST_L) {} -else { - LIBS += -L$$BOOST_L -} - -isEmpty(BOOST_LIB_SUFFIX) { - BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX) -} - -LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX - -STEAM { - DEFINES += STEAM -} - -# Input -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/sdl-util.h \ - src/oneshot.h \ - src/pipe.h - -SOURCES += \ - 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/vorbissource.cpp \ - src/oneshot.cpp \ - binding-mri/steam-binding.cpp \ - src/xdg-user-dir-lookup.c \ - src/screen.cpp \ - binding-mri/screen-binding.cpp \ - binding-mri/wallpaper-binding.cpp - -STEAM { - HEADERS += src/steam.h steamshim/steamshim_child.h - SOURCES += src/steam.cpp steamshim/steamshim_child.c -} - -EMBED = \ - 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/obscured.frag \ - shader/minimal.vert \ - shader/simple.vert \ - shader/simpleColor.vert \ - shader/sprite.vert \ - shader/tilemap.vert \ - shader/blur.frag \ - shader/blurH.vert \ - shader/blurV.vert \ - shader/simpleMatrix.vert \ - assets/icon.png \ - assets/gamecontrollerdb.txt - -defineReplace(xxdOutput) { - return($$basename(1).xxd) -} - -# xxd -xxd.output_function = xxdOutput -xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT} -xxd.depends = $$EMBED -xxd.input = EMBED -xxd.variable_out = HEADERS - -QMAKE_EXTRA_COMPILERS += xxd - - -BINDING_NULL { - SOURCES += binding-null/binding-null.cpp -} - -BINDING_MRI { - isEmpty(MRIVERSION) { - MRIVERSION = 2.2 - } - - PKGCONFIG += ruby-$$MRIVERSION - DEFINES += BINDING_MRI - -# EMBED2 = binding-mri/module_rpg.rb -# xxdp.output = ${QMAKE_FILE_NAME}.xxd -# xxdp.commands = xxd+/xxd+ ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} --string -# xxdp.depends = $$EMBED2 -# xxdp.input = EMBED2 -# xxdp.variable_out = HEADERS -# QMAKE_EXTRA_COMPILERS += xxdp - - 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 - - SOURCES += \ - 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/oneshot-binding.cpp -} - -OTHER_FILES += $$EMBED + + +TEMPLATE = app +QT = +TARGET = oneshot +DEPENDPATH += src shader assets +INCLUDEPATH += . src + +CONFIG -= qt +CONFIG += link_pkgconfig + +CONFIG(release, debug|release): DEFINES += NDEBUG + +isEmpty(BINDING) { + BINDING = MRI +} + +contains(BINDING, MRI) { + contains(_HAVE_BINDING, YES) { + error("Only one binding may be selected") + } + _HAVE_BINDING = YES + + CONFIG += BINDING_MRI +} + +contains(BINDING, MRUBY) { + contains(_HAVE_BINDING, YES) { + error("Only one binding may be selected") + } + _HAVE_BINDING = YES + + CONFIG += BINDING_MRUBY +} + +contains(BINDING, NULL) { + contains(_HAVE_BINDING, YES) { + error("Only one binding may be selected") + } + _HAVE_BINDING = YES + + CONFIG += BINDING_NULL +} + +unix { + CONFIG += c++11 + PKGCONFIG += sigc++-2.0 pixman-1 vorbisfile \ + sdl2 SDL2_image SDL2_ttf SDL_sound physfs + LIBS += -ldl + macx: { + CONFIG -= app_bundle + INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers + LIBS += -framework OpenAL + } + !macx: { + PKGCONFIG += openal zlib + INCLUDEPATH += /usr/include/AL /usr/local/include/AL + SOURCES += src/xdg-user-dir-lookup.c + } +} + +win32 { + QMAKE_CXXFLAGS += -std=gnu++11 + QMAKE_LFLAGS += -std=gnu++11 + + PKGCONFIG += sigc++-2.0 pixman-1 zlib \ + sdl2 SDL2_image SDL2_ttf openal SDL_sound vorbisfile freetype2 + LIBS += -lphysfs -lsecur32 + + release { + RC_FILE = assets/resources.rc + } +} + +# Deal with boost paths... +isEmpty(BOOST_I) { + BOOST_I = $$(BOOST_I) +} +isEmpty(BOOST_I) {} +else { + INCLUDEPATH += $$BOOST_I +} + +isEmpty(BOOST_L) { + BOOST_L = $$(BOOST_L) +} +isEmpty(BOOST_L) {} +else { + LIBS += -L$$BOOST_L +} + +isEmpty(BOOST_LIB_SUFFIX) { + BOOST_LIB_SUFFIX = $$(BOOST_LIB_SUFFIX) +} + +LIBS += -lboost_program_options$$BOOST_LIB_SUFFIX + +STEAM { + DEFINES += STEAM +} + +# Input +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/sdl-util.h \ + src/oneshot.h \ + src/pipe.h + +SOURCES += \ + 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/vorbissource.cpp \ + src/oneshot.cpp \ + src/screen.cpp \ + binding-mri/journal-binding.cpp + +STEAM { + HEADERS += src/steam.h steamshim/steamshim_child.h + SOURCES += src/steam.cpp steamshim/steamshim_child.c +} + +EMBED = \ + 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/obscured.frag \ + shader/minimal.vert \ + shader/simple.vert \ + shader/simpleColor.vert \ + shader/sprite.vert \ + shader/tilemap.vert \ + shader/blur.frag \ + shader/blurH.vert \ + shader/blurV.vert \ + shader/simpleMatrix.vert \ + assets/icon.png \ + assets/gamecontrollerdb.txt + +defineReplace(xxdOutput) { + return($$basename(1).xxd) +} + +# xxd +xxd.output_function = xxdOutput +xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT} +xxd.depends = $$EMBED +xxd.input = EMBED +xxd.variable_out = HEADERS + +QMAKE_EXTRA_COMPILERS += xxd + + +BINDING_NULL { + SOURCES += binding-null/binding-null.cpp +} + +BINDING_MRI { + isEmpty(MRIVERSION) { + MRIVERSION = 2.2 + } + + PKGCONFIG += ruby-$$MRIVERSION + DEFINES += BINDING_MRI + +# EMBED2 = binding-mri/module_rpg.rb +# xxdp.output = ${QMAKE_FILE_NAME}.xxd +# xxdp.commands = xxd+/xxd+ ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} --string +# xxdp.depends = $$EMBED2 +# xxdp.input = EMBED2 +# xxdp.variable_out = HEADERS +# QMAKE_EXTRA_COMPILERS += xxdp + + 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 + + SOURCES += \ + 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/oneshot-binding.cpp \ + binding-mri/steam-binding.cpp \ + binding-mri/wallpaper-binding.cpp \ + binding-mri/niko-binding.cpp +} + +OTHER_FILES += $$EMBED