Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified jars/Multiplayer.jar
Binary file not shown.
59 changes: 40 additions & 19 deletions src/data/scripts/plugins/gui/MPChatboxPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class MPChatboxPlugin extends BaseEveryFrameCombatPlugin {
// singleton
public static MPChatboxPlugin INSTANCE = null;

// Define a class-level field for the scaling multiplier
private float scaleMult;

private static LazyFont.DrawableString TODRAW14;

private String input;
Expand All @@ -30,6 +33,7 @@ private enum ActivePanel {
CHAT,
NONE,
}

private ActivePanel active = ActivePanel.TEXT_ONLY;

private ListPanel widget;
Expand All @@ -42,11 +46,16 @@ public MPChatboxPlugin() {

@Override
public void init(CombatEngineAPI engine) {
// Initialize scaling multiplier
scaleMult = Global.getSettings().getScreenScaleMult();

if (TODRAW14 == null) {
try {
LazyFont fontdraw = LazyFont.loadFont("graphics/fonts/victor14.fnt");
TODRAW14 = fontdraw.createText();
if (Global.getSettings().getScreenScaleMult() > 1f) TODRAW14.setFontSize(14f * Global.getSettings().getScreenScaleMult());
// If scaling is greater than 1, adjust small font size by the multiplier
if (scaleMult > 1f)
TODRAW14.setFontSize(14f * scaleMult);
} catch (FontException ignored) {
}
}
Expand All @@ -66,8 +75,9 @@ public void processInputPreCoreControls(float amount, List<InputEventAPI> events
float w = Global.getSettings().getScreenWidthPixels();
float h = Global.getSettings().getScreenHeightPixels();

Vector2f root1 = new Vector2f(w - 92f, h - 148f);
Vector2f root2 = new Vector2f(w - 364f, 500f);
// Use scaleMult to adjust the root position of UI elements
Vector2f root1 = new Vector2f(w - 92f * scaleMult, h - 244f * scaleMult);
Vector2f root2 = new Vector2f(w - 364f * scaleMult, 596f * scaleMult);

CMUKitUI.render(widget, root1, events);

Expand All @@ -85,15 +95,17 @@ public void processInputPreCoreControls(float amount, List<InputEventAPI> events

private ListPanel initWidget() {
ListPanel.ListPanelParams panelParams = new ListPanel.ListPanelParams();
panelParams.x = 60f;
panelParams.y = 26f;
// Use scaleMult to set the x and y positions of the panel
panelParams.x = 60f * scaleMult;
panelParams.y = 26f * scaleMult;

return new ListPanel(panelParams, new ListPanel.PanelMaker() {
@Override
public void make(ListPanel panel1) {
Button.ButtonParams buttonParams = new Button.ButtonParams();
buttonParams.width = 58f;
buttonParams.height = 24f;
// Use scaleMult to set the width and height of the button
buttonParams.width = 58f * scaleMult;
buttonParams.height = 24f * scaleMult;
Text.TextParams textParams = new Text.TextParams();
textParams.align = LazyFont.TextAlignment.CENTER;
Text text = new Text(new Execute<String>() {
Expand Down Expand Up @@ -125,8 +137,9 @@ public void onClick() {

private ListPanel initChatbox() {
final ListPanel.ListPanelParams panelParams = new ListPanel.ListPanelParams();
panelParams.x = 360f;
panelParams.y = 380f;
// Use scaleMult to set the x and y positions of the panel
panelParams.x = 360f * scaleMult;
panelParams.y = 380f * scaleMult;
panelParams.update = false;

final ListPanel textPanel = initTextPanel();
Expand All @@ -137,15 +150,17 @@ public void make(ListPanel panel1) {
panel1.addChild(textPanel);

TextEntryBox.TextEntryBoxParams textEntryBoxParams = new TextEntryBox.TextEntryBoxParams();
textEntryBoxParams.width = 350f;
textEntryBoxParams.height = 24f;
// Use scaleMult to set the width and height of the button
textEntryBoxParams.width = 350f * scaleMult;
textEntryBoxParams.height = 24f * scaleMult;
Text.TextParams textParams1 = new Text.TextParams();
final TextEntryBox textEntryBox = new TextEntryBox(textEntryBoxParams, TODRAW14, textParams1);
panel1.addChild(textEntryBox);

Button.ButtonParams buttonParams = new Button.ButtonParams();
buttonParams.width = 42f;
buttonParams.height = 17f;
// Use scaleMult to set the width and height of the button
buttonParams.width = 42f * scaleMult;
buttonParams.height = 17f * scaleMult;
Text.TextParams textParams = new Text.TextParams();
textParams.align = LazyFont.TextAlignment.CENTER;
Text text = new Text(new Execute<String>() {
Expand All @@ -168,12 +183,16 @@ public void onClick() {

private ListPanel initTextPanel() {
final ListPanel.ListPanelParams textPanelParams = new ListPanel.ListPanelParams();
textPanelParams.x = 350f;
textPanelParams.y = 360f;
// Use scaleMult to set the x and y positions of the panel
textPanelParams.x = 350f * scaleMult;
textPanelParams.y = 360f * scaleMult;
textPanelParams.noDeco = true;
textPanelParams.conformToListSize = true;
textPanelParams.update = true;

// Define a padding value to ensure text is not too close to the edges
final float padding = 4f;

return new ListPanel(textPanelParams, new ListPanel.PanelMaker() {
@Override
public void make(ListPanel panel) {
Expand All @@ -193,14 +212,16 @@ public void make(ListPanel panel) {
final String tt = t;

TODRAW14.setText(t);
TODRAW14.setMaxWidth(textPanelParams.x - 4f);
// Set the maximum width of the text, applying padding and scaling
TODRAW14.setMaxWidth(textPanelParams.x - padding * scaleMult);
height += TODRAW14.getHeight();
if (height > textPanelParams.y) break;

Text.TextParams textParams = new Text.TextParams();
textParams.color = Color.WHITE;
textParams.maxWidth = textPanelParams.x - 4f;
textParams.maxHeight = 50f;
// Set the maximum width the text can occupy within the panel, applying padding and scaling
textParams.maxWidth = textPanelParams.x - padding * scaleMult;
textParams.maxHeight = 50f * scaleMult; // Scale the text height
Text text = new Text(new Execute<String>() {
@Override
public String get() {
Expand All @@ -211,7 +232,7 @@ public String get() {
toAdd.add(text);
}

for (int i = toAdd.size(); i-- > 0;) {
for (int i = toAdd.size(); i-- > 0; ) {
panel.addChild(toAdd.get(i));
}
}
Expand Down
Loading