public void AddFiltersToTab(eTAB_TYPES tab, IEnumerable <Filter <MinerNotificationDetail> > filters) { foreach (var filter in filters) { TabFilters[tab].Add(filter); } }
public void AddFiltersToTab(eTAB_TYPES tab, IEnumerable <Filter <ResStationGroup> > filters) { foreach (var filter in filters) { TabFilters[tab].Add(filter); } }
public static string GetTabName(eTAB_TYPES tabType) { switch (tabType) { case eTAB_TYPES.TAB_PLANET: return("Planet"); case eTAB_TYPES.TAB_NETWORK: return("Power Network"); case eTAB_TYPES.TAB_RESOURCE: return("Resource"); case eTAB_TYPES.TAB_LOGISTICS: return("Logistics"); default: return("Undefined"); } }
public override void DrawFilterGUI(eTAB_TYPES selectedTab) { bool shouldUpdateFiltered = false; GUILayout.BeginVertical(GUILayout.MaxWidth(80)); GUILayout.Label($"<b>Filters</b>", UITheme.TextAlignStyle); GUILayout.Label($"Showing: ({TabFilterInfo[selectedTab].ItemsAfter}/{TabFilterInfo[selectedTab].ItemsBefore})", UITheme.TextAlignStyle); GUILayout.EndVertical(); foreach (var filter in TabFilters[selectedTab]) { GUILayout.BeginHorizontal(GUILayout.MaxWidth(150)); shouldUpdateFiltered |= filter.onGUI(filter); GUILayout.EndHorizontal(); } if (shouldUpdateFiltered) { UpdateSource(); } }
public abstract void DrawTabGUI(eTAB_TYPES selectedTab);
public abstract void DrawFilterGUI(eTAB_TYPES selectedTab);
public override void DrawTabGUI(eTAB_TYPES selectedTab) { var parentId = eTAB_SOURCE_TYPE.VeinMeiners + "." + selectedTab; var minersByPlanet = FilteredSource[selectedTab] .OrderBy(m => m.minutesToEmptyVein) .GroupBy(m => m.planetName).OrderBy(g => g.Key); if (selectedTab == eTAB_TYPES.TAB_PLANET) { foreach (var planet in minersByPlanet) { var myPlanetId = parentId + "." + planet.Key; var resourcesByPlanet = planet .GroupBy(miner => miner.itemProto).OrderBy(g => g.Key.name.Translate()) .Select(mtg => new { Name = mtg.Key.name.Translate(), Tex = mtg.First().resourceTexture, Miners = mtg.ToList(), SumMiningPerMin = mtg.Sum(m => m.miningRatePerMin) }); GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myPlanetId, out bool childrenCollapsed); GUILayout.Label($"<b>Planet {planet.Key}</b>", UITheme.TextAlignStyle); GUILayout.Label($" <b>Number of resource types: {resourcesByPlanet.Count()}</b>", UITheme.TextAlignStyle); GUILayout.EndHorizontal(); if (!childrenCollapsed) { foreach (var resource in resourcesByPlanet) { var myResId = myPlanetId + "." + resource.Name; var resourceTexture = resource.Tex ? resource.Tex : Texture2D.blackTexture; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myResId, out bool resourceChildrenCollapsed); GUILayout.Label($"<b>Resource</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Box(resourceTexture, UITheme.VeinIconLayoutOptions); GUILayout.Label($"<b>{resource.Name}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b># Miners: {resource.Miners.Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b>Sum Mining Rate: {resource.SumMiningPerMin.ToString("F0")}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.EndHorizontal(); if (!resourceChildrenCollapsed) { DrawVeinMinersHeader(); DrawVeinMiners(resource.Miners, parentId: myResId); } } } } } else if (selectedTab == eTAB_TYPES.TAB_NETWORK) { foreach (var planet in minersByPlanet) { var myId = parentId + "." + planet.Key; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myId, out bool childrenCollapsed); GUILayout.Label($"<b>Planet {planet.Key}</b>", UITheme.TextAlignStyle); GUILayout.EndHorizontal(); if (!childrenCollapsed) { var planetNetGroups = planet .OrderBy(m => m.veinAmount) .GroupBy(m => m.powerNetwork) .OrderBy(ng => ng.Key.id); foreach (var netGroup in planetNetGroups) { var myNetId = parentId + "." + netGroup.Key.id; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myNetId, out bool netChildrenCollapsed); GUILayout.Label($"<b>PowerNetwork {netGroup.Key.id} - Health: {Math.Round(netGroup.Key.consumerRatio * 100, 0) }</b>", UITheme.TextAlignStyle, GUILayout.Width(260)); GUILayout.EndHorizontal(); if (!netChildrenCollapsed) { DrawVeinMinersHeader(); DrawVeinMiners(netGroup, parentId: myId); } } } } } else if (selectedTab == eTAB_TYPES.TAB_RESOURCE) { var miners = FilteredSource[selectedTab] .OrderBy(miner => miner.veinAmount) .GroupBy(x => x.veinName).OrderBy(g => g.Key) .Select(mtg => new { Name = mtg.Key, Tex = mtg.First().resourceTexture, Miners = mtg.ToList(), SumMiningPerMin = mtg.Sum(m => m.miningRatePerMin) }); foreach (var resourceGroup in miners) { var myResId = parentId + "." + resourceGroup.Name; var resourceTexture = resourceGroup.Tex ? resourceGroup.Tex : Texture2D.blackTexture; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myResId, out bool childrenCollapsed); GUILayout.Label($"<b>Resource</b>", UITheme.TextAlignStyle, GUILayout.Width(65)); GUILayout.Box(resourceTexture, UITheme.VeinIconLayoutOptions); GUILayout.Label($"<b>{resourceGroup.Name}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b>Sum Mining Rate: {resourceGroup.SumMiningPerMin.ToString("F0")}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.EndHorizontal(); var minersByPlanetByResource = resourceGroup.Miners .OrderBy(m => m.minutesToEmptyVein) .GroupBy(m => m.planetName).OrderBy(g => g.Key) .Select(mtg => new { Name = mtg.Key, Miners = mtg.ToList(), SumMiningPerMin = mtg.Sum(m => m.miningRatePerMin) }); if (!childrenCollapsed) { foreach (var minersPlanet in minersByPlanetByResource) { var myMinersByPlanetId = myResId + "." + minersPlanet.Name; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myMinersByPlanetId, out bool minersByPlanetChildrenCollapsed); GUILayout.Label($"<b>Planet {minersPlanet.Name}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b># Miners: {minersPlanet.Miners.Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b>Sum Mining Rate: {minersPlanet.SumMiningPerMin.ToString("F0")}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.EndHorizontal(); if (!minersByPlanetChildrenCollapsed) { DrawVeinMinersHeader(includePlanet: false); DrawVeinMiners(minersPlanet.Miners, parentId: myMinersByPlanetId, includePlanet: false); } } } } } }
public void WindowFunc(int id) { GUILayout.BeginArea(new Rect(winRect.width - 22f, 2f, 20f, 17f)); if (GUILayout.Button("X")) { Show = false; } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(winRect.width - 45f, 2f, 20f, 17f)); if (GUILayout.Button("+")) { FixedSizeAdjust = Mathf.Min(FixedSizeAdjustOriginal + 0.8f, FixedSizeAdjust + 0.1f); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(winRect.width - 64f, 2f, 20f, 17f)); if (GUILayout.Button("1")) { FixedSizeAdjust = FixedSizeAdjustOriginal; } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(winRect.width - 83f, 2f, 20f, 17f)); if (GUILayout.Button("-")) { FixedSizeAdjust = Mathf.Max(FixedSizeAdjustOriginal - 0.5f, FixedSizeAdjust - 0.1f); } GUILayout.EndArea(); GUILayout.BeginVertical(); // Draw Top Menu GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); GUILayout.Label($"<b>Sources: </b>", UITheme.TextAlignStyle, GUILayout.Width(100)); foreach (eTAB_SOURCE_TYPE tabType in DSPStatSources.Keys) { if (GUILayout.Button(UIHelper.GetSourceTabName(tabType), selectedTabSourceType == tabType ? UITheme.TabMenuButtonSelectedStyle : UITheme.TabMenuButtonStyle)) { selectedTabSourceType = tabType; selectedTab = DSPStatSources[selectedTabSourceType].TABPages.First(); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); GUILayout.Label($"<b>Grouped On: </b>", UITheme.TextAlignStyle, GUILayout.Width(100)); foreach (eTAB_TYPES tabType in DSPStatSources[selectedTabSourceType].TABPages) //Enum.GetValues(typeof(eTAB_TYPES))) { if (GUILayout.Button(UIHelper.GetTabName(tabType), selectedTab == tabType ? UITheme.TabMenuButtonSelectedStyle : UITheme.TabMenuButtonStyle)) { selectedTab = tabType; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DSPStatSources[selectedTabSourceType].DrawFilterGUI(selectedTab); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); bool shouldUpdate = false; var oldAutoUpdateState = DSPStatSources[selectedTabSourceType].ShouldAutoUpdate; DSPStatSources[selectedTabSourceType].ShouldAutoUpdate = GUILayout.Toggle(DSPStatSources[selectedTabSourceType].ShouldAutoUpdate, $"AutoRefresh"); if (oldAutoUpdateState != DSPStatSources[selectedTabSourceType].ShouldAutoUpdate) { shouldUpdate = true; } for (int i = 1; i <= 3; i++) { var oldCollapsedLevelState = DSPStatSources[selectedTabSourceType].DefaultCollapsedStateLevel[i]; DSPStatSources[selectedTabSourceType].DefaultCollapsedStateLevel[i] = GUILayout.Toggle(DSPStatSources[selectedTabSourceType].DefaultCollapsedStateLevel[i], $"AutoCollapsed L" + i); if (oldCollapsedLevelState != DSPStatSources[selectedTabSourceType].DefaultCollapsedStateLevel[i]) { shouldUpdate = true; } } if (shouldUpdate) { DSPStatSources[selectedTabSourceType].CollapsedState.Clear(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); sv = GUILayout.BeginScrollView(sv, UnityEngine.GUI.skin.box); DSPStatSources[selectedTabSourceType].DrawTabGUI(selectedTab); GUILayout.EndScrollView(); GUILayout.EndVertical(); UnityEngine.GUI.DragWindow(); // Always close window on Escape for now if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape) { Show = false; } }
public override void DrawTabGUI(eTAB_TYPES selectedTab) { var parentId = eTAB_SOURCE_TYPE.LogisticStations + "." + selectedTab; if (selectedTab == eTAB_TYPES.TAB_PLANET) { var productsPerStation = FilteredSource[selectedTab].GroupBy(pair => pair.station, (group, pairList) => new { station = group, products = pairList }); var stationsPerPlanet = productsPerStation.GroupBy(pair => pair.station.planetData, (group, pairList) => new { planet = group, stations = pairList }); foreach (var stationsPlanetGroup in stationsPerPlanet) { var myPlanetId = parentId + "." + stationsPlanetGroup.planet.id; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myPlanetId, out bool childrenCollapsed); GUILayout.Label($"<b>Planet {stationsPlanetGroup.planet.name.Translate() }</b>", UITheme.TextAlignStyle, GUILayout.Width(170)); GUILayout.EndHorizontal(); if (!childrenCollapsed) { foreach (var statProdGroup in stationsPlanetGroup.stations) { var myStationId = myPlanetId + "." + statProdGroup.station.stationComponent.id; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(75), GUILayout.MaxWidth(75)); DrawCollapsedChildrenChevron(myStationId, out bool stationCildrenCollapsed); GUILayout.Label($"{statProdGroup.station.name}", UITheme.TextAlignStyle); if (statProdGroup.station.stationComponent.isCollector) { GUILayout.Label($"Collector", UITheme.TextAlignStyle); } else if (statProdGroup.station.stationComponent.isStellar) { GUILayout.Label($"Warpers: {statProdGroup.station.stationComponent.warperCount}", UITheme.TextAlignStyle); } GUILayout.Label($"{DSPHelper.PositionToLatLon(statProdGroup.station.stationPosition)}", UITheme.TextAlignStyle, UITheme.LocationColWidth); GUILayout.EndVertical(); if (!stationCildrenCollapsed) { foreach (var product in statProdGroup.products) { GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(150), GUILayout.MaxWidth(150)); GUILayout.BeginHorizontal(GUILayout.Width(150), GUILayout.MaxWidth(150), GUILayout.MinHeight(50)); GUILayout.Box(product.product.itemProto.iconSprite.texture, UITheme.VeinIconLayoutSmallOptions); GUILayout.Label($"{product.product.itemProto.name}", UITheme.TextAlignStyle, GUILayout.Width(120)); GUILayout.EndHorizontal(); GUILayout.Label($"Amount: {product.product.item.count}/{product.product.item.max}", UITheme.TextAlignStyle, GUILayout.Width(130)); GUILayout.BeginHorizontal(GUILayout.Width(150), GUILayout.MaxWidth(150)); GUILayout.Label($"L: {product.product.item.localLogic}", product.product.item.localLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(73), GUILayout.MinWidth(73)); GUILayout.Label($"R: {product.product.item.remoteLogic}", product.product.item.remoteLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(73), GUILayout.MinWidth(73)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } GUILayout.EndHorizontal(); } } } } else if (selectedTab == eTAB_TYPES.TAB_RESOURCE) { var stationsPerResource = FilteredSource[selectedTab].GroupBy(pair => pair.product.item.itemId, pair => new ResStationGroup() { station = pair.station, product = pair.product }) .Select(grp => new { itemId = grp.Key, itemProto = LDB.items.Select(grp.Key), stations = grp }).OrderBy(grp => grp.itemProto.name.Translate()); foreach (var resource in stationsPerResource) { var myId = parentId + "." + resource.itemId; var resourceTexture = resource.itemProto.iconSprite.texture; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(myId, out bool resChildrenCollapsed); GUILayout.Label($"<b>Resource</b>", UITheme.TextAlignStyle, GUILayout.Width(65)); GUILayout.Box(resourceTexture, UITheme.VeinIconLayoutOptions); GUILayout.Label($"<b>{resource.itemProto.Name.Translate()}</b>", UITheme.TextAlignStyle); GUILayout.EndHorizontal(); var interstellarDemand = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.Demand); var interstellarSupply = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.Supply); var interstellarNone = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.None); var localDemand = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.Demand); var localSupply = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.Supply); var localNone = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.None); List <PresOrderTuple> presOrder = new List <PresOrderTuple>() { { new PresOrderTuple() { name = "Interstellar Supply", stations = interstellarSupply, style = UITheme.SupplyStyle } }, { new PresOrderTuple() { name = "Interstellar Demand", stations = interstellarDemand, style = UITheme.DemandStyle } }, { new PresOrderTuple() { name = "Interstellar Storage", stations = interstellarNone, style = UITheme.TextAlignStyle } }, { new PresOrderTuple() { name = "Planetary Supply", stations = localSupply, style = UITheme.SupplyStyle } }, { new PresOrderTuple() { name = "Planetary Demand", stations = localDemand, style = UITheme.DemandStyle } }, { new PresOrderTuple() { name = "Planetary Storage", stations = localNone, style = UITheme.TextAlignStyle } } }; if (!resChildrenCollapsed) { foreach (var pres in presOrder) { if (pres.stations.Count() > 0) { var logTypeByResourceId = myId + "." + pres.name; var stationsByPlanetByResource = pres.stations .GroupBy(m => m.station.planetData.name.Translate()).OrderBy(g => g.Key) .Select(mtg => new { Name = mtg.Key, Stations = mtg.ToList() }); GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(75), GUILayout.MaxWidth(75)); //DrawCollapsedChildrenChevron(logTypeByResourceId, out bool logTypeByResourceChildrenCollapsed); GUILayout.Label($"{pres.name}", pres.style); GUILayout.EndVertical(); //if (!logTypeByResourceChildrenCollapsed) { GUILayout.BeginVertical(); foreach (var stationsPlanet in stationsByPlanetByResource) { var mStationsByPlanetId = logTypeByResourceId + "-" + stationsPlanet.Name; GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box); DrawCollapsedChildrenChevron(mStationsByPlanetId, out bool stationsByPlanetChildrenCollapsed); GUILayout.Label($"<b>Planet {stationsPlanet.Name}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b># P.L.S: {stationsPlanet.Stations.Where(s => !s.station.stationComponent.isStellar).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b># I.L.S: {stationsPlanet.Stations.Where(s => s.station.stationComponent.isStellar && !s.station.stationComponent.isCollector).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.Label($" <b># Collectors: {stationsPlanet.Stations.Where(s => s.station.stationComponent.isCollector).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65)); GUILayout.EndHorizontal(); if (!stationsByPlanetChildrenCollapsed) { GUILayout.BeginVertical(); DrawStationResourceGUI(stationsPlanet.Stations, MaxWidth: 165, MaxStationsPerLine: 4); GUILayout.EndVertical(); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } } } } }