-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On the Mac, some non-4:3 modes were causing serious flickering (only on some Macs). This is bad enough to pull fullscreen for now. Hasn't happened on Windows that I can test, but pulling there too.
- Loading branch information
Showing
6 changed files
with
46 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,17 @@ | ||
"""AudioQuake & LDL Launcher - Customise tab""" | ||
# FIXME: enforce min and max resolutions | ||
from buildlib import doset | ||
import launcherlib.config as config | ||
|
||
RESOLUTIONS = [ | ||
'640x400 (16:10)', # Default on macOS | ||
'640x480 (4:3)', # Default on Windows | ||
'800x600 (4:3)', | ||
'1152x720 (16:10)', | ||
'1280x720 (16:9)', | ||
'1024x768 (4:3)'] | ||
RESOLUTIONS = [(640, 480), (800, 600), (1024, 768)] | ||
DEFAULT_RESOLUTION_INDEX = 0 | ||
|
||
DEFAULT_RESOLUTION_INDEX = doset(mac=0, windows=1) | ||
|
||
RESOLUTIONS[DEFAULT_RESOLUTION_INDEX] += ' [default]' | ||
|
||
|
||
def width_and_height(resolution_string): | ||
"""Given a string, extract the width and height of the corresponding | ||
resolution | ||
Raises ValueError if the string doesn't describe a resolution""" | ||
if ' ' in resolution_string: | ||
dimensions = resolution_string.split(' ')[0] | ||
else: | ||
dimensions = resolution_string | ||
xstr, ystr = dimensions.split('x') # may raise ValueError | ||
return xstr, ystr | ||
|
||
|
||
DEFAULT_WIDTH, DEFAULT_HEIGHT = \ | ||
width_and_height(RESOLUTIONS[DEFAULT_RESOLUTION_INDEX]) | ||
|
||
|
||
def resolution_index_and_size(partial_resolution_string): | ||
"""Given a resolution string, find the index of the matching preset | ||
resolution, if it exists | ||
Returns | ||
(index, x, y) if the string matches a preset resolution | ||
( -1, x, y) if the string's resolution doesn't match a preset | ||
( -2, None, None) if the string's resolution is invalid""" | ||
def resolution_from_config(): | ||
try: | ||
given_xstr, given_ystr = width_and_height(partial_resolution_string) | ||
except ValueError: | ||
return -2, None, None | ||
|
||
for index, resolution_string in enumerate(RESOLUTIONS): | ||
res_xstr, res_ystr = width_and_height(resolution_string) | ||
if given_xstr == res_xstr and given_ystr == res_ystr: | ||
return index, given_xstr, given_ystr | ||
|
||
return -1, given_xstr, given_ystr | ||
|
||
|
||
def resolution_details_from_config(): | ||
"""Gets and updates info about the resolution string stored in the | ||
launcher's INI file. | ||
If the resolution is valid syntactically, works out if it's one of the | ||
preset ones and finds its index if so. | ||
Also finds the x and y sizes of the resultion. | ||
If the resolution in the INI file is not syntactically correct, replace it | ||
with the default resolution string for the current platform, then return | ||
the info on the default resolution. | ||
Returns | ||
index - int/None depending on whether the current res is a preset | ||
x - width of current resolution | ||
y - height of current resolution | ||
was_valid - Whether the INI file res was syntactically correct.""" | ||
index, x, y = resolution_index_and_size(config.resolution()) | ||
if index >= 0: | ||
return index, x, y, True | ||
elif index == -1: | ||
return None, x, y, True | ||
else: | ||
config.resolution(RESOLUTIONS[DEFAULT_RESOLUTION_INDEX]) | ||
return DEFAULT_RESOLUTION_INDEX, DEFAULT_WIDTH, DEFAULT_HEIGHT, False | ||
|
||
|
||
def resolution_index_from_config(): | ||
index, _, _, was_valid = resolution_details_from_config() | ||
return index, was_valid | ||
|
||
|
||
def resolution_size_from_config(): | ||
_, x, y, was_valid = resolution_details_from_config() | ||
return x, y, was_valid | ||
index = int(config.resolution()) | ||
x, y = RESOLUTIONS[index] | ||
return x, y | ||
except: # noqa 722 | ||
x, y = RESOLUTIONS[DEFAULT_RESOLUTION_INDEX] | ||
config.resolution(DEFAULT_RESOLUTION_INDEX) | ||
return x, y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters