Skip to content

Commit

Permalink
Merge d5b869d into 74aad35
Browse files Browse the repository at this point in the history
  • Loading branch information
MosesofEgypt committed Jun 13, 2017
2 parents 74aad35 + d5b869d commit c3b881c
Show file tree
Hide file tree
Showing 20 changed files with 790 additions and 150 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,11 @@ ENV/
# Idea/PyCharm project
.idea
*.iml

# Launcher stuff
Launcher/
launcher/
launcher_log.*

# Coverage tests
cover/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ matrix:
cache: pip
dist: trusty
sudo: false
env:
# Required to disable QXcbConnection errors/warnings
- QT_QPA_PLATFORM=offscreen
# Use generic language for osx
- os: osx
language: generic
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ you'll need to configure it, and build your own copy.

**NOTE:** For the patching functionality to work, the install directory for both
the patcher and the game (it must be the same directory) must be writable
without evevated permissions. The game will launch properly, but will not patch
without elevated permissions. The game will launch properly, but will not patch
over time. This includes Window's "Program Files" folder. For such situations,
we suggest installing under "C:\Games" or something similar.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion install/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AppSupportURL=http://houraiteahouse.net
AppUpdatesURL=http://houraiteahouse.net
DefaultDirName=C:\Games\{#APP_NAME}
DefaultGroupName={#APP_NAME}
SetupIconFile=..\img\app.ico
SetupIconFile=..\img\256x256.ico
AllowNoIcons=yes
;AppReadmeFile={#README}
LicenseFile={#LICENSE}
Expand Down
15 changes: 9 additions & 6 deletions scripts/deploy_win.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
echo "Branch: %APPVEYOR_REPO_BRANCH%"
echo "Pull Request: %APPVEYOR_PULL_REQUEST_NUMBER%"
if %APPVEYOR_REPO_BRANCH% == "master" (
for /r %%i in (dist/*) do echo %%i

for /r %%i in (dist/*) do echo %%i

for %%f in (dist/*) do (
curl.exe -i -X POST "%DEPLOY_UPLOAD_URL%/%APPVEYOR_REPO_BRANCH%/Windows?token=%TOKEN%" ^
-F "file=@dist/%%f" ^
--keepalive-time 2
for %%f in (dist/*) do (
curl.exe -i -X POST "%DEPLOY_UPLOAD_URL%/%APPVEYOR_REPO_BRANCH%/Windows?token=%TOKEN%" ^
-F "file=@dist/%%f" ^
--keepalive-time 2
)
)
2 changes: 1 addition & 1 deletion specs/launcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ exe = EXE(pyz,
strip=False,
upx=True,
console=False,
icon="img/app.ico")
icon="img/256x256.ico")
2 changes: 1 addition & 1 deletion specs/windows_launcher.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ exe = EXE(pyz,
strip=False,
upx=True,
console=False,
icon="img/app.ico")
icon="img/256x256.ico")
2 changes: 1 addition & 1 deletion specs/windows_launcher_dir.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exe = EXE(pyz,
strip=False,
upx=True,
console=False,
icon="img/app.ico")
icon="img/256x256.ico")
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
Expand Down
60 changes: 52 additions & 8 deletions src/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import platform
import re
from quamash import QEventLoop
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QApplication

app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
ICON_SIZES = (16, 32, 48, 64, 256)

GLOBAL_CONTEXT = {
'platform': platform.system(),
'executable': os.path.basename(sys.executable)
Expand All @@ -17,19 +17,63 @@
vars_regex = re.compile('{(.*?)}')


def get_app():
g = globals()
if g.get('app') is None:
g['app'] = QApplication(sys.argv)

return app


def get_loop():
g = globals()
if g.get('loop') is None:
if g.get('app') is None:
raise NameError("cannot create loop without an app to bind it to.")
new_loop = QEventLoop(app)
asyncio.set_event_loop(new_loop)
g['loop'] = new_loop

return loop


def set_app_icon():
# config relies on common, and this function in common relies on config.
# gotta break the import loop somewhere, so this seems like a good place.
# might be more preferrable to make a dummy config attribute and have the
# launcher's __init__.py set up a circular link between both modules.
# that might not work well when running tests though...
import config
g = globals()

if g.get('app') is None:
raise NameError("'app' is not defined. cannot set its icon.")
# load all the icons from the img folder into a QIcon object
app_icon = QtGui.QIcon()
for size in ICON_SIZES:
app_icon.addFile(
os.path.join(
config.RESOURCE_DIR, 'img', '%sx%s.ico' % (size, size)),
QtCore.QSize(size, size))

g['app_icon'] = app_icon
app.setWindowIcon(app_icon)


def sanitize_url(url):
return url.lower().replace(' ', '-')


def inject_variables(path_format, vars_obj=GLOBAL_CONTEXT):
matches = vars_regex.findall(path_format)
path = path_format
vars_is_dict = isinstance(vars_obj, dict)
for match in matches:
target = '{%s}' % match
if isinstance(vars_obj, dict) and match in vars_obj:
path = path.replace(target, str(vars_obj[match]))
if vars_is_dict:
replacement = vars_obj.get(match)
else:
replacement = getattr(vars_obj, match, None)
if replacement is not None:
path = path.replace(target, str(replacement))
if replacement is None:
continue
path = path.replace('{%s}' % match, str(replacement))
return path

0 comments on commit c3b881c

Please sign in to comment.