Skip to content

Commit

Permalink
config,forms,versioning update
Browse files Browse the repository at this point in the history
  • Loading branch information
gogodr committed Jun 7, 2022
1 parent ec5d17a commit 78f31c4
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 137 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
build/
dist/
__pycache__
config.ini
config.ini
file_version_info.txt
lamo-watcher.exe
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
## Lost Ark Market Launcher 1.0.1
## Lost Ark Market Launcher 1.2.1.1
This app does the authentication to the Lost Ark Marketplace Online project and looks if the latest version of the launcher is the one currently present.
If it finds a new version, it will proceed to download the new version and launch it. If the latest version is already present, it proceeds launching it.



### Dependencies
### App Dependencies
- Pyside6 (Qt for Python) `pip install PySide6`
- requests `pip install requests`
- Simpleaudio `pip install simpleaudio`

### Compilation Dependencies
- PyInstaller `pip install PyInstaller`
- pyinstaller-versionfile `pip install pyinstaller-versionfile`

### Assets
Audio files from [MixKit](https://mixkit.co/)


### Changelog
### 1.2.1.1
- Update forms
- Update config strategy
- Add file metadata
- Add compile script

### 1.0.1
- Add extra audio cues
- Fix subprocess no console
Expand Down
15 changes: 15 additions & 0 deletions compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PyInstaller.__main__

from modules.config import Config

import pyinstaller_versionfile

pyinstaller_versionfile.create_versionfile_from_input_file(
output_file="file_version_info.txt",
input_file="metadata.yml",
version=Config().version
)

PyInstaller.__main__.run([
'compile.spec',
])
3 changes: 2 additions & 1 deletion release.spec → compile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exe = EXE(
a.zipfiles,
a.datas,
[],
name='LostArkMarketLauncher',
name='lamo-launcher',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand All @@ -42,4 +42,5 @@ exe = EXE(
codesign_identity=None,
entitlements_file=None,
icon='assets\\icons\\favicon.ico',
version='file_version_info.txt'
)
44 changes: 44 additions & 0 deletions file_version_info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx

VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. Must always contain 4 elements.
filevers=(1,2,1,1),
prodvers=(1,2,1,1),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'Lost Ark Market Online'),
StringStruct(u'FileDescription', u'Lost Ark Market Online Launcher App'),
StringStruct(u'FileVersion', u'1.2.1.1'),
StringStruct(u'InternalName', u'Launcher App'),
StringStruct(u'LegalCopyright', u'© Lost Ark Market Online'),
StringStruct(u'OriginalFilename', u'lamo-launcher.exe'),
StringStruct(u'ProductName', u'Lost Ark Market Online Launcher App'),
StringStruct(u'ProductVersion', u'1.2.1.1')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)
41 changes: 17 additions & 24 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,20 @@
import subprocess

from PySide6.QtWidgets import QApplication
from PySide6.QtGui import QIcon
from modules.app_version import get_app_version
from modules.config import update_latest_app_version, get_tokens, needs_update, update_current_app_version
from modules.errors import NoTokenError
from modules.config import Config
from modules.sound import playDownloadComplete, playError, playSuccess, playUpdateDetected
from ui.download.download import LostArkMarketLauncherDownload
from ui.login_form.login_form import LostArkMarketLoginForm
from modules.auth import refresh_token



class LostArkMarketOnlineLauncher(QApplication):
refresh_token = None
id_token = None
uid = None

def __init__(self, *args, **kwargs):
QApplication.__init__(self, *args, **kwargs)
try:
self.id_token, self.refresh_token, self.uid = get_tokens()
self.id_token, self.refresh_token, self.uid = refresh_token(
self.refresh_token)

if(Config().refresh_token):
self.check_config()
except NoTokenError:
traceback.print_exc()
playUpdateDetected()
else:
self.login_form = LostArkMarketLoginForm()
self.login_form.login_success.connect(self.login_success)
self.login_form.login_error.connect(self.login_error)
Expand All @@ -38,17 +27,15 @@ def login_error(self):

def login_success(self):
playSuccess()
self.login_form.ui.hide()
self.login_form.close()
self.check_config()

def check_config(self):
self.latest_app_version = get_app_version()
update_latest_app_version(self.latest_app_version)
if needs_update() == True:
Config().check_watcher_version()
if Config().needs_update == True:
playUpdateDetected()
self.download = LostArkMarketLauncherDownload({
"url": f'https://github.com/gogodr/LostArk-Market-Watcher/releases/download/{self.latest_app_version}/LostArkMarketWatcher.exe',
"version": self.latest_app_version
"url": f'https://github.com/gogodr/LostArk-Market-Watcher/releases/download/{Config().watcher_version}/{Config().watcher_file}.exe'
})
self.download.launch.connect(self.launch_watcher)
self.download.finished_download.connect(self.finished_download)
Expand All @@ -57,16 +44,22 @@ def check_config(self):

def finished_download(self):
playDownloadComplete()
update_current_app_version(self.latest_app_version)
if(Config().run_after_download):
self.download.close()
self.launch_watcher()

def launch_watcher(self):
playSuccess()
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.call("LostArkMarketWatcher.exe")
subprocess.call(f"{Config().watcher_file}.exe")
sys.exit()


if __name__ == "__main__":
Config()
app = LostArkMarketOnlineLauncher([])
icon = QIcon(os.path.abspath(os.path.join(os.path.dirname(__file__),
"assets/icons/favicon.png")))
app.setWindowIcon(icon)
sys.exit(app.exec())
7 changes: 7 additions & 0 deletions metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Version: 1.1.0
CompanyName: Lost Ark Market Online
FileDescription: Lost Ark Market Online Launcher App
InternalName: Launcher App
LegalCopyright: © Lost Ark Market Online
OriginalFilename: lamo-launcher.exe
ProductName: Lost Ark Market Online Launcher App
14 changes: 6 additions & 8 deletions modules/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests
from modules.config import update_token
from modules.config import Config
from modules.errors import LoginError, NoTokenError

api_key = 'AIzaSyBMTA0A2fy-dh4jWidbAtYseC7ZZssnsmk'
Expand All @@ -14,12 +14,11 @@ def login(email, password):
tokens = res.json()
if 'error' in tokens:
raise LoginError()
update_token({
Config().update_token({
"id_token": tokens['idToken'],
"refresh_token": tokens['refreshToken'],
"uid": tokens['localId'],
})
return tokens['idToken'], tokens['refreshToken'], tokens['localId']


def refresh_token(token):
Expand All @@ -30,9 +29,8 @@ def refresh_token(token):
tokens = res.json()
if 'error' in tokens:
raise NoTokenError()
update_token({
"id_token": tokens['id_token'],
"refresh_token": tokens['refresh_token'],
"uid": tokens['user_id'],
Config().update_token({
"id_token": tokens['idToken'],
"refresh_token": tokens['refreshToken'],
"uid": tokens['localId'],
})
return tokens['id_token'], tokens['refresh_token'], tokens['user_id']
12 changes: 12 additions & 0 deletions modules/common/singleton.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import threading

class Singleton(type):
_instances = {}
_lock = threading.Lock()

def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
with cls._lock:
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
Loading

0 comments on commit 78f31c4

Please sign in to comment.