Codechange: use RAII to automatically restore _cur_dpi after use

This commit is contained in:
Rubidium
2023-01-26 19:21:36 +01:00
committed by rubidium42
parent b7a5d8e296
commit f001e84e5e
18 changed files with 122 additions and 136 deletions

View File

@@ -8,6 +8,7 @@
/** @file statusbar_gui.cpp The GUI for the bottom status bar. */
#include "stdafx.h"
#include "core/backup_type.hpp"
#include "date_func.h"
#include "gfx_func.h"
#include "news_func.h"
@@ -68,10 +69,8 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int scroll_pos, int left
int width = GetStringBoundingBox(buffer).width;
int pos = (_current_text_dir == TD_RTL) ? (scroll_pos - width) : (right - scroll_pos - left);
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
DrawString(pos, INT16_MAX, 0, buffer, TC_LIGHT_BLUE, SA_LEFT | SA_FORCE);
_cur_dpi = old_dpi;
return (_current_text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
}