This commit is contained in:
KockaAdmiralac 2018-03-14 16:34:52 +01:00
commit 973084d017
69 changed files with 73 additions and 36 deletions

View File

@ -28,7 +28,7 @@ Thanks to [hunternet93](https://github.com/hunternet93) for starting the reimple
* pixman * pixman
* zlib (only ruby bindings) * zlib (only ruby bindings)
* OpenGL header (alternatively GLES2 with `DEFINES+=GLES2_HEADER`) * 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 in newer versions) * Ruby (make sure to use 2.3 on macOS due to a save formatting bug in newer versions -- @Yummychickenblue reports this may not be an issue anymore)
* Python 3 (journal reimplementation only) * Python 3 (journal reimplementation only)
* PyQt5 for Python 3 (journal reimplementation only) * PyQt5 for Python 3 (journal reimplementation only)

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

View File

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 267 KiB

View File

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB

View File

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 228 KiB

View File

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 252 KiB

View File

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 183 KiB

View File

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

View File

Before

Width:  |  Height:  |  Size: 286 KiB

After

Width:  |  Height:  |  Size: 286 KiB

View File

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

View File

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 266 KiB

View File

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 217 KiB

View File

Before

Width:  |  Height:  |  Size: 288 KiB

After

Width:  |  Height:  |  Size: 288 KiB

View File

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 269 KiB

View File

Before

Width:  |  Height:  |  Size: 265 KiB

After

Width:  |  Height:  |  Size: 265 KiB

View File

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 247 KiB

View File

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 226 KiB

View File

Before

Width:  |  Height:  |  Size: 358 KiB

After

Width:  |  Height:  |  Size: 358 KiB

View File

Before

Width:  |  Height:  |  Size: 565 KiB

After

Width:  |  Height:  |  Size: 565 KiB

View File

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB

View File

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 248 KiB

View File

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 133 KiB

View File

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 207 KiB

View File

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

View File

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 257 KiB

View File

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

Before

Width:  |  Height:  |  Size: 328 KiB

After

Width:  |  Height:  |  Size: 328 KiB

View File

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View File

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

View File

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB

View File

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 180 KiB

View File

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 233 KiB

View File

Before

Width:  |  Height:  |  Size: 275 KiB

After

Width:  |  Height:  |  Size: 275 KiB

View File

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 217 KiB

View File

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 262 KiB

View File

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 216 KiB

View File

Before

Width:  |  Height:  |  Size: 286 KiB

After

Width:  |  Height:  |  Size: 286 KiB

View File

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 267 KiB

View File

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 266 KiB

View File

Before

Width:  |  Height:  |  Size: 244 KiB

After

Width:  |  Height:  |  Size: 244 KiB

View File

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

View File

Before

Width:  |  Height:  |  Size: 357 KiB

After

Width:  |  Height:  |  Size: 357 KiB

View File

Before

Width:  |  Height:  |  Size: 525 KiB

After

Width:  |  Height:  |  Size: 525 KiB

View File

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

View File

Before

Width:  |  Height:  |  Size: 241 KiB

After

Width:  |  Height:  |  Size: 241 KiB

View File

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 133 KiB

View File

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 152 KiB

View File

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

View File

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

View File

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 254 KiB

View File

Before

Width:  |  Height:  |  Size: 218 KiB

After

Width:  |  Height:  |  Size: 218 KiB

View File

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 99 KiB

View File

Before

Width:  |  Height:  |  Size: 313 KiB

After

Width:  |  Height:  |  Size: 313 KiB

View File

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View File

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 249 KiB

View File

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

View File

