Skip to content

Commit

Permalink
Merge pull request #3931 from AaronGullickson/update-scenario-dialog
Browse files Browse the repository at this point in the history
Add new Scenario features to CustomizeScenarioDialog
  • Loading branch information
HammerGS authored May 13, 2024
2 parents 9bdf79f + a5030a1 commit 47c5762
Show file tree
Hide file tree
Showing 26 changed files with 4,030 additions and 236 deletions.
45 changes: 45 additions & 0 deletions MekHQ/resources/mekhq/resources/CustomizeBotForceDialog.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
title=Customize BotForce
lblName.text=Name:
lblTeam.text=Team:
panBehavior.title=Behavior
panRandomUnits.title=Random Units
scrollFixedUnits.title=Fixed Units
choiceTeam.text=Team
choiceAllied.text=Allied
lblCowardice.text=Cowardice:
lblSelfPreservation.text=Self-Preservation:
lblAggression.text=Aggression:
lblHerdMentality.text=Herd Mentality:
lblPilotingRisk.text=Piloting Risk:
lblForcedWithdrawal.text=Forced Withdrawal:
lblAutoFlee.text=Auto Flee:
lblBalancingMethod.text=Balancing Method:
lblBalancingMethod.tooltip=<html>What characteristic to balance force multiplier on<br>(e.g. BV, weight)</html>
lblFaction.text=Faction:
lblFaction.tooltip=<html>Faction for selecting units</html>
lblUnitType.text=Unit Type:
lblUnitType.tooltip=<html>Which unit type to generate. For mixed unit types<br>use different forces on the same team or use percent<br>conventional and/or integrated BA chance.</html>
lblSkillLevel.text=Skill Level:
lblSkillLevel.tooltip=<html>Base skill level for random skill generation of the units.</html>
lblQuality.text=Rating:
lblQuality.tooltip=<html>Determines the tech quality of generated units.</html>
lblFocalWeightClass.text=Focal Weight Class:
lblFocalWeightClass.tooltip=<html>The targeted weight class of the generated units. If not specified,<br>the targeted weight class will be chosen to match the player's force.</html>
lblForceMultiplier.text=Force Multiplier:
lblForceMultiplier.tooltip=<html>How big/tough is this force relative to the player's force?<br>The final calculation will include fixed units as well.</html>
lblPercentConventional.text=Percent Conventional:
lblPercentConventional.tooltip=<html>Replace a certain percent of a Mek or Aero force<br>with vehicles or conventional fighters, respectively.</html>
lblBaChance.text=Integrated BA Chance:
lblBaChance.tooltip=<html>Probability that this force includes<br>integrated Battle Armor units.</html>
lblLanceSize.text=Formation Size:
lblLanceSize.tooltip=<html>The minimum group size that units should be added in.<br>Larger values can lead to more approximate<br>results with force multiplier matching.</html>
btnOK.text=Done
btnClose.text=Cancel
btnBehavior.text=Edit Behavior Settings
btnLoadUnits.text=Load Fixed Units
btnLoadUnits.tooltip=<html>Load fixed units from a .mul file,<br>overwriting existing units</html>
btnSaveUnits.text=Save Fixed Units
btnSaveUnits.tooltip=<html>Save fixed units to a .mul file</html>
btnDeleteUnits.text=Delete Fixed Units
btnDeleteUnits.tooltip=<html>Delete all fixed units</html>
chkUseRandomUnits.text=Use randomly generated units
50 changes: 46 additions & 4 deletions MekHQ/resources/mekhq/resources/CustomizeScenarioDialog.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
btnCancel.text=Cancel
btnOkay.text=OK
lblName.text=Scenario Name:
lblStatus.text=Status:
btnOkay.text=Done
lblName.text=<html><b><nobr>Scenario Name:</nobr></b></html>
lblDate.text=<html><b><nobr>Scenario Date:</nobr></b></html>
lblDeployment.text=<html><b><nobr>Deployment:</nobr></b></html>
lblStatus.text=<html><b><nobr>Status:</nobr></b></html>
title=Customize Scenario
title.new=New Scenario
lblDate.text=Date:
btnAddLoot.text=Add Loot
btnEditLoot.text=Edit Loot
btnDeleteLoot.text=Delete Loot
btnAddObjective.text=Add Objective
btnEditObjective.text=Edit Objective
btnDeleteObjective.text=Delete Objective
btnPlanetaryConditions.text=Edit Planetary Conditions...
btnMapSettings.text=Edit Map Settings...
panPlanetaryConditions.title=Planetary Conditions
panDeploymentLimits.title=Deployment Limits
panMap.title=Map Settings
lblAllowedUnits.text=<html><b><nobr>Allowed Unit Types:</nobr></b></html>
lblQuantityLimit.text=<html><b><nobr>Quantity Limit:</nobr></b></html>
lblRequiredPersonnel.text=<html><b><nobr>Required Personnel:</nobr></b></html>
lblRequiredUnits.text=<html><b><nobr>Required Units:</nobr></b></html>
lblLight.text=<html><b>Light:</b></html>
lblWeather.text=<html><b>Weather:</b></html>
lblWind.text=<html><b>Wind:</b></html>
lblFog.text=<html><b>Fog:</b></html>
lblBlowingSand.text=<html><b><nobr>Blowing Sand:</nobr></b></html>
lblEMI.text=<html><b>EMI:</b></html>
lblAtmosphere.text=<html><b>Atmosphere:</b></html>
lblGravity.text=<html><b>Gravity:</b></html>
lblTemperature.text=<html><b>Temperature:</b></html>
lblOtherConditions.text=<html><b>Other:</b></html>
lblBoardType.text=<html><b><nobr>Board Type:<nobr></b></html>
lblMap.text=<html><b>Map:<nobr></b></html>
lblMapSize.text=<html><b><nobr>Map Size:<nobr></b></html>
emi.text=Electromagnetic interference
sand.text=Blowing sand
panOtherForces.title=Other Forces
btnAddForce.text=Add Force
btnEditForce.text=Edit Force
btnDeleteForce.text=Delete Force
panObjectives.title=Scenario Objectives
panLoot.title=Scenario Costs & Payouts
addEventButton.text=Apply Modifier
txtDesc.title=Description
txtReport.title=After-Action Report
btnEditLimits.text=Edit Limits
btnRemoveLimits.text=Remove Limits
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
dialog.title=Customize Scenario Objective
panObjectiveEffect.title=Objective Effects
lblDescription.text=Description:
lblDetails.text=Details:
lblObjectiveType.text=Objective Type:
lblForceNames.text=Force Names:
lblTimeLimit.text=Time Limit:
lblMagnitude.text=Amount:
lblEffectType.text=Effect Type:
lblEffectScaling.text=Effect Scaling:
lblEffectCondition.text=Effect Condition:
lblSuccessEffects.text=Effects on Success
lblFailureEffects.text=Effects on Failure
btnAdd.text=Add
btnRemove.text=Remove
btnCancel.text=Cancel
btnOK.text=Done
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
labDeploymentOffset.text=Deployment Zone Offset
labDeploymentOffset.tip=Deployment Zone Offset, in hexes from corresponding map edge
labDeploymentWidth.text=Deployment Zone Width
labDeploymentWidth.tip=Deployment Zone width, in hexes
labDeploymentAnyNW.text=Deployment Zone NW corner
labDeploymentAnySE.text=Deployment Zone SE corner
btnOK.text=Done
btnCancel.text=Cancel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dialog.title=Select Map
checkFixed.text=Use Fixed Map
listMapGenerators.none=None
lblBoardType.text=Board Type:
lblMapSize.text=Map Size:
btnOK.text=Done
btnCancel.text=Cancel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dialog.title=Edit Scenario Deployment Limits
panAllowedUnits.title=Allowed Units
checkAllUnits.text=Allow all units
lblQuantityType.text=Quantity Type:
lblCountType.text=Maximum Type:
lblQuantity.text=Maximum Quantity:
btnOK.text=Done
btnCancel.text=Cancel
17 changes: 1 addition & 16 deletions MekHQ/src/mekhq/GameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,7 @@ public void run() {
client.sendMapSettings(mapSettings);
Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay());

PlanetaryConditions planetaryConditions = new PlanetaryConditions();
planetaryConditions.setLight(scenario.getLight());
planetaryConditions.setWeather(scenario.getWeather());
planetaryConditions.setWind(scenario.getWind());
planetaryConditions.setFog(scenario.getFog());
planetaryConditions.setAtmosphere(scenario.getAtmosphere());
planetaryConditions.setTemperature(scenario.getTemperature());
planetaryConditions.setGravity(scenario.getGravity());
planetaryConditions.setEMI(scenario.getEMI());
planetaryConditions.setBlowingSand(scenario.getBlowingSand());
planetaryConditions.setShiftingWindDirection(scenario.canWindShiftDirection());
planetaryConditions.setShiftingWindStrength(scenario.canWindShiftStrength());
planetaryConditions.setWindMax(scenario.getMaxWindStrength());
planetaryConditions.setWindMin(scenario.getMinWindStrength());

client.sendPlanetaryConditions(planetaryConditions);
client.sendPlanetaryConditions(scenario.createPlanetaryConditions());
Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay());

// set player deployment
Expand Down
87 changes: 87 additions & 0 deletions MekHQ/src/mekhq/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import mekhq.campaign.Campaign;
import mekhq.campaign.CampaignOptions;
import mekhq.campaign.finances.Money;
import mekhq.campaign.mission.IPlayerSettings;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.enums.PersonnelRole;
Expand Down Expand Up @@ -1285,4 +1286,90 @@ public static MechSummary retrieveOriginalUnit(Entity newE) throws EntityLoading

