qt: Actually save secondary video card settings

This also rounds off the new video monitor API with a instanced set_screen_size API
This commit is contained in:
Cacodemon345
2022-07-07 17:56:32 +06:00
parent dec057020d
commit a886194382
3 changed files with 65 additions and 50 deletions

View File

@@ -1247,14 +1247,13 @@ pc_onesec(void)
title_update = 1; title_update = 1;
} }
void void
set_screen_size(int x, int y) set_screen_size_monitor(int x, int y, int monitor_index)
{ {
int owsx = scrnsz_x; int owsx = monitors[monitor_index].mon_scrnsz_x;
int owsy = scrnsz_y; int owsy = monitors[monitor_index].mon_scrnsz_y;
int temp_overscan_x = overscan_x; int temp_overscan_x = monitors[monitor_index].mon_overscan_x;
int temp_overscan_y = overscan_y; int temp_overscan_y = monitors[monitor_index].mon_overscan_y;
double dx, dy, dtx, dty; double dx, dy, dtx, dty;
/* Make sure we keep usable values. */ /* Make sure we keep usable values. */
@@ -1267,8 +1266,8 @@ set_screen_size(int x, int y)
if (y > 2048) y = 2048; if (y > 2048) y = 2048;
/* Save the new values as "real" (unscaled) resolution. */ /* Save the new values as "real" (unscaled) resolution. */
unscaled_size_x = x; monitors[monitor_index].mon_unscaled_size_x = x;
efscrnsz_y = y; monitors[monitor_index].mon_efscrnsz_y = y;
if (suppress_overscan) if (suppress_overscan)
temp_overscan_x = temp_overscan_y = 0; temp_overscan_x = temp_overscan_y = 0;
@@ -1281,10 +1280,10 @@ set_screen_size(int x, int y)
dty = (double)temp_overscan_y; dty = (double)temp_overscan_y;
/* Account for possible overscan. */ /* Account for possible overscan. */
if (video_get_type_monitor(monitor_index_global) != VIDEO_FLAG_TYPE_SPECIAL && (temp_overscan_y == 16)) { if (video_get_type_monitor(monitor_index) != VIDEO_FLAG_TYPE_SPECIAL && (temp_overscan_y == 16)) {
/* CGA */ /* CGA */
dy = (((dx - dtx) / 4.0) * 3.0) + dty; dy = (((dx - dtx) / 4.0) * 3.0) + dty;
} else if (video_get_type_monitor(monitor_index_global) != VIDEO_FLAG_TYPE_SPECIAL && (temp_overscan_y < 16)) { } else if (video_get_type_monitor(monitor_index) != VIDEO_FLAG_TYPE_SPECIAL && (temp_overscan_y < 16)) {
/* MDA/Hercules */ /* MDA/Hercules */
dy = (x / 4.0) * 3.0; dy = (x / 4.0) * 3.0;
} else { } else {
@@ -1296,47 +1295,60 @@ set_screen_size(int x, int y)
dy = (x / 4.0) * 3.0; dy = (x / 4.0) * 3.0;
} }
} }
unscaled_size_y = (int)dy; monitors[monitor_index].mon_unscaled_size_y = (int)dy;
} else } else
unscaled_size_y = efscrnsz_y; monitors[monitor_index].mon_unscaled_size_y = monitors[monitor_index].mon_efscrnsz_y;
switch(scale) { switch(scale) {
case 0: /* 50% */ case 0: /* 50% */
scrnsz_x = (unscaled_size_x>>1); monitors[monitor_index].mon_scrnsz_x = (monitors[monitor_index].mon_unscaled_size_x>>1);
scrnsz_y = (unscaled_size_y>>1); monitors[monitor_index].mon_scrnsz_y = (monitors[monitor_index].mon_unscaled_size_y>>1);
break; break;
case 1: /* 100% */ case 1: /* 100% */
scrnsz_x = unscaled_size_x; monitors[monitor_index].mon_scrnsz_x = monitors[monitor_index].mon_unscaled_size_x;
scrnsz_y = unscaled_size_y; monitors[monitor_index].mon_scrnsz_y = monitors[monitor_index].mon_unscaled_size_y;
break; break;
case 2: /* 150% */ case 2: /* 150% */
scrnsz_x = ((unscaled_size_x*3)>>1); monitors[monitor_index].mon_scrnsz_x = ((monitors[monitor_index].mon_unscaled_size_x*3)>>1);
scrnsz_y = ((unscaled_size_y*3)>>1); monitors[monitor_index].mon_scrnsz_y = ((monitors[monitor_index].mon_unscaled_size_y*3)>>1);
break; break;
case 3: /* 200% */ case 3: /* 200% */
scrnsz_x = (unscaled_size_x<<1); monitors[monitor_index].mon_scrnsz_x = (monitors[monitor_index].mon_unscaled_size_x<<1);
scrnsz_y = (unscaled_size_y<<1); monitors[monitor_index].mon_scrnsz_y = (monitors[monitor_index].mon_unscaled_size_y<<1);
break; break;
} }
atomic_store(&doresize_monitors[monitor_index_global], 1); atomic_store(&doresize_monitors[monitor_index], 1);
} }
void
set_screen_size(int x, int y)
{
set_screen_size_monitor(x, y, monitor_index_global);
}
void
reset_screen_size_monitor(int monitor_index)
{
set_screen_size(monitors[monitor_index].mon_unscaled_size_x, monitors[monitor_index].mon_efscrnsz_y);
}
void void
reset_screen_size(void) reset_screen_size(void)
{ {
set_screen_size(unscaled_size_x, efscrnsz_y); for (int i = 0; i < MONITORS_NUM; i++)
set_screen_size(monitors[i].mon_unscaled_size_x, monitors[i].mon_efscrnsz_y);
} }
void void
set_screen_size_natural(void) set_screen_size_natural(void)
{ {
set_screen_size(unscaled_size_x, unscaled_size_y); for (int i = 0; i < MONITORS_NUM; i++)
set_screen_size(monitors[i].mon_unscaled_size_x, monitors[i].mon_unscaled_size_y);
} }

View File

@@ -155,7 +155,9 @@ extern void pclog_toggle_suppr(void);
extern void pclog(const char *fmt, ...); extern void pclog(const char *fmt, ...);
extern void fatal(const char *fmt, ...); extern void fatal(const char *fmt, ...);
extern void set_screen_size(int x, int y); extern void set_screen_size(int x, int y);
extern void set_screen_size_monitor(int x, int y, int monitor_index);
extern void reset_screen_size(void); extern void reset_screen_size(void);
extern void reset_screen_size_monitor(int monitor_index);
extern void set_screen_size_natural(void); extern void set_screen_size_natural(void);
extern void update_mouse_msg(); extern void update_mouse_msg();
#if 0 #if 0

View File

@@ -46,6 +46,7 @@ SettingsDisplay::~SettingsDisplay()
void SettingsDisplay::save() { void SettingsDisplay::save() {
gfxcard = ui->comboBoxVideo->currentData().toInt(); gfxcard = ui->comboBoxVideo->currentData().toInt();
gfxcard_2 = ui->comboBoxVideoSecondary->currentData().toInt();
voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0; voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0;
ibm8514_enabled = ui->checkBox8514->isChecked() ? 1 : 0; ibm8514_enabled = ui->checkBox8514->isChecked() ? 1 : 0;
xga_enabled = ui->checkBoxXga->isChecked() ? 1 : 0; xga_enabled = ui->checkBoxXga->isChecked() ? 1 : 0;