Browse Source

DiabloUI: Dialog positioning and other tweaks

pull/314/head
Gleb Mazovetskiy 7 years ago committed by Anders Jenbo
parent
commit
aa3a8fecd5
  1. 2
      SourceX/DiabloUI/button.h
  2. 9
      SourceX/DiabloUI/diabloui.cpp
  3. 1
      SourceX/DiabloUI/diabloui.h
  4. 18
      SourceX/DiabloUI/dialogs.cpp
  5. 3
      SourceX/DiabloUI/text_draw.cpp
  6. 9
      SourceX/DiabloUI/ui_item.h

2
SourceX/DiabloUI/button.h

@ -12,7 +12,7 @@ inline void UnloadSmlButtonArt()
SmlButton.Unload();
}
constexpr decltype(SDL_Rect().w) SML_BUTTON_WIDTH = 110;
constexpr decltype(SDL_Rect().h) SML_BUTTON_HEIGHT = 27;
constexpr decltype(SDL_Rect().h) SML_BUTTON_HEIGHT = 28;
enum class ButtonFrame {
BG_GOLD = 0,

9
SourceX/DiabloUI/diabloui.cpp

@ -637,15 +637,10 @@ void UiPollAndRender() {
while (SDL_PollEvent(&event)) {
UiFocusNavigation(&event);
}
UiRender(gUiItems, gUiItemCnt);
UiFadeIn();
}
void UiRender(UiItem *items, std::size_t size)
{
UiRenderItems(items, size);
UiRenderItems(gUiItems, gUiItemCnt);
DrawLogo();
DrawMouse();
UiFadeIn();
}
namespace {

1
SourceX/DiabloUI/diabloui.h

@ -50,7 +50,6 @@ void UiFocusNavigationYesNo();
void UiInitList(int min, int max, void (*fnFocus)(int value), void (*fnSelect)(int value), void (*fnEsc)(), UiItem *items, int size, bool wraps = false, bool (*fnYesNo)() = NULL);
void UiInitScrollBar(UiScrollBar *ui_sb, std::size_t viewport_size, const std::size_t *current_offset);
void UiPollAndRender();
void UiRender(UiItem *items, std::size_t size);
void UiRenderItems(UiItem *items, std::size_t size);
void DvlIntSetting(const char *valuename, int *value);

18
SourceX/DiabloUI/dialogs.cpp

@ -40,26 +40,26 @@ void DialogActionCancel()
}
constexpr auto DIALOG_ART_S = UiImage(&dialogArt, { 180, 168, 280, 144 });
constexpr auto DIALOG_ART_L = UiImage(&dialogArt, { 128, 168, 385, 280 });
constexpr auto DIALOG_ART_L = UiImage(&dialogArt, { 127, 100, 385, 280 });
UiItem OKCANCEL_DIALOG[] = {
DIALOG_ART_S,
UiText(dialogText, { 200, 200, 240, 80 }, UIS_CENTER),
UiText(dialogText, { 198, 211, 240, 80 }, UIS_CENTER),
MakeSmlButton("OK", &DialogActionOK, 200, 265),
MakeSmlButton("Cancel", &DialogActionCancel, 330, 265),
};
UiItem OK_DIALOG[] = {
DIALOG_ART_S,
UiText(dialogText, { 200, 200, 240, 80 }, UIS_CENTER),
MakeSmlButton("OK", &DialogActionOK, 266, 265),
UiText(dialogText, { 200, 211, 240, 80 }, UIS_CENTER),
MakeSmlButton("OK", &DialogActionOK, 265, 265),
};
UiItem OK_DIALOG_WITH_CAPTION[] = {
DIALOG_ART_L,
UiText(dialogText, { 200, 200, 240, 80 }, UIS_CENTER),
UiText(dialogCaption, { 200, 280, 240, 80 }, UIS_CENTER),
MakeSmlButton("OK", &DialogActionOK, 266, 401),
UiText(dialogText, SDL_Color { 255, 255, 0, 0 }, { 200, 110, 240, 20 }, UIS_CENTER),
UiText(dialogCaption, { 200, 141, 240, 80 }, UIS_CENTER),
MakeSmlButton("OK", &DialogActionOK, 264, 335),
};
UiItem PROGRESS_DIALOG[] = {
@ -147,7 +147,9 @@ void DialogLoop(UiItem *items, std::size_t num_items, UiItem *render_behind, std
}
}
UiRenderItems(render_behind, render_behind_size);
UiRender(items, num_items);
DrawLogo();
UiRenderItems(items, num_items);
DrawMouse();
UiFadeIn();
} while (state == State::DEFAULT);
}

3
SourceX/DiabloUI/text_draw.cpp

@ -41,7 +41,8 @@ void DrawTTF(const char *text, const SDL_Rect &rect, int flags,
dest_rect.y += static_cast<decltype(SDL_Rect().y)>(SCREEN_Y + y_offset);
SDL_Rect shadow_rect = dest_rect;
shadow_rect.x += 2;
++shadow_rect.x;
++shadow_rect.y;
if (SDL_BlitSurface(shadow_surface, nullptr, pal_surface, &shadow_rect) <= -1)
SDL_Log(SDL_GetError());
if (SDL_BlitSurface(text_surface, nullptr, pal_surface, &dest_rect) <= -1)

9
SourceX/DiabloUI/ui_item.h

@ -88,15 +88,20 @@ struct UiImage : public UiItemBase {
// Plain text (TTF).
struct UiText : public UiItemBase {
constexpr UiText(const char *text, SDL_Rect rect, int flags = 0)
constexpr UiText(const char *text, SDL_Color color, SDL_Rect rect, int flags = 0)
: UiItemBase(rect, flags)
, color{ 243, 243, 243, 0 }
, color(color)
, shadow_color{ 0, 0, 0, 0 }
, text(text)
, render_cache(nullptr)
{
}
constexpr UiText(const char *text, SDL_Rect rect, int flags = 0)
: UiText(text, SDL_Color{ 243, 243, 243, 0 }, rect, flags)
{
}
SDL_Color color;
SDL_Color shadow_color;
const char *text;

Loading…
Cancel
Save