-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when attempting to close title menu
- Loading branch information
1 parent
78b4a12
commit 5ca7c01
Showing
9 changed files
with
185 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
src/main/java/io/github/minifabric/minifabric_api/impl/MenuDuck.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 35 additions & 12 deletions
47
src/main/java/io/github/minifabric/minifabric_api/impl/SingleModDisplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,51 @@ | ||
package io.github.minifabric.minifabric_api.impl; | ||
|
||
import com.mojang.ld22.screen.controlmenu.ControlMenu; | ||
import com.mojang.ld22.screen.controlmenu.TextControlMenu; | ||
import com.mojang.ld22.gfx.Font; | ||
import com.mojang.ld22.gfx.Screen; | ||
import com.mojang.ld22.screen.Menu; | ||
import com.mojang.ld22.gfx.Color; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class SingleModDisplay extends TextControlMenu { | ||
public SingleModDisplay(ControlMenu parent, String mod_name, String content, String version) { | ||
super(parent); | ||
public class SingleModDisplay extends Menu { | ||
private Menu parent; | ||
private String title; | ||
private String version; | ||
ArrayList<String> desc = new ArrayList<>(); | ||
|
||
|
||
@Override | ||
public void tick() { | ||
if (this.input.attack.clicked || this.input.menu.clicked) { | ||
this.game.setMenu(this.parent); | ||
} | ||
|
||
} | ||
public SingleModDisplay(Menu parent, String mod_name, String content, String version) { | ||
this.parent = parent; | ||
this.title = mod_name; | ||
List matchList = new ArrayList(); | ||
Pattern regex = Pattern.compile("(.{1,24}(?:\\s|$))|(.{0,10})", Pattern.DOTALL); | ||
this.version = version; | ||
|
||
Pattern regex = Pattern.compile("(.{1,20}(?:\\s|$))|(.{0,10})", Pattern.DOTALL); | ||
Matcher regexMatcher = regex.matcher(content); | ||
while (regexMatcher.find()) { | ||
matchList.add(regexMatcher.group()); | ||
desc.add(regexMatcher.group()); | ||
} | ||
} | ||
|
||
@Override | ||
public void render(Screen screen) { | ||
int screenPos = 24; | ||
screen.clear(0); | ||
Font.draw(title, screen, 4, 8, Color.get(0, 333, 333, 333)); | ||
for (String s : desc) { | ||
Font.draw(s, screen, 0, screenPos, Color.get(0, 333, 333, 333)); | ||
screenPos += 8; | ||
} | ||
matchList.forEach(phrase -> { | ||
this.addTextLine((String) phrase, Color.get(0, 333, 333, 333)); | ||
}); | ||
|
||
this.addTextLine(version, Color.get(0, 50, 50, 50)); | ||
Font.draw(version, screen, 4, screenPos, Color.get(0, 50, 50, 50)); | ||
} | ||
} |
Oops, something went wrong.