ldtteam / minecolonies-features

This is a repo only to discuss minecolonies features (requested and planned)
10 stars 3 forks source link

Changing Composter Hut's Min Warehouse Stock setting value is janky #460

Open dupontct opened 3 years ago

dupontct commented 3 years ago

Prerequisites

Context

Expected behavior

The GUI for the Compost Hut Settings page will let you type in a completely new value for the setting.

Actual behavior

If you try to delete the setting value starting from the right most position it will not let you delete the left most digit. It will let you delete up to the left most digit. Then after deleting the remaining digit it will immediately replace the blank value with the character that was just deleted.

The only way to reliable set a zero value in the setting is to place your cursor at the right most position and type a 0 character, then move the cursor left 1 position and then use backspace to remove the characters to the left of the 0.

Steps to reproduce the issue

  1. Place townhall, and composters hut
  2. Try to modify the Min Warehouse Stock setting value.

Logs

Notes


Viewers

Raycoms commented 3 years ago

That's actually intended to avoid invalid values. Empty is an invalid value atm.

dhouck commented 3 years ago

I think it might be more intuitive if blank in the gui meant either 0 or "reset to default" when you saved the value, instead of not being possible.

Raycoms commented 3 years ago

There are two possibilities: a) You enter the value and the value is set in the system b) You enter the value and need a confirmation button

The value in the input box updates to the value of the system automatically. So if "" means default the UI would update to the default then. So the only laternative is b) And I think that's meh.

dupontct commented 3 years ago

Would it be possible to make the text of invalid value red and only set the setting value when the window is closed or switched to another window?

The behavior would be type in a non-numeric value text turns red until a numeric value is entered. If text is not a valid numeric value when window is closed or switched to another window the setting value remains unchanged. If text is valid numeric value when window is closed or switched to another window the setting is then changed.

Also I am asking if this is currently possible with no or very minor changes to BlockOut.

dupontct commented 3 years ago

On further examination of BlockOut. I don't think what I am asking for in the above post would be feasible.

One idea that might help would be to not replace the blank text field with current value.

Changing: https://github.com/ldtteam/minecolonies/blob/35af8153057bd038cbf2d944fae7ba65c0eab0a3/src/main/java/com/minecolonies/coremod/colony/buildings/modules/settings/IntSetting.java#L101-L104

        if (!field.getText().equals(String.valueOf(this.value)))
        {
            field.setText(String.valueOf(value));
        }

So it also checks to see that the field value is not blank before replacing the field value with the setting value.