public static List <BustupData> Create_Bustup_Data_List(OfficialSetData set_data) // For dev purposes only { var new_list = new List <BustupData>(); string bustup_path = $@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//SceneMaker//Templates//{set_data.Origin}//Bustup//{set_data.ID}"; string data_path = $@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//SceneMaker//Data//Template_Data//{set_data.Origin}//Bustup//{set_data.ID}//bustup_data.json"; // Get a count of how many files are in the sprite set's directory. int filecount = OfficialSetMethods.AttachmentCountItemDirectory(bustup_path); // Create a loop starting at 1 meant to iterate though every file in the directory. // Expression numbers always start at 1, so we'll begin there. for (int expression = 1; expression <= filecount; expression++) { // Inside, create a secondary loop also meant to iterate though every file in the directory. // This loop is searching for outfits, which start at 1. for (int outfit = 1; outfit <= filecount; outfit++) { // Here, we're going to create a file path that could potentially exist given the combination of expression and outfit numbers. // Check if the created file path string exists. if (File.Exists($"{bustup_path}//{set_data.ID.ToLower()}_{expression}_{outfit}.png")) { var new_bustup_data = new BustupData() { Filename = $"{set_data.ID.ToLower()}_{expression}_{outfit}.png", Default_Name_EN = "Rise", Default_Name_JPN = "久慈川 りせ", P4D_Scale_Width = 1024, P4D_Scale_Height = 1024, P4D_Left_Coord_X = -64, P4D_Left_Coord_Y = 64, P4D_Center_Coord_X = 448, P4D_Center_Coord_Y = 64, P4D_Right_Coord_X = 960, P4D_Right_Coord_Y = 64, P4D_Nav_Scale_Width = 0, P4D_Nav_Scale_Height = 0, P4D_Nav_Coord_X = 0, P4D_Nav_Coord_Y = 0, P4D_Dual_Flip = false }; new_list.Add(new_bustup_data); } } } try { string json = JsonConvert.SerializeObject(new_list, Formatting.Indented); File.WriteAllText(data_path, json); } catch (Exception e) { Console.WriteLine($"'{e}'"); } return(new_list); }
public static string Get_Bustup_Filename(UserInfoFields account, OfficialSetData set_data, MakerCommandData command_data) { // Establish the directory of the specified sprite set. string set_path = $@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//SceneMaker//Templates//{set_data.Origin}//Bustup//{set_data.ID}"; // Get a count of how many files are in the sprite set's directory. int filecount = OfficialSetMethods.AttachmentCountItemDirectory(set_path); // Create a variable for the base sprite's filename. We'll go searching for it in a few moments. string base_sprite_filename = ""; // Create variables that keep track of how many frames of each frame type are present for the base sprite. // This will help us perform the math needed to form the sprite sheet. //int eye_frame_count = 0; //int mouth_frame_count = 0; // Check if the sprite set's directory exists. if (Directory.Exists(set_path)) { // If so, it's time to find the filename for the user's selected sprite so we can retrieve the frames associated with it. // We can do this by creating a counter starting from zero that will increment by one until it reaches the sprite numer the user specified. // Once it reaches that number, the iterated filename will be saved and we can use that to find its associated frames. int counter = 0; int base_sprite_number = command_data.Base_Sprite; // The manner of iteration will change based on the user's settings. // First, Order by Outfit. if (account.Setting_Sheet_Order == "Order by Outfit") { // Create a loop starting at 1 meant to iterate though every file in the directory. // Outfit numbers always start at 1, so we'll begin there. for (int outfit = 1; outfit <= filecount; outfit++) { // Inside, create a secondary loop also meant to iterate though every file in the directory. // This loop is searching for expressions, which start at 1. for (int expression = 1; expression <= filecount; expression++) { // Here, we're going to create a file path that could potentially exist given the combination of expression and outfit numbers. // Check if the created file path string exists. if (File.Exists($"{set_path}//{set_data.ID.ToLower()}_{expression}_{outfit}.png")) { // If the file does exist, increment the counter by one. counter++; // Check if the counter matches the same number of the chosen sprite number. if (counter == base_sprite_number) { // If it does, we found our sprite! Save the filename to the variable created earlier so we can reference it later. base_sprite_filename = $"{set_data.ID.ToLower()}_{expression}_{outfit}"; // Break out of the current loop. break; } } } // Check if the filename variable for the base sprite is not empty. if (base_sprite_filename != "") { // If so, we already found our filename! Break out of the outer loop. break; } } } // Second case, Order by Expression. else if (account.Setting_Sheet_Order == "Order by Expression") { // Create a loop starting at 1 meant to iterate though every file in the directory. // Expression numbers always start at 1, so we'll begin there. for (int expression = 1; expression <= filecount; expression++) { // Inside, create a secondary loop also meant to iterate though every file in the directory. // This loop is searching for outfits, which start at 1. for (int outfit = 1; outfit <= filecount; outfit++) { // Here, we're going to create a file path that could potentially exist given the combination of expression and outfit numbers. // Check if the created file path string exists. if (File.Exists($"{set_path}//{set_data.ID.ToLower()}_{expression}_{outfit}.png")) { // If the file does exist, increment the counter by one. counter++; // Check if the counter matches the same number of the chosen sprite number. if (counter == base_sprite_number) { // If it does, we found our sprite! Save the filename to the variable created earlier so we can reference it later. base_sprite_filename = $"{set_data.ID.ToLower()}_{expression}_{outfit}"; // Break out of the current loop. break; } } } // Check if the filename variable for the base sprite is not empty. if (base_sprite_filename != "") { // If so, we already found our filename! Break out of the outer loop. break; } } } } return($"{base_sprite_filename}.png"); }
public static List <FrameData> Create_Mouth_Frame_Data_List(OfficialSetData set_data) // For dev purposes only { // Create a new empty frame data list. // This is what we'll be using to create frame data for each image. var new_list = new List <FrameData>(); // Establish the paths for the directory where the eye frames are held, as well as the directory for where the data sheet is held. string frame_path = $@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//SceneMaker//Templates//{set_data.Origin}//Bustup//{set_data.ID}//Mouth"; string data_path = $@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//SceneMaker//Data//Template_Data//{set_data.Origin}//Bustup//{set_data.ID}//mouth_frame_data.json"; // Initialize a new int variable to zero. // We'll need this to store how many frames are in the eye frame directory. int filecount = 0; // Check if the eye frame directory established exists. // If so, change the filecount int to how many images are in the eye frame directory. if (Directory.Exists(frame_path)) { filecount = OfficialSetMethods.AttachmentCountItemDirectory(frame_path); } // If not, return null. else { return(null); } // Create a loop starting at 1 meant to iterate though every file in the directory. // Expression numbers always start at 1, so we'll begin there. for (int expression = 1; expression <= filecount; expression++) { // Inside, create a secondary loop also meant to iterate though every file in the directory. // This loop is searching for outfits, which start at 1. for (int outfit = 1; outfit <= filecount; outfit++) { // Get the current filename generated from the for loops. // This name isn't guaranteed to exist, but we will test it soon to find out. string current_filename = $"{set_data.ID.ToLower()}_{expression}_{outfit}"; // Let's get the file count for any images in the directory that share the same base sprite filename substring as our current generated name. // We do that by forming an array of all filenames that match. string[] allFiles = Directory.GetFiles(frame_path, $"{current_filename}_m*.png"); // Take the length of the array and assign it to a new int variable. int base_sprite_eye_frame_count = allFiles.Length; // We're already within two loops to generate the base filename, but now we need to use another loop to iterate through potentially multiple frames for the same sprite. for (int i = 1; i <= base_sprite_eye_frame_count; i++) { // Here, we're going to create a file path that could potentially exist given the combination of expression and outfit numbers. // Check if the created file path string exists. if (File.Exists($"{frame_path}//{set_data.ID.ToLower()}_{expression}_{outfit}_m{i}.png")) { // If so, generate a new frame data object for the frame. var new_frame_data = new FrameData() { Filename = $"{set_data.ID.ToLower()}_{expression}_{outfit}_m{i}.png", Scale_Width = 176, Scale_Height = 100, Coord_X = 268, Coord_Y = 537 }; new_list.Add(new_frame_data); } } } } // Write all text to the data file. try { string json = JsonConvert.SerializeObject(new_list, Formatting.Indented); File.WriteAllText(data_path, json); } catch (Exception e) { Console.WriteLine($"'{e}'"); } return(new_list); }