Skip to content

Commit

Permalink
Fix chat scaling incorrectly on resolution change
Browse files Browse the repository at this point in the history
  • Loading branch information
Asunaya committed Aug 5, 2016
1 parent 617c3f2 commit db85180
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
24 changes: 19 additions & 5 deletions Gunz/NewChat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ void Chat::Create(const std::string &strFont, int nFontSize){
Cursor.y = RGetScreenHeight() / 2;

pFont = std::make_unique<MFontR2>();
pFont->Create("NewChatFont", strFont.c_str(), int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true);
pFont->Create("NewChatFont", strFont.c_str(),
int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true);
pItalicFont = std::make_unique<MFontR2>();
pItalicFont->Create("NewChatItalicFont", strFont.c_str(), int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true, true);
pItalicFont->Create("NewChatItalicFont", strFont.c_str(),
int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true, true);

nFontHeight = pFont->GetHeight();

Expand Down Expand Up @@ -245,12 +247,17 @@ void Chat::Scale(double fWidthRatio, double fHeightRatio){
Border.y1 *= fHeightRatio;
Border.y2 *= fHeightRatio;

nFontSize *= fHeightRatio;
//nFontSize *= fHeightRatio;
ResetFonts();
}

void Chat::Resize(int nWidth, int nHeight)
{
Border.x1 = 10;
Border.y1 = double(1080 - 300) / 1080 * RGetScreenHeight();
Border.x2 = (double)500 / 1920 * RGetScreenWidth();
Border.y2 = double(1080 - 100) / 1080 * RGetScreenHeight();

ResetFonts();
}

Expand Down Expand Up @@ -1229,6 +1236,13 @@ void Chat::ResetFonts(){
SafeDestroy(pFont.get());
SafeDestroy(pItalicFont.get());

pFont->Create("NewChatFont", strFont.c_str(), int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true);
pItalicFont->Create("NewChatItalicFont", strFont.c_str(), int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true, true);
char buf[64];
sprintf_safe(buf, "Font size: %d\n", int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5));
OutputDebugString(buf);
pFont->Create("NewChatFont", strFont.c_str(),
int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true);
pItalicFont->Create("NewChatItalicFont", strFont.c_str(),
int(float(nFontSize) / 1080 * RGetScreenHeight() + 0.5), 1, true, true);

nFontHeight = pFont->GetHeight();
}
5 changes: 2 additions & 3 deletions Gunz/ZOptionInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,8 @@ void ZOptionInterface::Resize(int w, int h)
ResizeWidget("MonsterBook", w, h);
ResizeWidget("CombatTDMInfo", w, h);

if (ZGetCombatInterface()) ZGetCombatInterface()->Resize(w, h);
if (ZGetCombatInterface())
ZGetCombatInterface()->Resize(w, h);

g_Chat.Resize(w, h);
}
Expand All @@ -1394,7 +1395,6 @@ void ZOptionInterface::GetOldScreenResolution()
Mint::GetInstance()->SetWorkspaceSize(ModeParams.nWidth, ModeParams.nHeight);
Mint::GetInstance()->GetMainFrame()->SetSize(ModeParams.nWidth, ModeParams.nHeight);
Resize(ModeParams.nWidth, ModeParams.nHeight);
g_Chat.Scale(double(RGetScreenWidth()) / mOldScreenWidth, double(RGetScreenHeight()) / mOldScreenHeight);

D3DDISPLAYMODE ddm;
ddm.Width = ModeParams.nWidth;
Expand Down Expand Up @@ -1460,7 +1460,6 @@ bool ZOptionInterface::TestScreenResolution()
Mint::GetInstance()->SetWorkspaceSize(ModeParams.nWidth, ModeParams.nHeight);
Mint::GetInstance()->GetMainFrame()->SetSize(ModeParams.nWidth, ModeParams.nHeight);
Resize(ModeParams.nWidth, ModeParams.nHeight);
g_Chat.Scale(double(RGetScreenWidth()) / mOldScreenWidth, double(RGetScreenHeight()) / mOldScreenHeight);
}
return true;
}
Expand Down

0 comments on commit db85180

Please sign in to comment.