private void OnEnable() { Generate(); SelectionManager.Current.SetSelectionChangeAction(UpdateSelection); RenderAdaptiveMarkers.UpdateAdaptiveLines(); UpdateMarkerName(); }
public void OnTableToggleChanged(int GroupId, int ToggleId) { TablesLua.TablesInfo TablesData = MapLuaParser.Current.TablesLuaFile.Data; bool SetTo = false; if (CustomToggles[GroupId][ToggleId].HasOffValue) { SetTo = true; } string TableKey; if (TablesData.AllTables[GroupId].OneDimension) { TableKey = TablesData.AllTables[GroupId].Key; } else { TableKey = TablesData.AllTables[GroupId].Key + "#" + ToggleId; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; AnyChanged |= SetTableGroupToggle(Current, SetTo, TableKey); } for (int s = 0; s < SelectionManager.Current.SymetrySelection.Length; s++) { for (int i = 0; i < SelectionManager.Current.SymetrySelection[s].Ids.Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.SymetrySelection[s].Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; AnyChanged |= SetTableGroupToggle(Current, SetTo, TableKey); } } CustomToggles[GroupId][ToggleId].HasOnValue = SetTo; CustomToggles[GroupId][ToggleId].HasOffValue = !SetTo; CustomToggles[GroupId][ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void OnArmyToggleChanged(int GroupId, int ToggleId) { bool SetTo = false; if (ArmyToogles[ToggleId].HasOffValue) { SetTo = true; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType != SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } if (SetTo) { if (!Current.SpawnWithArmy.Contains(ToggleId)) { Current.SpawnWithArmy.Add(ToggleId); AnyChanged = true; } } else { if (Current.SpawnWithArmy.Contains(ToggleId)) { Current.SpawnWithArmy.Remove(ToggleId); AnyChanged = true; } } } ArmyToogles[ToggleId].HasOnValue = SetTo; ArmyToogles[ToggleId].HasOffValue = !SetTo; ArmyToogles[ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void OnGUI() { RenderAdaptiveMarkers.DrawGUIStatic(); if (!RenderEnabled || WarningPosition.Count <= 0) { return; } if (PreviewTex.IsPreview) { return; } if (MapLuaParser.LoadingMapProcess || MapLuaParser.SavingMapProcess) { return; } Camera MainCam = CameraControler.Current.Cam; Rect CamRect = MainCam.pixelRect; Rect UiRect = new Rect(CamRect.x, CamRect.y + (Screen.height - CamRect.height), CamRect.width, CamRect.height); GUI.BeginScrollView(UiRect, Vector2.zero, new Rect(0, (Screen.height - CamRect.height), CamRect.width, CamRect.height), false, false); //GUI.Label(new Rect(500, 500, 100, 50), "Test"); //Color LastColor = GUI.contentColor; //GUI.contentColor = LabelColor; HashSet <MarkerWarning> .Enumerator ListEnum = WarningPosition.GetEnumerator(); while (ListEnum.MoveNext()) { MarkerWarning Current = ListEnum.Current; DrawGuiLabel(MainCam, CamRect, Current.Marker, Current.Log, LabelStyle); } ListEnum.Dispose(); //GUI.contentColor = LastColor; GUI.EndScrollView(); }
private void Awake() { Instance = this; }
private void OnDisable() { RenderAdaptiveMarkers.DisableRenderer(); }
public void OnTableToggleChanged(int GroupId, int ToggleId) { TablesLua.TablesInfo TablesData = MapLuaParser.Current.TablesLuaFile.Data; bool SetTo = false; if (CustomToggles[GroupId][ToggleId].HasOffValue) { SetTo = true; } string TableKey; if (TablesData.AllTables[GroupId].OneDimension) { TableKey = TablesData.AllTables[GroupId].Key; } else { TableKey = TablesData.AllTables[GroupId].Key + "#" + ToggleId; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; SaveLua.Marker Current = CurrentObj.GetComponent <MarkerObject>().Owner; if (Current.MarkerType != SaveLua.Marker.MarkerTypes.Mass && Current.MarkerType != SaveLua.Marker.MarkerTypes.Hydrocarbon) { continue; } if (SetTo) { if (!Current.AdaptiveKeys.Contains(TableKey)) { Current.AdaptiveKeys.Add(TableKey); AnyChanged = true; } } else { if (Current.AdaptiveKeys.Contains(TableKey)) { Current.AdaptiveKeys.Remove(TableKey); AnyChanged = true; } } } CustomToggles[GroupId][ToggleId].HasOnValue = SetTo; CustomToggles[GroupId][ToggleId].HasOffValue = !SetTo; CustomToggles[GroupId][ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void OnArmyToggleChanged(int GroupId, int ToggleId) { bool SetTo = false; if (ArmyToogles[ToggleId].HasOffValue) { SetTo = true; } int Count = SelectionManager.Current.Selection.Ids.Count; bool AnyChanged = false; for (int i = 0; i < Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; AnyChanged |= SetMarkerArmyToggle(CurrentObj.GetComponent <MarkerObject>().Owner, SetTo, ToggleId); } var symmetryArmies = MapLuaParser.Current.ScenarioLuaFile.GetSymmetryArmies(Armies[ToggleId]); Debug.Log(symmetryArmies.Count); for (int s = 0; s < SelectionManager.Current.SymetrySelection.Length; s++) { bool AnySymmetryChanged = false; int symmetryToogleId = -1; for (int a = 0; a < Armies.Length; a++) { if (Armies[a] == symmetryArmies[s]) { symmetryToogleId = a; break; } } Debug.Log(s + " : " + symmetryToogleId); if (symmetryToogleId < 0) { continue; } for (int i = 0; i < SelectionManager.Current.SymetrySelection[s].Ids.Count; i++) { GameObject CurrentObj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.SymetrySelection[s].Ids[i]]; AnySymmetryChanged |= SetMarkerArmyToggle(CurrentObj.GetComponent <MarkerObject>().Owner, SetTo, symmetryToogleId); } //ArmyToogles[symmetryToogleId].HasOnValue = SetTo; //ArmyToogles[symmetryToogleId].HasOffValue = !SetTo; //ArmyToogles[symmetryToogleId].ApplyTesting(); AnyChanged |= AnySymmetryChanged; } ArmyToogles[ToggleId].HasOnValue = SetTo; ArmyToogles[ToggleId].HasOffValue = !SetTo; ArmyToogles[ToggleId].ApplyTesting(); if (AnyChanged) { RenderAdaptiveMarkers.UpdateAdaptiveLines(); } }
public void OnGUI() { RenderAdaptiveMarkers.DrawGUIStatic(); if (BP.Footprint.x == 0 && BP.Footprint.y == 0) { return; } if (PreviewTex.IsPreview) { return; } if (MapLuaParser.LoadingMapProcess || MapLuaParser.SavingMapProcess) { return; } Camera MainCam = CameraControler.Current.Cam; Rect CamRect = MainCam.pixelRect; Rect UiRect = new Rect(CamRect.x, CamRect.y + (Screen.height - CamRect.height), CamRect.width, CamRect.height); GUI.BeginScrollView(UiRect, Vector2.zero, new Rect(0, (Screen.height - CamRect.height), CamRect.width, CamRect.height), false, false); Vector3 MapMaxPoint = ScmapEditor.ScmapPosToWorld( new Vector3(MapLuaParser.Current.ScenarioLuaFile.Data.Size[0], 0, MapLuaParser.Current.ScenarioLuaFile.Data.Size[1]) ); Vector2 BorderOffsetFootprint = new Vector2(BorderOffset + BP.Footprint.x * 0.05f, BorderOffset + BP.Footprint.y * 0.05f); //GUI.Label(new Rect(500, 500, 100, 50), "Test"); //Color LastColor = GUI.contentColor; //GUI.contentColor = LabelColor; var ListEnum = Instances.GetEnumerator(); while (ListEnum.MoveNext()) { Vector3 LocalPos = ListEnum.Current.LocalToWorldMatrix.GetColumn(3); if (LocalPos.x < BorderOffsetFootprint.x) { LocalPos.x -= BP.Footprint.x * 0.05f; DrawGuiLabel(MainCam, CamRect, LocalPos, BuildingEdgeWarning, RenderMarkersWarnings.Instance.LabelStyle); } else if (LocalPos.z > -BorderOffsetFootprint.y) { LocalPos.z += BP.Footprint.y * 0.05f; DrawGuiLabel(MainCam, CamRect, LocalPos, BuildingEdgeWarning, RenderMarkersWarnings.Instance.LabelStyle); } else if (LocalPos.x > MapMaxPoint.x - BorderOffsetFootprint.x) { LocalPos.x += BP.Footprint.x * 0.05f; DrawGuiLabel(MainCam, CamRect, LocalPos, BuildingEdgeWarning, RenderMarkersWarnings.Instance.LabelStyle); } else if (LocalPos.z < MapMaxPoint.z + BorderOffsetFootprint.y) { LocalPos.z -= BP.Footprint.y * 0.05f; DrawGuiLabel(MainCam, CamRect, LocalPos, BuildingEdgeWarning, RenderMarkersWarnings.Instance.LabelStyle); } } ListEnum.Dispose(); GUI.EndScrollView(); }