fix resolution loading & update issue
This commit is contained in:
1 parent
2140cc7820
commit
f4b6fd709d
2 files changed
+20
-22
No files matched your search
@@ -1758,7 +1758,7 @@ static NSMutableSet* hostList;
|
|||||||
object: nil];
|
object: nil];
|
||||||
//[self simulateSettingsButtonPress]; //force reload resolution table in the setting
|
//[self simulateSettingsButtonPress]; //force reload resolution table in the setting
|
||||||
//[self simulateSettingsButtonPress];
|
//[self simulateSettingsButtonPress];
|
||||||
//[self updateResolutionAccordingly];
|
[self updateResolutionAccordingly];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < RESOLUTION_TABLE_CUSTOM_INDEX; i++) {
|
for (int i = 0; i < RESOLUTION_TABLE_CUSTOM_INDEX; i++) {
|
||||||
|
NSLog(@"customRes: %f, %f, isrl: %f, %f", res.width, res.height, resolutionTable[i].width, resolutionTable[i].height);
|
||||||
if ((res.width == resolutionTable[i].width && res.height == resolutionTable[i].height) || (res.height == resolutionTable[i].width && res.width == resolutionTable[i].height)) {
|
if ((res.width == resolutionTable[i].width && res.height == resolutionTable[i].height) || (res.height == resolutionTable[i].width && res.width == resolutionTable[i].height)) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
@@ -286,6 +286,8 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
|
|
||||||
- (void)updateResolutionTable{
|
- (void)updateResolutionTable{
|
||||||
UIWindow *window = self.view.window;
|
UIWindow *window = self.view.window;
|
||||||
|
NSLog(@" window %@", window);
|
||||||
|
|
||||||
CGFloat screenScale = window.screen.scale;
|
CGFloat screenScale = window.screen.scale;
|
||||||
CGFloat safeAreaWidth = (window.frame.size.width - window.safeAreaInsets.left - window.safeAreaInsets.right) * screenScale;
|
CGFloat safeAreaWidth = (window.frame.size.width - window.safeAreaInsets.left - window.safeAreaInsets.right) * screenScale;
|
||||||
CGFloat appWindowWidth = window.frame.size.width * screenScale;
|
CGFloat appWindowWidth = window.frame.size.width * screenScale;
|
||||||
@@ -296,17 +298,17 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
appWindowWidth = bounds.size.width * screenScale;
|
appWindowWidth = bounds.size.width * screenScale;
|
||||||
appWindowHeight = bounds.size.height * screenScale;
|
appWindowHeight = bounds.size.height * screenScale;
|
||||||
}
|
}
|
||||||
bool needSwapWidthAndHeight = appWindowWidth > appWindowHeight;
|
|
||||||
|
|
||||||
resolutionTable[3] = CGSizeMake(safeAreaWidth, appWindowHeight);
|
bool needSwapWidthAndHeight = appWindowWidth < appWindowHeight;
|
||||||
|
|
||||||
for(uint8_t i=0;i<RESOLUTION_TABLE_SIZE;i++){
|
for(uint8_t i=0;i<6;i++){
|
||||||
CGFloat longSideLen = resolutionTable[i].height > resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
|
CGFloat longSideLen = resolutionTable[i].height > resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
|
||||||
CGFloat shortSideLen = resolutionTable[i].height < resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
|
CGFloat shortSideLen = resolutionTable[i].height < resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
|
||||||
if(needSwapWidthAndHeight) resolutionTable[i] = CGSizeMake(longSideLen, shortSideLen);
|
if(needSwapWidthAndHeight) resolutionTable[i] = CGSizeMake(shortSideLen, longSideLen);
|
||||||
else resolutionTable[i] = CGSizeMake(shortSideLen, longSideLen);
|
else resolutionTable[i] = CGSizeMake(longSideLen, shortSideLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolutionTable[3] = CGSizeMake(safeAreaWidth, appWindowHeight);
|
||||||
resolutionTable[4] = CGSizeMake(appWindowWidth, appWindowHeight);
|
resolutionTable[4] = CGSizeMake(appWindowWidth, appWindowHeight);
|
||||||
|
|
||||||
[self updateResolutionDisplayLabel];
|
[self updateResolutionDisplayLabel];
|
||||||
@@ -315,7 +317,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
// this will also be called back when device orientation changes
|
// this will also be called back when device orientation changes
|
||||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||||
double delayInSeconds = 0.2;
|
double delayInSeconds = 0.7;
|
||||||
// Convert the delay into a dispatch_time_t value
|
// Convert the delay into a dispatch_time_t value
|
||||||
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
||||||
// Perform some task after the delay
|
// Perform some task after the delay
|
||||||
@@ -325,14 +327,19 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillAppear:(BOOL)animated{
|
- (void)viewWillAppear:(BOOL)animated{
|
||||||
|
[super viewWillAppear:NO];
|
||||||
[self.resolutionSelector setEnabled:!self.customResolutionSwitch.isOn];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated{
|
- (void)viewDidAppear:(BOOL)animated{
|
||||||
[super viewDidAppear:NO];
|
[super viewDidAppear:NO];
|
||||||
[self updateResolutionTable];
|
[self updateResolutionTable];
|
||||||
NSLog(@"Resolution table updated");
|
[self.customResolutionSwitch addTarget:self action:@selector(customResolutionSwitched:) forControlEvents:UIControlEventValueChanged];
|
||||||
|
|
||||||
|
DataManager* dataMan = [[DataManager alloc] init];
|
||||||
|
TemporarySettings *currentSettings = [dataMan getSettings];
|
||||||
|
|
||||||
|
CGSize currentResolution = CGSizeMake(currentSettings.width.intValue, currentSettings.height.intValue);
|
||||||
|
[self.customResolutionSwitch setOn: isCustomResolution(currentResolution)];
|
||||||
[self.resolutionSelector setEnabled:!self.customResolutionSwitch.isOn];
|
[self.resolutionSelector setEnabled:!self.customResolutionSwitch.isOn];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1200,13 +1207,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
resolutionTable[3] = CGSizeMake(safeAreaWidth, fullScreenHeight);
|
resolutionTable[3] = CGSizeMake(safeAreaWidth, fullScreenHeight);
|
||||||
resolutionTable[4] = CGSizeMake(fullScreenWidth, fullScreenHeight);
|
resolutionTable[4] = CGSizeMake(fullScreenWidth, fullScreenHeight);
|
||||||
resolutionTable[5] = CGSizeMake([currentSettings.width integerValue], [currentSettings.height integerValue]); // custom initial value
|
resolutionTable[5] = CGSizeMake([currentSettings.width integerValue], [currentSettings.height integerValue]); // custom initial value
|
||||||
[self updateResolutionTable];
|
|
||||||
|
|
||||||
// Don't populate the custom entry unless we have a custom resolution
|
|
||||||
//self.customResolutionSwitch
|
|
||||||
if (!isCustomResolution(resolutionTable[5])) {
|
|
||||||
resolutionTable[5] = CGSizeMake(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
NSInteger framerate;
|
NSInteger framerate;
|
||||||
switch ([currentSettings.framerate integerValue]) {
|
switch ([currentSettings.framerate integerValue]) {
|
||||||
@@ -1308,9 +1309,6 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
_lastSelectedResolutionIndex = resolution;
|
_lastSelectedResolutionIndex = resolution;
|
||||||
[self.resolutionSelector setSelectedSegmentIndex:resolution];
|
[self.resolutionSelector setSelectedSegmentIndex:resolution];
|
||||||
[self.resolutionSelector addTarget:self action:@selector(newResolutionChosen) forControlEvents:UIControlEventValueChanged];
|
[self.resolutionSelector addTarget:self action:@selector(newResolutionChosen) forControlEvents:UIControlEventValueChanged];
|
||||||
[self.customResolutionSwitch addTarget:self action:@selector(customResolutionSwitched:) forControlEvents:UIControlEventValueChanged];
|
|
||||||
CGSize currentResolution = CGSizeMake(currentSettings.width.intValue, currentSettings.height.intValue);
|
|
||||||
[self.customResolutionSwitch setOn: isCustomResolution(currentResolution)];
|
|
||||||
|
|
||||||
[self.framerateSelector setSelectedSegmentIndex:framerate];
|
[self.framerateSelector setSelectedSegmentIndex:framerate];
|
||||||
[self.framerateSelector addTarget:self action:@selector(updateBitrate) forControlEvents:UIControlEventValueChanged];
|
[self.framerateSelector addTarget:self action:@selector(updateBitrate) forControlEvents:UIControlEventValueChanged];
|
||||||
|
|||||||
Reference in new issue
Block a user