Replies: 9 (Who?), Viewed: 867 times.
Virtual gardener
staff: administrator
Original Poster
#1 Old 22nd Mar 2020 at 3:05 PM
Default Creating a modal with Gameobjects rather than Ingredients
Hi everyone!

Currently, I'm working on some code that should open a dialogue that should list all possible craftables. Now, looking at EA's original code, I seem to see that all their code that does exactly what I want it to do is all done with "Ingredients". (So, fishes, books, seeds, metals, etc). That code handles the whole stacking stuff and whatnot, but in my case, I'm working with objects that are regular GameObjects. 

Now I am aware that in the current state that my code is right now, is that it needs the 'sewables' already in the world (Somehow need to figure that one out too :p) So please ignore that

Code:

public static List<IGameObject> ShowSewableItemsDialog()
      {
         List<ObjectPicker.HeaderInfo>    header = new List<ObjectPicker.HeaderInfo>();
         List<ObjectPicker.TabInfo>       tab = new List<ObjectPicker.TabInfo>();
         
         Sewables[] sewables = Sims3.Gameplay.Queries.GetObjects<Sewables>();
         
         // This is always the same. you can only select one project at a time.
         int numSelectableRows = 1;
         
         // Add another header.Add if ever need to have 2 header entries.
         header.Add(new ObjectPicker.HeaderInfo("Header test", "HeaderTestTooltip", 250));
         
         // Tab? No idea what this does honestly. I think it's just the 2 tabs you see with name and quantity
         ObjectPicker.TabInfo tabinfo = new ObjectPicker.TabInfo(string.Empty, LocalizeString("TabText"), new List<ObjectPicker.RowInfo>());
         
         foreach(Sewables sewable in sewables)
         {
            ObjectPicker.RowInfo rowInfo = new ObjectPicker.RowInfo(sewable, new List<ObjectPicker.ColumnInfo>());
            
            rowInfo.ColumnInfo.Add(new ObjectPicker.ThumbAndTextColumn(
               sewable.GetThumbnailKey(), 
               sewable.GetLocalizedName()
               )
            );
            rowInfo.ColumnInfo.Add(new ObjectPicker.NumberColumn(sewables.Length));
            tabinfo.RowInfo.Add(rowInfo);
            
            StyledNotification.Format format = new StyledNotification.Format(sewable.GetThumbnailKey().ToString(), StyledNotification.NotificationStyle.kGameMessagePositive);
            StyledNotification.Show(format);
         }
         
         tab.Add(tabinfo);
         List<ObjectPicker.RowInfo> rowInfo1 = ObjectPickerDialog.Show(
            "SmeltMetalHeaderText", 
            Localization.LocalizeString("Ui/Caption/Global:Ok"), 
            Localization.LocalizeString("Ui/Caption/Global:Cancel"), 
            tab, 
            header, 
            numSelectableRows
         );
         
         List<IGameObject> result = null;
         if (rowInfo1 != null && rowInfo1.Count > 0)
         {
            result = new List<IGameObject>();
            {
               foreach (Sewables sewable in sewables)
               {
                  result.Add(sewable);
                  StyledNotification.Format resultid = new StyledNotification.Format(result.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive);
                  StyledNotification.Show(resultid);
               }
               return result;
            }
         }
         return result;
      }

I will be honest, it feels like all I need is just the bit till the show option. But in both instances with and without the "if (rowInfo1 != null && rowInfo1.Count > 0)", it will either return 0, or it will show the modal like this:



Instead, I want something like this, without the quantity cell :



Thanks!
Screenshots
Advertisement
Field Researcher
#2 Old 22nd Mar 2020 at 4:42 PM Last edited by Battery : 22nd Mar 2020 at 5:03 PM.
Seems like line 27 is redundant :P
Virtual gardener
staff: administrator
Original Poster
#3 Old 22nd Mar 2020 at 5:26 PM
Quote:
Originally Posted by Battery
Seems like line 27 is redundant :P
Lol yes, :p It's actually showing it now!



So indeed, the fact that I accidentally made it so that it needed another column even though this wasn't necessary whatsoever was the issue!  Thanks again for your help Battery!
Screenshots
Field Researcher
#4 Old 22nd Mar 2020 at 6:16 PM
As an FYI, tabs are the little buttons above the table that allow you to place multiple lists of rows into a single menu dialog and switch between them; for example, when shopping at a bookstore, you can switch between lists of different genres of books.

If there is no need for this feature, EA standard is to create a single tab with an empty image name and a general caption name (i.e. what you've done here).

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Mad Poster
#5 Old 23rd Mar 2020 at 4:11 PM
Do love the way this is going, and I hope it'll lead to a more comprehensive crafting system in TS3!
Lab Assistant
#6 Old 23rd Mar 2020 at 8:41 PM
Wow this is awesome :D
Virtual gardener
staff: administrator
Original Poster
#7 Old 24th Mar 2020 at 12:04 PM
Quote:
Originally Posted by jje1000
Do love the way this is going, and I hope it'll lead to a more comprehensive crafting system in TS3!
Hopefully! I'd love to get more people introduced in these kinds of things tbh!  Though I did notice however that making crafting more difficult (and away from EA's method) wasn't *too* valued. 

I was thinking about making a thread for this particular project though! But I didn't yet since it's still really close in its early stages. I do think I might do it just for the sake of asking preferred gameplay questions and what people would like to see.
Trainee Moderator
staff: trainee moderator
#8 Old 26th Mar 2020 at 10:29 PM Last edited by zoe22 : 26th Mar 2020 at 11:03 PM.
In ani's anvil mod, she gets the list of forgable objects from this function:
Code:
List<string> list = new List<string>();
	XmlDbData xmlDbData = XmlDbData.ReadData("AnvilConfig");
	XmlDbTable value;
	if (xmlDbData != null && xmlDbData.Tables != null && xmlDbData.Tables.TryGetValue("ForgedObjects", out value) && value != null)
	{
		foreach (XmlDbRow row in value.Rows)
		{
			list.Add(row.GetString("object"));
		}
		return list;
	}
	return list;

In the xml file, it just has the strings with the Type:Group:Instance like what you use when creating a custom object in the world like "319e4f1d:00000000:67250BC86B693189".

So I'm guessing it should work with just the list of the strings? But having the xml file would be cool to allow people to add their own sewables :D

edit: To get the ThumbnailKey you need to do
Code:
ThumbnailKey thumbnail = new ThumbnailKey(ResourceKey.FromString(sewableString), ThumbnailSize.Medium);

Not sure about how to get the localized name though, not sure if the string would do it. I think it might judging by ani's code which has
Code:
ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(forgableObject, list2);

where list2 just has the thumbnail i think.
Virtual gardener
staff: administrator
Original Poster
#9 Old 27th Mar 2020 at 12:00 PM
Hiya @zoe22 !

Ah yeah! I remember you told me to look into Ani's stuff!  I was indeed thinking of doing it the same way, but I think I'm still conflicted with one thing here when it comes to Ani's way:

The user/person who creates their own Sewables needs an up-to-date XML file with that of others. Which begs the question, would this work if you have 2 CC creators who update the XML file? Obviously it will override each other's XML file once people have both their content in their games.

Now, that actually shouldn't be too big of an issue to bypass if I apply a different importing method which is similar to how CCloader does it. But the question then is, after the release would CC creators actually create stuff to be sewables? I've noticed Arsil struggling with those things too. 

Anyways! I think I'll be making a thread so that others can help out of they want to! I've noticed a lot of people here and on Tumblr really would love to
Test Subject
#10 Old 18th Oct 2020 at 10:54 AM
Omg this is all so awesome! I’m really new at this but being able to mod a game is so intriguing! I always loved the Nraas mods for this and now I’m getting into modding myself and all these terms and files look like a language from a different planet to me. I printed so many tutorials to understand it all I’m very eager to learn. I have so many projects in my head like replacing meals with TSM ones and collectibles and stuff. Great job! And I love how you’re still modding for The Sims 3❤️
Back to top