Skip to content

Commit

Permalink
Slightly improve CJK infobox rendering
Browse files Browse the repository at this point in the history
It still isn't perfect (there just isn't enough space) but we now
cut off fewer pixels at the bottom.
  • Loading branch information
glebm committed Jan 11, 2024
1 parent dbf14dd commit 647f8c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void PrintInfo(const Surface &out)
return;

const int space[] = { 18, 12, 6, 3, 0 };
Rectangle infoArea { GetMainPanel().position + Displacement { 177, 46 }, { 288, 60 } };
Rectangle infoArea { GetMainPanel().position + InfoBoxTopLeft, InfoBoxSize };

const auto newLineCount = static_cast<int>(c_count(InfoString.str(), '\n'));
const int spaceIndex = std::min(4, newLineCount);
Expand Down Expand Up @@ -1187,7 +1187,7 @@ void FreeControlPan()

void DrawInfoBox(const Surface &out)
{
DrawPanelBox(out, { 177, 62, 288, 63 }, GetMainPanel().position + Displacement { 177, 46 });
DrawPanelBox(out, { 177, 62, InfoBoxSize.width, InfoBoxSize.height }, GetMainPanel().position + InfoBoxTopLeft);
if (!panelflag && !trigflag && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && !spselflag) {
InfoString = StringOrView {};
InfoColor = UiFlags::ColorWhite;
Expand Down
6 changes: 6 additions & 0 deletions Source/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#include "DiabloUI/text_input.hpp"
#include "DiabloUI/ui_flags.hpp"
#include "engine.h"
#include "engine/displacement.hpp"
#include "engine/point.hpp"
#include "engine/rectangle.hpp"
#include "engine/render/text_render.hpp"
#include "engine/size.hpp"
#include "panels/ui_panels.hpp"
#include "spelldat.h"
#include "spells.h"
Expand All @@ -33,6 +35,10 @@ namespace devilution {

constexpr Size SidePanelSize { 320, 352 };

// Info box displacement of the top-left corner relative to GetMainPanel().position.
constexpr Displacement InfoBoxTopLeft { 177, 46 };
constexpr Size InfoBoxSize { 288, 64 };

extern bool dropGoldFlag;
extern TextInputCursorState GoldDropCursor;
extern char GoldDropText[21];
Expand Down
3 changes: 2 additions & 1 deletion Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,8 @@ void DrawMain(const Surface &out, int dwHgt, bool drawDesc, bool drawHp, bool dr
// When chat input is displayed, the belt is hidden and the chat moves up.
DoBlitScreen(mainPanelPosition.x + 171, mainPanelPosition.y + 6, 298, 116);
} else {
DoBlitScreen(mainPanelPosition.x + 176, mainPanelPosition.y + 46, 288, 63);
DoBlitScreen(mainPanelPosition.x + InfoBoxTopLeft.deltaX, mainPanelPosition.y + InfoBoxTopLeft.deltaY,
InfoBoxSize.width, InfoBoxSize.height);
}
}
if (drawMana) {
Expand Down

0 comments on commit 647f8c3

Please sign in to comment.