| 212 | } |
| 213 | |
| 214 | ALResult Tr2MainWindow::SetState( bool adjustWindow, const Tr2MainWindowState::State& newState ) |
| 215 | { |
| 216 | m_inSetState = true; |
| 217 | ON_BLOCK_EXIT( [&] { m_inSetState = false; } ); |
| 218 | |
| 219 | Tr2MainWindowState::State state = newState; |
| 220 | SanitizeState( state ); |
| 221 | |
| 222 | if( state == m_state ) |
| 223 | { |
| 224 | return S_OK; |
| 225 | } |
| 226 | |
| 227 | if( HasWindow() && gTriDev->DeviceExists() && !m_state.RequiresDeviceReset( state ) ) |
| 228 | { |
| 229 | if( adjustWindow ) |
| 230 | { |
| 231 | AdjustWindow( state ); |
| 232 | } |
| 233 | gTriDev->SetThrottling( TriDevice::WINDOW_HIDDEN, state.showState == Tr2WindowShowState::MINIMIZED ); |
| 234 | m_state = state; |
| 235 | m_onWindowStateChange.CallVoid( state.WrapCopy() ); |
| 236 | return S_OK; |
| 237 | } |
| 238 | |
| 239 | if( gTriDev->DeviceExists() ) |
| 240 | { |
| 241 | m_onBeforeSwapChainChange.CallVoid( state.WrapCopy() ); |
| 242 | } |
| 243 | |
| 244 | CCP_LOG_CH( s_moduleChannel, "Trying to change main window to %s", state.ToString().c_str() ); |
| 245 | |
| 246 | Tr2PresentParametersAL presentParams; |
| 247 | |
| 248 | m_isResizing = true; |
| 249 | bool justCreatedWindow = false; |
| 250 | |
| 251 | if( !HasWindow() ) |
| 252 | { |
| 253 | CCP_LOG_CH( s_moduleChannel, "Creating window" ); |
| 254 | CreateOSWindow( state ); |
| 255 | justCreatedWindow = true; |
| 256 | // TODO: this SetPresentation thing is not doing what you'd think it would be doing :/ |
| 257 | gTriDev->SetPresentation( state.adapter, &presentParams ); |
| 258 | } |
| 259 | #ifdef _WIN32 |
| 260 | |
| 261 | #if USE_BORDERLESS_WINDOW |
| 262 | else if( adjustWindow ) |
| 263 | #else |
| 264 | else if( adjustWindow && m_state.windowMode != Tr2WindowMode::FULL_SCREEN ) |
| 265 | #endif |
| 266 | |
| 267 | #else |
| 268 | else if( adjustWindow ) |
| 269 | #endif |
| 270 | { |
| 271 | AdjustWindow( state ); |
nothing calls this directly
no test coverage detected