Skip to content

Commit

Permalink
Merge pull request #1077 from VicenteCartas/mission-counter
Browse files Browse the repository at this point in the history
Mission log entries and counter for personnel #112
  • Loading branch information
sixlettervariables committed Feb 23, 2019
2 parents 07173f7 + f28ddfa commit e09a87b
Show file tree
Hide file tree
Showing 39 changed files with 1,517 additions and 787 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dialogAdd.title=Add Mission Entry
dialogEdit.title=Edit Mission Entry
lblKill.text=Killed What:
lblKiller.text=Killed With:
btnOK.text=Done
btnClose.text=Cancel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dialogAdd.title=Add Mission Entry
dialogEdit.title=Edit Mission Entry
btnOkay.text=Done
btnCancel.text=Cancel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dialogAdd.title=Add Log Entry
dialogEdit.title=Edit Log Entry
btnOkay.text=Done
btnCancel.text=Cancel
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ btnRandomName.text=Random Name
btnRandomBloodname.text=Random Bloodname
scrSkills.TabConstraints.tabTitle=Skills
scrOptions.TabConstraints.tabTitle=Abilities
panLog.TabConstraints.tabTitle=Log
panMissions.TabConstraints.tabTitle=Missions
panKills.TabConstraints.tabTitle=Kills
lblLevel.text=Level:
lblBonus.text=Bonus:
age= years old
optionGroup.lvl3Advantages=Advantages
optionGroup.edgeAdvantages=Edge
optionGroup.MDAdvantages=Warrior Augmentations
optionGroup.MDAdvantages=Warrior Augmentations
6 changes: 6 additions & 0 deletions MekHQ/resources/mekhq/resources/EditKillLogControl.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
control.name=EditKillLogControl
logsTable.name=KillLogTable
scrollLogsTable.name=ScrollKillLogTable
btnAdd.text=Add Kill
btnEdit.text=Edit Kill
btnDelete.text=Delete Kill
3 changes: 3 additions & 0 deletions MekHQ/resources/mekhq/resources/EditKillLogDialog.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dialog.name=EditKillLogDialog
dialog.title=Edit Kills for
btnOK.text=Done
3 changes: 0 additions & 3 deletions MekHQ/resources/mekhq/resources/EditLogEntryDialog.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
control.name=EditMissionsLogControl
logsTable.name=MissionsLogTable
scrollLogsTable.name=ScrollMissionsLogTable
btnAdd.text=Add Mission
btnEdit.text=Edit Mission
btnDelete.text=Delete Mission
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dialog.name=EditMissionsLogDialog
dialog.title=Edit Missions Log for
btnOK.text=Done
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
control.name=EditPersonnelLogControl
logsTable.name=PersonnelLogTable
scrollLogsTable.name=ScrollPersonnelLogTable
btnAdd.text=Add Entry
btnEdit.text=Edit Entry
btnDelete.text=Delete Entry
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Form.title=Edit Personnel Log for
dialog.name=EditMissionsLogDialog
dialog.title=Edit Personnel Log for
btnOK.text=Done
btnAdd.text=Add Entry
btnEdit.text=Edit Entry
btnDelete.text=Delete Entry
5 changes: 0 additions & 5 deletions MekHQ/resources/mekhq/resources/KillDialog.properties

This file was deleted.

2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/PersonViewPanel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ lblEdge1.text=<html><b>Edge:</b></html>;
lblEdgeAvail1.text=<html><b>Edge Available:</b></html>;
lblSpouse1.text=<html><b>Spouse:</b></html>;
lblChildren1.text=<html><b>Children:</b></html>;
missionLog.title=Mission Log
pnlInjuries.title=Injury Report
pnlDescription.title=Description
pnlLog.title=Personnel Log
Expand All @@ -31,5 +32,6 @@ format.itemHeader=<html><b>%s:</b></html>
format.date=MM/dd/yyyy
format.kills=Kills: %d
format.killDetail=%s with %s
format.missions=Missions: %d
format.italic=<html><i>%s</i></html>
format.injuryTime=%d days
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ kiaQ.text=KIA?
abilityDesc.format=%s %s
addPregnancy.text=Add Pregnancy
addSingleLogEntry.text=Add Single Log Entry...
addMissionEntry.text=Add Mission Entry...
addXP.text=Add XP...
add1XP.text=Add 1 XP
assignAsNavigator.text=As Navigator
Expand Down Expand Up @@ -64,6 +65,7 @@ editCallsign.text=Edit Callsign
editHits.text=Edit Hits...
editInjuries.text=Edit Injuries...
editKillLog.text=Edit Kill Log...
editMissionLog.text=Edit Mission Log...
editPersonnelLog.text=Edit Personnel Log...
enterNewCallsign.text=Enter new callsign
exportPersonnel.text=Export Personnel
Expand Down
157 changes: 90 additions & 67 deletions MekHQ/src/mekhq/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Version.java
*
* Copyright (c) 2009 Jay Lawson <jaylawson39 at yahoo.com>. All rights reserved.
* Copyright (c) 2019 The MekHQ Team.
*
* This file is part of MekHQ.
*
Expand All @@ -21,18 +22,17 @@

