Skip to content

Commit

Permalink
Rename IRasterTile and IRasterTiledMap to RasterTile and RasterTiledMap
Browse files Browse the repository at this point in the history
  • Loading branch information
SmylerMC committed Jan 13, 2024
1 parent 1bc8489 commit 0635f73
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 61 deletions.
16 changes: 8 additions & 8 deletions src/main/java/fr/thesmyler/terramap/TerramapClientContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import fr.thesmyler.terramap.gui.screens.SavedMainScreenState;
import fr.thesmyler.terramap.gui.screens.TerramapScreen;
import fr.thesmyler.terramap.input.KeyBindings;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import fr.thesmyler.terramap.maps.raster.MapStylesLibrary;
import fr.thesmyler.terramap.maps.raster.TiledMapProvider;
import fr.thesmyler.terramap.maps.raster.imp.TerrainPreviewMap;
Expand Down Expand Up @@ -69,8 +69,8 @@ public class TerramapClientContext {
private TerrainPreview terrainPreview = null;
private boolean isRegisteredForUpdates = false;
private String tpCommand = null;
private final Map<String, IRasterTiledMap> serverMaps = new HashMap<>();
private final Map<String, IRasterTiledMap> proxyMaps = new HashMap<>();
private final Map<String, RasterTiledMap> serverMaps = new HashMap<>();
private final Map<String, RasterTiledMap> proxyMaps = new HashMap<>();
private boolean proxyHasWarpSupport = false;
private boolean serverHasWarpSupport = false;
private boolean allowPlayerRadar = true;
Expand Down Expand Up @@ -205,19 +205,19 @@ public void resetWorld() {
HudScreenHandler.updateMinimap();
}

public Map<String, IRasterTiledMap> getServerMapStyles() {
public Map<String, RasterTiledMap> getServerMapStyles() {
return this.serverMaps;
}

public Map<String, IRasterTiledMap> getProxyMapStyles() {
public Map<String, RasterTiledMap> getProxyMapStyles() {
return this.proxyMaps;
}

/**
* @return a new Map containing all available mapstyles
*/
public Map<String, IRasterTiledMap> getMapStyles() {
Map<String, IRasterTiledMap> maps = new HashMap<>();
public Map<String, RasterTiledMap> getMapStyles() {
Map<String, RasterTiledMap> maps = new HashMap<>();
maps.putAll(MapStylesLibrary.getBaseMaps());
maps.putAll(this.proxyMaps);
maps.putAll(this.serverMaps);
Expand Down Expand Up @@ -466,7 +466,7 @@ public boolean isOnEarthWorld() {
}

public void setupMaps() {
for(IRasterTiledMap map: this.getMapStyles().values()) {
for(RasterTiledMap map: this.getMapStyles().values()) {
map.setup();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
import fr.thesmyler.terramap.TerramapConfig;
import fr.thesmyler.terramap.gui.screens.config.TerramapConfigScreen;
import fr.thesmyler.terramap.gui.widgets.CircularCompassWidget;
import fr.thesmyler.terramap.gui.widgets.map.layer.RasterMapLayer;
import fr.thesmyler.terramap.gui.widgets.markers.controllers.FeatureVisibilityController;
import fr.thesmyler.terramap.gui.widgets.markers.markers.Marker;
import fr.thesmyler.terramap.gui.widgets.markers.markers.entities.MainPlayerMarker;
import fr.thesmyler.terramap.input.KeyBindings;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import fr.thesmyler.terramap.maps.raster.TiledMapProvider;
import net.buildtheearth.terraplusplus.projection.GeographicProjection;
import net.buildtheearth.terraplusplus.projection.OutOfProjectionBoundsException;
Expand Down Expand Up @@ -401,7 +400,7 @@ public void onUpdate() {
debugBuilder.append(String.format(locale, "\nSledgehammer: %s", srv.getSledgehammerVersion()));
debugBuilder.append(String.format(locale, "\nProjection: %s", generationSettings != null ? generationSettings.projection() : null));
this.map.getRasterBackgroundLayer().ifPresent(layer -> {
IRasterTiledMap backgroundStyle = layer.getTiledMap();
RasterTiledMap backgroundStyle = layer.getTiledMap();
debugBuilder.append(String.format(locale, "\nMap id: %s", backgroundStyle.getId()));
debugBuilder.append(String.format(locale, "\nMap provider: %sv%s", backgroundStyle.getProvider(), backgroundStyle.getProviderVersion()));
if (backgroundStyle instanceof CachingRasterTiledMap) {
Expand Down Expand Up @@ -437,7 +436,7 @@ private void setZoomRestrictions() {
double maxZoom = 25;
double zoom = controller.getZoom();
if (backgroundLayer.isPresent()) {
IRasterTiledMap style = backgroundLayer.get().getTiledMap();
RasterTiledMap style = backgroundLayer.get().getTiledMap();
minZoom = style.getMinZoom();
if (!TerramapConfig.CLIENT.unlockZoom) {
maxZoom = style.getMaxZoom();
Expand Down Expand Up @@ -569,9 +568,9 @@ private class BackgroundStylePanelListContainer extends FlexibleWidgetContainer
this.addWidget(w);
lw = w;
}
ArrayList<IRasterTiledMap> maps = new ArrayList<>(TerramapClientContext.getContext().getMapStyles().values());
ArrayList<RasterTiledMap> maps = new ArrayList<>(TerramapClientContext.getContext().getMapStyles().values());
maps.sort((m1, m2) -> Integer.compare(m2.getDisplayPriority(), m1.getDisplayPriority()));
for(IRasterTiledMap map: maps) {
for(RasterTiledMap map: maps) {
MapPreview w = new MapPreview(50, map, m -> {
TerramapScreen.this.map.getRasterBackgroundLayer().ifPresent(l -> {
l.setTiledMap(m.previewLayer.getTiledMap());
Expand Down Expand Up @@ -699,7 +698,7 @@ private class MapPreview extends MapWidget {
final Consumer<MapPreview> onClick;
final OnlineRasterMapLayer previewLayer;

public MapPreview(int z, IRasterTiledMap map, Consumer<MapPreview> onClick) {
public MapPreview(int z, RasterTiledMap map, Consumer<MapPreview> onClick) {
super(z, MapContext.PREVIEW, TerramapScreen.this.map.getTileScaling());
this.setInteractive(false);
this.setRightClickMenuEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import fr.thesmyler.terramap.gui.widgets.markers.controllers.PlayerDirectionsVisibilityController;
import fr.thesmyler.terramap.gui.widgets.markers.controllers.PlayerNameVisibilityController;
import fr.thesmyler.terramap.gui.widgets.markers.markers.Marker;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import net.buildtheearth.terraplusplus.projection.GeographicProjection;
import net.buildtheearth.terraplusplus.projection.OutOfProjectionBoundsException;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -67,8 +67,8 @@ public HudConfigScreen() {
final MapController controller = this.minimap.getController();
List<MapStyleSliderEntry> maps = new ArrayList<>();
TerramapClientContext.getContext().getMapStyles().values().stream()
.sorted(((Comparator<IRasterTiledMap>)IRasterTiledMap::compareTo).reversed())
.filter(IRasterTiledMap::isAllowedOnMinimap)
.sorted(((Comparator<RasterTiledMap>) RasterTiledMap::compareTo).reversed())
.filter(RasterTiledMap::isAllowedOnMinimap)
.forEachOrdered(m -> maps.add(new MapStyleSliderEntry(m)));
this.mapStyles = maps.toArray(this.mapStyles);
this.styleSlider = new OptionSliderWidget<>(0, 0, 15, 10, this.mapStyles);
Expand Down Expand Up @@ -370,8 +370,8 @@ public void draw(float x, float y, float mouseX, float mouseY, boolean screenHov
}

private static class MapStyleSliderEntry {
private final IRasterTiledMap map;
private MapStyleSliderEntry(IRasterTiledMap map) {
private final RasterTiledMap map;
private MapStyleSliderEntry(RasterTiledMap map) {
this.map = map;
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import fr.thesmyler.terramap.gui.screens.LayerRenderingOffsetPopup;
import fr.thesmyler.terramap.gui.widgets.map.layer.McChunksLayer;
import fr.thesmyler.terramap.gui.widgets.map.layer.OnlineRasterMapLayer;
import fr.thesmyler.terramap.gui.widgets.map.layer.RasterMapLayer;
import fr.thesmyler.terramap.gui.widgets.markers.controllers.*;
import fr.thesmyler.terramap.gui.widgets.markers.markers.Marker;
import fr.thesmyler.terramap.maps.SavedMapState;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import net.buildtheearth.terraplusplus.projection.GeographicProjection;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
Expand Down Expand Up @@ -92,7 +91,7 @@ private void loadState() {
double minZoom = 0d;
double maxZoom = 25d;
if (background.isPresent()) {
IRasterTiledMap style = TerramapClientContext.getContext().getMapStyles().get(TerramapConfig.CLIENT.minimap.style);
RasterTiledMap style = TerramapClientContext.getContext().getMapStyles().get(TerramapConfig.CLIENT.minimap.style);
OnlineRasterMapLayer layer = background.get();
if (style != null) {
layer.setTiledMap(style);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package fr.thesmyler.terramap.gui.widgets.map.layer;

import fr.thesmyler.smylibgui.SmyLibGui;
import fr.thesmyler.smylibgui.container.FlexibleWidgetContainer;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import fr.thesmyler.terramap.maps.raster.imp.TerrainPreviewMap;

import static fr.thesmyler.smylibgui.SmyLibGui.getTranslator;
Expand Down Expand Up @@ -32,7 +31,7 @@ public FlexibleWidgetContainer createConfigurationContainer() {
}

@Override
public IRasterTiledMap getTiledMap() {
public RasterTiledMap getTiledMap() {
return this.map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import fr.thesmyler.terramap.TerramapConfig;
import fr.thesmyler.terramap.gui.widgets.map.MapController;
import fr.thesmyler.terramap.gui.widgets.map.MapWidget;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import fr.thesmyler.terramap.maps.raster.imp.ColorTiledMap;
import fr.thesmyler.terramap.util.CopyrightHolder;
import net.minecraft.util.text.ITextComponent;
Expand All @@ -35,13 +35,13 @@

public class OnlineRasterMapLayer extends RasterMapLayer implements CopyrightHolder {

protected IRasterTiledMap tiledMap = new ColorTiledMap(Color.WHITE, "Empty map");
protected RasterTiledMap tiledMap = new ColorTiledMap(Color.WHITE, "Empty map");

public IRasterTiledMap getTiledMap() {
public RasterTiledMap getTiledMap() {
return this.tiledMap;
}

public void setTiledMap(IRasterTiledMap map) {
public void setTiledMap(RasterTiledMap map) {
this.tiledMap = map;
this.getMap().updateCopyright();
}
Expand All @@ -66,7 +66,7 @@ public void loadSettings(JsonObject json) {
try {
JsonPrimitive primitiveValue = json.getAsJsonPrimitive("style");
String styleId = primitiveValue.getAsString();
IRasterTiledMap tiledMap = TerramapClientContext.getContext().getMapStyles().get(styleId);
RasterTiledMap tiledMap = TerramapClientContext.getContext().getMapStyles().get(styleId);
if (tiledMap != null) {
this.setTiledMap(tiledMap);
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public FlexibleWidgetContainer createConfigurationContainer() {

class StyleEntry extends WidgetContainer {

final IRasterTiledMap style;
final RasterTiledMap style;

final TextWidget nameText;
final TextWidget infoText;
Expand All @@ -117,7 +117,7 @@ class StyleEntry extends WidgetContainer {

final Animation backgroundColorAnimation = new Animation(200);

public StyleEntry(IRasterTiledMap style) {
public StyleEntry(RasterTiledMap style) {
super(0);
this.style = style;
float y = margin;
Expand Down Expand Up @@ -233,7 +233,7 @@ public float getHeight() {
FlexibleWidgetContainer container = new FlexibleWidgetContainer(0f, 0f, 0, width, 200f);
List<StyleEntry> styles = TerramapClientContext.getContext().getMapStyles().values()
.stream()
.sorted(comparing(IRasterTiledMap::getDisplayPriority).reversed())
.sorted(comparing(RasterTiledMap::getDisplayPriority).reversed())
.map(s -> new StyleEntry(s))
.collect(toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import fr.thesmyler.smylibgui.util.*;
import fr.thesmyler.terramap.gui.widgets.map.MapLayer;
import fr.thesmyler.terramap.gui.widgets.map.MapWidget;
import fr.thesmyler.terramap.maps.raster.IRasterTile;
import fr.thesmyler.terramap.maps.raster.IRasterTiledMap;
import fr.thesmyler.terramap.maps.raster.RasterTile;
import fr.thesmyler.terramap.maps.raster.RasterTiledMap;
import fr.thesmyler.terramap.maps.raster.imp.UrlRasterTile;
import fr.thesmyler.terramap.util.geo.*;
import fr.thesmyler.terramap.util.geo.TilePos.InvalidTilePositionException;
Expand All @@ -24,7 +24,7 @@

abstract public class RasterMapLayer extends MapLayer {

protected Set<IRasterTile> lastNeededTiles = new HashSet<>();
protected Set<RasterTile> lastNeededTiles = new HashSet<>();

// Used for calculations
private final Vec2dMutable top = new Vec2dMutable();
Expand All @@ -37,7 +37,7 @@ abstract public class RasterMapLayer extends MapLayer {
private Vec2dReadOnly renderingSpaceDimensions;
private Vec2dReadOnly halfRenderingSpaceDimensions;

public abstract IRasterTiledMap getTiledMap();
public abstract RasterTiledMap getTiledMap();

@Override
protected void initialize() {
Expand All @@ -50,15 +50,15 @@ protected void initialize() {
@Override
public void draw(float x, float y, float mouseX, float mouseY, boolean hovered, boolean focused, WidgetContainer parent) {

final IRasterTiledMap tiledMap = this.getTiledMap();
final RasterTiledMap tiledMap = this.getTiledMap();

Font smallFont = Util.getSmallestFont();
Minecraft mc = Minecraft.getMinecraft();
TextureManager textureManager = mc.getTextureManager();
float rotation = this.getRotation();

boolean perfectDraw = true;
Set<IRasterTile> neededTiles = new HashSet<>();
Set<RasterTile> neededTiles = new HashSet<>();

MapWidget parentMap = (MapWidget) parent;
boolean debug = parentMap.isDebugMode();
Expand Down Expand Up @@ -98,14 +98,14 @@ public void draw(float x, float y, float mouseX, float mouseY, boolean hovered,

for(int tileY = lowerTileY; tileY * renderSize < maxY; tileY++) {

IRasterTile tile;
RasterTile tile;

try {
tile = tiledMap.getTile(zoomLevel, Math.floorMod(tileX, maxTileXY), tileY);
} catch(InvalidTilePositionException silenced) { continue ;}

// This is the tile we would like to render, but it is not possible if it hasn't been cached yet
IRasterTile bestTile = tile;
RasterTile bestTile = tile;
double dispX = tileX * renderSize - upperLeft.x();
double dispY = tileY * renderSize - upperLeft.y();
double displayWidth = Math.min(renderSize, maxX - tileX * renderSize);
Expand Down Expand Up @@ -270,7 +270,7 @@ public void draw(float x, float y, float mouseX, float mouseY, boolean hovered,
}
if(perfectDraw) parentMap.discardPreviousErrors(this);
this.lastNeededTiles.removeAll(neededTiles);
this.lastNeededTiles.forEach(IRasterTile::cancelTextureLoading);
this.lastNeededTiles.forEach(RasterTile::cancelTextureLoading);
this.lastNeededTiles = neededTiles;

GlStateManager.popMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @param <T> The type of tile handled by this map
*/
public abstract class CachingRasterTiledMap<T extends IRasterTile> implements IRasterTiledMap {
public abstract class CachingRasterTiledMap<T extends RasterTile> implements RasterTiledMap {

private final LinkedList<T> tileList; // Uses for ordered access when unloading
private final Map<TilePosImmutable, T> tileMap; // Used for unordered access
Expand Down Expand Up @@ -181,7 +181,7 @@ public void setUseLowZoom(boolean yesNo) {
}

@Override
public int compareTo(IRasterTiledMap other) {
public int compareTo(RasterTiledMap other) {
return Integer.compare(this.getDisplayPriority(), other.getDisplayPriority());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MapStylesLibrary {

private static final String BUILT_IN_MAPS = "assets/terramap/mapstyles.json";
private static File configMapsFile;
private static final Map<String, IRasterTiledMap> baseMaps = new HashMap<>();
private static final Map<String, RasterTiledMap> baseMaps = new HashMap<>();
private static final Map<String, UrlTiledMap> userMaps = new HashMap<>();

/**
Expand All @@ -42,7 +42,7 @@ public class MapStylesLibrary {
*
* @return a new map that contains id => TiledMap couples
*/
public static Map<String, IRasterTiledMap> getBaseMaps() {
public static Map<String, RasterTiledMap> getBaseMaps() {
return new HashMap<>(baseMaps);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fr.thesmyler.terramap.util.geo.TilePosImmutable;
import net.minecraft.util.ResourceLocation;

public interface IRasterTile {
public interface RasterTile {

boolean isTextureAvailable();

Expand Down
Loading

0 comments on commit 0635f73

Please sign in to comment.