Browse Source

Slightly improve CJK infobox rendering

It still isn't perfect (there just isn't enough space) but we now
cut off fewer pixels at the bottom.
pull/6914/head
Gleb Mazovetskiy 2 years ago
parent
commit
813c7f3c52
  1. 4
      Source/control.cpp
  2. 6
      Source/control.h
  3. 3
      Source/engine/render/scrollrt.cpp

4
Source/control.cpp

@ -255,7 +255,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 int newLineCount = std::count(InfoString.str().begin(), InfoString.str().end(), '\n');
const int spaceIndex = std::min(4, newLineCount);
@ -1161,7 +1161,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 = {};
InfoColor = UiFlags::ColorWhite;

6
Source/control.h

@ -16,9 +16,11 @@
#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"
@ -32,6 +34,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 bool chrbtn[4];
extern bool lvlbtndown;

3
Source/engine/render/scrollrt.cpp

@ -1343,7 +1343,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) {

Loading…
Cancel
Save