Merge pull request #21 from vinyldarkscratch/journal-update
Journal update
BIN
journal/unix/images/ES/c1.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 267 KiB |
|
Before Width: | Height: | Size: 251 KiB After Width: | Height: | Size: 251 KiB |
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 252 KiB |
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 219 KiB |
|
Before Width: | Height: | Size: 266 KiB After Width: | Height: | Size: 266 KiB |
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 288 KiB |
|
Before Width: | Height: | Size: 269 KiB After Width: | Height: | Size: 269 KiB |
|
Before Width: | Height: | Size: 265 KiB After Width: | Height: | Size: 265 KiB |
|
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 226 KiB |
|
Before Width: | Height: | Size: 358 KiB After Width: | Height: | Size: 358 KiB |
|
Before Width: | Height: | Size: 565 KiB After Width: | Height: | Size: 565 KiB |
|
Before Width: | Height: | Size: 251 KiB After Width: | Height: | Size: 251 KiB |
|
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 248 KiB |
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |
|
Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 112 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 328 KiB After Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 175 KiB |
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 210 KiB |
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 233 KiB |
|
Before Width: | Height: | Size: 275 KiB After Width: | Height: | Size: 275 KiB |
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 217 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 262 KiB |
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 267 KiB |
|
Before Width: | Height: | Size: 266 KiB After Width: | Height: | Size: 266 KiB |
|
Before Width: | Height: | Size: 244 KiB After Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
|
Before Width: | Height: | Size: 525 KiB After Width: | Height: | Size: 525 KiB |
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 241 KiB After Width: | Height: | Size: 241 KiB |
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 225 KiB |
|
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 254 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 313 KiB After Width: | Height: | Size: 313 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 171 KiB |
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
BIN
journal/unix/images/close.png
Normal file
|
After Width: | Height: | Size: 227 B |
|
|
@ -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.QtGui import QIcon, QPixmap, QPainter
|
||||
|
||||
if sys.platform == "win32": pipe_path = '\\\\.\\pipe\\oneshot-journal-to-game'
|
||||
else: pipe_path = '/tmp/oneshot-pipe'
|
||||
if sys.platform == "win32":
|
||||
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
|
||||
except AttributeError: base_path = os.path.abspath('.')
|
||||
|
||||
class WatchPipe(QThread):
|
||||
change_image = pyqtSignal(str)
|
||||
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
while True:
|
||||
if os.path.exists(pipe_path): break
|
||||
else: 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
|
||||
if not os.path.exists(pipe_path):
|
||||
break # Handle game quitting cleanup
|
||||
message = os.read(pipe.fileno(), 256)
|
||||
if len(message) > 0:
|
||||
self.change_image.emit(message.decode())
|
||||
|
|
@ -38,10 +48,13 @@ class AnimationTimer(QThread):
|
|||
def run(self):
|
||||
while True:
|
||||
self.next_frame.emit()
|
||||
time.sleep(1.0/60)
|
||||
|
||||
time.sleep(1.0 / 60)
|
||||
|
||||
class Journal(QWidget):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.app = kwargs['app']
|
||||
del kwargs['app']
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.mousedown = False
|
||||
|
|
@ -49,11 +62,16 @@ class Journal(QWidget):
|
|||
|
||||
self.label = QLabel(self)
|
||||
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.setMouseTracking(True)
|
||||
self.setWindowTitle('')
|
||||
self.setWindowTitle(' ')
|
||||
self.setMinimumSize(800, 600)
|
||||
self.setMaximumSize(800, 600)
|
||||
self.setGeometry(0, 0, 800, 600)
|
||||
|
|
@ -63,6 +81,9 @@ class Journal(QWidget):
|
|||
self.mousedown = True
|
||||
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):
|
||||
self.mousedown = False
|
||||
|
||||
|
|
@ -71,31 +92,30 @@ class Journal(QWidget):
|
|||
pos = event.pos()
|
||||
frameGm = self.frameGeometry()
|
||||
self.setGeometry(frameGm.x() + pos.x() - self.mousedownpos.x(), frameGm.y() + pos.y() - self.mousedownpos.y(), 800, 600)
|
||||
|
||||
|
||||
def change_image(self, image):
|
||||
name, lang = image.split('_', 1)
|
||||
img = os.path.join(base_path, 'images', lang.upper(), '{}.png'.format(name))
|
||||
if not os.path.exists(img):
|
||||
if lang == 'en':
|
||||
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.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.screen_width, self.screen_height = kwargs['screen_width'], kwargs['screen_height']
|
||||
del kwargs['x'], kwargs['y'], kwargs['screen_width'], kwargs['screen_height'], kwargs['app'], kwargs['thread']
|
||||
|
||||
self.screen_height = kwargs['screen_height']
|
||||
del kwargs['x'], kwargs['y'], kwargs['screen_height'], kwargs['app'], kwargs['thread']
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
||||
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||
self.setWindowTitle('')
|
||||
self.setMinimumSize(self.screen_width, self.screen_height)
|
||||
self.setMaximumSize(self.screen_width, self.screen_height)
|
||||
self.setGeometry(self.x, self.y, self.x+48, self.y+64)
|
||||
|
||||
self.setMinimumSize(48, 64)
|
||||
self.setMaximumSize(48, 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])
|
||||
|
|
@ -112,8 +132,13 @@ class Niko(QWidget):
|
|||
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 self.y > self.screen_height:
|
||||
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__':
|
||||
app = QApplication(sys.argv)
|
||||
|
|
@ -121,20 +146,28 @@ if __name__ == '__main__':
|
|||
if len(sys.argv) == 3:
|
||||
# "Niko-leaves-the-screen" mode
|
||||
x, y = int(sys.argv[1]), int(sys.argv[2])
|
||||
screensize = app.primaryScreen().size()
|
||||
|
||||
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)
|
||||
|
||||
else:
|
||||
# Author's Journal mode
|
||||
journal = Journal()
|
||||
|
||||
thread = WatchPipe()
|
||||
thread.change_image.connect(journal.change_image)
|
||||
thread.start()
|
||||
|
||||
journal = Journal(app = app)
|
||||
save_path = os.path.join(documents_path, 'Oneshot', 'save_progress.oneshot')
|
||||
if os.path.exists(save_path):
|
||||
with open(save_path, 'rb') as save:
|
||||
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_()
|
||||
|
|
|
|||