From 68997e36aa9103c09b41bf7fe02729906746f35b Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 24 Apr 2015 16:56:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D0=BB=D0=BE?= =?UTF-8?q?=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annimon/everlastingsummer/MapPlaces.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/com/annimon/everlastingsummer/MapPlaces.java diff --git a/src/com/annimon/everlastingsummer/MapPlaces.java b/src/com/annimon/everlastingsummer/MapPlaces.java new file mode 100644 index 0000000..1bc7ea8 --- /dev/null +++ b/src/com/annimon/everlastingsummer/MapPlaces.java @@ -0,0 +1,60 @@ +package com.annimon.everlastingsummer; + +import java.util.HashMap; +import java.util.Map; +import android.content.Context; +import android.content.DialogInterface; + +/** + * Места на карте. + * @author aNNiMON + */ +public class MapPlaces { + + /** Маппинг <игровое названия, полное название> */ + protected final Map names; + + protected Map zones; + protected String currentZone; + + public MapPlaces() { + names = new HashMap(); + zones = new HashMap(); + currentZone = ""; + } + + public void disableAllZones() { + zones.clear(); + currentZone = ""; + } + + public void disableCurrentZone() { + zones.remove(currentZone); + } + + public void setZone(String name, String label) { + zones.put(name, label); + } + + public void showMap(Context context) { + final int size = zones.size(); + final String[] zoneKeys = new String[size]; + final String[] zoneNames = new String[size]; + int i = 0; + for (Map.Entry zone : zones.entrySet()) { + final String key = zone.getKey(); + zoneKeys[i] = key; + zoneNames[i] = names.containsKey(key) ? names.get(key) : key; + i++; + } + Dialogs.with(context).showMapMenu(zoneNames, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + currentZone = zoneKeys[which]; + Parser.getInstance().jumpLabel(zones.get(currentZone)); + Parser.getInstance().next(); + } + }); + } +}