Skip to content

Commit

Permalink
テキストフィールドからはみ出してテキストを空白にするとクラッシュするバグがあったので、サイズを変えてからテキストを空白にセットするとかなり…
Browse files Browse the repository at this point in the history
…無理やりだが空白文字にできた
  • Loading branch information
Hashibutogarasu committed Feb 26, 2022
1 parent 03f8bcf commit f75ff1d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package com.hashibutogarasu.screenshottweet.Custom;

import io.github.cottonmc.cotton.gui.widget.WTextField;
import net.minecraft.text.TranslatableText;

import static com.hashibutogarasu.screenshottweet.Ids.Id.MOD_ID;
import static com.hashibutogarasu.screenshottweet.guis.TweetScreenGUI.root;
import static com.hashibutogarasu.screenshottweet.guis.TweetScreenGUI.tweettext;

public class CustomTextField extends WTextField {
public void clear(){
for(int c = this.getText().length(); c>=0; c--){
this.setText(this.getText().substring(0,c));
}
public void refresh() throws InterruptedException {
tweettext.setSize(2000,12);
Thread.sleep(100);
tweettext.setText(new TranslatableText(MOD_ID + ".gui.tweettextfield").getString());
Thread.sleep(100);
root.remove(tweettext);
Thread.sleep(100);
root.add(tweettext, 13, 2, 7, 12);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hashibutogarasu.screenshottweet.Threads;

import com.hashibutogarasu.screenshottweet.Configs.ScreenshotTweetConfigScreenFactory;
import com.hashibutogarasu.screenshottweet.Custom.CustomTextField;
import com.hashibutogarasu.screenshottweet.Ids.Id;
import com.hashibutogarasu.screenshottweet.ScreenshotTweetModClient;
import io.github.cottonmc.cotton.gui.widget.WLabel;
Expand Down Expand Up @@ -28,6 +29,7 @@ public TwitterThread(boolean tweets){
@Override
public void run(){

tweettext.setEditable(false);
tweetbutton.setEnabled(false);

NetCheck.Checkinternetconnection();
Expand Down Expand Up @@ -66,8 +68,16 @@ public void run(){

Default.reset();

tweetbutton.setEnabled(true);

try {
tweettext.refresh();
}
catch (InterruptedException e) {

}

tweetbutton.setEnabled(true);
tweettext.setEditable(true);
}

public static void Oauth(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public TweetScreenGUI()
root.add(list, 0, 2, 12, 9);

tweettext = new CustomTextField();
tweettext.setMaxLength(100);
tweettext.setMaxLength(140);

root.add(tweettext, 13, 2, 7, 12);

statusimage = new WSprite(none);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/screenshottweet/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"screenshottweet.gui.oauthscreen.loggedas" : "Loggining as %s",
"screenshottweet.gui.oauthscreen.oauthloggedas" : "Loggining as %s",
"gui.screenshottweet.title" : "Screenshot Tweet Settings",
"screenshottweet.gui.tweettextfield" : "",
"screenshottweet.gui.tweetstatuslabel" : "",
"screenshottweet.gui.tweetstatuslabel.oauth" : "Oauthing",
"screenshottweet.gui.tweetstatuslabel.oauth.ok" : "OK",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/screenshottweet/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"screenshottweet.gui.oauthscreen.loggedas" : "%sとしてログイン中",
"screenshottweet.gui.oauthscreen.oauthloggedas" : "%sとしてログイン中",
"gui.screenshottweet.title" : "Screenshot Tweetの設定",
"screenshottweet.gui.tweettextfield" : "",
"screenshottweet.gui.tweetstatuslabel" : "",
"screenshottweet.gui.tweetstatuslabel.oauth" : "認証中",
"screenshottweet.gui.tweetstatuslabel.oauth.ok" : "認証しました",
Expand Down

0 comments on commit f75ff1d

Please sign in to comment.