1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

GLideNUI: introduce config.hotkeys.enabledKeys

This commit is contained in:
Rosalie Wanders 2021-07-28 14:38:42 +02:00 committed by Sergey Lipskiy
parent 50fe71dc4c
commit c36ffa97f7
7 changed files with 70 additions and 23 deletions

View File

@ -139,8 +139,10 @@ void Config::resetToDefaults()
onScreenDisplay.statistics = 0; onScreenDisplay.statistics = 0;
onScreenDisplay.pos = posBottomLeft; onScreenDisplay.pos = posBottomLeft;
for (u32 idx = 0; idx < HotKey::hkTotal; ++idx) for (u32 idx = 0; idx < HotKey::hkTotal; ++idx) {
hotkeys.enabledKeys[idx] = 0;
hotkeys.keys[idx] = 0; hotkeys.keys[idx] = 0;
}
debug.dumpMode = 0; debug.dumpMode = 0;
} }
@ -200,3 +202,40 @@ const char* Config::hotkeyIniName(u32 _idx)
} }
return nullptr; return nullptr;
} }
const char* Config::enabledHotkeyIniName(u32 _idx)
{
switch (_idx)
{
case Config::HotKey::hkTexDump:
return "hkTexDumpEnabled";
case Config::HotKey::hkHdTexReload:
return "hkHdTexReloadEnabled";
case Config::HotKey::hkHdTexToggle:
return "hkHdTexToggleEnabled";
case Config::HotKey::hkTexCoordBounds:
return "hkTexCoordBoundsEnabled";
case Config::HotKey::hkNativeResTexrects:
return "hkNativeResTexrectsEnabled";
case Config::HotKey::hkVsync:
return "hkVsyncEnabled";
case Config::HotKey::hkFBEmulation:
return "hkFBEmulationEnabled";
case Config::HotKey::hkN64DepthCompare:
return "hkN64DepthCompareEnabled";
case Config::HotKey::hkOsdVis:
return "hkOsdVisEnabled";
case Config::HotKey::hkOsdFps:
return "hkOsdFpsEnabled";
case Config::HotKey::hkOsdPercent:
return "hkOsdPercentEnabled";
case Config::HotKey::hkOsdInternalResolution:
return "hkOsdInternalResolutionEnabled";
case Config::HotKey::hkOsdRenderingResolution:
return "hkOsdRenderingResolutionEnabled";
case Config::HotKey::hkForceGammaCorrection:
return "hkForceGammaCorrectionEnabled";
}
return nullptr;
}

View File

@ -235,6 +235,7 @@ struct Config
}; };
struct { struct {
u8 enabledKeys[hkTotal];
u8 keys[hkTotal]; u8 keys[hkTotal];
} hotkeys; } hotkeys;
@ -245,6 +246,7 @@ struct Config
void resetToDefaults(); void resetToDefaults();
void validate(); void validate();
static const char* hotkeyIniName(u32 _idx); static const char* hotkeyIniName(u32 _idx);
static const char* enabledHotkeyIniName(u32 _idx);
}; };
#define hack_Ogre64 (1<<0) //Ogre Battle 64 background copy #define hack_Ogre64 (1<<0) //Ogre Battle 64 background copy

View File

