Skip to content

Commit

Permalink
Update instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed Sep 27, 2017
1 parent e023c49 commit c12b7c6
Showing 1 changed file with 70 additions and 38 deletions.
108 changes: 70 additions & 38 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,35 @@
from gamma import Context as GammaContext


if getattr(sys, 'frozen', False):
class Excepthook:
def __init__(self, excepthook):
self.exception = False
self.excepthook = excepthook

def __call__(self, type, value, traceback):
self.exception = True
self.excepthook(type, value, traceback)

excepthook = Excepthook(sys.excepthook)
sys.excepthook = excepthook

def exit_handler():
if excepthook.exception:
print('\n\nPress CTRL+C to quit...\n')
class Excepthook:
def __init__(self, excepthook, handler):
self.excepthook = excepthook
self.handler = handler

def __call__(self, type, value, traceback):
self.handler.exception = True
self.excepthook(type, value, traceback)


class ExitHandler:
def __init__(self, excepthook):
self.excepthook = Excepthook(excepthook, self)
self.exception = False
self.confirm_exit = False
self.confirm_exit_on_exception = False

def __call__(self):
if self.exception:
print("\n\n"
" (1) Did you restart your PC after running "
"set_max_gamma_range.reg?\n"
" (2) Make sure your graphics card drivers are up to date.\n"
" (3) Make sure your operating system is up to date.\n"
" (4) Try disabling your integrated graphics card.")

if self.confirm_exit or \
self.exception and self.confirm_exit_on_exception:
print('\n\nPress CTRL+C to quit...')

try:
from time import sleep
Expand All @@ -33,13 +46,19 @@ def exit_handler():
except KeyboardInterrupt:
pass

atexit.register(exit_handler)

def exit(*args, **kwargs):
excepthook.exception = True
sys.exit(*args, **kwargs)
else:
exit = sys.exit
exit_handler = ExitHandler(sys.excepthook)
exit_handler.confirm_exit_on_exception = getattr(sys, 'frozen', False)
sys.excepthook = exit_handler.excepthook
atexit.register(exit_handler)


def exit(*args, **kwargs):
if getattr(sys, 'frozen', False):
exit_handler.confirm_exit = True

sys.exit(*args, **kwargs)


if platform.system() == 'Windows':
import win32console, win32gui, win32con
Expand Down Expand Up @@ -109,11 +128,30 @@ def extract(data, *keys, default=None):
}}
}}'''.format(port))

print("Don't forget to copy gamestate_integration_dont_blind_me.cfg into\n"
" ...\\Steam\\userdata\\________\\730\\local\\cfg, or\n"
print("Don't forget to copy gamestate_integration_dont_blind_me.cfg into "
"either\n ...\\Steam\\userdata\\________\\730\\local\\cfg or\n"
" ...\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\"
"csgo\\cfg!\n")


print("Don't forget to set the launch option -nogammaramp!\n"
" (1) Go to the Steam library,\n"
" (2) right click on CS:GO and go to properties and\n"
" (3) click 'Set Launch Options...' and add -nogammaramp.\n")

print("To uninstall, \n"
" (1) remove gamestate_integration_dont_blind_me.cfg from the "
"cfg folder and\n"
" (2) remove the launch option -nogammaramp and\n"
" (3) run restore_gamma_range.reg and restart PC if it exists.\n")

print("If your monitor permanently changed in brightness/color,\n"
" (1) restart the app and close it with CTRL+C;\n"
" (2) in case that didn't work, restart your PC.\n"
" (3) If that failed too, make sure the app is closed, then\n"
" (4) set reset_gamma in settings.json to true, then\n"
" (5) open the app and close it again with CTRL+C.\n")

mat_monitorgamma = settings.get('mat_monitorgamma')
mat_monitorgamma_tv_enabled = settings.get('mat_monitorgamma_tv_enabled')

Expand All @@ -126,10 +164,15 @@ def extract(data, *keys, default=None):

print("Don't forget to set your preferred gamma in settings.json! "
"Currently set to:\n"
" mat_monitorgamma\t\t {:3.2f}\n"
" mat_monitorgamma_tv_enabled\t {}\n".format(
" mat_monitorgamma\t\t {:3.2f} (Brightness)\n"
" mat_monitorgamma_tv_enabled\t {} (Color Mode: "
"Computer Monitor 0, Television 1)\n".format(
mat_monitorgamma, int(mat_monitorgamma_tv_enabled)))

print("Don't forget to disable f.lux!")
print("Don't forget to disable Redshift!")
print("Don't forget to disable Windows Night Light!")
print("Don't forget to disable Xbox DVR/Game bar!\n")

if platform.system() == 'Windows':
from winreg import (HKEY_LOCAL_MACHINE, OpenKey, CloseKey,
Expand Down Expand Up @@ -171,17 +214,6 @@ def extract(data, *keys, default=None):
exit()


print("Don't forget to set the launch option -nogammaramp!\n")

print("Don't forget to disable f.lux!")
print("Don't forget to disable Redshift!")
print("Don't forget to disable Windows Night Light!")
print("Don't forget to disable Xbox DVR/Game bar!\n")

print("In case you get an error:\n"
" Did you restart your PC after running set_max_gamma_range.reg?\n")


def adjust_brightness(flashed):
a = remap[0] / 256
b = (remap[1] + 1 - remap[0]) / 256
Expand Down Expand Up @@ -264,7 +296,7 @@ def restore_gamma():

adjust_brightness(0)

print("Please exit with CTRL+C! "
print("Please close the app with CTRL+C! "
"If you don't, the gamma won't reset.\n")

app = web.Application()
Expand Down

0 comments on commit c12b7c6

Please sign in to comment.