Skip to content

Allow topmenu config file to sort with subcategories#1757

Merged
peace-maker merged 2 commits intoalliedmodders:masterfrom
PeakKS:master
Feb 18, 2024
Merged

Allow topmenu config file to sort with subcategories#1757
peace-maker merged 2 commits intoalliedmodders:masterfrom
PeakKS:master

Conversation

@PeakKS
Copy link
Contributor

@PeakKS PeakKS commented Apr 23, 2022

This allows some config files to be reused for sorting a topmenu as well. For example this config could be used both to load the data a plugin needs and to sort a topmenu:

"Menu"
{
    "Pistol"
    {
        "glock"
        {
            "price"     "200"
            "restrict"  "no"
            "knockback" "1.1"
        }
    }
    "SMG"
    {
        "mac10"
        {
            "price"     "1400"
            "restrict"  "no"
            "knockback" "1.0"
        }
    }
}

Whereas this config can only be used to sort a topmenu:

"Menu"
{
    "Pistol"
    {
        "item" "glock"
    }
    "SMG"
    {      
        "item" "mac10"
    }
}

@peace-maker
Copy link
Member

Do you have an example plugin that would benefit from this change?

@PeakKS
Copy link
Contributor Author

PeakKS commented Jul 17, 2022

I was working on something a while back where having a separate topmenu config would be completely redundant as all the information was already available in a different KV file used for creating the menu that the config would be sorting. For context, the plugin, the KV that already exists, the redundant top menu sorting file. Plus this does not affect the parsing of already existing top menu configs.

Copy link
Member

@KyleSanderson KyleSanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me, just another level if people want it.

@peace-maker
Copy link
Member

We should add some documentation for this as well. I guess this is the only place documenting sorting? https://wiki.alliedmods.net/Admin_Menu_Configuration_(SourceMod)

@peace-maker peace-maker reopened this Apr 19, 2023
@PeakKS
Copy link
Contributor Author

PeakKS commented Feb 18, 2024

We should add some documentation for this as well. I guess this is the only place documenting sorting? wiki.alliedmods.net/Admin_Menu_Configuration_(SourceMod)

Not sure if there's a way to just suggest changes on the wiki but does this look okay? Forgot this PR was still open haha.

diff --git a/olddocs.txt b/newdocs.txt
index ac4fb66..f6206d2 100644
--- a/olddocs.txt
+++ b/newdocs.txt
@@ -37,5 +37,37 @@ This layout is designed to look similar to Mani Admin Plugin's admin menu.
     }
 }</pre>
 
+=Alternate Layout=
+Alternatively instead of "item" keys subkeys can be used, with their signifying the value. It is important to note that topmenu configs are not infinitely recursive, this subkey layout works at the top level but other keys further within will not be a part of the topmenus config. Instead the ability to use these subkeys is intented to allow one config to be used as both a topmenu configuration file and a normal keyvalues file, with all the necessary information inside.
+
+
+<pre>
+"Menu"
+{
+    "PlayerCommands"
+    {
+        "sm_slay"
+        {
+            ...
+        }
+    }
+
+    "ServerCommands"
+    {
+        "sm_map"
+        {
+            ...
+        }
+    }
+
+    "VotingCommands"
+    {
+        "sm_cancelvote"
+        {
+            ...
+        }
+    }
+}</pre>
+
 [[Category:SourceMod Documentation]]

newdocs.txt

@peace-maker
Copy link
Member

You can login to the wiki using your forums account and change it directly. Thank you for writing this up.

@peace-maker peace-maker merged commit 06dcb99 into alliedmodders:master Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants