| 1 |
#ifndef IMGUI_SETTINGS_HH |
| 2 |
#define IMGUI_SETTINGS_HH |
| 3 |
|
| 4 |
#include "AnalogInput.hh" |
| 5 |
#include "FileListWidget.hh" |
| 6 |
#include "ImGuiPart.hh" |
| 7 |
#include "ImGuiUtils.hh" |
| 8 |
#include "freetype_utils.hh" |
| 9 |
|
| 10 |
#include "Shortcuts.hh" |
| 11 |
|
| 12 |
#include "EventListener.hh" |
| 13 |
|
| 14 |
#include <span> |
| 15 |
#include <string> |
| 16 |
#include <vector> |
| 17 |
|
| 18 |
namespace openmsx { |
| 19 |
|
| 20 |
class JoystickManager; |
| 21 |
|
| 22 |
class ImGuiSettings final : public ImGuiPart, private EventListener |
| 23 |
{ |
| 24 |
public: |
| 25 |
explicit ImGuiSettings(ImGuiManager& manager); |
| 26 |
~ImGuiSettings(); |
| 27 |
|
| 28 |
[[nodiscard]] zstring_view iniName() const override { return "settings"; } |
| 29 |
void save(ImGuiTextBuffer& buf) override; |
| 30 |
void loadLine(std::string_view name, zstring_view value) override; |
| 31 |
void loadEnd() override; |
| 32 |
|
| 33 |
void showMenu(MSXMotherBoard* motherBoard) override; |
| 34 |
void paint(MSXMotherBoard* motherBoard) override; |
| 35 |
|
| 36 |
private: |
| 37 |
bool signalEvent(const Event& event) override; |
| 38 |
void initListener(); |
| 39 |
void deinitListener(); |
| 40 |
void deinitListenerIfIdle(); |
| 41 |
|
| 42 |
void setStyle() const; |
| 43 |
void paintJoystick(MSXMotherBoard& motherBoard, JoystickManager& joystickManager); |
| 44 |
void paintCalibrate(JoystickManager& joystickManager); |
| 45 |
void paintFont(); |
| 46 |
void paintShortcut(); |
| 47 |
void paintEditShortcut(); |
| 48 |
|
| 49 |
struct FontInfo { |
| 50 |
std::string filename; |
| 51 |
std::string displayName; |
| 52 |
int faceIndex = 0; |
| 53 |
}; |
| 54 |
std::span<const FontInfo> getAvailableFonts(); |
| 55 |
|
| 56 |
private: |
| 57 |
bool showConfigureJoystick = false; |
| 58 |
bool showFont = false; |
| 59 |
bool showShortcut = false; |
| 60 |
Shortcuts::ID editShortcutId = Shortcuts::ID::INVALID; |
| 61 |
|
| 62 |
unsigned joystick = 0; |
| 63 |
unsigned addPopupForKey = unsigned(-1); |
| 64 |
unsigned removePopupForKey = unsigned(-1); |
| 65 |
float popupTimeout = 0.0f; |
| 66 |
bool listening = false; |
| 67 |
|
| 68 |
bool showCalibrateJoystick = false; |
| 69 |
|
| 70 |
struct AnalogStatus { |
| 71 |
AnalogInput binding; |
| 72 |
float value = 0.0f; |
| 73 |
}; |
| 74 |
std::vector<AnalogStatus> analogBindings; |
| 75 |
|
| 76 |
int selectedStyle = -1; |
| 77 |
unsigned selectedJoystick = 0; |
| 78 |
std::string saveLayoutName; |
| 79 |
|
| 80 |
FileListWidget saveLayout; |
| 81 |
FileListWidget loadLayout; |
| 82 |
ConfirmDialog confirmOverwrite; |
| 83 |
|
| 84 |
std::vector<FontInfo> availableFonts; |
| 85 |
|
| 86 |
static constexpr auto persistentElements = std::tuple{ |
| 87 |
PersistentElement{"style", &ImGuiSettings::selectedStyle}, |
| 88 |
}; |
| 89 |
}; |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
#endif |