Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #746 from PayDay1/selection-modification
Browse files Browse the repository at this point in the history
Allow selecting wounded from a larger selection of settlers by using the TAB key.
  • Loading branch information
andreas-eberle authored Jan 19, 2019
2 parents 3c4b2e6 + a399f21 commit fd584a4
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class GOSwingEventConverter extends AbstractEventConverter
public GOSwingEventConverter(Component component, GOEventHandlerProvider provider) {
super(provider);

component.setFocusTraversalKeysEnabled(false);

component.addKeyListener(this);
component.addMouseListener(this);
component.addMouseMotionListener(this);
Expand Down Expand Up @@ -252,6 +254,9 @@ private String getKeyName(KeyEvent e) {
case KeyEvent.VK_BACK_SPACE:
text = "BACK_SPACE";
break;
case KeyEvent.VK_TAB:
text = "TAB";
break;
default:
text = "" + e.getKeyChar();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
*******************************************************************************/
package jsettlers.buildingcreator.editor.map;

import java.util.Collections;
import java.util.List;

import jsettlers.common.buildings.EBuildingType;
import jsettlers.common.buildings.IBuilding;
import jsettlers.common.buildings.IBuildingMaterial;
Expand All @@ -24,9 +27,6 @@
import jsettlers.common.position.ShortPoint2D;
import jsettlers.common.selectable.ESelectionType;

import java.util.Collections;
import java.util.List;

public class PseudoBuilding implements IBuilding, IBuilding.IMill {
private final EBuildingType type;
private final ShortPoint2D pos;
Expand Down Expand Up @@ -61,6 +61,11 @@ public boolean isSelected() {
return false;
}

@Override
public boolean isWounded() {
return false;
}

@Override
public void setSelected(boolean b) {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015
/*
* Copyright (c) 2015 - 2018
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
Expand All @@ -11,26 +11,26 @@
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*******************************************************************************/
*/
package jsettlers.common.action;

/**
* This enum defines the type of the action.
*
*
* @author Michael Zangl
* @author Andreas Eberle
*/
public enum EActionType {
/**
* Builds a building, the building has to be supplied by the action.
*
*
* @see BuildAction
*/
BUILD,

/**
* Show or hide the construction marks.
*
*
* @see ShowConstructionMarksAction
*/
SHOW_CONSTRUCTION_MARK,
Expand All @@ -42,18 +42,23 @@ public enum EActionType {

/**
* Select a point on the map.
*
*
* @see PointAction
*/
SELECT_POINT,

/**
* Select all units of the type on that point that are around that point.
*
*
* @see PointAction
*/
SELECT_POINT_TYPE,

/**
* Select only the wounded of the current selection.
*/
FILTER_WOUNDED,

/**
* Skip the next minute of gameplay.
*/
Expand Down Expand Up @@ -98,14 +103,14 @@ public enum EActionType {

/**
* Request to set the working area of the building.
*
*
* @see SelectAction
*/
SET_WORK_AREA,

/**
* Lets the settler move to a given point.
*
*
* @see MoveToAction
*/
MOVE_TO,
Expand All @@ -122,7 +127,7 @@ public enum EActionType {

/**
* Selects an area of the screen.
*
*
* @see SelectAreaAction
*/
SELECT_AREA,
Expand All @@ -134,7 +139,7 @@ public enum EActionType {

/**
* The screen changed.
*
*
* @see ScreenChangeAction
*/
SCREEN_CHANGE,
Expand All @@ -146,7 +151,7 @@ public enum EActionType {

/**
* Changes the side panel content.
*
*
* @see ChangePanelAction
*/
CHANGE_PANEL,
Expand Down Expand Up @@ -185,7 +190,7 @@ public enum EActionType {

/**
* used to convert any movable to another.<br>
*
*
* @see ConvertAction
*/
CONVERT,
Expand Down Expand Up @@ -241,21 +246,21 @@ public enum EActionType {

/**
* The user wants to set the priority of the building.
*
*
* @see SetBuildingPriorityAction
*/
SET_BUILDING_PRIORITY,

/**
* The user wants to change the settings for the distribution of a material to the receiving buildings.
*
*
* @see SetMaterialDistributionSettingsAction
*/
SET_MATERIAL_DISTRIBUTION_SETTINGS,

/**
* The user wants to change the order in which materials are served by bearers.
*
*
* @see SetMaterialPrioritiesAction
*/
SET_MATERIAL_PRIORITIES,
Expand All @@ -271,21 +276,21 @@ public enum EActionType {
NEXT_OF_TYPE,
/**
* Request an upgrade of the soldiers.
*
*
* @see UpgradeSoldiersAction
*/
UPGRADE_SOLDIERS,

/**
* Set the material production.
*
*
* @see SetMaterialProductionAction
*/
SET_MATERIAL_PRODUCTION,

/**
* Sets if the material should be placed in stock or not.
*
*
* @see SetMaterialShouldUseStockAction
*/
SET_MATERIAL_STOCK_ACCEPTED,
Expand All @@ -300,27 +305,27 @@ public enum EActionType {
SOLDIERS_ONE,
/**
* Add one more soldier of this type to the building.
*
*
* @see SoldierAction
*/
SOLDIERS_MORE,
/**
* Add one more soldier of this type to the building.
*
*
* @see SoldierAction
*/
SOLDIERS_LESS,

/**
* Ask the user to select a trading waypoint.
*
*
* @see AskSetTradingWaypointAction
*/
ASK_SET_TRADING_WAYPOINT,

/**
* Set the trading waypoint for the current selection.
*
*
* @see SetTradingWaypointAction
*/
SET_TRADING_WAYPOINT,
Expand Down Expand Up @@ -362,7 +367,7 @@ public enum EActionType {

/**
* Changes the amount of materials that should be traded from the current trading building.
*
*
* @see ChangeTradingRequestAction
*/
CHANGE_TRADING_REQUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ public interface ISelectable extends IPlayerable{
* @return {@link ESelectionType}
*/
ESelectionType getSelectionType();

/**
* Returns whether this object is currently wounded.
* @return If it is wounded or not.
*/
boolean isWounded();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
import go.graphics.sound.SoundPlayer;
import go.graphics.text.EFontSize;
import go.graphics.text.TextDrawer;

import jsettlers.common.Color;
import jsettlers.common.CommitInfo;
import jsettlers.common.CommonConstants;
import jsettlers.common.action.Action;
import jsettlers.common.action.EActionType;
import jsettlers.common.action.IAction;
import jsettlers.common.action.PointAction;
import jsettlers.common.action.ScreenChangeAction;
import jsettlers.common.action.SelectAreaAction;
import jsettlers.common.action.ShowConstructionMarksAction;
import jsettlers.common.buildings.EBuildingType;
import jsettlers.common.buildings.IBuilding;
import jsettlers.common.images.AnimationSequence;
Expand All @@ -56,23 +64,16 @@
import jsettlers.common.menu.IMapInterfaceListener;
import jsettlers.common.menu.IStartedGame;
import jsettlers.common.menu.UIState;
import jsettlers.common.action.EActionType;
import jsettlers.common.action.IAction;
import jsettlers.common.menu.messages.IMessage;
import jsettlers.common.movable.IMovable;
import jsettlers.common.position.FloatRectangle;
import jsettlers.common.position.ShortPoint2D;
import jsettlers.common.selectable.ISelectionSet;
import jsettlers.common.statistics.FramerateComputer;
import jsettlers.common.statistics.IGameTimeProvider;
import jsettlers.common.action.Action;
import jsettlers.graphics.action.ActionFireable;
import jsettlers.graphics.action.ActionHandler;
import jsettlers.graphics.action.ActionThreadBlockingListener;
import jsettlers.common.action.PointAction;
import jsettlers.common.action.ScreenChangeAction;
import jsettlers.common.action.SelectAreaAction;
import jsettlers.common.action.ShowConstructionMarksAction;
import jsettlers.graphics.font.FontDrawerFactory;
import jsettlers.graphics.localization.Labels;
import jsettlers.graphics.map.controls.IControls;
Expand Down Expand Up @@ -769,6 +770,8 @@ private static Action getActionForKeyboard(String keyCode) {
return new Action(EActionType.ZOOM_OUT);
} else if ("F2".equalsIgnoreCase(keyCode)) {
return new Action(EActionType.SAVE);
} else if ("TAB".equalsIgnoreCase(keyCode)) {
return new Action(EActionType.FILTER_WOUNDED);
} else if ("DELETE".equalsIgnoreCase(keyCode)) {
return new Action(EActionType.DESTROY);
} else if ("ESCAPE".equalsIgnoreCase(keyCode)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Iterator;

import go.graphics.GLDrawContext;

import jsettlers.common.Color;
import jsettlers.common.landscape.ELandscapeType;
import jsettlers.common.map.IDirectGridProvider;
Expand Down Expand Up @@ -211,6 +212,7 @@ private ShortPoint2D getPositionUnder(float screenX, float screenY) {
height = map.getHeightAt(mapX, mapY);
mapX = (int) (getConverter().getExactMapXwithHeight(screenX, screenY, height) + 0.5);
mapY = (int) (getConverter().getExactMapYwithHeight(screenX, screenY, height) + 0.5);

return new ShortPoint2D(mapX, mapY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public boolean isSelected() {
return false;
}

@Override
public boolean isWounded() {
return false;
}

@Override
public IMapObject getNextObject() {
return null;
Expand Down
Loading

0 comments on commit fd584a4

Please sign in to comment.