Skip to content

Commit

Permalink
Better order of welcome dialogs to endorse PaperVision
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Nov 21, 2024
1 parent 3e70359 commit 3b0c1d7
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ class EOCVSim(val params: Parameters = Parameters()) {

if(!config.flags.contains("hasShownIamA") || config.flags["hasShownIamA"] == false) {
DialogFactory.createIAmA(visualizer)
} else if(!config.flags.contains("hasShownIamPaperVision") || config.flags["hasShownIamPaperVision"] == false) {
DialogFactory.createIAmAPaperVision(visualizer, false) // in case the user missed the PaperVision dialog
} else if(config.flags["prefersPaperVision"] == true) {
// if the user prefers PaperVision, switch to it upon start up
val indexOfTab = visualizer.pipelineOpModeSwitchablePanel.indexOfTab("PaperVision")
if(indexOfTab >= 0) {
visualizer.pipelineOpModeSwitchablePanel.selectedIndex = indexOfTab
}
}

while (!eocvSimThread.isInterrupted && !destroying) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.github.serivesmejia.eocvsim.gui.dialog.*;
import com.github.serivesmejia.eocvsim.gui.dialog.SplashScreen;
import com.github.serivesmejia.eocvsim.gui.dialog.iama.IAmA;
import com.github.serivesmejia.eocvsim.gui.dialog.iama.IAmAPaperVision;
import com.github.serivesmejia.eocvsim.gui.dialog.source.CreateCameraSource;
import com.github.serivesmejia.eocvsim.gui.dialog.source.CreateImageSource;
import com.github.serivesmejia.eocvsim.gui.dialog.source.CreateSource;
Expand Down Expand Up @@ -166,6 +167,10 @@ public static void createIAmA(Visualizer visualizer) {
invokeLater(() -> new IAmA(visualizer.frame, visualizer));
}

public static void createIAmAPaperVision(Visualizer visualizer, boolean showWorkspacesButton) {
invokeLater(() -> new IAmAPaperVision(visualizer.frame, visualizer, false, showWorkspacesButton));
}

public static void createWorkspace(Visualizer visualizer) {
invokeLater(() -> new CreateWorkspace(visualizer.frame, visualizer));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PipelineSelectorButtonsPanel(eocvSim: EOCVSim) : JPanel(GridBagLayout()) {
val pipelineWorkspaceBtt = JButton("Workspace")

val workspaceButtonsPanel = JPanel(GridBagLayout())
val pipelineCompileBtt = JButton("Build java files")
val pipelineCompileBtt = JButton("Build Java Files")

private var lastWorkspacePopup: PopupX? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class Configuration {
public JPanel contents = new JPanel(new GridBagLayout());
public JComboBox<String> themeComboBox = new JComboBox<>();
public JCheckBox superAccessCheckBox = new JCheckBox("Auto Accept SuperAccess on Trusted Plugins");
public JCheckBox prefersPaperVisionCheckbox = new JCheckBox("Focus on PaperVision Upon Startup");

public JButton acceptButton = new JButton("Accept");

Expand Down Expand Up @@ -82,7 +83,7 @@ private void initConfiguration() {
UI TAB
*/

JPanel uiPanel = new JPanel(new GridLayout(2, 1, 1, 8));
JPanel uiPanel = new JPanel(new GridLayout(3, 1, 1, 8));

/* THEME SETTING */
JPanel themePanel = new JPanel(new FlowLayout());
Expand All @@ -104,11 +105,17 @@ private void initConfiguration() {
JPanel superAccessPanel = new JPanel(new FlowLayout());

superAccessCheckBox.setSelected(config.autoAcceptSuperAccessOnTrusted);

superAccessPanel.add(superAccessCheckBox);

uiPanel.add(superAccessPanel);

/* FOCUS ON PAPERVISION UPON STARTUP */

JPanel prefersPaperVisionPanel = new JPanel(new FlowLayout());

prefersPaperVisionCheckbox.setSelected(config.flags.get("prefersPaperVision"));
prefersPaperVisionPanel.add(prefersPaperVisionCheckbox);
uiPanel.add(prefersPaperVisionPanel);

tabbedPane.addTab("Interface", uiPanel);

/*
Expand Down Expand Up @@ -226,6 +233,8 @@ private void applyChanges() {
config.videoRecordingFps = videoRecordingFpsComboBox.getSelectedEnum();
config.autoAcceptSuperAccessOnTrusted = superAccessCheckBox.isSelected();

config.flags.put("prefersPaperVision", prefersPaperVisionCheckbox.isSelected());

eocvSim.configManager.saveToFile(); //update config file

if (userSelectedTheme != beforeTheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class IAmA(

dialog.defaultCloseOperation = JDialog.DISPOSE_ON_CLOSE
dialog.setLocationRelativeTo(null)

visualizer.eocvSim.config.flags["hasShownIamA"] = true
dialog.isVisible = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import javax.swing.JButton
import javax.swing.JDialog
import javax.swing.JFrame
import javax.swing.JLabel
import javax.swing.JOptionPane
import javax.swing.JPanel
import javax.swing.SwingConstants

class IAmAPaperVision(
parent: JFrame,
visualizer: Visualizer,
specificallyInterested: Boolean = false
specificallyInterested: Boolean = false,
showWorkspacesButton: Boolean = true
) {

companion object {
Expand Down Expand Up @@ -89,7 +91,7 @@ class IAmAPaperVision(

add(Box.createHorizontalStrut(10)) // Add some space between the buttons

if(!specificallyInterested) {
if(!specificallyInterested && showWorkspacesButton) {
add(JButton("Use Workspaces Instead").apply {
addActionListener {
dialog.dispose() // Close the dialog on click
Expand All @@ -103,7 +105,45 @@ class IAmAPaperVision(
add(JButton("Use PaperVision").apply {
addActionListener {
dialog.dispose() // Close the dialog on click
visualizer.pipelineOpModeSwitchablePanel.selectedIndex = visualizer.pipelineOpModeSwitchablePanel.indexOfTab("PaperVision")

// if the user prefers PaperVision, switch to it upon start up
val indexOfTab = visualizer.pipelineOpModeSwitchablePanel.indexOfTab("PaperVision")
if(indexOfTab >= 0) {
visualizer.pipelineOpModeSwitchablePanel.selectedIndex = indexOfTab
}

fun openPaperVisionByDefault() {
visualizer.eocvSim.config.flags["prefersPaperVision"] = true

JOptionPane.showConfirmDialog(
parent,
"From now on, EOCV-Sim will focus on PaperVision upon startup.\nYou can change this in the settings.",
"PaperVision",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE
)
}

if(specificallyInterested) {
openPaperVisionByDefault()
} else {
JOptionPane.showOptionDialog(
parent,
"Would you like to focus on PaperVision by default?\nThis is useful if you're not interested on the other pipeline development tools.",
"PaperVision",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
arrayOf("Yes", "No"),
"No"
).let {
if(it == JOptionPane.YES_OPTION) {
openPaperVisionByDefault()
} else {
visualizer.eocvSim.config.flags["prefersPaperVision"] = false
}
}
}
}
})

Expand All @@ -113,8 +153,8 @@ class IAmAPaperVision(
buttonsPanel.alignmentX = JPanel.CENTER_ALIGNMENT // Align the panel in the BoxLayout
dialog.contentPane.add(buttonsPanel)

visualizer.eocvSim.config.flags["hasShownIamA"] = true

visualizer.eocvSim.config.flags["hasShownIamPaperVision"] = true
dialog.isVisible = true
}

Expand Down

0 comments on commit 3b0c1d7

Please sign in to comment.