Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport v1 additions to v2 #50

Merged
merged 9 commits into from
Jan 4, 2024
Merged
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
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug Report
about: Create a report to help us improve the mod.
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
[A clear and simple description of what the bug is **Remove this line!**]

**To Reproduce**
Steps to reproduce the behaviour:
1. [replace with]
2. [all the steps]
3. [required to explain]
4. [how to reproduce]
5. [remove/add steps as you see fit]

**Mod Version and OS**
[What mod version are you using and operating system. **Remove this line!**]

**Screenshot/Video**
[Screenshots/video evidence of the issue occuring is applicable. **Remove this line!**]

**Effected Scripts**
[Add any website links to effected scripts. **Remove this line!**]
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord Contact
url: https://discord.gg/gtfFwWEapx
about: Contact us via our discord
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
steps:
- uses: actions/checkout@v1
- name: Set up JDK 17
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[![Build](https://github.com/DFOnline/DFScript/actions/workflows/build.yml/badge.svg)
](https://github.com/DFOnline/DFScript/actions/workflows/build.yml)
[![Build](https://github.com/DFScripting/DFScript/actions/workflows/build.yml/badge.svg)
](https://github.com/DFScripting/DFScript/actions/workflows/build.yml)
# DFScript
DFScript is a mod created for DiamondFire to allow scripting on the client. This mod is a seperation and improvement from the shutdown mod [CodeUtilities](https://github.com/CodeUtilities/CodeUtilities).

- You can download DFScript from its [Github page](https://github.com/DFOnline/DFScript/releases/latest), or its [Modrinth page](https://modrinth.com/mod/dfscript).
- You can report issues on [the issues tab](https://github.com/DFOnline/DFScript/issues)
- You can download DFScript from its [Github page](https://github.com/DFScripting/DFScript/releases/latest), or its [Modrinth page](https://modrinth.com/mod/dfscript).
- You can report issues on [the issues tab](https://github.com/DFScripting/DFScript/issues)

- You can join our [discord here](https://discord.gg/gtfFwWEapx)

Expand Down Expand Up @@ -107,8 +107,8 @@ You can easily back up scripts here by copy and pasting the json file into anoth
___

<p>
<img src="https://img.shields.io/github/downloads/DFOnline/DFScript/total?color=blue"/>
<img src="https://img.shields.io/github/languages/code-size/DFOnline/DFScript"/>
<img src="https://img.shields.io/github/contributors/DFOnline/DFScript" />
<img src="https://img.shields.io/github/release-date/DFOnline/DFScript" />
<img src="https://img.shields.io/github/downloads/DFScripting/DFScript/total?color=blue"/>
<img src="https://img.shields.io/github/languages/code-size/DFScripting/DFScript"/>
<img src="https://img.shields.io/github/contributors/DFScripting/DFScript" />
<img src="https://img.shields.io/github/release-date/DFScripting/DFScript" />
</p>
9 changes: 9 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Security Policy

## Definition of a Vulnerability
We define a security vulnerability to be a weakness in a product, service, or software that could allow an attacker to comprimise the integrity, availability, or data of that product, service, or software.

## Reporting a Vulnerability
**Please do not report security vulnerabilities publically (e.g. through discord, creating a GitHub issue).**

If you believe that the security issue you have found is considered to be a vulnerability under our definition then please report it to us via github, or email us at **vulnerability@techstreet.tech**.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class MOptionsScreen extends Screen {
@Unique
private final Identifier identifier_main_highlight = new Identifier(DFScript.MOD_ID + ":scripts_highlight");

@Unique
private final Identifier identifier_test = new Identifier(DFScript.MOD_ID + ":scripts");
@Unique
private final Identifier identifier_test_highlight = new Identifier(DFScript.MOD_ID + ":scripts_highlight");

public MOptionsScreen(Text literalText) {
super(literalText);
}
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/io/github/techstreet/dfscript/screen/CScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -38,7 +39,7 @@ public void render(@NotNull DrawContext context, int mouseX, int mouseY, float t

// float scaleFactor = (float) mc.getWindow().getScaleFactor();
float scaleFactor = 2;
stack.scale(scaleFactor,scaleFactor,0);
stack.scale(scaleFactor,scaleFactor,1F);

stack.translate(-width/2f, -height/2f, 0);

Expand Down Expand Up @@ -143,4 +144,34 @@ public boolean shouldCloseOnEsc() {

return super.shouldCloseOnEsc();
}

@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
mouseX = translateMouseX(mouseX);
mouseY = translateMouseY(mouseY);

for (int i = widgets.size() - 1; i >= 0; i--) {
if (widgets.get(i).mouseReleased(mouseX, mouseY, button)) {
break;
}
}

return super.mouseReleased(mouseX, mouseY, button);
}

@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
mouseX = translateMouseX(mouseX);
mouseY = translateMouseY(mouseY);
deltaX = translateMouseX(deltaX);
deltaY = translateMouseY(deltaY);

for (int i = widgets.size() - 1; i >= 0; i--) {
if (widgets.get(i).mouseDragged(mouseX, mouseY, button, deltaX, deltaY)) {
break;
}
}

return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,221 +35,6 @@ public ScriptEditScreen(Script script) {
this.script = script;

reload();
/*panel = new CScrollPanel(0, 3, 120, 94);

//CTextField description = new CTextField(script.getDescription(), 3, 3, 115, 20, true);
//description.setChangedListener(() -> script.setDescription(description.getText()));
//panel.add(description);

widgets.add(panel);

int y = 0;
int index = 0;
int indent = 0;

CText name = new CText(5,y+2,Text.literal(script.getName()),0,1,false,false);
panel.add(name);

CButton settings = new CTexturedButton(120-8, y, 8, 8, DFScript.MOD_ID + ":settings.png", () -> {
DFScript.MC.setScreen(new ScriptSettingsScreen(this.script, true));
}, 0, 0, 1, 0.5f, 0, 0.5f);

panel.add(settings);

y += 10;

for (ScriptPart part : script.getParts()) {
if (part instanceof ScriptEvent se) {
panel.add(new CItem(5, y, se.getType().getIcon()));
panel.add(new CText(15, y + 2, Text.literal(se.getType().getName())));
indent = 5;

int currentIndex = index;
panel.add(new CButton(5, y-1, 115, 10, "",() -> {}) {
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
Rectangle b = getBounds();

if (b.contains(mouseX, mouseY)) {
int color = 0x33000000;

DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
}
}

@Override
public boolean mouseClicked(double x, double y, int button) {
if (getBounds().contains(x, y)) {
DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f,1f));

if (button != 0) {
CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
});
CButton insertAfter = new CButton((int) x, (int) y+8, 40, 8, "Insert After", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
});
CButton delete = new CButton((int) x, (int) y+16, 40, 8, "Delete", () -> {
script.getParts().remove(currentIndex);
scroll = panel.getScroll();
DFScript.MC.setScreen(new ScriptEditScreen(script));
});
DFScript.MC.send(() -> {
panel.add(insertBefore);
panel.add(insertAfter);
panel.add(delete);
contextMenu.add(insertBefore);
contextMenu.add(insertAfter);
contextMenu.add(delete);
});
}
return true;
}
return false;
}
});
} else if (part instanceof ScriptAction sa) {
if (sa.getType() == ScriptActionType.CLOSE_BRACKET) {
indent -= 5;
}

panel.add(new CItem(5 + indent, y, sa.getType().getIcon()));
panel.add(new CText(15 + indent, y + 2, Text.literal(sa.getType().getName())));

createIndent(indent, y);

int currentIndex = index;
panel.add(new CButton(5, y - 1, 115, 10, "", () -> {
}) {
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
Rectangle b = getBounds();
if (b.contains(mouseX, mouseY)) {
int color = 0x33000000;

if (sa.getType().isDeprecated()) {
color = 0x80FF0000;
}

DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
} else {
if (sa.getType().isDeprecated()) {
DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, 0x33FF0000);
}
}
}

@Override
public boolean mouseClicked(double x, double y, int button) {
if (getBounds().contains(x, y)) {
DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f, 1f));

if (button == 0) {
if (sa.getType() != ScriptActionType.CLOSE_BRACKET) {
scroll = panel.getScroll();
DFScript.MC.setScreen(new ScriptEditActionScreen(sa, script));
}
} else {
CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
});
CButton insertAfter = new CButton((int) x, (int) y + 8, 40, 8, "Insert After", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
});
CButton delete = new CButton((int) x, (int) y + 16, 40, 8, "Delete", () -> {
script.getParts().remove(currentIndex);
scroll = panel.getScroll();
DFScript.MC.setScreen(new ScriptEditScreen(script));
});
DFScript.MC.send(() -> {
panel.add(insertBefore);
panel.add(insertAfter);
panel.add(delete);
contextMenu.add(insertBefore);
contextMenu.add(insertAfter);
contextMenu.add(delete);
});
}
return true;
}
return false;
}
});

if (sa.getType().hasChildren()) {
indent += 5;
}
} else if (part instanceof ScriptComment sc) {
panel.add(new CItem(5 + indent, y, new ItemStack(Items.MAP).setCustomName(Text.literal("Comment").setStyle(Style.EMPTY.withItalic(false)))));

CTextField cTextField = new CTextField(sc.getComment(),15+indent, y-1, width-(15+indent)-5, 10, true);

cTextField.setChangedListener(() -> sc.setComment(cTextField.getText()));

panel.add(cTextField);

int currentIndex = index;

panel.add(new CButton(5, y-1, 115, 10, "",() -> {}) {
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float tickDelta) {
Rectangle b = getBounds();

if (b.contains(mouseX, mouseY)) {
int color = 0x33000000;

DrawableHelper.fill(stack, b.x, b.y, b.x + b.width, b.y + b.height, color);
}
}

@Override
public boolean mouseClicked(double x, double y, int button) {
if (getBounds().contains(x, y)) {
DFScript.MC.getSoundManager().play(PositionedSoundInstance.ambient(SoundEvents.UI_BUTTON_CLICK, 1f,1f));

if (button != 0) {
CButton insertBefore = new CButton((int) x, (int) y, 40, 8, "Insert Before", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex));
});
CButton insertAfter = new CButton((int) x, (int) y+8, 40, 8, "Insert After", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, currentIndex + 1));
});
CButton delete = new CButton((int) x, (int) y+16, 40, 8, "Delete", () -> {
script.getParts().remove(currentIndex);
scroll = panel.getScroll();
DFScript.MC.setScreen(new ScriptEditScreen(script));
});
DFScript.MC.send(() -> {
panel.add(insertBefore);
panel.add(insertAfter);
panel.add(delete);
contextMenu.add(insertBefore);
contextMenu.add(insertAfter);
contextMenu.add(delete);
});

return true;
}
}
return false;
}
});

createIndent(indent, y);
} else {
throw new IllegalArgumentException("Unknown script part type");
}

y += 10;
index++;
}

CButton add = new CButton(37, y, 46, 8, "Add", () -> {
DFScript.MC.setScreen(new ScriptActionCategoryScreen(script, script.getParts().size()));
});

panel.add(add);
panel.setScroll(scroll);*/
}

public void reload()
Expand Down
Loading
Loading