Added an Energy Textbox Widget #364

Closed
Trytoon wants to merge 2 commits from my1.20-6.0.7 into dev/1.20.1
Trytoon commented 2023-07-27 16:08:55 +00:00 (Migrated from github.com)

Description

A Textbox that only accepts numbers and format with comma separator in real time.
It can be used in buffers to set energy i/o and was also used in capacitor banks in 1.12

The way I imagine it is that the menu in which it is used control whatever value is stored on it. When ticking, then menu gets the integer and do whatever we want with it (communicate it with the block entity etc...)

I am sure that this can be improved, I take suggestions from the main team (you guys are very skilled :D )

Checklist:

  • My code follows the style guidelines of this project (.editorconfig, most IDEs will use this for you).
  • I have performed a self-review of my own code.
  • I have commented my code in areas it may be challenging to understand.
  • I have made corresponding changes to the documentation.
  • My changes are ready for review from a contributor.
# Description A Textbox that only accepts numbers and format with comma separator in real time. It can be used in buffers to set energy i/o and was also used in capacitor banks in 1.12 The way I imagine it is that the menu in which it is used control whatever value is stored on it. When ticking, then menu gets the integer and do whatever we want with it (communicate it with the block entity etc...) I am sure that this can be improved, I take suggestions from the main team (you guys are very skilled :D ) # Checklist: - [X] My code follows the style guidelines of this project (.editorconfig, most IDEs will use this for you). - [X] I have performed a self-review of my own code. - [X] I have commented my code in areas it may be challenging to understand. <!-- (Although we prefer code that is readable instead of over-commented) --> - [X] I have made corresponding changes to the documentation. - [X] My changes are ready for review from a contributor.
dphaldes (Migrated from github.com) requested changes 2023-07-31 12:43:23 +00:00
dphaldes (Migrated from github.com) left a comment

Haven't tested in-game. just initial code review :)

Haven't tested in-game. just initial code review :)
@ -0,0 +1,108 @@
package com.enderio.machines.client.gui.widget;
dphaldes (Migrated from github.com) commented 2023-07-31 12:39:37 +00:00

redundant override ?

redundant override ?
dphaldes (Migrated from github.com) commented 2023-07-31 12:41:24 +00:00

I don't think you are supposed to return false unless you don't consume the input

I don't think you are supposed to return `false` unless you don't consume the input
@ -0,0 +31,4 @@
return res;
}
return false;
dphaldes (Migrated from github.com) commented 2023-07-31 12:42:40 +00:00

always return false?

always return `false`?
Trytoon (Migrated from github.com) reviewed 2023-07-31 13:46:59 +00:00
@ -0,0 +31,4 @@
return res;
}
return false;
Trytoon (Migrated from github.com) commented 2023-07-31 13:46:59 +00:00

yes.
Because I want only digits to be entered (0,1, ..., 9)
Any other character cannot be entered.
It could be improved if we think we need to do so by allowing prefixes like k = 1000 etc...

yes. Because I want only digits to be entered (0,1, ..., 9) Any other character cannot be entered. It could be improved if we think we need to do so by allowing prefixes like k = 1000 etc...
Rover656 (Migrated from github.com) requested changes 2023-08-02 18:17:05 +00:00
@ -0,0 +88,4 @@
}
try {
DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getInstance(Locale.US);
Rover656 (Migrated from github.com) commented 2023-08-02 18:17:03 +00:00

Should be swapped to Locale.ROOT imo :)

Should be swapped to Locale.ROOT imo :)
Rover656 commented 2023-08-02 18:17:29 +00:00 (Migrated from github.com)

Looks good from what I can see, its difficult to tell how this will work in game without an explainer, but I trust that it should behave as expected :)

Looks good from what I can see, its difficult to tell how this will work in game without an explainer, but I trust that it should behave as expected :)
Trytoon commented 2023-08-13 18:54:40 +00:00 (Migrated from github.com)

Well, this one wasn't merged before I finished the buffers.
Full implementation done in #455 so I'm going to close this .

Well, this one wasn't merged before I finished the buffers. Full implementation done in #455 so I'm going to close this .

Pull request closed

Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Team-EnderIO/EnderIO#364
No description provided.