Improve /f map by increasing the width and making the height much larger in case its a single view.

This commit is contained in:
Olof Larsson 2014-10-14 09:09:37 +02:00
parent e3785a1790
commit 2a827a28b1
6 changed files with 23 additions and 16 deletions

View File

@ -16,8 +16,10 @@ public class Const
public static final String ASPECT = BASENAME;
// ASCII Map
public static final int MAP_WIDTH = 47;
public static final int MAP_HEIGHT = 8;
public static final int MAP_WIDTH = 39;
public static final int MAP_HEIGHT_FULL = 17;
public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray();
}

View File

@ -1,5 +1,8 @@
package com.massivecraft.factions.cmd;
import java.util.List;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
@ -33,16 +36,16 @@ public class CmdFactionsMap extends FactionsCommand
@Override
public void perform()
{
if (!this.argIsSet(0))
if ( ! this.argIsSet(0))
{
showMap();
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
return;
}
if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating()))
{
// And show the map once
showMap();
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT);
// Turn on
msender.setMapAutoUpdating(true);
@ -56,9 +59,10 @@ public class CmdFactionsMap extends FactionsCommand
}
}
public void showMap()
public void showMap(int width, int height)
{
sendMessage(BoardColl.get().getMap(msenderFaction, PS.valueOf(me), me.getLocation().getYaw()));
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(me), me.getLocation().getYaw(), width, height);
sendMessage(message);
}
}

View File

@ -60,6 +60,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.ProjectileSource;
import com.massivecraft.factions.Const;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.TerritoryAccess;
@ -425,7 +426,8 @@ public class EngineMain extends EngineAbstract
// send host faction info updates
if (mplayer.isMapAutoUpdating())
{
mplayer.sendMessage(BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw()));
List<String> message = BoardColl.get().getMap(mplayer, chunkTo, player.getLocation().getYaw(), Const.MAP_WIDTH, Const.MAP_HEIGHT);
mplayer.sendMessage(message);
}
else if (factionFrom != factionTo)
{

View File

@ -289,7 +289,7 @@ public class Board extends Entity<Board> implements BoardInterface
// MAP GENERATION
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees)
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
{
centerPs = centerPs.getChunkCoords(true);
@ -298,14 +298,13 @@ public class Board extends Entity<Board> implements BoardInterface
ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getName(observer)));
int halfWidth = Const.MAP_WIDTH / 2;
int halfHeight = Const.MAP_HEIGHT / 2;
int halfWidth = width / 2;
int halfHeight = height / 2;
width = halfWidth * 2 + 1;
height = halfHeight * 2 + 1;
PS topLeftPs = centerPs.plusChunkCoords(-halfWidth, -halfHeight);
int width = halfWidth * 2 + 1;
int height = halfHeight * 2 + 1;
// Make room for the list of names
height--;

View File

@ -184,12 +184,12 @@ public class BoardColl extends Coll<Board> implements BoardInterface
// MAP GENERATION
@Override
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees)
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height)
{
if (centerPs == null) return null;
Board board = this.get(centerPs.getWorld());
if (board == null) return null;
return board.getMap(observer, centerPs, inDegrees);
return board.getMap(observer, centerPs, inDegrees, width, height);
}
// -------------------------------------------- //

View File

@ -36,6 +36,6 @@ public interface BoardInterface
// MAP
// TODO: Could the degrees be embedded in centerPs yaw instead?
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees);
public ArrayList<String> getMap(RelationParticipator observer, PS centerPs, double inDegrees, int width, int height);
}