return summary;
}

public static List<String> generateEntityStub(List<Entity> entities) {
List<String> stub = new ArrayList<>();
for (Entity en : entities) {
if (null == en) {
stub.add("<html><font color='red'>No random assignment table found for faction</font></html>");
} else {
stub.add("<html>" + en.getCrew().getName() + " (" +
en.getCrew().getGunnery() + "/" +
en.getCrew().getPiloting() + "), " +
"<i>" + en.getShortName() + "</i>" +
"</html>");
}
}
return stub;
}

/**
* Display a descriptive character string for the deployment parameters in an object that implements IPlayerSettings
* @param player object that implements IPlayerSettings
* @return A character string
*/
public static String getDeploymentString(Player player) {
StringBuilder result = new StringBuilder("");

if(player.getStartingPos() >=0
&& player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length) {
result.append(IStartingPositions.START_LOCATION_NAMES[player.getStartingPos()]);
}

if (player.getStartingPos() == 0) {
int NWx = player.getStartingAnyNWx() + 1;
int NWy = player.getStartingAnyNWy() + 1;
int SEx = player.getStartingAnySEx() + 1;
int SEy = player.getStartingAnySEy() + 1;
if ((NWx + NWy + SEx + SEy) > 0) {
result.append(" (" + NWx + ", " + NWy + ")-(" + SEx + ", " + SEy + ")");
}
}
int so = player.getStartOffset();
int sw = player.getStartWidth();
if ((so != 0) || (sw != 3)) {
result.append(", " + so);
result.append(", " + sw);
}

return result.toString();
}

public static String getDeploymentString(IPlayerSettings settings) {
return getDeploymentString(createPlayer(settings));
}

/**
* Create a Player object from IPlayerSettings parameters. Useful for tracking these variables in dialogs.
* @param settings an object that implements IPlayerSettings
* @return A Player object
*/
public static Player createPlayer(IPlayerSettings settings) {
Player p = new Player(1, "fake");
p.setStartingPos(settings.getStartingPos());
p.setStartWidth(settings.getStartWidth());
p.setStartOffset(settings.getStartOffset());
p.setStartingAnyNWx(settings.getStartingAnyNWx());
p.setStartingAnyNWy(settings.getStartingAnyNWy());
p.setStartingAnySEx(settings.getStartingAnySEx());
p.setStartingAnySEy(settings.getStartingAnySEy());

return p;
}

/**
* Update values of an object that implements IPlayerSettings from a player object
* @param settings An object that implements IPlayerSettings
* @param player A Player object from which to read values
*/
public static void updatePlayerSettings(IPlayerSettings settings, Player player) {
settings.setStartingPos(player.getStartingPos());
settings.setStartWidth(player.getStartWidth());
settings.setStartOffset(player.getStartOffset());
settings.setStartingAnyNWx(player.getStartingAnyNWx());
settings.setStartingAnyNWy(player.getStartingAnyNWy());
settings.setStartingAnySEx(player.getStartingAnySEx());
settings.setStartingAnySEy(player.getStartingAnySEy());

}
}
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/campaign/mission/AtBScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import megamek.common.planetaryconditions.Atmosphere;
import mekhq.MHQConstants;
import mekhq.MekHQ;
import mekhq.Utilities;
import mekhq.campaign.Campaign;
import mekhq.campaign.againstTheBot.AtBConfiguration;
import mekhq.campaign.againstTheBot.AtBStaticWeightGenerator;
Expand Down Expand Up @@ -1501,7 +1502,7 @@ protected BotForce getEnemyBotForce(AtBContract c, int start, int home, List<Ent
@Override
public void generateStub(Campaign c) {
super.generateStub(c);
alliesPlayerStub = generateEntityStub(alliesPlayer);
alliesPlayerStub = Utilities.generateEntityStub(alliesPlayer);

alliesPlayer.clear();
if (null != bigBattleAllies) {
Expand Down
Loading

0 comments on commit 47c5762

Please sign in to comment.