Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select Unit screen update #234

Merged
merged 4 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BFB/src/main/java/BFB/GUI/dlgQuickAdd.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import list.view.*;

public class dlgQuickAdd extends javax.swing.JDialog {

private frmBase parent;
private Force force;
private UnitList list, filtered = new UnitList();
Expand Down Expand Up @@ -39,7 +39,7 @@ public dlgQuickAdd(java.awt.Frame parent, boolean modal, Force force) {
cmbPiloting.setSelectedIndex(5);

list = new UnitList(this.parent.Prefs.get("ListPath", ""), true);
viewModel = new tbTotalWarfareCompact(list);
viewModel = new tbTotalWarfareCompact();
tblList.setModel(new DefaultTableModel());
//setupList(list);
}
Expand All @@ -56,7 +56,7 @@ private void Filter(java.awt.event.ActionEvent evt) {
}

private void setupList(UnitList mechList) {
viewModel.list = mechList;
viewModel.setList(mechList);
viewModel.setupTable(tblList);
}

Expand Down
28 changes: 14 additions & 14 deletions BFB/src/main/java/BFB/GUI/frmBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public class frmBase extends javax.swing.JFrame implements java.awt.datatransfer
private Media media = new Media();
private ImageTracker images = new ImageTracker();
private Force addToForce = new Force();

private UnitList list = new UnitList(), filtered, chosen = new UnitList();
private abView currentView = new tbTotalWarfareView(list);
private abView currentView = new tbTotalWarfareView();
private String MechListPath = "", BaseRUSPath = "./Data/Tables/", RUSDirectory = "", RUSPath = BaseRUSPath, CurrentFile = "";
private RUS rus = new RUS();

Expand Down Expand Up @@ -124,7 +124,7 @@ public frmBase() {
initComponents();
Prefs = Preferences.userRoot().node( Constants.BFBPrefs );
MechListPath = Prefs.get("ListPath", "");

popUtilities.add(popGroup);
popUtilities.add(popSkill);
popUtilities.add(popName);
Expand All @@ -149,7 +149,7 @@ public frmBase() {
edtSpecialRules.addKeyListener(KeyTyped);
edtVictoryConditions.addKeyListener(KeyTyped);
edtAftermath.addKeyListener(KeyTyped);

Refresh();
lblStatusUpdate.setText("");
LoadRUSOptions();
Expand All @@ -174,7 +174,7 @@ public void Refresh() {
} else {
btnISTop.setSelected(true);
}

if ( scenario.getDefenderForce().getType().equals(BattleForce.Comstar) ) {
btnCSBottom.setSelected(true);
} else if ( scenario.getDefenderForce().getType().equals(BattleForce.Clan) ) {
Expand All @@ -184,7 +184,7 @@ public void Refresh() {
}

lblForceMod.setText( String.format( "%1$,.2f", CommonTools.GetForceSizeMultiplier( scenario.getAttackerForce().getUnits().size(), scenario.getDefenderForce().getUnits().size() )) );

updateFields();
}

Expand Down Expand Up @@ -317,7 +317,7 @@ private void updateFields() {

private void loadScenario( String filename ) {
if ( filename.isEmpty() ) { return; }

BFBReader reader = new BFBReader();
//Force[] forces;
try {
Expand Down Expand Up @@ -3429,7 +3429,7 @@ private void mnuLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
System.out.println(e.getMessage());
return;
}

DefaultCursor();
}
}//GEN-LAST:event_mnuLoadActionPerformed
Expand Down Expand Up @@ -3537,7 +3537,7 @@ private void mnuSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST

XMLWriter writer = new XMLWriter();
writer.WriteScenario(scenario, filename);

Prefs.put("LastOpenBFBFile", filename);
//Prefs.put("CurrentBFBFile", filename);
CurrentFile = filename;
Expand Down Expand Up @@ -3626,7 +3626,7 @@ private void btnMULExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
MULWriter mw = new MULWriter();
String dir = "";
dir = media.GetDirectorySelection(this, Prefs.get("MULDirectory", ""));
if ( dir.isEmpty() ) {
if ( dir.isEmpty() ) {
DefaultCursor();
return;
}
Expand Down Expand Up @@ -3941,11 +3941,11 @@ private void mnuBVListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
//Media.Messager("This will output a csv list of mechs and also a list of EVERY SINGLE Mech's cost and BV2 calculation!");
WaitCursor();
if ( list == null ) { LoadList(true); }

TXTWriter out = new TXTWriter();
String dir = "";
dir = media.GetDirectorySelection(this, Prefs.get("ListDirectory", ""));
if ( dir.isEmpty() ) {
if ( dir.isEmpty() ) {
DefaultCursor();
return;
}
Expand Down Expand Up @@ -4197,7 +4197,7 @@ private void btnAddGeneric1ActionPerformed(java.awt.event.ActionEvent evt) {//GE
dlgGen.setLocationRelativeTo(this);
dlgGen.setVisible(true);
}//GEN-LAST:event_btnAddGeneric1ActionPerformed

private void setTooltip(UnitListData data) {
spnMechTable.setToolTipText(data.getInfo());
txtInfo.setText(data.getInfo());
Expand Down Expand Up @@ -4272,7 +4272,7 @@ private void btnFilterFilter(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_
}//GEN-LAST:event_btnFilterFilter

private void setupList(UnitList mechList, boolean forceSort) {
currentView.list = mechList;
currentView.setList(mechList);
tblMechData.setModel(currentView);
currentView.setupTable(tblMechData);

Expand Down
30 changes: 17 additions & 13 deletions saw/src/main/java/saw/gui/dlgOpen.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public class dlgOpen extends javax.swing.JFrame implements PropertyChangeListene
private String dirPath = "";
private String NL = "";
private String msg = "";
private abView currentView = new tbTotalWarfareView(list);
private abView twView = new tbTotalWarfareView();
private abView bfView = new tbBattleForceView();
private abView compView = new tbTotalWarfareCompact();
private abView chatView = new tbChatInformation();
private abView currentView = twView;
private boolean cancelledListDirSelection = false;

public int Requestor = SSW;
Expand All @@ -66,15 +70,15 @@ public dlgOpen(java.awt.Frame parent, boolean modal) {
//ImageIcon icon = new ImageIcon(super.getClass().getResource("/ssw/Images/appicon.png"));
//super.setIconImage(icon.getImage());
this.parent = (common.DesignForm) parent;

prgResaving.setVisible(false);
cmbTech.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Tech", "Clan", "Inner Sphere", "Mixed" }));
cmbEra.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Era", "Age of War/Star League", "Succession Wars", "Clan Invasion", "Dark Ages", "All Eras (non-canon)" }));
cmbRulesLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Level", "Introductory", "Tournament Legal", "Advanced Rules", "Experimental Tech", "Era Specific" }));
cmbMotive.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Motive", "Hovercraft", "Naval (Displacement)", "Naval (Hydrofoil)", "Naval (Submarine)", "Tracked", "VTOL", "Wheeled", "WiGE" }));
NL = System.getProperty( "line.separator" );
}

private void LoadMech() {
switch ( Requestor ) {
case SSW:
Expand Down Expand Up @@ -141,7 +145,7 @@ public void LoadList(boolean useIndex) {
this.lblStatus.setText("Loading Units...");
this.txtSelected.setText("0 Units Selected for 0 BV and 0 C-Bills");
this.tblMechData.setModel(new UnitList());

if (dirPath.isEmpty()) {
dirPath = parent.GetPrefs().get("ListPath", parent.GetPrefs().get( "LastOpenCVDirectory", "" ) );

Expand All @@ -165,7 +169,7 @@ public void LoadList(boolean useIndex) {
}

this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

list = new UnitList(dirPath, useIndex);

if (list.Size() > 0) {
Expand Down Expand Up @@ -242,7 +246,7 @@ private void setTooltip( UnitListData data ) {
//do nothing
}
}

public void propertyChange( PropertyChangeEvent e ) {
prgResaving.setValue( ((Resaver) e.getSource()).getProgress() );
}
Expand Down Expand Up @@ -1226,7 +1230,7 @@ private void txtMaxCostFilter(java.awt.event.ActionEvent evt) {//GEN-FIRST:event

private void btnClearFilterFilter(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearFilterFilter
setupList(list, false);

//clear the dropdowns
cmbEra.setSelectedIndex(0);
cmbMotive.setSelectedIndex(0);
Expand Down Expand Up @@ -1350,7 +1354,7 @@ private void tblMechDataKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:ev

private void btnViewForceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewForceActionPerformed
lblForce.setText("");

//if ( tblMechData.getSelectedRowCount() > 0 ) {
// btnAdd2ForceActionPerformed(evt);
//}
Expand All @@ -1369,19 +1373,19 @@ private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:
private void cmbViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbViewActionPerformed
switch ( cmbView.getSelectedIndex() ) {
case 0:
currentView = new tbTotalWarfareView(list);
currentView = twView.setList(list);
break;
case 1:
currentView = new tbTotalWarfareCompact(list);
currentView = compView.setList(list);
break;
case 2:
currentView = new tbBattleForceView(list);
currentView = bfView.setList(list);
break;
case 3:
currentView = new tbChatInformation(list);
currentView = chatView.setList(list);
break;
default:
currentView = new tbTotalWarfareView(list);
currentView = twView.setList(list);
}
tblMechData.setModel(currentView);
currentView.setupTable(tblMechData);
Expand Down
30 changes: 17 additions & 13 deletions ssw/src/main/java/ssw/gui/dlgOpen.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public class dlgOpen extends javax.swing.JFrame implements PropertyChangeListene
private String dirPath = "";
private String NL = "";
private String msg = "";
private abView currentView = new tbTotalWarfareView(list);
private abView twView = new tbTotalWarfareView();
private abView bfView = new tbBattleForceView();
private abView compView = new tbTotalWarfareCompact();
private abView chatView = new tbChatInformation();
private abView currentView = twView;
private boolean cancelledListDirSelection = false;

public int Requestor = SSW;
Expand All @@ -63,7 +67,7 @@ public dlgOpen(java.awt.Frame parent, boolean modal) {
ImageIcon icon = new ImageIcon(super.getClass().getResource("/ssw/Images/appicon.png"));
super.setIconImage(icon.getImage());
this.parent = (ifMechForm) parent;

prgResaving.setVisible(false);
cmbTech.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Tech", "Clan", "Inner Sphere", "Mixed" }));
cmbEra.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Era", "Age of War/Star League", "Succession Wars", "Clan Invasion", "Dark Ages", "All Eras (non-canon)" }));
Expand All @@ -72,7 +76,7 @@ public dlgOpen(java.awt.Frame parent, boolean modal) {
cmbMotive.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any Motive", "Biped", "Quad" }));
NL = System.getProperty( "line.separator" );
}

private void LoadMech() {
switch ( Requestor ) {
case SSW:
Expand Down Expand Up @@ -139,7 +143,7 @@ public void LoadList(boolean useIndex) {
this.lblStatus.setText("Loading Mechs...");
this.txtSelected.setText("0 Units Selected for 0 BV and 0 C-Bills");
this.tblMechData.setModel(new UnitList());

if (dirPath.isEmpty()) {
dirPath = parent.GetPrefs().get("ListPath", parent.GetPrefs().get( "LastOpenDirectory", "" ) );

Expand All @@ -163,7 +167,7 @@ public void LoadList(boolean useIndex) {
}

this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

list = new UnitList(dirPath, useIndex);

if (list.Size() > 0) {
Expand Down Expand Up @@ -239,7 +243,7 @@ private void setTooltip( UnitListData data ) {
//do nothing
}
}

public void propertyChange( PropertyChangeEvent e ) {
prgResaving.setValue( ((Resaver) e.getSource()).getProgress() );
}
Expand Down Expand Up @@ -1254,7 +1258,7 @@ private void txtMaxCostFilter(java.awt.event.ActionEvent evt) {//GEN-FIRST:event

private void btnClearFilterFilter(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearFilterFilter
setupList(list, false);

//clear the dropdowns
cmbEra.setSelectedIndex(0);
cmbMotive.setSelectedIndex(0);
Expand Down Expand Up @@ -1383,7 +1387,7 @@ private void tblMechDataKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:ev

private void btnViewForceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewForceActionPerformed
lblForce.setText("");

//if ( tblMechData.getSelectedRowCount() > 0 ) {
// btnAdd2ForceActionPerformed(evt);
//}
Expand All @@ -1402,19 +1406,19 @@ private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:
private void cmbViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbViewActionPerformed
switch ( cmbView.getSelectedIndex() ) {
case 0:
currentView = new tbTotalWarfareView(list);
currentView = twView.setList(list);
break;
case 1:
currentView = new tbTotalWarfareCompact(list);
currentView = compView.setList(list);
break;
case 2:
currentView = new tbBattleForceView(list);
currentView = bfView.setList(list);
break;
case 3:
currentView = new tbChatInformation(list);
currentView = chatView.setList(list);
break;
default:
currentView = new tbTotalWarfareView(list);
currentView = twView.setList(list);
}
tblMechData.setModel(currentView);
currentView.setupTable(tblMechData);
Expand Down
4 changes: 3 additions & 1 deletion sswlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ plugins {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
}

dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.apache.commons:commons-csv:1.8'

testCompile group: 'junit', name: 'junit', version: '4.12'
}

Expand Down
Loading