OSDN Git Service

indentation
[automap/automap.git] / Automap / AutomapMod.cs
1 using Vintagestory.API.Client;
2 using Vintagestory.API.Common;
3
4
5
6 namespace Automap
7 {
8     public class AutomapMod : ModSystem
9     {
10         private ICoreAPI API { get; set; }
11         private ICoreClientAPI ClientAPI { get; set; }
12         private ILogger Logger { get; set; }
13         private AutomapSystem _localAutomap;
14         private AutomapGUIDialog _automapDialog;
15
16
17         public override bool ShouldLoad(EnumAppSide forSide)
18         {
19             return forSide.IsClient();
20         }
21
22         public override void StartClientSide(ICoreClientAPI api)
23         {
24             this.API = api;
25
26             if (api.Side == EnumAppSide.Client)
27             {
28                 this.ClientAPI = api as ICoreClientAPI;
29                 this.Logger = Mod.Logger;
30
31
32                 ClientAPI.Logger.VerboseDebug("Automap Present!");
33                 _localAutomap = new AutomapSystem(this.ClientAPI, this.Logger);
34                 _automapDialog = new AutomapGUIDialog(ClientAPI, _localAutomap);
35
36                 ClientAPI.Input.RegisterHotKey(AutomapGUIDialog._automapControlPanelKey, "Automap control panel", GlKeys.A, HotkeyType.GUIOrOtherControls);
37                 ClientAPI.Input.SetHotKeyHandler(AutomapGUIDialog._automapControlPanelKey, ToggleAM_Dialog);
38             }
39
40             base.StartClientSide(api);
41         }
42
43         public override double ExecuteOrder()
44         {
45             return 0.2;
46         }
47
48         private bool ToggleAM_Dialog(KeyCombination comb)
49         {
50             if (_automapDialog.IsOpened()) _automapDialog.TryClose();
51             else _automapDialog.TryOpen();
52
53             return true;
54         }
55
56
57     }
58 }
59