package mekhq;


/**
*
* @author Jay Lawson <jaylawson39 at yahoo.com>
* This is a very simple class that keeps track of versioning
*/
public class Version {

private static final int NO_REVISION = -1;
private int snapshot;
private int minor;
private int major;
private int revision = -1;
private int revision = NO_REVISION;

public Version(String version) {
if(null != version && version.length() > 0) {
Expand All @@ -46,25 +46,29 @@ public Version(String version) {

// Check for other information embedded in the snapshot & handle it
if (snap.indexOf("-") > 0) {
// Create a new temporary array split by the hyphen
// Create a new temporary array split by the hyphen
temp = snap.split("\\-");
// The snapshot is the first element of the new array
snap = temp[0];

// Loop over other elements searching for usable parameters
for (int i = 1; i < temp.length; i++) {
// For now the only usable parameter is the revision
if (temp[i].matches("r[0-9]+")) {
String rev = temp[i].replace("r", "");
// For now the only usable parameter is the revision
if (temp[i].matches("r[0-9]+")) {
String rev = temp[i].replace("r", "");
revision = Integer.parseInt(rev);
}
}
}
}

// Finally, file the snapshot
snapshot = Integer.parseInt(snap);
}
}

public boolean hasRevision() {
return revision != NO_REVISION;
}

public int getRevision() {
return revision;
Expand All @@ -85,86 +89,105 @@ public int getMajorVersion() {
/**
* Compare Versions
*
* Use this method to determine if the version passed is less than
* this Version object
* Use this method to determine if this version is higher than
* the version passed
*
* @param checkVersion The version we want to see if is less than this version.
* @param other The version we want to see if it is lower than this version.
*
* @return true if checkVersion is less than this Version object
* @return true if this is higher than checkVersion
*/
public boolean versionCompare(String checkVersion) {
return versionCompare(new Version(checkVersion));
public boolean isHigherThan(String other) {
return isHigherThan(new Version(other));
}

/**
* Compare Versions
*
*
* Use this method to determine if the version passed is less than
* this Version object.
*
* @param checkVersion The version we want to see if is less than this version
*
*
* @param other The version we want to see if is less than this version
*
* @return true if checkVersion is less than this Version object
*/
public boolean versionCompare(Version checkVersion) {
// Pass to the static method for the final computation
return Version.versionCompare(checkVersion, this);
}

/**
* Compare Versions
*
* @param checkVersion The version we want to see if is less than the other
* @param staticVersion The static version that we're comparing against
*
* @return true if checkVersion is less than staticVersion
*/
public static boolean versionCompare(String checkVersion, String staticVersion) {
return versionCompare(new Version(checkVersion), new Version(staticVersion));
public boolean isHigherThan(Version other) {
return Version.compare(this, other) > 0;
}

/**
* Compare Versions
*
* @param checkVersion The version we want to see if is less than the other
* @param staticVersion The static version that we're comparing against
*
* @return true if checkVersion is less than staticVersion
*
* Use this method to determine if this version is lower than
* the version passed
*
* @param other The version we want to see if it is higher than this version.
*
* @return true if this is lower than checkVersion
*/
public static boolean versionCompare(Version checkVersion, String staticVersion) {
return versionCompare(checkVersion, new Version(staticVersion));
public boolean isLowerThan(String other) {
return isLowerThan(new Version(other));
}

/**
* Compare Versions
*
* @param checkVersion The version we want to see if is less than the other
* @param staticVersion The static version that we're comparing against
*
* @return true if checkVersion is less than staticVersion
*
* Use this method to determine if this version is lower than
* the version passed
*
* @param other The version we want to see if it is higher than this version.
*
* @return true if this is lower than checkVersion
*/
public static boolean versionCompare(String checkVersion, Version staticVersion) {
return versionCompare(new Version(checkVersion), staticVersion);
public boolean isLowerThan(Version other) {
return Version.compare(this, other) < 0;
}

/**
* Compare Versions
* Compare versions
*
* @param checkVersion The version we want to see if is less than the other
* @param staticVersion The static version that we're comparing against
* @param left left version to compare
* @param right right version to compare
*
* @return true if checkVersion is less than staticVersion
* @return a positive value if left is higher, a negative value if right is higher. 0 if they are equal.
*/
public static boolean versionCompare(Version checkVersion, Version staticVersion) {
// Major version is less
if (checkVersion.getMajorVersion() < staticVersion.getMajorVersion())
return true;
else if (checkVersion.getMajorVersion() == staticVersion.getMajorVersion() && checkVersion.getMinorVersion() < staticVersion.getMinorVersion())
return true;
else if (checkVersion.getMajorVersion() == staticVersion.getMajorVersion() && checkVersion.getMinorVersion() == staticVersion.getMinorVersion() && checkVersion.getSnapshot() < staticVersion.getSnapshot())
return true;
else if (checkVersion.getRevision() != -1 && staticVersion.getRevision() != -1 && checkVersion.getRevision() < staticVersion.getRevision())
return true;
return false;
private static int compare(Version left, Version right) {
// Check Major version
if (left.getMajorVersion() > right.getMajorVersion()) {
return 1;
} else if (left.getMajorVersion() < right.getMajorVersion()) {
return -1;
}

// Major version is equal, try with Minor
if (left.getMinorVersion() > right.getMinorVersion()) {
return 1;
} else if (left.getMinorVersion() < right.getMinorVersion()) {
return -1;
}

// Minor version is also equal, try snapshot
if (left.getSnapshot() > right.getSnapshot()) {
return 1;
} else if (left.getSnapshot() < right.getSnapshot()) {
return -1;
}

// Snapshot is also equal, try revision if we have it
if (left.hasRevision() && right.hasRevision()) {
if (left.getRevision() > right.getRevision()) {
return 1;
} else if (left.getRevision() < right.getRevision()) {
return -1;
}
}

// If one side has a revision and the other does not, that side is higher
if (left.hasRevision() && !right.hasRevision()) {
return 1;
} else if (!left.hasRevision() && right.hasRevision()) {
return -1;
}

return 0;
}
}
}
3 changes: 1 addition & 2 deletions MekHQ/src/mekhq/campaign/Kill.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class Kill implements Serializable {
private int oldPilotId = -1;

public Kill() {

}

public Kill(UUID id, String kill, String killer, Date d) {
Expand Down Expand Up @@ -164,4 +163,4 @@ public Kill clone() {
return new Kill(getPilotId(), getWhatKilled(), getKilledByWhat(), getDate());
}

}
}
1 change: 0 additions & 1 deletion MekHQ/src/mekhq/campaign/event/PersonLogEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ public class PersonLogEvent extends PersonEvent {
public PersonLogEvent(Person person) {
super(person);
}

}
4 changes: 2 additions & 2 deletions MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ else if (xn.equalsIgnoreCase("info")) {

// If the version is earlier than 0.3.4 r1782, then we need to translate
// the rank system.
if (Version.versionCompare(version, "0.3.4-r1782")) {
if (version.isLowerThan("0.3.4-r1782")) {
retVal.setRankSystem(
RankTranslator.translateRankSystem(retVal.getRanks().getOldRankSystem(), retVal.getFactionCode()));
if (retVal.getRanks() == null) {
Expand Down Expand Up @@ -951,7 +951,7 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)
} else if (xn.equalsIgnoreCase("rankNames")) {
rankNames = wn.getTextContent().trim();
} else if (xn.equalsIgnoreCase("ranks") || xn.equalsIgnoreCase("rankSystem")) {
if (Version.versionCompare(version, "0.3.4-r1645")) {
if (version.isLowerThan("0.3.4-r1645")) {
rankSystem = Integer.parseInt(wn.getTextContent().trim());
} else {
Ranks r = Ranks.generateInstanceFromXML(wn, version);
Expand Down
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/campaign/log/ServiceLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public static void demotedTo(Person person, Date date){

public static void participatedInMission(Person person, Date date, String scenarioName, String missionName){
String message = logEntriesResourceMap.getString("participatedInMission.text");
person.addLogEntry(new ServiceLogEntry(date,
person.addMissionLogEntry(new ServiceLogEntry(
date,
MessageFormat.format(message, scenarioName, missionName)));
}

Expand Down

0 comments on commit e09a87b

Please sign in to comment.