Client Settings (GUI)

Discussion in 'Incubator' started by overdhose, Jul 1, 2012.

    overdhose Active Member

    Cervator edit: Moved to Incubator, added header

    Name: Client Settings (GUI)
    Summary: An options UI providing game settings and in particular custom key bindings
    Scope: Engine (and supports mods)
    Current Goal: Stabilize and add more options
    Phase: Maintenance
    Curator: @ddr2 taking over from @overdhose who built on top of stuff by @Immortius and @ironchefpython
    Related: Other GUI threads

    had a need to have some config settings of my own, delayed it long enough
    here is what I made, might be temp solution, let me know if it's acceptable
    modopt1.png modopt2.png
    I created a ModData and MinionData proto respectively.

    overdhose Active Member

    I'll include experimental options to enable / disable sound / music, think we had an issue open for that, can be moved to general settings later, I prefer not to interfere with existing things

    Ten'son' Member

    The possibility to hide HUD (for screenshots) could be awesome. :D

    overdhose Active Member

    heh ok that shouldn't be to hard

    looking at the issues I'll see what I can do for the jumping and the keybinding, about keybinding though, I'm thinking of adding a seperate screen like modData called InputData, with matching proto. Might have azerty defaults though :p

    overdhose Active Member

    I'll include the hidegui and jumpbehaviour in input :
    modopt3.png

    overdhose Active Member

    to easily map mouse and key buttons, I used this trick :
    Code:
     public int getKey(String skey)
        {
            if(skey.startsWith("MOUSE"))
            {
                if(skey == "MOUSELEFT"){
                    return 256;
                }else if(skey == "MOUSERIGHT"){
                    return 257;
                }else if(skey == "MOUSEMIDDLE"){
                    return 258;
                }else if(skey == "MOUSEWHEELUP"){
                    return 259;
                }else if(skey == "MOUSEWHEELDOWN"){
                    return 260;
                }else {
                    return 261;
                }           
            }else {
                return Keyboard.getKeyIndex("KEY_" + skey);
            }
        }
    so mapping keys in the config screen uses the default Keyboard enum values and the Mouse values in the function.
    Let me know if you don't like it.

    overdhose Active Member

    InputSystem code
    Code:
     private int linkMouseByConfig(int button)
        {
            switch(button){
                case 256 : return 0;
                case 257 : return 1;
                case 258 : return 2;
                case 259 : return +1;
                case 260 : return -1;
                default: return 2;
            }
        }
     
        private void REPLACE_THIS_WITH_CONFIG() {
            InputConfig inputConfig = InputConfig.getInstance();
            int keyvalue;
    
            registerBindButton(InventoryButton.ID, "Inventory", new InventoryButton());
            keyvalue = inputConfig.getKeyInventory();
            if(keyvalue < 256){
                linkBindButtonToKey(keyvalue, InventoryButton.ID);
            }else{
                linkBindButtonToMouse(linkMouseByConfig(keyvalue), InventoryButton.ID);
            }
    

    begla Project Founder and Lead Developer

    Just learned something new. So much new stuff... Great work Immortius. ;)

    overdhose Active Member

    all that extra work what I wanted to do was toy around with the controller input :ninja: yet another screen I'll need to add after all this.

    overdhose Active Member

    should this be kept together or split?
    optional bool animated_water_and_grass = 19 [default = false];

    begla Project Founder and Lead Developer

    Animated water is gone for the time being anyhow (animated vertices). We'll just need "animated grass".

    begla Project Founder and Lead Developer

    I've pushed the stuff to develop. All you need to enabled the water reflection is to adjust...

    in the Config class. If you want to add this to your config menu, make sure to trigger a shader recompile. This incorporates some compiler directives in the chunk shader.

    overdhose Active Member

    I wish I knew what you were saying o_O I'll uch make the screens and add options, you might have to add the trigger yourself

    Cervator Project Lead and Community Wizard

    Immortius Lead Software Architect

    Thanks begla. IronChefPython deserves thanks too as he contributed the foundations of the Input System and got the ball rolling.

    @overdhose - I like what you are doing, but have some suggestions around the persistence of the config. It would be nice if the config files were in a human editable format - I would suggest using Java Bean + gson instead of protobuf to save the config as JSON. Then for the the keys/mouse buttons you could store the string name of the button (using Keyboard.getKeyName() and Mouse.getButtonName()), prefixed with KEY_ or MOUSE_ respectively (assuming that is appropriate). You can then convert back by reading off the prefix and using Keyboard.getKeyIndex() and Mouse.getButtonIndex() respectively, plus some quick checks for the mouse wheel names. This would also handle mice with more than 3 buttons (such as mine :p)

    A nice format for the input may be something along the lines of:
    Code:
    {
         "input" : {
              "engine" : {
                   "moveForwards" : "KEY_W",
                   "moveBackwards" : "KEY_S",
                   "fire" : "MOUSE_1"
                   .....
              },
              "minions" : {
                   "toggleMinionMode" : "KEY_X"
              }
        }
    }
    
    So the inputs are grouped by their owning mod.

    I realize this probably would perform a bit worse than just storing the integer values like you are doing, but since this would be done rarely (only during load, plus a small amount when updating inputs), it should be acceptable.

    overdhose Active Member

    I was planning to add a whole interface to that thing so you wouldn't need to edit the file yourself.
    So human readable seemed less necessary. I'm gonna finish this round first, will look into changing it into gson.
    I only copied the config way of doing things tbh, I'm already glad I made it a seperate file.

    overdhose Active Member

    sneak peak : input screen
    sneak1.png
    must be about the most boring thing I did in Terasology.
    It leaves room to add stuff, if this seems unnecessary let me know I can center it more

    I was pondering what would be the best way to add mod related button configs, maybe a button with the mods name that opens a seperate screen? Might get crowded though. I initially thought of adding it in the mods... section but that might be counter intuitive spreading it so far out.
    • Like Like x 1

    begla Project Founder and Lead Developer

    Maybe now is the right time to introduce UI layouts! Like a simple centering one. :) So you don't have to do that manually all the time.

    overdhose Active Member

    yeah I considered that myself, even a full fledged ui editor :D

    Just as a fyi : the most work is actually copy pasting the same thing over and over again, the positioning was actually pretty fast, hence the editor idea

    Cervator Project Lead and Community Wizard

    I've merged this code to our integrate branch after testing that it (mostly) works, or at least doesn't break too much :D

    Feels a bit like the key mappings are stuck in AZERTY or something? But testing around with different keys (oohh, I forgot what 'r' did!)I can move enough to prove to myself that the game still works - now we just need to make the key mapping popup work!

    I've discussed with new contributor @ddr2 on IRC and am tagging him as curator for this feature, taking over from @overdhose (who'll be in hibernation due to RL for a while). There are other potential interested parties too, join in if you're available, this is the perfect time!

    I also moved this thread to the Incubator and added the standard header :)

Share This Page