private void DrawParameterFields(GUIStyle style) { style.alignment = TextAnchor.UpperRight; style.font = font; style.fontSize = 14; Color savedColor = GUI.color; Color savedBkgdColor = GUI.backgroundColor; if (currAttempt != null && currAttempt.seriesParams.Count > 0) { int paramCnt = currAttempt.seriesParams.Count; int row = 0; int col = 0; float entryHeight = height - heightGraph - 30 * 3 - bufferBorder * 2; GUI.BeginGroup(new Rect(bufferBorder, topGraph + heightGraph + bufferBorder, width, entryHeight)); //use seriesNodes to force order foreach (int nodeId in manager.seriesNodes) { //look for all possible parameter types for each node foreach (char paramId in new char[] { 'K', 'R', 'X' }) { string strId = paramId.ToString(); ConvergeParam param; string nodeIdParamId = ConvergeParam.NodeIdParamId(nodeId, strId); if (currAttempt.seriesParams.ContainsKey(nodeIdParamId)) { param = currAttempt.seriesParams [nodeIdParamId]; } else { continue; } float min = 0f; float max = 1f; switch (paramId) { case 'K': min = 1000f; max = 15000f; break; case 'R': min = 0f; max = 3f; break; default: break; } Rect labelRect; //draw name, paramId labelRect = new Rect(col * (350 + bufferBorder), row * 35, 250, 30); if (labelRect.Contains(Event.current.mousePosition)) { manager.mouseOverLabels.Add(param.name); manager.selected = param.name; manager.lastSeriesToDraw = param.name; } GUI.color = (param.name.Equals(manager.selected)) ? manager.seriesColors [param.name] : Color.white; GUI.Label(labelRect, param.name + " - " + param.paramId, style); //if player clicks on species, set as selected and activate foodWeb if (GUI.Button(labelRect, "", GUIStyle.none)) { foodWeb.selected = SpeciesTable.GetSpeciesName(param.name); foodWeb.SetActive(true, foodWeb.selected); } //draw slider with underlying colored bar showing original value Rect sliderRect = new Rect(labelRect.x + 250 + bufferBorder, labelRect.y + 5, 100, 20); if (sliderRect.Contains(Event.current.mousePosition)) { manager.mouseOverLabels.Add(param.name); manager.selected = param.name; manager.lastSeriesToDraw = param.name; } GUI.color = manager.seriesColors [param.name]; float origValWidth = ConvergeParam.NormParam(param.origVal, min, max, sliderRect.width); //float origValWidth = (param.origVal / (max - min)) * sliderRect.width; Color slTexture = new Color(0.85f, 0.85f, 0.85f); GUI.DrawTexture(new Rect(sliderRect.x, sliderRect.y, origValWidth, 10), //sliderRect.height), Functions.CreateTexture2D(slTexture)); // GUI.color = savedColor; //draw slider for parameter value manipulation GUI.backgroundColor = manager.seriesColors [param.name]; param.value = GUI.HorizontalSlider( sliderRect, param.value, min, max ); //show normalized value for parameter if (param.name.Equals(manager.selected)) { string valLabel = String.Format( "{0}", ConvergeParam.NormParam(param.value, min, max)); if (param.value != param.origVal) { valLabel = valLabel + String.Format( " [{0}]", ConvergeParam.NormParam(param.origVal, min, max)); } style.alignment = TextAnchor.UpperLeft; float xPosn = sliderRect.x + (param.value / (max - min)) * sliderRect.width + bufferBorder; Rect valRect = new Rect(xPosn, labelRect.y, 70, labelRect.height - 5); GUI.Box(valRect, valLabel); style.alignment = TextAnchor.UpperRight; } if ((row + 1) * 35 + 30 > entryHeight) { col++; row = 0; } else { row++; } GUI.color = savedColor; GUI.backgroundColor = savedBkgdColor; } } GUI.EndGroup(); } style.alignment = TextAnchor.UpperLeft; style.font = font; style.fontSize = 16; }
private void DrawParameterFields(GUIStyle style) { style.alignment = TextAnchor.UpperRight; style.font = font; style.fontSize = 14; Color temp = GUI.color; if (currAttempt != null && currAttempt.seriesParams.Count > 0) { int paramCnt = currAttempt.seriesParams.Count; int row = 0; int col = 0; float entryHeight = height - heightGraph - 30 * 3 - bufferBorder * 2; GUI.BeginGroup(new Rect(bufferBorder, topGraph + heightGraph + bufferBorder, width, entryHeight)); //use seriesNodes to force order foreach (int nodeId in manager.seriesNodes) { //look for all possible parameter types for each node foreach (char paramId in new char[] { 'K', 'R', 'X' }) { string strId = paramId.ToString(); ConvergeParam param; string nodeIdParamId = ConvergeParam.NodeIdParamId(nodeId, strId); if (currAttempt.seriesParams.ContainsKey(nodeIdParamId)) { param = currAttempt.seriesParams [nodeIdParamId]; } else { continue; } float min = 0f; float max = 1f; switch (paramId) { case 'K': min = 1000f; max = 15000f; break; case 'R': min = 0f; max = 3f; break; default: break; } Rect itemRect; //draw name, paramId itemRect = new Rect(col * (350 + bufferBorder), row * 35, 250, 30); if (itemRect.Contains(Event.current.mousePosition)) { manager.mouseOverLabels.Add(param.name); manager.selected = param.name; manager.lastSeriesToDraw = param.name; } style.normal.textColor = (param.name == manager.selected) ? manager.seriesColors [param.name] : Color.white; GUI.Label(itemRect, param.name + " - " + param.paramId, style); //if player clicks on species, set as selected and activate foodWeb if (GUI.Button(itemRect, "", GUIStyle.none)) { foodWeb.selected = SpeciesTable.GetSpeciesName(param.name); foodWeb.SetActive(true, foodWeb.selected); } //draw colored bar showing original value itemRect = new Rect(col * (350 + bufferBorder) + 250 + bufferBorder, row * 35 + 5, 100, 10); if (itemRect.Contains(Event.current.mousePosition)) { manager.mouseOverLabels.Add(param.name); manager.selected = param.name; manager.lastSeriesToDraw = param.name; } GUI.color = manager.seriesColors [param.name]; float origValWidth = (param.origVal / (max - min)) * itemRect.width; GUI.DrawTexture(new Rect(itemRect.x, itemRect.y, origValWidth, itemRect.height), Functions.CreateTexture2D(new Color(0.85f, 0.85f, 0.85f))); GUI.color = temp; //draw slider for parameter value manipulation GUI.backgroundColor = manager.seriesColors [param.name]; param.value = GUI.HorizontalSlider( itemRect, param.value, min, max ); GUI.backgroundColor = temp; if ((row + 1) * 35 + 30 > entryHeight) { col++; row = 0; } else { row++; } } } GUI.EndGroup(); } style.alignment = TextAnchor.UpperLeft; style.font = font; style.fontSize = 16; style.normal.textColor = temp; GUI.color = temp; }
public void DrawLegend() { legendRect = new Rect(left + (2 * widthGraph) + (2 * bufferGraph), top, widthLegend, height); legendScrollRect = new Rect( legendRect.width * 0.05f, bufferBorder, legendRect.width - bufferBorder * 2, legendRect.height - bufferBorder * 2 ); GUIStyle style = new GUIStyle(GUI.skin.label); style.richText = true; Texture2D markerTex = Functions.CreateTexture2D(new Color(0.85f, 0.85f, 0.85f)); Texture2D markerHoverTex = Functions.CreateTexture2D(Color.white); Color temp = GUI.color; GUI.BeginGroup(legendRect, GUI.skin.box); style.alignment = TextAnchor.UpperCenter; //GUI.color = Color.yellow; //GUI.Label (new Rect ((legendRect.width - 200) / 2, 10, 200, 30), "Legend", style); //GUI.color = temp; Rect scrollRect = new Rect(0, 0, legendScrollRect.width - 20, manager.seriesLabels.Count * 30); legendScrollPos = GUI.BeginScrollView(legendScrollRect, legendScrollPos, scrollRect); style.alignment = TextAnchor.UpperLeft; for (int i = 0; i < manager.seriesLabels.Count; i++) { Series series = graph1.seriesList [manager.seriesLabels [i]]; string label = series.label; Rect itemRect = new Rect(10, i * heightSeries, legendScrollRect.width * 0.8f, heightSeries); if (itemRect.Contains(Event.current.mousePosition)) { manager.selected = label; manager.lastSeriesToDraw = label; } // Marquee Effect if (label == manager.selected) { float textWidth = GUI.skin.label.CalcSize(new GUIContent(label)).x; float maxViewWidth = itemRect.width - 50; if (textWidth > maxViewWidth) { series.labelX = Mathf.Lerp(0, maxViewWidth - textWidth, series.labelDT += Time.deltaTime * 0.75f); } } else { series.labelX = 0; series.labelDT = 0; } GUI.BeginGroup(itemRect); GUI.color = manager.excludeList.Contains(label) ? Color.gray : manager.seriesColors [series.label]; GUI.DrawTexture(new Rect(5, 10, 30, 15), (label == manager.selected) ? markerHoverTex : markerTex); GUI.color = temp; GUI.color = manager.excludeList.Contains(label) ? Color.gray : temp; style.normal.textColor = (label == manager.selected) ? manager.seriesColors [series.label] : Color.white; { GUI.BeginGroup(new Rect(50, 5, 200, heightSeries)); GUI.Label(new Rect(series.labelX, 0, 200, heightSeries), label, style); GUI.EndGroup(); } GUI.color = temp; //if player clicks on species, set as selected and activate foodWeb if (GUI.Button(new Rect(0, 0, itemRect.width, itemRect.height), "", GUIStyle.none)) { foodWeb.selected = SpeciesTable.GetSpeciesName(label); foodWeb.SetActive(true, foodWeb.selected); } GUI.EndGroup(); } GUI.EndScrollView(); GUI.EndGroup(); }