From cd9597010a71e7d4ec51298cd9c2fc77371b6fa0 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 02:04:03 -0800 Subject: [PATCH 1/9] Update readme --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8afb37e..8208572 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This is a specialized fork of [mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/). -Thanks to [hunternet93](https://github.com/hunternet93) for the macOS and Linux [reimplementation of the journal program](https://github.com/hunternet93/OneShot-Journal)! +Thanks to [hunternet93](https://github.com/hunternet93) for starting the reimplementation of the journal program! > mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file. > @@ -13,6 +13,7 @@ Thanks to [hunternet93](https://github.com/hunternet93) for the macOS and Linux ## Dependencies / Building * Qt5 +* CMake (macOS only) * Boost.Unordered (headers only) * Boost.Program_options * Boost.CRC @@ -27,9 +28,9 @@ Thanks to [hunternet93](https://github.com/hunternet93) for the macOS and Linux * pixman * zlib (only ruby bindings) * OpenGL header (alternatively GLES2 with `DEFINES+=GLES2_HEADER`) -* Ruby (make sure to use 2.3 on macOS and Linux(?) due to a save formatting bug) -* Python 3 (macOS/Linux journal reimplementation only) -* PyQt5 (macOS/Linux journal reimplementation only) +* Ruby (make sure to use 2.3 on macOS and Linux(?) due to a save formatting bug in newer versions) +* Python 3 (journal reimplementation only) +* PyQt5 for Python 3 (journal reimplementation only) *SyngleChance* employs Qt's qmake build system, so you'll need to install that beforehand. (The cmake build hasn't been maintained since the fork.) @@ -39,10 +40,10 @@ The exception is boost, which is weird in that it still hasn't managed to pull o By default, *SyngleChance* switches into the directory where its binary is contained and then starts reading the configuration and resolving relative paths. In case this is undesired (eg. when the binary is to be installed to a system global, read-only location), it can be turned off by adding `DEFINES+=WORKDIR_CURRENT` to qmake's arguments. -pkg-config will look for `ruby-2.2.pc`, but you can override the version with `MRIVERSION=2.3` ('2.3' being an example). This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit). +pkg-config will look for `ruby-2.3.pc`, but you can override the version with `MRIVERSION=2.5` ('2.5' being an example). This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit). ### Supported image/audio formats -These depend on the SDL auxiliary libraries. *SyngleChance* only makes use of png for images and oggvorbis/wav for audio. +These depend on the SDL auxiliary libraries. *SyngleChance* only makes use of bmp/png for images and oggvorbis/wav for audio. To run *SyngleChance*, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed. From 4df91ac787c6e1a8c2553f173b4ceefe807b49dd Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 02:13:19 -0800 Subject: [PATCH 2/9] Remove unneeded lines in journal --- journal/unix/journal.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/journal/unix/journal.py b/journal/unix/journal.py index 8339e5c..0ad0657 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -93,9 +93,6 @@ class Niko(QWidget): self.frames = [QPixmap(os.path.join(base_path, 'images', 'niko{}.png'.format(n))) for n in range(1,4)] - self.setBackgroundRole(QPalette.Base) - self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - if __name__ == '__main__': app = QApplication(sys.argv) From d0ef02098569a071f3b39cb08f7f7bd638a7b1be Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 02:13:29 -0800 Subject: [PATCH 3/9] Rename start_x/y to x/y --- journal/unix/journal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/journal/unix/journal.py b/journal/unix/journal.py index 0ad0657..c00db13 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -77,9 +77,9 @@ class Journal(QWidget): class Niko(QWidget): def __init__(self, *args, **kwargs): - self.start_x, self.start_y = kwargs['start_x'], kwargs['start_y'] + self.x, self.y = kwargs['x'], kwargs['y'] self.screen_width, self.screen_height = kwargs['screen_width'], kwargs['screen_height'] - del kwargs['start_x'], kwargs['start_y'], kwargs['screen_width'], kwargs['screen_height'] + del kwargs['x'], kwargs['y'], kwargs['screen_width'], kwargs['screen_height'] super().__init__(*args, **kwargs) @@ -101,7 +101,7 @@ if __name__ == '__main__': x, y = int(sys.argv[1]), int(sys.argv[2]) screensize = app.primaryScreen().size() - niko = Niko(start_x = x, start_y = y, screen_width = screensize.width(), screen_height = screensize.height()) + niko = Niko(x = x, y = y, screen_width = screensize.width(), screen_height = screensize.height()) else: # Author's Journal mode From 9b6030414c95c0cd39e4c700f28b6d56e338cbf9 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 02:55:08 -0800 Subject: [PATCH 4/9] Implement Niko walking off part of journal --- journal/unix/journal.py | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/journal/unix/journal.py b/journal/unix/journal.py index c00db13..1ac2ca8 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -33,6 +33,14 @@ class WatchPipe(QThread): self.change_image.emit(message.decode()) time.sleep(0.05) + +class AnimationTimer(QThread): + next_frame = pyqtSignal() + + def run(self): + while True: + self.next_frame.emit() + time.sleep(1.0/60) class Journal(QWidget): def __init__(self, *args, **kwargs): @@ -77,21 +85,37 @@ class Journal(QWidget): class Niko(QWidget): def __init__(self, *args, **kwargs): - self.x, self.y = kwargs['x'], kwargs['y'] + self.x, self.y, self.start_y, self.app, self.thread = kwargs['x'], kwargs['y'], kwargs['y'], kwargs['app'], kwargs['thread'] self.screen_width, self.screen_height = kwargs['screen_width'], kwargs['screen_height'] - del kwargs['x'], kwargs['y'], kwargs['screen_width'], kwargs['screen_height'] + del kwargs['x'], kwargs['y'], kwargs['screen_width'], kwargs['screen_height'], kwargs['app'], kwargs['thread'] super().__init__(*args, **kwargs) - self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) + self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setAttribute(Qt.WA_TranslucentBackground) - self.setMouseTracking(True) self.setWindowTitle('') self.setMinimumSize(self.screen_width, self.screen_height) self.setMaximumSize(self.screen_width, self.screen_height) - self.setGeometry(0, 0, self.screen_width, self.screen_height) + self.setGeometry(self.x, self.y, self.x+48, self.y+64) + self.label = QLabel(self) 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() + + self.thread.start() + + def getFrame(self): + if ((self.y - self.start_y) % 32 >= 16): return 1 + if ((self.y - self.start_y) % 64 >= 32): return 0 + else: return 2 + + def update(self): + self.label.setPixmap(self.frames[self.getFrame()]) + self.y += 2 + self.setGeometry(self.x, self.y, self.x+48, self.y+64) + if self.y > self.screen_height: self.app.quit() if __name__ == '__main__': app = QApplication(sys.argv) @@ -101,7 +125,11 @@ if __name__ == '__main__': x, y = int(sys.argv[1]), int(sys.argv[2]) screensize = app.primaryScreen().size() - niko = Niko(x = x, y = y, screen_width = screensize.width(), screen_height = screensize.height()) + thread = AnimationTimer() + + niko = Niko(x = x, y = y, screen_width = screensize.width(), screen_height = screensize.height(), app = app, thread = thread) + + thread.next_frame.connect(niko.update) else: # Author's Journal mode From dc51296d20a661ba73306df728bd76599c02908c Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 02:58:09 -0800 Subject: [PATCH 5/9] Fix imports --- journal/unix/journal.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/journal/unix/journal.py b/journal/unix/journal.py index 1ac2ca8..f24d75d 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -import os -import sys -import time +import os, sys, time from PyQt5.QtCore import Qt, QEvent, QThread, pyqtSignal, QRect, QRectF, QTimer, QPoint from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget, QLabel From cddd5d8a4fc30a99caeb6bb338b00692695d09f4 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 03:34:46 -0800 Subject: [PATCH 6/9] Bump version number --- make-oneshot-mac.command | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make-oneshot-mac.command b/make-oneshot-mac.command index 5931d89..f6b4ac1 100755 --- a/make-oneshot-mac.command +++ b/make-oneshot-mac.command @@ -4,7 +4,7 @@ set -e cd `dirname $0` # User-configurable variables -mac_version="0.7.1" +mac_version="0.8.0" make_threads=8 ONESHOT_PATH=$HOME/Library/Application\ Support/Steam/steamapps/common/OneShot From 00dcba7785034905e616334ca841cbf13d6de72e Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 03:34:55 -0800 Subject: [PATCH 7/9] Fix Journal path for macOS --- src/oneshot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 95a2242..65e9521 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -585,7 +585,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : p->docsPath = path.c_str(); p->gamePath = path.c_str(); #ifdef OS_OSX - p->journal = "_______.app"; + p->journal = "_______.app/Contents/MacOS/_______"; #elif defined OS_LINUX p->journal = "_______"; #endif From b9d5b954b52c3ca87df813510986df96a8544d18 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 03:48:38 -0800 Subject: [PATCH 8/9] Bind journal to ending on macOS and Linux --- binding-mri/niko-binding.cpp | 67 +++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index 20c9d6c..a91b63e 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -13,6 +13,8 @@ #else #define OS_LINUX #endif + + #include #endif #include @@ -32,7 +34,7 @@ RB_METHOD(nikoStart) SDL_VERSION(&syswindow.version); SDL_GetWindowWMInfo(shState->rtData().window, &syswindow); -#if defined _WIN32 +#ifdef _WIN32 // Calculate where to stick the window POINT pos; pos.x = NIKO_X; @@ -50,36 +52,53 @@ RB_METHOD(nikoStart) si.cb = sizeof(si); PROCESS_INFORMATION pi; CreateProcessW(path, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); -#elif defined LINUX +#else // Calculate where to stick the window int x, y; // Top-left area of client (hopefully) 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 path[PATH_MAX]; - ssize_t len = readlink("/proc/self/exe", path, PATH_MAX); - if (len > 0) { - // Replace filename - for (size_t i = len; i > 0; --i) { - if (path[i-1] == '/') { - strcpy(path + i, "_______"); - break; - } - } - // X and Y string arguments - char x_str[16]; - char y_str[16]; - sprintf(x_str, "%d", x); - sprintf(y_str, "%d", y); - // Assume that was a success and run the binary - pid_t pid = fork(); - if (pid == 0) { - execl(path, "_______", x_str, y_str, NULL); - exit(1); - } + 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(), x_str, y_str, (char*)0); + exit(1); } -#else -#error "not yet implemented" + + // ssize_t len = readlink("/proc/self/exe", path, PATH_MAX); + // if (len > 0) { + // // Replace filename + // for (size_t i = len; i > 0; --i) { + // if (path[i-1] == '/') { + // strcpy(path + i, "_______"); + // break; + // } + // } + // // Run the binary + // pid_t pid = fork(); + // if (pid == 0) { + // execl(path, "_______", x_str, y_str, (char*)0); + + // exit(1); + // } + // } #endif return Qnil; } From 4fd06b9a82c3500e7e0c5706ac392e0796820ff1 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Thu, 8 Mar 2018 11:33:31 -0800 Subject: [PATCH 9/9] Fix Journal execution Fixes #19 --- binding-mri/niko-binding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index a91b63e..bc21751 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -78,7 +78,7 @@ RB_METHOD(nikoStart) // Run the binary pid_t pid = fork(); if (pid == 0) { - execl(journal.c_str(), x_str, y_str, (char*)0); + execl(journal.c_str(), journal.c_str(), x_str, y_str, (char*)0); exit(1); }