private Source GenerateUsingDeclarations(UIFramework uiFramework, Usings usings) { #if false foreach (var member in Declaration.Members) { if (!(member is PropertyDeclarationSyntax modelProperty)) { continue; } // Array.Empty requires System if (modelProperty.Type is ArrayTypeSyntax) { AddUsing(usings, IdentifierName("System")); } } #endif /* * foreach (IPropertySymbol propertySymbol in Type.GetMembers().Where(member => member.Kind == SymbolKind.Property)) * { * var property = new Property(Context, this, propertySymbol); * OutputType.AddTypeAliasUsingIfNeeded(usings, property.FrameworkTypeName.ToString()); * } */ return(usings.Generate()); }
void Start() { levelTime = 0; activeMessager = null; UI = GameObject.Find("LabCanvas").GetComponent <UIFramework> (); UI.ToggleContinueButton(false); narratorText = GameObject.Find("NarratorText").GetComponent <Text>(); narratorText.text = ""; textOptionsHolder = GameObject.Find("TextOptionsHolder"); Experiment e = GetComponent <Experiment> (); e.BaseSetup(); e.dna.Setup(scientistMapList); e.dna.MakeVisibleAndInteractive(false, false); nts = new List <NarratorTrigger> (); for (int i = 0; i < textOptionsHolder.transform.childCount; i++) { nts.Add(textOptionsHolder.transform.GetChild(i).GetComponent <NarratorTrigger> ()); nts [nts.Count - 1].Setup(); if (nts [nts.Count - 1].CanTriggerOnStart()) { BeginMessaging(nts[nts.Count - 1]); } } }
private Source?GenerateConstructor(UIFramework uiFramework, List <Property> properties) { Source constructorBody = new Source(Context); foreach (Property property in properties) { uiFramework.GeneratePropertyInit(property, constructorBody); } if (constructorBody.IsEmpty) { return(null); } Source constructor = new Source(Context); constructor.AddLines( $"public {FrameworkClassName}()", "{"); using (constructor.Indent()) constructor.AddSource( constructorBody); constructor.AddLine( "}"); return(constructor); }
public ProjectInfo(string baseDirectory, string fullName, string name, TemplateType templateType, UIFramework uiFramework, bool tiered) { BaseDirectory = baseDirectory; Name = name; TemplateType = templateType; UIFramework = uiFramework; Tiered = tiered; FullName = fullName; }
public override void Entry(IModHelper helper) { Util.Config = helper.ReadConfig <ModConfig>(); Util.ModManifest = this.ModManifest; Util.Monitor = this.Monitor; Util.Helper = helper; this.taxation = new TaxationService(); var framework = new UIFramework(); framework.AddNewPage(() => new EconomyPage( framework, Util.Helper.Content.Load <Texture2D>($"assets/Interface/tabIcon.png"), Util.Helper.Translation.Get("BalanceReportText"), taxation), 0, new SidetabData(Util.Helper.Content.Load <Texture2D>($"assets/Interface/sidebarButtonReport.png"), Util.Helper.Translation.Get("Sidetab_TaxPaymentReportText"), 0)); taxation.OnTaxScheduleListUpdated += (object sender, IEnumerable <Model.TaxSchedule> collection) => framework.UpdateListDataList(collection); framework.AddNewPage(() => new ConfigurationPage(framework), 0, new SidetabData(Util.Helper.Content.Load <Texture2D>($"assets/Interface/sidebarButtonGear.png"), "Configuration", 0)); Util.Helper.Events.Display.WindowResized += Display_WindowResized; //} //framework.AddNewPage(() => new LoanPage(framework, taxation), 0, new SidetabData(Util.Helper.Content.Load<Texture2D>($"assets/Interface/LoanButton.png"), "Loan", 0)); this.messageBroadcast = new MessageBroadcastService(taxation); #if DEBUG Util.IsDebug = true; Monitor.Log("-----------------------DEBUG MODE-----------------------", LogLevel.Alert); this.Helper.Events.GameLoop.DayStarted += (object sender, StardewModdingAPI.Events.DayStartedEventArgs e) => Game1.addHUDMessage(new HUDMessage("DEBUG MODE", 2)); helper.Events.Input.ButtonPressed += (object sender, ButtonPressedEventArgs e) => { if (!Context.IsWorldReady) { return; } if (e.Button == SButton.F) { InterfaceHelper.DrawGuidelines = !InterfaceHelper.DrawGuidelines; } if (e.Button == SButton.G) { var message = new Multiplayer.Messages.BroadcastMessage(); Util.Helper.Multiplayer.SendMessage(message, "nil", modIDs: new[] { Util.ModManifest.UniqueID }); } }; #endif }
public EconomyPage(UIFramework ui, Texture2D texture, string Hovertext, TaxationService taxation) : base(ui, texture, Hovertext) { this.taxation = taxation; //Elements.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11233"))); //Elements.Add(new ContentElementText(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11234"))); Elements.Add(new ContentElementHeaderText(Util.Helper.Translation.Get("BalanceReportText"))); Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentLotValueText")}: {taxation.LotValue.Sum}g")); Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentTaxBalance")}: {taxation.State?.PendingTaxAmount}g")); TaxSchedule scheduledTask = null; CustomWorldDate date = null; load(); void load() { scheduledTask = taxation.State?.ScheduledTax.OrderBy(c => c.DayCount).FirstOrDefault(c => !c.Paid); date = scheduledTask?.DayCount.ToWorldDate(); }; Elements.Add(new ContentElementText(() => { load(); return(scheduledTask != null ? Util.Helper.Translation.Get("NextScheduledTaxText") : Util.Helper.Translation.Get("NoBillsForYouText")); })); Elements.Add(new ContentElementText(() => { return(scheduledTask != null ? $"{Game1.content.LoadString("Strings\\StringsFromCSFiles:Utility.cs.5678", date.DayOfMonth, (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.es) ? date.Season.GetLocalizedSeason().ToLower() : date.Season.GetLocalizedSeason(), date.Year)} - {scheduledTask.Sum}g" : ""); })); payButton = new ClickableComponent(new Rectangle(xPositionOnScreen + 64, Game1.activeClickableMenu.height + 50, (int)Game1.dialogueFont.MeasureString("_____________").X, 96), "", "_____________"); for (int i = 0; i < Elements.Count; ++i) { Slots.Add(new ClickableComponent( new Rectangle( xPositionOnScreen + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * (height - Game1.tileSize * 2) / 7, width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom), i.ToString())); } this.Draw = DrawContent; this.DrawHover = DrawHoverContent; this.LeftClickAction += Leftclick; }
/// <summary> /// Adds a default, self-contained UI for Identity to the application using /// Razor Pages in an area named Identity. /// </summary> /// <remarks> /// In order to use the default UI, the application must be using <see cref="Microsoft.AspNetCore.Mvc"/>, /// <see cref="Microsoft.AspNetCore.StaticFiles"/> and contain a <c>_LoginPartial</c> partial view that /// can be found by the application. /// </remarks> /// <param name="builder">The <see cref="IdentityBuilder"/>.</param> /// <returns>The <see cref="IdentityBuilder"/>.</returns> public static IdentityBuilder AddDefaultUI( this IdentityBuilder builder, UIFramework framework) { builder.AddSignInManager(); AddRelatedParts(builder, framework); builder.Services.ConfigureOptions( typeof(IdentityDefaultUIConfigureOptions <>) .MakeGenericType(builder.UserType)); builder.Services.TryAddTransient <IEmailSender, EmailSender>(); builder.Services.Configure <DefaultUIOptions>(o => o.UIFramework = framework); return(builder); }
public ConfigurationPage(UIFramework ui, Texture2D Icon = null, string hoverText = null) : base(ui, Icon, hoverText) { //Elements.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.Constants.WholeYearDaysCount33"))); //Elements.Add(new ContentElementText(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.Constants.WholeYearDaysCount34"))); Elements.Add(new ContentElementHeaderText(Util.Helper.Translation.Get("Configuration").Default("Economy Mod Configuration"))); //Elements.Add(new ContentElementSlider("Threshold To Ask About Payment", () => Util.Config.ThresholdInPercentageToAskAboutPayment, (o) => Util.Config.SetThresholdInPercentageToAskAboutPayment(Convert.ToByte(o)))); Elements.Add(new ContentElementCheckbox(Util.Helper.Translation.Get("ChkTaxAfterFirstYear").Default("skip tax for the first Year"), Util.Config.TaxAfterFirstYear, (newValue) => { Util.Config.TaxAfterFirstYear = newValue; Util.Helper.WriteConfig(Util.Config); })); this.Draw = DrawContent; this.DrawHover = DrawHoverContent; ui.OnLeftClick += Leftclick; }
public LoanPage(UIFramework ui, TaxationService taxation) : base(ui) { LoanButton = new ClickableComponent(InterfaceHelper.GetButtonSizeForPage(this), "", "_____________"); for (int i = 0; i < 7; ++i) { Slots.Add(new ClickableComponent( new Rectangle( xPositionOnScreen + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * (height - Game1.tileSize * 2) / 7, width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom), i.ToString())); } Draw = () => { int currentItemIndex = 0; for (int i = 0; i < Slots.Count; ++i) { InterfaceHelper.Draw(Slots[i].bounds); if (currentItemIndex >= 0 && currentItemIndex + i < Elements.Count) { Elements[currentItemIndex + i].draw(Game1.spriteBatch, Slots[i].bounds.X, Slots[i].bounds.Y); } } if (taxation.State.PendingTaxAmount != 0) { IClickableMenu.drawTextureBox(Game1.spriteBatch, Game1.mouseCursors, new Rectangle(432, 439, 9, 9), LoanButton.bounds.X, LoanButton.bounds.Y, LoanButton.bounds.Width, LoanButton.bounds.Height, (LoanButton.scale > 0f) ? Color.Wheat : Color.White, 4f); var btnPosition = new Vector2(LoanButton.bounds.Center.X, LoanButton.bounds.Center.Y + 4) - Game1.dialogueFont.MeasureString("Loan Funds - Pelican Town 10000g") / 2f; Utility.drawTextWithShadow(Game1.spriteBatch, "Loan Funds - Pelican Town 10000g", Game1.dialogueFont, btnPosition, Game1.textColor, 1f, -1f, -1, -1, 0f); InterfaceHelper.Draw(LoanButton.bounds, center: true); InterfaceHelper.Draw(btnPosition, InterfaceHelper.InterfaceHelperType.Red); } }; ui.OnLeftClick += Leftclick; }
private string?GetOutputBaseClass(UIFramework uiFramework) { #if NOMORE string?elementType = Utils.IsCollectionType(Type); if (elementType != null) { return($"StandardUICollection<{elementType}>"); } #endif INamedTypeSymbol?baseInterface = Type.Interfaces.FirstOrDefault(); if (baseInterface == null) { return(null); } else { return(uiFramework.OutputTypeName(baseInterface)); } }
private static bool TryResolveUIFramework(Assembly? assembly, out UIFramework uiFramework) { uiFramework = default; var metadata = assembly?.GetCustomAttributes<UIFrameworkAttribute>() .SingleOrDefault()?.UIFramework; // Bootstrap5 is the default if (metadata == null) { return false; } // If we find the metadata there must be a valid framework here. if (!Enum.TryParse(metadata, ignoreCase: true, out uiFramework)) { var enumValues = string.Join(", ", Enum.GetNames(typeof(UIFramework)).Select(v => $"'{v}'")); throw new InvalidOperationException( $"Found an invalid value for the 'IdentityUIFrameworkVersion'. Valid values are {enumValues}"); } return true; }
public ViewVersionFeatureProvider(UIFramework framework) => _framework = framework;
private static void AddRelatedParts(IdentityBuilder builder, UIFramework framework) { var mvcBuilder = builder.Services .AddMvc() .ConfigureApplicationPartManager(partManager => { var thisAssembly = typeof(IdentityBuilderUIExtensions).Assembly; var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); var relatedParts = relatedAssemblies.ToDictionary( ra => ra, CompiledRazorAssemblyApplicationPartFactory.GetDefaultApplicationParts); var selectedFrameworkAssembly = _assemblyMap[framework]; foreach (var kvp in relatedParts) { var assemblyName = kvp.Key.GetName().Name; if (!IsAssemblyForFramework(selectedFrameworkAssembly, assemblyName)) { RemoveParts(partManager, kvp.Value); } else { AddParts(partManager, kvp.Value); } } bool IsAssemblyForFramework(string frameworkAssembly, string assemblyName) => string.Equals(assemblyName, frameworkAssembly, StringComparison.OrdinalIgnoreCase); void RemoveParts( ApplicationPartManager manager, IEnumerable <ApplicationPart> partsToRemove) { for (var i = 0; i < manager.ApplicationParts.Count; i++) { var part = manager.ApplicationParts[i]; if (partsToRemove.Any(p => string.Equals( p.Name, part.Name, StringComparison.OrdinalIgnoreCase))) { manager.ApplicationParts.Remove(part); } } } void AddParts( ApplicationPartManager manager, IEnumerable <ApplicationPart> partsToAdd) { foreach (var part in partsToAdd) { if (!manager.ApplicationParts.Any(p => p.GetType() == part.GetType() && string.Equals(p.Name, part.Name, StringComparison.OrdinalIgnoreCase))) { manager.ApplicationParts.Add(part); } } } }); }
// Use this for initialization void Awake() { if (geneMap.Length == 0) { geneMap = new string[2] { "shape", "color" } } ; experiments = new List <Experiment> (); mouseSelectedExps = new List <Experiment> (); gConditions = GetComponents <GroupCondition> (); aConditions = GetComponents <AttackCondition> (); GeneValues.NUM_BASE_TYPES = NUM_BASE_TYPES; expHolder = ((GameObject)GameObject.Find("ExperimentHolder")).transform; factoryHolder = ((GameObject)GameObject.Find("FactoryHolder")).transform; goalHolder = ((GameObject)GameObject.Find("GoalHolder")).transform; tempExp = ((GameObject)Resources.Load("temp_experiment")).transform; foreach (GroupCondition gc in GetComponents <GroupCondition>()) { gc.Setup(); } } void Start() { // Rogue node setup GameObject rogueNode = (GameObject)Resources.Load("nodes/roguenode"); rogueSpots = new Vector3[rogueNode.transform.childCount]; for (int i = 0; i < rogueNode.transform.childCount; i++) { rogueSpots [i] = rogueNode.transform.GetChild(i).position; } groupMarker = Resources.Load("nodes/groupmarker") as GameObject; // UI Setup UI = GameObject.Find("LabCanvas").GetComponent <UIFramework> (); SocStatus = GameObject.Find("SocietyStatus"); SocStatus.SetActive(false); societyCenter = new Vector3(UI.societyBounds.x + UI.societyBounds.z / 2, UI.societyBounds.y + UI.societyBounds.w / 2, 0); // GameObject Setup for (int i = 0; i < geneMapDefaultExps.Length; i++) { Experiment e = CreateExperiment(expHolder, i, NewBoundedRandomLoc()); e.dna.Setup(geneMapDefaultExps[i].mapList); } SpawnGoalExperiments(); AddFactoryExperiment(); AddNucleobases(); // Interaction Setup for (int i = 0; i < expHolder.childCount; i++) { Experiment e = expHolder.GetChild(i).GetComponent <Experiment> (); // Check if this is a valid experiment if (e.gameObject.activeInHierarchy && !e.gameObject.name.Equals("ToBeDestroyed")) { experiments.Add(e); } } state = SocState.Regrouping; } Experiment CreateExperiment(Transform holder, int id, Vector3 pos) { Experiment exp = ((GameObject)GameObject.Instantiate(Resources.Load("temp_experiment"), holder)).GetComponent <Experiment>(); exp.BaseSetup(); exp.id = id; exp.transform.position = pos; return(exp); } // Update is called once per frame void Update() { //print (numInteracting); switch (state) { case SocState.CheckVictory: ActivateStatusUIWith(false, ""); CheckForVictory(); break; case SocState.Waiting: if (numInteracting == 0) { state = nextState; } break; case SocState.Regrouping: BucketExpsIntoGroups(); foreach (Experiment e in experiments) { e.SetState(Experiment.ExpState.Moving); } ActivateStatusUIWith(true, "Grouping"); state = SocState.Waiting; nextState = SocState.Attacking; DrawGroupMarkers(); break; case SocState.Attacking: ActivateStatusUIWith(true, "Attacking"); UpdateExpAttacks(); state = SocState.Waiting; nextState = SocState.CheckVictory; break; case SocState.Joining: EraseGroupMarkers(); JoinSelectedExps(); state = SocState.Waiting; nextState = SocState.Regrouping; break; } } void ActivateStatusUIWith(bool active, string text) { SocStatus.SetActive(active); SocStatus.GetComponentInChildren <Text> ().text = text; } void InsertExpIntoList(Experiment e) { //int index; //if ((index = experiments.BinarySearch (e, (Experiment x, Experiment y) => x.transform.position.x.CompareTo (y.transform.position.x))) < 0) // index = 0; //experiments.Insert (index, e); //print ("Added: " + e.name); }
public void Generate(UIFramework uiFramework) { string frameworkNamespaceName = uiFramework.ToFrameworkNamespaceName(Namespace); var usings = new Usings(Context, frameworkNamespaceName); var properties = new List <Property>(); var stubSourceForUsings = new Source(Context, usings); var mainClassStaticFields = new Source(Context, usings); var mainClassStaticMethods = new Source(Context, usings); var mainClassNonstaticFields = new Source(Context, usings); var mainClassNonstaticMethods = new Source(Context, usings); var attachedClassStaticFields = new Source(Context, usings); var attachedClassMethods = new Source(Context, usings); // Add the property descriptors and accessors foreach (IPropertySymbol propertySymbol in Type.GetMembers().Where(member => member.Kind == SymbolKind.Property)) { var property = new Property(Context, this, propertySymbol); properties.Add(property); uiFramework.GeneratePropertyDescriptor(property, mainClassStaticFields); uiFramework.GeneratePropertyField(property, mainClassNonstaticFields); uiFramework.GeneratePropertyMethods(property, mainClassNonstaticMethods); } // If there are any attached properties, add the property descriptors and accessors for them if (AttachedType != null) { foreach (ISymbol member in AttachedType.GetMembers()) { if (!(member is IMethodSymbol getterMethod)) { continue; } // We just process the Get string methodName = getterMethod.Name; if (!methodName.StartsWith("Get")) { if (!methodName.StartsWith("Set")) { throw new UserViewableException( $"Attached type method {AttachedType.Name}.{methodName} doesn't start with Get or Set"); } else { continue; } } string propertyName = methodName.Substring("Get".Length); string setterMethodName = "Set" + propertyName; IMethodSymbol?setterMethod = (IMethodSymbol?)AttachedType.GetMembers(setterMethodName).FirstOrDefault(); var attachedProperty = new AttachedProperty(Context, this, AttachedType, getterMethod, setterMethod); uiFramework.GenerateAttachedPropertyDescriptor(attachedProperty, mainClassStaticFields); uiFramework.GenerateAttachedPropertyMethods(attachedProperty, mainClassStaticMethods); uiFramework.GenerateAttachedPropertyAttachedClassMethods(attachedProperty, attachedClassMethods); } } // Add any other methods needed for particular special types if (IsDrawableObject) { uiFramework.GenerateDrawableObjectMethods(this, mainClassNonstaticMethods); } if (IsThisType(KnownTypes.IPanel)) { uiFramework.GeneratePanelMethods(mainClassNonstaticMethods); } if (Purpose == InterfacePurpose.StandardPanel) { uiFramework.GenerateStandardPanelLayoutMethods(LayoutManagerType !.Name, mainClassNonstaticMethods); } usings.AddTypeNamespace(Type); usings.AddNamespace(frameworkNamespaceName); Source usingDeclarations = GenerateUsingDeclarations(uiFramework, usings); string?destinationBaseClass = GetOutputBaseClass(uiFramework); Source?constructor = GenerateConstructor(uiFramework, properties); string frameworkOutputDirectory = uiFramework.GetOutputDirectory(ChildNamespaceName); string mainClassDerviedFrom; if (destinationBaseClass == null) { mainClassDerviedFrom = Name; } else { mainClassDerviedFrom = $"{destinationBaseClass}, {Name}"; } Source mainClassSource = GenerateClassFile(usings, frameworkNamespaceName, FrameworkClassName, mainClassDerviedFrom, constructor: constructor, staticFields: mainClassStaticFields, staticMethods: mainClassStaticMethods, nonstaticFields: mainClassNonstaticFields, nonstaticMethods: mainClassNonstaticMethods); mainClassSource.WriteToFile(frameworkOutputDirectory, FrameworkClassName + ".cs"); if (AttachedType != null) { string attachedClassName = FrameworkClassName + "Attached"; string attachedClassDerivedFrom = AttachedType.Name; attachedClassStaticFields.AddLine($"public static {attachedClassName} Instance = new {attachedClassName}();"); Source attachedClassSource = GenerateClassFile(usings, frameworkNamespaceName, attachedClassName, attachedClassDerivedFrom, staticFields: attachedClassStaticFields, nonstaticMethods: attachedClassMethods); attachedClassSource.WriteToFile(frameworkOutputDirectory, attachedClassName + ".cs"); } }