Skip to content

Commit

Permalink
Merge branch 'master' into fixRotateAlphaProblems
Browse files Browse the repository at this point in the history
  • Loading branch information
arlith committed Sep 1, 2016
2 parents 7db0146 + e81f75f commit 6a84131
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 46 deletions.
2 changes: 1 addition & 1 deletion megamek/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<target name="compile" depends="init" description="Compile java sources into class files">
<!-- compile -->
<javac debug="true" debuglevel="lines,source" target="1.7" source="1.7" destdir="${builddir}" srcdir="${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<javac debug="true" debuglevel="lines,source" target="1.8" source="1.8" destdir="${builddir}" srcdir="${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<classpath>
<pathelement location="${basedir}" />
<fileset dir="${libdir}" includes="*.jar" />
Expand Down
2 changes: 2 additions & 0 deletions megamek/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ VERSION HISTORY:
----------------
v0.41.23-git
+ Issue #323: Artefacting drawing the boardview background
+ Bug: Bot would fire at hidden units
+ Added option to toggle displaying of unit labels, default key is Y

v0.41.22 (2016-08-26 03:00 UTC)
+ Issue #295: Roads not preventing swamp/rubble PSRs
Expand Down
3 changes: 3 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,9 @@ KeyBinds.cmdNames.nextMode=Next Weapon Mode
KeyBinds.cmdDesc.nextMode=Selects the next mode for the selected weapon in the unit display weapon list.
KeyBinds.cmdNames.prevMode=Previous Weapon Mode
KeyBinds.cmdDesc.prevMode=Selects the previous mode for the selected weapon the unit display weapon list.
KeyBinds.cmdNames.toggleDrawLabels=Toggle Unit Labels
KeyBinds.cmdDesc.toggleDrawLabels=Toggles between displaying and not displaying unit labels
LOSDialog.inFirstHex=In first hex:
LOSDialog.InSecondHex=In second hex:
Expand Down
7 changes: 7 additions & 0 deletions megamek/mmconf/defaultKeyBinds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,11 @@
<isRepeatable>false</isRepeatable>
</KeyBind>

<KeyBind>
<command>toggleDrawLabels</command>
<keyCode>89</keyCode> <!-- Y -->
<modifier>0</modifier>
<isRepeatable>false</isRepeatable>
</KeyBind>

</KeyBindings>
2 changes: 1 addition & 1 deletion megamek/packaging.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

<!-- compile -->
<echo message="building MegaMek from git sources" />
<javac debug="true" debuglevel="lines,source" target="1.7" source="1.7" destdir="${pkgbuilddir}" srcdir="${pkgdir}/${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<javac debug="true" debuglevel="lines,source" target="1.8" source="1.8" destdir="${pkgbuilddir}" srcdir="${pkgdir}/${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<classpath>
<pathelement location="${pkgdir}" />
<fileset dir="${pkgdir}/${libdir}" includes="*.jar" />
Expand Down
2 changes: 1 addition & 1 deletion megamek/packaging_local.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

<!-- compile -->
<echo message="building MegaMek from local sources" />
<javac debug="true" debuglevel="lines,source" target="1.7" source="1.7" destdir="${localbuilddir}" srcdir="${localdir}/${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<javac debug="true" debuglevel="lines,source" target="1.8" source="1.8" destdir="${localbuilddir}" srcdir="${localdir}/${srcdir}" memoryInitialSize="512m" memoryMaximumSize="512m" fork="true" encoding="UTF-8">
<classpath>
<pathelement location="${localdir}" />
<fileset dir="${localdir}/${libdir}" includes="*.jar" />
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class GUIPreferences extends PreferenceStoreProxy {
*/
public static final String ADVANCED_CHATBOX_SIZE = "AdvancedChatboxSize";
public static final String ADVANCED_CHAT_LOUNGE_TAB_FONT_SIZE = "AdvancedChatLoungeTabFontSize";
public static final String ADVANCED_DRAW_ENTITY_LABEL = "AdvancedDrawEntityLabel";
public static final String ADVANCED_MECH_DISPLAY_ARMOR_LARGE_FONT_SIZE = "AdvancedMechDisplayArmorLargeFontSize";
public static final String ADVANCED_MECH_DISPLAY_ARMOR_MEDIUM_FONT_SIZE = "AdvancedMechDisplayArmorMediumFontSize";
public static final String ADVANCED_MECH_DISPLAY_ARMOR_SMALL_FONT_SIZE = "AdvancedMechDisplayArmorSmallFontSize";
Expand Down Expand Up @@ -213,6 +214,7 @@ protected GUIPreferences() {

store.setDefault(ADVANCED_CHATBOX_SIZE, 5);
store.setDefault(ADVANCED_CHAT_LOUNGE_TAB_FONT_SIZE, 16);
store.setDefault(ADVANCED_DRAW_ENTITY_LABEL, true);
store.setDefault(ADVANCED_MECH_DISPLAY_ARMOR_LARGE_FONT_SIZE, 12);
store.setDefault(ADVANCED_MECH_DISPLAY_ARMOR_MEDIUM_FONT_SIZE, 10);
store.setDefault(ADVANCED_MECH_DISPLAY_ARMOR_SMALL_FONT_SIZE, 9);
Expand Down
28 changes: 28 additions & 0 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView1.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,31 @@ public void performAction() {
}

});

// Register the action for Toggling drawing unit labels
controller.registerCommandAction(KeyCommandBind.TOGGLE_DRAW_LABELS.cmd,
new CommandAction() {

@Override
public boolean shouldPerformAction() {
if (shouldIgnoreKeyCommands()) {
return false;
} else {
return true;
}
}

@Override
public void performAction() {
GUIPreferences guip = GUIPreferences.getInstance();
boolean drawLabels = guip.getBoolean(
GUIPreferences.ADVANCED_DRAW_ENTITY_LABEL);
guip.setValue(GUIPreferences.ADVANCED_DRAW_ENTITY_LABEL,
!drawLabels);
updateEntityLabels();
}

});
}

private boolean shouldIgnoreKeyCommands() {
Expand Down Expand Up @@ -1029,6 +1054,9 @@ public void preferenceChange(PreferenceChangeEvent e) {
if (e.getName().equals(IClientPreferences.MAP_TILESET)) {
updateBoard();
}
if (e.getName().equals(GUIPreferences.ADVANCED_DRAW_ENTITY_LABEL)) {
updateEntityLabels();
}
}

/**
Expand Down
64 changes: 33 additions & 31 deletions megamek/src/megamek/client/ui/swing/boardview/EntitySprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,39 +466,41 @@ public void prepare() {
graph.scale(1/bv.scale, 1/bv.scale);

// Label background
if (criticalStatus) {
graph.setColor(LABEL_CRITICAL_BACK);
} else {
graph.setColor(LABEL_BACK);
}
graph.fillRoundRect(labelRect.x, labelRect.y,
labelRect.width, labelRect.height, 5, 10);

if (guip.getEntityOwnerLabelColor()) {
graph.setColor(PlayerColors
.getColor(entity.getOwner().getColorIndex(), false));
Stroke oldStroke = graph.getStroke();
graph.setStroke(new BasicStroke(3));
graph.drawRoundRect(labelRect.x - 1, labelRect.y - 1,
labelRect.width + 1, labelRect.height + 1, 5, 10);
graph.setStroke(oldStroke);
}
if (guip.getBoolean(GUIPreferences.ADVANCED_DRAW_ENTITY_LABEL)) {
if (criticalStatus) {
graph.setColor(LABEL_CRITICAL_BACK);
} else {
graph.setColor(LABEL_BACK);
}
graph.fillRoundRect(labelRect.x, labelRect.y, labelRect.width,
labelRect.height, 5, 10);

if (guip.getEntityOwnerLabelColor()) {
graph.setColor(PlayerColors.getColor(
entity.getOwner().getColorIndex(), false));
Stroke oldStroke = graph.getStroke();
graph.setStroke(new BasicStroke(3));
graph.drawRoundRect(labelRect.x - 1, labelRect.y - 1,
labelRect.width + 1, labelRect.height + 1, 5, 10);
graph.setStroke(oldStroke);
}

// Label text
graph.setFont(labelFont);
Color textColor = LABEL_TEXT_COLOR;
if (!entity.isDone() && !onlyDetectedBySensors()) {
textColor = guip.getColor(
GUIPreferences.ADVANCED_UNITOVERVIEW_VALID_COLOR);
}
if (isSelected) {
textColor = guip.getColor(
GUIPreferences.ADVANCED_UNITOVERVIEW_SELECTED_COLOR);
// Label text
graph.setFont(labelFont);
Color textColor = LABEL_TEXT_COLOR;
if (!entity.isDone() && !onlyDetectedBySensors()) {
textColor = guip.getColor(
GUIPreferences.ADVANCED_UNITOVERVIEW_VALID_COLOR);
}
if (isSelected) {
textColor = guip.getColor(
GUIPreferences.ADVANCED_UNITOVERVIEW_SELECTED_COLOR);
}
bv.drawCenteredText(graph, getAdjShortName(),
labelRect.x + labelRect.width / 2,
labelRect.y + labelRect.height / 2 - 1, textColor,
(entity.isDone() && !onlyDetectedBySensors()));
}
bv.drawCenteredText(graph, getAdjShortName(),
labelRect.x + labelRect.width / 2,
labelRect.y + labelRect.height / 2 - 1, textColor,
(entity.isDone() && !onlyDetectedBySensors()));

// Past here, everything is drawing status that shouldn't be seen
// on a sensor return, so we'll just quit here
Expand Down
3 changes: 2 additions & 1 deletion megamek/src/megamek/client/ui/swing/util/KeyCommandBind.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public enum KeyCommandBind {
/** Toggles between Jumping and Walk/Run, also acts as a reset when a unit cannot jump */
TOGGLE_MOVEMODE("toggleJump", false, KeyEvent.VK_J, 0), // Default: J
PREV_MODE("prevMode", false, KeyEvent.VK_Z, InputEvent.SHIFT_MASK), // Default: Shift-Z
NEXT_MODE("nextMode", false, KeyEvent.VK_C, InputEvent.SHIFT_MASK); // Default: Shift-C
NEXT_MODE("nextMode", false, KeyEvent.VK_C, InputEvent.SHIFT_MASK), // Default: Shift-C
TOGGLE_DRAW_LABELS("toggleDrawLabels", false, KeyEvent.VK_Y, 0); // Default: Y


/**
Expand Down
10 changes: 0 additions & 10 deletions megamek/src/megamek/common/Aero.java
Original file line number Diff line number Diff line change
Expand Up @@ -2640,16 +2640,6 @@ public boolean isRepairable() {
return true; // deal with this later
}

/**
* Restores the entity after serialization
*/
@Override
public void restore() {
super.restore();
// not sure what to put here

}

@Override
public boolean canCharge() {
// ramming is resolved differently than chargin
Expand Down
6 changes: 5 additions & 1 deletion megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,10 @@ private static String toHitIsImpossible(IGame game, Entity ae,
boolean isHoming = false;
ToHitData toHit = null;

if ((target instanceof Entity) && ((Entity)target).isHidden()) {
return "Can't fire at hidden units!";
}

if (weapon.isSquadSupportWeapon() && (ae instanceof BattleArmor)) {
if (!((BattleArmor) ae).isTrooperActive(BattleArmor.LOC_TROOPER_1)) {
return "Squad support mounted weapons cannot fire if "
Expand Down Expand Up @@ -4211,7 +4215,7 @@ private static String toHitIsImpossible(IGame game, Entity ae,
// Must target infantry in buildings from the inside.
if (targetInBuilding && (te instanceof Infantry)
&& (null == los.getThruBldg())) {
return "Attack on infantry crosses building exterior wall.";
return "Attack on infantry crosses building exterior wall/roof.";
}

if ((wtype.getAmmoType() == AmmoType.T_NARC)
Expand Down

0 comments on commit 6a84131

Please sign in to comment.