コード例 #1
0
        public void Draw_Config_Wardrobe(Wardrobe wardrobe)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            {
                Draw_Config_Field(Strings.NAME,
                                  () => wardrobe.name = GUILayout.TextField(wardrobe.name)
                                  );
                Draw_Config_Field(Strings.WEIGHT,
                                  () => int.TryParse(
                                      GUILayout.TextField(wardrobe.weight.ToString()),
                                      out wardrobe.weight
                                      )
                                  );
                Draw_Config_Field(Strings.NAME_MODE,
                                  () => wardrobe.nameMode = GUILayout.Toolbar(
                                      wardrobe.nameMode,
                                      Strings.WARDROBE_NAME_MODE,
                                      GUILayout.ExpandWidth(false)
                                      )
                                  );
            }
            GUILayout.EndVertical();

            Draw_Config_Wardrobe_NameList(wardrobe);
        }
コード例 #2
0
        public void Draw_Home()
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(Strings.NEW_WARDROBE, GUILayout.ExpandWidth(false)))
                {
                    int i;

                    bool predicate(Wardrobe v) =>
                    v.name.ToLower() == string.Format(Strings.WARDROBE_N, i).ToLower();

                    for (i = 1; Controller.wardrobes.Any(predicate); i++)
                    {
                        ;
                    }

                    Wardrobe wardrobe = new Wardrobe {
                        name = string.Format(Strings.WARDROBE_N, i)
                    };
                    Controller.wardrobes.Add(wardrobe);
                }
            }
            GUILayout.EndHorizontal();

            home_Scroll = GUILayout.BeginScrollView(home_Scroll);
            {
                foreach (Wardrobe wardrobe in Controller.wardrobes)
                {
                    Draw_Home_Item(wardrobe);
                }
            }
            GUILayout.EndScrollView();
        }
コード例 #3
0
        public void Draw_Home_Item(Wardrobe wardrobe)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(wardrobe.name);

                    if (GUILayout.Button(Strings.EDIT, GUILayout.ExpandWidth(false)))
                    {
                        config_Folder = wardrobe;
                    }

                    if (GUILayout.Button(Strings.OPEN, GUILayout.ExpandWidth(false)))
                    {
                        address.Push(wardrobe);
                    }
                }
                GUILayout.EndHorizontal();

                float maxWeight = Controller.wardrobes.Aggregate(0, (a, b) => a + b.weight) / 100f;
                float chance    = maxWeight > 0 ? wardrobe.weight / maxWeight : 0;

                GUILayout.Label(string.Format(Strings.COUNT_LAYERS, wardrobe.layers.Count));
                GUILayout.Label(string.Format(Strings.WARDROBE_WEIGHT, wardrobe.weight, chance));
            }
            GUILayout.EndVertical();
        }
コード例 #4
0
 public void Draw_Menu_Delete_Wardrobe(Wardrobe wardrobe)
 {
     if (GUILayout.Button(Strings.DELETE_WARDROBE, menu_DeleteStyle, GUILayout.ExpandWidth(false)))
     {
         Controller.wardrobes.Remove(wardrobe);
         Draw_Menu_Delete_Loop(wardrobe);
         config_Folder = null;
     }
 }
コード例 #5
0
        public void Draw_Config_Wardrobe_NameList_onAccept(Wardrobe wardrobe, string[] paths)
        {
            ChaFileControl chaFileCtrl = new ChaFileControl();

            foreach (string path in paths)
            {
                if (chaFileCtrl.LoadCharaFile(path))
                {
                    wardrobe.nameList.Add(chaFileCtrl.parameter.fullname);
                }
            }
        }
