public void setupLS(DBStorePanel ls) { ls.selection = 0; ls.buttonHeight = LSButtonHeight; ls.buttonWidth = LSButtonWidth; ls.xPad = LSxPad; ls.yPad = LSyPad; ls.navButtonWidth = ls.buttonWidth / 2.0f; ls.navButtonHeight = ls.buttonHeight / 2.0f; ls.nextIcon = LSNextIcon; ls.prevIcon = LSPrevIcon; ls.r = new Rect(sPosX, sPosY + HHeight, LSWidth, LSHeight); ls.buttonsPerPage = (int)Mathf.Floor((ls.r.height - ls.titleHeight - ls.navButtonHeight - 2 * ls.yPad) / (ls.buttonHeight + ls.yPad)); ls.store = store; }
public void setupMD(DBStorePanel md) { md.selection = -1; md.buttonHeight = MDButtonHeight; md.buttonWidth = MDButtonWidth; md.xPad = MDxPad; md.yPad = MDyPad; md.checkedIcon = checkedIcon; md.lockedIcon = lockedIcon; md.r = new Rect(sPosX + LSWidth, sPosY + HHeight, HWidth, LSHeight); md.columns = (int)Mathf.Floor((md.r.width - md.xPad) / (md.buttonWidth + md.xPad)); md.rows = (int)Mathf.Floor((md.r.height - md.titleHeight - md.yPad) / (md.buttonHeight - md.yPad)); md.content = null; md.store = store; }
public static int DisplayMD(DBStorePanel cfg, int sel, HeaderModes mode) { int clicked = -1; string msg; //used to hold temporary string messages GUIContent gc; GUILayout.BeginArea(cfg.r); GUI.Box(new Rect(0, 0, cfg.r.width, cfg.r.height), ""); if (cfg.content == null) { GUILayout.EndArea(); return(clicked); } GUILayout.BeginVertical(); GUILayout.Space(cfg.yPad); if (cfg.content.Length == 0) { DrawLabelHCenter("Slot: " + cfg.store.slotInfo.slotName[sel]); GUILayout.Space(20); DrawLabelHCenter("You Don't Own any Weapons For This Slot"); GUILayout.EndVertical(); GUILayout.EndArea(); return(clicked); } else { if (mode == HeaderModes.Equip) { DrawLabelHCenter("Slot: " + cfg.store.slotInfo.slotName[sel]); } } int count = 0; int cl = -1; for (int i = 0; i < cfg.rows; i++) { GUILayout.BeginHorizontal(); GUILayout.Space(cfg.xPad); for (int j = 0; j < cfg.columns; j++) { if (count >= cfg.content.Length) { break; } // TODO: Something is wrong. this is always false. if (HeaderModes.Buy != 0 && cfg.wi[count].owned) { msg = cfg.content[count]; } else { msg = cfg.content[count] + "\n$" + cfg.wi[count].buyPrice; } gc = setGUIContent(cfg.wi[count].icon, msg, ""); if (GUILayout.Button(gc, GUILayout.Width(cfg.buttonWidth), GUILayout.Height(cfg.buttonHeight))) { clicked = count; } // now draw the overlay icons if the weapon is owned or locked when in buy mode // and equipped in slot in equip mode Rect r = GUILayoutUtility.GetLastRect(); if (mode == HeaderModes.Equip) { if ((cfg.store.playerW.weapons[sel] == cfg.wi[count].gameObject) && cfg.checkedIcon) { GUI.Label(r, cfg.checkedIcon); } } else { if (cfg.wi[count].owned && cfg.checkedIcon) { GUI.Label(r, cfg.checkedIcon); } if (cfg.wi[count].locked && cfg.lockedIcon) { GUI.Label(r, cfg.lockedIcon); } } count++; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndArea(); return(clicked); }
public static int DisplayLS(DBStorePanel cfg) { // function to display Left Selection Box int clicked = -1; //local variable to keep track of selections int startInt = ((cfg.page - 1) * cfg.buttonsPerPage); int endInt = Mathf.Min(startInt + cfg.buttonsPerPage, cfg.content.Length); GUILayout.BeginArea(cfg.r); GUI.Box(new Rect(0, 0, cfg.r.width, cfg.r.height), ""); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(cfg.title, GUILayout.Height(cfg.titleHeight)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); for (int i = startInt; i < endInt; i++) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (cfg.contentIcon[i]) { if (GUILayout.Button(cfg.contentIcon[i], GUILayout.Width(cfg.buttonWidth), GUILayout.Height(cfg.buttonHeight))) { clicked = i; cfg.selection = i; } } else { if (GUILayout.Button(cfg.content[i], GUILayout.Width(cfg.buttonWidth), GUILayout.Height(cfg.buttonHeight))) { clicked = i; cfg.selection = i; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); float bx = cfg.r.width - cfg.navButtonWidth - cfg.xPad; float by = cfg.r.height - cfg.navButtonHeight - cfg.yPad; if (cfg.page < cfg.nPages) { if (cfg.nextIcon) { if (GUI.Button(new Rect(bx, by, cfg.navButtonWidth, cfg.navButtonHeight), cfg.nextIcon)) { cfg.page++; } } else { if (GUI.Button(new Rect(bx, by, cfg.navButtonWidth, cfg.navButtonHeight), "next")) { cfg.page++; } } } if (cfg.page > 1) { bx = cfg.xPad / 2.0f; if (cfg.prevIcon) { if (GUI.Button(new Rect(bx, by, cfg.navButtonWidth, cfg.navButtonHeight), cfg.prevIcon)) { cfg.page--; } } else { if (GUI.Button(new Rect(bx, by, cfg.navButtonWidth, cfg.navButtonHeight), "Prev")) { cfg.page--; } } } GUILayout.EndArea(); return(clicked); }
//Function to display the Header Panel for the store public static int DisplayHeader(DBStorePanel cfg) { int clicked = -1; Rect rect; GUIContent gc; GUILayout.BeginArea(cfg.r); GUI.Box(new Rect(0, 0, cfg.r.width, cfg.r.height), ""); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); gc = setGUIContent(cfg.titleIcon, cfg.title, ""); GUILayout.Label(gc, GUILayout.Height(cfg.titleHeight), GUILayout.Width(cfg.titleHeight / cfg.titleIcon.height * cfg.titleIcon.width)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); for (int i = 0; i < cfg.content.Length; i++) { if (GUILayout.Button(cfg.content[i], GUILayout.Width(cfg.buttonWidth), GUILayout.Height(cfg.buttonHeight))) { clicked = i; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Balance: $" + cfg.store.getBalance()); GUILayout.Space(5); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); string msg = ""; if (cfg.selection == (int)HeaderModes.Buy) { msg = "Owned"; } if (cfg.selection == (int)HeaderModes.Equip) { msg = "Equipped"; } GUILayout.BeginHorizontal(); GUILayout.Label(cfg.checkedIcon, GUILayout.Width(40), GUILayout.Height(20)); Rect r = GUILayoutUtility.GetLastRect(); r.x += 25; r.width += 15; GUI.Label(r, msg); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(cfg.lockedIcon, GUILayout.Width(40), GUILayout.Height(20)); r = GUILayoutUtility.GetLastRect(); r.x += 25; r.width += 10; GUI.Label(r, "Locked"); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndArea(); return(clicked); }