Skip to content

Commit

Permalink
Merge pull request #4106 from AaronGullickson/tab-scenario-dialog
Browse files Browse the repository at this point in the history
Use tabs in customize scenario dialog
  • Loading branch information
HammerGS authored May 25, 2024
2 parents 6c0cc03 + a903277 commit 480149d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
panTab.basic=Basic Information
panTab.rewards=Objectives and Rewards
panTab.otherforces=Other Forces
btnCancel.text=Cancel
btnOkay.text=Done
lblName.text=<html><b><nobr>Scenario Name:</nobr></b></html>
Expand Down
59 changes: 23 additions & 36 deletions MekHQ/src/mekhq/gui/dialog/CustomizeScenarioDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ private void initComponents() {
setTitle(resourceMap.getString("title"));
}

JPanel panMain = new JPanel(new GridBagLayout());
JTabbedPane panTabs = new JTabbedPane();

JPanel panBasic = new JPanel(new GridBagLayout());
JPanel panRewards = new JPanel(new GridLayout(2, 0));

JPanel panInfo = new JPanel(new GridBagLayout());
JPanel panWrite = new JPanel(new GridBagLayout());
JPanel panBtn = new JPanel(new FlowLayout());
Expand All @@ -215,7 +219,7 @@ private void initComponents() {
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(5, 5, 5, 5);
panInfo.add(new JLabel(resourceMap.getString("lblName.text")), gbc);

Expand Down Expand Up @@ -314,6 +318,7 @@ public Component getListCellRendererComponent(final JList<?> list, final Object

initMapPanel(resourceMap);
gbc.gridy++;
gbc.weighty = 1.0;
panInfo.add(panMap, gbc);

initObjectivesPanel(resourceMap);
Expand All @@ -331,11 +336,8 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
BorderFactory.createEmptyBorder(5,5,5,5)));

initOtherForcesPanel(resourceMap);
panOtherForces.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0, 0, 10, 0),
BorderFactory.createTitledBorder(resourceMap.getString("panOtherForces.title"))));
panOtherForces.setPreferredSize(new Dimension(600,250));
panOtherForces.setMinimumSize(new Dimension(600,250));
panOtherForces.setPreferredSize(new Dimension(600,300));
panOtherForces.setMinimumSize(new Dimension(600,300));

txtDesc = new MarkdownEditorPanel(resourceMap.getString("txtDesc.title"));
txtDesc.setText(scenario.getDescription());
Expand Down Expand Up @@ -396,43 +398,28 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
btnClose.addActionListener(this::btnCloseActionPerformed);
panBtn.add(btnClose);

getContentPane().add(panMain, BorderLayout.CENTER);
getContentPane().add(panBtn, BorderLayout.PAGE_END);

JPanel panNW = new JPanel(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridheight = 2;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weightx = 0.0;
gbc.weighty = 1.0;
panNW.add(panInfo, gbc);
gbc.gridx = 1;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.BOTH;
panNW.add(panObjectives, gbc);
gbc.gridy = 1;
panNW.add(panLoot, gbc);

gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.fill = GridBagConstraints.BOTH;
panMain.add(panNW, gbc);
panBasic.add(panInfo, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridheight = 2;
gbc.weighty = 1.0;
panMain.add(panWrite, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridheight = 1;
panMain.add(panOtherForces, gbc);
gbc.weightx = 1.0;
panBasic.add(panWrite, gbc);

panRewards.add(panObjectives);
panRewards.add(panLoot);

panTabs.add(resourceMap.getString("panTab.basic"), panBasic);
panTabs.add(resourceMap.getString("panTab.rewards"), panRewards);
panTabs.add(resourceMap.getString("panTab.otherforces"), panOtherForces);

getContentPane().add(panTabs, BorderLayout.CENTER);
getContentPane().add(panBtn, BorderLayout.PAGE_END);

pack();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private void initObjectiveEffectPanel(ResourceBundle resourceMap) {
panObjectiveEffect.add(btnAdd, gbcLeft);

JLabel lblSuccessEffects = new JLabel(resourceMap.getString("lblSuccessEffects.text"));
JLabel lblFailureEffects = new JLabel(resourceMap.getString("lblSuccessEffects.text"));
JLabel lblFailureEffects = new JLabel(resourceMap.getString("lblFailureEffects.text"));

successEffects = new JList<>(successEffectsModel);
successEffects.addListSelectionListener(e -> btnRemoveSuccess.setEnabled(!successEffects.getSelectedValuesList().isEmpty()));
Expand Down

0 comments on commit 480149d

Please sign in to comment.