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

@@ -9,6 +9,7 @@
#include "stdafx.h"
#include <stdarg.h>
#include "core/backup_type.hpp"
#include "window_gui.h"
#include "window_func.h"
#include "random_access_file_type.h"
@@ -895,17 +896,13 @@ struct SpriteAlignerWindow : Window {
DrawPixelInfo new_dpi;
if (!FillDrawPixelInfo(&new_dpi, ir.left, ir.top, ir.Width(), ir.Height())) break;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &new_dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &new_dpi);
DrawSprite(this->current_sprite, PAL_NONE, x, y, nullptr, ZOOM_LVL_GUI);
if (this->crosshair) {
GfxDrawLine(x, 0, x, ir.Height() - 1, PC_WHITE, 1, 1);
GfxDrawLine(0, y, ir.Width() - 1, y, PC_WHITE, 1, 1);
}
_cur_dpi = old_dpi;
break;
}