http-api: add world region to World

Add a WorldRegion to convert from location id to region

Co-authored-by: melkypie <melkypie@users.noreply.github.com>
This commit is contained in:
Adam
2020-03-24 11:24:31 -04:00
committed by Adam
parent 32e435e42d
commit c930a5d261
4 changed files with 104 additions and 10 deletions

View File

@@ -43,6 +43,7 @@ import lombok.Getter;
import net.runelite.client.ui.FontManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.worlds.World;
import net.runelite.http.api.worlds.WorldRegion;
import net.runelite.http.api.worlds.WorldType;
class WorldTableRow extends JPanel
@@ -57,7 +58,6 @@ class WorldTableRow extends JPanel
private static final int PING_COLUMN_WIDTH = 35;
private static final Color CURRENT_WORLD = new Color(66, 227, 17);
private static final Color UNAVAILABLE_WORLD = Color.GRAY.darker().darker();
private static final Color DANGEROUS_WORLD = new Color(251, 62, 62);
private static final Color TOURNAMENT_WORLD = new Color(79, 145, 255);
private static final Color MEMBERS_WORLD = new Color(210, 193, 53);
@@ -326,26 +326,36 @@ class WorldTableRow extends JPanel
worldField = new JLabel(world.getId() + "");
JLabel flag = new JLabel(getFlag(world.getLocation()));
column.add(flag, BorderLayout.WEST);
ImageIcon flagIcon = getFlag(world.getRegion());
if (flagIcon != null)
{
JLabel flag = new JLabel(flagIcon);
column.add(flag, BorderLayout.WEST);
}
column.add(worldField, BorderLayout.CENTER);
return column;
}
private ImageIcon getFlag(int locationId)
private static ImageIcon getFlag(WorldRegion region)
{
switch (locationId)
if (region == null)
{
case 0:
return null;
}
switch (region)
{
case UNITED_STATES_OF_AMERICA:
return FLAG_US;
case 1:
case UNITED_KINGDOM:
return FLAG_UK;
case 3:
case AUSTRALIA:
return FLAG_AUS;
default:
case GERMANY:
return FLAG_GER;
default:
return null;
}
}
}