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

Add movable textures for all original Civilizations #791

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
840f51a
backport d24ed35, fix BackendSelector on jre11
paulwedeck Oct 11, 2019
4b33c83
fix MapCreator
paulwedeck Oct 13, 2019
d38fc0d
fix nativeScale with glfw
paulwedeck Oct 25, 2019
4880cb5
Remove unnecessary block="true" attributes and always default to bloc…
paulwedeck Mar 12, 2020
8dfa71b
fix comment
paulwedeck Apr 19, 2020
3e25e0a
Extend ECivilisation to include all S3 nations and make them selectab…
paulwedeck Apr 20, 2020
616951f
choose Image for movable based on movables civilisation (fallback is …
paulwedeck Apr 20, 2020
d991130
add template system to movable files
paulwedeck Apr 21, 2020
1b69da5
add civ-specific BEARER animations and missing Materials
paulwedeck Apr 21, 2020
36c91cf
fix empty donkey
paulwedeck Apr 21, 2020
e9fdcd7
add DIGGER animation
paulwedeck Apr 21, 2020
0edf0d3
add SAWMILLER and DOCKWORKER
paulwedeck Apr 21, 2020
5112c7b
add some movables
paulwedeck Apr 22, 2020
b1f005b
Fix SLAUGHTERHOUSE drawing in MapCreator
paulwedeck Apr 22, 2020
ff91a34
Merge branch 'fixes' of paulwedeck/settlers-remake into nations
paulwedeck Apr 22, 2020
a005eae
add FARMER, FISHERMAN and BAKER, fix some minor animation bugs
paulwedeck Apr 22, 2020
1beb70d
add missing common movables
paulwedeck Apr 23, 2020
e1d7b4e
Implement some more nation specific images
paulwedeck Apr 24, 2020
a27c5b3
add nation specific ships
paulwedeck Apr 24, 2020
c724a48
implement fallback graphics for non-ROMAN nations (if file couldn't b…
paulwedeck Apr 29, 2020
6a57b1f
add nation specific images to SettlersStatisticsPanel
paulwedeck Apr 29, 2020
769ab46
use different images on dockyard
paulwedeck Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public class BackendSelector extends JComboBox<EBackendType> {
public void actionPerformed(ActionEvent actionEvent) {
super.actionPerformed(actionEvent);

if(actionEvent.getActionCommand() == "comboBoxChanged") {
if(actionEvent.getActionCommand().equals("comboBoxChanged")) {
if(getSelectedItem() instanceof String) {
setSelectedItem(current_item);
return;
}
EBackendType bi = (EBackendType) getSelectedItem();
if (bi.platform != null && bi.platform != Platform.get()) {
setSelectedItem(current_item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,17 @@ public boolean isValid() {
return contextValid;
}

protected float nativeScale = 0;

public void resize(int width, int height) {
if(nativeScale == 0) {
int[] vp = new int[4];
GL11.glGetIntegerv(GL11.GL_VIEWPORT, vp);
nativeScale = vp[2] / (float)width;

if(nativeScale < 0.1f) nativeScale = 1;
}

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
// coordinate system origin at lower left with width and height same as
Expand All @@ -342,6 +352,6 @@ public void resize(int width, int height) {

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glViewport(0, 0, width, height);
GL11.glViewport(0, 0, (int)(width*nativeScale), (int)(height*nativeScale));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,18 @@ public void setGlobalAttributes(float x, float y, float z, float sx, float sy, f
}
}

protected float nativeScale = 0;

@Override
public void resize(int width, int height) {
GL11.glViewport(0, 0, width, height);
if(nativeScale == 0) {
int[] vp = new int[4];
GL11.glGetIntegerv(GL11.GL_VIEWPORT, vp);
nativeScale = vp[2] / (float)width;

if(nativeScale < 0.1f) nativeScale = 1;
}
GL11.glViewport(0, 0, (int)(width*nativeScale), (int)(height*nativeScale));

mat.identity();
mat.ortho(0, width, 0, height, -1, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ public void startElement(String uri, String localName, String tagName, Attribute
flag = readRelativeTile(attributes);
} else if (TAG_BLOCKED.equals(tagName)) {
RelativePoint point = readRelativeTile(attributes);
if ("true".equals(attributes.getValue("block"))) {

// block should only be false or true. true is the default value but android sometimes defaults to null.
if (!"false".equals(attributes.getValue("block"))) {
blocked.add(point);
}
protectedTiles.add(point);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public abstract class ImageLink implements Serializable {
private static final long serialVersionUID = 1572028978425777114L;

private static final Pattern ORIGINAL_LINK = Pattern
.compile("original_(\\d+)_(SETTLER|GUI|LANDSCAPE)_(\\d+)");
.compile("original_(\\d+)_(SETTLER|GUI|LANDSCAPE)_(\\d+)(?:_(\\d+))?");
private static final int ORIGINAL_LINK_FILE = 1;
private static final int ORIGINAL_LINK_TYPE = 2;
private static final int ORIGINAL_LINK_SEQUENCE = 3;
private static final int ORIGINAL_LINK_INDEX = 4;

/**
* Converts a given name to an image link.
Expand All @@ -57,6 +58,30 @@ public static ImageLink fromName(String name, int imageIndex) {
}
}

/**
* Converts a given name to an image link.
* <p>
* Names can either be direct names of the png files or they can have the for "original_&lt;file>_&lt;type>_&lt;sequence
*
* @param name
* The name.
* @return The image link for that image, no matter if it exists or not.
*/
public static ImageLink fromName(String name) {
Matcher matcher = ORIGINAL_LINK.matcher(name);
if (matcher.matches()) {
EImageLinkType type = EImageLinkType.valueOf(matcher.group(ORIGINAL_LINK_TYPE));
int file = Integer.parseInt(matcher.group(ORIGINAL_LINK_FILE));
int sequence = Integer.parseInt(matcher.group(ORIGINAL_LINK_SEQUENCE));
int imageIndex = 0;
String indexStr = matcher.group(ORIGINAL_LINK_INDEX);
if(indexStr != null) imageIndex = Integer.parseInt(indexStr);
return new OriginalImageLink(type, file, sequence, imageIndex);
} else {
return new DirectImageLink(name);
}
}

/**
* Gets the name of this link.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public final class OriginalImageLink extends ImageLink {
private final int image;
private final int length;
private final String humanName;
private OriginalImageLink fallback;

/**
* Creates a new image link description.
Expand Down Expand Up @@ -160,4 +161,12 @@ public EImageLinkType type() {
public String getHumanName() {
return humanName;
}

public void setFallback(OriginalImageLink fallback) {
this.fallback = fallback;
}

public OriginalImageLink getFallback() {
return fallback;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,19 @@ public enum EMaterialType {

NO_MATERIAL((short) 0, 0, 0, false, -1, false),

MEAD((short) 90, 14, 126, false, -1, true),
HONEY((short) 89, 14, 129, false, -1, true),
GEMS((short) 79, 24, 120, false, -1, false),
SULFUR((short) 80, 34, 126, false, -1, false),
RICE((short) 78, 34, 129, false, -1, false),
KEG((short) 70, 34, 132, false, -1, false),
BOX((short) 82, 0, 0, false, -1, false),

// ammo for cannon (6 frames instead of 8)
CANNON_AMMO((short) 86, 0, 0, false, -1, false),
// ammo for ballista (6 frames instead of 8)
BALLISTA_AMMO((short) 87, 0, 0, false, -1, false),
// ammo for catapult (6 frames instead of 8)
CATAPULT_AMMO((short) 88, 0, 0, false, -1, false),
MEAD((short) 90, 14, 126, true, -1, true),
HONEY((short) 89, 14, 129, true, -1, true),
GEMS((short) 79, 24, 120, true, -1, false),
SULFUR((short) 80, 34, 126, true, -1, false),
RICE((short) 78, 34, 129, true, -1, false),
KEG((short) 70, 34, 132, true, -1, false),
LIQUOR((short)71, 34, 132, true, -1, false),
GUN_POWDER((short) 82, 34, 135, true, -1, false),

// ammo for siege weapons (6 frames instead of 8)
CANNON_AMMO((short) 86, 34, 249, false, -1, false),
BALLISTA_AMMO((short) 87, 24, 234, false, -1, false),
CATAPULT_AMMO((short) 88, 14, 240, false, -1, false),

WHITE_BREAD((short) 0, 0, 0, false, -1, false),
BASKET((short) 0, 0, 0, false, -1, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package jsettlers.common.movable;

import jsettlers.common.mapobject.EMapObjectType;
import jsettlers.common.player.IPlayer;

/**
* Created by Andreas Eberle on 07.09.2017.
Expand All @@ -27,4 +28,6 @@ public interface IShipInConstruction {
EDirection getDirection();

EMapObjectType getObjectType();

IPlayer getPlayer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,20 @@
* @author codingberlin
*/
public enum ECivilisation {
ROMAN,
ROMAN(1),
EGYPTIAN(2),
ASIAN(3),
AMAZON(4);

private int fileIndex;
public final int ordinal;

ECivilisation(int fileIndex) {
ordinal = ordinal();
this.fileIndex = fileIndex;
}

public int getFileIndex() {
return fileIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public interface IInGamePlayer extends IPlayer {
* Get win/lose state for the player
* @return The win/lose state the player is in
*/
public EWinState getWinState();
EWinState getWinState();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public interface IPlayer {

EWinState getWinState();

ECivilisation getCivilisation();

class DummyPlayer implements IPlayer {
private final byte playerAndTeamId;

Expand All @@ -54,5 +56,10 @@ public byte getTeamId() {
public EWinState getWinState() {
return EWinState.UNDECIDED;
}

@Override
public ECivilisation getCivilisation() {
return ECivilisation.ROMAN;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
*******************************************************************************/
package jsettlers.common.selectable;

import java.util.EnumMap;
import java.util.Map;

import jsettlers.common.movable.EMovableType;

import java8.util.stream.Stream;
import jsettlers.common.player.ECivilisation;
import jsettlers.common.player.IInGamePlayer;
import jsettlers.common.player.IPlayer;

/**
* Interface for sets of selectables.<br>
Expand Down Expand Up @@ -53,9 +59,10 @@ public interface ISelectionSet extends Iterable<ISelectable> {
* counts the movables in the set of the given type.
*
* @param type
* @param playerStatistic
* @return
*/
int getMovableCount(EMovableType type);
int getMovableCount(EMovableType type, Map<IPlayer, Integer> playerStatistic);

/**
* gives the selected at given index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
<ground groundtype="EARTH" />
<ground groundtype="FLATTENED" />

<blocked dx="-2" dy="-3" block="true" />
<blocked dx="-2" dy="-2" block="true" />
<blocked dx="-2" dy="-1" block="true" />
<blocked dx="-2" dy="0" block="true" />
<blocked dx="-1" dy="1" block="true" />
<blocked dx="-1" dy="0" block="true" />
<blocked dx="-1" dy="-1" block="true" />
<blocked dx="-1" dy="-2" block="true" />
<blocked dx="-1" dy="-3" block="true" />
<blocked dx="0" dy="-2" block="true" />
<blocked dx="0" dy="-1" block="true" />
<blocked dx="0" dy="0" block="true" />
<blocked dx="0" dy="1" block="true" />
<blocked dx="0" dy="2" block="true" />
<blocked dx="1" dy="3" block="true" />
<blocked dx="1" dy="2" block="true" />
<blocked dx="1" dy="1" block="true" />
<blocked dx="1" dy="0" block="true" />
<blocked dx="1" dy="-1" block="true" />
<blocked dx="2" dy="0" block="true" />
<blocked dx="2" dy="1" block="true" />
<blocked dx="2" dy="2" block="true" />
<blocked dx="2" dy="3" block="true" />
<blocked dx="3" dy="3" block="true" />
<blocked dx="3" dy="1" block="true" />
<blocked dx="-2" dy="-3" />
<blocked dx="-2" dy="-2" />
<blocked dx="-2" dy="-1" />
<blocked dx="-2" dy="0" />
<blocked dx="-1" dy="1" />
<blocked dx="-1" dy="0" />
<blocked dx="-1" dy="-1" />
<blocked dx="-1" dy="-2" />
<blocked dx="-1" dy="-3" />
<blocked dx="0" dy="-2" />
<blocked dx="0" dy="-1" />
<blocked dx="0" dy="0" />
<blocked dx="0" dy="1" />
<blocked dx="0" dy="2" />
<blocked dx="1" dy="3" />
<blocked dx="1" dy="2" />
<blocked dx="1" dy="1" />
<blocked dx="1" dy="0" />
<blocked dx="1" dy="-1" />
<blocked dx="2" dy="0" />
<blocked dx="2" dy="1" />
<blocked dx="2" dy="2" />
<blocked dx="2" dy="3" />
<blocked dx="3" dy="3" />
<blocked dx="3" dy="1" />

<blocked dx="4" dy="1" block="false" />
<blocked dx="4" dy="2" block="false" />
Expand Down Expand Up @@ -133,11 +133,12 @@

<job name="C_work1" type="LOOK_AT" successjob="C_work2" failjob="gohome" direction="NORTH_EAST"/>
<job name="C_work2" type="PLAY_ACTION1" successjob="C_work3" failjob="gohome" time="1"/>
<job name="C_work3" type="SET_MATERIAL" successjob="C_work4" failjob="gohome" material="BREAD"/>
<job name="C_work3" type="SET_MATERIAL" successjob="C_work4" failjob="gohome" material="BLADE"/>
<job name="C_work4" type="SMOKE_ON" successjob="C_work5" failjob="gohome" dx="0" dy="2"/>
<job name="C_work5" type="PLAY_ACTION2" successjob="C_work6" failjob="gohome" time="4"/>
<job name="C_work6" type="SMOKE_OFF" successjob="C_work7" failjob="gohome" dx="0" dy="2"/>
<job name="C_work7" type="PLAY_ACTION1" successjob="C_walkB1" failjob="gohome" time="1"/>
<job name="C_work5" type="WAIT" successjob="C_work6" failjob="gohome" time="4"/>
<job name="C_work6" type="SET_MATERIAL" successjob="C_work7" failjob="gohome" material="BREAD"/>
<job name="C_work7" type="SMOKE_OFF" successjob="C_work8" failjob="gohome" dx="0" dy="2"/>
<job name="C_work8" type="PLAY_ACTION1" successjob="C_walkB1" failjob="gohome" time="1"/>

<job name="C_walkB1" type="WALK" successjob="C_walkB2" failjob="gohome" direction="NORTH_WEST"/>
<job name="C_walkB2" type="WALK" successjob="C_drop1" failjob="gohome" direction="NORTH_WEST"/>
Expand Down
Loading