Exemplo n.º 1
0
        internal void loadSettings(ConfigNode toolbarNode)
        {
            Log.info("loading toolbar settings (toolbar '{0}')", toolbarNode.name);

            rect.x = toolbarNode.get("x", DEFAULT_X);
            rect.y = toolbarNode.get("y", DEFAULT_Y);
            rect.width = toolbarNode.get("width", DEFAULT_WIDTH);
            rect.height = toolbarNode.get("height", 0f);
            autoHide = toolbarNode.get("autoHide", false);
            showBorder = toolbarNode.get("drawBorder", true);
            UseKSPSkin = toolbarNode.get("useKSPSkin", false);
            savedButtonOrder = toolbarNode.get("buttonOrder", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            savedVisibleButtons = new HashSet<string>(toolbarNode.get("visibleButtons", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));

            if (toolbarNode.HasNode("folders")) {
                foreach (ConfigNode folderNode in toolbarNode.GetNode("folders").nodes) {
                    string folderId = folderNode.name;
                    string texturePath = folderNode.get("texturePath", "000_Toolbar/folder");
                    if (!textureExists(texturePath)) {
                        texturePath = "000_Toolbar/folder";
                    }
                    string toolTip = folderNode.get("toolTip", string.Empty);
                    HashSet<string> buttonIds = new HashSet<string>(folderNode.get("buttons", string.Empty).Split(new char[] { ',' }));

                    Toolbar folder = createFolder(folderId, texturePath, toolTip, false);

                    savedFolderSettings[folderId].buttons = buttonIds;
                }
            }

            savedMaxWidth = rect.width;

            updateVisibleButtons();
            sortButtons(buttons, compareButtonsUserOrder);
        }