diff --git a/.vs/launch.vs.json b/.vs/launch.vs.json index be17fb24ee7..a7a463646c3 100644 --- a/.vs/launch.vs.json +++ b/.vs/launch.vs.json @@ -145,7 +145,6 @@ "name": "Game - Jak 1 - Runtime (boot)", "args": [ "-v", - "--portable", "--game", "jak1", "--", diff --git a/common/formatter/rules/rule_config.cpp b/common/formatter/rules/rule_config.cpp index bab83cf2bf0..829e539d883 100644 --- a/common/formatter/rules/rule_config.cpp +++ b/common/formatter/rules/rule_config.cpp @@ -240,6 +240,7 @@ static FormFormattingConfig new_top_level_inline_form(bool elide_new_line) { const std::unordered_map opengoal_form_config = { {"case", new_pair_rule(true)}, + {"case-str", new_pair_rule(true)}, {"cond", new_pair_rule(false)}, {"#cond", new_pair_rule(false)}, {"in-package", new_top_level_inline_form(true)}, diff --git a/game/kernel/common/kmachine.cpp b/game/kernel/common/kmachine.cpp index 36ecdd42cbc..970ae318ec6 100644 --- a/game/kernel/common/kmachine.cpp +++ b/game/kernel/common/kmachine.cpp @@ -448,6 +448,19 @@ u64 pc_get_mips2c(u32 name) { return Mips2C::gLinkedFunctionTable.get(n); } +u64 pc_get_display_id() { + if (Display::GetMainDisplay()) { + return Display::GetMainDisplay()->get_display_manager()->get_active_display_id(); + } + return 0; +} + +void pc_set_display_id(u64 display_id) { + if (Display::GetMainDisplay()) { + Display::GetMainDisplay()->get_display_manager()->enqueue_set_display_id(display_id); + } +} + u64 pc_get_display_name(u32 id, u32 str_dest_ptr) { std::string name = ""; if (Display::GetMainDisplay()) { @@ -469,17 +482,16 @@ u64 pc_get_display_name(u32 id, u32 str_dest_ptr) { } u32 pc_get_display_mode() { - auto display_mode = WindowDisplayMode::Windowed; + auto display_mode = game_settings::DisplaySettings::DisplayMode::Windowed; if (Display::GetMainDisplay()) { - display_mode = Display::GetMainDisplay()->get_display_manager()->get_window_display_mode(); + display_mode = Display::GetMainDisplay()->get_display_manager()->get_display_mode(); } switch (display_mode) { - case WindowDisplayMode::Borderless: + case game_settings::DisplaySettings::DisplayMode::Borderless: return g_pc_port_funcs.intern_from_c("borderless").offset; - case WindowDisplayMode::Fullscreen: + case game_settings::DisplaySettings::DisplayMode::Fullscreen: return g_pc_port_funcs.intern_from_c("fullscreen").offset; default: - case WindowDisplayMode::Windowed: return g_pc_port_funcs.intern_from_c("windowed").offset; } } @@ -490,13 +502,13 @@ void pc_set_display_mode(u32 symptr) { } if (symptr == g_pc_port_funcs.intern_from_c("windowed").offset || symptr == s7.offset) { Display::GetMainDisplay()->get_display_manager()->enqueue_set_window_display_mode( - WindowDisplayMode::Windowed); + game_settings::DisplaySettings::DisplayMode::Windowed); } else if (symptr == g_pc_port_funcs.intern_from_c("borderless").offset) { Display::GetMainDisplay()->get_display_manager()->enqueue_set_window_display_mode( - WindowDisplayMode::Borderless); + game_settings::DisplaySettings::DisplayMode::Borderless); } else if (symptr == g_pc_port_funcs.intern_from_c("fullscreen").offset) { Display::GetMainDisplay()->get_display_manager()->enqueue_set_window_display_mode( - WindowDisplayMode::Fullscreen); + game_settings::DisplaySettings::DisplayMode::Fullscreen); } } @@ -568,12 +580,6 @@ void pc_get_window_scale(u32 x_ptr, u32 y_ptr) { } } -void pc_get_fullscreen_display(u64 display_id) { - if (Display::GetMainDisplay()) { - Display::GetMainDisplay()->get_display_manager()->enqueue_set_fullscreen_display_id(display_id); - } -} - void pc_set_window_size(u64 width, u64 height) { if (Display::GetMainDisplay()) { Display::GetMainDisplay()->get_display_manager()->enqueue_set_window_size(width, height); @@ -601,6 +607,14 @@ void pc_get_resolution(u32 id, u32 w_ptr, u32 h_ptr) { } } +u64 pc_is_supported_resolution(u64 width, u64 height) { + if (Display::GetMainDisplay()) { + return bool_to_symbol( + Display::GetMainDisplay()->get_display_manager()->is_supported_resolution(width, height)); + } + return bool_to_symbol(false); +} + u64 pc_get_controller_name(u32 id, u32 str_dest_ptr) { std::string name = ""; if (Display::GetMainDisplay()) { @@ -912,9 +926,11 @@ void init_common_pc_port_functions( // -- DISPLAY RELATED -- // Returns the name of the display with the given id or #f if not found / empty + make_func_symbol_func("pc-get-display-id", (void*)pc_get_display_id); + make_func_symbol_func("pc-set-display-id!", (void*)pc_set_display_id); make_func_symbol_func("pc-get-display-name", (void*)pc_get_display_name); make_func_symbol_func("pc-get-display-mode", (void*)pc_get_display_mode); - make_func_symbol_func("pc-set-display-mode", (void*)pc_set_display_mode); + make_func_symbol_func("pc-set-display-mode!", (void*)pc_set_display_mode); make_func_symbol_func("pc-get-display-count", (void*)pc_get_display_count); // Returns resolution of the monitor's current display mode make_func_symbol_func("pc-get-active-display-size", (void*)pc_get_active_display_size); @@ -925,10 +941,10 @@ void init_common_pc_port_functions( make_func_symbol_func("pc-get-window-size", (void*)pc_get_window_size); // Returns scale of window. This is for DPI stuff. make_func_symbol_func("pc-get-window-scale", (void*)pc_get_window_scale); - make_func_symbol_func("pc-set-fullscreen-display", (void*)pc_get_fullscreen_display); - make_func_symbol_func("pc-set-window-size", (void*)pc_set_window_size); + make_func_symbol_func("pc-set-window-size!", (void*)pc_set_window_size); make_func_symbol_func("pc-get-num-resolutions", (void*)pc_get_num_resolutions); make_func_symbol_func("pc-get-resolution", (void*)pc_get_resolution); + make_func_symbol_func("pc-is-supported-resolution?", (void*)pc_is_supported_resolution); // -- INPUT RELATED -- // Returns the name of the display with the given id or #f if not found / empty diff --git a/game/settings/settings.cpp b/game/settings/settings.cpp index 93092e6d311..bd1621fa1bb 100644 --- a/game/settings/settings.cpp +++ b/game/settings/settings.cpp @@ -53,6 +53,8 @@ void DebugSettings::load_settings() { } void DebugSettings::save_settings() { + // Update the version string as we are now saving it back ground + version = current_version; json data = *this; auto debug_settings_filename = file_util::get_user_misc_dir(g_game_version) / "debug-settings.json"; @@ -65,12 +67,17 @@ void to_json(json& j, const DisplaySettings& obj) { json_serialize(display_id); json_serialize(window_xpos); json_serialize(window_ypos); + json_serialize(display_mode); } void from_json(const json& j, DisplaySettings& obj) { json_deserialize_if_exists(version); json_deserialize_if_exists(display_id); json_deserialize_if_exists(window_xpos); json_deserialize_if_exists(window_ypos); + if (j.contains("display_mode")) { + int mode = j.at("display_mode"); + obj.display_mode = static_cast(mode); + } } DisplaySettings::DisplaySettings() {} @@ -92,6 +99,8 @@ void DisplaySettings::load_settings() { } void DisplaySettings::save_settings() { + // Update the version string as we are now saving it back ground + version = current_version; json data = *this; auto file_path = file_util::get_user_settings_dir(g_game_version) / "display-settings.json"; file_util::create_dir_if_needed_for_file(file_path); @@ -139,6 +148,8 @@ void InputSettings::load_settings() { } void InputSettings::save_settings() { + // Update the version string as we are now saving it back ground + version = current_version; json data = *this; auto file_path = file_util::get_user_settings_dir(g_game_version) / "input-settings.json"; file_util::create_dir_if_needed_for_file(file_path); diff --git a/game/settings/settings.h b/game/settings/settings.h index 2b66c04e540..d3d2cc70745 100644 --- a/game/settings/settings.h +++ b/game/settings/settings.h @@ -11,7 +11,8 @@ namespace game_settings { struct DebugSettings { DebugSettings(); - std::string version = "1.2"; + std::string current_version = "1.2"; + std::string version = current_version; bool show_imgui = false; int imgui_font_size = 16; @@ -32,13 +33,17 @@ void to_json(json& j, const DebugSettings& obj); void from_json(const json& j, DebugSettings& obj); struct DisplaySettings { + enum class DisplayMode { Windowed = 0, Fullscreen = 1, Borderless = 2 }; + DisplaySettings(); - std::string version = "1.1"; + std::string current_version = "1.2"; + std::string version = current_version; int window_xpos = 50; int window_ypos = 50; int display_id = 0; + DisplayMode display_mode = DisplayMode::Borderless; void load_settings(); void save_settings(); @@ -50,7 +55,8 @@ void from_json(const json& j, DisplaySettings& obj); struct InputSettings { InputSettings(); - std::string version = "1.0"; + std::string current_version = "1.0"; + std::string version = current_version; // NOTE - assumes only port 0 std::string last_selected_controller_guid = ""; diff --git a/game/system/hid/display_manager.cpp b/game/system/hid/display_manager.cpp index 87620b2b08a..5094c8302a8 100644 --- a/game/system/hid/display_manager.cpp +++ b/game/system/hid/display_manager.cpp @@ -7,12 +7,12 @@ #include "fmt/core.h" #include "fmt/format.h" -DisplayManager::DisplayManager(SDL_Window* window) - : m_window(window), m_selected_fullscreen_display_id(0) { +DisplayManager::DisplayManager(SDL_Window* window) : m_window(window) { prof().instant_event("ROOT"); { auto p = scoped_prof("display_manager::init"); - m_display_settings.load_settings(); + // initialize settings + m_display_settings = game_settings::DisplaySettings(); #ifdef _WIN32 // Windows hint to disable OS level forced scaling and allow native resolution at non 100% // scales @@ -20,10 +20,11 @@ DisplayManager::DisplayManager(SDL_Window* window) #endif update_curr_display_info(); update_video_modes(); - // Load display settings from a file - m_display_settings = game_settings::DisplaySettings(); + // Load from file now (after initializing current window settings) + m_display_settings.load_settings(); // Adjust window / monitor position initialize_window_position_from_settings(); + set_display_mode(m_display_settings.display_mode); } } @@ -31,8 +32,7 @@ DisplayManager::~DisplayManager() { prof().instant_event("ROOT"); { auto p = scoped_prof("display_manager::destroy"); - if (m_window_display_mode == WindowDisplayMode::Windowed) { - m_display_settings.display_id = m_active_display_id; + if (m_display_settings.display_mode == game_settings::DisplaySettings::DisplayMode::Windowed) { m_display_settings.window_xpos = m_window_xpos; m_display_settings.window_ypos = m_window_ypos; } @@ -44,9 +44,11 @@ void DisplayManager::initialize_window_position_from_settings() { // Check that the display id is still valid if (m_current_display_modes.find(m_display_settings.display_id) == m_current_display_modes.end()) { + lg::warn("[DISPLAY] Saved display ID is no longer valid, resetting to display 0"); m_display_settings.display_id = 0; m_display_settings.window_xpos = 50; m_display_settings.window_ypos = 50; + m_display_settings.save_settings(); } SDL_Rect rect; @@ -58,11 +60,13 @@ void DisplayManager::initialize_window_position_from_settings() { // Adjust the settings if they are out of bounds if (m_display_settings.window_xpos <= rect.x || m_display_settings.window_xpos + 50 >= rect.x + rect.w) { + lg::warn("[DISPLAY] Saved xpos is out of bounds, resetting"); m_display_settings.window_xpos = rect.x + 50; m_display_settings.save_settings(); } if (m_display_settings.window_ypos <= rect.y || m_display_settings.window_ypos + 50 > rect.y + rect.h) { + lg::warn("[DISPLAY] Saved ypos is out of bounds, resetting"); m_display_settings.window_ypos = rect.y + 50; m_display_settings.save_settings(); } @@ -133,11 +137,11 @@ void DisplayManager::process_ee_events() { case EEDisplayEventType::SET_WINDOW_SIZE: set_window_size(std::get(evt.param1), std::get(evt.param2)); break; - case EEDisplayEventType::SET_WINDOW_DISPLAY_MODE: - set_window_display_mode(std::get(evt.param1)); + case EEDisplayEventType::SET_DISPLAY_MODE: + set_display_mode(std::get(evt.param1)); break; - case EEDisplayEventType::SET_FULLSCREEN_DISPLAY_ID: - set_fullscreen_display_id(std::get(evt.param1)); + case EEDisplayEventType::SET_DISPLAY_ID: + set_display_id(std::get(evt.param1)); break; } ee_event_queue.pop(); @@ -152,25 +156,25 @@ std::string DisplayManager::get_connected_display_name(int id) { } int DisplayManager::get_active_display_refresh_rate() { - if (m_active_display_id >= 0 && - m_current_display_modes.find(m_active_display_id) != m_current_display_modes.end()) { - return m_current_display_modes.at(m_active_display_id).refresh_rate; + if (get_active_display_id() >= 0 && + m_current_display_modes.find(get_active_display_id()) != m_current_display_modes.end()) { + return m_current_display_modes.at(get_active_display_id()).refresh_rate; } return 0; } int DisplayManager::get_screen_width() { - if (m_active_display_id >= 0 && - m_current_display_modes.find(m_active_display_id) != m_current_display_modes.end()) { - return m_current_display_modes.at(m_active_display_id).screen_width; + if (get_active_display_id() >= 0 && + m_current_display_modes.find(get_active_display_id()) != m_current_display_modes.end()) { + return m_current_display_modes.at(get_active_display_id()).screen_width; } return 640; } int DisplayManager::get_screen_height() { - if (m_active_display_id >= 0 && - m_current_display_modes.find(m_active_display_id) != m_current_display_modes.end()) { - return m_current_display_modes.at(m_active_display_id).screen_height; + if (get_active_display_id() >= 0 && + m_current_display_modes.find(get_active_display_id()) != m_current_display_modes.end()) { + return m_current_display_modes.at(get_active_display_id()).screen_height; } return 480; } @@ -182,6 +186,16 @@ Resolution DisplayManager::get_resolution(int id) { return {0, 0, 0.0}; } +bool DisplayManager::is_supported_resolution(int width, int height) { + for (const auto resolution : m_available_resolutions) { + if (resolution.width == width && resolution.height == height) { + return true; + } + } + lg::warn("[DISPLAY] {}x{} is not a supported resolution", width, height); + return false; +} + void DisplayManager::enqueue_set_window_size(int width, int height) { const std::lock_guard lock(event_queue_mtx); ee_event_queue.push({EEDisplayEventType::SET_WINDOW_SIZE, width, height}); @@ -191,54 +205,58 @@ void DisplayManager::set_window_size(int width, int height) { SDL_SetWindowSize(m_window, width, height); } -void DisplayManager::enqueue_set_window_display_mode(WindowDisplayMode mode) { +void DisplayManager::enqueue_set_window_display_mode( + game_settings::DisplaySettings::DisplayMode mode) { const std::lock_guard lock(event_queue_mtx); - ee_event_queue.push({EEDisplayEventType::SET_WINDOW_DISPLAY_MODE, mode, {}}); + ee_event_queue.push({EEDisplayEventType::SET_DISPLAY_MODE, mode, {}}); } -void DisplayManager::set_window_display_mode(WindowDisplayMode mode) { +void DisplayManager::set_display_mode(game_settings::DisplaySettings::DisplayMode mode) { + lg::info("[DISPLAY] Setting to display mode: {}", static_cast(mode)); // https://wiki.libsdl.org/SDL2/SDL_SetWindowFullscreen int result = 0; switch (mode) { - case WindowDisplayMode::Windowed: + case game_settings::DisplaySettings::DisplayMode::Windowed: result = SDL_SetWindowFullscreen(m_window, 0); if (result == 0) { - lg::info("windowed mode - resizing window to {}x{}", m_window_width, m_window_height); + lg::info("[DISPLAY] windowed mode - resizing window to {}x{}", m_window_width, + m_window_height); SDL_SetWindowSize(m_window, m_window_width, m_window_height); } else { sdl_util::log_error("unable to change window to windowed mode"); } break; - case WindowDisplayMode::Fullscreen: - case WindowDisplayMode::Borderless: + case game_settings::DisplaySettings::DisplayMode::Fullscreen: + case game_settings::DisplaySettings::DisplayMode::Borderless: // 1. exit fullscreen result = SDL_SetWindowFullscreen(m_window, 0); if (result == 0) { SDL_Rect display_bounds; - result = SDL_GetDisplayBounds(m_selected_fullscreen_display_id, &display_bounds); + result = SDL_GetDisplayBounds(get_active_display_id(), &display_bounds); if (result < 0) { sdl_util::log_error(fmt::format("unable to get display bounds for display id {}", - m_selected_fullscreen_display_id)); + get_active_display_id())); } else { // 2. move it to the right monitor - lg::info("preparing fullscreen - moving window to {},{} on display id {}", - display_bounds.x + 50, display_bounds.y + 50, m_selected_fullscreen_display_id); + lg::info("[DISPLAY] preparing fullscreen - moving window to {},{} on display id {}", + display_bounds.x + 50, display_bounds.y + 50, get_active_display_id()); SDL_SetWindowPosition(m_window, display_bounds.x + 50, display_bounds.y + 50); - if (mode == WindowDisplayMode::Fullscreen) { + if (mode == game_settings::DisplaySettings::DisplayMode::Fullscreen) { update_video_modes(); // If fullscreen, we have to resize the window to take up the full resolution // // Some people are weird and don't use the monitor's maximum supported resolution // in which case, we use what the user actually has selected. - const auto& display_res = m_current_display_modes.at(m_selected_fullscreen_display_id); - lg::info("preparing fullscreen - setting window resolution to {}x{}", + const auto& display_res = m_current_display_modes.at(get_active_display_id()); + lg::info("[DISPLAY] preparing fullscreen - setting window resolution to {}x{}", display_res.screen_width, display_res.screen_height); set_window_size(display_res.screen_width, display_res.screen_height); } // 3. fullscreen it! - result = SDL_SetWindowFullscreen(m_window, mode == WindowDisplayMode::Fullscreen - ? SDL_WINDOW_FULLSCREEN - : SDL_WINDOW_FULLSCREEN_DESKTOP); + result = SDL_SetWindowFullscreen( + m_window, mode == game_settings::DisplaySettings::DisplayMode::Fullscreen + ? SDL_WINDOW_FULLSCREEN + : SDL_WINDOW_FULLSCREEN_DESKTOP); if (result < 0) { sdl_util::log_error("unable to switch window fullscreen or borderless fullscreen"); } @@ -254,32 +272,35 @@ void DisplayManager::set_window_display_mode(WindowDisplayMode mode) { fmt::format("unable to change window display mode to {}", fmt::underlying(mode))); } else { // Set the mode, now that we've been successful - m_window_display_mode = mode; + m_display_settings.display_mode = mode; + m_display_settings.save_settings(); } } -void DisplayManager::enqueue_set_fullscreen_display_id(int display_id) { +void DisplayManager::enqueue_set_display_id(int display_id) { const std::lock_guard lock(event_queue_mtx); - ee_event_queue.push({EEDisplayEventType::SET_FULLSCREEN_DISPLAY_ID, display_id, {}}); + ee_event_queue.push({EEDisplayEventType::SET_DISPLAY_ID, display_id, {}}); } -void DisplayManager::set_fullscreen_display_id(int display_id) { +void DisplayManager::set_display_id(int display_id) { + lg::info("[DISPLAY] Setting display id to: {}", display_id); if (display_id >= (int)m_current_display_modes.size()) { display_id = 0; } - bool update_fullscreen = m_window_display_mode != WindowDisplayMode::Windowed && - m_selected_fullscreen_display_id != display_id; - m_selected_fullscreen_display_id = display_id; - if (update_fullscreen) { - set_window_display_mode(m_window_display_mode); + m_display_settings.display_id = display_id; + if (get_display_mode() != game_settings::DisplaySettings::DisplayMode::Windowed) { + set_display_mode((game_settings::DisplaySettings::DisplayMode)m_display_settings.display_mode); } + m_display_settings.save_settings(); } void DisplayManager::update_curr_display_info() { - m_active_display_id = SDL_GetWindowDisplayIndex(m_window); - if (m_active_display_id < 0) { + lg::info("[DISPLAY] Updating current display info"); + m_display_settings.display_id = SDL_GetWindowDisplayIndex(m_window); + if (get_active_display_id() < 0) { sdl_util::log_error("could not retrieve current window's display index"); } + lg::info("[DISPLAY] current display id is {}", m_display_settings.display_id); SDL_GL_GetDrawableSize(m_window, &m_window_width, &m_window_height); SDL_GetWindowPosition(m_window, &m_window_xpos, &m_window_ypos); // Update the scale of the display as well @@ -290,6 +311,7 @@ void DisplayManager::update_curr_display_info() { } void DisplayManager::update_video_modes() { + lg::info("[DISPLAY] Enumerating video modes"); const auto num_displays = SDL_GetNumVideoDisplays(); if (num_displays < 0) { sdl_util::log_error("could not retrieve number of displays"); @@ -341,14 +363,15 @@ void DisplayManager::update_video_modes() { } void DisplayManager::update_resolutions() { + lg::info("[DISPLAY] Enumerating resolutions"); // Enumerate display's display modes to get the resolutions - auto num_display_modes = SDL_GetNumDisplayModes(m_active_display_id); + auto num_display_modes = SDL_GetNumDisplayModes(get_active_display_id()); SDL_DisplayMode curr_mode; for (int i = 0; i < num_display_modes; i++) { - auto ok = SDL_GetDisplayMode(m_active_display_id, i, &curr_mode); + auto ok = SDL_GetDisplayMode(get_active_display_id(), i, &curr_mode); if (ok != 0) { sdl_util::log_error(fmt::format("unable to get display mode for display {}, index {}", - m_active_display_id, i)); + get_active_display_id(), i)); continue; } Resolution new_res = {curr_mode.w, curr_mode.h, diff --git a/game/system/hid/display_manager.h b/game/system/hid/display_manager.h index befc696479e..23f0c3c82c2 100644 --- a/game/system/hid/display_manager.h +++ b/game/system/hid/display_manager.h @@ -17,8 +17,6 @@ - hiDPI support, see https://wiki.libsdl.org/SDL2/SDL_GetRendererOutputSize */ -enum class WindowDisplayMode { Windowed = 0, Fullscreen = 1, Borderless = 2 }; - enum class WindowState { Minimized, Maximized, Restored }; enum class Orientation { Landscape, LandscapeFlipped, Portrait, PortraitFlipped, Unknown }; @@ -47,16 +45,12 @@ struct Resolution { /// Manages display related operations and querying class DisplayManager { private: - enum class EEDisplayEventType { - SET_WINDOW_SIZE, - SET_WINDOW_DISPLAY_MODE, - SET_FULLSCREEN_DISPLAY_ID - }; + enum class EEDisplayEventType { SET_WINDOW_SIZE, SET_DISPLAY_MODE, SET_DISPLAY_ID }; struct EEDisplayEvent { EEDisplayEventType type; - std::variant param1; - std::variant param2; + std::variant param1; + std::variant param2; }; public: @@ -69,7 +63,7 @@ class DisplayManager { /// event so it can be ran from the proper thread context (the graphics thread) void process_ee_events(); - // Accessors + int get_active_display_id() { return m_display_settings.display_id; } bool is_window_active() { return m_window != nullptr; } bool is_minimized() { return m_window_state == WindowState::Minimized; } int get_window_width() { return m_window_width; } @@ -83,14 +77,17 @@ class DisplayManager { int get_active_display_refresh_rate(); int get_screen_width(); int get_screen_height(); - WindowDisplayMode get_window_display_mode() { return m_window_display_mode; } + game_settings::DisplaySettings::DisplayMode get_display_mode() { + return m_display_settings.display_mode; + } int get_num_resolutions() { return m_available_resolutions.size(); } Resolution get_resolution(int id); + bool is_supported_resolution(int width, int height); // Mutators void enqueue_set_window_size(int width, int height); - void enqueue_set_window_display_mode(WindowDisplayMode mode); - void enqueue_set_fullscreen_display_id(int display_id); + void enqueue_set_window_display_mode(game_settings::DisplaySettings::DisplayMode mode); + void enqueue_set_display_id(int display_id); void set_game_size(int width, int height) { m_window_game_width = width; @@ -109,12 +106,6 @@ class DisplayManager { std::mutex event_queue_mtx; std::queue ee_event_queue; - WindowDisplayMode m_window_display_mode = WindowDisplayMode::Windowed; - int m_active_display_id; - // This can differ from the active display id, this is set by the game - // to explicitly define which monitor the game should be fullscreened with - int m_selected_fullscreen_display_id; - int m_window_xpos = 0; int m_window_ypos = 0; int m_window_width = 0; @@ -139,6 +130,6 @@ class DisplayManager { void update_resolutions(); void set_window_size(int width, int height); - void set_window_display_mode(WindowDisplayMode mode); - void set_fullscreen_display_id(int display_id); + void set_display_mode(game_settings::DisplaySettings::DisplayMode mode); + void set_display_id(int display_id); }; diff --git a/goal_src/jak1/kernel-defs.gc b/goal_src/jak1/kernel-defs.gc index d9795e328c1..b183ddce64c 100644 --- a/goal_src/jak1/kernel-defs.gc +++ b/goal_src/jak1/kernel-defs.gc @@ -499,15 +499,15 @@ (define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) -(define-extern pc-set-window-size (function int int none)) - -(define-extern pc-set-fullscreen-display (function int none)) - -(define-extern pc-set-display-mode (function symbol none)) +(define-extern pc-set-window-size! (function int int none)) +(define-extern pc-get-display-id (function int)) +(define-extern pc-set-display-id! (function int none)) +(define-extern pc-set-display-mode! (function symbol none)) (define-extern pc-get-num-resolutions (function int)) (define-extern pc-get-resolution (function int (pointer int64) (pointer int64) none)) +(define-extern pc-is-supported-resolution? (function int int symbol)) (define-extern pc-set-frame-rate (function int none)) diff --git a/goal_src/jak1/pc/debug/default-menu-pc.gc b/goal_src/jak1/pc/debug/default-menu-pc.gc index 648be74180b..95d467e1f12 100644 --- a/goal_src/jak1/pc/debug/default-menu-pc.gc +++ b/goal_src/jak1/pc/debug/default-menu-pc.gc @@ -508,30 +508,30 @@ ,(lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y))))) (menu "Fullscreen" - (function "Windowed" #f ,(lambda () (set-display-mode! *pc-settings* 'windowed #t))) - (function "Fullscreen" #f ,(lambda () (set-display-mode! *pc-settings* 'fullscreen #t))) - (function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless #t)))) + (function "Windowed" #f ,(lambda () (pc-set-display-mode! 'windowed))) + (function "Fullscreen" #f ,(lambda () (pc-set-display-mode! 'fullscreen))) + (function "Borderless" #f ,(lambda () (pc-set-display-mode! 'borderless)))) (menu "Sizes" - (function "640 x 480" #f ,(lambda () (set-size! *pc-settings* 640 480 #t))) - (function "640 x 360" #f ,(lambda () (set-size! *pc-settings* 640 360 #t))) - (function "720 x 540" #f ,(lambda () (set-size! *pc-settings* 720 540 #t))) - (function "960 x 540" #f ,(lambda () (set-size! *pc-settings* 960 540 #t))) - (function "800 x 600" #f ,(lambda () (set-size! *pc-settings* 800 600 #t))) - (function "960 x 720" #f ,(lambda () (set-size! *pc-settings* 960 720 #t))) - (function "1280 x 720" #f ,(lambda () (set-size! *pc-settings* 1280 720 #t))) - (function "1024 x 768" #f ,(lambda () (set-size! *pc-settings* 1024 768 #t))) - (function "1366 x 768" #f ,(lambda () (set-size! *pc-settings* 1366 768 #t))) - (function "1280 x 960" #f ,(lambda () (set-size! *pc-settings* 1280 960 #t))) - (function "1440 x 1080" #f ,(lambda () (set-size! *pc-settings* 1440 1080 #t))) - (function "1920 x 1080" #f ,(lambda () (set-size! *pc-settings* 1920 1080 #t))) - (function "1920 x 1440" #f ,(lambda () (set-size! *pc-settings* 1920 1440 #t))) - (function "2560 x 1440" #f ,(lambda () (set-size! *pc-settings* 2560 1440 #t))) - (function "2880 x 2160" #f ,(lambda () (set-size! *pc-settings* 2880 2160 #t))) - (function "3840 x 2160" #f ,(lambda () (set-size! *pc-settings* 3840 2160 #t))) - (function "512 x 224" #f ,(lambda () (set-size! *pc-settings* 512 224 #t))) - (function "512 x 256" #f ,(lambda () (set-size! *pc-settings* 512 256 #t))) - (function "512 x 448" #f ,(lambda () (set-size! *pc-settings* 512 448 #t))) - (function "512 x 512" #f ,(lambda () (set-size! *pc-settings* 512 512 #t)))) + (function "640 x 480" #f ,(lambda () (set-window-size! *pc-settings* 640 480))) + (function "640 x 360" #f ,(lambda () (set-window-size! *pc-settings* 640 360))) + (function "720 x 540" #f ,(lambda () (set-window-size! *pc-settings* 720 540))) + (function "960 x 540" #f ,(lambda () (set-window-size! *pc-settings* 960 540))) + (function "800 x 600" #f ,(lambda () (set-window-size! *pc-settings* 800 600))) + (function "960 x 720" #f ,(lambda () (set-window-size! *pc-settings* 960 720))) + (function "1280 x 720" #f ,(lambda () (set-window-size! *pc-settings* 1280 720))) + (function "1024 x 768" #f ,(lambda () (set-window-size! *pc-settings* 1024 768))) + (function "1366 x 768" #f ,(lambda () (set-window-size! *pc-settings* 1366 768))) + (function "1280 x 960" #f ,(lambda () (set-window-size! *pc-settings* 1280 960))) + (function "1440 x 1080" #f ,(lambda () (set-window-size! *pc-settings* 1440 1080))) + (function "1920 x 1080" #f ,(lambda () (set-window-size! *pc-settings* 1920 1080))) + (function "1920 x 1440" #f ,(lambda () (set-window-size! *pc-settings* 1920 1440))) + (function "2560 x 1440" #f ,(lambda () (set-window-size! *pc-settings* 2560 1440))) + (function "2880 x 2160" #f ,(lambda () (set-window-size! *pc-settings* 2880 2160))) + (function "3840 x 2160" #f ,(lambda () (set-window-size! *pc-settings* 3840 2160))) + (function "512 x 224" #f ,(lambda () (set-window-size! *pc-settings* 512 224))) + (function "512 x 256" #f ,(lambda () (set-window-size! *pc-settings* 512 256))) + (function "512 x 448" #f ,(lambda () (set-window-size! *pc-settings* 512 448))) + (function "512 x 512" #f ,(lambda () (set-window-size! *pc-settings* 512 512)))) (menu "Secrets" (menu "PC cheats" (flag "Big head jak" (the binteger (pc-cheats big-head)) dm-pc-cheats-pick-func) diff --git a/goal_src/jak1/pc/pckernel-common.gc b/goal_src/jak1/pc/pckernel-common.gc index 48d466aadc7..6007a2ade2f 100644 --- a/goal_src/jak1/pc/pckernel-common.gc +++ b/goal_src/jak1/pc/pckernel-common.gc @@ -31,30 +31,18 @@ ;;;; updates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defmethod set-display-mode! ((obj pc-settings) (mode symbol) (call-handlers symbol)) - "sets the game's display mode" - ;; no-op if the display mode hasn't actually changed - (when (!= mode (-> obj display-mode)) - ;; change the display mode. - (set! (-> obj display-mode) mode) - (when call-handlers - ;; set fullscreen to what we want - (pc-set-display-mode (-> obj display-mode)) - ;; if windowed mode, set the size properly - (when (= (-> obj display-mode) 'windowed) - ;; TODO - this means the user can never have a window smaller than MIN_WIDTH/HEIGHT - (pc-set-window-size (max PC_MIN_WIDTH (-> obj window-width)) (max PC_MIN_HEIGHT (-> obj window-height)))))) - 0) - -(defmethod set-size! ((obj pc-settings) (width int) (height int) (call-handlers symbol)) +(defmethod set-window-size! ((obj pc-settings) (width int) (height int)) "sets the size of the display window" - (format 0 "Setting ~A size to ~D x ~D~%" (-> obj display-mode) width height) - (cond - ((= 'windowed (-> obj display-mode)) - (set! (-> obj window-width) width) - (set! (-> obj window-height) height) - (if call-handlers (pc-set-window-size (max PC_MIN_WIDTH (-> obj window-width)) (max PC_MIN_HEIGHT (-> obj window-height))))) - (else (set! (-> obj width) width) (set! (-> obj height) height))) + (let ((display-mode (pc-get-display-mode))) + (format 0 "Setting ~A size to ~D x ~D~%" display-mode width height) + (cond + ((= display-mode 'windowed) + (set! (-> obj window-width) width) + (set! (-> obj window-height) height) + (pc-set-window-size! (max PC_MIN_WIDTH (-> obj window-width)) (max PC_MIN_HEIGHT (-> obj window-height)))) + (else + (set! (-> obj width) width) + (set! (-> obj height) height)))) (none)) (defmethod set-aspect! ((obj pc-settings) (aw int) (ah int)) @@ -77,7 +65,7 @@ (defmethod set-frame-rate! ((obj pc-settings) (rate int) (call-handlers symbol)) "set the target framerate." (if call-handlers (pc-set-frame-rate rate)) - (if (and (!= 'fullscreen (-> obj display-mode)) (!= (pc-get-active-display-refresh-rate) rate)) (set! (-> obj vsync?) #f)) + (if (and (!= 'fullscreen (pc-get-display-mode)) (!= (pc-get-active-display-refresh-rate) rate)) (set! (-> obj vsync?) #f)) (set! (-> obj target-fps) rate) (case rate ((50) (set-game-setting! obj 'video-mode 'pal)) @@ -85,18 +73,6 @@ (else (set-game-setting! obj 'video-mode 'custom))) rate) -(defmethod set-monitor! ((obj pc-settings) (monitor int)) - "set the monitor to use when in fullscreen/borderless" - ;; if monitor selection is out of bounds (e.g. if a monitor got disconnected), - ;; then default to the primary monitor - (cond - ((>= (-> obj monitor) (pc-get-display-count)) - (format 0 "Monitor selection out of bounds, defaulting to primary monitor.~%") - (set! (-> obj monitor) 0)) - (else (set! (-> obj monitor) monitor))) - (pc-set-fullscreen-display (-> obj monitor)) - (none)) - (defmethod commit-to-file ((obj pc-settings)) "commits the current settings to the file" (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) @@ -141,11 +117,11 @@ ((-> obj letterbox?) (pc-set-letterbox (-> obj framebuffer-scissor-width) (-> obj framebuffer-scissor-height))) (else (pc-set-letterbox (-> obj framebuffer-width) (-> obj framebuffer-height)))) (pc-set-vsync (and (-> obj vsync?) - (or (= 'fullscreen (-> obj display-mode)) (>= (pc-get-active-display-refresh-rate) (-> obj target-fps))))) - (when (!= 'fullscreen (-> obj display-mode)) + (or (= 'fullscreen (pc-get-display-mode)) (>= (pc-get-active-display-refresh-rate) (-> obj target-fps))))) + (when (!= 'fullscreen (pc-get-display-mode)) (pc-set-frame-rate (-> obj target-fps))) ;; do game resolution - (if (= (-> obj display-mode) 'windowed) + (if (= (pc-get-display-mode) 'windowed) (pc-set-game-resolution (-> obj framebuffer-scissor-width) (-> obj framebuffer-scissor-height)) (pc-set-game-resolution (-> obj width) (-> obj height))) ;; set msaa sample rate. if invalid, just reset to 2. @@ -253,14 +229,14 @@ (defmethod get-current-game-width ((obj pc-settings)) "return the current width in pixels of the visible portion of the game" (cond - ((= (-> obj display-mode) 'windowed) + ((= (pc-get-display-mode) 'windowed) (if (-> obj letterbox?) (-> obj framebuffer-scissor-width) (-> obj framebuffer-width))) (else (-> obj width)))) (defmethod get-current-game-height ((obj pc-settings)) "return the current height in pixels of the visible portion of the game" (cond - ((= (-> obj display-mode) 'windowed) + ((= (pc-get-display-mode) 'windowed) (if (-> obj letterbox?) (-> obj framebuffer-scissor-height) (-> obj framebuffer-height))) (else (-> obj height)))) @@ -288,7 +264,6 @@ (-> obj aspect-ratio-auto?) (-> obj use-vis?) (-> obj letterbox?)) - (format *stdcon* "display-mode: ~A vsync? ~A~%" (-> obj display-mode) (-> obj vsync?)) (clear *pc-temp-string*)) (when *display-actor-bank* (draw-string-xy (string-format "Actor Bank: ~,,1m/~,,1m (~D)" @@ -463,8 +438,8 @@ (file-stream-close file)) (format 0 "pc settings file read: ~A~%" filename) ;; restore the windowed mode resolution properly - (when (= (-> obj display-mode) 'windowed) - (pc-set-window-size (max PC_MIN_WIDTH (-> obj window-width)) (max PC_MIN_HEIGHT (-> obj window-height)))) + (when (= (pc-get-display-mode) 'windowed) + (pc-set-window-size! (max PC_MIN_WIDTH (-> obj window-width)) (max PC_MIN_HEIGHT (-> obj window-height)))) #t) (defmethod handle-input-settings ((obj pc-settings) (file file-stream)) @@ -474,7 +449,22 @@ (("window-size") (set! (-> obj window-width) (file-stream-read-int file)) (set! (-> obj window-height) (file-stream-read-int file))) - (("game-size") (set! (-> obj width) (file-stream-read-int file)) (set! (-> obj height) (file-stream-read-int file))) + (("game-size") + ;; Check to see if the game-size is a valid resolution on this persons device + ;; on some machines, this has been proven to cause the black-screen issue https://github.com/open-goal/jak-project/issues/3563 + ;; Correlating with logs like: + ;; - OpenGL error 0x502 S8246 T824C: GL_INVALID_OPERATION error generated. Source and destination dimensions must be identical with the current filtering modes. + (let* ((saved-width (file-stream-read-int file)) + (saved-height (file-stream-read-int file)) + (supported-resolution? (pc-is-supported-resolution? saved-width saved-height))) + (cond + (supported-resolution? + (format 0 "[PC Settings]: Valid game-size resolution ~D x ~D~%" saved-width saved-height) + (set! (-> obj width) saved-width) + (set! (-> obj height) saved-height)) + (else + (pc-get-active-display-size (&-> obj width) (&-> obj height)) + (format 0 "[PC Settings]: Invalid game-size resolution ~D x ~D, defaulting to ~D x ~D~%" saved-width saved-height (-> obj width) (-> obj height)))))) (("msaa") (set! (-> obj gfx-msaa) (file-stream-read-int file))) (("aspect-state") ;; game aspect @@ -486,11 +476,12 @@ (set! (-> obj aspect-ratio-auto?) (file-stream-read-symbol file)) (unless (-> obj aspect-ratio-auto?) (set-aspect! obj (-> obj aspect-custom-x) (-> obj aspect-custom-y)))) - (("display-mode") - ;; force a display mode update - (set! (-> obj display-mode) #f) - (set-display-mode! obj (file-stream-read-symbol file) #t)) - (("monitor") (set-monitor! obj (file-stream-read-int file))) + ;; TODO - moved to C++, has to remain because settings parsing can't handle + ;; unexpected keys + (("display-mode") (file-stream-read-symbol file)) + ;; TODO - moved to C++, has to remain because settings parsing can't handle + ;; unexpected keys + (("monitor") (file-stream-read-int file)) (("letterbox") (set! (-> obj letterbox?) (file-stream-read-symbol file))) (("vsync") (set! (-> obj vsync?) (file-stream-read-symbol file))) (("font-scale") (set! (-> obj font-scale) (file-stream-read-float file))) @@ -564,10 +555,8 @@ (-> obj aspect-custom-x) (-> obj aspect-custom-y) (-> obj aspect-ratio-auto?)) - (format file " (display-mode ~A)~%" (-> obj display-mode)) (format file " (window-size ~D ~D)~%" (-> obj window-width) (-> obj window-height)) (format file " (game-size ~D ~D)~%" (-> obj width) (-> obj height)) - (format file " (monitor ~D)~%" (-> obj monitor)) (format file " (letterbox ~A)~%" (-> obj letterbox?)) (format file " (vsync ~A)~%" (-> obj vsync?)) ;(format file " (font-scale ~f)~%" (-> obj font-scale)) diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 26fa7e89b99..38c084538a5 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -123,11 +123,9 @@ (aspect-ratio-reciprocal float) ;; reciprocal of that (aspect-custom-x int) (aspect-custom-y int) - (display-mode symbol) ;; display mode. can be windowed, fullscreen or borderless (letterbox? symbol) ;; letterbox. #f = stretched (vsync? symbol) ;; vsync. (font-scale float) ;; font scaling. - (monitor int32) ;; index of which monitor to use when fullscreen or borderless ;; debug settings (os symbol) ;; windows, linux, macos (user symbol) ;; username. not system username, just debug thing. @@ -215,12 +213,10 @@ (print-debug-misc (_type_) object) (draw (_type_ dma-buffer) object) (draw-memory (_type_ dma-buffer) symbol) - (set-display-mode! (_type_ symbol symbol) int) - (set-size! (_type_ int int symbol) none) + (set-window-size! (_type_ int int) none) (set-aspect! (_type_ int int) none) (set-aspect-ratio! (_type_ float) none) (set-frame-rate! (_type_ int symbol) int) - (set-monitor! (_type_ int) none) (set-game-setting! (_type_ symbol symbol) object) (get-game-setting (_type_ symbol) symbol) (set-game-language! (_type_ language-enum) language-enum) @@ -308,10 +304,7 @@ (defmethod reset-gfx ((obj pc-settings) (call-handlers symbol)) "Set the default graphics settings" - ;; temporarily "set" to windowed so we can change window size - ;; we set our actual target display mode later. - (set! (-> obj display-mode) 'windowed) - (set-size! obj PC_BASE_WIDTH PC_BASE_HEIGHT #f) + (set-window-size! obj PC_BASE_WIDTH PC_BASE_HEIGHT) (set-aspect! obj 4 3) (set-frame-rate! obj 60 call-handlers) (set! (-> obj use-vis?) #f) @@ -330,7 +323,6 @@ (max! (-> obj height) PC_MIN_HEIGHT) (format 0 "!!!! failed to get any screen resolutions !!!!"))) (format 0 "fullscreen resolution defaulted to ~D x ~D~%" (-> obj width) (-> obj height)) - (if (not *debug-segment*) (set-display-mode! obj 'borderless call-handlers) (set-display-mode! obj 'windowed call-handlers)) (set! (-> obj gfx-msaa) PC_DEFAULT_MSAA) ;; default msaa 0) @@ -420,7 +412,8 @@ `(debug-font-scale-factor *pc-settings*)) (defmacro fullscreen? () - `(symbol-member? (-> *pc-settings* display-mode) '(fullscreen borderless))) + `(or (= (pc-get-display-mode) 'fullscreen) + (= (pc-get-display-mode) 'borderless))) (defun bcd->dec ((bcd uint)) "Convert a number encoded in BCD to its decimal equivalent" diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index 024b2500e34..2dd719fdb29 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -260,7 +260,7 @@ :param3 (game-option-menu monitor) :option-disabled-func (lambda () - (= (-> *pc-settings* display-mode) 'windowed))) + (= (pc-get-display-mode) 'windowed))) (new 'static 'game-option :option-type (game-option-type on-off) :name (text-id vsync) :scale #t) (new 'static 'game-option @@ -2045,7 +2045,6 @@ (set! (-> *game-options-pc* 6 value-to-modify) (&-> *progress-carousell* int-backup)) (set! (-> *game-options-pc* 7 value-to-modify) (&-> *progress-carousell* int-backup)) (set! (-> *graphic-options-pc* 1 value-to-modify) (&-> *progress-carousell* int-backup)) - (set! (-> *graphic-options-pc* 2 value-to-modify) (&-> *pc-settings* monitor)) (set! (-> *graphic-options-pc* 3 value-to-modify) (&-> *pc-settings* vsync?)) (set! (-> *graphic-options-pc* 5 value-to-modify) (&-> *progress-carousell* int-backup)) (set! (-> *graphic-options-pc* 6 value-to-modify) (&-> *progress-carousell* int-backup)) @@ -2486,7 +2485,7 @@ ;; resolution button. change resolution! (let ((newx (the int (-> options (-> obj option-index) param1))) (newy (the int (-> options (-> obj option-index) param2)))) - (set-size! *pc-settings* newx newy #t)) + (set-window-size! *pc-settings* newx newy)) (cpad-clear! 0 x) (cpad-clear! 0 circle) (sound-play "cursor-options") @@ -2504,7 +2503,7 @@ (commit-to-file *pc-settings*)) ((= (-> options (-> obj option-index) option-type) (game-option-type monitor)) ;; monitor button - (let ((monitor (the int (-> options (-> obj option-index) param1)))) (set-monitor! *pc-settings* monitor)) + (let ((monitor (the int (-> options (-> obj option-index) param1)))) (pc-set-display-id! monitor)) (cpad-clear! 0 x) (cpad-clear! 0 circle) (sound-play "cursor-options") @@ -2659,9 +2658,9 @@ (((game-option-type display-mode)) ;; same thing. (case (-> *progress-carousell* int-backup) - ((0) (set-display-mode! *pc-settings* 'windowed #t)) - ((1) (set-display-mode! *pc-settings* 'fullscreen #t)) - ((2) (set-display-mode! *pc-settings* 'borderless #t)))) + ((0) (pc-set-display-mode! 'windowed)) + ((1) (pc-set-display-mode! 'fullscreen)) + ((2) (pc-set-display-mode! 'borderless)))) (((game-option-type msaa)) (case (-> *progress-carousell* int-backup) ((0) (set! (-> *pc-settings* gfx-msaa) 1)) diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index ac28c57c26d..8bfadaaf478 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -203,11 +203,13 @@ (define-extern pc-get-os (function symbol)) (define-extern pc-get-window-size (function (pointer int64) (pointer int64) none)) (define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) -(define-extern pc-set-window-size (function int int none)) -(define-extern pc-set-fullscreen-display (function int none)) -(define-extern pc-set-display-mode (function symbol none)) +(define-extern pc-set-window-size! (function int int none)) +(define-extern pc-get-display-id (function int)) +(define-extern pc-set-display-id! (function int none)) +(define-extern pc-set-display-mode! (function symbol none)) (define-extern pc-get-num-resolutions (function int)) (define-extern pc-get-resolution (function int (pointer int64) (pointer int64) none)) +(define-extern pc-is-supported-resolution? (function int int symbol)) (define-extern pc-set-frame-rate (function int none)) (define-extern pc-set-vsync (function symbol none)) diff --git a/goal_src/jak2/pc/debug/default-menu-pc.gc b/goal_src/jak2/pc/debug/default-menu-pc.gc index 09a8b54734f..757bebf6668 100644 --- a/goal_src/jak2/pc/debug/default-menu-pc.gc +++ b/goal_src/jak2/pc/debug/default-menu-pc.gc @@ -799,8 +799,7 @@ (= (-> *pc-settings* territory) terr))) (defun dm-size-pick-func ((size pair)) - (set-size! *pc-settings* (/ (the int (car size)) 8) (/ (the int (cadr size)) 8) #t) - ) + (set-window-size! *pc-settings* (/ (the int (car size)) 8) (/ (the int (cadr size)) 8))) (defun dm-screen-shot-preset-pick-func ((args pair) (msg debug-menu-msg)) (let ((w (/ (the int (car args)) 8)) @@ -856,9 +855,9 @@ (function "Custom" #f ,(lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)))) ) (menu "Fullscreen" - (function "Windowed" #f ,(lambda () (set-display-mode! *pc-settings* 'windowed #t))) - (function "Fullscreen" #f ,(lambda () (set-display-mode! *pc-settings* 'fullscreen #t))) - (function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless #t))) + (function "Windowed" #f ,(lambda () (pc-set-display-mode! 'windowed))) + (function "Fullscreen" #f ,(lambda () (pc-set-display-mode! 'fullscreen))) + (function "Borderless" #f ,(lambda () (pc-set-display-mode! 'borderless))) ) (menu "Sizes" (function "640 x 480" (640 480) dm-size-pick-func) diff --git a/goal_src/jak2/pc/progress/progress-pc.gc b/goal_src/jak2/pc/progress/progress-pc.gc index add2fabc8ff..f58685bb10e 100644 --- a/goal_src/jak2/pc/progress/progress-pc.gc +++ b/goal_src/jak2/pc/progress/progress-pc.gc @@ -842,7 +842,7 @@ ;; select ((cpad-pressed? 0 confirm) (cpad-clear! 0 confirm) - (set-size! *pc-settings* select-w select-h #t) + (set-window-size! *pc-settings* select-w select-h) (pc-settings-save) (pop-state arg0)) ;; exit diff --git a/goal_src/jak2/pc/progress/progress-static-pc.gc b/goal_src/jak2/pc/progress/progress-static-pc.gc index a9e0182e1b7..253117b7745 100644 --- a/goal_src/jak2/pc/progress/progress-static-pc.gc +++ b/goal_src/jak2/pc/progress/progress-static-pc.gc @@ -436,7 +436,7 @@ This gives us more freedom to write code how we want. (push-and-set-state the-progress 'resolutions))) (new 'static 'menu-generic-carousel-option :name (text-id progress-graphics-display) - :get-item-index-fn (lambda () (-> *pc-settings* monitor)) + :get-item-index-fn (lambda () (pc-get-display-id)) :get-max-size-fn (lambda () (pc-get-display-count)) :get-item-label-fn (lambda ((index int)) (let ((name (pc-get-display-name index *pc-cpp-temp-string*))) @@ -445,9 +445,8 @@ This gives us more freedom to write code how we want. (string-format "Display ~D" index)) )) :on-confirm (lambda ((index int) (the-progress progress)) - (set-monitor! *pc-settings* index) - (pc-settings-save)) - :should-disable? (lambda () (nmember (the basic (-> *pc-settings* display-mode)) '(windowed #f)))) + (pc-set-display-id! index)) + :should-disable? (lambda () (or (= (pc-get-display-mode) 'windowed) (<= (pc-get-display-count) 1)))) (new 'static 'menu-generic-carousel-option :name (text-id progress-display-mode) :items (new 'static 'boxed-array :type text-id @@ -455,16 +454,15 @@ This gives us more freedom to write code how we want. (text-id progress-fullscreen) (text-id progress-borderless)) :get-item-index-fn (lambda () - (case (-> *pc-settings* display-mode) - (('windowed #f) 0) + (case (pc-get-display-mode) + (('windowed) 0) (('fullscreen) 1) - (('borderless) 2)) ) + (('borderless) 2))) :on-confirm (lambda ((index int) (the-progress progress)) (case index - ((0) (set-display-mode! *pc-settings* 'windowed #t)) - ((1) (set-display-mode! *pc-settings* 'fullscreen #t)) - ((2) (set-display-mode! *pc-settings* 'borderless #t))) - (pc-settings-save))) + ((0) (pc-set-display-mode! 'windowed)) + ((1) (pc-set-display-mode! 'fullscreen)) + ((2) (pc-set-display-mode! 'borderless))))) (new 'static 'menu-generic-carousel-option :name (text-id progress-aspect-ratio) :items (new 'static 'boxed-array :type text-id diff --git a/goal_src/jak3/kernel-defs.gc b/goal_src/jak3/kernel-defs.gc index 8e8ad2cc140..3b9e958ef83 100644 --- a/goal_src/jak3/kernel-defs.gc +++ b/goal_src/jak3/kernel-defs.gc @@ -206,11 +206,13 @@ (define-extern pc-get-os (function symbol)) (define-extern pc-get-window-size (function (pointer int64) (pointer int64) none)) (define-extern pc-get-window-scale (function (pointer float) (pointer float) none)) -(define-extern pc-set-window-size (function int int none)) -(define-extern pc-set-fullscreen-display (function int none)) -(define-extern pc-set-display-mode (function symbol none)) +(define-extern pc-set-window-size! (function int int none)) +(define-extern pc-get-display-id (function int)) +(define-extern pc-set-display-id! (function int none)) +(define-extern pc-set-display-mode! (function symbol none)) (define-extern pc-get-num-resolutions (function int)) (define-extern pc-get-resolution (function int (pointer int64) (pointer int64) none)) +(define-extern pc-is-supported-resolution? (function int int symbol)) (define-extern pc-set-frame-rate (function int none)) (define-extern pc-set-vsync (function symbol none)) diff --git a/goal_src/jak3/pc/debug/default-menu-pc.gc b/goal_src/jak3/pc/debug/default-menu-pc.gc index ad78516779b..14b045f63ed 100644 --- a/goal_src/jak3/pc/debug/default-menu-pc.gc +++ b/goal_src/jak3/pc/debug/default-menu-pc.gc @@ -791,7 +791,7 @@ (= (-> *pc-settings* territory) terr))) (defun dm-size-pick-func ((size pair)) - (set-size! *pc-settings* (/ (the int (car size)) 8) (/ (the int (cadr size)) 8) #t) + (set-window-size! *pc-settings* (/ (the int (car size)) 8) (/ (the int (cadr size)) 8)) ) (defun dm-screen-shot-preset-pick-func ((args pair) (msg debug-menu-msg)) @@ -848,9 +848,9 @@ (function "Custom" #f ,(lambda () (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)))) ) (menu "Fullscreen" - (function "Windowed" #f ,(lambda () (set-display-mode! *pc-settings* 'windowed #t))) - (function "Fullscreen" #f ,(lambda () (set-display-mode! *pc-settings* 'fullscreen #t))) - (function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless #t))) + (function "Windowed" #f ,(lambda () (pc-set-display-mode! 'windowed))) + (function "Fullscreen" #f ,(lambda () (pc-set-display-mode! 'fullscreen))) + (function "Borderless" #f ,(lambda () (pc-set-display-mode! 'borderless))) ) (menu "Sizes" (function "640 x 480" (640 480) dm-size-pick-func)