コード例 #6
0
        public void Draw_Config_Wardrobe_NameList(Wardrobe wardrobe)
        {
            switch (wardrobe.nameMode)
            {
            case 0:
                GUILayout.Label(Strings.WARDROBE_NAME_MODE_BLACKLIST);
                break;

            case 1:
                GUILayout.Label(Strings.WARDROBE_NAME_MODE_WHITELIST);
                break;
            }

            GUILayout.Label(Strings.WARDROBE_NAME_MODE_TIP);

            config_wardrobe_Scroll = GUILayout.BeginScrollView(config_wardrobe_Scroll);
            {
                int  i;
                bool flag = false;

                for (i = 0; i < wardrobe.nameList.Count; i++)
                {
                    if (flag = Draw_Config_Wardrobe_NameList_Item(wardrobe, wardrobe.nameList[i], i))
                    {
                        break;
                    }
                }

                if (flag)
                {
                    wardrobe.nameList.RemoveAt(i);
                }

                GUILayout.BeginHorizontal(GUI.skin.box);
                {
                    if (GUILayout.Button(Strings.PLUS, GUILayout.ExpandWidth(false)))
                    {
                        wardrobe.nameList.Add(string.Empty);
                    }

                    if (GUILayout.Button(Strings.BROWSE, GUILayout.ExpandWidth(false)))
                    {
                        Util.PromptCards(
                            paths => Draw_Config_Wardrobe_NameList_onAccept(wardrobe, paths),
                            Strings.CHARA_FILTER
                            );
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
コード例 #7
0
        public bool Draw_Config_Wardrobe_NameList_Item(Wardrobe wardrobe, string name, int key)
        {
            bool flag;

            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                flag = GUILayout.Button(Strings.X, GUILayout.ExpandWidth(false));
                wardrobe.nameList[key] = GUILayout.TextField(name);
            }
            GUILayout.EndHorizontal();

            return(flag);
        }
コード例 #8
0
        /// <summary>
        /// Check if there are folders/cards that are not included
        /// in the manager. This happens if the user deleted them within
        /// the manager, or a new folder/card is copied outside the
        /// manager.
        /// </summary>
        public static bool HasUnusedAssets()
        {
            string path0 = Path.GetFullPath(Strings.DATA_PATH) + "\\";

            if (!Directory.Exists(path0))
            {
                return(false);
            }

            foreach (string path1 in Directory.GetDirectories(path0))
            {
                Wardrobe wardrobe = wardrobes.FirstOrDefault(v =>
                                                             v.name.ToLower() == Path.GetFileName(path1).ToLower()
                                                             );

                if (wardrobe == null)
                {
                    return(true);
                }

                foreach (string path2 in Directory.GetDirectories(path1))
                {
                    Layer layer = wardrobe.layers.FirstOrDefault(v =>
                                                                 v.name.ToLower() == Path.GetFileName(path2).ToLower()
                                                                 );

                    if (layer == null)
                    {
                        return(true);
                    }

                    foreach (string path3 in Directory.GetFiles(path2))
                    {
                        if (Path.GetExtension(path3).ToLower() != Strings.CARD_EXTENSION)
                        {
                            continue;
                        }

                        if (!layer.cards.Any(v =>
                                             v.name.ToLower() == Path.GetFileName(path3).ToLower()
                                             ))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #9
0
        public void Draw_Wardrobe()
        {
            if (wardrobe_IndexStyle == null)
            {
                wardrobe_IndexStyle = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter,
                    fontStyle = FontStyle.Bold
                };
            }

            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(Strings.NEW_LAYER, GUILayout.ExpandWidth(false)))
                {
                    int      i;
                    Wardrobe wardrobe = address.Peek() as Wardrobe;

                    bool predicate(Layer v) =>
                    v.name.ToLower() == string.Format(Strings.LAYER_N, i).ToLower();

                    for (i = 1; wardrobe.layers.Any(predicate); i++)
                    {
                        ;
                    }

                    Layer layer = new Layer {
                        name = string.Format(Strings.LAYER_N, i)
                    };
                    wardrobe.layers.Add(layer);
                }
            }
            GUILayout.EndHorizontal();

            wardrobe_Scroll = GUILayout.BeginScrollView(wardrobe_Scroll);
            {
                if (address.Peek() is Wardrobe wardrobe)
                {
                    for (int i = 0; i < wardrobe.layers.Count; i++)
                    {
                        Draw_Wardrobe_Item(i, wardrobe.layers[i], wardrobe);
                    }
                }
            }
            GUILayout.EndScrollView();
        }
コード例 #10
0
        public void Draw_Wardrobe_Item(int index, Layer layer, Wardrobe wardrobe)
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical(GUILayout.ExpandWidth(false));
                {
                    GUILayout.Label(
                        (index + 1).ToString(),
                        wardrobe_IndexStyle,
                        GUILayout.Width(20f)
                        );

                    if (index > 1 && GUILayout.Button(Strings.T, GUILayout.Width(20f)))
                    {
                        wardrobe.layers.Remove(layer);
                        wardrobe.layers.Insert(0, layer);
                    }

                    if (index > 0 && GUILayout.Button(Strings.ARROW_UP, GUILayout.Width(20f)))
                    {
                        wardrobe.layers.Remove(layer);
                        wardrobe.layers.Insert(index - 1, layer);
                    }

                    int max = wardrobe.layers.Count - 1;

                    if (index < max && GUILayout.Button(Strings.ARROW_DOWN, GUILayout.Width(20f)))
                    {
                        wardrobe.layers.Remove(layer);
                        wardrobe.layers.Insert(index + 1, layer);
                    }

                    if (index < max - 1 && GUILayout.Button(Strings.B, GUILayout.Width(20f)))
                    {
                        wardrobe.layers.Remove(layer);
                        wardrobe.layers.Insert(max, layer);
                    }
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUI.skin.box);
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(layer.name);

                        if (GUILayout.Button(Strings.EDIT, GUILayout.ExpandWidth(false)))
                        {
                            config_Folder = layer;
                        }

                        if (GUILayout.Button(Strings.OPEN, GUILayout.ExpandWidth(false)))
                        {
                            address.Push(layer);
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Label(string.Format(Strings.COUNT_CARDS, layer.cards.Count));
                    Draw_Wardrobe_Item_Images(layer);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
コード例 #11
0
        public static void Save_Wardrobe(Wardrobe wardrobe, string path0)
        {
            if (wardrobe.name.Length == 0)
            {
                serializationWindow.Write(string.Format(
                                              Strings.UNABLE_TO_SAVE,
                                              Strings.WARDROBE.ToLower()
                                              ));
                serializationWindow.wardrobes_error++;
                return;
            }

            char[] invalidChars = Path.GetInvalidFileNameChars();

            if (wardrobe.name.Any(v => invalidChars.Contains(v)))
            {
                serializationWindow.Write(string.Format(
                                              Strings.CONTAINS_INVALID_CHAR,
                                              Strings.WARDROBE.ToLower(),
                                              wardrobe.name
                                              ));
                serializationWindow.wardrobes_error++;
                return;
            }

            serializationWindow.wardrobes++;

            string path1 = $"{path0}{wardrobe.name}\\";
            Dictionary <string, object> state = new Dictionary <string, object>
            {
                [Strings.STATE_WARDROBE_WEIGHT] = wardrobe.weight,
                [Strings.STATE_WARDROBE_ORDER]  = wardrobe.layers.Aggregate(
                    string.Empty,
                    (a, b) => $"{a}\\{b.name.ToLower()}"
                    ),
                [Strings.NAME_MODE] = wardrobe.nameMode
            };

            for (int i = 0; i < wardrobe.nameList.Count; i++)
            {
                state[Strings.STATE_WARDROBE_NAME_LIST + i] = wardrobe.nameList[i];
            }

            if (!Directory.Exists(path1))
            {
                Directory.CreateDirectory(path1);
                serializationWindow.Write(string.Format(
                                              Strings.CREATED_NEW_FOLDER,
                                              Strings.WARDROBE.ToLower(),
                                              wardrobe.name
                                              ));
            }

            File.WriteAllBytes(path1 + Strings.STATE_BIN, LZ4MessagePackSerializer.Serialize(state));

            foreach (Layer layer in wardrobe.layers)
            {
                Save_Layer(layer, path1);
            }

            // Delete unused layers.

            foreach (string path2 in Directory.GetDirectories(path1))
            {
                if (!wardrobe.layers.Any(v => v.name.ToLower() == Path.GetFileName(path2).ToLower()))
                {
                    Directory.Delete(path2, true);
                    serializationWindow.Write(string.Format(
                                                  Strings.DELETE_UNUSED,
                                                  Strings.LAYER.ToLower(),
                                                  Path.GetFileName(path2)
                                                  ));
                    serializationWindow.layers_deleted++;
                }
            }
        }