Skip to content

Commit c4e67e8

Browse files
committed
feat: add Specify the card number to which you are transferring in the comments
1 parent a4d6db2 commit c4e67e8

5 files changed

Lines changed: 35 additions & 22 deletions

File tree

src/main/java/zadudoder/spmhelper/ModMenuIntegration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
5252
})
5353
.build());
5454

55+
general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("text.spmhelper.option.numberOfCardInComment"), config.numberOfCardInComment)
56+
.setSaveConsumer(newValue -> config.numberOfCardInComment = newValue)
57+
.build());
5558
return builder.build();
5659
};
5760
}

src/main/java/zadudoder/spmhelper/Screen/MainScreen.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,29 @@ protected void init() {
9999
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
100100
super.render(context, mouseX, mouseY, delta);
101101

102-
Identifier MainText = Identifier.of("spmhelper", "titles/spmhelpertextmain.png");
103-
int originalWidth = 932 / 4;
104-
int originalHeight = 152 / 4;
102+
Identifier MainText = Identifier.of("spmhelper", "titles/spmhelpertextmain.png");
103+
int originalWidth = 932 / 4;
104+
int originalHeight = 152 / 4;
105105

106-
// Рассчитываем размер изображения
107-
int availableWidth = width - 2 * SCREEN_PADDING;
108-
int imageWidth = Math.min(originalWidth, availableWidth);
109-
float scale = (float) imageWidth / originalWidth;
110-
int imageHeight = (int) (originalHeight * scale);
106+
// Рассчитываем размер изображения
107+
int availableWidth = width - 2 * SCREEN_PADDING;
108+
int imageWidth = Math.min(originalWidth, availableWidth);
109+
float scale = (float) imageWidth / originalWidth;
110+
int imageHeight = (int) (originalHeight * scale);
111111

112-
// Позиционируем изображение по центру сверху
113-
int totalRows = (int) Math.ceil((double) BUTTON_COUNT /
114-
Math.max(1, Math.min(BUTTON_COUNT,
115-
availableWidth / (MIN_BUTTON_WIDTH + HORIZONTAL_SPACING))));
116-
int totalButtonsHeight = totalRows * BUTTON_HEIGHT + (totalRows - 1) * VERTICAL_SPACING;
117-
int totalBlockHeight = imageHeight + IMAGE_BOTTOM_MARGIN + totalButtonsHeight;
118-
int startY = (height - totalBlockHeight) / 2;
112+
// Позиционируем изображение по центру сверху
113+
int totalRows = (int) Math.ceil((double) BUTTON_COUNT /
114+
Math.max(1, Math.min(BUTTON_COUNT,
115+
availableWidth / (MIN_BUTTON_WIDTH + HORIZONTAL_SPACING))));
116+
int totalButtonsHeight = totalRows * BUTTON_HEIGHT + (totalRows - 1) * VERTICAL_SPACING;
117+
int totalBlockHeight = imageHeight + IMAGE_BOTTOM_MARGIN + totalButtonsHeight;
118+
int startY = (height - totalBlockHeight) / 2;
119+
120+
int imageX = (width - imageWidth) / 2;
121+
int imageY = startY;
119122

120-
int imageX = (width - imageWidth) / 2;
121-
int imageY = startY;
123+
context.drawTexture(MainText, imageX, imageY, 0, 0, imageWidth, imageHeight, imageWidth, imageHeight);
122124

123-
context.drawTexture(MainText, imageX, imageY, 0, 0, imageWidth, imageHeight, imageWidth, imageHeight);
124125
}
125126

126127
private void handleButtonClick(int buttonLabel) {

src/main/java/zadudoder/spmhelper/Screen/Pays/PayScreen.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class PayScreen extends Screen {
2424
private TextFieldWidget receiverCardOrNameField;
2525
private TextFieldWidget amountField;
2626
private TextFieldWidget commentField;
27+
2728
private String p_number;
2829
private String p_amount;
2930
private String p_comment;
@@ -216,8 +217,14 @@ private void processTransfer() {
216217
return;
217218
}
218219

219-
if ((MinecraftClient.getInstance().getSession().getUsername().length() + commentField.getText().length()) > 32) {
220-
setStatus (String.format(Text.translatable("text.spmhelper.pays_processTransfer_CommentIsLong").getString(), (30 - MinecraftClient.getInstance().getSession().getUsername().length())), 0xFF5555);
220+
String comment = commentField.getText();
221+
222+
if (SPmHelperConfig.get().numberOfCardInComment) {
223+
comment = commentField.getText() + " " + receiverCardNumber;
224+
}
225+
226+
if ((MinecraftClient.getInstance().getSession().getUsername().length() + commentField.getText().length()) + Integer.parseInt(receiverCardNumber) > 32) {
227+
setStatus (String.format(Text.translatable("text.spmhelper.pays_processTransfer_CommentIsLong").getString(), (29 - MinecraftClient.getInstance().getSession().getUsername().length()) - Integer.parseInt(receiverCardNumber)), 0xFF5555);
221228
return;
222229
}
223230

@@ -226,7 +233,8 @@ private void processTransfer() {
226233
senderCard,
227234
receiverCardNumber,
228235
amount,
229-
commentField.getText()
236+
comment
237+
230238
);
231239
if (response.has("error")) {
232240
String error = response.get("error").toString();

src/main/java/zadudoder/spmhelper/config/SPmHelperConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class SPmHelperConfig implements ConfigData {
1717
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
1818
public ScreenType defaultScreen = ScreenType.MAIN;
1919
public Boolean paymentWithNick = false; // true - ник, false - по номеру
20+
public Boolean numberOfCardInComment = false; // true - включено, false - выключено в переводе будет указывать карту куда вы переводите
2021

2122
String API_TOKEN = "";
2223
Map<String, Card> cards = new HashMap<>();

src/main/resources/assets/spmhelper/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"text.spmhelper.config.category": "Настройки мода",
99
"text.spmhelper.option.enableMenuButton": "Включить кнопку SPmHelper в основном меню: ",
1010
"text.spmhelper.option.defaultScreen": "На какой экран будет вести эта кнопка: ",
11-
"text.spmhelper.option.paymentNickOrNumber": "Оплата по нику:",
11+
"text.spmhelper.option.numberOfCardInComment": "Указывать номер карты куда вы переводите в комментарии?",
1212
"text.spmhelper.screen_type.main": "Главный экран",
1313
"text.spmhelper.screen_type.settings": "Настройки",
1414
"text.spmhelper.screen_type.pay": "Оплата",

0 commit comments

Comments
 (0)