Open FyreAus opened 4 years ago
Hi. Thank you for your feedback. The toll object is not currently implemented. It is for internal testing purposes and is only available by going through files or using a dev command. We will figure this out when it is time to implement the object.
I think you are missing the point. I realize the Toll Object is not implemented, What is implemented is the ability for modders to use the Attributes indicated to Auto generate World Object UI by using the attribute on property on a Component on the Object.
There is a bug here which effects that process, and I believe this needs looking at. it's not about the toll object that was just where you can see an example of this bug in action.
I bleieve the TollObject and it's TollComponent was created for the purpose of demonstrating to modders how to develop AutoGenerated Client side UI using only server side code, I don't think it was ever meant to be part of the game. The issue at stake is the Attribute [Eco] (and probably the underlying combination of attributes it represents) which should theoretically take any Property and make a UI element out of it. I assume it already works as intended. It's used extensively throughout the game on things like Titles, Wages and Laws, it just does not seem to be updating client side when on World Objects Components.
For example the Attribute is used here on the abstract Title class
[Eco, LocDescription("All office holders must be in this demographic. If they cease to be, they will be removed from office. (Note: for appointed titles, this will only remove directly specified users. Users that are part of a sub-title or demographic will be unaffected)."), AllowNull]
public GameValue<bool> RequiredOfOfficeHolders { get; set; }
[Eco, LocDescription("Wages for being an occupant of this title."), AllowEmpty]
public ControllerList<Wage> Wages { get; set; }
I assume this generates the UI for changing the titles Wages and RequiredOfficeHolders. (I will admit I've never set-up a Title in game yet, but I have to imagine since no one has registered it as a bug it must work as intended) In fact I have created an object that uses [Eco] and it correctly gets a custom list to display to the user in the World Object Components interface. It simply just doesn't update client side when you make a selection in the list.
for reference here is the original wiki document John wrote describing how to use AutoGenerated UI: https://github.com/StrangeLoopGames/EcoModKit/wiki/Creating-UIs-for-Mods It is a bit older and lists is not a part of the original document, but I noticed that things had made some progression and everything seems to work (for lists), except for the client side update after the object in the list is selected.
Also for reference here is how I am using it:
[Serialized, AutogenClass, LocDisplayName("Storage Terminal")]
public partial class StorageTerminalComponent : WorldObjectComponent
{
[SyncToView, Autogen, AutoRPC, GuestHidden, Serialized] public float Radius { get; set; }
[Eco] public OrderBy OrderBy {get; set;} // OrderBy is an enum with Alphabetical and StockLevel potential values
// further implementation of Component
}
and a pic in game of the component so you can see it does in fact create the component correctly
Thank you for clarifying. I will follow up with the creator of the attribute to see what we can do.
Hello, I was wondering if there was an update on this as attempting to get a selection from an enumeration still does not update on the client correctly. (the option selects correctly in the background, but it does not visually change on the client until the client restarts).
Is it at all possible that the generic enum view in AutoGenEnum.cs for the client is not refreshing the view on property change?
AutoGenEnum.cs Here the view is refreshed when ViewInited (which explains why relogging updates the view), but on property change there is no refresh so client side the view doesn't update?
public override void ViewInited()
{
base.ViewInited();
this.Options = ViewManager.GetViewClassInfo(PropertyInfo.RelevantTypeName).EnumNames;
var enumVal = this.ParentView.GetValue(PropertyInfo.Name, this.ListIndex);
this.ViewDropdown.gameObject.SetActive(true);
this.ViewDropdown.options = this.Options.Select(x => new TMP_Dropdown.OptionData(x)).ToList();
this.ViewDropdown.value = (int)enumVal;
this.ViewDropdown.RefreshShownValue();
this.ViewDropdown.onValueChanged.AddListener(this.OnDropdownValueChanged);
}
private void OnDropdownValueChanged(int newVal) => this.ParentView.RPC($"Set{this.PropertyInfo.Name}", newVal);
Using the Toll Object as an example the [Eco] property is used on the BankAccount property.
The Property is correctly scanned for the relevant list behind the Prop, but it does not update the property on selection from the list, at least not client side. It requires a relog of the client to get the selection to visually update.
using [SyncToView, Autogen, AutoRPC, Serialized, ScanProp] also produces similar behavior.