| 91 | } // namespace |
| 92 | |
| 93 | bool UiProgressDialog(int (*fnfunc)()) |
| 94 | { |
| 95 | SetFadeLevel(256); |
| 96 | |
| 97 | // Blit the background once and then free it. |
| 98 | ProgressLoadBackground(); |
| 99 | |
| 100 | ProgressRenderBackground(); |
| 101 | |
| 102 | if (RenderDirectlyToOutputSurface && PalSurface != nullptr) { |
| 103 | // Render into all the backbuffers if there are multiple. |
| 104 | const void *initialPixels = PalSurface->pixels; |
| 105 | UiFadeIn(); |
| 106 | while (PalSurface->pixels != initialPixels) { |
| 107 | ProgressRenderBackground(); |
| 108 | UiFadeIn(); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | ProgressFreeBackground(); |
| 113 | |
| 114 | ProgressLoadForeground(); |
| 115 | |
| 116 | endMenu = false; |
| 117 | int progress = 0; |
| 118 | |
| 119 | SDL_Event event; |
| 120 | while (!endMenu && progress < 100) { |
| 121 | progress = fnfunc(); |
| 122 | ProgressRenderForeground(progress); |
| 123 | UiRenderItems(vecProgress); |
| 124 | DrawMouse(); |
| 125 | UiFadeIn(); |
| 126 | |
| 127 | while (PollEvent(&event) != 0) { |
| 128 | switch (event.type) { |
| 129 | case SDL_MOUSEBUTTONDOWN: |
| 130 | case SDL_MOUSEBUTTONUP: |
| 131 | UiItemMouseEvents(&event, vecProgress); |
| 132 | break; |
| 133 | #ifndef USE_SDL1 |
| 134 | case SDLK_KP_ENTER: |
| 135 | #endif |
| 136 | case SDLK_ESCAPE: |
| 137 | case SDLK_RETURN: |
| 138 | case SDLK_SPACE: |
| 139 | endMenu = true; |
| 140 | break; |
| 141 | default: |
| 142 | for (MenuAction menuAction : GetMenuActions(event)) { |
| 143 | if (IsNoneOf(menuAction, MenuAction_BACK, MenuAction_SELECT)) |
| 144 | continue; |
| 145 | endMenu = true; |
| 146 | break; |
| 147 | } |
| 148 | break; |
| 149 | } |
| 150 | UiHandleEvents(&event); |
no test coverage detected