diff --git a/.gitignore b/.gitignore index 7e7d56a71..3b7e0fd70 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,7 @@ hs_err_pid* # Icon must end with two \r Icon !common/src/main/resources/assets/devices/textures/app/icon - +!addon/gitweb-builder/common/src/resources/assets/gitwebbuilder/textures/app/icon !updater/updater.jar # Thumbnails diff --git a/addon/addon-common.build.gradle b/addon/addon-common.build.gradle new file mode 100644 index 000000000..0f0168ec9 --- /dev/null +++ b/addon/addon-common.build.gradle @@ -0,0 +1,14 @@ +architectury { + common(rootProject.platforms.split(",")) +} + +loom { + +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations + // Do NOT use other classes from fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + implementation project(path: ":common", configuration: "namedElements") +} \ No newline at end of file diff --git a/addon/addon-fabric.build.gradle b/addon/addon-fabric.build.gradle new file mode 100644 index 000000000..4a3f1711e --- /dev/null +++ b/addon/addon-fabric.build.gradle @@ -0,0 +1,51 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +loom { + mixin { useLegacyMixinAp = true } + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +architectury { + platformSetupLoomIde() + fabric() +} + +configurations { + common + shadowCommon + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + +String strippedName = project.getName().substring(0, project.getName().length() - "-fabric".length()) + +archivesBaseName = strippedName +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + + implementation project(path: ":fabric", configuration: "namedElements") + common(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + + common(project(path: ":$strippedName-common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":$strippedName-common", configuration: "transformProductionFabric")) { transitive false } +} + +shadowJar { + configurations = [project.configurations.shadowCommon] + archiveClassifier = "dev-shadow" +} + +remapJar { + injectAccessWidener = true + //noinspection GrDeprecatedAPIUsage + input.set shadowJar.archiveFile + dependsOn shadowJar + archiveClassifier = null +} + +jar { + archiveClassifier = "dev" +} \ No newline at end of file diff --git a/addon/addon-forge.build.gradle b/addon/addon-forge.build.gradle new file mode 100644 index 000000000..e69de29bb diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/GitwebBuilder.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/GitwebBuilder.java new file mode 100644 index 000000000..d258031c4 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/GitwebBuilder.java @@ -0,0 +1,28 @@ +package mastef_chief.gitwebbuilder; + +import com.ultreon.devices.api.ApplicationManager; +import com.ultreon.devices.api.task.TaskManager; +import dev.architectury.core.item.ArchitecturyRecordItem; +import dev.architectury.registry.client.level.entity.EntityModelLayerRegistry; +import mastef_chief.gitwebbuilder.app.GWBApp; +import mastef_chief.gitwebbuilder.app.models.GWBLogoModel; +import mastef_chief.gitwebbuilder.app.tasks.TaskNotificationCopiedCode; +import mastef_chief.gitwebbuilder.app.tasks.TaskNotificationCopiedLink; +import net.minecraft.resources.ResourceLocation; + +public class GitwebBuilder { + + public static GitwebBuilder INSTANCE; + + public GitwebBuilder() { + INSTANCE = this; + TaskManager.registerTask(TaskNotificationCopiedCode::new); + TaskManager.registerTask(TaskNotificationCopiedLink::new); + + EntityModelLayerRegistry.register(GWBLogoModel.LAYER_LOCATION, GWBLogoModel::createTexturedModelData); + } + + public static void registerApplications() { + ApplicationManager.registerApplication(new ResourceLocation(Reference.MOD_ID, "gitwebbuilder_app"), () -> GWBApp::new, false); + } +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/Reference.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/Reference.java new file mode 100644 index 000000000..7f84353eb --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/Reference.java @@ -0,0 +1,14 @@ +package mastef_chief.gitwebbuilder; + +public class Reference { + + public static final String MOD_ID = "gitwebbuilder"; + public static final String NAME = "GitWeb Builder"; + public static final String VERSION = "1.0"; + public static final String ACCEPTED_VERSIONS = "[1.12.2]"; + public static final String DEPENDS = "required-after:cdm@[0.3.0,)"; + + public static final String CLIENT_PROXY_CLASS = "mastef_chief.gitwebbuilder.proxy.ClientProxy"; + public static final String SERVER_PROXY_CLASS = "mastef_chief.gitwebbuilder.proxy.ServerProxy"; + +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/GWBApp.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/GWBApp.java new file mode 100644 index 000000000..9420cd677 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/GWBApp.java @@ -0,0 +1,1012 @@ +package mastef_chief.gitwebbuilder.app; + +import com.mojang.blaze3d.platform.ClipboardManager; +import com.mojang.blaze3d.platform.Lighting; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.ultreon.devices.api.app.Application; +import com.ultreon.devices.api.app.Dialog; +import com.ultreon.devices.api.app.Icons; +import com.ultreon.devices.api.app.ScrollableLayout; +import com.ultreon.devices.api.app.component.Button; +import com.ultreon.devices.api.app.component.*; +import com.ultreon.devices.api.app.component.Image; +import com.ultreon.devices.api.app.component.Label; +import com.ultreon.devices.api.app.component.TextArea; +import com.ultreon.devices.api.app.interfaces.IHighlight; +import com.ultreon.devices.api.io.File; +import com.ultreon.devices.api.task.TaskManager; +import com.ultreon.devices.api.utils.OnlineRequest; +import com.ultreon.devices.api.utils.RenderUtil; +import com.ultreon.devices.core.Laptop; +import com.ultreon.devices.core.io.FileSystem; +import com.ultreon.devices.programs.gitweb.component.GitWebFrame; +import com.ultreon.devices.programs.system.layout.StandardLayout; +import mastef_chief.gitwebbuilder.app.components.MenuButton; +import mastef_chief.gitwebbuilder.app.components.ModuleCreatorDialog; +import mastef_chief.gitwebbuilder.app.components.PasteBinCompleteDialog; +//import mastef_chief.gitwebbuilder.app.models.GWBLogoModel; +import mastef_chief.gitwebbuilder.app.models.GWBLogoModel; +import mastef_chief.gitwebbuilder.app.tasks.TaskNotificationCopiedCode; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.font.TextFieldHelper; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import org.joml.Quaternionf; + +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.function.Predicate; + +public class GWBApp extends Application { + + //Todo module dialog, scrollable layout for design view, custom layouts which take in module instance, which type of module + + private static final Predicate PREDICATE_FILE_SITE = file -> !file.isFolder() + && file.getData().contains("content", Tag.TAG_STRING); + + public static final IHighlight CODE_HIGHLIGHT = text -> + { + if (text.startsWith("#")) + return asArray(ChatFormatting.GREEN); + + if (text.startsWith("\"") && text.endsWith("\"")) + return asArray(ChatFormatting.AQUA); + + switch (text) { + case "text": + case "image": + return asArray(ChatFormatting.BLUE); + default: + return asArray(ChatFormatting.WHITE); + } + }; + + + Minecraft mc = Minecraft.getInstance(); + + Toolkit toolkit = Toolkit.getDefaultToolkit(); + + private GitWebFrame liveGitWebFrame; + + private float rotationCounter = 0; + private int tickCounter = 0; + + //Todo work on save method to enable and disable save button + private String savedData; + + private boolean isSaved; + private boolean autoSave = true; + + private File currentFile; + + private StandardLayout layoutMain; + private StandardLayout layoutSettings; + private StandardLayout layoutCodeView; + private StandardLayout layoutDesignView; + private StandardLayout layoutLiveView; + + private ScrollableLayout moduleSelctionLayout; + + private MenuButton newSiteButton; + private MenuButton loadSiteButton; + private MenuButton settingsButton; + private MenuButton loadSiteFromListButton; + private Button backToMenuButton1; + private Button saveAsSiteButton; + private Button saveSiteButton; + private Button exportToPastebinButton; + private Button importButton; + private Button copyToClipboardButton; + + //Module Buttons + private Button paragraphModuleButton; + private Button navigationModuleButton; + private Button brewingModuleButton; + private Button downloadModuleButton; + private Button furnaceModuleButton; + private Button footerModuleButton; + private Button dividerModuleButton; + private Button craftingModuleButton; + private Button anvilModuleButton; + private Button headerModuleButton; + private Button bannerModuleButton; + + //16 Color Buttons + private Button[] formattingButtons = new Button[ChatFormatting.values().length - 1]; + + //Formatting Buttons + private Button resetButton; + + private ComboBox.List textFormattingSelectionList; + + private ItemList sitesList; + + private Label recentSitesLabel; + private Label autoSaveLabel; + + + private CheckBox autoSaveOnCheckBox; + private CheckBox autoSaveOffCheckBox; + private CheckBox codeViewCheckBox; + private CheckBox designViewCheckBox; + private CheckBox liveViewCheckBox; + + private TextArea siteBuilderTextArea; + + private GWBLogoModel gwbLogoModel = null; + + private static final ResourceLocation logo = new ResourceLocation("gitwebbuilder:textures/app/gui/logo.png"); + private static final ResourceLocation ud = new ResourceLocation("gitwebbuilder:textures/app/gui/ud.png"); + + /** + * The default initialization method. Clears any components in the default + * layout and sets it as the current layout. If you override this method and + * are using the default layout, make sure you call it using + * super.init(x, y) + *

+ * The parameters passed are the x and y location of the top left corner or + * your application window. + */ + @Override + public void init(CompoundTag nbtTagCompound) { + + /*--------------------------------------------------------------------------*/ + layoutMain = new StandardLayout("Menu", 363, 165, this, null); + layoutMain.setIcon(Icons.HOME); + layoutMain.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y + 21, x + width, y + 164, Color.GRAY.getRGB()); + }); + + layoutMain.setInitListener(() -> + { + sitesList.getItems().clear(); + FileSystem.getApplicationFolder(this, (folder, success) -> + { + if (success) { + folder.search(file -> file.isForApplication(this)).forEach(file -> + { + sitesList.addItem(Sites.fromFile(file)); + }); + } else { + this.openDialog(new Dialog.Message("Error creating app directory")); + } + }); + }); + + newSiteButton = new MenuButton(160, 45, 75, 16, "New Site", Icons.NEW_FILE); + newSiteButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + this.setCurrentLayout(layoutCodeView); + siteBuilderTextArea.setFocused(true); + } + }); + + layoutMain.addComponent(newSiteButton); + loadSiteButton = new MenuButton(185, 85, 75, 16, "Load Site", Icons.LOAD); + loadSiteButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + Dialog.OpenFile openDialog = new Dialog.OpenFile(this); + openDialog.setResponseHandler((success, file) -> + { + if (file.isForApplication(this)) { + CompoundTag data = file.getData(); + siteBuilderTextArea.setText(data.getString("content").replace("\n\n", "\n")); + currentFile = file; + //Todo Testing Code + /*saveSiteButton.setEnabled(false); + savedData = siteBuilderTextArea.getText();*/ + this.setCurrentLayout(layoutCodeView); + return true; + } else { + Dialog.Message errorDialog = new Dialog.Message("Invalid file for GitWeb Builder"); + openDialog(errorDialog); + } + return false; + }); + this.openDialog(openDialog); + } + }); + + layoutMain.addComponent(loadSiteButton); + + settingsButton = new MenuButton(210, 125, 75, 16, "Settings", Icons.WRENCH); + settingsButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + //this.setCurrentLayout(layoutSettings); + } + }); + layoutMain.addComponent(settingsButton); + + recentSitesLabel = new Label("\u00A7n\u00A7lRecent Sites", 273, 29); + layoutMain.addComponent(recentSitesLabel); + + sitesList = new ItemList(265, 40, 90, 5); + sitesList.setItemClickListener((e, index, mouseButton) -> { + if (mouseButton == 0) { + loadSiteFromListButton.setEnabled(true); + } + }); + layoutMain.addComponent(sitesList); + + loadSiteFromListButton = new MenuButton(265, 110, 90, 16, "Load", Icons.LOAD); + loadSiteFromListButton.setEnabled(false); + loadSiteFromListButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + if (sitesList.getSelectedIndex() != -1) { + Sites sites = sitesList.getSelectedItem(); + siteBuilderTextArea.setText(sites.getContent().replace("\n\n", "\n")); + currentFile = sites.getSource(); + setCurrentLayout(layoutCodeView); + } + } + }); + layoutMain.addComponent(loadSiteFromListButton); + + this.setCurrentLayout(layoutMain); + /*----------------------------------------------------------------------------------------------------------------------------------------*/ + + layoutSettings = new StandardLayout("Settings", 363, 165, this, layoutMain) { + @Override + protected void handleUnload() { + super.handleUnload(); + } + }; + layoutSettings.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y + 21, x + width, y + 164, Color.GRAY.getRGB()); + }); + + int autoSaveX = 10; + int autoSaveY = 30; + autoSaveLabel = new Label("\u00A7n\u00A7lAuto Save", autoSaveX, autoSaveY); + layoutSettings.addComponent(autoSaveLabel); + RadioGroup autoSaveToggle = new RadioGroup(); + + autoSaveOnCheckBox = new CheckBox("On", autoSaveX, autoSaveY + 15); + autoSaveOnCheckBox.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + autoSave = true; + markDirty(); + } + }); + autoSaveOnCheckBox.setRadioGroup(autoSaveToggle); + layoutSettings.addComponent(autoSaveOnCheckBox); + + autoSaveOffCheckBox = new CheckBox("Off", autoSaveX + 30, autoSaveY + 15); + autoSaveOffCheckBox.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + autoSave = false; + markDirty(); + } + }); + autoSaveOffCheckBox.setRadioGroup(autoSaveToggle); + layoutSettings.addComponent(autoSaveOffCheckBox); + + + /*----------------------------------------------------------------------------------------------------------------------------------------*/ + + layoutCodeView = new StandardLayout("Code View", 363, 165, this, null); + layoutCodeView.setIcon(Icons.EARTH); + + backToMenuButton1 = new Button(100, 2, Icons.ARROW_LEFT); + backToMenuButton1.setToolTip("Back To Menu", "Will take you back to the main menu"); + backToMenuButton1.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + if (currentFile == null) { + if (siteBuilderTextArea.getText().isEmpty()) { + this.setCurrentLayout(layoutMain); + } else { + Dialog.Confirmation saveCheckDialog = new Dialog.Confirmation("You have not saved your site, would you like to save?"); + saveCheckDialog.setPositiveText("Yes"); + saveCheckDialog.setNegativeText("No"); + this.openDialog(saveCheckDialog); + saveCheckDialog.setPositiveListener((mouseX1, mouseY1, mouseButton1) -> { + if (mouseButton1 == 0) { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + Dialog.SaveFile saveDialog = new Dialog.SaveFile(this, data); + this.openDialog(saveDialog); + saveDialog.setResponseHandler((success, file) -> { + siteBuilderTextArea.clear(); + this.setCurrentLayout(layoutMain); + return true; + }); + } + }); + saveCheckDialog.setNegativeListener((mouseX1, mouseY1, mouseButton1) -> { + if (mouseButton1 == 0) { + siteBuilderTextArea.clear(); + this.setCurrentLayout(layoutMain); + } + }); + } + } else { + if (currentFile.getData().getString("content").equals(siteBuilderTextArea.getText())) { + siteBuilderTextArea.clear(); + this.setCurrentLayout(layoutMain); + currentFile = null; + } else { + Dialog.Confirmation saveCheckDialog = new Dialog.Confirmation("You have unsaved changes, would you like to save?"); + this.openDialog(saveCheckDialog); + saveCheckDialog.setPositiveListener((mouseX1, mouseY1, mouseButton1) -> { + if (mouseButton1 == 0) { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + currentFile.setData(data, (v, success) -> { + }); + siteBuilderTextArea.clear(); + this.setCurrentLayout(layoutMain); + currentFile = null; + } + }); + saveCheckDialog.setNegativeListener((mouseX2, mouseY2, mouseButton2) -> { + if (mouseButton2 == 0) { + saveCheckDialog.close(); + siteBuilderTextArea.clear(); + this.setCurrentLayout(layoutMain); + currentFile = null; + } + }); + } + } + } + }); + layoutCodeView.addComponent(backToMenuButton1); + + saveAsSiteButton = new Button(118, 2, Icons.SAVE); + saveAsSiteButton.setToolTip("Save As", "Saves your site to a new file"); + saveAsSiteButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + + Dialog.SaveFile saveDialog = new Dialog.SaveFile(this, data); + saveDialog.setFolder(getApplicationFolderPath()); + saveDialog.setResponseHandler((success, file) -> { + currentFile = file; + return true; + }); + this.openDialog(saveDialog); + } + }); + layoutCodeView.addComponent(saveAsSiteButton); + + saveSiteButton = new Button(136, 2, Icons.SAVE); + saveSiteButton.setToolTip("Save", "Saves your site to the current file"); + saveSiteButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + if (currentFile != null) { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + currentFile.setData(data, (v, success) -> { + if (success) { + + } + }); + } else { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + + Dialog.SaveFile saveDialog = new Dialog.SaveFile(this, data); + saveDialog.setFolder(getApplicationFolderPath()); + saveDialog.setResponseHandler((success, file) -> { + currentFile = file; + return true; + }); + this.openDialog(saveDialog); + } + + } + }); + layoutCodeView.addComponent(saveSiteButton); + exportToPastebinButton = new Button(154, 2, Icons.EXPORT); + exportToPastebinButton.setToolTip("Export To PasteBin", "Exports code to GitWeb Buidler's Pastebin"); + exportToPastebinButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + Dialog.Input exportDialog = new Dialog.Input("Site Title:"); + exportDialog.setTitle("Export Site"); + exportDialog.setPositiveText("Export"); + this.openDialog(exportDialog); + exportDialog.setResponseHandler((success, v) -> + { + if (success) { + createPastebin(exportDialog.getTextFieldInput().getText(), siteBuilderTextArea.getText().replace("\n\n", "\n").replace("&", "%26")); + } + return true; + }); + } + }); + layoutCodeView.addComponent(exportToPastebinButton); + + importButton = new Button(172, 2, Icons.IMPORT); + importButton.setToolTip("Import", "Import an existing site into GitWeb Builder"); + importButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + + Dialog.Input importDialog = new Dialog.Input("Insert URL to the raw text of the site"); + importDialog.setTitle("Import Site"); + importDialog.setPositiveText("Import"); + this.openDialog(importDialog); + importDialog.setResponseHandler((success, s) -> { + if (success) { + + OnlineRequest.getInstance().make(importDialog.getTextFieldInput().getText().toString(), (success1, response) -> { + if (success1) { + siteBuilderTextArea.setText(response.replace("ยง", "&")); + } + }); + importDialog.close(); + } + return false; + }); + + + } + }); + layoutCodeView.addComponent(importButton); + + copyToClipboardButton = new Button(190, 2, Icons.COPY); + copyToClipboardButton.setToolTip("Copy to Clipboard", "Copy's code to clipboard with correct formatting for GitWeb"); + copyToClipboardButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + TextFieldHelper.setClipboardContents(this.mc, siteBuilderTextArea.getText().replace("\n\n", "\n")); + TaskManager.sendTask(new TaskNotificationCopiedCode()); + } + }); + layoutCodeView.addComponent(copyToClipboardButton); + + RadioGroup viewGroup = new RadioGroup(); + + codeViewCheckBox = new CheckBox("Code", 240, 5); + codeViewCheckBox.setSelected(true); + codeViewCheckBox.setRadioGroup(viewGroup); + codeViewCheckBox.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + + this.setCurrentLayout(layoutCodeView); + + } + }); + layoutCodeView.addComponent(codeViewCheckBox); + + designViewCheckBox = new CheckBox("Design", 280, 5); + designViewCheckBox.setRadioGroup(viewGroup); + designViewCheckBox.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + + this.setCurrentLayout(layoutDesignView); + + } + }); + layoutCodeView.addComponent(designViewCheckBox); + + liveViewCheckBox = new CheckBox("Live", 327, 5); + liveViewCheckBox.setRadioGroup(viewGroup); + liveViewCheckBox.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + try { + liveGitWebFrame.loadRaw(renderFormatting(siteBuilderTextArea.getText())); + + } catch (NumberFormatException e) { + this.openDialog(new Dialog.Message(ChatFormatting.RED + "Error \n" + ChatFormatting.RESET + e.getLocalizedMessage() + "\nCheck logs for more info." )); + e.printStackTrace(); + + } + + this.setCurrentLayout(layoutLiveView); + + + } + }); + layoutCodeView.addComponent(liveViewCheckBox); + + siteBuilderTextArea = new TextArea(0, 21, layoutCodeView.width - 75, layoutCodeView.height - 22); + //siteBuilderTextArea.setHighlight(CODE_HIGHLIGHT); + layoutCodeView.addComponent(siteBuilderTextArea); + + for (int i = 0; i < formattingButtons.length; i++) { + int x = 290 + (i % 4) * 18; + int y = 39 + (i / 4) * 18; + final int index = i; + Button button = new Button(x, y, 16, 16, ChatFormatting.values()[i] + "A"); + button.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + siteBuilderTextArea.writeText("&" + ChatFormatting.values()[index].toString().substring(1)); + siteBuilderTextArea.setFocused(true); + } + }); + layoutCodeView.addComponent(button); + formattingButtons[i] = button; + } + + String[] formattingType = new String[]{"Formatting", "Modules"}; + textFormattingSelectionList = new ComboBox.List<>(290, 23, 70, formattingType); + textFormattingSelectionList.setChangeListener((oldValue, newValue) -> { + if (!newValue.equals(oldValue)) { + if (newValue.equals("Formatting")) { + for (Button formattingButton : formattingButtons) { + formattingButton.setVisible(true); + } + resetButton.setVisible(true); + moduleSelctionLayout.setVisible(false); + } else if (newValue.equals("Modules")) { + for (Button formattingButton : formattingButtons) { + formattingButton.setVisible(false); + } + resetButton.setVisible(false); + moduleSelctionLayout.setVisible(true); + moduleSelctionLayout.resetScroll(); + } + } + }); + layoutCodeView.addComponent(textFormattingSelectionList); + + resetButton = new Button(308, 129, 52, 16, "Reset"); + resetButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + siteBuilderTextArea.writeText("&r"); + siteBuilderTextArea.setFocused(true); + } + }); + layoutCodeView.addComponent(resetButton); + + moduleSelctionLayout = new ScrollableLayout(290, 39, 70, 200, 123); + moduleSelctionLayout.setVisible(false); + moduleSelctionLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + 100, y + 300, Color.gray.getRGB()); + }); + layoutCodeView.addComponent(moduleSelctionLayout); + + paragraphModuleButton = new Button(1, 1, 62, 16, "Paragraph"); + paragraphModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Paragraph", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(paragraphModuleButton); + + navigationModuleButton = new Button(1, 19, 62, 16, "Navigation"); + navigationModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Navigation", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(navigationModuleButton); + + brewingModuleButton = new Button(1, 37, 62, 16, "Brewing"); + brewingModuleButton.setToolTip("Unavailable", "This module is currently being worked on."); + brewingModuleButton.setEnabled(false); + brewingModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Brewing", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(brewingModuleButton); + + downloadModuleButton = new Button(1, 55, 62, 16, "Download"); + downloadModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Download", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(downloadModuleButton); + + furnaceModuleButton = new Button(1, 73, 62, 16, "Furnace"); + furnaceModuleButton.setToolTip("Unavailable", "This module is currently being worked on."); + furnaceModuleButton.setEnabled(false); + moduleSelctionLayout.addComponent(furnaceModuleButton); + + footerModuleButton = new Button(1, 91, 62, 16, "Footer"); + footerModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Footer", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(footerModuleButton); + + dividerModuleButton = new Button(1, 109, 62, 16, "Divider"); + dividerModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Divider", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(dividerModuleButton); + + craftingModuleButton = new Button(1, 127, 62, 16, "Crafting"); + craftingModuleButton.setToolTip("Unavailable", "This module is currently being worked on."); + craftingModuleButton.setEnabled(false); + moduleSelctionLayout.addComponent(craftingModuleButton); + + anvilModuleButton = new Button(1, 145, 62, 16, "Anvil"); + anvilModuleButton.setToolTip("Unavailable", "This module is currently being worked on."); + anvilModuleButton.setEnabled(false); + moduleSelctionLayout.addComponent(anvilModuleButton); + + headerModuleButton = new Button(1, 163, 62, 16, "Header"); + headerModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Header", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(headerModuleButton); + + bannerModuleButton = new Button(1, 181, 62, 16, "Banner"); + bannerModuleButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if (mouseButton == 0) { + ModuleCreatorDialog moduleCreatorDialog = new ModuleCreatorDialog("Banner", siteBuilderTextArea); + this.openDialog(moduleCreatorDialog); + } + }); + moduleSelctionLayout.addComponent(bannerModuleButton); + + + + //Todo Add search for code + + /*---------------------------------------------------------------------------------------------------------------*/ + + layoutDesignView = new StandardLayout("Design View", 363, 165, this, null); + layoutDesignView.setIcon(Icons.EDIT); + layoutDesignView.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y + 21, x + width, y + 164, Color.darkGray.getRGB()); + }); + + layoutDesignView.addComponent(codeViewCheckBox); + layoutDesignView.addComponent(designViewCheckBox); + layoutDesignView.addComponent(liveViewCheckBox); + + + + //Todo work on design view + + /*---------------------------------------------------------------------------------------------------------------*/ + + layoutLiveView = new StandardLayout("Live View", 363, 165, this, null); + layoutLiveView.setIcon(Icons.PLAY); + layoutLiveView.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y + 21, x + width, y + 164, Color.GRAY.getRGB()); + }); + + layoutLiveView.addComponent(codeViewCheckBox); + layoutLiveView.addComponent(designViewCheckBox); + layoutLiveView.addComponent(liveViewCheckBox); + + liveGitWebFrame = new GitWebFrame(this, 0, 21, layoutLiveView.width, layoutLiveView.height - 22); + + layoutLiveView.addComponent(liveGitWebFrame); + } + + + + @Override + public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { + + super.render(graphics, laptop, mc, x, y, mouseX, mouseY, active, partialTicks); + + + if (this.getCurrentLayout() == layoutMain) { + if (gwbLogoModel == null) { + gwbLogoModel = new GWBLogoModel(GWBLogoModel.createContext().bakeLayer(GWBLogoModel.LAYER_LOCATION)); + } + graphics.pose().pushPose(); + + MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + VertexConsumer vertexConsumer = immediate.getBuffer(this.gwbLogoModel.renderType(logo)); + gwbLogoModel.renderToBuffer(graphics.pose(), vertexConsumer, 0xF000F0, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f); + immediate.endBatch(); +// { +// RenderSystem.enableDepthTest(); +// Lighting.setupForFlatItems(); +// graphics.pose().translate(x + 135, y - 43, 250); +// graphics.pose().scale((float) -8.0, (float) -8.0, (float) -8.0); +// graphics.pose().mulPose(new Quaternionf( 5F, 1, 0, 0)); +// graphics.pose().mulPose(new Quaternionf(200F, 0, 0, 1)); +// graphics.pose().mulPose(new Quaternionf(-rotationCounter - partialTicks, 0, 1, 0)); +// RenderSystem.setShaderTexture(0, logo); +// +// Lighting.setupFor3DItems(); +// RenderSystem.disableDepthTest(); +// +// } + graphics.pose().popPose(); + } + + if (this.getCurrentLayout() == layoutDesignView) { + + RenderSystem.setShaderTexture(0, ud); + RenderUtil.drawRectWithTexture(ud, graphics, (double) (x + 46), (double) (y + 19), 0.0F, 0.0F, 250, 145, 250, 250); + + } + + + } + + @Override + public void onTick() { + super.onTick(); + + rotationCounter++; + rotationCounter %= 360; + + + if (autoSave) { + if (this.getCurrentLayout().equals(layoutCodeView) || this.getCurrentLayout().equals(layoutDesignView)) { + if (currentFile != null) { + if (tickCounter == 100) { + CompoundTag data = new CompoundTag(); + data.putString("content", siteBuilderTextArea.getText()); + currentFile.setData(data, (v, success) -> { + }); + tickCounter = 0; + } + tickCounter++; + } + } + } + } + + public void createPastebin(String title, String code) { + String apikey = "12bfae53f22fc3d7bd73eb515f5a147f"; + String option = "paste"; + try { + URL url = new URL("https://pastebin.com/api/api_post.php"); + URLConnection conn = url.openConnection(); + conn.setDoOutput(true); + OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); + + writer.write("api_dev_key=" + apikey + "&api_option=" + option + "&api_paste_code=" + code + "&api_paste_name=" + title + "&api_paste_private=" + "0"); + writer.flush(); + String line; + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + while ((line = reader.readLine()) != null) { + this.openDialog(new PasteBinCompleteDialog(line)); + } + writer.close(); + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + + public String renderFormatting(String content) { + + return content + //new line fix + .replace("\n\n", "\n") + //color conversion to unicode format + .replace("&0", "\u00A70").replace("&1", "\u00A71").replace("&2", "\u00A72").replace("&3", "\u00A73") + .replace("&4", "\u00A74").replace("&5", "\u00A75").replace("&6", "\u00A76").replace("&7", "\u00A77") + .replace("&8", "\u00A78").replace("&9", "\u00A79").replace("&a", "\u00A7a").replace("&b", "\u00A7b") + .replace("&c", "\u00A7c").replace("&d", "\u00A7d").replace("&e", "\u00A7e").replace("&f", "\u00A7f") + //Formatting conversion to unicode format + .replace("&k", "\u00A7k").replace("&l", "\u00A7l").replace("&m", "\u00A7m").replace("&n", "\u00A7n") + .replace("&o", "\u00A7o").replace("&r", "\u00A7r"); + + } + + @Override + public void handleKeyTyped(char character, int code) { + super.handleKeyTyped(character, code); + /* TODO + + if (this.getCurrentLayout().equals(layoutCodeView)) { + if (GuiScreen.isCtrlKeyDown() && code == Keyboard.KEY_S) { + + if (currentFile != null) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("content", siteBuilderTextArea.getText()); + currentFile.setData(data, (v, success) -> { + if (success) { + + } + }); + } else { + NBTTagCompound data = new NBTTagCompound(); + data.setString("content", siteBuilderTextArea.getText()); + + Dialog.SaveFile saveDialog = new Dialog.SaveFile(this, data); + saveDialog.setFolder(getApplicationFolderPath()); + saveDialog.setResponseHandler((success, file) -> { + currentFile = file; + return true; + }); + this.openDialog(saveDialog); + } + } + if (GuiScreen.isCtrlKeyDown() && GuiScreen.isShiftKeyDown() && code == Keyboard.KEY_S) { + + NBTTagCompound data = new NBTTagCompound(); + data.setString("content", siteBuilderTextArea.getText()); + + Dialog.SaveFile saveDialog = new Dialog.SaveFile(this, data); + saveDialog.setFolder(getApplicationFolderPath()); + saveDialog.setResponseHandler((success, file) -> { + currentFile = file; + return true; + }); + this.openDialog(saveDialog); + } + } + + /*if (code == Keyboard.KEY_DELETE) { + siteBuilderTextArea.moveCursorRight(1); + siteBuilderTextArea.performBackspace(); + }*//* + + if (this.getCurrentLayout().equals(layoutCodeView) || this.getCurrentLayout().equals(layoutDesignView) || this.getCurrentLayout().equals(layoutLiveView)) { + if (GuiScreen.isCtrlKeyDown()) { + if (code == Keyboard.KEY_LEFT) { + if (this.getCurrentLayout().equals(layoutCodeView)) { + liveGitWebFrame.loadRaw(renderFormatting(siteBuilderTextArea.getText())); + this.setCurrentLayout(layoutLiveView); + codeViewCheckBox.setSelected(false); + designViewCheckBox.setSelected(false); + liveViewCheckBox.setSelected(true); + } else if (this.getCurrentLayout().equals(layoutDesignView)) { + this.setCurrentLayout(layoutCodeView); + codeViewCheckBox.setSelected(true); + designViewCheckBox.setSelected(false); + liveViewCheckBox.setSelected(false); + } else if (this.getCurrentLayout().equals(layoutLiveView)) { + this.setCurrentLayout(layoutDesignView); + codeViewCheckBox.setSelected(false); + designViewCheckBox.setSelected(true); + liveViewCheckBox.setSelected(false); + } + } + + if (code == Keyboard.KEY_RIGHT) { + if (this.getCurrentLayout().equals(layoutCodeView)) { + this.setCurrentLayout(layoutDesignView); + codeViewCheckBox.setSelected(false); + designViewCheckBox.setSelected(true); + liveViewCheckBox.setSelected(false); + } else if (this.getCurrentLayout().equals(layoutDesignView)) { + liveGitWebFrame.loadRaw(renderFormatting(siteBuilderTextArea.getText())); + this.setCurrentLayout(layoutLiveView); + codeViewCheckBox.setSelected(false); + designViewCheckBox.setSelected(false); + liveViewCheckBox.setSelected(true); + } else if (this.getCurrentLayout().equals(layoutLiveView)) { + this.setCurrentLayout(layoutCodeView); + codeViewCheckBox.setSelected(true); + designViewCheckBox.setSelected(false); + liveViewCheckBox.setSelected(false); + } + } + + } + } + +*/ + } + + @Override + public boolean handleFile(File file) { + if (!PREDICATE_FILE_SITE.test(file)) + return false; + + currentFile = file; + + CompoundTag data = file.getData(); + siteBuilderTextArea.setText(data.getString("content").replace("\n\n", "\n")); + this.setCurrentLayout(layoutCodeView); + + return true; + + } + + @Override + public void onClose() { + super.onClose(); + + + //Todo add save on close if not saved already + + + currentFile = null; + + + } + + private static T[] asArray(T... t) { + return t; + } + + + @Override + public void load(CompoundTag tagCompound) { + + if (tagCompound.contains("autoSave", Tag.TAG_BYTE)) { + autoSave = tagCompound.getBoolean("autoSave"); + } + + //Todo fix issue with autosave in settings + if (autoSave) { + autoSaveOnCheckBox.setSelected(true); + } else { + autoSaveOffCheckBox.setSelected(true); + } + + } + + /** + * Allows you to save data from your application. This is only called if + * {@link #isDirty()} returns true. You can mark your application as dirty + * by calling {@link #markDirty()}. + * + * @param tagCompound the tag compound to save your data to + */ + @Override + public void save(CompoundTag tagCompound) { + + tagCompound.putBoolean("autoSave", autoSave); + + } + + private static class Sites { + private File source; + private String fileName; + private String content; + + public Sites(String fileName, String content) { + this.fileName = fileName; + this.content = content; + } + + public File getSource() { + return this.source; + } + + public String getFileName() { + return this.fileName; + } + + public String getContent() { + return this.content; + } + + public String toString() { + return this.fileName; + } + + public static Sites fromFile(File file) { + Sites note = new Sites(file.getName(), file.getData().getString("content")); + note.source = file; + return note; + } + } + +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/MenuButton.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/MenuButton.java new file mode 100644 index 000000000..0e7cd6432 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/MenuButton.java @@ -0,0 +1,426 @@ +package mastef_chief.gitwebbuilder.app.components; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.ultreon.devices.api.app.Component; +import com.ultreon.devices.api.app.IIcon; +import com.ultreon.devices.api.app.listener.ClickListener; +import com.ultreon.devices.api.utils.RenderUtil; +import com.ultreon.devices.core.Laptop; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.sounds.SoundManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; + +import java.util.Arrays; + +public class MenuButton extends Component{ + + protected static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("textures/gui/widgets.png"); + + protected static final int TOOLTIP_DELAY = 20; + + protected String text; + protected String toolTip, toolTipTitle; + protected int toolTipTick; + protected boolean hovered; + + protected int padding = 5; + protected int width, height; + protected boolean explicitSize = false; + + protected ResourceLocation iconResource; + protected int iconU, iconV; + protected int iconWidth, iconHeight; + protected int iconSourceWidth; + protected int iconSourceHeight; + + protected ClickListener clickListener = null; + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + * @param text text to be displayed in the button + */ + public MenuButton(int left, int top, String text) + { + super(left, top); + this.width = getTextWidth(text) + padding * 2; + this.height = 16; + this.text = text; + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + * @param text text to be displayed in the button + */ + public MenuButton(int left, int top, int buttonWidth, int buttonHeight, String text) + { + super(left, top); + this.explicitSize = true; + this.width = buttonWidth; + this.height = buttonHeight; + this.text = text; + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + I * @param top how many pixels from the top + * @param icon + */ + public MenuButton(int left, int top, IIcon icon) + { + super(left, top); + this.padding = 3; + this.width = icon.getIconSize() + padding * 2; + this.height = icon.getIconSize() + padding * 2; + this.setIcon(icon); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + * @param icon + */ + public MenuButton(int left, int top, int buttonWidth, int buttonHeight, IIcon icon) + { + super(left, top); + this.explicitSize = true; + this.width = buttonWidth; + this.height = buttonHeight; + this.setIcon(icon); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + * @param icon + */ + public MenuButton(int left, int top, String text, IIcon icon) + { + this(left, top, text); + this.setIcon(icon); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + * @param icon + */ + public MenuButton(int left, int top, int buttonWidth, int buttonHeight, String text, IIcon icon) + { + super(left, top); + this.text = text; + this.explicitSize = true; + this.width = buttonWidth; + this.height = buttonHeight; + this.setIcon(icon); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + */ + public MenuButton(int left, int top, ResourceLocation iconResource, int iconU, int iconV, int iconWidth, int iconHeight) + { + super(left, top); + this.padding = 3; + this.setIcon(iconResource, iconU, iconV, iconWidth, iconHeight); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + */ + public MenuButton(int left, int top, int buttonWidth, int buttonHeight, ResourceLocation iconResource, int iconU, int iconV, int iconWidth, int iconHeight) + { + super(left, top); + this.explicitSize = true; + this.width = buttonWidth; + this.height = buttonHeight; + this.setIcon(iconResource, iconU, iconV, iconWidth, iconHeight); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + */ + public MenuButton(int left, int top, String text, ResourceLocation iconResource, int iconU, int iconV, int iconWidth, int iconHeight) + { + super(left, top); + this.text = text; + this.setIcon(iconResource, iconU, iconV, iconWidth, iconHeight); + } + + /** + * Alternate button constructor + * + * @param left how many pixels from the left + * @param top how many pixels from the top + */ + public MenuButton(int left, int top, int buttonWidth, int buttonHeight, String text, ResourceLocation iconResource, int iconU, int iconV, int iconWidth, int iconHeight) + { + super(left, top); + this.text = text; + this.explicitSize = true; + this.width = buttonWidth; + this.height = buttonHeight; + this.setIcon(iconResource, iconU, iconV, iconWidth, iconHeight); + } + + @Override + protected void handleTick() + { + toolTipTick = hovered ? ++toolTipTick : 0; + } + + @Override + public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) + { + if (this.visible) + { + RenderSystem.setShaderTexture(0, Component.COMPONENTS_GUI); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + this.hovered = isInside(mouseX, mouseY) && windowActive; + int i = this.getHoverState(this.hovered); + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(770, 771, 1, 0); + RenderSystem.blendFunc(770, 771); + + /* Corners */ + /*RenderUtil.drawRectWithTexture(xPosition, yPosition, 96 + i * 5, 12, 2, 2, 2, 2); + RenderUtil.drawRectWithTexture(xPosition + width - 2, yPosition, 99 + i * 5, 12, 2, 2, 2, 2); + RenderUtil.drawRectWithTexture(xPosition + width - 2, yPosition + height - 2, 99 + i * 5, 15, 2, 2, 2, 2); + RenderUtil.drawRectWithTexture(xPosition, yPosition + height - 2, 96 + i * 5, 15, 2, 2, 2, 2);*/ + + /* Middles */ + /*RenderUtil.drawRectWithTexture(xPosition + 2, yPosition, 98 + i * 5, 12, width - 4, 2, 1, 2); + RenderUtil.drawRectWithTexture(xPosition + width - 2, yPosition + 2, 99 + i * 5, 14, 2, height - 4, 2, 1); + RenderUtil.drawRectWithTexture(xPosition + 2, yPosition + height - 2, 98 + i * 5, 15, width - 4, 2, 1, 2); + RenderUtil.drawRectWithTexture(xPosition, yPosition + 2, 96 + i * 5, 14, 2, height - 4, 2, 1);*/ + + /* Center */ + /*RenderUtil.drawRectWithTexture(xPosition + 2, yPosition + 2, 98 + i * 5, 14, width - 4, height - 4, 1, 1);*/ + + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + + int contentWidth = (iconResource != null ? iconWidth: 0) + getTextWidth(text); + if(iconResource != null && text != null) contentWidth += 3; + int contentX = (int) Math.ceil((width - contentWidth) / 2.0); + + if(iconResource != null) + { + int iconY = (height - iconHeight) / 2; + RenderSystem.setShaderTexture(0, iconResource); + RenderUtil.drawRectWithTexture(iconResource, graphics, x + contentX, y + iconY, iconU, iconV, iconWidth, iconHeight, iconWidth, iconHeight, iconSourceWidth, iconSourceHeight); + } + + if(text != null) + { + int textY = (height - mc.font.lineHeight) / 2 + 1; + int textOffsetX = iconResource != null ? iconWidth + 3 : 0; + int textColor = !MenuButton.this.enabled ? 10526880 : (MenuButton.this.hovered ? 16777120 : 14737632); + graphics.drawString(mc.font, text, x + contentX + textOffsetX, y + textY, textColor); + } + } + } + + @Override + public void renderOverlay(GuiGraphics graphics, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) + { + if(this.hovered && this.toolTip != null && toolTipTick >= TOOLTIP_DELAY) + { + // TODO: laptop.drawHoveringText(Arrays.asList(TextFormatting.GOLD + this.toolTipTitle, this.toolTip), mouseX, mouseY); + } + } + + @Override + public void handleMouseClick(int mouseX, int mouseY, int mouseButton) + { + if(!this.visible || !this.enabled) + return; + + if(this.hovered) + { + if(clickListener != null) + { + clickListener.onClick(mouseX, mouseY, mouseButton); + } + playClickSound(Minecraft.getInstance().getSoundManager()); + } + } + + /** + * Sets the click listener. Use this to handle custom actions + * when you press the button. + * + * @param clickListener the click listener + */ + public final void setClickListener(ClickListener clickListener) + { + this.clickListener = clickListener; + } + + protected int getHoverState(boolean mouseOver) + { + int i = 1; + + if (!this.enabled) + { + i = 0; + } + else if (mouseOver) + { + i = 2; + } + + return i; + } + + protected void playClickSound(SoundManager handler) + { + // TODO: handler.play(.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + } + + protected boolean isInside(int mouseX, int mouseY) + { + return mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; + } + + public void setSize(int width, int height) + { + this.explicitSize = true; + this.width = width; + this.height = height; + } + + public void setPadding(int padding) + { + this.padding = padding; + updateSize(); + } + + /** + * Sets the text to display in the button + * + * @param text the text + */ + public void setText(String text) + { + this.text = text; + updateSize(); + } + + /** + * Gets the text currently displayed in the button + * + * @return the button text + */ + public String getText() + { + return text; + } + + public void setIcon(ResourceLocation iconResource, int iconU, int iconV, int iconWidth, int iconHeight) + { + this.iconU = iconU; + this.iconV = iconV; + this.iconResource = iconResource; + this.iconWidth = iconWidth; + this.iconHeight = iconHeight; + this.iconSourceWidth = 256; + this.iconSourceHeight = 256; + updateSize(); + } + + public void setIcon(IIcon icon) + { + this.iconU = icon.getU(); + this.iconV = icon.getV(); + this.iconResource = icon.getIconAsset(); + this.iconWidth = icon.getIconSize(); + this.iconHeight = icon.getIconSize(); + this.iconSourceWidth = icon.getGridWidth() * icon.getIconSize(); + this.iconSourceHeight = icon.getGridHeight() * icon.getIconSize(); + updateSize(); + } + + public void removeIcon() + { + this.iconResource = null; + updateSize(); + } + + private void updateSize() + { + if(explicitSize) return; + int height = padding * 2; + int width = padding * 2; + + if(iconResource != null) + { + width += iconWidth; + height += iconHeight; + } + + if(text != null) + { + width += getTextWidth(text); + height = 16; + } + + if(iconResource != null && text != null) + { + width += 3; + height = iconHeight + padding * 2; + } + + this.width = width; + this.height = height; + } + + /** + * Displays a message when hovering the button. + * + * @param toolTipTitle title of the tool tip + * @param toolTip description of the tool tip + */ + public void setToolTip(String toolTipTitle, String toolTip) + { + this.toolTipTitle = toolTipTitle; + this.toolTip = toolTip; + } + + private static int getTextWidth(String text) + { + Font fontRenderer = Minecraft.getInstance().font; + //boolean flag = fontRenderer.getUnicodeFlag(); + //fontRenderer.setUnicodeFlag(false); + int width = fontRenderer.width(text); + //fontRenderer.setUnicodeFlag(flag); + return width; + } + + //TODO add button text color and button color + +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/ModuleCreatorDialog.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/ModuleCreatorDialog.java new file mode 100644 index 000000000..6e5ef445d --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/ModuleCreatorDialog.java @@ -0,0 +1,1149 @@ +package mastef_chief.gitwebbuilder.app.components; + +import com.ultreon.devices.api.app.Component; +import com.ultreon.devices.api.app.Dialog; +import com.ultreon.devices.api.app.Layout; +import com.ultreon.devices.api.app.ScrollableLayout; +import com.ultreon.devices.api.app.component.Button; +import com.ultreon.devices.api.app.component.Label; +import com.ultreon.devices.api.app.component.*; +import com.ultreon.devices.api.app.component.TextArea; +import com.ultreon.devices.api.app.component.TextField; +import com.ultreon.devices.api.app.listener.SlideListener; +import com.ultreon.devices.api.utils.RenderUtil; +import com.ultreon.devices.core.Laptop; +import com.ultreon.devices.object.ColorGrid; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.nbt.CompoundTag; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; + +public class ModuleCreatorDialog extends Dialog { + + private static final int DIVIDE_WIDTH = 15; + + private String selectedModule = null; + private String inputText = ""; + private String positiveText = "Create"; + private String negativeText = "Cancel"; + + private Color setColor = Color.darkGray; + + private ResponseHandler responseListener; + + private Button buttonPositive; + private Button buttonNegative; + + private Component colorDisplay; + + private ColorGrid colorGrid; + + private Slider redSlider; + private Slider greenSlider; + private Slider blueSlider; + + private TextArea selectedTextArea; + + public static final int LAYOUT_WIDTH = 175; + public static final int LAYOUT_HEIGHT = 150; + + public ModuleCreatorDialog(String module, TextArea textArea) { + + this.selectedModule = module; + this.selectedTextArea = textArea; + } + + + @Override + public void init(@Nullable CompoundTag nbtTagCompound) { + super.init(nbtTagCompound); + + Layout layout = new Layout(LAYOUT_WIDTH, LAYOUT_HEIGHT); + layout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + LAYOUT_HEIGHT, Color.DARK_GRAY.getRGB()); + }); + + this.setTitle("Module Builder (" + selectedModule + ")"); + + + if (selectedModule.equals("Paragraph")) { + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 125, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + LAYOUT_HEIGHT - 25, Color.gray.getRGB()); + }); + + Label textLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Text:", 5, 8); + scrollableLayout.addComponent(textLabel); + TextField textTextField = new TextField(5, 20, 162); + scrollableLayout.addComponent(textTextField); + + Label paddingLabel = new Label("Padding:", 5, 40); + scrollableLayout.addComponent(paddingLabel); + TextField paddingTextField = new TextField(5, 52, 162); + scrollableLayout.addComponent(paddingTextField); + + + Label imageLabel = new Label("Image Link:", 5, 72); + scrollableLayout.addComponent(imageLabel); + TextField imageTextField = new TextField(5, 84, 162); + scrollableLayout.addComponent(imageTextField); + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + System.out.println("Handled key press"); + if(!textTextField.getText().isEmpty()){ + System.out.println("on"); + buttonPositive.setEnabled(true); + }else { + System.out.println("off"); + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + if (mouseButton == 0) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("#paragraph"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("text=" + textTextField.getText()); + if (!paddingTextField.getText().isEmpty()) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("padding=" + paddingTextField.getText()); + } + if (!imageTextField.getText().isEmpty()) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("image=" + imageTextField.getText()); + } + selectedTextArea.performReturn(); + close(); + + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + if (selectedModule.equals("Navigation")) { + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 1060, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + 1060, Color.gray.getRGB()); + }); + + Text colorLabel = new Text(ChatFormatting.RESET + "Menu \nColor:", 10, 15, 60); + scrollableLayout.addComponent(colorLabel); + + Label redLabel = new Label("R ", 100, 12); + scrollableLayout.addComponent(redLabel); + redSlider = new Slider(110, 10, 50); + redSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(v, greenSlider.getPercentage(), blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(redSlider); + + Label greenLabel = new Label("G ", 100, 28); + scrollableLayout.addComponent(greenLabel); + greenSlider = new Slider(110, 26, 50); + greenSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), v, blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(greenSlider); + + Label blueLabel = new Label("B ", 100, 44); + scrollableLayout.addComponent(blueLabel); + blueSlider = new Slider(110, 42, 50); + blueSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), greenSlider.getPercentage(), v); + } + }); + scrollableLayout.addComponent(blueSlider); + + colorDisplay = new Component(45, 5) { + @Override + public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + graphics.fill(xPosition, yPosition, xPosition + 50, yPosition + 51, Color.DARK_GRAY.getRGB()); + graphics.fill(xPosition + 1, yPosition + 1, xPosition + 49, yPosition + 50, setColor.getRGB()); + } + }; + scrollableLayout.addComponent(colorDisplay); + + Label menuItemLink1Label = new Label("Menu Item Link (1):", 5, 70); + scrollableLayout.addComponent(menuItemLink1Label); + TextField menuItemLink1TextField = new TextField(5, 80, 162); + scrollableLayout.addComponent(menuItemLink1TextField); + + Label menuItemLabel1Label = new Label("Menu Item Label (1):", 5, 100); + scrollableLayout.addComponent(menuItemLabel1Label); + TextField menuItemLabel1TextField = new TextField(5, 110, 162); + scrollableLayout.addComponent(menuItemLabel1TextField); + + Label menuItemIcon1Label = new Label("Menu Item Icon (1):", 5, 130); + scrollableLayout.addComponent(menuItemIcon1Label); + TextField menuItemIcon1TextField = new TextField(5, 140, 162); + scrollableLayout.addComponent(menuItemIcon1TextField); + + + Label menuItemLink2Label = new Label("Menu Item Link (2):", 5, 170); + scrollableLayout.addComponent(menuItemLink2Label); + TextField menuItemLink2TextField = new TextField(5, 180, 162); + scrollableLayout.addComponent(menuItemLink2TextField); + + Label menuItemLabel2Label = new Label("Menu Item Label (2):", 5, 200); + scrollableLayout.addComponent(menuItemLabel2Label); + TextField menuItemLabel2TextField = new TextField(5, 210, 162); + scrollableLayout.addComponent(menuItemLabel2TextField); + + Label menuItemIcon2Label = new Label("Menu Item Icon (2):", 5, 230); + scrollableLayout.addComponent(menuItemIcon2Label); + TextField menuItemIcon2TextField = new TextField(5, 240, 162); + scrollableLayout.addComponent(menuItemIcon2TextField); + + + Label menuItemLink3Label = new Label("Menu Item Link (3):", 5, 270); + scrollableLayout.addComponent(menuItemLink3Label); + TextField menuItemLink3TextField = new TextField(5, 280, 162); + scrollableLayout.addComponent(menuItemLink3TextField); + + Label menuItemLabel3Label = new Label("Menu Item Label (3):", 5, 300); + scrollableLayout.addComponent(menuItemLabel3Label); + TextField menuItemLabel3TextField = new TextField(5, 310, 162); + scrollableLayout.addComponent(menuItemLabel3TextField); + + Label menuItemIcon3Label = new Label("Menu Item Icon (3):", 5, 330); + scrollableLayout.addComponent(menuItemIcon3Label); + TextField menuItemIcon3TextField = new TextField(5, 340, 162); + scrollableLayout.addComponent(menuItemIcon3TextField); + + + Label menuItemLink4Label = new Label("Menu Item Link (4):", 5, 370); + scrollableLayout.addComponent(menuItemLink4Label); + TextField menuItemLink4TextField = new TextField(5, 380, 162); + scrollableLayout.addComponent(menuItemLink4TextField); + + Label menuItemLabel4Label = new Label("Menu Item Label (4):", 5, 400); + scrollableLayout.addComponent(menuItemLabel4Label); + TextField menuItemLabel4TextField = new TextField(5, 410, 162); + scrollableLayout.addComponent(menuItemLabel4TextField); + + Label menuItemIcon4Label = new Label("Menu Item Icon (4):", 5, 430); + scrollableLayout.addComponent(menuItemIcon4Label); + TextField menuItemIcon4TextField = new TextField(5, 440, 162); + scrollableLayout.addComponent(menuItemIcon4TextField); + + + Label menuItemLink5Label = new Label("Menu Item Link (5):", 5, 470); + scrollableLayout.addComponent(menuItemLink5Label); + TextField menuItemLink5TextField = new TextField(5, 480, 162); + scrollableLayout.addComponent(menuItemLink5TextField); + + Label menuItemLabel5Label = new Label("Menu Item Label (5):", 5, 500); + scrollableLayout.addComponent(menuItemLabel5Label); + TextField menuItemLabel5TextField = new TextField(5, 510, 162); + scrollableLayout.addComponent(menuItemLabel5TextField); + + Label menuItemIcon5Label = new Label("Menu Item Icon (5):", 5, 530); + scrollableLayout.addComponent(menuItemIcon5Label); + TextField menuItemIcon5TextField = new TextField(5, 540, 162); + scrollableLayout.addComponent(menuItemIcon5TextField); + + + Label menuItemLink6Label = new Label("Menu Item Link (6):", 5, 570); + scrollableLayout.addComponent(menuItemLink6Label); + TextField menuItemLink6TextField = new TextField(5, 580, 162); + scrollableLayout.addComponent(menuItemLink6TextField); + + Label menuItemLabel6Label = new Label("Menu Item Label (6):", 5, 600); + scrollableLayout.addComponent(menuItemLabel6Label); + TextField menuItemLabel6TextField = new TextField(5, 610, 162); + scrollableLayout.addComponent(menuItemLabel6TextField); + + Label menuItemIcon6Label = new Label("Menu Item Icon (6):", 5, 630); + scrollableLayout.addComponent(menuItemIcon6Label); + TextField menuItemIcon6TextField = new TextField(5, 640, 162); + scrollableLayout.addComponent(menuItemIcon6TextField); + + + Label menuItemLink7Label = new Label("Menu Item Link (7):", 5, 670); + scrollableLayout.addComponent(menuItemLink7Label); + TextField menuItemLink7TextField = new TextField(5, 680, 162); + scrollableLayout.addComponent(menuItemLink7TextField); + + Label menuItemLabel7Label = new Label("Menu Item Label (7):", 5, 700); + scrollableLayout.addComponent(menuItemLabel7Label); + TextField menuItemLabel7TextField = new TextField(5, 710, 162); + scrollableLayout.addComponent(menuItemLabel7TextField); + + Label menuItemIcon7Label = new Label("Menu Item Icon (7):", 5, 730); + scrollableLayout.addComponent(menuItemIcon7Label); + TextField menuItemIcon7TextField = new TextField(5, 740, 162); + scrollableLayout.addComponent(menuItemIcon7TextField); + + + Label menuItemLink8Label = new Label("Menu Item Link (8):", 5, 770); + scrollableLayout.addComponent(menuItemLink8Label); + TextField menuItemLink8TextField = new TextField(5, 780, 162); + scrollableLayout.addComponent(menuItemLink8TextField); + + Label menuItemLabel8Label = new Label("Menu Item Label (8):", 5, 800); + scrollableLayout.addComponent(menuItemLabel8Label); + TextField menuItemLabel8TextField = new TextField(5, 810, 162); + scrollableLayout.addComponent(menuItemLabel8TextField); + + Label menuItemIcon8Label = new Label("Menu Item Icon (8):", 5, 830); + scrollableLayout.addComponent(menuItemIcon8Label); + TextField menuItemIcon8TextField = new TextField(5, 840, 162); + scrollableLayout.addComponent(menuItemIcon8TextField); + + + Label menuItemLink9Label = new Label("Menu Item Link (9):", 5, 870); + scrollableLayout.addComponent(menuItemLink9Label); + TextField menuItemLink9TextField = new TextField(5, 880, 162); + scrollableLayout.addComponent(menuItemLink9TextField); + + Label menuItemLabel9Label = new Label("Menu Item Label (9):", 5, 900); + scrollableLayout.addComponent(menuItemLabel9Label); + TextField menuItemLabel9TextField = new TextField(5, 910, 162); + scrollableLayout.addComponent(menuItemLabel9TextField); + + Label menuItemIcon9Label = new Label("Menu Item Icon (9):", 5, 930); + scrollableLayout.addComponent(menuItemIcon9Label); + TextField menuItemIcon9TextField = new TextField(5, 940, 162); + scrollableLayout.addComponent(menuItemIcon9TextField); + + Label menuItemLink10Label = new Label("Menu Item Link (10):", 5, 970); + scrollableLayout.addComponent(menuItemLink10Label); + TextField menuItemLink10TextField = new TextField(5, 980, 162); + scrollableLayout.addComponent(menuItemLink10TextField); + + Label menuItemLabel10Label = new Label("Menu Item Label (10):", 5, 1000); + scrollableLayout.addComponent(menuItemLabel10Label); + TextField menuItemLabel10TextField = new TextField(5, 1010, 162); + scrollableLayout.addComponent(menuItemLabel10TextField); + + Label menuItemIcon10Label = new Label("Menu Item Icon (10):", 5, 1030); + scrollableLayout.addComponent(menuItemIcon10Label); + TextField menuItemIcon10TextField = new TextField(5, 1040, 162); + scrollableLayout.addComponent(menuItemIcon10TextField); + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!menuItemLink1TextField.getText().isEmpty() && !menuItemLabel1TextField.getText().isEmpty() || !menuItemIcon1TextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + if (mouseButton == 0) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("#navigation"); + selectedTextArea.performReturn(); + if (setColor != Color.darkGray) { + selectedTextArea.writeText("color=" + setColor.getRGB()); + selectedTextArea.performReturn(); + } + if (!menuItemLink1TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-1=" + menuItemLink1TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel1TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-1=" + menuItemLabel1TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon1TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-1=" + menuItemIcon1TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel1TextField.getText().isEmpty() && menuItemIcon1TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (1) requires either a label or a icon.")); + } + } + + if (!menuItemLink2TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-2=" + menuItemLink2TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel2TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-2=" + menuItemLabel2TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon2TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-2=" + menuItemIcon2TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel2TextField.getText().isEmpty() && menuItemIcon2TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (2) requires either a label or a icon.")); + } + } + + if (!menuItemLink3TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-3=" + menuItemLink3TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel3TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-3=" + menuItemLabel3TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon3TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-3=" + menuItemIcon3TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel3TextField.getText().isEmpty() && menuItemIcon3TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (3) requires either a label or a icon.")); + } + } + + if (!menuItemLink4TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-4=" + menuItemLink4TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel4TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-4=" + menuItemLabel4TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon4TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-4=" + menuItemIcon4TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel4TextField.getText().isEmpty() && menuItemIcon4TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (4) requires either a label or a icon.")); + } + } + + if (!menuItemLink5TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-5=" + menuItemLink5TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel5TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-5=" + menuItemLabel5TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon5TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-5=" + menuItemIcon5TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel5TextField.getText().isEmpty() && menuItemIcon5TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (5) requires either a label or a icon.")); + } + } + + if (!menuItemLink6TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-6=" + menuItemLink6TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel6TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-6=" + menuItemLabel6TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon6TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-6=" + menuItemIcon6TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel6TextField.getText().isEmpty() && menuItemIcon6TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (6) requires either a label or a icon.")); + } + } + + if (!menuItemLink7TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-7=" + menuItemLink7TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel7TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-7=" + menuItemLabel7TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon7TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-7=" + menuItemIcon7TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel7TextField.getText().isEmpty() && menuItemIcon7TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (7) requires either a label or a icon.")); + } + } + + if (!menuItemLink8TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-8=" + menuItemLink8TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel8TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-8=" + menuItemLabel8TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon8TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-8=" + menuItemIcon8TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel8TextField.getText().isEmpty() && menuItemIcon8TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (8) requires either a label or a icon.")); + } + } + + if (!menuItemLink9TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-9=" + menuItemLink9TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel9TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-9=" + menuItemLabel9TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon9TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-9=" + menuItemIcon9TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + if (menuItemLabel9TextField.getText().isEmpty() && menuItemIcon9TextField.getText().isEmpty()) { + this.openDialog(new Message("Menu Item (9) requires either a label or a icon.")); + } + } + + if (!menuItemLink10TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-link-10=" + menuItemLink10TextField.getText()); + selectedTextArea.performReturn(); + if (!menuItemLabel10TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-label-10=" + menuItemLabel10TextField.getText()); + selectedTextArea.performReturn(); + } + if (!menuItemIcon10TextField.getText().isEmpty()) { + selectedTextArea.writeText("item-icon-10=" + menuItemIcon10TextField.getText().toUpperCase()); + selectedTextArea.performReturn(); + } + } + + close(); + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + } + + if(selectedModule.equals("Brewing")){ + + /*ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 220, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.drawRect(x, y, x + LAYOUT_WIDTH, y + 220, Color.gray.getRGB()); + }); + + Label titleLabel = new Label("Title:", 5, 8); + scrollableLayout.addComponent(titleLabel); + TextField titleTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(titleTextField); + + Label descLabel = new Label("Description:", 5, 38); + scrollableLayout.addComponent(descLabel); + TextField descTextField = new TextField(5, 48, 162); + scrollableLayout.addComponent(descTextField); + + Label fuelLabel = new Label("Fuel:", 5, 68); + scrollableLayout.addComponent(fuelLabel); + TextField fuelTextField = new TextField(5, 78, 162); + fuelTextField.setPlaceholder("{id:\"minecraft:blaze_powder\",Count:1}"); + scrollableLayout.addComponent(fuelTextField); + + Label inputLabel = new Label("Input:", 5, 98); + scrollableLayout.addComponent(inputLabel); + TextField inputTextField = new TextField(5, 108, 162); + scrollableLayout.addComponent(inputTextField); + + Label output1Label = new Label("Output (1):", 5, 128); + scrollableLayout.addComponent(output1Label); + TextField output1TextField = new TextField(5, 138, 162); + scrollableLayout.addComponent(output1TextField); + + Label output2Label = new Label("Output (2):", 5, 158); + scrollableLayout.addComponent(output2Label); + TextField output2TextField = new TextField(5, 168, 162); + scrollableLayout.addComponent(output2TextField); + + Label output3Label = new Label("Output (3):", 5, 188); + scrollableLayout.addComponent(output3Label); + TextField output3TextField = new TextField(5, 198, 162); + scrollableLayout.addComponent(output3TextField); + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(positiveText); + buttonPositive = new Button(125, 130, positiveText); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + + if (mouseButton == 0) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("#brewing"); + selectedTextArea.performReturn(); + if(!titleTextField.getText().isEmpty()){ + selectedTextArea.writeText("title=" + titleTextField.getText()); + selectedTextArea.performReturn(); + } + if(!descTextField.getText().isEmpty()){ + selectedTextArea.writeText("desc=" + descTextField.getText()); + selectedTextArea.performReturn(); + } + if(!fuelTextField.getText().isEmpty()){ + selectedTextArea.writeText("slot-fuel=" + fuelTextField.getText()); + selectedTextArea.performReturn(); + } + if(!inputTextField.getText().isEmpty()){ + selectedTextArea.writeText("slot-input=" + inputTextField.getText()); + selectedTextArea.performReturn(); + } + if(!output1TextField.getText().isEmpty()){ + selectedTextArea.writeText("slot-output-1=" + output1TextField.getText()); + selectedTextArea.performReturn(); + } + if(!output2TextField.getText().isEmpty()){ + selectedTextArea.writeText("slot-output-2=" + output2TextField.getText()); + selectedTextArea.performReturn(); + } + if(!output3TextField.getText().isEmpty()){ + selectedTextArea.writeText("slot-output-3=" + output3TextField.getText()); + selectedTextArea.performReturn(); + } + + + close(); + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getMinecraft().fontRenderer.getStringWidth(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative);*/ + + + + } + + if(selectedModule.equals("Download")){ + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 130, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + 130, Color.gray.getRGB()); + }); + + Label fileAppLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "File App:", 5, 8); + scrollableLayout.addComponent(fileAppLabel); + TextField fileAppTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(fileAppTextField); + + Label fileDataLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "File Data:", 5, 38); + scrollableLayout.addComponent(fileDataLabel); + TextField fileDataTextField = new TextField(5, 48, 162); + scrollableLayout.addComponent(fileDataTextField); + + Label fileNameLabel = new Label("File Name:", 5, 68); + scrollableLayout.addComponent(fileNameLabel); + TextField fileNameTextField = new TextField(5, 78, 162); + scrollableLayout.addComponent(fileNameTextField); + + Label textLabel = new Label("Text:", 5, 98); + scrollableLayout.addComponent(textLabel); + TextField textTextField = new TextField(5, 108, 162); + scrollableLayout.addComponent(textTextField); + + + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!fileAppTextField.getText().isEmpty() && !fileDataTextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + + if (mouseButton == 0) { + + selectedTextArea.performReturn(); + selectedTextArea.writeText("#download"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("file-app=" + fileAppTextField.getText()); + selectedTextArea.performReturn(); + selectedTextArea.writeText("file-data=" + fileDataTextField.getText()); + selectedTextArea.performReturn(); + if(!fileNameTextField.getText().isEmpty()){ + selectedTextArea.writeText("file-name=" + fileNameTextField.getText()); + selectedTextArea.performReturn(); + } + if(!textTextField.getText().isEmpty()){ + selectedTextArea.writeText("text=" + textTextField.getText()); + selectedTextArea.performReturn(); + } + close(); + + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + + if(selectedModule.equals("Footer")){ + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 160, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + 160, Color.gray.getRGB()); + }); + + Label titleLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Title:", 5, 8); + scrollableLayout.addComponent(titleLabel); + TextField titleTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(titleTextField); + + Label subtitleLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Subtitle:", 5, 38); + scrollableLayout.addComponent(subtitleLabel); + TextField subtitleTextField = new TextField(5, 48, 162); + scrollableLayout.addComponent(subtitleTextField); + + Label homePageLinkLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Home Page Link:", 5, 68); + scrollableLayout.addComponent(homePageLinkLabel); + TextField homePageLinkTextField = new TextField(5, 78, 162); + scrollableLayout.addComponent(homePageLinkTextField); + + Label colorLabel = new Label("Color:", 5, 98); + scrollableLayout.addComponent(colorLabel); + + Label redLabel = new Label("R ", 100, 107); + scrollableLayout.addComponent(redLabel); + redSlider = new Slider(110, 105, 50); + redSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(v, greenSlider.getPercentage(), blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(redSlider); + + Label greenLabel = new Label("G ", 100, 123); + scrollableLayout.addComponent(greenLabel); + greenSlider = new Slider(110, 121, 50); + greenSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), v, blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(greenSlider); + + Label blueLabel = new Label("B ", 100, 139); + scrollableLayout.addComponent(blueLabel); + blueSlider = new Slider(110, 137, 50); + blueSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), greenSlider.getPercentage(), v); + } + }); + scrollableLayout.addComponent(blueSlider); + + colorDisplay = new Component(45, 100) { + @Override + public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + graphics.fill(xPosition, yPosition, xPosition + 50, yPosition + 51, Color.DARK_GRAY.getRGB()); + graphics.fill(xPosition + 1, yPosition + 1, xPosition + 49, yPosition + 50, setColor.getRGB()); + } + }; + scrollableLayout.addComponent(colorDisplay); + + + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!titleTextField.getText().isEmpty() && !subtitleTextField.getText().isEmpty() && !homePageLinkTextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + + if (mouseButton == 0) { + + selectedTextArea.performReturn(); + selectedTextArea.writeText("#footer"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("title=" + titleTextField.getText()); + selectedTextArea.performReturn(); + selectedTextArea.writeText("sub-title=" + subtitleTextField.getText()); + selectedTextArea.performReturn(); + selectedTextArea.writeText("home-page=" + homePageLinkTextField.getText()); + selectedTextArea.performReturn(); + if (setColor != Color.darkGray) { + selectedTextArea.writeText("color=" + setColor.getRGB()); + selectedTextArea.performReturn(); + } + close(); + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + if(selectedModule.equals("Divider")){ + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 120, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + 120, Color.gray.getRGB()); + }); + + Label sizeLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Size:", 5, 8); + scrollableLayout.addComponent(sizeLabel); + TextField sizeTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(sizeTextField); + + Label colorLabel = new Label("Color:", 5, 38); + scrollableLayout.addComponent(colorLabel); + + Label redLabel = new Label("R ", 100, 47); + scrollableLayout.addComponent(redLabel); + redSlider = new Slider(110, 45, 50); + redSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(v, greenSlider.getPercentage(), blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(redSlider); + + Label greenLabel = new Label("G ", 100, 63); + scrollableLayout.addComponent(greenLabel); + greenSlider = new Slider(110, 61, 50); + greenSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), v, blueSlider.getPercentage()); + } + }); + scrollableLayout.addComponent(greenSlider); + + Label blueLabel = new Label("B ", 100, 79); + scrollableLayout.addComponent(blueLabel); + blueSlider = new Slider(110, 77, 50); + blueSlider.setSlideListener(new SlideListener() { + @Override + public void onSlide(float v) { + setColor = new Color(redSlider.getPercentage(), greenSlider.getPercentage(), v); + } + }); + scrollableLayout.addComponent(blueSlider); + + colorDisplay = new Component(45, 40) { + @Override + public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + graphics.fill(xPosition, yPosition, xPosition + 50, yPosition + 51, Color.DARK_GRAY.getRGB()); + graphics.fill(xPosition + 1, yPosition + 1, xPosition + 49, yPosition + 50, setColor.getRGB()); + } + }; + scrollableLayout.addComponent(colorDisplay); + + + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!sizeTextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + + if (mouseButton == 0) { + + selectedTextArea.performReturn(); + selectedTextArea.writeText("#divider"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("size=" + sizeTextField.getText()); + selectedTextArea.performReturn(); + if (setColor != Color.darkGray) { + selectedTextArea.writeText("color=" + setColor.getRGB()); + selectedTextArea.performReturn(); + } + close(); + + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + if(selectedModule.equals("Header")){ + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 125, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + LAYOUT_HEIGHT - 25, Color.gray.getRGB()); + }); + + Label textLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Text:", 5, 8); + scrollableLayout.addComponent(textLabel); + TextField textTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(textTextField); + + Label scaleLabel = new Label("Scale:", 5, 38); + scrollableLayout.addComponent(scaleLabel); + TextField scaleTextField = new TextField(5, 48, 162); + scrollableLayout.addComponent(scaleTextField); + + Label paddingLabel = new Label("Padding:", 5, 68); + scrollableLayout.addComponent(paddingLabel); + TextField paddingTextField = new TextField(5, 78, 162); + scrollableLayout.addComponent(paddingTextField); + + Label alignLabel = new Label("Align:", 5, 98); + scrollableLayout.addComponent(alignLabel); + TextField alignTextField = new TextField(5, 108, 162); + scrollableLayout.addComponent(alignTextField); + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!textTextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + if (mouseButton == 0) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("#header"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("text=" + textTextField.getText()); + selectedTextArea.performReturn(); + if(!scaleTextField.getText().isEmpty()){ + selectedTextArea.writeText("scale=" + scaleTextField.getText()); + selectedTextArea.performReturn(); + } + if(!paddingTextField.getText().isEmpty()){ + selectedTextArea.writeText("padding=" + paddingTextField.getText()); + selectedTextArea.performReturn(); + } + if(!alignTextField.getText().isEmpty()){ + selectedTextArea.writeText("align=" + alignTextField.getText()); + selectedTextArea.performReturn(); + } + + close(); + + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + if(selectedModule.equals("Banner")){ + + ScrollableLayout scrollableLayout = new ScrollableLayout(0, 0, LAYOUT_WIDTH, 125, LAYOUT_HEIGHT - 25); + scrollableLayout.setScrollSpeed(8); + scrollableLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); + gui.fill(x, y, x + LAYOUT_WIDTH, y + LAYOUT_HEIGHT - 25, Color.gray.getRGB()); + }); + + Label imageLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + "Image Link:", 5, 8); + scrollableLayout.addComponent(imageLabel); + TextField imageTextField = new TextField(5, 18, 162); + scrollableLayout.addComponent(imageTextField); + + Label textLabel = new Label("Text:", 5, 38); + scrollableLayout.addComponent(textLabel); + TextField textTextField = new TextField(5, 48, 162); + scrollableLayout.addComponent(textTextField); + + + layout.addComponent(scrollableLayout); + + int positiveWidth = Minecraft.getInstance().font.width(positiveText); + buttonPositive = new Button(125, 130, positiveText){ + @Override + public void handleCharTyped(char character, int code) { + super.handleCharTyped(character, code); + + if(!imageTextField.getText().isEmpty()){ + buttonPositive.setEnabled(true); + }else { + buttonPositive.setEnabled(false); + } + + } + }; + buttonPositive.setEnabled(false); + buttonPositive.setSize(positiveWidth + 10, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + if (mouseButton == 0) { + selectedTextArea.performReturn(); + selectedTextArea.writeText("#banner"); + selectedTextArea.performReturn(); + selectedTextArea.writeText("image=" + imageTextField.getText()); + selectedTextArea.performReturn(); + if(!textTextField.getText().isEmpty()){ + selectedTextArea.writeText("text=" + textTextField.getText()); + } + + close(); + + } + }); + layout.addComponent(buttonPositive); + + int negativeWidth = Minecraft.getInstance().font.width(negativeText); + buttonNegative = new Button(75, 130, negativeText); + buttonNegative.setSize(negativeWidth + 10, 16); + buttonNegative.setClickListener((mouseX, mouseY, mouseButton) -> close()); + layout.addComponent(buttonNegative); + + Label requiredLabel = new Label(ChatFormatting.RED + "*" + ChatFormatting.RESET + " Required", 7, 134); + layout.addComponent(requiredLabel); + + } + + this.setLayout(layout); + + + } + + +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/PasteBinCompleteDialog.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/PasteBinCompleteDialog.java new file mode 100644 index 000000000..b93e813ef --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/components/PasteBinCompleteDialog.java @@ -0,0 +1,90 @@ +package mastef_chief.gitwebbuilder.app.components; + +import com.ultreon.devices.api.app.Dialog; +import com.ultreon.devices.api.app.Layout; +import com.ultreon.devices.api.app.component.Button; +import com.ultreon.devices.api.app.component.Text; +import com.ultreon.devices.api.app.listener.ClickListener; +import com.ultreon.devices.api.task.TaskManager; +import mastef_chief.gitwebbuilder.app.tasks.TaskNotificationCopiedLink; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.font.TextFieldHelper; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.FormattedText; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; + +public class PasteBinCompleteDialog extends Dialog{ + + Toolkit toolkit = Toolkit.getDefaultToolkit(); + + private String messageText = ""; + + private ClickListener positiveListener; + private Button buttonPositive; + private Button openLinkButton; + private Button copyToClipboard; + + public PasteBinCompleteDialog(String messageText) + { + this.messageText = messageText; + } + + @Override + public void init(@Nullable CompoundTag nbtTagCompound) + { + super.init(nbtTagCompound); + + int lines = Minecraft.getInstance().font.split(FormattedText.of("Link: " + messageText), getWidth() - 10).size(); + defaultLayout.height += (lines) * Minecraft.getInstance().font.lineHeight; + + defaultLayout.setBackground((gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> + { + gui.fill(x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB()); + }); + + Text message = new Text("Link: " + messageText, 5, 5, getWidth() - 10); + this.addComponent(message); + + buttonPositive = new Button(getWidth() - 41, getHeight() - 20, "Close"); + buttonPositive.setSize(36, 16); + buttonPositive.setClickListener((mouseX, mouseY, mouseButton) -> + { + if(positiveListener != null) + { + positiveListener.onClick(mouseX, mouseY, mouseButton); + } + close(); + }); + this.addComponent(buttonPositive); + + /*openLinkButton = new Button(getWidth() - 145, getHeight() - 20, "Open"); + openLinkButton.setClickListener((mouseX, mouseY, mouseButton) -> { + if(mouseButton == 0){ + GuiConfirmOpenLink gui = new GuiConfirmOpenLink((res, id) ->{ + + + + }, messageText, 0, false); + gui.disableSecurityWarning(); + Minecraft.getMinecraft().displayGuiScreen(gui); + } + }); + this.addComponent(openLinkButton);*/ + + copyToClipboard = new Button(getWidth() - 104, getHeight() - 20, "Copy Link"); + copyToClipboard.setClickListener((mouseX, mouseY, mouseButton) -> { + if(mouseButton == 0){ + TextFieldHelper.setClipboardContents(Minecraft.getInstance(), messageText); + TaskManager.sendTask(new TaskNotificationCopiedLink()); + } + }); + this.addComponent(copyToClipboard); + + } + +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/models/GWBLogoModel.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/models/GWBLogoModel.java new file mode 100644 index 000000000..36bde8867 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/models/GWBLogoModel.java @@ -0,0 +1,84 @@ +package mastef_chief.gitwebbuilder.app.models; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.Model; + +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.client.renderer.RenderType; + +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; + +/** + * GWBLogoModel - Mastef_Chief + * Created using Tabula 7.0.0 + */ +public class GWBLogoModel extends Model { + private final ModelPart bb_main; + public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("gitwebbuilder:logo"), "logo"); + + public GWBLogoModel(ModelPart modelPart) { + super(RenderType::entityCutout); +// this.textureWidth = 64; +// this.textureHeight = 32; +// this.baseblock = new ModelRenderer(this, 0, 0); +// this.baseblock.setRotationPoint(-6.0F, 12.0F, -6.0F); +// this.baseblock.addBox(0.0F, 0.0F, 0.0F, 12, 12, 12, 0.0F); +// PiglinModel + this.bb_main = modelPart.getChild("bb_main"); + } + + public static LayerDefinition createTexturedModelData() { + MeshDefinition meshDefinition1 = new MeshDefinition(); + PartDefinition meshDefinition = meshDefinition1.getRoot(); + //PartDefinition bb_main = meshDefinition.addOrReplaceChild("bb_main", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -16.0F, -0.5F, 10.0F, 16.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.rotation(0.0F, 8.0F, 0.0F)); + PartDefinition bb_main2 = meshDefinition + .addOrReplaceChild("bb_main", + CubeListBuilder.create() + .texOffs(0, 0) + .addBox(0.0F, 0.0F, 0.0F, 12, 12, 12, + new CubeDeformation(0.0F) + ), + PartPose.ZERO //PartPose.offset(-60.0F, 12.0F, -6.0F) + ); + return LayerDefinition.create(meshDefinition1, 64, 32); + + } + + + public ModelPart getBb_main() { + return bb_main; + } + + @Override + public void renderToBuffer(PoseStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + bb_main.render(matrices, vertices, light, overlay, red, green, blue, alpha); + } + +// /** +// * This is a helper function from Tabula to set the rotation of model parts +// */ +// public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { +// modelRenderer.rotateAngleX = x; +// modelRenderer.rotateAngleY = y; +// modelRenderer.rotateAngleZ = z; +// } + + public static EntityRendererProvider.Context createContext() { + return new EntityRendererProvider.Context( + Minecraft.getInstance().getEntityRenderDispatcher(), + Minecraft.getInstance().getItemRenderer(), + Minecraft.getInstance().getBlockRenderer(), + Minecraft.getInstance().getEntityRenderDispatcher().getItemInHandRenderer(), + Minecraft.getInstance().getResourceManager(), + Minecraft.getInstance().getEntityModels(), + Minecraft.getInstance().font + ); + } +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedCode.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedCode.java new file mode 100644 index 000000000..b0ca1034e --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedCode.java @@ -0,0 +1,67 @@ +package mastef_chief.gitwebbuilder.app.tasks; + +import com.ultreon.devices.api.app.Icons; +import com.ultreon.devices.api.app.Notification; +import com.ultreon.devices.api.task.Task; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; + +public class TaskNotificationCopiedCode extends Task { + + + public TaskNotificationCopiedCode() { + super("notification_copiedcode"); + } + + /** + * Called before the request is sent off to the server. + * You should store the data you want to sendTask into the NBT Tag + * + * @param nbt The NBT to be sent to the server + */ + @Override + public void prepareRequest(CompoundTag nbt) { + + } + + /** + * Called when the request arrives to the server. Here you can perform actions + * with your request. Data attached to the NBT from {@link Task#prepareRequest(NBTTagCompound nbt)} + * can be accessed from the NBT tag parameter. + * + * @param nbt The NBT Tag received from the client + * @param world + * @param player + */ + @Override + public void processRequest(CompoundTag nbt, Level world, Player player) { + Notification notification = new Notification(Icons.COPY, ChatFormatting.BOLD + "Copied", "Code To Clipboard"); + notification.pushTo((ServerPlayer) player); + } + + /** + * Called before the response is sent back to the client. + * You should store the data you want to sendTask back into the NBT Tag + * + * @param nbt The NBT to be sent back to the client + */ + @Override + public void prepareResponse(CompoundTag nbt) { + + } + + /** + * Called when the response arrives to the client. Here you can update data + * on the client side. If you want to update any UI component, you should set + * a Callback before you sendTask the request. See {@link #setCallback(Callback)} + * + * @param nbt The NBT Tag received from the server + */ + @Override + public void processResponse(CompoundTag nbt) { + + } +} diff --git a/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedLink.java b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedLink.java new file mode 100644 index 000000000..b4b2bc3c8 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/java/mastef_chief/gitwebbuilder/app/tasks/TaskNotificationCopiedLink.java @@ -0,0 +1,66 @@ +package mastef_chief.gitwebbuilder.app.tasks; + +import com.ultreon.devices.api.app.Icons; +import com.ultreon.devices.api.app.Notification; +import com.ultreon.devices.api.task.Task; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; + +public class TaskNotificationCopiedLink extends Task { + + public TaskNotificationCopiedLink() { + super("notification_copiedlink"); + } + + /** + * Called before the request is sent off to the server. + * You should store the data you want to sendTask into the NBT Tag + * + * @param nbt The NBT to be sent to the server + */ + @Override + public void prepareRequest(CompoundTag nbt) { + + } + + /** + * Called when the request arrives to the server. Here you can perform actions + * with your request. Data attached to the NBT from {@link Task#prepareRequest(NBTTagCompound nbt)} + * can be accessed from the NBT tag parameter. + * + * @param nbt The NBT Tag received from the client + * @param world + * @param player + */ + @Override + public void processRequest(CompoundTag nbt, Level level, Player player) { + Notification notification = new Notification(Icons.COPY, ChatFormatting.BOLD + "Copied", "Link To Clipboard"); + notification.pushTo((ServerPlayer) player); + } + + /** + * Called before the response is sent back to the client. + * You should store the data you want to sendTask back into the NBT Tag + * + * @param nbt The NBT to be sent back to the client + */ + @Override + public void prepareResponse(CompoundTag nbt) { + + } + + /** + * Called when the response arrives to the client. Here you can update data + * on the client side. If you want to update any UI component, you should set + * a Callback before you sendTask the request. See {@link #setCallback(Callback)} + * + * @param nbt The NBT Tag received from the server + */ + @Override + public void processResponse(CompoundTag nbt) { + + } +} diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/apps/gitwebbuilder_app.json b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/apps/gitwebbuilder_app.json new file mode 100644 index 000000000..52f559886 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/apps/gitwebbuilder_app.json @@ -0,0 +1,13 @@ +{ + "schemaVersion": 2, + "name": "GitWeb Builder", + "authors": ["Mastef_Chief"], + "description": "${desc}", + "version": "1.0", + "icon": "gitwebbuilder:textures/app/icon/gitwebbuilder_app.png", + "screenshots": [ + "http://mastefchief.com/mods/gitwebbuilder/screenshots/screenshot1.png", + "http://mastefchief.com/mods/gitwebbuilder/screenshots/screenshot2.png", + "http://mastefchief.com/mods/gitwebbuilder/screenshots/screenshot3.png" + ] +} \ No newline at end of file diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/lang/en_us.json b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/lang/en_us.json new file mode 100644 index 000000000..09d887fd1 --- /dev/null +++ b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "app.gitwebbuilder.gitwebbuilder_app.desc": "Want to create an awesome site for GitWeb? Well, then use this builder to create your very own! GitWeb Builder comes equipped with all the tools you need to create your very own website! GitWeb Builder includes: Easy to use formatting buttons, module builders, and a live view to see your website in action!" +} \ No newline at end of file diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/banner/gitwebbuilder_app.png b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/banner/gitwebbuilder_app.png new file mode 100644 index 000000000..8abda3782 Binary files /dev/null and b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/banner/gitwebbuilder_app.png differ diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/lazy3dlogo.png b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/lazy3dlogo.png new file mode 100644 index 000000000..6aa25f8db Binary files /dev/null and b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/lazy3dlogo.png differ diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/logo.png b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/logo.png new file mode 100644 index 000000000..f10800b1c Binary files /dev/null and b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/logo.png differ diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/ud.png b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/ud.png new file mode 100644 index 000000000..1d9e69bf9 Binary files /dev/null and b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/gui/ud.png differ diff --git a/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/icon/base/gitwebbuilder_app.png b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/icon/base/gitwebbuilder_app.png new file mode 100644 index 000000000..5aadb2aea Binary files /dev/null and b/addon/gitweb-builder/common/src/main/resources/assets/gitwebbuilder/textures/app/icon/base/gitwebbuilder_app.png differ diff --git a/addon/gitweb-builder/fabric/src/main/java/mastef_chief/gitwebbuilder/fabric/GitwebBuilderFabric.java b/addon/gitweb-builder/fabric/src/main/java/mastef_chief/gitwebbuilder/fabric/GitwebBuilderFabric.java new file mode 100644 index 000000000..30a855ead --- /dev/null +++ b/addon/gitweb-builder/fabric/src/main/java/mastef_chief/gitwebbuilder/fabric/GitwebBuilderFabric.java @@ -0,0 +1,17 @@ +package mastef_chief.gitwebbuilder.fabric; + +import com.ultreon.devices.fabric.FabricApplicationRegistration; +import mastef_chief.gitwebbuilder.GitwebBuilder; +import net.fabricmc.api.ModInitializer; + +public class GitwebBuilderFabric implements ModInitializer, FabricApplicationRegistration { + @Override + public void registerApplications() { + GitwebBuilder.registerApplications(); + } + + @Override + public void onInitialize() { + new GitwebBuilder(); + } +} diff --git a/addon/gitweb-builder/fabric/src/main/resources/fabric.mod.json b/addon/gitweb-builder/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 000000000..4483fe2ca --- /dev/null +++ b/addon/gitweb-builder/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,47 @@ +{ + "schemaVersion": 1, + "id": "gitweb-builder", + "version": "${version}", + "name": "Gitweb Builder", + "description": "${description}", + "authors": [ + "Ultreon Team" + ], + "contributors": [ + "Jab125", + "Dv8FromTheCode (Mastef_Chief)" + ], + "contact": { + "repo": "https://github.com/Ultreon/devices-mod", + "issues": "https://github.com/Ultreon/devices-mod/issues", + "sources": "https://github.com/Ultreon/devices-mod" + }, + "license": "GPL-3.0", + "icon": "gitwebbuilder.png", + "environment": "*", + "entrypoints": { + "main": [ + "mastef_chief.gitwebbuilder.fabric.GitwebBuilderFabric" + ], + "devices:application_registration": [ + "mastef_chief.gitwebbuilder.fabric.GitwebBuilderFabric" + ] + }, + "mixins": [ + ], + "depends": { + "fabricloader": "*", + "minecraft": "*", + "architectury": "*" + }, + "custom": { + "modmenu": { + "links": { + "modmenu.discord": "https://discord.gg/dtdc46g6ry", + "modmenu.youtube": "https://youtube.com/@ultreon", + "modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/devices-mod", + "modmenu.modrinth": "https://modrinth.com/mod/devices-mod" + } + } + } +} diff --git a/addon/gitweb-builder/fabric/src/main/resources/gitwebbuilder.png b/addon/gitweb-builder/fabric/src/main/resources/gitwebbuilder.png new file mode 100644 index 000000000..5aadb2aea Binary files /dev/null and b/addon/gitweb-builder/fabric/src/main/resources/gitwebbuilder.png differ diff --git a/common/src/main/java/com/ultreon/devices/api/app/Dialog.java b/common/src/main/java/com/ultreon/devices/api/app/Dialog.java index ef60f0ca5..3a6f509ef 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Dialog.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Dialog.java @@ -359,7 +359,7 @@ public void init(@Nullable CompoundTag intent) { int offset = 0; if (messageText != null) { - int lines = Minecraft.getInstance().font.wordWrapHeight(messageText, getWidth() - 10); + int lines = Minecraft.getInstance().font.wordWrapHeight(messageText, 300/*getWidth() - 10*/); defaultLayout.height += lines * 9 + 10; offset += lines * 9 + 5; } diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Image.java b/common/src/main/java/com/ultreon/devices/api/app/component/Image.java index 866626b72..883019c7f 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Image.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Image.java @@ -456,6 +456,7 @@ public void setup(final Image image) { OnlineRequest.checkURLForSuspicions(url); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0"); + conn.setRequestProperty("Accept", "image/png"); InputStream connIn = conn.getInputStream(); byte[] bytes = connIn.readAllBytes(); connIn.close(); @@ -473,6 +474,7 @@ public void setup(final Image image) { setup = true; }); } catch (IOException e) { + Devices.LOGGER.debug("Failed to load image: " + url); texture = MissingTextureAtlasSprite.getTexture(); setup = true; e.printStackTrace(); diff --git a/settings.gradle b/settings.gradle index 90beba93d..ca0765ca7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,4 +11,20 @@ include("common") include("fabric") include("forge") include("fabric-datagen-helper") -include("fabric-testmod") \ No newline at end of file +include("fabric-testmod") + +def addons = ["gitweb-builder"] +addons.forEach { addon -> + include(":$addon-common") + include(":$addon-fabric") + include(":$addon-forge") + + project(":$addon-common").projectDir = file("addon/$addon/common") + project(":$addon-common").buildFileName = "../../addon-common.build.gradle" + + project(":$addon-fabric").projectDir = file("addon/$addon/fabric") + project(":$addon-fabric").buildFileName = "../../addon-fabric.build.gradle" + + project(":$addon-forge").projectDir = file("addon/$addon/forge") + project(":$addon-forge").buildFileName = "../../addon-forge.build.gradle" +} \ No newline at end of file