Skip to content
Merged
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,29 @@ jobs:
fail-fast: false

steps:
- name: Find the Right Data Branch
id: find_data
shell: bash {0}
env:
DATA_BRANCH: ${{ github.event.pull_request.head.ref }}
DATA_REMOTE_URL: ${{ github.event.pull_request.head.repo.owner.html_url }}/mm-data.git
DATA_REPO_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
run: |
if git ls-remote --exit-code --heads \
"$DATA_REMOTE_URL" "$DATA_BRANCH" > /dev/null 2>&1
then
printf 'dataRepo=%s/mm-data\n' "$DATA_REPO_OWNER" >> "$GITHUB_OUTPUT"
printf 'dataBranch=%s\n' "$DATA_BRANCH" >> "$GITHUB_OUTPUT"
else
printf 'dataRepo=MegaMek/mm-data\n' >> "$GITHUB_OUTPUT"
printf 'dataBranch=main\n' >> "$GITHUB_OUTPUT"
fi
Comment thread
pavelbraginskiy marked this conversation as resolved.

- name: Checkout Data Repo
uses: actions/checkout@v7
with:
repository: megamek/mm-data
repository: ${{ steps.find_data.outputs.dataRepo }}
ref: ${{ steps.find_data.outputs.dataBranch }}
path: mm-data

- name: Checkout out MekHQ
Expand Down
25 changes: 8 additions & 17 deletions MekHQ/src/mekhq/gui/dialog/MekHQUnitSelectorDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,12 @@ protected Entity refreshUnitView() {
* @param weightClassSelectorIndex The current weight class selection
* @param tech The current tech selection
* @param techLevelMatch whether the current tech selection matches
* @param checkSupportVee Whether the special 'Support Vehicle' unit type was selected
* @param unitTypeSelectorIndex Which unit type is currently selected (Depends on the combo box order!)
* @param unitTypeCode the selected unit-type code
*
* @return true if the unit passes all filters and allowed, false otherwise
*/
private boolean isAllowedUnit(MekSummary unitSummary, int weightClassSelectorIndex, ITechnology tech,
boolean techLevelMatch,
boolean checkSupportVee, int unitTypeSelectorIndex) {
boolean techLevelMatch, int unitTypeCode) {
if (enableYearLimits && (unitSummary.getYear() > allowedYear)) {
return false;
}
Expand All @@ -335,14 +333,8 @@ private boolean isAllowedUnit(MekSummary unitSummary, int weightClassSelectorInd
return false;
}

// Filter by unit type and support vehicles (if applicable)
if (unitTypeSelectorIndex != -1) {
String unitTypeName = checkSupportVee ? "Support Vehicle" : UnitType.getTypeName(unitTypeSelectorIndex);
boolean isCorrectType = unitSummary.getUnitType().equals(unitTypeName);
boolean isSupport = unitSummary.isSupport();
if ((!checkSupportVee && !isCorrectType) || (checkSupportVee && !isSupport)) {
return false;
}
if (!matchesUnitTypeSelection(unitSummary, unitTypeCode)) {
return false;
}

// if we have an advanced filter set, does it match that filter?
Expand Down Expand Up @@ -370,9 +362,9 @@ protected void filterUnits() {
techLevels.toArray(nTypes);

final int weightClassSelectorIndex = comboWeight.getSelectedIndex();
final int unitTypeSelectorIndex = comboUnitType.getSelectedIndex() - 1;
final boolean checkSupportVee = Messages.getString("MekSelectorDialog.SupportVee")
.equals(comboUnitType.getSelectedItem());
// Use the base class's gap-robust mapping (the shared combo omits AERO, so a positional
// selectedIndex - 1 would mismap types that follow it).
final int unitTypeCode = unitTypeCodeForComboIndex(comboUnitType.getSelectedIndex());
// If the current expression doesn't parse, don't update.
try {
unitTypeFilter = new RowFilter<>() {
Expand All @@ -393,8 +385,7 @@ public boolean include(Entry<? extends MekTableModel, ? extends Integer> entry)
weightClassSelectorIndex,
tech,
techLevelMatch,
checkSupportVee,
unitTypeSelectorIndex);
unitTypeCode);
}
};
} catch (PatternSyntaxException ignored) {
Expand Down
Loading