public static void SetCurrSheet(ADMSheet sheet, bool refresh = true) { currSheet = sheet; selected = 0; if (refresh) { RefreshWindow(); } }
public static void AddSheet(ADMSheet sheet, bool selectThis = true) { if (sheet == null || sheets.Contains(sheet)) { return; } Action callback = () => SetCurrSheet(sheet); sheet.callback = callback; sheets.Add(sheet); visible = ShowImmediately.Value; if (selectThis) { SetCurrSheet(sheet, false); } RefreshWindow(); }
public static bool IsSheet(ADMSheet sheet) { return(currSheet == sheet); }
public static void Draw(int id) { GUILayout.BeginArea(new Rect(MARGIN_LEFT, MARGIN_TOP, innerWidth, innerHeight)); if (visible) { GUILayout.BeginHorizontal(); { List <ADMSheet> list = currSheet?.sheets ?? sheets; GUILayout.BeginVertical(GUILayout.Width(itemWidth)); { int trueMaxLength = list.Count; int maxLengthHalf = maxLength / 2; int maxLengthDiff = trueMaxLength - maxLength; int offset = 0; if (maxLength != list.Count && selected > maxLengthHalf) { offset = Mathf.Min(maxLengthDiff, selected - maxLengthHalf); } if (offset > 0) { if (Draw_More()) { selected = offset; } } else if (!Draw_Back()) { GUILayout.Label(""); } for (int i = offset; i < maxLength + offset; i++) { ADMSheet sheet = list[i]; if (sheet.Draw(i == selected, out int next)) { selected = i; sheet.Invoke(next); } } if (maxLength + offset != trueMaxLength) { if (Draw_More()) { selected = maxLength + offset - 1; } } else if (!Draw_Back()) { GUILayout.Label(""); } GUILayout.Label( list[selected].description ?? "", descriptionBoxStyle, GUILayout.Width(itemWidth), GUILayout.Height(DESCRIPTION_HEIGHT) ); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }