client base

This commit is contained in:
core 2023-07-14 23:49:03 -04:00
commit 86be867fdd
Signed by: core
GPG Key ID: FDBF740DADDCEECF
28 changed files with 1896 additions and 0 deletions

118
.gitignore vendored Normal file
View File

@ -0,0 +1,118 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

2
LICENSE Normal file
View File

@ -0,0 +1,2 @@
Copyright (c) 2023 c0repwn3r
All rights reserved.

98
build.gradle Normal file
View File

@ -0,0 +1,98 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
version = project.mod_version
group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name = "lukflug"
url = "https://lukflug.github.io/maven/"
}
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
}
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "com.lukflug:panelstudio:0.2.4"
implementation "com.lukflug:panelstudio-mc20:0.2.4"
implementation "meteordevelopment:orbit:0.2.3"
}
processResources {
inputs.property "version", project.version
inputs.property "minecraft_version", project.minecraft_version
inputs.property "loader_version", project.loader_version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version,
"minecraft_version": project.minecraft_version,
"loader_version": project.loader_version
}
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

17
gradle.properties Normal file
View File

@ -0,0 +1,17 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
# Mod Properties
mod_version = 1.0-SNAPSHOT
maven_group = dev.coredoes
archives_base_name = coreclient
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.85.0+1.20.1

View File

@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

245
gradlew vendored Executable file
View File

@ -0,0 +1,245 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

92
gradlew.bat vendored Normal file
View File

@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

9
settings.gradle Normal file
View File

@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@ -0,0 +1,69 @@
package dev.coredoes.coreclient;
import dev.coredoes.coreclient.gui.Category;
import dev.coredoes.coreclient.gui.ClickGUI;
import dev.coredoes.coreclient.gui.module.*;
import meteordevelopment.orbit.EventBus;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
public class CoreClient implements ClientModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("coreclient");
public static EventBus eventBus;
private static ClickGUI gui;
private boolean inited=false;
private final boolean[] keys =new boolean[266];
@Override
public void onInitializeClient() {
LOGGER.info("Hello, world! CoreClient is loading up");
LOGGER.info("[Stage 1/4: BusInit] Creating plugin event bus");
eventBus = new EventBus();
eventBus.registerLambdaFactory("dev.coredoes.coreclient", ((lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())));
LOGGER.info("[Stage 2/4: GuiCategoryInit] Initializing Category");
Category.init();
LOGGER.info("[Stage 3/4: GuiModuleInit] Registering Modules");
Category.OTHER.modules.add(new ClickGUIModule());
Category.OTHER.modules.add(new HUDEditorModule());
Category.HUD.modules.add(new TabGUIModule());
Category.HUD.modules.add(new WatermarkModule());
Category.HUD.modules.add(new LogoModule());
LOGGER.info("[Stage 4/4: GuiEventInit] Registering GUI events");
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (!inited) {
for (int i=32;i<keys.length;i++) keys[i]= GLFW.glfwGetKey(MinecraftClient.getInstance().getWindow().getHandle(),i)==GLFW.GLFW_PRESS;
gui=new ClickGUI();
HudRenderCallback.EVENT.register((cli, tickDelta)->gui.render());
inited=true;
}
for (int i=32;i<keys.length;i++) {
if (keys[i]!=(GLFW.glfwGetKey(MinecraftClient.getInstance().getWindow().getHandle(),i)==GLFW.GLFW_PRESS)) {
keys[i]=!keys[i];
if (keys[i]) {
if (i==ClickGUIModule.keybind.getKey()) gui.enterGUI();
if (i==HUDEditorModule.keybind.getKey()) gui.enterHUDEditor();
gui.handleKeyEvent(i);
}
}
}
});
LOGGER.info("CoreClient loaded!");
}
}

View File

@ -0,0 +1,108 @@
package dev.coredoes.coreclient.gui;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Stream;
import dev.coredoes.coreclient.gui.module.Module;
import dev.coredoes.coreclient.gui.setting.BooleanSetting;
import dev.coredoes.coreclient.gui.setting.ColorSetting;
import dev.coredoes.coreclient.gui.setting.DoubleSetting;
import dev.coredoes.coreclient.gui.setting.IntegerSetting;
import dev.coredoes.coreclient.gui.setting.Setting;
import dev.coredoes.coreclient.gui.setting.StringSetting;
import com.lukflug.panelstudio.setting.ICategory;
import com.lukflug.panelstudio.setting.IClient;
import com.lukflug.panelstudio.setting.IModule;
public enum Category implements ICategory {
COMBAT("Combat"),EXPLOITS("Exploits"),HUD("HUD"),MISCELLANEOUS("Miscellaneous"),MOVEMENT("Movement"),OTHER("Other"),RENDER("Render"),WORLD("World");
public final String displayName;
public final List<Module> modules=new ArrayList<Module>();
public static Random random=new Random();
private Category (String displayName) {
this.displayName=displayName;
}
public static void init() {
for (Category category: Category.values()) {
int count=random.nextInt(6)+5;
for (int i=0;i<count;i++) {
if (category!=OTHER && category!=HUD) category.modules.add(generateRandomModule());
}
}
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public Stream<IModule> getModules() {
return modules.stream().map(module->module);
}
public static IClient getClient() {
return new IClient() {
@Override
public Stream<ICategory> getCategories() {
return Arrays.stream(Category.values());
}
};
}
public static Module generateRandomModule() {
Module module=new Module(generateRandomName(5,10),generateRandomName(10,20),()->true,random.nextInt(2)==0);
int count=random.nextInt(6)+5;
for (int i=0;i<count;i++) {
module.settings.add(generateRandomSetting());
}
return module;
}
public static Setting<?> generateRandomSetting() {
String displayName=generateRandomName(5,10);
String description=generateRandomName(10,20);
int type=random.nextInt(6);
int min=random.nextInt(50),max=random.nextInt(50)+50;
boolean alpha=random.nextInt(2)==0;
boolean rainbow=random.nextInt(2)==0;
Color color=new Color(random.nextInt(256),random.nextInt(256),random.nextInt(256),alpha?random.nextInt(256):255);
switch (type) {
case 0:
return new BooleanSetting(displayName,displayName,description,()->true,random.nextInt(2)==0);
case 1:
return new ColorSetting(displayName,displayName,description,()->true,alpha,rainbow,color,rainbow?random.nextInt(2)==0:false);
case 2:
return new DoubleSetting(displayName,displayName,description,()->true,min,max,random.nextDouble()*(max-min)+min);
case 4:
return new IntegerSetting(displayName,displayName,description,()->true,min,max,random.nextInt(max-min+1)+min);
default:
return new StringSetting(displayName,displayName,description,()->true,generateRandomName(5,10));
}
};
public static String generateRandomName (int min, int max) {
int length=random.nextInt(max-min+1)+min;
String s="";
for (int i=0;i<length;i++) {
int type=random.nextInt(5);
switch (type) {
case 0:
s+=' ';
break;
case 1:
s+=(char)('A'+random.nextInt(26));
break;
default:
s+=(char)('a'+random.nextInt(26));
}
}
return s;
}
}

View File

@ -0,0 +1,496 @@
package dev.coredoes.coreclient.gui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.EnumMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.IntPredicate;
import java.util.function.Supplier;
import org.lwjgl.glfw.GLFW;
import dev.coredoes.coreclient.gui.Category;
import dev.coredoes.coreclient.gui.module.ClickGUIModule;
import dev.coredoes.coreclient.gui.module.ClickGUIModule.Theme;
import dev.coredoes.coreclient.gui.module.HUDEditorModule;
import dev.coredoes.coreclient.gui.module.LogoModule;
import dev.coredoes.coreclient.gui.module.TabGUIModule;
import dev.coredoes.coreclient.gui.module.WatermarkModule;
import dev.coredoes.coreclient.gui.setting.BooleanSetting;
import dev.coredoes.coreclient.gui.setting.ColorSetting;
import dev.coredoes.coreclient.gui.setting.IntegerSetting;
import com.lukflug.panelstudio.base.Animation;
import com.lukflug.panelstudio.base.Context;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.base.IInterface;
import com.lukflug.panelstudio.base.IToggleable;
import com.lukflug.panelstudio.base.SettingsAnimation;
import com.lukflug.panelstudio.base.SimpleToggleable;
import com.lukflug.panelstudio.component.IComponent;
import com.lukflug.panelstudio.component.IFixedComponent;
import com.lukflug.panelstudio.component.IResizable;
import com.lukflug.panelstudio.component.IScrollSize;
import com.lukflug.panelstudio.container.IContainer;
import com.lukflug.panelstudio.hud.HUDGUI;
import com.lukflug.panelstudio.layout.CSGOLayout;
import com.lukflug.panelstudio.layout.ChildUtil.ChildMode;
import com.lukflug.panelstudio.layout.ComponentGenerator;
import com.lukflug.panelstudio.layout.IComponentAdder;
import com.lukflug.panelstudio.layout.IComponentGenerator;
import com.lukflug.panelstudio.layout.ILayout;
import com.lukflug.panelstudio.layout.PanelAdder;
import com.lukflug.panelstudio.layout.PanelLayout;
import com.lukflug.panelstudio.layout.SearchableLayout;
import com.lukflug.panelstudio.layout.SinglePanelAdder;
import com.lukflug.panelstudio.layout.StackedPanelAdder;
import com.lukflug.panelstudio.mc20.MinecraftHUDGUI;
import com.lukflug.panelstudio.popup.CenteredPositioner;
import com.lukflug.panelstudio.popup.IPopupPositioner;
import com.lukflug.panelstudio.popup.MousePositioner;
import com.lukflug.panelstudio.popup.PanelPositioner;
import com.lukflug.panelstudio.popup.PopupTuple;
import com.lukflug.panelstudio.setting.IBooleanSetting;
import com.lukflug.panelstudio.setting.IClient;
import com.lukflug.panelstudio.setting.IColorSetting;
import com.lukflug.panelstudio.setting.IEnumSetting;
import com.lukflug.panelstudio.setting.INumberSetting;
import com.lukflug.panelstudio.setting.Labeled;
import com.lukflug.panelstudio.theme.ClearTheme;
import com.lukflug.panelstudio.theme.GameSenseTheme;
import com.lukflug.panelstudio.theme.IColorScheme;
import com.lukflug.panelstudio.theme.ITheme;
import com.lukflug.panelstudio.theme.IThemeMultiplexer;
import com.lukflug.panelstudio.theme.ImpactTheme;
import com.lukflug.panelstudio.theme.OptimizedTheme;
import com.lukflug.panelstudio.theme.RainbowTheme;
import com.lukflug.panelstudio.theme.ThemeTuple;
import com.lukflug.panelstudio.theme.Windows31Theme;
import com.lukflug.panelstudio.widget.ColorPickerComponent;
import com.lukflug.panelstudio.widget.CycleSwitch;
import com.lukflug.panelstudio.widget.DropDownList;
import com.lukflug.panelstudio.widget.ITextFieldKeys;
import com.lukflug.panelstudio.widget.Spinner;
import com.lukflug.panelstudio.widget.ToggleSwitch;
import net.minecraft.util.Formatting;
public class ClickGUI extends MinecraftHUDGUI {
private final GUIInterface inter;
private final HUDGUI gui;
public static final int WIDTH=120,HEIGHT=12,DISTANCE=6,BORDER=2;
public ClickGUI() {
// Getting client structure ...
IClient client= Category.getClient();
/* Set to false to disable horizontal clipping, this may cause graphical glitches,
* but will let you see long text, even if it is too long to fit in the panel. */
inter=new GUIInterface(true) {
@Override
protected String getResourcePrefix() {
return "examplemod:";
}
};
// Instantiating theme ...
ITheme theme=new OptimizedTheme(new ThemeSelector(inter));
// Instantiating GUI ...
IToggleable guiToggle=new SimpleToggleable(false);
IToggleable hudToggle=new SimpleToggleable(false) {
@Override
public boolean isOn() {
return guiToggle.isOn()?HUDEditorModule.showHUD.isOn():super.isOn();
}
};
gui=new HUDGUI(inter,theme.getDescriptionRenderer(),(IPopupPositioner)new MousePositioner(new Point(10,10)),guiToggle,hudToggle);
// Creating animation ...
Supplier<Animation> animation=()->new SettingsAnimation(()-> ClickGUIModule.animationSpeed.getValue(),()->inter.getTime());
// Populating HUD ...
gui.addHUDComponent(TabGUIModule.getComponent(client,new IContainer<IFixedComponent>() {
@Override
public boolean addComponent (IFixedComponent component) {
return gui.addHUDComponent(component,()->true);
}
@Override
public boolean addComponent (IFixedComponent component, IBoolean visible) {
return gui.addHUDComponent(component,visible);
}
@Override
public boolean removeComponent (IFixedComponent component) {
return gui.removeComponent(component);
}
},animation),TabGUIModule.getToggle(),animation.get(),theme,BORDER);
gui.addHUDComponent(WatermarkModule.getComponent(),WatermarkModule.getToggle(),animation.get(),theme,BORDER);
gui.addHUDComponent(LogoModule.getComponent(inter),LogoModule.getToggle(),animation.get(),theme,BORDER);
// Creating popup types ...
BiFunction<Context,Integer,Integer> scrollHeight=(context,componentHeight)->Math.min(componentHeight,Math.max(HEIGHT*4,ClickGUI.this.height-context.getPos().y-HEIGHT));
PopupTuple popupType=new PopupTuple(new PanelPositioner(new Point(0,0)),false,new IScrollSize() {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return scrollHeight.apply(context,componentHeight);
}
});
PopupTuple colorPopup=new PopupTuple(new CenteredPositioner(()->new Rectangle(new Point(0,0),inter.getWindowSize())),true,new IScrollSize() {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return scrollHeight.apply(context,componentHeight);
}
});
// Defining resize behavior ...
IntFunction<IResizable> resizable=width->new IResizable() {
Dimension size=new Dimension(width,320);
@Override
public Dimension getSize() {
return new Dimension(size);
}
@Override
public void setSize (Dimension size) {
this.size.width=size.width;
this.size.height=size.height;
if (size.width<75) this.size.width=75;
if (size.height<50) this.size.height=50;
}
};
// Defining scroll behavior ...
Function<IResizable,IScrollSize> resizableHeight=size->new IScrollSize() {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return size.getSize().height;
}
};
// Defining function keys ...
IntPredicate keybindKey=scancode->scancode==GLFW.GLFW_KEY_DELETE;
IntPredicate charFilter=character->{
return character>=' ';
};
ITextFieldKeys keys=new ITextFieldKeys() {
@Override
public boolean isBackspaceKey (int scancode) {
return scancode==GLFW.GLFW_KEY_BACKSPACE;
}
@Override
public boolean isDeleteKey (int scancode) {
return scancode==GLFW.GLFW_KEY_DELETE;
}
@Override
public boolean isInsertKey (int scancode) {
return scancode==GLFW.GLFW_KEY_INSERT;
}
@Override
public boolean isLeftKey (int scancode) {
return scancode==GLFW.GLFW_KEY_LEFT;
}
@Override
public boolean isRightKey (int scancode) {
return scancode==GLFW.GLFW_KEY_RIGHT;
}
@Override
public boolean isHomeKey (int scancode) {
return scancode==GLFW.GLFW_KEY_HOME;
}
@Override
public boolean isEndKey (int scancode) {
return scancode==GLFW.GLFW_KEY_END;
}
@Override
public boolean isCopyKey (int scancode) {
return scancode==GLFW.GLFW_KEY_C;
}
@Override
public boolean isPasteKey (int scancode) {
return scancode==GLFW.GLFW_KEY_V;
}
@Override
public boolean isCutKey (int scancode) {
return scancode==GLFW.GLFW_KEY_X;
}
@Override
public boolean isAllKey (int scancode) {
return scancode==GLFW.GLFW_KEY_A;
}
};
// Normal generator
IComponentGenerator generator=new ComponentGenerator(keybindKey,charFilter,keys);
// Use cycle switches instead of buttons
IComponentGenerator cycleGenerator=new ComponentGenerator(keybindKey,charFilter,keys) {
@Override
public IComponent getEnumComponent (IEnumSetting setting, Supplier<Animation> animation, IComponentAdder adder, ThemeTuple theme, int colorLevel, boolean isContainer) {
return new CycleSwitch(setting,theme.getCycleSwitchRenderer(isContainer));
}
};
// Use all the fancy widgets with text boxes
IComponentGenerator csgoGenerator=new ComponentGenerator(keybindKey,charFilter,keys) {
@Override
public IComponent getBooleanComponent (IBooleanSetting setting, Supplier<Animation> animation, IComponentAdder adder, ThemeTuple theme, int colorLevel, boolean isContainer) {
return new ToggleSwitch(setting,theme.getToggleSwitchRenderer(isContainer));
}
@Override
public IComponent getEnumComponent (IEnumSetting setting, Supplier<Animation> animation, IComponentAdder adder, ThemeTuple theme, int colorLevel, boolean isContainer) {
return new DropDownList(setting,theme,isContainer,false,keys,new IScrollSize(){},adder::addPopup) {
@Override
protected Animation getAnimation() {
return animation.get();
}
@Override
public boolean allowCharacter (char character) {
return charFilter.test(character);
}
@Override
protected boolean isUpKey (int key) {
return key==GLFW.GLFW_KEY_UP;
}
@Override
protected boolean isDownKey (int key) {
return key==GLFW.GLFW_KEY_DOWN;
}
@Override
protected boolean isEnterKey (int key) {
return key==GLFW.GLFW_KEY_ENTER;
}
};
}
@Override
public IComponent getNumberComponent (INumberSetting setting, Supplier<Animation> animation, IComponentAdder adder, ThemeTuple theme, int colorLevel, boolean isContainer) {
return new Spinner(setting,theme,isContainer,true,keys);
}
@Override
public IComponent getColorComponent (IColorSetting setting, Supplier<Animation> animation, IComponentAdder adder, ThemeTuple theme, int colorLevel, boolean isContainer) {
return new ColorPickerComponent(setting,new ThemeTuple(theme.theme,theme.logicalLevel,colorLevel));
}
};
// Classic Panel
IComponentAdder classicPanelAdder=new PanelAdder(gui,false,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.ClassicPanel,title->"classicPanel_"+title) {
@Override
protected IResizable getResizable (int width) {
return resizable.apply(width);
}
@Override
protected IScrollSize getScrollSize (IResizable size) {
return resizableHeight.apply(size);
}
};
ILayout classicPanelLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->ChildMode.DOWN,level->ChildMode.DOWN,popupType);
classicPanelLayout.populateGUI(classicPanelAdder,generator,client,theme);
// Pop-up Panel
IComponentAdder popupPanelAdder=new PanelAdder(gui,false,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.PopupPanel,title->"popupPanel_"+title) {
@Override
protected IResizable getResizable (int width) {
return resizable.apply(width);
}
@Override
protected IScrollSize getScrollSize (IResizable size) {
return resizableHeight.apply(size);
}
};
ILayout popupPanelLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->ChildMode.POPUP,level->ChildMode.DOWN,popupType);
popupPanelLayout.populateGUI(popupPanelAdder,generator,client,theme);
// Draggable Panel
IComponentAdder draggablePanelAdder=new PanelAdder(gui,false,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.DraggablePanel,title->"draggablePanel_"+title) {
@Override
protected IResizable getResizable (int width) {
return resizable.apply(width);
}
@Override
protected IScrollSize getScrollSize (IResizable size) {
return resizableHeight.apply(size);
}
};
ILayout draggablePanelLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->level==0?ChildMode.DRAG_POPUP:ChildMode.DOWN,level->ChildMode.DOWN,popupType);
draggablePanelLayout.populateGUI(draggablePanelAdder,generator,client,theme);
// Single Panel
IComponentAdder singlePanelAdder=new SinglePanelAdder(gui,new Labeled("Example Menu",null,()->true),theme,new Point(10,10),WIDTH*Category.values().length,animation,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.SinglePanel,"singlePanel") {
@Override
protected IResizable getResizable (int width) {
return resizable.apply(width);
}
@Override
protected IScrollSize getScrollSize (IResizable size) {
return resizableHeight.apply(size);
}
};
ILayout singlePanelLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->ChildMode.DOWN,level->ChildMode.DOWN,popupType);
singlePanelLayout.populateGUI(singlePanelAdder,generator,client,theme);
// Panel Menu
IComponentAdder panelMenuAdder=new StackedPanelAdder(gui,new Labeled("Example Menu",null,()->true),theme,new Point(10,10),WIDTH,animation,ChildMode.POPUP,new PanelPositioner(new Point(0,0)),()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.PanelMenu,"panelMenu");
ILayout panelMenuLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->ChildMode.POPUP,level->ChildMode.POPUP,popupType);
panelMenuLayout.populateGUI(panelMenuAdder,generator,client,theme);
// Color Panel
IComponentAdder colorPanelAdder=new PanelAdder(gui,false,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.ColorPanel,title->"colorPanel_"+title) {
@Override
protected IResizable getResizable (int width) {
return resizable.apply(width);
}
@Override
protected IScrollSize getScrollSize (IResizable size) {
return resizableHeight.apply(size);
}
};
ILayout colorPanelLayout=new PanelLayout(WIDTH,new Point(DISTANCE,DISTANCE),(WIDTH+DISTANCE)/2,HEIGHT+DISTANCE,animation,level->ChildMode.DOWN,level->ChildMode.POPUP,colorPopup);
colorPanelLayout.populateGUI(colorPanelAdder,cycleGenerator,client,theme);
// Horizontal CSGO
AtomicReference<IResizable> horizontalResizable=new AtomicReference<IResizable>(null);
IComponentAdder horizontalCSGOAdder=new PanelAdder(gui,true,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.CSGOHorizontal,title->"horizontalCSGO_"+title) {
@Override
protected IResizable getResizable (int width) {
horizontalResizable.set(resizable.apply(width));
return horizontalResizable.get();
}
};
ILayout horizontalCSGOLayout=new CSGOLayout(new Labeled("Example",null,()->true),new Point(100,100),480,WIDTH,animation,"Enabled",true,true,2,ChildMode.POPUP,colorPopup) {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return resizableHeight.apply(horizontalResizable.get()).getScrollHeight(null,height);
}
};
horizontalCSGOLayout.populateGUI(horizontalCSGOAdder,csgoGenerator,client,theme);
// Vertical CSGO
AtomicReference<IResizable> verticalResizable=new AtomicReference<IResizable>(null);
IComponentAdder verticalCSGOAdder=new PanelAdder(gui,true,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.CSGOVertical,title->"verticalCSGO_"+title) {
@Override
protected IResizable getResizable (int width) {
verticalResizable.set(resizable.apply(width));
return verticalResizable.get();
}
};
ILayout verticalCSGOLayout=new CSGOLayout(new Labeled("Example",null,()->true),new Point(100,100),480,WIDTH,animation,"Enabled",false,true,2,ChildMode.POPUP,colorPopup) {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return resizableHeight.apply(verticalResizable.get()).getScrollHeight(null,height);
}
};
verticalCSGOLayout.populateGUI(verticalCSGOAdder,csgoGenerator,client,theme);
// Category CSGO
AtomicReference<IResizable> categoryResizable=new AtomicReference<IResizable>(null);
IComponentAdder categoryCSGOAdder=new PanelAdder(gui,true,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.CSGOCategory,title->"categoryCSGO_"+title) {
@Override
protected IResizable getResizable (int width) {
categoryResizable.set(resizable.apply(width));
return categoryResizable.get();
}
};
ILayout categoryCSGOLayout=new CSGOLayout(new Labeled("Example",null,()->true),new Point(100,100),480,WIDTH,animation,"Enabled",false,false,2,ChildMode.POPUP,colorPopup) {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return resizableHeight.apply(categoryResizable.get()).getScrollHeight(null,height);
}
};
categoryCSGOLayout.populateGUI(categoryCSGOAdder,csgoGenerator,client,theme);
// Searchable CSGO
AtomicReference<IResizable> searchableResizable=new AtomicReference<IResizable>(null);
IComponentAdder searchableCSGOAdder=new PanelAdder(gui,true,()->ClickGUIModule.layout.getValue()==ClickGUIModule.Layout.SearchableCSGO,title->"searchableCSGO_"+title) {
@Override
protected IResizable getResizable (int width) {
searchableResizable.set(resizable.apply(width));
return searchableResizable.get();
}
};
ILayout searchableCSGOLayout=new SearchableLayout(new Labeled("Example",null,()->true),new Labeled("Search",null,()->true),new Point(100,100),480,WIDTH,animation,"Enabled",2,ChildMode.POPUP,colorPopup,(a,b)->a.getDisplayName().compareTo(b.getDisplayName()),charFilter,keys) {
@Override
public int getScrollHeight (Context context, int componentHeight) {
return resizableHeight.apply(searchableResizable.get()).getScrollHeight(null,height);
}
};
searchableCSGOLayout.populateGUI(searchableCSGOAdder,csgoGenerator,client,theme);
}
@Override
protected HUDGUI getGUI() {
return gui;
}
@Override
protected GUIInterface getInterface() {
return inter;
}
@Override
protected int getScrollSpeed() {
return ClickGUIModule.scrollSpeed.getValue();
}
private class ThemeSelector implements IThemeMultiplexer {
protected Map<ClickGUIModule.Theme,ITheme> themes=new EnumMap<ClickGUIModule.Theme,ITheme>(ClickGUIModule.Theme.class);
public ThemeSelector (IInterface inter) {
BooleanSetting clearGradient=new BooleanSetting("Gradient","gradient","Whether the title bars should have a gradient.",()->ClickGUIModule.theme.getValue()==Theme.Clear,true);
BooleanSetting ignoreDisabled=new BooleanSetting("Ignore Disabled","ignoreDisabled","Have the rainbow drawn for disabled containers.",()->ClickGUIModule.theme.getValue()==Theme.Rainbow,false);
BooleanSetting buttonRainbow=new BooleanSetting("Button Rainbow","buttonRainbow","Have a separate rainbow for each component.",()->ClickGUIModule.theme.getValue()==Theme.Rainbow,false);
IntegerSetting rainbowGradient=new IntegerSetting("Rainbow Gradient","rainbowGradient","How fast the rainbow should repeat.",()->ClickGUIModule.theme.getValue()==Theme.Rainbow,150,50,300);
ClickGUIModule.theme.subSettings.add(clearGradient);
ClickGUIModule.theme.subSettings.add(ignoreDisabled);
ClickGUIModule.theme.subSettings.add(buttonRainbow);
ClickGUIModule.theme.subSettings.add(rainbowGradient);
addTheme(Theme.Clear,new ClearTheme(new ThemeScheme(Theme.Clear),()->clearGradient.getValue(),9,3,1,": "+Formatting.GRAY));
addTheme(Theme.GameSense,new GameSenseTheme(new ThemeScheme(Theme.GameSense),9,4,5,": "+Formatting.GRAY));
addTheme(Theme.Rainbow,new RainbowTheme(new ThemeScheme(Theme.Rainbow),()->ignoreDisabled.getValue(),()->buttonRainbow.getValue(),()->rainbowGradient.getValue(),9,3,": "+Formatting.GRAY));
addTheme(Theme.Windows31,new Windows31Theme(new ThemeScheme(Theme.Windows31),9,2,9,": "+Formatting.DARK_GRAY));
addTheme(Theme.Impact,new ImpactTheme(new ThemeScheme(Theme.Impact),9,4));
}
@Override
public ITheme getTheme() {
return themes.getOrDefault(ClickGUIModule.theme.getValue(),themes.get(Theme.GameSense));
}
private void addTheme (Theme key, ITheme value) {
themes.put(key,new OptimizedTheme(value));
value.loadAssets(inter);
}
private class ThemeScheme implements IColorScheme {
private final Theme themeValue;
private final String themeName;
public ThemeScheme (Theme themeValue) {
this.themeValue=themeValue;
this.themeName=themeValue.toString().toLowerCase();
}
@Override
public void createSetting (ITheme theme, String name, String description, boolean hasAlpha, boolean allowsRainbow, Color color, boolean rainbow) {
ClickGUIModule.theme.subSettings.add(new ColorSetting(name,themeName+"-"+name,description,()->ClickGUIModule.theme.getValue()==themeValue,hasAlpha,allowsRainbow,color,rainbow));
}
@Override
public Color getColor (String name) {
return ((ColorSetting)ClickGUIModule.theme.subSettings.stream().filter(setting->setting.configName.equals(themeName+"-"+name)).findFirst().orElse(null)).getValue();
}
}
}
}

