|
|
@@ -5,25 +5,12 @@ import javax.swing.JPanel;
|
|
|
import lombok.AccessLevel;
|
|
|
import lombok.experimental.FieldDefaults;
|
|
|
import java.awt.GridBagLayout;
|
|
|
-import javax.swing.JScrollPane;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
-import java.awt.Insets;
|
|
|
|
|
|
-import org.jdesktop.swingx.VerticalLayout;
|
|
|
import org.leumasjaffe.charsheet.model.DDCharacter;
|
|
|
-import org.leumasjaffe.charsheet.model.equip.DDInventory;
|
|
|
-import org.leumasjaffe.charsheet.model.equip.DDItem;
|
|
|
-import org.leumasjaffe.charsheet.model.equip.EquipmentSlot;
|
|
|
-import org.leumasjaffe.charsheet.view.inventory.ArmorPanel;
|
|
|
-import org.leumasjaffe.charsheet.view.inventory.ItemPanel;
|
|
|
-import org.leumasjaffe.charsheet.view.inventory.ShieldPanel;
|
|
|
-import org.leumasjaffe.charsheet.view.inventory.WeaponPanel;
|
|
|
+import org.leumasjaffe.charsheet.view.inventory.EquipmentPanel;
|
|
|
+import org.leumasjaffe.charsheet.view.inventory.InventoryPanel;
|
|
|
|
|
|
-import java.awt.Color;
|
|
|
-import javax.swing.JLabel;
|
|
|
-import javax.swing.SwingConstants;
|
|
|
-import java.awt.Font;
|
|
|
-import javax.swing.border.MatteBorder;
|
|
|
import java.awt.Dimension;
|
|
|
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
@@ -32,8 +19,8 @@ public class EquipmentTab extends JPanel {
|
|
|
*
|
|
|
*/
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
- private JPanel equipment;
|
|
|
- private JPanel inventory;
|
|
|
+ private EquipmentPanel equipment;
|
|
|
+ private InventoryPanel inventory;
|
|
|
|
|
|
public EquipmentTab() {
|
|
|
setPreferredSize(new Dimension(600, 300));
|
|
|
@@ -45,77 +32,24 @@ public class EquipmentTab extends JPanel {
|
|
|
gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
|
setLayout(gridBagLayout);
|
|
|
|
|
|
- JScrollPane scrollPane = new JScrollPane();
|
|
|
- scrollPane.setOpaque(false);
|
|
|
- GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
|
- gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
|
|
|
- gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
|
- gbc_scrollPane.gridx = 0;
|
|
|
- gbc_scrollPane.gridy = 0;
|
|
|
- add(scrollPane, gbc_scrollPane);
|
|
|
-
|
|
|
- equipment = new JPanel();
|
|
|
- equipment.setBackground(Color.WHITE);
|
|
|
- scrollPane.setViewportView(equipment);
|
|
|
- equipment.setLayout(new VerticalLayout(5));
|
|
|
-
|
|
|
- JScrollPane scrollPane_1 = new JScrollPane();
|
|
|
- scrollPane_1.setOpaque(false);
|
|
|
- GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints();
|
|
|
- gbc_scrollPane_1.fill = GridBagConstraints.BOTH;
|
|
|
- gbc_scrollPane_1.gridx = 1;
|
|
|
- gbc_scrollPane_1.gridy = 0;
|
|
|
- add(scrollPane_1, gbc_scrollPane_1);
|
|
|
-
|
|
|
- inventory = new JPanel();
|
|
|
- inventory.setBackground(Color.WHITE);
|
|
|
- scrollPane_1.setViewportView(inventory);
|
|
|
- inventory.setLayout(new VerticalLayout(5));
|
|
|
-
|
|
|
- JLabel lblEquipment = new JLabel("Equipment");
|
|
|
- lblEquipment.setBorder(new MatteBorder(0, 0, 1, 0, (Color) Color.WHITE));
|
|
|
- lblEquipment.setFont(new Font("Tahoma", Font.BOLD, 20));
|
|
|
- lblEquipment.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- lblEquipment.setBackground(Color.BLACK);
|
|
|
- lblEquipment.setOpaque(true);
|
|
|
- lblEquipment.setForeground(Color.WHITE);
|
|
|
- scrollPane.setColumnHeaderView(lblEquipment);
|
|
|
-
|
|
|
- JLabel lblInventory = new JLabel("Inventory");
|
|
|
- lblInventory.setBorder(new MatteBorder(0, 0, 1, 0, (Color) Color.WHITE));
|
|
|
- lblInventory.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- lblInventory.setBackground(Color.BLACK);
|
|
|
- lblInventory.setOpaque(true);
|
|
|
- lblInventory.setForeground(Color.WHITE);
|
|
|
- lblInventory.setFont(new Font("Tahoma", Font.BOLD, 20));
|
|
|
- scrollPane_1.setColumnHeaderView(lblInventory);
|
|
|
+ equipment = new EquipmentPanel();
|
|
|
+ GridBagConstraints gbc_equipment = new GridBagConstraints();
|
|
|
+ gbc_equipment.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_equipment.gridx = 0;
|
|
|
+ gbc_equipment.gridy = 0;
|
|
|
+ add(equipment, gbc_equipment);
|
|
|
+
|
|
|
+ inventory = new InventoryPanel();
|
|
|
+ GridBagConstraints gbc_inventory = new GridBagConstraints();
|
|
|
+ gbc_inventory.fill = GridBagConstraints.BOTH;
|
|
|
+ gbc_inventory.gridx = 1;
|
|
|
+ gbc_inventory.gridy = 0;
|
|
|
+ add(inventory, gbc_inventory);
|
|
|
}
|
|
|
|
|
|
public void setModel(DDCharacter model) {
|
|
|
- equipment.removeAll();
|
|
|
- inventory.removeAll();
|
|
|
-
|
|
|
- final DDInventory inv = model.getInventory();
|
|
|
- for ( final DDItem item : inv.getItems() ) {
|
|
|
- inventory.add(new ItemPanel(item));
|
|
|
- }
|
|
|
-
|
|
|
- final DDItem armor = inv.getEquipment().get(EquipmentSlot.BODY);
|
|
|
- if ( armor != null ) {
|
|
|
- equipment.add(new ArmorPanel(armor));
|
|
|
- }
|
|
|
-
|
|
|
- final DDItem main = inv.getEquipment().get(EquipmentSlot.MAIN_HAND);
|
|
|
- final DDItem off = inv.getEquipment().get(EquipmentSlot.OFF_HAND);
|
|
|
- if ( off != null && off.isArmor() ) {
|
|
|
- equipment.add(new ShieldPanel(off));
|
|
|
- }
|
|
|
- if ( main != null ) {
|
|
|
- equipment.add(new WeaponPanel(main));
|
|
|
- }
|
|
|
- if ( off != null && ( off != main || ( off.getSlot() == EquipmentSlot.ONE_HAND && off.getCount().value() > 1 ) ) ) {
|
|
|
- equipment.add(new WeaponPanel(off));
|
|
|
- }
|
|
|
+ equipment.setModel(model);
|
|
|
+ inventory.setModel(model);
|
|
|
}
|
|
|
|
|
|
}
|