public StructureReusable(Rect drawRect, Texture iconTexture, string title, BlueprintDesign blueprintDesign) { igrList = new List <IconGroupReusable>(); labels = new List <string>(); this.iconTexture = iconTexture; this.title = title; this.blueprintDesign = blueprintDesign; titleStyle = GUIFunctions.GetStandardGUIStyle(12); titleStyle.alignment = TextAnchor.MiddleCenter; labelStyle = GUIFunctions.GetStandardGUIStyle(8); labelStyle.alignment = TextAnchor.MiddleLeft; titleHeight = titleStyle.CalcSize(new GUIContent("HEIGHT LAWL")).y; float iconSize = drawRect.height - titleHeight; iconRect = new Rect(0, 0, iconSize, iconSize); titleRect = new Rect(0, 0, drawRect.width, titleHeight); listRect = new Rect(iconRect.width, titleHeight, drawRect.width, iconRect.height); background = GUIFunctions.Get1x1Texture(new Color(0f, 1f, 1f, 0.5f)); BuildIGRList(); }
public Tooltip(Rect mouseRect, string tooltipID, string tooltipText) { this.mouseRect = mouseRect; this.tooltipID = tooltipID; this.tooltipText = GUIFunctions.MakeTextMultilined(tooltipText, 20); lastFrameCount = 0; }
private void Setup() { if (isSetup) { return; } gameObject.AddComponent <GUIManager> (); gameObject.AddComponent <ClickController> (); crew = player.GetComponent <Crew> (); ThingFactory.Setup(); GUIFunctions.Setup(); BlueprintDesignManager.Setup(); //setup structures that are already in scene foreach (StructureController sc in GameObject.FindObjectsOfType <StructureController>()) { sc.SetupRealStructure(); sc.SetAltitudeToMatchTerrain(); } isSetup = true; }
public PicNameStatusReusable(string label, Texture iconTexture) { this.iconTexture = iconTexture; this.label = label; textStyle = GUIFunctions.GetStandardGUIStyle(10); textStyle.alignment = TextAnchor.MiddleLeft; }
void Start() { fpsRect = new Rect(Screen.width / 50, 0, 100, 40); guiStyle = GUIFunctions.GetStandardGUIStyle(12); guiStyle.alignment = TextAnchor.MiddleLeft; StartCoroutine(CalculateFPS()); }
public ResourceReusable(ResourceTypes resourceType, string tooltipText) { this.resourceType = resourceType; this.tooltipText = tooltipText; valueStyle = GUIFunctions.GetStandardGUIStyle(16); valueStyle.alignment = TextAnchor.MiddleLeft; iconTexture = GetResourceTextureFromResourceType(resourceType); }
public IconGroupReusable(bool alwaysUseTextNumbers) { this.alwaysUseTextNumbers = alwaysUseTextNumbers; iconGroups = new List <IconGroup>(); textStyle = GUIFunctions.GetStandardGUIStyle(10); textStyle.alignment = TextAnchor.UpperRight; moreStyle = GUIFunctions.GetStandardGUIStyle(10); moreStyle.alignment = TextAnchor.MiddleLeft; }
private IntVector2 GetDragCoords() { //takes into account the position of the inventory window, and //its things, to find which icon coordinate the mouse is on. Vector2 mousePoint = GUIFunctions.GetGUIMousePositionFromInputMousePosition(); Vector2 point = new Vector2(mousePoint.x - windowRect.x - iconSize, mousePoint.y - windowRect.y - iconSize); return(new IntVector2(Mathf.FloorToInt(point.x / iconSize), Mathf.FloorToInt(point.y / iconSize))); }
public static Texture GetResourceTextureFromResourceType(ResourceTypes resourceType) { string iconName = GetIconNameFromResourceType(resourceType); string path = "gui/icons/" + iconName; Texture iconTexture = Resources.Load(path) as Texture; if (iconTexture == null) { iconTexture = GUIFunctions.Get1x1Texture(Color.black); Debug.LogError("ResourceReusable failed to load texture: " + path); } return(iconTexture); }
private void WindowFunction(int id) { for (int i = 0; i < resourceCount; i++) { resourceRect.x = i * windowRect.width / resourceCount; ResourceReusable resourceReusable = resourceReusables[i]; resourceReusable.Draw(resourceRect, ResourceController.GetResourceQuantityFromType(resourceReusable.resourceType)); Rect tooltipRect = GUIFunctions.AddRectAndRectCoords(resourceRect, windowRect); string stringID = "resource-" + i; TooltipManager.SetTooltip(stringID, tooltipRect, resourceReusable.tooltipText); } GUI.DragWindow(); }
void OnGUI() { //draw reticle Vector2 size = GUI.skin.label.CalcSize(new GUIContent("+")); Rect reticleRect = new Rect(0, 0, size.x, size.y); reticleRect.center = new Vector2(Screen.width, Screen.height) / 2f; GUI.Label(reticleRect, "+"); if (selectedThing != null) { GUIFunctions.DrawThing(selectedThingRect, selectedThing, true); GUI.Label(selectedLabelRect, selectedSlotIndex.ToString(), GUIFunctions.hotkeyStyle); GUI.Label(selectedNameRect, selectedThing.longName, GUIFunctions.hotkeyStyle); } }
private void WindowFunction(int id) { //GUI.Button(new Rect(10, 10, 50, 50), "button!!"); for (int i = 0; i < thingsPerRow; i++) { for (int j = 0; j < rowCount; j++) { Rect rect = thingIconRects [i, j]; if (j == rowCount - 1) { GUI.Label(rect, (i + 1).ToString(), GUIFunctions.hotkeyStyle); } Thing thing = things [i + j * thingsPerRow]; if (thing == null) { GUI.DrawTexture(rect, Thing.GetFrameInventoryTexture()); } else { GUIFunctions.DrawThing(rect, thing, true); Rect tooltipRect = GUIFunctions.AddRectAndRectCoords(rect, windowRect); TooltipManager.SetTooltip(thingTooltipIDs [i, j], tooltipRect, thing.longName); } } } if (dragThing == null) { GUI.DragWindow(); } else { Rect rect = new Rect(Input.mousePosition.x - iconSize / 2 - windowRect.x, Screen.height - Input.mousePosition.y - iconSize / 2 - windowRect.y, iconSize, iconSize); if (dragThing.isBlueprint) { GUIFunctions.DrawThing(rect, dragThing, true); } else { GUIFunctions.DrawThing(rect, dragThing, false); } } }
private int GetMouseHoverListIndex() { Vector2 mousePosition = GUIFunctions.GetMousePositionFromInputMousePosition(); float relativeX = mousePosition.x - scrollRect.x - windowRect.x; if (relativeX < 0 || relativeX > scrollRect.width - GUIFunctions.verticalBarWidth) { return(-1); } float relativeY = mousePosition.y - scrollRect.y - windowRect.y + scrollPosition.y; if (relativeY > 0 && relativeY < viewRect.height) { return(Mathf.FloorToInt(relativeY / selectedRect.height)); } return(-1); }
public StructuresWindow() { //used in every toolbar window to make a unique id windowId = Toolbar.GetNextWindowID(); scrollPosition = Vector2.zero; windowRect = new Rect(0, 0, Screen.width / 2, Screen.height * 2 / 3); windowRect = new Rect(Screen.width / 2 - windowRect.width / 2, Screen.height / 2 - windowRect.height / 2, windowRect.width, windowRect.height); scrollRect = new Rect(GUIFunctions.margin, GUIFunctions.heightOfWindowBar, windowRect.width - GUIFunctions.margin * 2, windowRect.height - GUIFunctions.heightOfWindowBar - GUIFunctions.margin); rowHeight = Screen.height / 20; cellRect = new Rect(0, 0, Screen.width / 6, rowHeight); bigCellRect = new Rect(0, 0, Screen.width / 4, rowHeight); tinyCellRect = new Rect(0, 0, Screen.width / 8, rowHeight); rowStyle = GUIFunctions.GetStandardGUIStyle(10); rowStyle.alignment = TextAnchor.MiddleLeft; }
void Update() { Vector3 mousePosition = GUIFunctions.GetGUIMousePositionFromInputMousePosition(); if (currentTooltip == null) { //no tooltip was hovered over recently. //check all tooltips if we're hovering over them foreach (Tooltip tooltip in tooltips.Values) { if (tooltip.mouseRect.Contains(mousePosition)) { currentTooltip = tooltip; break; } } } else if (currentTooltip.lastFrameCount < Time.frameCount - 1) { //this means SetTooltip wasn't called recently and the tooltip shouldn't display anymore. RemoveTooltip(currentTooltip.tooltipID); currentTooltip = null; } else { //we were just hovering over a tooltip that is still active. //are we still hovering? if (currentTooltip.mouseRect.Contains(mousePosition)) { timeCount += Time.deltaTime; } else { timeCount = 0; currentTooltip = null; } } }
void Start() { tooltipStyle = GUIFunctions.GetStandardGUIStyle(12); tooltipStyle.alignment = TextAnchor.MiddleCenter; tooltipStyle.normal.background = GUIFunctions.Get1x1Texture(new Color(0, .8f, .8f, 0.8f)); }