|
|
|
|
@ -19,6 +19,7 @@ namespace devilution {
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
Art dialogArt; |
|
|
|
|
std::string wrappedText; |
|
|
|
|
|
|
|
|
|
bool dialogEnd; |
|
|
|
|
|
|
|
|
|
@ -157,31 +158,8 @@ void LoadFallbackPalette()
|
|
|
|
|
BlackPalette(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Init(const char *text, const char *caption, bool error, bool renderBehind) |
|
|
|
|
void Init(const char *caption, const char *text, bool error, bool renderBehind) |
|
|
|
|
{ |
|
|
|
|
if (caption == nullptr) { |
|
|
|
|
SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 180), (Sint16)(UI_OFFSET_Y + 168), 280, 144 }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 200), (Sint16)(UI_OFFSET_Y + 211), 240, 80 }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter | UiFlags::ColorDialogWhite)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 265), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect3)); |
|
|
|
|
} else { |
|
|
|
|
SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 127), (Sint16)(UI_OFFSET_Y + 100), 385, 280 }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 110), 345, 20 }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter | UiFlags::ColorDialogYellow)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 141), 345, 190 }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(caption, rect3, UiFlags::AlignCenter | UiFlags::ColorDialogWhite)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 335), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect4)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!renderBehind) { |
|
|
|
|
ArtBackground.Unload(); |
|
|
|
|
LoadBackgroundArt("ui_art\\black.pcx"); |
|
|
|
|
@ -200,6 +178,33 @@ void Init(const char *text, const char *caption, bool error, bool renderBehind)
|
|
|
|
|
LoadMaskedArt("ui_art\\lpopup.pcx", &dialogArt); |
|
|
|
|
} |
|
|
|
|
LoadSmlButtonArt(); |
|
|
|
|
|
|
|
|
|
const int textWidth = dialogArt.w() - 40; |
|
|
|
|
|
|
|
|
|
wrappedText = WordWrapString(text, textWidth, FontSizeDialog, 0); |
|
|
|
|
|
|
|
|
|
if (caption == nullptr) { |
|
|
|
|
SDL_Rect rect1 = MakeSdlRect(PANEL_LEFT + 180, UI_OFFSET_Y + 168, dialogArt.w(), dialogArt.h()); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect2 = MakeSdlRect(PANEL_LEFT + 200, UI_OFFSET_Y + 211, textWidth, 80); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(wrappedText.c_str(), rect2, UiFlags::AlignCenter | UiFlags::ColorDialogWhite)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect3 = MakeSdlRect(PANEL_LEFT + 265, UI_OFFSET_Y + 265, SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect3)); |
|
|
|
|
} else { |
|
|
|
|
SDL_Rect rect1 = MakeSdlRect(PANEL_LEFT + 127, UI_OFFSET_Y + 100, dialogArt.w(), dialogArt.h()); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect2 = MakeSdlRect(PANEL_LEFT + 147, UI_OFFSET_Y + 110, textWidth, 20); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(caption, rect2, UiFlags::AlignCenter | UiFlags::ColorDialogYellow)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect3 = MakeSdlRect(PANEL_LEFT + 147, UI_OFFSET_Y + 141, textWidth, 190); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiText>(wrappedText.c_str(), rect3, UiFlags::AlignCenter | UiFlags::ColorDialogWhite)); |
|
|
|
|
|
|
|
|
|
SDL_Rect rect4 = MakeSdlRect(PANEL_LEFT + 264, UI_OFFSET_Y + 335, SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT); |
|
|
|
|
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect4)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Deinit() |
|
|
|
|
@ -248,14 +253,12 @@ void DialogLoop(const std::vector<std::unique_ptr<UiItemBase>> &items, const std
|
|
|
|
|
} while (!dialogEnd); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
void UiOkDialog(const char *text, const char *caption, bool error, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) |
|
|
|
|
void UiOkDialog(const char *caption, const char *text, bool error, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) |
|
|
|
|
{ |
|
|
|
|
static bool inDialog = false; |
|
|
|
|
|
|
|
|
|
if (caption != nullptr) { |
|
|
|
|
LogError("{}\n{}", text, caption); |
|
|
|
|
LogError("{}\n{}", caption, text); |
|
|
|
|
} else { |
|
|
|
|
LogError("{}", text); |
|
|
|
|
} |
|
|
|
|
@ -264,7 +267,7 @@ void UiOkDialog(const char *text, const char *caption, bool error, const std::ve
|
|
|
|
|
if (!gbQuietMode) { |
|
|
|
|
if (SDL_ShowCursor(SDL_ENABLE) <= -1) |
|
|
|
|
Log("{}", SDL_GetError()); |
|
|
|
|
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) { |
|
|
|
|
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, nullptr) <= -1) { |
|
|
|
|
Log("{}", SDL_GetError()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -278,25 +281,27 @@ void UiOkDialog(const char *text, const char *caption, bool error, const std::ve
|
|
|
|
|
|
|
|
|
|
inDialog = true; |
|
|
|
|
SDL_SetClipRect(DiabloUiSurface(), nullptr); |
|
|
|
|
Init(text, caption, error, !renderBehind.empty()); |
|
|
|
|
Init(caption, text, error, !renderBehind.empty()); |
|
|
|
|
DialogLoop(vecOkDialog, renderBehind); |
|
|
|
|
Deinit(); |
|
|
|
|
inDialog = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UiErrorOkDialog(const char *text, const char *caption, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) |
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
void UiErrorOkDialog(const char *caption, const char *text, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) |
|
|
|
|
{ |
|
|
|
|
UiOkDialog(text, caption, /*error=*/true, renderBehind); |
|
|
|
|
UiOkDialog(caption, text, /*error=*/true, renderBehind); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UiErrorOkDialog(const char *text, const char *caption, bool error) |
|
|
|
|
void UiErrorOkDialog(const char *caption, const char *text, bool error) |
|
|
|
|
{ |
|
|
|
|
UiOkDialog(text, caption, error, vecNULL); |
|
|
|
|
UiOkDialog(caption, text, error, vecNULL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UiErrorOkDialog(const char *text, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) |
|
|
|
|
{ |
|
|
|
|
UiErrorOkDialog(text, nullptr, renderBehind); |
|
|
|
|
UiErrorOkDialog(nullptr, text, renderBehind); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace devilution
|
|
|
|
|
|