@ -6,26 +6,36 @@ from PyQt5.QtCore import Qt, QEvent, QThread, pyqtSignal, QRect, QRectF, QTimer,
from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget, QLabel from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget, QLabel
from PyQt5.QtGui import QIcon, QPixmap, QPainter from PyQt5.QtGui import QIcon, QPixmap, QPainter
if sys.platform == "win32": pipe_path = '\\\\.\\pipe\\oneshot-journal-to-game' if sys.platform == "win32":
else: pipe_path = '/tmp/oneshot-pipe' pipe_path = '\\\\.\\pipe\\oneshot-journal-to-game'
import ctypes.wintypes
buff = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf)
documents_path = os.path.join(buf.value, 'My Games')
else:
pipe_path = '/tmp/oneshot-pipe'
documents_path = os.path.expanduser('~/Documents')
left_close = False
if sys.platform == "darwin": left_close = True
try: base_path = sys._MEIPASS try: base_path = sys._MEIPASS
except AttributeError: base_path = os.path.abspath('.') except AttributeError: base_path = os.path.abspath('.')
class WatchPipe(QThread): class WatchPipe(QThread):
change_image = pyqtSignal(str) change_image = pyqtSignal(str)
def run(self): def run(self):
while True: while True:
while True: while True:
if os.path.exists(pipe_path): break if os.path.exists(pipe_path): break
else: time.sleep(0.1) else: time.sleep(0.1)
pipe = open(pipe_path, 'r') pipe = open(pipe_path, 'r')
pipe.flush() pipe.flush()
while True: while True:
if not os.path.exists(pipe_path): break # Handle game quitting cleanup if not os.path.exists(pipe_path):
break # Handle game quitting cleanup
message = os.read(pipe.fileno(), 256) message = os.read(pipe.fileno(), 256)
if len(message) > 0: if len(message) > 0:
self.change_image.emit(message.decode()) self.change_image.emit(message.decode())
@ -38,10 +48,13 @@ class AnimationTimer(QThread):
def run(self): def run(self):
while True: while True:
self.next_frame.emit() self.next_frame.emit()
time.sleep(1.0/60) time.sleep(1.0 / 60)
class Journal(QWidget): class Journal(QWidget):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.app = kwargs['app']
del kwargs['app']
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.mousedown = False self.mousedown = False
@ -49,11 +62,16 @@ class Journal(QWidget):
self.label = QLabel(self) self.label = QLabel(self)
self.change_image('default_en') self.change_image('default_en')
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint) self.close_label = QLabel(self)
self.close_label.setPixmap(QPixmap(os.path.join(base_path, 'images', 'close.png')))
if not left_close: self.close_label.move(776, 0) # X = 800-24
if "linux" in sys.platform: self.setWindowFlags(Qt.FramelessWindowHint)
else: self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint | Qt.NoDropShadowWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WA_TranslucentBackground)
self.setMouseTracking(True) self.setMouseTracking(True)
self.setWindowTitle('') self.setWindowTitle(' ')
self.setMinimumSize(800, 600) self.setMinimumSize(800, 600)
self.setMaximumSize(800, 600) self.setMaximumSize(800, 600)
self.setGeometry(0, 0, 800, 600) self.setGeometry(0, 0, 800, 600)
@ -63,6 +81,9 @@ class Journal(QWidget):
self.mousedown = True self.mousedown = True
self.mousedownpos = event.pos() self.mousedownpos = event.pos()
if ((left_close and self.mousedownpos.x() <= 24) or (not left_close and self.mousedownpos.x() >= 776)) and self.mousedownpos.y() < 24:
self.app.quit()
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
self.mousedown = False self.mousedown = False
@ -71,31 +92,30 @@ class Journal(QWidget):
pos = event.pos() pos = event.pos()
frameGm = self.frameGeometry() frameGm = self.frameGeometry()
self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600) self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600)
def change_image(self, image): def change_image(self, image):
name, lang = image.split('_', 1) name, lang = image.split('_', 1)
img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name)) if lang == 'en':
if not os.path.exists(img):
img = os.path.join(base_path, 'images', '{}.png'.format(name)) img = os.path.join(base_path, 'images', '{}.png'.format(name))
if not os.path.exists(img): return 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.pixmap = QPixmap(img)
self.label.setPixmap(self.pixmap) self.label.setPixmap(self.pixmap)
class Niko(QWidget): class Niko(QWidget):
def __init__(self, *args, **kwargs): 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.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'] self.screen_height = kwargs['screen_height']
del kwargs['x'], kwargs['y'], kwargs['screen_width'], kwargs['screen_height'], kwargs['app'], kwargs['thread'] del kwargs['x'], kwargs['y'], kwargs['screen_height'], kwargs['app'], kwargs['thread']
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowTitle('') self.setMinimumSize(48, 64)
self.setMinimumSize(self.screen_width, self.screen_height) self.setMaximumSize(48, 64)
self.setMaximumSize(self.screen_width, self.screen_height)
self.setGeometry(self.x, self.y, self.x+48, self.y+64)
self.label = QLabel(self) self.label = QLabel(self)
self.frames = [QPixmap(os.path.join(base_path, 'images', 'niko{}.png'.format(n))) for n in range(1,4)] 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.label.setPixmap(self.frames[1])
@ -112,8 +132,13 @@ class Niko(QWidget):
def update(self): def update(self):
self.label.setPixmap(self.frames[self.getFrame()]) self.label.setPixmap(self.frames[self.getFrame()])
self.y += 2 self.y += 2
self.setGeometry(self.x, self.y, self.x+48, self.y+64) if self.y > self.screen_height:
if self.y > self.screen_height: self.app.quit() self.app.quit()
return
elif self.y > self.screen_height - 64:
self.setMinimumSize(48, self.screen_height - self.y)
self.resize(48, self.screen_height - self.y)
self.move(self.x, self.y)
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)
@ -121,20 +146,28 @@ if __name__ == '__main__':
if len(sys.argv) == 3: if len(sys.argv) == 3:
# "Niko-leaves-the-screen" mode # "Niko-leaves-the-screen" mode
x, y = int(sys.argv[1]), int(sys.argv[2]) x, y = int(sys.argv[1]), int(sys.argv[2])
screensize = app.primaryScreen().size()
thread = AnimationTimer() thread = AnimationTimer()
niko = Niko(x = x, y = y, screen_width = screensize.width(), screen_height = screensize.height(), app = app, thread = thread) niko = Niko(x = x, y = y, screen_height = app.primaryScreen().size().height(), app = app, thread = thread)
thread.next_frame.connect(niko.update) thread.next_frame.connect(niko.update)
else: else:
# Author's Journal mode # Author's Journal mode
journal = Journal() journal = Journal(app = app)
save_path = os.path.join(documents_path, 'Oneshot', 'save_progress.oneshot')
thread = WatchPipe() if os.path.exists(save_path):
thread.change_image.connect(journal.change_image) with open(save_path, 'rb') as save:
thread.start() save.seek(-8, os.SEEK_END)
lang = save.read().decode('utf-8')
lang = lang[lang.find('[') + 1:lang.find(']')]
if lang == 'en_US':
lang = 'en'
journal.change_image('save_' + lang)
else:
thread = WatchPipe()
thread.change_image.connect(journal.change_image)
thread.start()
app.exec_() app.exec_()

View File

@ -19,7 +19,7 @@ echo "${white}Compiling ${bold}SyngleChance v${linux_version} ${white}engine for
# Generate makefile and build main + journal # Generate makefile and build main + journal
echo "-> ${cyan}Generate makefile...${color_reset}" echo "-> ${cyan}Generate makefile...${color_reset}"
qmake MRIVERSION=2.3 qmake
echo "-> ${cyan}Compile engine...${color_reset}" echo "-> ${cyan}Compile engine...${color_reset}"
make -j${make_threads} make -j${make_threads}
echo "-> ${cyan}Compile journal...${color_reset}" echo "-> ${cyan}Compile journal...${color_reset}"

View File

@ -275,7 +275,11 @@ int main(int argc, char *argv[])
} }
SDL_Window *win; SDL_Window *win;
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_RESIZABLE; //| SDL_WINDOW_ALLOW_HIGHDPI; Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS; //| SDL_WINDOW_ALLOW_HIGHDPI;
#ifdef __APPLE__
winFlags |= SDL_WINDOW_RESIZABLE;
#endif
if (conf.fullscreen) if (conf.fullscreen)
winFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; winFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;