@ -10,6 +10,7 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QInputDialog> #include <QInputDialog>
#include <QDirIterator> #include <QDirIterator>
#include <qnamespace.h>
#include "../Config.h" #include "../Config.h"
#include "../DebugDump.h" #include "../DebugDump.h"
@ -429,7 +430,9 @@ void ConfigDialog::_init(bool reInit, bool blockCustomSettings)
if (config.hotkeys.keys[idx] != 0) { if (config.hotkeys.keys[idx] != 0) {
pWgt->setHidCode(config.hotkeys.keys[idx]); pWgt->setHidCode(config.hotkeys.keys[idx]);
pBtn->setText(HIDKeyToName(config.hotkeys.keys[idx])); pBtn->setText(HIDKeyToName(config.hotkeys.keys[idx]));
pItem->setCheckState(Qt::Checked); if (config.hotkeys.enabledKeys[idx] != 0) {
pItem->setCheckState(Qt::Checked);
}
} }
} }
} }
@ -692,7 +695,7 @@ void ConfigDialog::accept(bool justSave) {
if (!txDumpPath.exists() && if (!txDumpPath.exists() &&
!txDumpPath.mkdir(txDumpPath.absolutePath()) && !txDumpPath.mkdir(txDumpPath.absolutePath()) &&
config.textureFilter.txHiresEnable != 0 && config.textureFilter.txHiresEnable != 0 &&
config.hotkeys.keys[Config::HotKey::hkTexDump] != 0) { config.hotkeys.enabledKeys[Config::HotKey::hkTexDump] != 0) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setStandardButtons(QMessageBox::Close); msgBox.setStandardButtons(QMessageBox::Close);
msgBox.setWindowTitle("GLideN64"); msgBox.setWindowTitle("GLideN64");
@ -743,11 +746,12 @@ void ConfigDialog::accept(bool justSave) {
config.onScreenDisplay.statistics = ui->statisticsCheckBox->isChecked() ? 1 : 0; config.onScreenDisplay.statistics = ui->statisticsCheckBox->isChecked() ? 1 : 0;
for (quint32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) { for (quint32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) {
config.hotkeys.keys[idx] = 0; config.hotkeys.keys[idx] = config.hotkeys.enabledKeys[idx] = 0;
QListWidgetItem * pItem = ui->hotkeyListWidget->item(idx); QListWidgetItem * pItem = ui->hotkeyListWidget->item(idx);
HotkeyItemWidget* pWgt = (HotkeyItemWidget*)ui->hotkeyListWidget->itemWidget(pItem);
config.hotkeys.keys[idx] = pWgt->hidCode();
if (pItem->checkState() == Qt::Checked) { if (pItem->checkState() == Qt::Checked) {
HotkeyItemWidget* pWgt = (HotkeyItemWidget*)ui->hotkeyListWidget->itemWidget(pItem); config.hotkeys.enabledKeys[idx] = pWgt->hidCode();
config.hotkeys.keys[idx] = pWgt->hidCode();
} }
} }

View File

@ -144,6 +144,7 @@ void _loadSettings(QSettings & settings)
settings.beginGroup("hotkeys"); settings.beginGroup("hotkeys");
for (u32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) { for (u32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) {
config.hotkeys.keys[idx] = settings.value(Config::hotkeyIniName(idx), config.hotkeys.keys[idx]).toInt(); config.hotkeys.keys[idx] = settings.value(Config::hotkeyIniName(idx), config.hotkeys.keys[idx]).toInt();
config.hotkeys.enabledKeys[idx] = settings.value(Config::enabledHotkeyIniName(idx), config.hotkeys.keys[idx]).toInt();
} }
settings.endGroup(); settings.endGroup();
@ -319,6 +320,7 @@ void writeSettings(const QString & _strIniFolder)
settings.beginGroup("hotkeys"); settings.beginGroup("hotkeys");
for (u32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) { for (u32 idx = 0; idx < Config::HotKey::hkTotal; ++idx) {
settings.setValue(Config::hotkeyIniName(idx), config.hotkeys.keys[idx]); settings.setValue(Config::hotkeyIniName(idx), config.hotkeys.keys[idx]);
settings.setValue(Config::enabledHotkeyIniName(idx), config.hotkeys.enabledKeys[idx]);
} }
settings.endGroup(); settings.endGroup();

View File

@ -55,7 +55,7 @@ u32 TextureFilterHandler::_getConfigOptions() const
options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE); options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE);
if (config.textureFilter.txHiresFullAlphaChannel) if (config.textureFilter.txHiresFullAlphaChannel)
options |= LET_TEXARTISTS_FLY; options |= LET_TEXARTISTS_FLY;
if (config.hotkeys.keys[Config::HotKey::hkTexDump] != 0) if (config.hotkeys.enabledKeys[Config::HotKey::hkTexDump] != 0)
options |= DUMP_TEX; options |= DUMP_TEX;
if (config.textureFilter.txDeposterize) if (config.textureFilter.txDeposterize)
options |= DEPOSTERIZE; options |= DEPOSTERIZE;

View File

@ -804,7 +804,7 @@ void TextureCache::_loadBackground(CachedTexture *pTexture)
if (m_toggleDumpTex && if (m_toggleDumpTex &&
config.textureFilter.txHiresEnable != 0 && config.textureFilter.txHiresEnable != 0 &&
config.hotkeys.keys[Config::HotKey::hkTexDump] != 0) { config.hotkeys.enabledKeys[Config::HotKey::hkTexDump] != 0) {
txfilter_dmptx((u8*)pDest, pTexture->width, pTexture->height, txfilter_dmptx((u8*)pDest, pTexture->width, pTexture->height,
pTexture->width, (u16)u32(glInternalFormat), pTexture->width, (u16)u32(glInternalFormat),
(unsigned short)(pTexture->format << 8 | pTexture->size), (unsigned short)(pTexture->format << 8 | pTexture->size),
@ -1216,7 +1216,7 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
if (m_toggleDumpTex && if (m_toggleDumpTex &&
config.textureFilter.txHiresEnable != 0 && config.textureFilter.txHiresEnable != 0 &&
config.hotkeys.keys[Config::HotKey::hkTexDump] != 0) { config.hotkeys.enabledKeys[Config::HotKey::hkTexDump] != 0) {
txfilter_dmptx((u8*)texData.get(), tmptex.width, tmptex.height, txfilter_dmptx((u8*)texData.get(), tmptex.width, tmptex.height,
tmptex.width, (u16)u32(glInternalFormat), tmptex.width, (u16)u32(glInternalFormat),
(unsigned short)(_pTexture->format << 8 | _pTexture->size), (unsigned short)(_pTexture->format << 8 | _pTexture->size),

View File

@ -107,7 +107,7 @@ static void checkHotkeys()
SwitchDump(config.debug.dumpMode); SwitchDump(config.debug.dumpMode);
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkHdTexToggle], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkHdTexToggle], 0x0001)) {
if (config.textureFilter.txHiresEnable == 0) if (config.textureFilter.txHiresEnable == 0)
dwnd().getDrawer().showMessage("Enable HD textures\n", Milliseconds(750)); dwnd().getDrawer().showMessage("Enable HD textures\n", Milliseconds(750));
else else
@ -118,7 +118,7 @@ static void checkHotkeys()
if (config.textureFilter.txHiresEnable != 0) { if (config.textureFilter.txHiresEnable != 0) {
/* Force reload hi-res textures. Useful for texture artists */ /* Force reload hi-res textures. Useful for texture artists */
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkHdTexReload], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkHdTexReload], 0x0001)) {
dwnd().getDrawer().showMessage("Reload HD textures\n", Milliseconds(750)); dwnd().getDrawer().showMessage("Reload HD textures\n", Milliseconds(750));
if (txfilter_reloadhirestex()) { if (txfilter_reloadhirestex()) {
textureCache().clear(); textureCache().clear();
@ -126,11 +126,11 @@ static void checkHotkeys()
} }
/* Turn on texture dump */ /* Turn on texture dump */
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkTexDump], 0x0001)) if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkTexDump], 0x0001))
textureCache().toggleDumpTex(); textureCache().toggleDumpTex();
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkTexCoordBounds], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkTexCoordBounds], 0x0001)) {
if (config.graphics2D.enableTexCoordBounds == 0) if (config.graphics2D.enableTexCoordBounds == 0)
dwnd().getDrawer().showMessage("Bound texrect texture coordinates on\n", Milliseconds(1000)); dwnd().getDrawer().showMessage("Bound texrect texture coordinates on\n", Milliseconds(1000));
else else
@ -138,7 +138,7 @@ static void checkHotkeys()
config.graphics2D.enableTexCoordBounds = !config.graphics2D.enableTexCoordBounds; config.graphics2D.enableTexCoordBounds = !config.graphics2D.enableTexCoordBounds;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkNativeResTexrects], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkNativeResTexrects], 0x0001)) {
static u32 s_nativeResTexrects = Config::NativeResTexrectsMode::ntOptimized; static u32 s_nativeResTexrects = Config::NativeResTexrectsMode::ntOptimized;
if (config.graphics2D.enableNativeResTexrects != Config::NativeResTexrectsMode::ntDisable) { if (config.graphics2D.enableNativeResTexrects != Config::NativeResTexrectsMode::ntDisable) {
s_nativeResTexrects = config.graphics2D.enableNativeResTexrects; s_nativeResTexrects = config.graphics2D.enableNativeResTexrects;
@ -152,7 +152,7 @@ static void checkHotkeys()
dwnd().getDrawer().showMessage("Enable 2D texrects in native resolution\n", Milliseconds(1000)); dwnd().getDrawer().showMessage("Enable 2D texrects in native resolution\n", Milliseconds(1000));
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkVsync], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkVsync], 0x0001)) {
config.video.verticalSync = !config.video.verticalSync; config.video.verticalSync = !config.video.verticalSync;
dwnd().stop(); dwnd().stop();
dwnd().start(); dwnd().start();
@ -163,7 +163,7 @@ static void checkHotkeys()
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkFBEmulation], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkFBEmulation], 0x0001)) {
config.frameBufferEmulation.enable = !config.frameBufferEmulation.enable; config.frameBufferEmulation.enable = !config.frameBufferEmulation.enable;
dwnd().stop(); dwnd().stop();
dwnd().start(); dwnd().start();
@ -174,7 +174,7 @@ static void checkHotkeys()
} }
if (config.frameBufferEmulation.enable != 0 && if (config.frameBufferEmulation.enable != 0 &&
osal_is_key_pressed(config.hotkeys.keys[Config::hkN64DepthCompare], 0x0001)) { osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkN64DepthCompare], 0x0001)) {
static u32 N64DepthCompare = Config::N64DepthCompareMode::dcCompatible; static u32 N64DepthCompare = Config::N64DepthCompareMode::dcCompatible;
if (config.frameBufferEmulation.N64DepthCompare != Config::N64DepthCompareMode::dcDisable) { if (config.frameBufferEmulation.N64DepthCompare != Config::N64DepthCompareMode::dcDisable) {
N64DepthCompare = config.frameBufferEmulation.N64DepthCompare; N64DepthCompare = config.frameBufferEmulation.N64DepthCompare;
@ -189,27 +189,27 @@ static void checkHotkeys()
dwnd().getDrawer().showMessage("Enable N64 depth compare\n", Milliseconds(1000)); dwnd().getDrawer().showMessage("Enable N64 depth compare\n", Milliseconds(1000));
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkOsdVis], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkOsdVis], 0x0001)) {
config.onScreenDisplay.vis = !config.onScreenDisplay.vis; config.onScreenDisplay.vis = !config.onScreenDisplay.vis;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkOsdFps], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkOsdFps], 0x0001)) {
config.onScreenDisplay.fps = !config.onScreenDisplay.fps; config.onScreenDisplay.fps = !config.onScreenDisplay.fps;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkOsdPercent], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkOsdPercent], 0x0001)) {
config.onScreenDisplay.percent = !config.onScreenDisplay.percent; config.onScreenDisplay.percent = !config.onScreenDisplay.percent;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkOsdInternalResolution], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkOsdInternalResolution], 0x0001)) {
config.onScreenDisplay.internalResolution = !config.onScreenDisplay.internalResolution; config.onScreenDisplay.internalResolution = !config.onScreenDisplay.internalResolution;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkOsdRenderingResolution], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkOsdRenderingResolution], 0x0001)) {
config.onScreenDisplay.renderingResolution = !config.onScreenDisplay.renderingResolution; config.onScreenDisplay.renderingResolution = !config.onScreenDisplay.renderingResolution;
} }
if (osal_is_key_pressed(config.hotkeys.keys[Config::hkForceGammaCorrection], 0x0001)) { if (osal_is_key_pressed(config.hotkeys.enabledKeys[Config::hkForceGammaCorrection], 0x0001)) {
if (config.gammaCorrection.force == 0) if (config.gammaCorrection.force == 0)
dwnd().getDrawer().showMessage("Force gamma correction on\n", Milliseconds(750)); dwnd().getDrawer().showMessage("Force gamma correction on\n", Milliseconds(750));
else else