Skip to content

Commit

Permalink
Fix some help GUI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samkusin committed Aug 17, 2023
1 parent db18f06 commit df9760c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 41 deletions.
71 changes: 39 additions & 32 deletions host/clem_front.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ ClemensFrontend::ClemensFrontend(ClemensConfiguration &config,
emulatorHasMouseFocus_(false), mouseInEmulatorScreen_(false),
pasteClipboardToEmulator_(false), debugIOMode_(DebugIOMode::Core), vgcDebugMinScanline_(0),
vgcDebugMaxScanline_(0), joystickSlotCount_(0), guiMode_(GUIMode::None),
guiPrevMode_(GUIMode::None), appTime_(0.0), nextUIFlashCycleAppTime_(0.0),
uiFlashAlpha_(1.0f), debugger_(backendQueue_, *this), settingsView_(config_) {
helpMode_(HelpMode::None), appTime_(0.0), nextUIFlashCycleAppTime_(0.0), uiFlashAlpha_(1.0f),
debugger_(backendQueue_, *this), settingsView_(config_) {

ClemensTraceExecutedInstruction::initialize();

Expand Down Expand Up @@ -923,15 +923,25 @@ auto ClemensFrontend::frame(int width, int height, double deltaTime, ClemensHost
interop.minWindowHeight +=
ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().WindowBorderSize;
}
if (interop.action != ClemensHostInterop::None) {
// leave the help interface.
helpMode_ = HelpMode::None;
// prevent low-priority operations if in a modal state

if (guiMode_ == GUIMode::LoadSnapshot || guiMode_ == GUIMode::LoadSnapshotAfterPowerOn ||
guiMode_ == GUIMode::SaveSnapshot) {
interop.action = ClemensHostInterop::None;
}
}
switch (interop.action) {
case ClemensHostInterop::About:
setGUIMode(GUIMode::Help);
helpMode_ = HelpMode::General;
break;
case ClemensHostInterop::Help:
setGUIMode(GUIMode::HelpShortcuts);
helpMode_ = HelpMode::Shortcuts;
break;
case ClemensHostInterop::DiskHelp:
setGUIMode(GUIMode::HelpDisk);
helpMode_ = HelpMode::Disk;
break;
case ClemensHostInterop::LoadSnapshot:
if (isBackendRunning()) {
Expand Down Expand Up @@ -994,6 +1004,9 @@ auto ClemensFrontend::frame(int width, int height, double deltaTime, ClemensHost
}
emulatorHasMouseFocus_ = emulatorHasMouseFocus_ && isBackendRunning();
doEmulatorInterface(interfaceAnchor, ImVec2(width, height), interop, viewToMonitor, deltaTime);
if (helpMode_ != HelpMode::None) {
doHelpScreen(width, height);
}

switch (guiMode_) {
case GUIMode::None:
Expand Down Expand Up @@ -1031,11 +1044,6 @@ auto ClemensFrontend::frame(int width, int height, double deltaTime, ClemensHost
setGUIMode(GUIMode::LoadSnapshot);
}
break;
case GUIMode::Help:
case GUIMode::HelpShortcuts:
case GUIMode::HelpDisk:
doHelpScreen(width, height);
break;
case GUIMode::JoystickConfig:
// this is handled above
break;
Expand All @@ -1058,8 +1066,6 @@ auto ClemensFrontend::frame(int width, int height, double deltaTime, ClemensHost
break;
}

guiPrevMode_ = guiMode_;

if (delayRebootTimer_.has_value()) {
delayRebootTimer_ = *delayRebootTimer_ + (float)deltaTime;
if (*delayRebootTimer_ > kClemensRebootDelayDuration) {
Expand Down Expand Up @@ -1278,17 +1284,24 @@ void ClemensFrontend::doEmulatorInterface(ImVec2 anchor, ImVec2 dimensions,
if (guiMode_ == GUIMode::JoystickConfig)
guiMode_ = GUIMode::None;
doMachineSmartDiskBrowserInterface(kMonitorViewAnchor, kMonitorViewSize);
} else if (guiMode_ == GUIMode::Setup) {
doSetupUI(kMonitorViewAnchor, kMonitorViewSize);
} else if (guiMode_ == GUIMode::JoystickConfig) {
doJoystickConfig(kMonitorViewAnchor, kMonitorViewSize);
} else {
if (config_.hybridInterfaceEnabled) {
doDebuggerLayout(kMonitorViewAnchor, kMonitorViewSize, viewToMonitor);
} else {
doMachineViewLayout(kMonitorViewAnchor, kMonitorViewSize, viewToMonitor);
switch (guiMode_) {
case GUIMode::Setup:
doSetupUI(kMonitorViewAnchor, kMonitorViewSize);
break;
case GUIMode::JoystickConfig:
doJoystickConfig(kMonitorViewAnchor, kMonitorViewSize);
break;
default:
if (config_.hybridInterfaceEnabled) {
doDebuggerLayout(kMonitorViewAnchor, kMonitorViewSize, viewToMonitor);
} else {
doMachineViewLayout(kMonitorViewAnchor, kMonitorViewSize, viewToMonitor);
}
break;
}
}

doSidePanelLayout(kSideBarAnchor, kSideBarSize);
doInfoStatusLayout(kInfoStatusAnchor, kInfoStatusSize, kMonitorViewAnchor.x);
ImGui::PopStyleColor(7);
Expand Down Expand Up @@ -3123,15 +3136,15 @@ void ClemensFrontend::doHelpScreen(int width, int height) {
ClemensHostImGui::Markdown(CLEM_L10N_LABEL(kEmulatorHelp));
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem(
"Hotkeys", NULL,
guiMode_ == GUIMode::HelpShortcuts ? ImGuiTabItemFlags_SetSelected : 0)) {
if (ImGui::BeginTabItem("Hotkeys", NULL,
helpMode_ == HelpMode::Shortcuts ? ImGuiTabItemFlags_SetSelected
: 0)) {
ClemensHostImGui::Markdown(CLEM_L10N_LABEL(kGSKeyboardCommands));
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Disk Selection", NULL,
guiMode_ == GUIMode::HelpDisk ? ImGuiTabItemFlags_SetSelected
: 0)) {
helpMode_ == HelpMode::Disk ? ImGuiTabItemFlags_SetSelected
: 0)) {
ClemensHostImGui::Markdown(CLEM_L10N_LABEL(kDiskSelectionHelp));
ImGui::EndTabItem();
}
Expand All @@ -3144,13 +3157,7 @@ void ClemensFrontend::doHelpScreen(int width, int height) {

ImGui::EndPopup();
}
if (guiMode_ == GUIMode::HelpShortcuts || guiMode_ == GUIMode::HelpDisk) {
// hacky method to automatically trigger the shortcuts tab from the main menu
setGUIMode(GUIMode::Help);
}
if (!isOpen) {
setGUIMode(GUIMode::Emulator);
}
helpMode_ = isOpen ? HelpMode::General : HelpMode::None;
}

void ClemensFrontend::doJoystickConfig(ImVec2 anchor, ImVec2 dimensions) {
Expand Down
12 changes: 8 additions & 4 deletions host/clem_front.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,22 @@ class ClemensFrontend : public ClemensHostView, ClemensDebuggerListener {
LoadSnapshot,
LoadSnapshotAfterPowerOn,
SaveSnapshot,
Help,
HelpShortcuts,
HelpDisk,
JoystickConfig,
RebootEmulator,
StartingEmulator,
ShutdownEmulator
};
void setGUIMode(GUIMode guiMode);

enum class HelpMode {
None,
General,
Shortcuts,
Disk
};

GUIMode guiMode_;
GUIMode guiPrevMode_;
HelpMode helpMode_;
double appTime_;
double nextUIFlashCycleAppTime_;
float uiFlashAlpha_;
Expand Down
14 changes: 9 additions & 5 deletions host/strings/clem_help.inl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ First time users will be prompted to set a location where the emulator will stor
const char *kDiskSelectionHelp[] = {R"md(
## Disk Selection
Disk images are loaded by 'importing' them into the Emulator's library folder.
The disk tray resides on the top left most section of the interface.
Each widget represents a physical disk slot.
* **s5d1** and **s5d2** disks were 800K 3.5" disk images used to distribute most Apple IIgs titles
* **s6d1** and **s6d2** disks were 140K 5.25" disk images used to legacy Apple II titles
* **s7d1** and **s7d2** are disks that can support up to 32MB hard drive images
All disk widgets have eject buttons. Currently s7d1 and s7d2 do not support write protection.
* Choose a drive from the four drive widgets in the top left of the Emulator view
* Select 'import' to import one or more disk images as a set (.DSK, .2MG, .PO, .DO, .WOZ)
* Enter the desired disk set name
* A folder will be created in the library folder for the disk set containing the imported images
)md"};

const char *kDebuggerHelp[] = {R"md(
Expand Down

0 comments on commit df9760c

Please sign in to comment.