Basic implementation
Some checks failed
/ Build & Publish (push) Failing after 46s

This commit is contained in:
Daniella / Tove 2024-06-25 06:30:44 +02:00
parent c7b0d7afde
commit e155c31771
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
12 changed files with 245 additions and 46 deletions

View file

@ -17,11 +17,13 @@ jobs:
java-version: 8 java-version: 8
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Initialize Gradle - name: Initialize Gradle
uses: https://github.com/gradle/actions/setup-gradle@v3 uses: https://github.com/gradle/actions/setup-gradle@v3
- name: Build - name: Build
run: ./gradlew build run: ./gradlew build
- name: Publish - name: Publish
run: VERSION=$(git describe --always) ./gradlew publish run: VERSION=$(git rev-list --count HEAD) ./gradlew publish
env: env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}

5
.gitignore vendored
View file

@ -5,10 +5,7 @@ build/
!**/src/test/**/build/ !**/src/test/**/build/
### IntelliJ IDEA ### ### IntelliJ IDEA ###
.idea/modules.xml /.idea
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws *.iws
*.iml *.iml
*.ipr *.ipr

8
.idea/.gitignore generated vendored
View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

16
.idea/gradle.xml generated
View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

10
.idea/misc.xml generated
View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml generated
View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# ClientBoot
It's Grub, but for Minecraft mods.

View file

@ -8,13 +8,18 @@ version = '1.0-SNAPSHOT'
repositories { repositories {
mavenCentral() mavenCentral()
maven { url = 'https://git.tudbut.de/api/packages/TudbuT/maven' }
}
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 60, 'seconds'
} }
dependencies { dependencies {
implementation('de.tudbut:tuddylib:+')
} }
test { test {
useJUnitPlatform()
} }
publishing { publishing {

View file

@ -0,0 +1,5 @@
package de.com.baseband.clientboot;
public interface CBCallback {
void run(ClientBoot boot);
}

View file

@ -0,0 +1,11 @@
package de.com.baseband.clientboot;
class CBCallbackContainer {
final String name;
final CBCallback callback;
CBCallbackContainer(String name, CBCallback callback) {
this.name = name;
this.callback = callback;
}
}

View file

@ -0,0 +1,167 @@
package de.com.baseband.clientboot;
import de.tudbut.tools.Lock;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
public class CBWindow extends JFrame implements WindowListener {
final Lock openLock = new Lock(true);
final ClientBoot parent;
final Stack<List<CBCallbackContainer>> options = new Stack<>();
{
options.push(new ArrayList<>());
}
int selected = 0;
Lock justRanSomething = new Lock();
public CBWindow(String name, ClientBoot parent) {
super();
this.parent = parent;
add(new RootComponent());
getContentPane().setBackground(new Color(0x303030));
setSize(600, 400);
setTitle(name);
setResizable(false);
setLocation(20, 20);
addWindowListener(this);
}
public void waitForClose() {
setVisible(true);
while(poll());
}
public boolean poll() {
if (openLock.isLocked()) {
EventQueue.invokeLater(this::repaint);
openLock.waitHere(20);
return true;
}
return false;
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
@Override
public void windowOpened(WindowEvent e) {
openLock.lock(3000);
}
@Override
public void windowClosing(WindowEvent e) {
setVisible(false);
openLock.unlock();
}
@Override
public void windowClosed(WindowEvent e) {}
@Override
public void windowIconified(WindowEvent e) {}
@Override
public void windowDeiconified(WindowEvent e) {}
@Override
public void windowActivated(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
private class RootComponent extends Component implements MouseListener, KeyListener {
{
CBWindow.this.addMouseListener(this);
CBWindow.this.addKeyListener(this);
}
@Override
public void paint(Graphics g) {
Graphics2D g2 = ((Graphics2D) g);
g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
int y = 5;
g.setFont(new Font("Fira Code", Font.BOLD, 25));
g.setColor(new Color(0xcc00cc));
g.drawString("ClientBoot", 5, y += 25);
g.setFont(new Font("Fira Code", Font.BOLD, 15));
y += 5 + 15;
if(openLock.timeLeft() != Long.MAX_VALUE) {
g.drawString("Continuing in " + openLock.timeLeft() / 1000 + "s...", 5, y);
}
List<CBCallbackContainer> list = options.peek();
for (int i = 0; i < list.size(); i++) {
if(justRanSomething.isLocked() && i == selected) {
g.setColor(new Color(0xee00ee));
g.drawString("> "+ list.get(i).name, 7, y += 2 + 15);
g.setColor(new Color(0xcc00cc));
continue;
}
g.drawString((i == selected ? "> " : "") + list.get(i).name, 5, y += 2 + 15);
}
}
@Override
public void mouseClicked(MouseEvent e) {
openLock.lock();
}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
@Override
public void keyTyped(KeyEvent e) {}
@Override
public void keyPressed(KeyEvent e) {
openLock.lock();
if(options.peek().isEmpty()) {
return;
}
justRanSomething.unlock();
if(e.getKeyCode() == KeyEvent.VK_DOWN && options.peek().size() > selected + 1) {
selected++;
}
if(e.getKeyCode() == KeyEvent.VK_UP && selected != 0) {
selected--;
}
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
justRanSomething.lock(200);
options.peek().get(selected).callback.run(parent);
}
}
@Override
public void keyReleased(KeyEvent e) {}
}
}

View file

@ -1,4 +1,53 @@
package de.com.baseband.clientboot; package de.com.baseband.clientboot;
import de.tudbut.parsing.TCN;
import java.util.ArrayList;
public class ClientBoot { public class ClientBoot {
public static void main(String[] args) {
new ClientBoot("ClientBoot Test")
.option("Print something", x -> x.newScreen()
.option("Hello!", x1 -> System.out.println("Hello!"))
.option("Hellorld!", x1 -> System.out.println("Hellorld!"))
.option("Back", ClientBoot::back))
.option("Exit", ClientBoot::finish)
.show();
System.exit(0);
}
private final CBWindow window;
public final TCN data = new TCN();
public ClientBoot(String name) {
window = new CBWindow(name, this);
}
public ClientBoot newScreen() {
window.options.push(new ArrayList<>());
window.selected = 0;
window.justRanSomething.unlock();
return this;
}
public ClientBoot option(String name, CBCallback callback) {
window.options.peek().add(new CBCallbackContainer(name, callback));
return this;
}
public void back() {
window.options.pop();
window.selected = 0;
window.justRanSomething.unlock();
}
public void finish() {
window.windowClosing(null);
}
public TCN show() {
window.waitForClose();
return data;
}
} }