mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-14 19:41:15 +00:00
I think this is pretty much it, should be done
This commit is contained in:
parent
c5cb30bd86
commit
7bbb50a1d8
@ -450,6 +450,7 @@ target_sources(lego1 PRIVATE
|
||||
LEGO1/lego/legoomni/src/entity/legoworld.cpp
|
||||
LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp
|
||||
LEGO1/lego/legoomni/src/input/legoinputmanager.cpp
|
||||
LEGO1/lego/legoomni/src/input/legokeymaps.cpp
|
||||
LEGO1/lego/legoomni/src/main/legomain.cpp
|
||||
LEGO1/lego/legoomni/src/main/scripts.cpp
|
||||
LEGO1/lego/legoomni/src/paths/legoanimactor.cpp
|
||||
@ -639,6 +640,7 @@ if (ISLE_BUILD_CONFIG)
|
||||
qt_add_executable(isle-config WIN32
|
||||
LEGO1/mxdirectx/mxdirectxinfo.cpp
|
||||
LEGO1/mxdirectx/legodxinfo.cpp
|
||||
LEGO1/lego/legoomni/src/input/legokeymaps.cpp
|
||||
CONFIG/config.cpp
|
||||
CONFIG/AboutDlg.cpp
|
||||
CONFIG/MainDlg.cpp
|
||||
@ -654,6 +656,7 @@ if (ISLE_BUILD_CONFIG)
|
||||
list(APPEND isle_targets isle-config)
|
||||
target_compile_definitions(isle-config PRIVATE _AFXDLL MXDIRECTX_FOR_CONFIG)
|
||||
target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1")
|
||||
target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1/lego/legoomni/include")
|
||||
target_include_directories(isle-config PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/util>")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
|
||||
target_link_libraries(isle-config PRIVATE DirectX5::DirectX5)
|
||||
|
||||
@ -74,6 +74,15 @@ CMainDialog::CMainDialog(QWidget* pParent) : QDialog(pParent)
|
||||
connect(m_ui->launchButton, &QPushButton::clicked, this, &CMainDialog::launch);
|
||||
|
||||
connect(m_ui->keyForward_1, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChanged);
|
||||
connect(m_ui->keyForward_2, &QPushButton::clicked, this, &CMainDialog::ForwardKeyChangedAlt);
|
||||
connect(m_ui->keyBack_1, &QPushButton::clicked, this, &CMainDialog::BackwardKeyChanged);
|
||||
connect(m_ui->keyBack_2, &QPushButton::clicked, this, &CMainDialog::BackwardKeyChangedAlt);
|
||||
connect(m_ui->keyLeft_1, &QPushButton::clicked, this, &CMainDialog::LeftKeyChanged);
|
||||
connect(m_ui->keyLeft_2, &QPushButton::clicked, this, &CMainDialog::LeftKeyChangedAlt);
|
||||
connect(m_ui->keyRight_1, &QPushButton::clicked, this, &CMainDialog::RightKeyChanged);
|
||||
connect(m_ui->keyRight_2, &QPushButton::clicked, this, &CMainDialog::RightKeyChangedAlt);
|
||||
connect(m_ui->keySprint_1, &QPushButton::clicked, this, &CMainDialog::SprintKeyChanged);
|
||||
connect(m_ui->keySprint_2, &QPushButton::clicked, this, &CMainDialog::SprintKeyChangedAlt);
|
||||
|
||||
connect(m_ui->dataPathOpen, &QPushButton::clicked, this, &CMainDialog::SelectDataPathDialog);
|
||||
connect(m_ui->savePathOpen, &QPushButton::clicked, this, &CMainDialog::SelectSavePathDialog);
|
||||
@ -183,16 +192,18 @@ bool CMainDialog::OnInitDialog()
|
||||
m_ui->exFullResComboBox->clear();
|
||||
|
||||
int displayModeCount;
|
||||
displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount);
|
||||
m_displayModes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &displayModeCount);
|
||||
|
||||
for (int i = 0; i < displayModeCount; ++i) {
|
||||
QString mode =
|
||||
QString("%1x%2 @ %3Hz").arg(displayModes[i]->w).arg(displayModes[i]->h).arg(displayModes[i]->refresh_rate);
|
||||
QString mode = QString("%1x%2 @ %3Hz")
|
||||
.arg(m_displayModes[i]->w)
|
||||
.arg(m_displayModes[i]->h)
|
||||
.arg(m_displayModes[i]->refresh_rate);
|
||||
m_ui->exFullResComboBox->addItem(mode);
|
||||
|
||||
if ((displayModes[i]->w == currentConfigApp->m_exf_x_res) &&
|
||||
(displayModes[i]->h == currentConfigApp->m_exf_y_res) &&
|
||||
(displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) {
|
||||
if ((m_displayModes[i]->w == currentConfigApp->m_exf_x_res) &&
|
||||
(m_displayModes[i]->h == currentConfigApp->m_exf_y_res) &&
|
||||
(m_displayModes[i]->refresh_rate == currentConfigApp->m_exf_fps)) {
|
||||
m_ui->exFullResComboBox->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
@ -350,6 +361,22 @@ void CMainDialog::UpdateInterface()
|
||||
m_ui->msaaNum->setNum(currentConfigApp->m_msaa);
|
||||
m_ui->AFSlider->setValue(log2(currentConfigApp->m_anisotropy));
|
||||
m_ui->AFNum->setNum(currentConfigApp->m_anisotropy);
|
||||
|
||||
m_ui->keyForward_1->setText(GetKeyName(g_keyMaps.k_forward[0]));
|
||||
m_ui->keyForward_2->setText(GetKeyName(g_keyMaps.k_forward[1]));
|
||||
m_ui->keyBack_1->setText(GetKeyName(g_keyMaps.k_back[0]));
|
||||
m_ui->keyBack_2->setText(GetKeyName(g_keyMaps.k_back[1]));
|
||||
m_ui->keyLeft_1->setText(GetKeyName(g_keyMaps.k_left[0]));
|
||||
m_ui->keyLeft_2->setText(GetKeyName(g_keyMaps.k_left[1]));
|
||||
m_ui->keyRight_1->setText(GetKeyName(g_keyMaps.k_right[0]));
|
||||
m_ui->keyRight_2->setText(GetKeyName(g_keyMaps.k_right[1]));
|
||||
m_ui->keySprint_1->setText(GetKeyName(g_keyMaps.k_sprint[0]));
|
||||
m_ui->keySprint_2->setText(GetKeyName(g_keyMaps.k_sprint[1]));
|
||||
}
|
||||
|
||||
QString CMainDialog::GetKeyName(SDL_Scancode key)
|
||||
{
|
||||
return QString(SDL_GetKeyName(SDL_GetKeyFromScancode(key, 0, true)));
|
||||
}
|
||||
|
||||
// FUNCTION: CONFIG 0x004045e0
|
||||
@ -490,9 +517,9 @@ void CMainDialog::TransitionTypeChanged(int index)
|
||||
|
||||
void CMainDialog::ExclusiveResolutionChanged(int index)
|
||||
{
|
||||
currentConfigApp->m_exf_x_res = displayModes[index]->w;
|
||||
currentConfigApp->m_exf_y_res = displayModes[index]->h;
|
||||
currentConfigApp->m_exf_fps = displayModes[index]->refresh_rate;
|
||||
currentConfigApp->m_exf_x_res = m_displayModes[index]->w;
|
||||
currentConfigApp->m_exf_y_res = m_displayModes[index]->h;
|
||||
currentConfigApp->m_exf_fps = m_displayModes[index]->refresh_rate;
|
||||
m_modified = true;
|
||||
UpdateInterface();
|
||||
}
|
||||
@ -637,12 +664,8 @@ void CMainDialog::TexturePathEdited()
|
||||
void CMainDialog::AddCustomAssetPath()
|
||||
{
|
||||
QDir data_path = QDir(QString::fromStdString(currentConfigApp->m_cd_path));
|
||||
QStringList new_files = QFileDialog::getOpenFileNames(
|
||||
this,
|
||||
"Open File(s)",
|
||||
data_path.absolutePath(),
|
||||
"Interleaf files (*.si)"
|
||||
);
|
||||
QStringList new_files =
|
||||
QFileDialog::getOpenFileNames(this, "Open File(s)", data_path.absolutePath(), "Interleaf files (*.si)");
|
||||
if (!new_files.isEmpty()) {
|
||||
for (QString& item : new_files) {
|
||||
item = data_path.relativeFilePath(item);
|
||||
@ -752,30 +775,85 @@ void CMainDialog::FramerateChanged(int i)
|
||||
UpdateInterface();
|
||||
}
|
||||
|
||||
void CMainDialog::ForwardKeyChanged() {
|
||||
void CMainDialog::ForwardKeyChanged()
|
||||
{
|
||||
RebindInput(m_ui->keyForward_1, g_keyMaps.k_forward[0]);
|
||||
}
|
||||
|
||||
void CMainDialog::RebindInput(QPushButton* &button, SDL_Scancode &key)
|
||||
void CMainDialog::ForwardKeyChangedAlt()
|
||||
{
|
||||
RebindInput(m_ui->keyForward_2, g_keyMaps.k_forward[1]);
|
||||
}
|
||||
|
||||
void CMainDialog::BackwardKeyChanged()
|
||||
{
|
||||
RebindInput(m_ui->keyBack_1, g_keyMaps.k_back[0]);
|
||||
}
|
||||
|
||||
void CMainDialog::BackwardKeyChangedAlt()
|
||||
{
|
||||
RebindInput(m_ui->keyBack_2, g_keyMaps.k_back[1]);
|
||||
}
|
||||
|
||||
void CMainDialog::LeftKeyChanged()
|
||||
{
|
||||
RebindInput(m_ui->keyLeft_1, g_keyMaps.k_left[0]);
|
||||
}
|
||||
|
||||
void CMainDialog::LeftKeyChangedAlt()
|
||||
{
|
||||
RebindInput(m_ui->keyLeft_2, g_keyMaps.k_left[1]);
|
||||
}
|
||||
|
||||
void CMainDialog::RightKeyChanged()
|
||||
{
|
||||
RebindInput(m_ui->keyRight_1, g_keyMaps.k_right[0]);
|
||||
}
|
||||
|
||||
void CMainDialog::RightKeyChangedAlt()
|
||||
{
|
||||
RebindInput(m_ui->keyRight_2, g_keyMaps.k_right[1]);
|
||||
}
|
||||
|
||||
void CMainDialog::SprintKeyChanged()
|
||||
{
|
||||
RebindInput(m_ui->keySprint_1, g_keyMaps.k_sprint[0]);
|
||||
}
|
||||
|
||||
void CMainDialog::SprintKeyChangedAlt()
|
||||
{
|
||||
RebindInput(m_ui->keySprint_2, g_keyMaps.k_sprint[1]);
|
||||
}
|
||||
|
||||
void CMainDialog::RebindInput(QPushButton*& button, SDL_Scancode& key)
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
||||
button->setText(QString("Press a key..."));
|
||||
currentKeyBind = &key;
|
||||
m_currentKeyBind = &key;
|
||||
|
||||
inputWindow = SDL_CreateWindow("Press a key...", 256, 128, SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY | SDL_WINDOW_KEYBOARD_GRABBED);
|
||||
m_inputWindow = SDL_CreateWindow(
|
||||
"Press a key...",
|
||||
256,
|
||||
128,
|
||||
SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY |
|
||||
SDL_WINDOW_KEYBOARD_GRABBED
|
||||
);
|
||||
#ifdef MINIWIN
|
||||
hWnd = reinterpret_cast<HWND>(inputWindow);
|
||||
m_hWnd = reinterpret_cast<HWND>(m_inputWindow);
|
||||
#else
|
||||
hWnd = (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
m_hWnd =
|
||||
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(m_inputWindow), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
#endif
|
||||
|
||||
inputTimeout.setSingleShot(true);
|
||||
inputTimeout.setInterval(3 * 1000);
|
||||
inputTimeout.setSingleShot(false);
|
||||
inputTimeout.setInterval(1000);
|
||||
sdlPoller.setSingleShot(false);
|
||||
sdlPoller.setInterval(10);
|
||||
connect(&inputTimeout, &QTimer::timeout, this, &CMainDialog::RebindTimeout);
|
||||
connect(&sdlPoller, &QTimer::timeout, this, &CMainDialog::PollInputs);
|
||||
SDL_ShowWindow(inputWindow);
|
||||
SDL_ShowWindow(m_inputWindow);
|
||||
SDL_RaiseWindow(m_inputWindow);
|
||||
timeoutCountdown = 3;
|
||||
sdlPoller.start();
|
||||
inputTimeout.start();
|
||||
}
|
||||
@ -785,13 +863,14 @@ void CMainDialog::PollInputs()
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
SDL_Log("Key down!");
|
||||
SDL_Scancode sc = event.key.scancode;
|
||||
*currentKeyBind = sc;
|
||||
if (event.key.scancode != SDL_SCANCODE_ESCAPE) {
|
||||
SDL_Scancode sc = event.key.scancode;
|
||||
*m_currentKeyBind = sc;
|
||||
m_modified = true;
|
||||
}
|
||||
sdlPoller.disconnect();
|
||||
inputTimeout.disconnect();
|
||||
SDL_DestroyWindow(inputWindow);
|
||||
m_modified = true;
|
||||
SDL_DestroyWindow(m_inputWindow);
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
@ -799,9 +878,11 @@ void CMainDialog::PollInputs()
|
||||
|
||||
void CMainDialog::RebindTimeout()
|
||||
{
|
||||
SDL_Log("Timeout");
|
||||
sdlPoller.disconnect();
|
||||
inputTimeout.disconnect();
|
||||
SDL_DestroyWindow(inputWindow);
|
||||
UpdateInterface();
|
||||
timeoutCountdown -= 1;
|
||||
if (timeoutCountdown <= 0) {
|
||||
sdlPoller.disconnect();
|
||||
inputTimeout.disconnect();
|
||||
SDL_DestroyWindow(m_inputWindow);
|
||||
UpdateInterface();
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
@ -38,15 +39,17 @@ class CMainDialog : public QDialog {
|
||||
bool m_advanced = false;
|
||||
QStringList assetPaths = QStringList();
|
||||
Ui::MainDialog* m_ui = nullptr;
|
||||
SDL_DisplayMode** displayModes;
|
||||
SDL_Window* inputWindow;
|
||||
HWND hWnd;
|
||||
SDL_DisplayMode** m_displayModes;
|
||||
SDL_Window* m_inputWindow;
|
||||
HWND m_hWnd;
|
||||
QTimer sdlPoller;
|
||||
QTimer inputTimeout;
|
||||
SDL_Scancode* currentKeyBind = nullptr;
|
||||
QTimer inputTimeout;
|
||||
int timeoutCountdown = 0;
|
||||
SDL_Scancode* m_currentKeyBind = nullptr;
|
||||
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
bool OnInitDialog();
|
||||
QString GetKeyName(SDL_Scancode key);
|
||||
private slots:
|
||||
void OnList3DevicesSelectionChanged(int row);
|
||||
void OnCheckbox3DSound(bool checked);
|
||||
@ -88,10 +91,19 @@ private slots:
|
||||
void AspectRatioChanged(int index);
|
||||
void EnsureAspectRatio();
|
||||
void FramerateChanged(int i);
|
||||
void ForwardKeyChanged();
|
||||
void RebindInput(QPushButton* &button, SDL_Scancode &key);
|
||||
void RebindInput(QPushButton*& button, SDL_Scancode& key);
|
||||
void PollInputs();
|
||||
void RebindTimeout();
|
||||
void ForwardKeyChanged();
|
||||
void ForwardKeyChangedAlt();
|
||||
void BackwardKeyChanged();
|
||||
void BackwardKeyChangedAlt();
|
||||
void LeftKeyChanged();
|
||||
void LeftKeyChangedAlt();
|
||||
void RightKeyChanged();
|
||||
void RightKeyChangedAlt();
|
||||
void SprintKeyChanged();
|
||||
void SprintKeyChangedAlt();
|
||||
};
|
||||
|
||||
// SYNTHETIC: CONFIG 0x00403de0
|
||||
|
||||
@ -507,8 +507,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_EVENTS) != true) {
|
||||
qDebug() << "SDL_Init Error:" << SDL_GetError();
|
||||
//return 1;
|
||||
}
|
||||
// return 1;
|
||||
}
|
||||
|
||||
int result = 1;
|
||||
if (g_theApp.InitInstance()) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "AboutDlg.h"
|
||||
#include "compat.h"
|
||||
#include "decomp.h"
|
||||
#include "lego/legoomni/include/legokeymaps.h"
|
||||
#include "legokeymaps.h"
|
||||
|
||||
#ifdef MINIWIN
|
||||
#include "miniwin/d3d.h"
|
||||
@ -12,8 +12,8 @@
|
||||
#include <d3d.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <SDL3/SDL_scancode.h>
|
||||
#include <string>
|
||||
|
||||
class LegoDeviceEnumerate;
|
||||
struct Direct3DDeviceInfo;
|
||||
|
||||
@ -960,9 +960,6 @@ The game will gradually increase the number of actors until this maximum is reac
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Work-In-Progress, currently non-functional</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Keyboard Mappings</string>
|
||||
</property>
|
||||
|
||||
@ -16,14 +16,14 @@
|
||||
#include <map>
|
||||
#include <variant>
|
||||
|
||||
struct KeyMaps {
|
||||
SDL_Scancode k_forward[2];
|
||||
SDL_Scancode k_back[2];
|
||||
SDL_Scancode k_left[2];
|
||||
SDL_Scancode k_right[2];
|
||||
SDL_Scancode k_sprint[2];
|
||||
};
|
||||
|
||||
struct {
|
||||
SDL_Scancode k_forward[2] = {SDL_SCANCODE_UP, SDL_SCANCODE_KP_8};
|
||||
SDL_Scancode k_back[2] = {SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2};
|
||||
SDL_Scancode k_left[2] = {SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4};
|
||||
SDL_Scancode k_right[2] = {SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6};
|
||||
SDL_Scancode k_sprint[2] = {SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL};
|
||||
} g_keyMaps;
|
||||
|
||||
extern KeyMaps g_keyMaps;
|
||||
|
||||
#endif
|
||||
|
||||
11
LEGO1/lego/legoomni/src/input/legokeymaps.cpp
Normal file
11
LEGO1/lego/legoomni/src/input/legokeymaps.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "legokeymaps.h"
|
||||
|
||||
#include <SDL3/SDL_scancode.h>
|
||||
|
||||
KeyMaps g_keyMaps = {
|
||||
{SDL_SCANCODE_UP, SDL_SCANCODE_KP_8},
|
||||
{SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2},
|
||||
{SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4},
|
||||
{SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6},
|
||||
{SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user