From f666ab14cb15d0b5592e7bb36976b3bb45f03c37 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 28 Aug 2020 00:18:45 +0000 Subject: [PATCH] Make movie_pause_window window inherit from dcx::window --- d2x-rebirth/main/movie.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/d2x-rebirth/main/movie.cpp b/d2x-rebirth/main/movie.cpp index bce0033c1..b2d9bab52 100644 --- a/d2x-rebirth/main/movie.cpp +++ b/d2x-rebirth/main/movie.cpp @@ -122,6 +122,12 @@ static unsigned int FileRead(void *handle, void *buf, unsigned int count) return (numread == count); } +struct movie_pause_window : window +{ + using window::window; + virtual window_event_result event_handler(const d_event &) override; +}; + } //----------------------------------------------------------------------- @@ -253,10 +259,8 @@ struct movie : ignore_window_pointer_t d_subtitle_state SubtitleState; }; -static window_event_result show_pause_message(window *, const d_event &event, const unused_window_userdata_t *) +window_event_result movie_pause_window::event_handler(const d_event &event) { - window_event_result result; - switch (event.type) { case EVENT_MOUSE_BUTTON_DOWN: @@ -264,11 +268,10 @@ static window_event_result show_pause_message(window *, const d_event &event, co return window_event_result::ignored; DXX_BOOST_FALLTHROUGH; case EVENT_KEY_COMMAND: - if ((result = call_default_handler(event)) == window_event_result::ignored) - { + if (const auto result = call_default_handler(event); result == window_event_result::ignored) return window_event_result::close; - } - return result; + else + return result; case EVENT_WINDOW_DRAW: { @@ -323,8 +326,12 @@ static window_event_result MovieHandler(window *, const d_event &event, movie *m // If PAUSE pressed, then pause movie if ((key == KEY_PAUSE) || (key == KEY_COMMAND + KEY_P)) { - if (window_create(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, show_pause_message, unused_window_userdata)) + if (auto pause_window = std::make_unique(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT)) + { MVE_rmHoldMovie(); + pause_window->send_creation_events(nullptr); + pause_window.release(); + } return window_event_result::handled; } break;