X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ftips%2FTipManager.java;fp=src%2Ftim%2Fprune%2Ftips%2FTipManager.java;h=24c12bc683f1a15f0573d871d85f77c3fed6f91b;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/tips/TipManager.java b/src/tim/prune/tips/TipManager.java new file mode 100644 index 0000000..24c12bc --- /dev/null +++ b/src/tim/prune/tips/TipManager.java @@ -0,0 +1,45 @@ +package tim.prune.tips; + +/** + * Class to manage the showing of tips according + * to the fixed TipDefinitions + */ +public abstract class TipManager +{ + public static final int Tip_UseAMapCache = 0; + public static final int Tip_LearnTimeParams = 1; + public static final int Tip_DownloadSrtm = 2; + public static final int Tip_UseSrtmFor3d = 3; + public static final int Tip_ManuallyCorrelateOne = 4; + private static final int Number_Tips = Tip_ManuallyCorrelateOne + 1; + + /** Array of tip definitions */ + private static TipDefinition[] TIPDEFS = new TipDefinition[Number_Tips]; + + /** Static block to initialise tip definitions */ + static + { + TIPDEFS[Tip_UseAMapCache] = new TipDefinition("tip.useamapcache", 150); + TIPDEFS[Tip_LearnTimeParams] = new TipDefinition("tip.learntimeparams"); + TIPDEFS[Tip_DownloadSrtm] = new TipDefinition("tip.downloadsrtm", 5); + TIPDEFS[Tip_UseSrtmFor3d] = new TipDefinition("tip.usesrtmfor3d"); + TIPDEFS[Tip_ManuallyCorrelateOne] = new TipDefinition("tip.manuallycorrelateone"); + } + + /** + * Fire a trigger for the specified tip and get the message key if tip should be shown + * @param inTipNumber number of tip from constants + * @return message key if a message should be shown, or null otherwise + */ + public static String fireTipTrigger(int inTipNumber) + { + try { + TipDefinition tip = TIPDEFS[inTipNumber]; + if (tip.shouldShowMessage()) { + return tip.getMessageKey(); + } + } + catch (ArrayIndexOutOfBoundsException obe) {} // unrecognised tip given + return null; + } +}