GUI: draft panel - added set code to booster names, improved text fonts and drawing;

This commit is contained in:
Oleg Agafonov 2023-12-15 16:01:09 +04:00
parent c10ed215ab
commit d03ebad794
2 changed files with 36 additions and 13 deletions

View file

@ -184,13 +184,16 @@
<Component class="javax.swing.JTextField" name="editPack1"> <Component class="javax.swing.JTextField" name="editPack1">
<Properties> <Properties>
<Property name="editable" type="boolean" value="false"/> <Property name="editable" type="boolean" value="false"/>
<Property name="enabled" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 22]"/> <Dimension value="[130, 22]"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="checkPack1"> <Component class="javax.swing.JCheckBox" name="checkPack1">
<Properties>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
@ -206,13 +209,16 @@
<Component class="javax.swing.JTextField" name="editPack2"> <Component class="javax.swing.JTextField" name="editPack2">
<Properties> <Properties>
<Property name="editable" type="boolean" value="false"/> <Property name="editable" type="boolean" value="false"/>
<Property name="enabled" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 22]"/> <Dimension value="[130, 22]"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="checkPack2"> <Component class="javax.swing.JCheckBox" name="checkPack2">
<Properties>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
@ -228,13 +234,16 @@
<Component class="javax.swing.JTextField" name="editPack3"> <Component class="javax.swing.JTextField" name="editPack3">
<Properties> <Properties>
<Property name="editable" type="boolean" value="false"/> <Property name="editable" type="boolean" value="false"/>
<Property name="enabled" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[130, 22]"/> <Dimension value="[130, 22]"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="checkPack3"> <Component class="javax.swing.JCheckBox" name="checkPack3">
<Properties>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

View file

@ -112,6 +112,7 @@
.map(c -> (JLabel) c) .map(c -> (JLabel) c)
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
hideUnusedPlayerNames(true); // hide default list
draftBooster.setOpaque(false); draftBooster.setOpaque(false);
draftPicks.setSortSetting(SortSettingDraft.getInstance()); draftPicks.setSortSetting(SortSettingDraft.getInstance());
@ -190,14 +191,20 @@
this.editPack2.setText("Random Boosters"); this.editPack2.setText("Random Boosters");
this.editPack3.setText("Random Boosters"); this.editPack3.setText("Random Boosters");
} else { } else {
this.editPack1.setText(draftView.getSets().get(0)); this.editPack1.setText(String.format("%s - %s", draftView.getSetCodes().get(0), draftView.getSets().get(0)));
this.editPack2.setText(draftView.getSets().get(1)); this.editPack2.setText(String.format("%s - %s", draftView.getSetCodes().get(1), draftView.getSets().get(1)));
this.editPack3.setText(draftView.getSets().get(2)); this.editPack3.setText(String.format("%s - %s", draftView.getSetCodes().get(2), draftView.getSets().get(2)));
} }
// scroll too long text to the start
this.editPack1.setCaretPosition(0);
this.editPack2.setCaretPosition(0);
this.editPack3.setCaretPosition(0);
this.checkPack1.setSelected(draftView.getBoosterNum() > 1); this.checkPack1.setSelected(draftView.getBoosterNum() > 1);
this.checkPack2.setSelected(draftView.getBoosterNum() > 2); this.checkPack2.setSelected(draftView.getBoosterNum() > 2);
this.checkPack3.setSelected(draftView.getBoosterNum() > 3); this.checkPack3.setSelected(draftView.getBoosterNum() > 3);
this.labelCardNumber.setText("Card #" + Integer.toString(draftView.getCardNum())); this.labelCardNumber.setText("Card #" + draftView.getCardNum());
packNo = draftView.getBoosterNum(); packNo = draftView.getBoosterNum();
pickNo = draftView.getCardNum(); pickNo = draftView.getCardNum();
@ -215,7 +222,8 @@
count++; count++;
setPlayerNameToLabel(playerName, count, draftView.getPlayers().size()); setPlayerNameToLabel(playerName, count, draftView.getPlayers().size());
} }
hideUnusedPlayerNames(); hideUnusedPlayerNames(false);
this.revalidate();
// TODO: auto-resize for players list doesn't work with layouts, wtf // TODO: auto-resize for players list doesn't work with layouts, wtf
int rightAmount = draftView.getPlayers().size() / 2; int rightAmount = draftView.getPlayers().size() / 2;
@ -233,12 +241,12 @@
}); });
} }
private void hideUnusedPlayerNames() { private void hideUnusedPlayerNames(boolean hideAll) {
int maxPlayersPerPanel = 8; int maxPlayersPerPanel = 8;
playerLabels.forEach((panel, labels) -> { playerLabels.forEach((panel, labels) -> {
AtomicInteger hiddenCount = new AtomicInteger(0); AtomicInteger hiddenCount = new AtomicInteger(0);
labels.forEach(label -> { labels.forEach(label -> {
if (label.getText().isEmpty()) { if (hideAll || label.getText().isEmpty()) {
hiddenCount.incrementAndGet(); hiddenCount.incrementAndGet();
panel.remove(label); panel.remove(label);
} else { } else {
@ -674,9 +682,11 @@
panelPack1.add(labelPack1); panelPack1.add(labelPack1);
editPack1.setEditable(false); editPack1.setEditable(false);
editPack1.setEnabled(false); editPack1.setFocusable(false);
editPack1.setPreferredSize(new java.awt.Dimension(130, 22)); editPack1.setPreferredSize(new java.awt.Dimension(130, 22));
panelPack1.add(editPack1); panelPack1.add(editPack1);
checkPack1.setEnabled(false);
panelPack1.add(checkPack1); panelPack1.add(checkPack1);
panelPack2.setLayout(new javax.swing.BoxLayout(panelPack2, javax.swing.BoxLayout.LINE_AXIS)); panelPack2.setLayout(new javax.swing.BoxLayout(panelPack2, javax.swing.BoxLayout.LINE_AXIS));
@ -685,9 +695,11 @@
panelPack2.add(labelPack2); panelPack2.add(labelPack2);
editPack2.setEditable(false); editPack2.setEditable(false);
editPack2.setEnabled(false); editPack2.setFocusable(false);
editPack2.setPreferredSize(new java.awt.Dimension(130, 22)); editPack2.setPreferredSize(new java.awt.Dimension(130, 22));
panelPack2.add(editPack2); panelPack2.add(editPack2);
checkPack2.setEnabled(false);
panelPack2.add(checkPack2); panelPack2.add(checkPack2);
panelPack3.setLayout(new javax.swing.BoxLayout(panelPack3, javax.swing.BoxLayout.LINE_AXIS)); panelPack3.setLayout(new javax.swing.BoxLayout(panelPack3, javax.swing.BoxLayout.LINE_AXIS));
@ -696,9 +708,11 @@
panelPack3.add(labelPack3); panelPack3.add(labelPack3);
editPack3.setEditable(false); editPack3.setEditable(false);
editPack3.setEnabled(false); editPack3.setFocusable(false);
editPack3.setPreferredSize(new java.awt.Dimension(130, 22)); editPack3.setPreferredSize(new java.awt.Dimension(130, 22));
panelPack3.add(editPack3); panelPack3.add(editPack3);
checkPack3.setEnabled(false);
panelPack3.add(checkPack3); panelPack3.add(checkPack3);
panelPackCard.setLayout(new java.awt.BorderLayout()); panelPackCard.setLayout(new java.awt.BorderLayout());