- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Custom UI
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Custom UI
Replies: 2 (Who?), Viewed: 269 times.
#1
7th Mar 2021 at 5:35 PM
Posts: 3,860
Thanks: 8537 in 67 Posts
Custom UI
Hiya!This is my very first approach for a custom UI, I think I got the code figured out and the LAYO keys as expected. However, whenever I load it in-game, the entire world gets 'Error Trapped' by Nraas traveller (and if I take traveller out, it complains that 'WalkStyle' is screwed up :p)
Now, this issue currently is that the game doesn't like it for some reason. on world load, it basically screws things up and thus Nraas's error trap is pretty much whining about that (with a sweet 106 errors :p)
So i'm just wondering, what could screw it up?
Code:
public class CreateClothingSelector : ModalDialog { public List<Pattern> mOutfits = new List<Pattern>(); public ItemGrid mProfilesGrid; public Button mOkayButton; public Button mCloseButton; // The SimOutfit we end up selecting public Pattern mResult; public Pattern Result { get { return mResult; } } public static Pattern Show(List<Pattern> Outfits) { try { if (!ModalDialog.EnableModalDialogs) { return null; } using (CreateClothingSelector mCreateClothingSelector = new CreateClothingSelector(Outfits, true, true)) { mCreateClothingSelector.StartModal(); return mCreateClothingSelector.Result; } } catch (Exception ex) { GlobalOptionsSewingTable.print("Sewing table UI: " + ex.Message.ToString()); return null; } } public enum ControlIDs { EntryThumbnail = 576, EntryText, ButtonDone = 234442752, ButtonFemale, ButtonMale, ProfileGrid, ProfileSubWindow, ButtonBack = 234442768, ButtonSendMessage, ButtonPrevious, ButtonNext, BodyTypeText, ButtonClose } public const string kLayoutName = "CreateClothingSelector"; public const int kWinExportID = 1; // STILL NEED TO EDIT THE IDs! // RESEARCH: GetChildByID is the ID inside LAYO // Init the Dialog. Here we basically say "if buttons are clicked then refer to X function." and such // REFERENCE: BrowseDatingProfilesDialog public CreateClothingSelector(List<Pattern> Outfits, bool trueButtonEnabled, bool falseButtonEnabled) : base("CreateClothingSelector", 1, true, PauseMode.PauseSimulator, null) { if ((WindowBase)base.mModalDialogWindow != (WindowBase)null) { GlobalOptionsSewingTable.print("Window isn't null"); mOkayButton = (base.mModalDialogWindow.GetChildByID(99576785u, true) as Button); mOkayButton.Click += OnOkayButtonClick; GlobalOptionsSewingTable.print("Set button"); // Cancel button mCloseButton = (base.mModalDialogWindow.GetChildByID(99576785u, true) as Button); mCloseButton.Click += OnCancelButtonClick; GlobalOptionsSewingTable.print("Set other button"); // Setup 3D viewer //mSceneWindows[0] = (base.mModalDialogWindow.GetChildByID(4096u, true) as BabyMakerSceneWindow); // Set up grids mProfilesGrid = (base.mModalDialogWindow.GetChildByID(234442755u, true) as ItemGrid); // When grid has been selected, initiate the function. mProfilesGrid.ItemClicked += OnGridItemClick; GlobalOptionsSewingTable.print("On grid"); // Here we actually populate all the Grids! Make sure we also check here whether they're meant for the sewing table! foreach (Pattern outfit in Outfits) { mOutfits.Add(outfit); } PopulateGrid(); base.mModalDialogWindow.CenterInParent(); base.mModalDialogWindow.Visible = true; base.OkayID = 234442769u; base.CancelID = 234442752u; base.SelectedID = 234442769u; } } public void PopulateGrid() { mProfilesGrid.SelectedItem = -1; mProfilesGrid.Clear(); ResourceKey resKey = ResourceKey.CreateUILayoutKey("CreateClothingSelectorEntry", 0u); foreach (Pattern item in mOutfits) { // Load LAYO resource as Window Window window = UIManager.LoadLayout(resKey).GetWindowByExportID(1) as Window; Window window2 = window.GetChildByID(576u, true) as Window; // Init images so we can use our clothing's thumbnails ImageDrawable imageDrawable = window2.Drawable as ImageDrawable; if ((DrawableBase)imageDrawable != (DrawableBase)null) { // Get the thumbkey from the outfits, kindly stolen from Sims3.UI.CAS.CASEyebrows.AddPresetGridItem ThumbnailKey key = new ThumbnailKey(item.ResourceKeyPattern, ThumbnailSize.ExtraLarge); // Set image for Grid (bascally linking the Outift's thumb to a grid //imageDrawable.Image = UIUtils.GetUIImageFromThumbnailKey(thumbKey); imageDrawable.Image = UIUtils.GetUIImageFromThumbnailKey(key); // Check if it is acceptable. window2.Invalidate(); } // Add as Item Grid to the window. mProfilesGrid.AddItem(new ItemGridCellItem(window, item)); } } // Set up the 3D viewer thing public void Populate3DPreviewer() { IHudModel mHudModel = HudController.Instance.Model; SimInfo sCurrentSim = mHudModel.GetCurrentSimInfo(); //mSceneWindows[0].InitScene(); //mSceneWindows[0].SetCameraOrientation(5f, 10f, 0f, 10f); //mSceneWindows[0].FrameAll(); } public void OnCancelButtonClick(WindowBase sender, UIButtonClickEventArgs eventArgs) { mResult = null; eventArgs.Handled = true; EndDialog(base.CancelID); } public void Close() { EndDialog(base.CancelID); } public void OnGridItemClick(WindowBase sender, ItemGridCellClickEvent eventArgs) { mResult = mOutfits[mProfilesGrid.SelectedItem]; } public void OnOkayButtonClick(WindowBase sender, UIButtonClickEventArgs eventArgs) { eventArgs.Handled = true; EndDialog(0u); } }
For Resources (I know there are UITX and stuff but I noticed that wasn't too necessary.) But the LAYO_ is an exact copy of "BrowseDatingProfilesDialog" And "BrowseDatingProfilesDialogEntry" And I didn't change anything (Except changing the instance ID to work with "CreateClothingSelectorEntry" and "CreateClothingSelector")
I'm just super confused :p Do I need to somehow instantiate it before worldload? because on worldload it's where the game basically breaks entirely for me.
Advertisement
#2
8th Mar 2021 at 10:36 AM
Posts: 845
Thanks: 371 in 3 Posts
Have you possibly looked at the code of this mod which seems to have managed to design custom UIs: https://modthesims.info/d/485201/modoor-4.html
Unfortuately clueless about advanced coding so can't be of further help, I'm afraid.
Unfortuately clueless about advanced coding so can't be of further help, I'm afraid.
#3
8th Mar 2021 at 2:08 PM
Posts: 3,860
Thanks: 8537 in 67 Posts
So tuuurns out the crashing stuff was actually a whole different issue that had nothing to do with my code. But rather an outdated DLL file reference I have in my projects... woops! So that's now fixed!
Thanks for letting me know about that mod btw! Leaves me to have some references of mods that also added a similair thing
Thanks for letting me know about that mod btw! Leaves me to have some references of mods that also added a similair thing
Who Posted
|