public static GaugeSet.ID decrement(this GaugeSet.ID id) { switch (id) { case GaugeSet.ID.STANDARD: return(GaugeSet.ID.SET3); case GaugeSet.ID.LAUNCH: return(GaugeSet.ID.STANDARD); case GaugeSet.ID.LAND: return(GaugeSet.ID.LAUNCH); case GaugeSet.ID.DOCK: return(GaugeSet.ID.LAND); case GaugeSet.ID.ORBIT: return(GaugeSet.ID.DOCK); case GaugeSet.ID.FLIGHT: return(GaugeSet.ID.ORBIT); case GaugeSet.ID.SET1: return(GaugeSet.ID.FLIGHT); case GaugeSet.ID.SET2: return(GaugeSet.ID.SET1); case GaugeSet.ID.SET3: return(GaugeSet.ID.SET2); default: return(GaugeSet.ID.CLIPBOARD); } }
private void CheckIndicatorClick(float x, float y, Rect bounds, GaugeSet.ID id) { if (x >= bounds.x && x < bounds.x + bounds.width && y >= bounds.y && y < bounds.y + bounds.height) { NanoGauges.configuration.SetGaugeSet(id); this.gauges.ReflectGaugeSetChange(); } }
public void CopySelectorPositionFrom(GaugeSet.ID id) { GaugeSet source = GaugeSetPool.instance.GetGaugeSet(id); Pair <int, int> position = source.GetWindowPosition(Constants.WINDOW_ID_GAUGE_SETS); foreach (GaugeSet set in GaugeSetPool.instance) { set.SetWindowPosition(Constants.WINDOW_ID_GAUGE_SETS, position); } }
private void ReadGaugeSets(BinaryReader reader) { int cnt = reader.ReadInt16(); for (int i = 0; i < cnt; i++) { GaugeSet.ID id = (GaugeSet.ID)reader.ReadInt16(); Log.Detail("loading gaugeset " + id); GaugeSet set = GaugeSetPool.instance.GetGaugeSet(id); ReadGaugeSet(reader, set); } }
private void GaugeSetButton(GaugeSet.ID id, String text) { Configuration config = NanoGauges.configuration; if (GUILayout.Toggle(id == config.GetGaugeSetId(), text, HighLogic.Skin.button)) { if (config.GetGaugeSetId() != id) { Log.Detail("gauge set in config changed to " + id); config.SetGaugeSet(id); gauges.ReflectGaugeSetChange(); } } }
public override void EnableGauges(GaugeSet set) { GaugeSet.ID id = set.GetId(); switch (id) { case GaugeSet.ID.STANDARD: standard.EnableGauges(set); return; case GaugeSet.ID.LAUNCH: launch.EnableGauges(set); return; case GaugeSet.ID.FLIGHT: flight.EnableGauges(set); return; case GaugeSet.ID.LAND: landing.EnableGauges(set); return; case GaugeSet.ID.DOCK: docking.EnableGauges(set); return; case GaugeSet.ID.ORBIT: orbiting.EnableGauges(set); return; case GaugeSet.ID.SET1: set1.EnableGauges(set); return; case GaugeSet.ID.SET2: set2.EnableGauges(set); return; case GaugeSet.ID.SET3: set3.EnableGauges(set); return; default: Log.Warning("unknown gauge sewt ID for layout: " + id); break; } }
private void ReadGaugeSets(BinaryReader reader) { // used for decluttering (i.e. show gauges hidden by other gauges) DefaultLayout layout = new DefaultLayout(NanoGauges.gauges, this); int cnt = reader.ReadInt16(); for (int i = 0; i < cnt; i++) { GaugeSet.ID id = (GaugeSet.ID)reader.ReadInt16(); Log.Detail("loading gaugeset " + id); GaugeSet set = GaugeSetPool.instance.GetGaugeSet(id); ReadGaugeSet(reader, set); if (declutterEnabled) { layout.Declutter(set); } } }
public void CopyToClipboard(GaugeSet.ID id) { GaugeSet set = GetGaugeSet(id); CopyToClipboard(set); }
public GaugeSet GetGaugeSet(GaugeSet.ID id) { return(sets[id]); }
public void SetGaugeSet(GaugeSet.ID set) { this.gaugeSet = set; currentGaugeSet = GaugeSetPool.instance.GetGaugeSet(set); }
private void DefineDefaultPosition(GaugeSet.ID set, int windowId, bool enabled, ORIGIN origin, int dx, int dy) { Dictionary <int, bool> enabledMap = defaultEnabledMap[set]; Dictionary <int, int> positionXMap = defaultPositionXMap[set]; Dictionary <int, int> positionYMap = defaultPositionYMap[set]; int LAYOUT_CELL_X = NanoGauges.configuration.verticalGaugeWidth + Gauges.LAYOUT_GAP; int LAYOUT_CELL_Y = NanoGauges.configuration.verticalGaugeHeight + Gauges.LAYOUT_GAP; int LAYOUT_RANGE_X = 3 * LAYOUT_CELL_X / 2; int LAYOUT_RANGE_Y = 3 * LAYOUT_CELL_Y / 2; enabledMap.Add(windowId, enabled); switch (origin) { case ORIGIN.RIGHTEDGE: { int x0 = Screen.width - LAYOUT_CELL_X; int y0 = Screen.height / 2; positionXMap.Add(windowId, x0 + dx); positionYMap.Add(windowId, y0 + dy); break; } case ORIGIN.BOTTOMRIGHT: { int x0 = Screen.width - LAYOUT_CELL_X; int y0 = Screen.height - LAYOUT_CELL_Y; positionXMap.Add(windowId, x0 + dx); positionYMap.Add(windowId, y0 + dy); break; } case ORIGIN.LEFTEDGE: { int y0 = Screen.height / 2; positionXMap.Add(windowId, dx); positionYMap.Add(windowId, y0 + dy); break; } case ORIGIN.TOPEDGE: { int x0 = Screen.width / 2; positionXMap.Add(windowId, x0 + dx); positionYMap.Add(windowId, dy); break; } case ORIGIN.BOTTOMEDGE: { int x0 = Screen.width / 2; int y0 = Screen.height - LAYOUT_CELL_Y; positionXMap.Add(windowId, x0 + dx); positionYMap.Add(windowId, y0 + dy); break; } case ORIGIN.NAVBALL: { int x0 = Screen.width / 2; int y0 = Screen.height - 200; positionXMap.Add(windowId, x0 + dx); positionYMap.Add(windowId, y0 + dy); break; } default: { Log.Warning("invalid origin in gauge set " + set + ", window id " + windowId); positionXMap.Add(windowId, dx); positionYMap.Add(windowId, dy); break; } } }
public bool GetDefaultEnabled(GaugeSet.ID set, int windowId) { return(true); }
public int GetDefaultY(GaugeSet.ID set, int windowId) { return(0); }
protected override void OnWindow(int id) { // skin GUI.DrawTexture(skinBounds, skin); // indicator GaugeSet.ID currentGaugeSet = NanoGauges.configuration.GetGaugeSetId(); Texture2D indicatorSkin = INDICATOR__ON_SKIN; if (NanoGauges.profileManager.enabled) { if (!NanoGauges.profileManager.IsProfileChangeLocked()) { indicatorSkin = INDICATOR__AUTO_SKIN; } else { indicatorSkin = INDICATOR__LOCKED_SKIN; } } switch (currentGaugeSet) { case GaugeSet.ID.STANDARD: GUI.DrawTexture(BOUNDS_INDICATOR_STD, indicatorSkin); break; case GaugeSet.ID.LAUNCH: GUI.DrawTexture(BOUNDS_INDICATOR_LAU, indicatorSkin); break; case GaugeSet.ID.LAND: GUI.DrawTexture(BOUNDS_INDICATOR_LAN, indicatorSkin); break; case GaugeSet.ID.DOCK: GUI.DrawTexture(BOUNDS_INDICATOR_DCK, indicatorSkin); break; case GaugeSet.ID.ORBIT: GUI.DrawTexture(BOUNDS_INDICATOR_ORB, indicatorSkin); break; case GaugeSet.ID.FLIGHT: GUI.DrawTexture(BOUNDS_INDICATOR_FLT, indicatorSkin); break; case GaugeSet.ID.SET1: GUI.DrawTexture(BOUNDS_INDICATOR_S_1, indicatorSkin); break; case GaugeSet.ID.SET2: GUI.DrawTexture(BOUNDS_INDICATOR_S_2, indicatorSkin); break; case GaugeSet.ID.SET3: GUI.DrawTexture(BOUNDS_INDICATOR_S_3, indicatorSkin); break; } // Mouseclicks Event e = Event.current; if (e.type == EventType.MouseDown && e.button == 0) { float x = e.mousePosition.x; float y = e.mousePosition.y; CheckIndicatorClick(x, y, BOUNDS_INDICATOR_STD, GaugeSet.ID.STANDARD); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_LAU, GaugeSet.ID.LAUNCH); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_LAN, GaugeSet.ID.LAND); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_DCK, GaugeSet.ID.DOCK); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_ORB, GaugeSet.ID.ORBIT); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_FLT, GaugeSet.ID.FLIGHT); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_1, GaugeSet.ID.SET1); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_2, GaugeSet.ID.SET2); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_3, GaugeSet.ID.SET3); } }
protected override void OnWindow(int id) { // skin GUI.DrawTexture(skinBounds, skin); // indicator GaugeSet.ID currentGaugeSet = NanoGauges.configuration.GetGaugeSetId(); switch (currentGaugeSet) { case GaugeSet.ID.STANDARD: GUI.DrawTexture(BOUNDS_INDICATOR_STD, INDICATOR__ON_SKIN); break; case GaugeSet.ID.LAUNCH: GUI.DrawTexture(BOUNDS_INDICATOR_LAU, INDICATOR__ON_SKIN); break; case GaugeSet.ID.LAND: GUI.DrawTexture(BOUNDS_INDICATOR_LAN, INDICATOR__ON_SKIN); break; case GaugeSet.ID.DOCK: GUI.DrawTexture(BOUNDS_INDICATOR_DCK, INDICATOR__ON_SKIN); break; case GaugeSet.ID.ORBIT: GUI.DrawTexture(BOUNDS_INDICATOR_ORB, INDICATOR__ON_SKIN); break; case GaugeSet.ID.FLIGHT: GUI.DrawTexture(BOUNDS_INDICATOR_FLT, INDICATOR__ON_SKIN); break; case GaugeSet.ID.SET1: GUI.DrawTexture(BOUNDS_INDICATOR_S_1, INDICATOR__ON_SKIN); break; case GaugeSet.ID.SET2: GUI.DrawTexture(BOUNDS_INDICATOR_S_2, INDICATOR__ON_SKIN); break; case GaugeSet.ID.SET3: GUI.DrawTexture(BOUNDS_INDICATOR_S_3, INDICATOR__ON_SKIN); break; } // Mouseclicks Event e = Event.current; if (e.type == EventType.MouseDown && e.button == 0) { float x = e.mousePosition.x; float y = e.mousePosition.y; CheckIndicatorClick(x, y, BOUNDS_INDICATOR_STD, GaugeSet.ID.STANDARD); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_LAU, GaugeSet.ID.LAUNCH); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_LAN, GaugeSet.ID.LAND); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_DCK, GaugeSet.ID.DOCK); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_ORB, GaugeSet.ID.ORBIT); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_FLT, GaugeSet.ID.FLIGHT); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_1, GaugeSet.ID.SET1); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_2, GaugeSet.ID.SET2); CheckIndicatorClick(x, y, BOUNDS_INDICATOR_S_3, GaugeSet.ID.SET3); } }
private void SetGaugeSet(GaugeSet.ID id) { Log.Detail("SetGaugeSet to " + id); configuration.SetGaugeSet(id); gauges.ReflectGaugeSetChange(); }
public bool IsCurrentGaugeSet(GaugeSet.ID id) { return(currentGaugeSet.GetId() == id); }