private void InitServices() { services = new List <SlyService>(); foreach (var service in slyServices) { SlyService slyService = (SlyService)Activator.CreateInstance(service); services.Add(slyService); } }
private void DrawServices(Rect rect, Map map) { List <SellableItemWithModif> items = stock; Rect goodsRect = new Rect(rect.x + 10, rect.y + 5, rect.width - 15, rect.height - 25); Rect goodRect = new Rect(0, 0, goodsRect.width - 25, 200); Rect scrollVertRectFact = new Rect(0, 0, rect.x, Services.Count * 225); Widgets.BeginScrollView(goodsRect, ref slider, scrollVertRectFact, true); for (int i = 0; i < Services.Count; i++) { SlyService item = Services[i]; DrawService(item, goodRect, map); goodRect.y += 205; } Widgets.EndScrollView(); }
private void DrawService(SlyService service, Rect rect, Map map) { bgCardColor.a = 150; Widgets.DrawBoxSolid(rect, bgCardColor); GUI.color = GUIUtils.CommBorderColor; Widgets.DrawBox(rect); GUI.color = Color.white; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(rect.x + 130, rect.y + 8, rect.width - 88, 25), service.Label); Text.Anchor = TextAnchor.UpperLeft; GUIUtils.DrawLineHorizontal(rect.x + 205, rect.y + 34, rect.width - 213, Color.gray); float y = rect.y + 36; Widgets.Label(new Rect(rect.x + 205, y, rect.width - 213, 140), service.Description); Text.Anchor = TextAnchor.MiddleCenter; bool serviceStatus = service.AvaliableRightNow(out string reason); Rect bRect = new Rect(rect.x + 8, rect.y + 36, 190, 25); foreach (var option in service.Options(map)) { if (GUIUtils.DrawCustomButton(bRect, option.Label, serviceStatus ? Color.white : Color.gray)) { if (serviceStatus) { option.action.Invoke(); } } bRect.y += 32; } if (!serviceStatus) { Widgets.Label(new Rect(rect.x + 8, rect.y + 175, rect.width - 8, 25), "DarkNetLabels_ServiceUnavaliable".Translate(reason)); } Text.Anchor = TextAnchor.UpperLeft; }