View File

@ -0,0 +1,40 @@
package dev.coredoes.coreclient.gui.module;
import org.lwjgl.glfw.GLFW;
import dev.coredoes.coreclient.gui.setting.EnumSetting;
import dev.coredoes.coreclient.gui.setting.IntegerSetting;
import dev.coredoes.coreclient.gui.setting.KeybindSetting;
public class ClickGUIModule extends Module {
public static final EnumSetting<ColorModel> colorModel=new EnumSetting<ColorModel>("Color Model","colorModel","Whether to use RGB or HSB.",()->true,ColorModel.RGB,ColorModel.class);
public static final IntegerSetting rainbowSpeed=new IntegerSetting("Rainbow Speed","rainbowSpeed","The speed of the color hue cycling.",()->true,1,100,32);
public static final IntegerSetting scrollSpeed=new IntegerSetting("Scroll Speed","scrollSpeed","The speed of scrolling.",()->true,0,20,10);
public static final IntegerSetting animationSpeed=new IntegerSetting("Animation Speed","animationSpeed","The speed of GUI animations.",()->true,0,1000,200);
public static final EnumSetting<Theme> theme=new EnumSetting<Theme>("Theme","theme","What theme to use.",()->true,Theme.GameSense,Theme.class);
public static final EnumSetting<Layout> layout=new EnumSetting<Layout>("Layout","layout","What layout to use.",()->true,Layout.ClassicPanel,Layout.class);
public static final KeybindSetting keybind=new KeybindSetting("Keybind","keybind","The key to toggle the module.",()->true,GLFW.GLFW_KEY_O);
public ClickGUIModule() {
super("ClickGUI","Module containing ClickGUI settings.",()->true,false);
settings.add(colorModel);
settings.add(rainbowSpeed);
settings.add(scrollSpeed);
settings.add(animationSpeed);
settings.add(theme);
settings.add(layout);
settings.add(keybind);
}
public enum ColorModel {
RGB,HSB;
}
public enum Theme {
Clear,GameSense,Rainbow,Windows31,Impact;
}
public enum Layout {
ClassicPanel,PopupPanel,DraggablePanel,SinglePanel,PanelMenu,ColorPanel,CSGOHorizontal,CSGOVertical,CSGOCategory,SearchableCSGO;
}
}

View File

@ -0,0 +1,17 @@
package dev.coredoes.coreclient.gui.module;
import org.lwjgl.glfw.GLFW;
import dev.coredoes.coreclient.gui.setting.BooleanSetting;
import dev.coredoes.coreclient.gui.setting.KeybindSetting;
public class HUDEditorModule extends Module {
public static final BooleanSetting showHUD=new BooleanSetting("Show HUD Panels","showHUD","Whether to show the HUD panels in the ClickGUI.",()->true,true);
public static final KeybindSetting keybind=new KeybindSetting("Keybind","keybind","The key to toggle the module.",()->true,GLFW.GLFW_KEY_P);
public HUDEditorModule() {
super("HUDEditor","Module containing HUDEditor settings.",()->true,false);
settings.add(showHUD);
settings.add(keybind);
}
}

View File

@ -0,0 +1,48 @@
package dev.coredoes.coreclient.gui.module;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import dev.coredoes.coreclient.gui.setting.BooleanSetting;
import dev.coredoes.coreclient.gui.setting.ColorSetting;
import dev.coredoes.coreclient.gui.setting.IntegerSetting;
import com.lukflug.panelstudio.base.Context;
import com.lukflug.panelstudio.base.IInterface;
import com.lukflug.panelstudio.base.IToggleable;
import com.lukflug.panelstudio.component.IFixedComponent;
import com.lukflug.panelstudio.hud.HUDComponent;
public class LogoModule extends Module {
private static LogoModule instance;
private static final IntegerSetting rotation=new IntegerSetting("Image Rotation","rotation","How to rotate the image.",()->true,0,3,0);
private static final BooleanSetting parity=new BooleanSetting("Flip Image","parity","Whether to flip the image or not.",()->true,false);
private static final ColorSetting color=new ColorSetting("Logo Color","color","The color to modulate the logo with.",()->true,true,true,new Color(255,255,255,128),true);
public LogoModule() {
super("Logo","Module that displays the PanelStudio icon on HUD.",()->true,true);
instance=this;
settings.add(rotation);
settings.add(parity);
settings.add(color);
}
public static IFixedComponent getComponent (IInterface inter) {
int image=inter.loadImage("panelstudio.png");
return new HUDComponent(()->"Logo",new Point(300,300),"logo") {
@Override
public void render (Context context) {
super.render(context);
context.getInterface().drawImage(context.getRect(),rotation.getValue(),parity.getValue(),image,color.getValue());
}
@Override
public Dimension getSize (IInterface inter) {
return new Dimension(141,61);
}
};
}
public static IToggleable getToggle() {
return instance.isEnabled();
}
}

View File

@ -0,0 +1,62 @@
package dev.coredoes.coreclient.gui.module;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import dev.coredoes.coreclient.gui.setting.Setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.base.IToggleable;
import com.lukflug.panelstudio.setting.IModule;
import com.lukflug.panelstudio.setting.ISetting;
public class Module implements IModule {
public final String displayName,description;
public final IBoolean visible;
public final List<Setting<?>> settings=new ArrayList<Setting<?>>();
public final boolean toggleable;
private boolean enabled=false;
public Module (String displayName, String description, IBoolean visible, boolean toggleable) {
this.displayName=displayName;
this.description=description;
this.visible=visible;
this.toggleable=toggleable;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public String getDescription() {
return description;
}
@Override
public IBoolean isVisible() {
return visible;
}
@Override
public IToggleable isEnabled() {
if (!toggleable) return null;
return new IToggleable() {
@Override
public boolean isOn() {
return enabled;
}
@Override
public void toggle() {
enabled=!enabled;
}
};
}
@Override
public Stream<ISetting<?>> getSettings() {
return settings.stream().filter(setting->setting instanceof ISetting).sorted((a,b)->a.displayName.compareTo(b.displayName)).map(setting->(ISetting<?>)setting);
}
}

View File

@ -0,0 +1,49 @@
package dev.coredoes.coreclient.gui.module;
import java.awt.Color;
import java.awt.Point;
import java.util.function.Supplier;
import org.lwjgl.glfw.GLFW;
import dev.coredoes.coreclient.gui.setting.ColorSetting;
import com.lukflug.panelstudio.base.Animation;
import com.lukflug.panelstudio.base.IToggleable;
import com.lukflug.panelstudio.component.IFixedComponent;
import com.lukflug.panelstudio.container.IContainer;
import com.lukflug.panelstudio.setting.IClient;
import com.lukflug.panelstudio.tabgui.ITabGUITheme;
import com.lukflug.panelstudio.tabgui.StandardTheme;
import com.lukflug.panelstudio.tabgui.TabGUI;
import com.lukflug.panelstudio.theme.IColorScheme;
import com.lukflug.panelstudio.theme.ITheme;
public class TabGUIModule extends Module {
private static TabGUIModule instance;
private static ITabGUITheme theme;
public TabGUIModule() {
super("TabGUI","HUD module that lets toggle modules.",()->true,true);
instance=this;
theme=new StandardTheme(new IColorScheme() {
@Override
public void createSetting(ITheme theme, String name, String description, boolean hasAlpha, boolean allowsRainbow, Color color, boolean rainbow) {
ColorSetting setting=new ColorSetting(name,name,description,()->true,allowsRainbow,hasAlpha,color,rainbow);
instance.settings.add(setting);
}
@Override
public Color getColor (String name) {
return (Color)instance.settings.stream().filter(setting->setting.configName.equals(name)).findFirst().orElse(null).getValue();
}
},75,9,2,5);
}
public static IFixedComponent getComponent (IClient client, IContainer<IFixedComponent> container, Supplier<Animation> animation) {
return new TabGUI(()->"TabGUI",client,theme,container,animation,key->key==GLFW.GLFW_KEY_UP,key->key==GLFW.GLFW_KEY_DOWN,key->key==GLFW.GLFW_KEY_ENTER||key==GLFW.GLFW_KEY_RIGHT,key->key==GLFW.GLFW_KEY_LEFT,new Point(10,10),"tabGUI").getWrappedComponent();
}
public static IToggleable getToggle() {
return instance.isEnabled();
}
}

View File

@ -0,0 +1,68 @@
package dev.coredoes.coreclient.gui.module;
import java.awt.Color;
import java.awt.Point;
import dev.coredoes.coreclient.gui.setting.BooleanSetting;
import dev.coredoes.coreclient.gui.setting.ColorSetting;
import dev.coredoes.coreclient.gui.setting.StringSetting;
import com.lukflug.panelstudio.base.IToggleable;
import com.lukflug.panelstudio.component.IFixedComponent;
import com.lukflug.panelstudio.hud.HUDList;
import com.lukflug.panelstudio.hud.ListComponent;
public class WatermarkModule extends Module {
private static WatermarkModule instance;
private static final ColorSetting color=new ColorSetting("Text Color","color","The color of the displayed text.",()->true,false,true,new Color(0,0,255),false);
private static final BooleanSetting sortUp=new BooleanSetting("Sort Up","sortUp","Whether to align the text from the bottom up.",()->true,false);
private static final BooleanSetting sortRight=new BooleanSetting("Sort Right","sortRight","Whether to align the text from right to left.",()->true,false);
private static final StringSetting line1=new StringSetting("First Line","line1","The first line of text.",()->true,"PanelStudio");
private static final StringSetting line2=new StringSetting("Second Line","line2","The second line of text.",()->true,"Example Mod");
private static final StringSetting line3=new StringSetting("Third Line","line3","The third line of text.",()->true,"made by lukflug");
public WatermarkModule() {
super("Watermark","Module that displays text on HUD.",()->true,true);
instance=this;
settings.add(color);
settings.add(sortUp);
settings.add(sortRight);
settings.add(line1);
settings.add(line2);
settings.add(line3);
}
public static IFixedComponent getComponent() {
return new ListComponent(()->"Watermark",new Point(300,10),"watermark",new HUDList() {
@Override
public int getSize() {
return 3;
}
@Override
public String getItem(int index) {
if (index==0) return line1.getValue();
else if (index==1) return line2.getValue();
else return line3.getValue();
}
@Override
public Color getItemColor(int index) {
return color.getValue();
}
@Override
public boolean sortUp() {
return sortUp.getValue();
}
@Override
public boolean sortRight() {
return sortRight.getValue();
}
},9,2);
}
public static IToggleable getToggle() {
return instance.isEnabled();
}
}

View File

@ -0,0 +1,20 @@
package dev.coredoes.coreclient.gui.setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.IBooleanSetting;
public class BooleanSetting extends Setting<Boolean> implements IBooleanSetting {
public BooleanSetting (String displayName, String configName, String description, IBoolean visible, Boolean value) {
super(displayName,configName,description,visible,value);
}
@Override
public void toggle() {
setValue(!getValue());
}
@Override
public boolean isOn() {
return getValue();
}
}

View File

@ -0,0 +1,59 @@
package dev.coredoes.coreclient.gui.setting;
import java.awt.Color;
import dev.coredoes.coreclient.gui.module.ClickGUIModule;
import dev.coredoes.coreclient.gui.module.ClickGUIModule.ColorModel;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.IColorSetting;
import com.lukflug.panelstudio.theme.ITheme;
public class ColorSetting extends Setting<Color> implements IColorSetting {
public final boolean hasAlpha,allowsRainbow;
private boolean rainbow;
public ColorSetting (String displayName, String configName, String description, IBoolean visible, boolean hasAlpha, boolean allowsRainbow, Color value, boolean rainbow) {
super(displayName,configName,description,visible,value);
this.hasAlpha=hasAlpha;
this.allowsRainbow=allowsRainbow;
this.rainbow=rainbow;
}
@Override
public Color getValue() {
if (rainbow) {
int speed=ClickGUIModule.rainbowSpeed.getValue();
return ITheme.combineColors(Color.getHSBColor((System.currentTimeMillis()%(360*speed))/(float)(360*speed),1,1),super.getValue());
}
else return super.getValue();
}
@Override
public Color getColor() {
return super.getValue();
}
@Override
public boolean getRainbow() {
return rainbow;
}
@Override
public void setRainbow (boolean rainbow) {
this.rainbow=rainbow;
}
@Override
public boolean hasAlpha() {
return hasAlpha;
}
@Override
public boolean allowsRainbow() {
return allowsRainbow;
}
@Override
public boolean hasHSBModel() {
return ClickGUIModule.colorModel.getValue()==ColorModel.HSB;
}
}

View File

@ -0,0 +1,39 @@
package dev.coredoes.coreclient.gui.setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.INumberSetting;
public class DoubleSetting extends Setting<Double> implements INumberSetting {
public final double min,max;
public DoubleSetting (String displayName, String configName, String description, IBoolean visible, double min, double max, double value) {
super(displayName,configName,description,visible,value);
this.min=min;
this.max=max;
}
@Override
public double getNumber() {
return getValue();
}
@Override
public void setNumber (double value) {
setValue(value);
}
@Override
public double getMaximumValue() {
return max;
}
@Override
public double getMinimumValue() {
return min;
}
@Override
public int getPrecision() {
return 2;
}
}

View File

@ -0,0 +1,60 @@
package dev.coredoes.coreclient.gui.setting;
import java.util.Arrays;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.IEnumSetting;
import com.lukflug.panelstudio.setting.ILabeled;
public class EnumSetting<E extends Enum<E>> extends Setting<E> implements IEnumSetting {
private final Class<E> settingClass;
private final ILabeled[] array;
public EnumSetting (String displayName, String configName, String description, IBoolean visible, E value, Class<E> settingClass) {
super(displayName,configName,description,visible,value);
this.settingClass=settingClass;
array=Arrays.stream(settingClass.getEnumConstants()).map(v->{
return new ILabeled() {
@Override
public String getDisplayName() {
return v.toString();
}
};
}).toArray(ILabeled[]::new);
}
@Override
public void increment() {
E[] array=settingClass.getEnumConstants();
int index=getValue().ordinal()+1;
if (index>=array.length) index=0;
setValue(array[index]);
}
@Override
public void decrement() {
E[] array=settingClass.getEnumConstants();
int index=getValue().ordinal()-1;
if (index<0) index=array.length-1;
setValue(array[index]);
}
@Override
public String getValueName() {
return getValue().toString();
}
@Override
public int getValueIndex() {
return getValue().ordinal();
}
@Override
public void setValueIndex(int index) {
setValue(settingClass.getEnumConstants()[index]);
}
@Override
public ILabeled[] getAllowedValues() {
return array;
}
}

View File

@ -0,0 +1,38 @@
package dev.coredoes.coreclient.gui.setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.INumberSetting;
public class IntegerSetting extends Setting<Integer> implements INumberSetting {
public final int min,max;
public IntegerSetting (String displayName, String configName, String description, IBoolean visible, int min, int max, int value) {
super(displayName,configName,description,visible,value);
this.min=min;
this.max=max;
}
@Override
public double getNumber() {
return getValue();
}
@Override
public void setNumber (double value) {
setValue((int)Math.round(value));
}
@Override
public double getMaximumValue() {
return max;
}
@Override
public double getMinimumValue() {
return min;
}
@Override
public int getPrecision() {
return 0;
}
}

View File

@ -0,0 +1,30 @@
package dev.coredoes.coreclient.gui.setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.IKeybindSetting;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.TranslatableTextContent;
public class KeybindSetting extends Setting<Integer> implements IKeybindSetting {
public KeybindSetting (String displayName, String configName, String description, IBoolean visible, Integer value) {
super(displayName,configName,description,visible,value);
}
@Override
public int getKey() {
return getValue();
}
@Override
public void setKey (int key) {
setValue(key);
}
@Override
public String getKeyName() {
String translationKey=InputUtil.Type.KEYSYM.createFromCode(getKey()).getTranslationKey();
String translation=new TranslatableTextContent(translationKey,null,TranslatableTextContent.EMPTY_ARGUMENTS).toString();
if (!translation.equals(translationKey)) return translation;
return InputUtil.Type.KEYSYM.createFromCode(getKey()).getLocalizedText().getString();
}
}

View File

@ -0,0 +1,52 @@
package dev.coredoes.coreclient.gui.setting;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.ILabeled;
import com.lukflug.panelstudio.setting.ISetting;
public abstract class Setting<T> implements ILabeled {
public final String displayName,configName,description;
public final IBoolean visible;
public final List<Setting<?>> subSettings=new ArrayList<Setting<?>>();
private T value;
public Setting (String displayName, String configName, String description, IBoolean visible, T value) {
this.displayName=displayName;
this.configName=configName;
this.description=description;
this.visible=visible;
this.value=value;
}
public T getValue() {
return value;
}
public void setValue (T value) {
this.value=value;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public String getDescription() {
return description;
}
@Override
public IBoolean isVisible() {
return visible;
}
public Stream<ISetting<?>> getSubSettings() {
if (subSettings.size()==0) return null;
return subSettings.stream().filter(setting->setting instanceof ISetting).sorted((a,b)->a.displayName.compareTo(b.displayName)).map(setting->(ISetting<?>)setting);
}
}

View File

@ -0,0 +1,10 @@
package dev.coredoes.coreclient.gui.setting;
import com.lukflug.panelstudio.base.IBoolean;
import com.lukflug.panelstudio.setting.IStringSetting;
public class StringSetting extends Setting<String> implements IStringSetting {
public StringSetting (String displayName, String configName, String description, IBoolean visible, String value) {
super(displayName,configName,description,visible,value);
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.coredoes.coreclient.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -0,0 +1,30 @@
{
"schemaVersion": 1,
"id": "coreclient",
"version": "${version}",
"name": "coreclient",
"description": "An epic client mod",
"authors": [
"c0repwn3r"
],
"contact": {
"website": "https://coredoes.dev/coreclient",
"repo": "https://git.e3t.cc/~core/coreclient"
},
"license": "All-Rights-Reserved",
"icon": "assets/coreclient/icon.png",
"environment": "client",
"entrypoints": {
"client": [
"dev.coredoes.coreclient.CoreClient"
]
},
"mixins": [
"coreclient.mixins.json"
],
"depends": {
"fabricloader": ">=${loader_version}",
"fabric": "*",
"minecraft": "${minecraft_version}"
}
}