From b47e6af1e8bf61691943dbedbbca2e9b640391a6 Mon Sep 17 00:00:00 2001 From: jrbudda Date: Thu, 20 Jul 2017 07:50:02 -0400 Subject: [PATCH] 40b --- installer/Installer.java | 533 ++++++++---------- minecriftversion.py | 2 +- .../net/minecraft/client/Minecraft.java.patch | 2 +- .../client/entity/EntityPlayerSP.java.patch | 4 +- .../net/minecraft/client/main/Main.java.patch | 11 +- .../ThreadDownloadImageData.java.patch | 15 - .../entity/projectile/EntityArrow.java.patch | 2 +- .../projectile/EntityFireball.java.patch | 2 +- .../projectile/EntityThrowable.java.patch | 2 +- .../net/minecraft/src/RandomMobs.java.patch | 51 -- .../minecraft/src/WrUpdateThread.java.patch | 47 -- .../util/MovementInputFromOptions.java.patch | 30 +- .../minecrift/gui/GuiKeyBindingSelection.java | 169 ++++++ .../minecrift/gui/GuiLocomotionSettings.java | 48 +- .../mtbs3d/minecrift/gui/GuiVRControls.java | 117 +++- .../minecrift/gui/GuiVRControlsList.java | 132 +---- .../mtbs3d/minecrift/provider/MCOpenVR.java | 201 ++++--- .../minecrift/provider/OpenVRPlayer.java | 8 +- .../mtbs3d/minecrift/settings/VRSettings.java | 8 +- 19 files changed, 725 insertions(+), 659 deletions(-) delete mode 100644 patches/net/minecraft/client/renderer/ThreadDownloadImageData.java.patch delete mode 100644 patches/net/minecraft/src/RandomMobs.java.patch delete mode 100644 patches/net/minecraft/src/WrUpdateThread.java.patch create mode 100644 src/com/mtbs3d/minecrift/gui/GuiKeyBindingSelection.java diff --git a/installer/Installer.java b/installer/Installer.java index 785c8115..bc9d9a19 100644 --- a/installer/Installer.java +++ b/installer/Installer.java @@ -33,7 +33,10 @@ public class Installer extends JPanel implements PropertyChangeListener private String tempDir = System.getProperty("java.io.tmpdir"); private static final boolean ALLOW_FORGE_INSTALL = true; - private static final boolean ALLOW_HYDRA_INSTALL = false; // TODO: Change to true once Hydra is fixed up + private static final boolean ALLOW_HYDRA_INSTALL = false; + private static final boolean ALLOW_KATVR_INSTALL = false; + private static final boolean ALLOW_KIOSK_INSTALL = false; + private static final boolean ALLOW_HRTF_INSTALL = true; private static final boolean ALLOW_SHADERSMOD_INSTALL = true; private static final boolean NEEDS_2010_REDIST = false; @@ -58,6 +61,12 @@ public class Installer extends JPanel implements PropertyChangeListener private static final String FORGE_VERSION = "10.13.4.1614-1.7.10"; /* END OF DO NOT RENAME */ + private static final String DEFAULT_PROFILE_NAME = "ViveCraft " + MINECRAFT_VERSION; + private static final String DEFAULT_PROFILE_NAME_FORGE = "ViveCraft-Forge " + MINECRAFT_VERSION; + private static final String GITHUB_LINK = "https://github.com/jrbudda/minecrift"; + private static final String HOMEPAGE_LINK = "http://www.vivecraft.org"; + private static final String DONATION_LINK = "https://www.patreon.com/jrbudda"; + private String mc_url = "https://s3.amazonaws.com/Minecraft.Download/versions/" + MINECRAFT_VERSION + "/" + MINECRAFT_VERSION +".jar"; private InstallTask task; @@ -83,6 +92,8 @@ public class Installer extends JPanel implements PropertyChangeListener private JComboBox forgeVersion; private JCheckBox useHydra; private JCheckBox useHrtf; + private JCheckBox katvr; + private JCheckBox kiosk; private JComboBox ramAllocation; private final boolean QUIET_DEV = false; private File releaseNotes = null; @@ -97,7 +108,12 @@ public class Installer extends JPanel implements PropertyChangeListener private final String smcVanillaMD5 = "4797D91A1F3752EF47242637901199CB"; private final String smcForgeMD5 = "F66374AEA8DDA5F3B7CCB20C230375D7"; - + private JTextField txtCustomProfileName; + private JTextField txtCustomGameDir; + private JCheckBox chkCustomProfileName; + private JCheckBox chkCustomGameDir; + + static private final String forgeNotFound = "Forge not found..." ; private String userHomeDir; @@ -334,7 +350,6 @@ private boolean checkMD5(File a, String b){ return GetMd5(a).equalsIgnoreCase(b); } - private String GetMd5(File fo) { if (!fo.exists()) @@ -419,186 +434,6 @@ public void run() { } return true; - -/* File versionRootDir = new File(target,"versions"); - File versionTarget = new File(versionRootDir,MINECRAFT_VERSION); - if (!versionTarget.mkdirs() && !versionTarget.isDirectory()) - { - versionTarget.delete(); - versionTarget.mkdirs(); - } - - File librariesDir = new File(target, "libraries"); - List libraries = VersionInfo.getVersionInfo().getArrayNode("libraries"); - monitor.setMaximum(libraries.size() + 3); - int progress = 3; - - File versionJsonFile = new File(versionTarget,VersionInfo.getVersionTarget()+".json"); - - if (!VersionInfo.isInheritedJson()) - { - File clientJarFile = new File(versionTarget, VersionInfo.getVersionTarget()+".jar"); - File minecraftJarFile = VersionInfo.getMinecraftFile(versionRootDir); - - try - { - boolean delete = false; - monitor.setNote("Considering minecraft client jar"); - monitor.setProgress(1); - - if (!minecraftJarFile.exists()) - { - minecraftJarFile = File.createTempFile("minecraft_client", ".jar"); - delete = true; - monitor.setNote(String.format("Downloading minecraft client version %s", VersionInfo.getMinecraftVersion())); - String clientUrl = String.format(DownloadUtils.VERSION_URL_CLIENT.replace("{MCVER}", VersionInfo.getMinecraftVersion())); - System.out.println(" Temp File: " + minecraftJarFile.getAbsolutePath()); - - if (!DownloadUtils.downloadFileEtag("minecraft server", minecraftJarFile, clientUrl)) - { - minecraftJarFile.delete(); - JOptionPane.showMessageDialog(null, "Downloading minecraft failed, invalid e-tag checksum.\n" + - "Try again, or use the official launcher to run Minecraft " + - VersionInfo.getMinecraftVersion() + " first.", - "Error downloading", JOptionPane.ERROR_MESSAGE); - return false; - } - monitor.setProgress(2); - } - - if (VersionInfo.getStripMetaInf()) - { - monitor.setNote("Copying and filtering minecraft client jar"); - copyAndStrip(minecraftJarFile, clientJarFile); - monitor.setProgress(3); - } - else - { - monitor.setNote("Copying minecraft client jar"); - Files.copy(minecraftJarFile, clientJarFile); - monitor.setProgress(3); - } - - if (delete) - { - minecraftJarFile.delete(); - } - } - catch (IOException e1) - { - JOptionPane.showMessageDialog(null, "You need to run the version "+VersionInfo.getMinecraftVersion()+" manually at least once", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - } - - File targetLibraryFile = VersionInfo.getLibraryPath(librariesDir); - grabbed = Lists.newArrayList(); - List bad = Lists.newArrayList(); - progress = DownloadUtils.downloadInstalledLibraries("clientreq", librariesDir, monitor, libraries, progress, grabbed, bad); - - monitor.close(); - if (bad.size() > 0) - { - String list = Joiner.on("\n").join(bad); - JOptionPane.showMessageDialog(null, "These libraries failed to download. Try again.\n"+list, "Error downloading", JOptionPane.ERROR_MESSAGE); - return false; - } - - if (!targetLibraryFile.getParentFile().mkdirs() && !targetLibraryFile.getParentFile().isDirectory()) - { - if (!targetLibraryFile.getParentFile().delete()) - { - JOptionPane.showMessageDialog(null, "There was a problem with the launcher version data. You will need to clear "+targetLibraryFile.getAbsolutePath()+" manually", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - else - { - targetLibraryFile.getParentFile().mkdirs(); - } - } - - - JsonRootNode versionJson = JsonNodeFactories.object(VersionInfo.getVersionInfo().getFields()); - - try - { - BufferedWriter newWriter = Files.newWriter(versionJsonFile, Charsets.UTF_8); - PrettyJsonFormatter.fieldOrderPreservingPrettyJsonFormatter().format(versionJson,newWriter); - newWriter.close(); - } - catch (Exception e) - { - JOptionPane.showMessageDialog(null, "There was a problem writing the launcher version data, is it write protected?", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - - try - { - VersionInfo.extractFile(targetLibraryFile); - } - catch (IOException e) - { - JOptionPane.showMessageDialog(null, "There was a problem writing the system library file", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - - JdomParser parser = new JdomParser(); - JsonRootNode jsonProfileData; - - try - { - jsonProfileData = parser.parse(Files.newReader(launcherProfiles, Charsets.UTF_8)); - } - catch (InvalidSyntaxException e) - { - JOptionPane.showMessageDialog(null, "The launcher profile file is corrupted. Re-run the minecraft launcher to fix it!", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - catch (Exception e) - { - throw Throwables.propagate(e); - } - - - - - HashMap profileCopy = Maps.newHashMap(jsonProfileData.getNode("profiles").getFields()); - HashMap rootCopy = Maps.newHashMap(jsonProfileData.getFields()); - if(profileCopy.containsKey(JsonNodeFactories.string(VersionInfo.getProfileName()))) - { - HashMap forgeProfileCopy = Maps.newHashMap(profileCopy.get(JsonNodeFactories.string(VersionInfo.getProfileName())).getFields()); - forgeProfileCopy.put(JsonNodeFactories.string("name"), JsonNodeFactories.string(VersionInfo.getProfileName())); - forgeProfileCopy.put(JsonNodeFactories.string("lastVersionId"), JsonNodeFactories.string(VersionInfo.getVersionTarget())); - } - else - { - JsonField[] fields = new JsonField[] { - JsonNodeFactories.field("name", JsonNodeFactories.string(VersionInfo.getProfileName())), - JsonNodeFactories.field("lastVersionId", JsonNodeFactories.string(VersionInfo.getVersionTarget())), - }; - profileCopy.put(JsonNodeFactories.string(VersionInfo.getProfileName()), JsonNodeFactories.object(fields)); - } - JsonRootNode profileJsonCopy = JsonNodeFactories.object(profileCopy); - rootCopy.put(JsonNodeFactories.string("profiles"), profileJsonCopy); - - jsonProfileData = JsonNodeFactories.object(rootCopy); - - try - { - BufferedWriter newWriter = Files.newWriter(launcherProfiles, Charsets.UTF_8); - PrettyJsonFormatter.fieldOrderPreservingPrettyJsonFormatter().format(jsonProfileData,newWriter); - newWriter.close(); - } - catch (Exception e) - { - JOptionPane.showMessageDialog(null, "There was a problem writing the launch profile, is it write protected?", "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - */ - - - -// return success; } private boolean SetupMinecraftAsLibrary() { @@ -617,12 +452,10 @@ private boolean SetupMinecraftAsLibrary() { if(checkMD5(vanilla, MC_MD5)) mc_jar = vanilla; } - if(mc_jar == null){ // Download the minecraft jar (we don't wont to require that it has previously been downloaded in Minecraft) mc_jar = new File(tempDir + File.separator + MINECRAFT_VERSION + ".jar"); if (!mc_jar.exists() || !checkMD5(mc_jar, MC_MD5)) { - if (!downloadFile(mc_url, mc_jar, MC_MD5)) { JOptionPane.showMessageDialog(null, " Error: Failed to download " + MINECRAFT_VERSION + ".jar from " + mc_url, "Warning", JOptionPane.ERROR_MESSAGE); return false; @@ -635,16 +468,11 @@ private boolean SetupMinecraftAsLibrary() { InputStream src = new FileInputStream(mc_jar); tar.getParentFile().mkdirs(); return copyInputStreamToFile(src, tar); - } catch (Exception e) { JOptionPane.showMessageDialog(null, " Error: "+e.getLocalizedMessage(), "Warning", JOptionPane.ERROR_MESSAGE); return false; } - - - - } private boolean ExtractVersion() { @@ -705,12 +533,12 @@ public int read(byte[] buff) throws IOException { //modify json args if needed try { int jsonIndentSpaces = 2; - String profileName = getMinecraftProfileName(useForge.isSelected(), useShadersMod.isSelected()); File fileJson = ver_json_file; String json = readAsciiFile(fileJson); JSONObject root = new JSONObject(json); String args = (String)root.get("minecraftArguments"); - args += " --test"; + if(katvr.isSelected()) args += " --katvr"; + if(kiosk.isSelected()) args += " --kiosk"; root.put("minecraftArguments", args); FileWriter fwJson = new FileWriter(fileJson); fwJson.write(root.toString(jsonIndentSpaces)); @@ -731,14 +559,6 @@ public int read(byte[] buff) throws IOException { } ver_jar.close(); - //Create empty version jar file - //All code actually lives in libraries/ - - //1/2017 - dont do this anymore - better errors. - // ZipOutputStream null_jar = new ZipOutputStream(new FileOutputStream(new File (ver_dir, jar_id+".jar"))); - // null_jar.putNextEntry(new ZipEntry("Classes actually in libraries directory")); - // null_jar.closeEntry(); - // null_jar.close(); return ver_json_file.exists() && ver_file.exists(); } catch (Exception e) { finalMessage += " Error: "+e.getLocalizedMessage(); @@ -782,7 +602,6 @@ private boolean EnableHRTF() // Implementation by Zach Jaggi // VIVE START - install openVR dlls private boolean InstallOpenVR() { - String osname = System.getProperty("os.name").toLowerCase(); String osarch= System.getProperty("os.arch").toLowerCase(); @@ -791,11 +610,20 @@ private boolean InstallOpenVR() { String resource = "win32/openvr_api.dll"; if (osname.contains("windows")){ + installFile(osFolder, resource); + osFolder = "win64"; + resource = "win64/openvr_api.dll"; installFile(osFolder, resource); - osFolder = "win64"; - resource = "win64/openvr_api.dll"; - installFile(osFolder, resource); + + if(katvr.isSelected()){ + installFile("katvr", "katvr/WalkerBase.dll"); + installFile("katvr", "katvr/msvcp120d.dll"); + installFile("katvr", "katvr/msvcp140d.dll"); + installFile("katvr", "katvr/msvcr120d.dll"); + installFile("katvr", "katvr/vcruntime140d.dll"); + installFile("katvr", "katvr/ucrtbased.dll"); + } } else if( osname.contains("linux")){ osFolder = "linux32"; @@ -812,21 +640,18 @@ else if( osname.contains("mac")){ } return true; } - private boolean installFile(String osFolder, String resource){ File win32_dir = new File (targetDir, osFolder); win32_dir.mkdirs(); - - InputStream openvrdll = Installer.class.getResourceAsStream(resource); File dll_out = new File (targetDir, resource); - if (!copyInputStreamToFile(openvrdll, dll_out)) + if (!copyInputStreamToFile(openvrdll, dll_out)){ return false; - + } + return true; } - // VIVE END - install openVR dll @@ -1102,7 +927,6 @@ public Void doInBackground() monitor.close(); return null; } - if(useHrtf.isSelected()) { monitor.setProgress(85); @@ -1113,6 +937,7 @@ public Void doInBackground() } } boolean profileCreated = false; + finalMessage = "Failed: Couldn't setup profile!"; if (createProfile.isSelected()) { monitor.setProgress(95); @@ -1176,8 +1001,6 @@ public void run() null, "Please ensure you have closed the Minecraft launcher before proceeding.\n" //"Also, if installing with Forge please ensure you have installed Forge " + FORGE_VERSION + " first.", - - ,"Important!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); @@ -1233,6 +1056,9 @@ private boolean updateLauncherJson(File mcBaseDirFile, String minecriftVer) try { int jsonIndentSpaces = 2; String profileName = getMinecraftProfileName(useForge.isSelected(), useShadersMod.isSelected()); + if(chkCustomProfileName.isSelected() && txtCustomProfileName.getText().trim() != ""){ + profileName = txtCustomProfileName.getText(); + } File fileJson = new File(mcBaseDirFile, "launcher_profiles.json"); String json = readAsciiFile(fileJson); JSONObject root = new JSONObject(json); @@ -1243,16 +1069,15 @@ private boolean updateLauncherJson(File mcBaseDirFile, String minecriftVer) try { prof = (JSONObject) profiles.get(profileName); } - catch (Exception e) {} - + catch (Exception e) { + //this is normal if doesnt exist. + } java.text.DateFormat dateFormat=new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); if (prof == null) { prof = new JSONObject(); prof.put("name", profileName); - prof.put("useHopperCrashService", false); prof.put("launcherVisibilityOnGameClose", "keep the launcher open"); - prof.put("created", dateFormat.format(new java.util.Date())); profiles.put(profileName, prof); } @@ -1261,6 +1086,9 @@ private boolean updateLauncherJson(File mcBaseDirFile, String minecriftVer) prof.put("javaArgs", "-Xmx" + ramAllocation.getSelectedItem() + "G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn256M -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true"); root.put("selectedProfile", profileName); prof.put("lastUsed", dateFormat.format(new java.util.Date())); + if(chkCustomGameDir.isSelected() && txtCustomGameDir.getText().trim() != ""){ + prof.put("gameDir", txtCustomGameDir.getText()); + } FileWriter fwJson = new FileWriter(fileJson); fwJson.write(root.toString(jsonIndentSpaces)); @@ -1301,6 +1129,38 @@ public void actionPerformed(ActionEvent e) } } + private class GameDirSelectAction extends AbstractAction + { + @Override + public void actionPerformed(ActionEvent e) + { + JFileChooser dirChooser = new JFileChooser(); + dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + dirChooser.setFileHidingEnabled(false); + dirChooser.ensureFileIsVisible(targetDir); + dirChooser.setSelectedFile(targetDir); + int response = dirChooser.showOpenDialog(Installer.this); + switch (response) + { + case JFileChooser.APPROVE_OPTION: + txtCustomGameDir.setText(dirChooser.getSelectedFile().toString()); + break; + default: + break; + } + } + } + + private class updateTxtEnabled extends AbstractAction + { + @Override + public void actionPerformed(ActionEvent e) + { + txtCustomProfileName.setEditable(chkCustomProfileName.isSelected()); + } + } + + private class updateActionF extends AbstractAction { @Override @@ -1319,7 +1179,7 @@ public void actionPerformed(ActionEvent e) } } - private class updateActionP extends AbstractAction + private class updateActionP extends AbstractAction { @Override public void actionPerformed(ActionEvent e) @@ -1327,10 +1187,12 @@ public void actionPerformed(ActionEvent e) updateInstructions(); } } - - - public Installer(File targetDir) + + public Installer(File target) { + this.setMaximumSize(new Dimension(640,780)); + this.setPreferredSize(new Dimension(640,780)); + targetDir = target; ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); @@ -1342,7 +1204,7 @@ public Installer(File targetDir) image = ImageIO.read(Installer.class.getResourceAsStream("logo.png")); ImageIcon icon = new ImageIcon(image); JLabel logoLabel = new JLabel(icon); - logoLabel.setAlignmentX(CENTER_ALIGNMENT); + logoLabel.setAlignmentX(LEFT_ALIGNMENT); logoLabel.setAlignmentY(CENTER_ALIGNMENT); logoLabel.setSize(image.getWidth(), image.getHeight()); if (!QUIET_DEV) // VIVE - hide oculus logo @@ -1382,38 +1244,44 @@ public Installer(File targetDir) } JLabel tag = new JLabel("Welcome! This will install Vivecraft "+ version); - tag.setAlignmentX(CENTER_ALIGNMENT); + tag.setAlignmentX(LEFT_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); logoSplash.add(Box.createRigidArea(new Dimension(5,20))); tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)"); - tag.setAlignmentX(CENTER_ALIGNMENT); + tag.setAlignmentX(LEFT_ALIGNMENT); tag.setAlignmentY(CENTER_ALIGNMENT); logoSplash.add(tag); - logoSplash.setAlignmentX(CENTER_ALIGNMENT); + logoSplash.setAlignmentX(LEFT_ALIGNMENT); logoSplash.setAlignmentY(TOP_ALIGNMENT); - this.add(logoSplash); + this.add(logoSplash); JPanel entryPanel = new JPanel(); entryPanel.setLayout(new BoxLayout(entryPanel,BoxLayout.X_AXIS)); - - Installer.targetDir = targetDir; + entryPanel.setAlignmentX(LEFT_ALIGNMENT); + entryPanel.setAlignmentY(TOP_ALIGNMENT); + selectedDirText = new JTextField(); selectedDirText.setEditable(false); selectedDirText.setToolTipText("Path to minecraft"); - selectedDirText.setColumns(30); - entryPanel.add(selectedDirText); + selectedDirText.setAlignmentX(LEFT_ALIGNMENT); + selectedDirText.setAlignmentY(TOP_ALIGNMENT); + selectedDirText.setMaximumSize(new Dimension(400,20)); + JButton dirSelect = new JButton(); + dirSelect.setMaximumSize(new Dimension(20,20)); dirSelect.setAction(new FileSelectAction()); dirSelect.setText("..."); dirSelect.setToolTipText("Select an alternative minecraft directory"); + dirSelect.setAlignmentX(LEFT_ALIGNMENT); + dirSelect.setAlignmentY(TOP_ALIGNMENT); + + entryPanel.add(selectedDirText); entryPanel.add(dirSelect); - entryPanel.setAlignmentX(LEFT_ALIGNMENT); - entryPanel.setAlignmentY(TOP_ALIGNMENT); infoLabel = new JLabel(); infoLabel.setHorizontalTextPosition(JLabel.LEFT); infoLabel.setVerticalTextPosition(JLabel.TOP); @@ -1423,25 +1291,24 @@ public Installer(File targetDir) fileEntryPanel = new JPanel(); fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel,BoxLayout.Y_AXIS)); - fileEntryPanel.add(infoLabel); - fileEntryPanel.add(entryPanel); - - fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT); + fileEntryPanel.setAlignmentX(LEFT_ALIGNMENT); fileEntryPanel.setAlignmentY(TOP_ALIGNMENT); + + fileEntryPanel.add(entryPanel); + fileEntryPanel.add(infoLabel); + this.add(fileEntryPanel); + this.add(Box.createVerticalStrut(5)); - JPanel optPanel = new JPanel(); - optPanel.setLayout( new BoxLayout(optPanel, BoxLayout.Y_AXIS)); - optPanel.setAlignmentX(LEFT_ALIGNMENT); - optPanel.setAlignmentY(TOP_ALIGNMENT); - //Add forge options + + //Forge Options + JPanel forgePanel = new JPanel(); forgePanel.setLayout( new BoxLayout(forgePanel, BoxLayout.X_AXIS)); //Create forge: no/yes buttons useForge = new JCheckBox(); - AbstractAction actf = new updateActionF(); actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION); useForge.setAction(actf); @@ -1450,8 +1317,7 @@ public Installer(File targetDir) useForge.setEnabled(false); useForge.setToolTipText( "" + - "If checked, installs Vivecraft with Forge support. The correct version of Forge
" + - "(as displayed) must already be installed.
" + + "If checked, installs Vivecraft with Forge support.
" + ""); //Add "yes" and "which version" to the forgePanel @@ -1460,9 +1326,8 @@ public Installer(File targetDir) forgePanel.setAlignmentX(LEFT_ALIGNMENT); forgePanel.add(useForge); //forgePanel.add(forgeVersion); - useForge.setSelected(true); //and on that day, hundreds of clicks were saved. - // Profile creation / update support + //Create Profile createProfile = new JCheckBox("", true); AbstractAction actp = new updateActionP(); actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile"); @@ -1471,33 +1336,11 @@ public Installer(File targetDir) createProfile.setSelected(true); createProfile.setToolTipText( "" + - "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher
" + - "one is added. Then the profile is selected, and this Vivecraft version is set as the
" + - "current version.
" + + "Creates or updates a Minecraft Launcher profile for Vivecraft with the selected settings.
" + + "You should typically leave this checked." + ""); - useShadersMod = new JCheckBox(); - useShadersMod.setAlignmentX(LEFT_ALIGNMENT); - if (!ALLOW_SHADERSMOD_INSTALL) - useShadersMod.setEnabled(false); - AbstractAction acts = new updateActionSM(); - acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29"); - useShadersMod.setAction(acts); - useShadersMod.setToolTipText( - "" + - "If checked, sets the vivecraft profile to use ShadersMod
" + - "support." + - ""); - - useHydra = new JCheckBox("Razer Hydra support",false); - useHydra.setAlignmentX(LEFT_ALIGNMENT); - if (!ALLOW_HYDRA_INSTALL) - useHydra.setEnabled(false); - useHydra.setToolTipText( - "" + - "If checked, installs the additional Razor Hydra native library required for Razor Hydra
" + - "support." + - ""); + //Binaural Audio useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false); useHrtf.setToolTipText( @@ -1511,7 +1354,20 @@ public Installer(File targetDir) ""); useHrtf.setAlignmentX(LEFT_ALIGNMENT); + //ShadersMod + + useShadersMod = new JCheckBox(); + useShadersMod.setAlignmentX(LEFT_ALIGNMENT); + AbstractAction acts = new updateActionSM(); + acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29"); + useShadersMod.setAction(acts); + useShadersMod.setToolTipText( + "" + + "If checked, sets the vivecraft profile to use ShadersMod
" + + "support." + + ""); + //RAM Allocation JPanel ramPanel = new JPanel(); ramPanel.setLayout( new BoxLayout(ramPanel, BoxLayout.X_AXIS)); @@ -1524,39 +1380,121 @@ public Installer(File targetDir) ramAllocation.setSelectedIndex(1); ramAllocation.setToolTipText( "" + - "Select the amount of Ram, in GB to allocate to the Vivecraft profile." + + "Select the amount of Ram, in GB to allocate to the Vivecraft profile.
" + "At least 2GB is recommened. More than 1GB of ram requires 64 bit PC and java." + ""); ramAllocation.setAlignmentX(LEFT_ALIGNMENT); - ramAllocation.setMaximumSize( ramAllocation.getPreferredSize() ); + ramAllocation.setMaximumSize( new Dimension((int)ramAllocation.getPreferredSize().getWidth(), 20)); + - JLabel ram = new JLabel(" Profile Ram Allocation (GB)"); + JLabel ram = new JLabel(" Profile Ram Allocation (GB) "); ram.setAlignmentX(LEFT_ALIGNMENT); ramPanel.add(ram); ramPanel.add(ramAllocation); - optPanel.add(forgePanel); - optPanel.add(useShadersMod); - optPanel.add(createProfile); - optPanel.add(ramPanel); - optPanel.add(useHrtf); - this.add(optPanel); + //Custom Profile - this.add(Box.createRigidArea(new Dimension(5,20))); + JPanel namePanel = new JPanel(); + namePanel.setLayout( new BoxLayout(namePanel, BoxLayout.X_AXIS)); + namePanel.setAlignmentX(LEFT_ALIGNMENT); + namePanel.setAlignmentY(TOP_ALIGNMENT); + + txtCustomProfileName = new JTextField(); + txtCustomProfileName.setAlignmentX(LEFT_ALIGNMENT); + txtCustomProfileName.setMaximumSize(new Dimension(250,20)); + txtCustomProfileName.setEditable(false); + + chkCustomProfileName = new JCheckBox(); + chkCustomProfileName.setAlignmentX(LEFT_ALIGNMENT); + AbstractAction u = new updateTxtEnabled(); + u.putValue(AbstractAction.NAME, "Custom Profile Name"); + chkCustomProfileName.setAction(u); + chkCustomProfileName.setToolTipText( + "" + + "Enter a custom name for this profile"); + + namePanel.add(Box.createRigidArea(new Dimension(36,20))); + namePanel.add(chkCustomProfileName); + namePanel.add(txtCustomProfileName); + + // Custom Game Dir + + JPanel gameDirPanel = new JPanel(); + gameDirPanel.setLayout( new BoxLayout(gameDirPanel, BoxLayout.X_AXIS)); + gameDirPanel.setAlignmentX(LEFT_ALIGNMENT); + gameDirPanel.setAlignmentY(TOP_ALIGNMENT); + + txtCustomGameDir= new JTextField(); + txtCustomGameDir.setAlignmentX(LEFT_ALIGNMENT); + txtCustomGameDir.setMaximumSize(new Dimension(400,20)); + txtCustomGameDir.setEditable(false); + + chkCustomGameDir = new JCheckBox("Modpack Directory"); + chkCustomGameDir.setAlignmentX(LEFT_ALIGNMENT); + chkCustomGameDir.setToolTipText( + "" + + "Points the profile at a different game directory.
" + + "Select this to use Vivecraft with a modpack.
" + + "The game directory should contain the 'mods' " + + "directory of the desired pack." + + ""); + JButton gdirSelect = new JButton(); + gdirSelect.setAction(new GameDirSelectAction()); + gdirSelect.setText("..."); + gdirSelect.setMaximumSize(new Dimension(20,20)); + gdirSelect.setToolTipText("Select a modpack directory"); + entryPanel.add(gdirSelect); + + gameDirPanel.add(Box.createRigidArea(new Dimension(36,20))); + gameDirPanel.add(chkCustomGameDir); + gameDirPanel.add(txtCustomGameDir); + gameDirPanel.add(gdirSelect); + + // KATVR + + katvr = new JCheckBox("KATVR Driver", false); + katvr.setToolTipText( + "" + + "If checked, install the drivers needed for KATVR Treadmill
" + + "DO NOT select this unless you have the KATVR runtime installed."); + katvr.setAlignmentX(LEFT_ALIGNMENT); + + + kiosk = new JCheckBox("Kiosk Mode", false); + kiosk.setToolTipText( + "" + + "If checked, disables use of in-game menu via controller" + + ""); + kiosk.setAlignmentX(LEFT_ALIGNMENT); + + this.add(forgePanel); + if(ALLOW_SHADERSMOD_INSTALL) this.add(useShadersMod); + this.add(createProfile); + this.add(ramPanel); + this.add(namePanel); + this.add(gameDirPanel); + if(ALLOW_HRTF_INSTALL)this.add(useHrtf); + this.add(new JLabel(" ")); + if(ALLOW_KATVR_INSTALL||ALLOW_KIOSK_INSTALL) this.add(new JLabel("Advanced Options")); + if(ALLOW_KIOSK_INSTALL) this.add(kiosk); + if(ALLOW_KATVR_INSTALL) this.add(katvr); + + this.add(Box.createRigidArea(new Dimension(5,20))); + instructions = new JLabel("",SwingConstants.CENTER); instructions.setAlignmentX(CENTER_ALIGNMENT); instructions.setAlignmentY(TOP_ALIGNMENT); instructions.setForeground(Color.RED); instructions.setPreferredSize(new Dimension(20, 40)); - this.add(instructions); + this.add(instructions); this.add(Box.createVerticalGlue()); - JLabel github = linkify("Vivecraft is open source. find it on Github","https://github.com/jrbudda/minecrift","Vivecraft 1.7.10 Github"); - JLabel wiki = linkify("Vivecraft home page","http://www.vivecraft.org","Vivecraft Home"); - JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.","https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)","jrbudda's Paypal"); + JLabel github = linkify("Vivecraft is open source. find it on Github",GITHUB_LINK,"Vivecraft Github"); + JLabel wiki = linkify("Vivecraft home page",HOMEPAGE_LINK,"Vivecraft Home"); + JLabel donate = linkify("If you think Vivecraft is awesome, please consider supporting us on Patreon",DONATION_LINK,"jrbudda's Patreon"); JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.","http://optifine.net/donate.php","http://optifine.net/donate.php"); github.setAlignmentX(CENTER_ALIGNMENT); @@ -1573,28 +1511,26 @@ public Installer(File targetDir) this.add( wiki ); this.add( donate ); this.add( optifine ); - - this.setAlignmentX(LEFT_ALIGNMENT); updateFilePath(); updateInstructions(); } - private void updateInstructions(){ String out = ""; if(createProfile.isSelected()){ out += "Please make sure the Minecraft Launcher is not running."; + if(chkCustomProfileName.isSelected() == false){ + txtCustomProfileName.setText(getMinecraftProfileName(useForge.isSelected(), useShadersMod.isSelected())); + } } + ramAllocation.setSelectedIndex(1); if (useForge.isSelected()){ + ramAllocation.setSelectedIndex(2); out += "
Please make sure Forge has been installed first."; } - if (useForge.isSelected() && useShadersMod.isSelected()){ - // out += "Please make sure that ShadersModCore is NOT in your Forge mods folder!"; - } out+=""; instructions.setText(out); ramAllocation.setEnabled(createProfile.isSelected()); - } private void updateFilePath() @@ -1603,7 +1539,7 @@ private void updateFilePath() { targetDir = targetDir.getCanonicalFile(); if( targetDir.exists() ) { - File ForgeDir = new File(targetDir, "libraries"+File.separator+"net"+File.separator+"minecraftforge"+File.separator+"forge"); + File ForgeDir = new File( targetDir, "libraries"+File.separator+"net"+File.separator+"minecraftforge"+File.separator+"forge"); if( ForgeDir.isDirectory() ) { forgeVersions = ForgeDir.list(); if (forgeVersions != null && forgeVersions.length > 0) { @@ -1712,15 +1648,8 @@ public void mouseReleased(MouseEvent e) { private String getMinecraftProfileName(boolean usingForge, boolean sm) { - if(!usingForge) { - if(sm) - return "ViveCraft-ShadersMod " + MINECRAFT_VERSION; - else - return "ViveCraft " + MINECRAFT_VERSION; - } else if(sm) - return "ViveCraft-SM-Forge " + MINECRAFT_VERSION; - else - return "ViveCraft-Forge " + MINECRAFT_VERSION; + if(!usingForge) return DEFAULT_PROFILE_NAME; + else return DEFAULT_PROFILE_NAME_FORGE; } public static String readAsciiFile(File file) diff --git a/minecriftversion.py b/minecriftversion.py index fa6e47b0..06813b73 100644 --- a/minecriftversion.py +++ b/minecriftversion.py @@ -4,7 +4,7 @@ of_json_name = "1.7.10_HD_U_D1" of_file_md5 = "57c724fe8335c82aef8d54c101043e60" minecrift_version_num = "1.7.10" -minecrift_build = "jrbudda-39finalr1" +minecrift_build = "jrbudda-40b" of_file_extension = ".jar" mcp_version = "mcp908" mcp_uses_generics = False diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 1a240092..99ec61d3 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -1246,7 +1246,7 @@ + * The minecriftVerString will be automatically updated by the build scripts, do not modify here. + * Modify minecriftversion.py in root minecrift dir. + */ -+ public final String minecriftVerString = "Vivecraft 1.7.10 jrbudda-39finalr1"; ++ public final String minecriftVerString = "Vivecraft 1.7.10 jrbudda-40b"; + private boolean trigger; + /* end version */ + /** END MINECRIFT */ diff --git a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch index cb2a60fc..69dc9fad 100644 --- a/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -429,7 +429,7 @@ this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, name, volume, pitch, false); } -@@ -662,4 +853,292 @@ +@@ -662,4 +853,294 @@ } protected void sendHorseJump() {} @@ -532,6 +532,7 @@ + if(this.capabilities.isFlying || this.inWater){ + switch (mc.vrSettings.vrFreeMoveMode){ + case VRSettings.FREEMOVE_CONTROLLER: ++ case VRSettings.FREEMOVE_JOYPAD: + directionVec.rotateAroundX(con.getControllerOffhandPitch_World() * PIOVER180); + break; + case VRSettings.FREEMOVE_HMD: @@ -546,6 +547,7 @@ + + switch (mc.vrSettings.vrFreeMoveMode){ + case VRSettings.FREEMOVE_CONTROLLER: ++ case VRSettings.FREEMOVE_JOYPAD: + directionVec.rotateAroundY(-con.getControllerOffhandYaw_World() * PIOVER180); + break; + case VRSettings.FREEMOVE_HMD: diff --git a/patches/net/minecraft/client/main/Main.java.patch b/patches/net/minecraft/client/main/Main.java.patch index 0826d7fb..cf56e28b 100644 --- a/patches/net/minecraft/client/main/Main.java.patch +++ b/patches/net/minecraft/client/main/Main.java.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -77,8 +77,8 @@ +@@ -23,6 +23,8 @@ + + public class Main + { ++ public static boolean kiosk; ++ public static boolean katvr; + private static final java.lang.reflect.Type field_152370_a = new ParameterizedType() + { + private static final String __OBFID = "CL_00000828"; +@@ -77,8 +79,8 @@ ArgumentAcceptingOptionSpec var12 = var1.accepts("uuid").withRequiredArg(); ArgumentAcceptingOptionSpec var13 = var1.accepts("accessToken").withRequiredArg().required(); ArgumentAcceptingOptionSpec var14 = var1.accepts("version").withRequiredArg().required(); diff --git a/patches/net/minecraft/client/renderer/ThreadDownloadImageData.java.patch b/patches/net/minecraft/client/renderer/ThreadDownloadImageData.java.patch deleted file mode 100644 index 1d494ec7..00000000 --- a/patches/net/minecraft/client/renderer/ThreadDownloadImageData.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/client/renderer/ThreadDownloadImageData.java -+++ b/net/minecraft/client/renderer/ThreadDownloadImageData.java -@@ -232,11 +232,11 @@ - } - - this.setBufferedImage(var2); -- return; - } - catch (Exception var9) - { - logger.error("Couldn\'t download http texture: " + var9.getClass().getName() + ": " + var9.getMessage()); -+ return; - } - finally - { diff --git a/patches/net/minecraft/entity/projectile/EntityArrow.java.patch b/patches/net/minecraft/entity/projectile/EntityArrow.java.patch index bdab41cb..7f2a28fb 100644 --- a/patches/net/minecraft/entity/projectile/EntityArrow.java.patch +++ b/patches/net/minecraft/entity/projectile/EntityArrow.java.patch @@ -47,7 +47,7 @@ + float pitch = shooter.rotationPitch; + + -+ if (shooter instanceof EntityPlayer) ++ if (shooter.getEntityId() == Minecraft.getMinecraft().thePlayer.getEntityId()) + { + + Vec3 aimSource = Minecraft.getMinecraft().roomScale.getControllerPos_World(1); diff --git a/patches/net/minecraft/entity/projectile/EntityFireball.java.patch b/patches/net/minecraft/entity/projectile/EntityFireball.java.patch index 09ae167c..ec8cbd4f 100644 --- a/patches/net/minecraft/entity/projectile/EntityFireball.java.patch +++ b/patches/net/minecraft/entity/projectile/EntityFireball.java.patch @@ -36,7 +36,7 @@ + float yaw = shooter.rotationYaw; + float pitch = shooter.rotationPitch; + -+ if (shooter instanceof EntityPlayer) ++ if (shooter.getEntityId() == Minecraft.getMinecraft().thePlayer.getEntityId()) + { + Vec3 aimSource = Minecraft.getMinecraft().roomScale.getControllerPos_World(0); + Vec3 controllerDirection = Minecraft.getMinecraft().roomScale.getControllerMainDir_World(); diff --git a/patches/net/minecraft/entity/projectile/EntityThrowable.java.patch b/patches/net/minecraft/entity/projectile/EntityThrowable.java.patch index 633088e8..fd48c974 100644 --- a/patches/net/minecraft/entity/projectile/EntityThrowable.java.patch +++ b/patches/net/minecraft/entity/projectile/EntityThrowable.java.patch @@ -38,7 +38,7 @@ + float pitch = shooter.rotationPitch; + + -+ if (shooter instanceof EntityPlayer) ++ if (shooter.getEntityId() == Minecraft.getMinecraft().thePlayer.getEntityId()) + { + Vec3 aimSource = Minecraft.getMinecraft().roomScale.getControllerPos_World(0); + Vec3 controllerDirection = Minecraft.getMinecraft().roomScale.getControllerMainDir_World(); diff --git a/patches/net/minecraft/src/RandomMobs.java.patch b/patches/net/minecraft/src/RandomMobs.java.patch deleted file mode 100644 index fc070a1f..00000000 --- a/patches/net/minecraft/src/RandomMobs.java.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/src/RandomMobs.java -+++ b/net/minecraft/src/RandomMobs.java -@@ -80,7 +80,7 @@ - } - else - { -- ResourceLocation var5; -+ ResourceLocation props; - - try - { -@@ -108,28 +108,29 @@ - EntityLiving entityLiving = (EntityLiving)entity; - String name = loc.getResourcePath(); - -- if (!name.startsWith("textures/entity/")) -+ if (name.startsWith("textures/entity/")) - { -- ResourceLocation props1 = loc; -- return props1; -- } -+ RandomMobsProperties props1 = getProperties(loc); -+ ResourceLocation var5; - -- RandomMobsProperties props = getProperties(loc); -+ if (props1 == null) -+ { -+ var5 = loc; -+ return var5; -+ } - -- if (props != null) -- { -- var5 = props.getTextureLocation(loc, entityLiving); -+ var5 = props1.getTextureLocation(loc, entityLiving); - return var5; - } - -- var5 = loc; -+ props = loc; - } - finally - { - working = false; - } - -- return var5; -+ return props; - } - } - diff --git a/patches/net/minecraft/src/WrUpdateThread.java.patch b/patches/net/minecraft/src/WrUpdateThread.java.patch deleted file mode 100644 index 17bb33ec..00000000 --- a/patches/net/minecraft/src/WrUpdateThread.java.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/src/WrUpdateThread.java -+++ b/net/minecraft/src/WrUpdateThread.java -@@ -46,7 +46,7 @@ - var8.printStackTrace(); - } - -- WrUpdateThread.ThreadUpdateListener updateListener = new WrUpdateThread.ThreadUpdateListener((WrUpdateThread.NamelessClass1670024686)null); -+ WrUpdateThread.ThreadUpdateListener updateListener = new WrUpdateThread.ThreadUpdateListener((WrUpdateThread.NamelessClass2055995941)null); - - while (!Thread.interrupted() && !this.terminated) - { -@@ -367,7 +367,7 @@ - this.terminated = true; - } - -- static class NamelessClass1670024686 -+ static class NamelessClass2055995941 - { - } - -@@ -407,7 +407,7 @@ - this.updateControl = updateControl; - } - -- ThreadUpdateControl(WrUpdateThread.NamelessClass1670024686 x1) -+ ThreadUpdateControl(WrUpdateThread.NamelessClass2055995941 x1) - { - this(); - } -@@ -419,7 +419,7 @@ - - private ThreadUpdateListener() - { -- this.tuc = WrUpdateThread.this.new ThreadUpdateControl((WrUpdateThread.NamelessClass1670024686)null); -+ this.tuc = WrUpdateThread.this.new ThreadUpdateControl((WrUpdateThread.NamelessClass2055995941)null); - } - - public void updating(IWrUpdateControl uc) -@@ -428,7 +428,7 @@ - WrUpdateThread.this.checkCanWork(this.tuc); - } - -- ThreadUpdateListener(WrUpdateThread.NamelessClass1670024686 x1) -+ ThreadUpdateListener(WrUpdateThread.NamelessClass2055995941 x1) - { - this(); - } diff --git a/patches/net/minecraft/util/MovementInputFromOptions.java.patch b/patches/net/minecraft/util/MovementInputFromOptions.java.patch index 0dd0f27e..58ce0bc5 100644 --- a/patches/net/minecraft/util/MovementInputFromOptions.java.patch +++ b/patches/net/minecraft/util/MovementInputFromOptions.java.patch @@ -1,14 +1,18 @@ --- a/net/minecraft/util/MovementInputFromOptions.java +++ b/net/minecraft/util/MovementInputFromOptions.java -@@ -1,5 +1,7 @@ +@@ -1,6 +1,11 @@ package net.minecraft.util; ++import com.mtbs3d.minecrift.control.VRControllerButtonMapping; ++import com.mtbs3d.minecrift.provider.MCOpenVR; +import com.mtbs3d.minecrift.settings.VRSettings; +import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; ++import net.minecraft.client.settings.KeyBinding; public class MovementInputFromOptions extends MovementInput -@@ -14,8 +16,12 @@ + { +@@ -14,8 +19,12 @@ public void updatePlayerMoveState() { @@ -23,13 +27,31 @@ if (this.gameSettings.keyBindForward.getIsKeyPressed()) { -@@ -37,13 +43,30 @@ +@@ -36,14 +45,47 @@ + { --this.moveStrafe; } - +- - this.jump = this.gameSettings.keyBindJump.getIsKeyPressed(); - this.sneak = this.gameSettings.keyBindSneak.getIsKeyPressed(); ++ + Minecraft mc = Minecraft.getMinecraft(); ++ if(mc.vrSettings.vrFreeMoveMode == mc.vrSettings.FREEMOVE_JOYPAD){ ++ //override everything ++ this.moveForward = MCOpenVR.joyPadZ; ++ this.moveStrafe = MCOpenVR.joyPadX; ++ ++ //just assuming all this below is needed for compatibility. ++ boolean forwardKeyDown = this.moveForward > 0; ++ boolean backKeyDown = this.moveForward < 0; ++ boolean leftKeyDown = this.moveStrafe < 0 ; ++ boolean rightKeyDown = this.moveStrafe > 0; ++ KeyBinding.setKeyBindState(this.gameSettings.keyBindForward, forwardKeyDown); ++ KeyBinding.setKeyBindState(this.gameSettings.keyBindBack, backKeyDown); ++ KeyBinding.setKeyBindState(this.gameSettings.keyBindLeft, leftKeyDown); ++ KeyBinding.setKeyBindState(this.gameSettings.keyBindRight, rightKeyDown); ++ } ++ + boolean ok = Minecraft.getMinecraft().currentScreen==null && (mc.vrPlayer.getFreeMoveMode() || mc.vrSettings.simulateFalling); + + //VIVECRAFT DO ok. diff --git a/src/com/mtbs3d/minecrift/gui/GuiKeyBindingSelection.java b/src/com/mtbs3d/minecrift/gui/GuiKeyBindingSelection.java new file mode 100644 index 00000000..b0f2ec82 --- /dev/null +++ b/src/com/mtbs3d/minecrift/gui/GuiKeyBindingSelection.java @@ -0,0 +1,169 @@ +package com.mtbs3d.minecrift.gui; + +import java.util.Arrays; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiListExtended; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.EnumChatFormatting; +import org.apache.commons.lang3.ArrayUtils; + +public class GuiKeyBindingSelection extends GuiListExtended +{ + private final GuiVRControls controlsScreen; + private final Minecraft mc; + private final GuiListExtended.IGuiListEntry[] listEntries; + private int maxListLabelWidth; + + public GuiKeyBindingSelection(GuiVRControls controls, Minecraft mcIn) + { + super(mcIn, controls.width + 45, controls.height, 63, controls.height - 32, 20); + this.controlsScreen = controls; + this.mc = mcIn; + KeyBinding[] akeybinding = (KeyBinding[])ArrayUtils.clone(mcIn.gameSettings.keyBindings); + this.listEntries = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()+7]; + Arrays.sort((Object[])akeybinding); + int i = 0; + String s = null; + + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("None"); + + for (KeyBinding keybinding : akeybinding) + { + String s1 = keybinding.getKeyCategory(); + + if (!s1.equals(s)) + { + s = s1; + this.listEntries[i++] = new GuiKeyBindingSelection.CategoryEntry(s1); + } + + int j = mcIn.fontRendererObj.getStringWidth(I18n.format(keybinding.getKeyDescription())); + + if (j > this.maxListLabelWidth) + { + this.maxListLabelWidth = j; + } + + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry(keybinding); + } + this.listEntries[i++] = new GuiKeyBindingSelection.CategoryEntry("Keyboard Emulation"); + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("keyboard (press)"); + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("keyboard (hold)"); + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("keyboard-shift"); + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("keyboard-ctrl"); + this.listEntries[i++] = new GuiKeyBindingSelection.KeyEntry("keyboard-alt"); + + } + + protected int getSize() + { + return this.listEntries.length; + } + + /** + * Gets the IGuiListEntry object for the given index + */ + public GuiListExtended.IGuiListEntry getListEntry(int index) + { + return this.listEntries[index]; + } + + protected int getScrollBarX() + { + return super.getScrollBarX() + 15; + } + + /** + * Gets the width of the list + */ + public int getListWidth() + { + return super.getListWidth() + 32; + } + + public class CategoryEntry implements GuiListExtended.IGuiListEntry + { + private final String labelText; + private final int labelWidth; + + public CategoryEntry(String name) + { + this.labelText = I18n.format(name); + this.labelWidth = GuiKeyBindingSelection.this.mc.fontRendererObj.getStringWidth(this.labelText); + } + + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight,Tessellator p_148279_6_,int mouseX, int mouseY, boolean isSelected) { + GuiKeyBindingSelection.this.mc.fontRendererObj.drawString(EnumChatFormatting.AQUA + this.labelText, GuiKeyBindingSelection.this.mc.currentScreen.width / 2 - this.labelWidth / 2, y + slotHeight - GuiKeyBindingSelection.this.mc.fontRendererObj.FONT_HEIGHT - 1, 16777215); + } + + public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) + { + return false; + } + + public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) + { + } + + public void updatePosition(int p_192633_1_, int p_192633_2_, int p_192633_3_, float p_192633_4_) + { + } + + + } + + public class KeyEntry implements GuiListExtended.IGuiListEntry + { + private final String keyDesc; + private final String keyPrettyDesc; + + private KeyEntry(String keydesc) + { + this.keyDesc = keydesc; + this.keyPrettyDesc= I18n.format(keydesc); + } + + + public KeyEntry(KeyBinding keybinding) { + this.keyDesc = keybinding.getKeyDescription(); + this.keyPrettyDesc= I18n.format(this.keyDesc); + } + + + @Override + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight,Tessellator p_148279_6_, int mouseX, int mouseY, + boolean isSelected) { + boolean flag = (mouseX <= GuiKeyBindingSelection.this.width * .6) && mouseY < y + slotHeight && mouseY > y; + if(flag) + GuiKeyBindingSelection.this.mc.fontRendererObj.drawString(EnumChatFormatting.GREEN + this.keyPrettyDesc, x + 190 - GuiKeyBindingSelection.this.maxListLabelWidth, y + slotHeight / 2 - GuiKeyBindingSelection.this.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215); + else + GuiKeyBindingSelection.this.mc.fontRendererObj.drawString(EnumChatFormatting.WHITE + this.keyPrettyDesc, x + 190 - GuiKeyBindingSelection.this.maxListLabelWidth, y + slotHeight / 2 - GuiKeyBindingSelection.this.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215); + + } + + public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) + { + if(mouseX > GuiKeyBindingSelection.this.width * .6) return false; + if(GuiKeyBindingSelection.this.controlsScreen.buttonId == null) return false; //how did u get here? + GuiKeyBindingSelection.this.controlsScreen.selectionMode = false; + GuiKeyBindingSelection.this.controlsScreen.buttonId.FunctionDesc = this.keyDesc; + GuiKeyBindingSelection.this.controlsScreen.bindKey(GuiKeyBindingSelection.this.controlsScreen.buttonId); + if(this.keyDesc.startsWith("keyboard")) GuiKeyBindingSelection.this.controlsScreen.waitingForKey = true; + return true; + } + + public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) + { + } + + public void updatePosition(int p_192633_1_, int p_192633_2_, int p_192633_3_, float p_192633_4_) + { + } + + + } +} diff --git a/src/com/mtbs3d/minecrift/gui/GuiLocomotionSettings.java b/src/com/mtbs3d/minecrift/gui/GuiLocomotionSettings.java index 4ad61f6f..3efea91e 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiLocomotionSettings.java +++ b/src/com/mtbs3d/minecrift/gui/GuiLocomotionSettings.java @@ -14,13 +14,13 @@ public class GuiLocomotionSettings extends BaseGuiSettings implements GuiEventEx VRSettings.VrOptions.WEAPON_COLLISION, VRSettings.VrOptions.REALISTIC_JUMP, VRSettings.VrOptions.ANIMAL_TOUCHING, - VRSettings.VrOptions.ALLOW_MODE_SWITCH, VRSettings.VrOptions.REALISTIC_SNEAK, VRSettings.VrOptions.BCB_ON, VRSettings.VrOptions.REALISTIC_CLIMB, VRSettings.VrOptions.WALK_MULTIPLIER, - VRSettings.VrOptions.REALISTIC_SWIM, - VRSettings.VrOptions.DUMMY + VRSettings.VrOptions.REALISTIC_ROW, + VRSettings.VrOptions.ALLOW_MODE_SWITCH, + VRSettings.VrOptions.REALISTIC_SWIM }; static VRSettings.VrOptions[] teleportSettings = new VRSettings.VrOptions[] @@ -33,10 +33,10 @@ public class GuiLocomotionSettings extends BaseGuiSettings implements GuiEventEx static VRSettings.VrOptions[] freeMoveSettings = new VRSettings.VrOptions[] { VRSettings.VrOptions.FREEMOVE_MODE, - VRSettings.VrOptions.WALK_UP_BLOCKS, VRSettings.VrOptions.MOVEMENT_MULTIPLIER, VRSettings.VrOptions.INERTIA_FACTOR, - VRSettings.VrOptions.FOV_REDUCTION + VRSettings.VrOptions.FOV_REDUCTION, + }; public GuiLocomotionSettings(GuiScreen guiScreen, VRSettings guivrSettings) { @@ -54,11 +54,11 @@ public void initGui() this.buttonList.add(new GuiButtonEx(ID_GENERIC_DONE, this.width / 2 - 155 + 160, this.height -25,150,20, "Done")); VRSettings.VrOptions[] buttons = locomotionSettings; addButtons(buttons,0); + mc.vrSettings.vrFreeMove = mc.vrPlayer.getFreeMoveMode(); GuiSmallButtonEx mode = new GuiSmallButtonEx(VRSettings.VrOptions.MOVE_MODE.returnEnumOrdinal(), this.width / 2 - 68, this.height / 6 + 102,VRSettings.VrOptions.MOVE_MODE, this.guivrSettings.getKeyBinding(VRSettings.VrOptions.MOVE_MODE)); mode.setEventHandler(this); this.buttonList.add(mode); - mc.vrSettings.vrFreeMove = mc.vrPlayer.getFreeMoveMode(); - if(mc.vrSettings.vrFreeMove) + if(mc.vrPlayer.getFreeMoveMode()) addButtons(freeMoveSettings,134); else addButtons(teleportSettings,134); @@ -164,9 +164,10 @@ else if (par1GuiButton.id == ID_GENERIC_DEFAULTS) { vr.inertiaFactor = VRSettings.INERTIA_NORMAL; vr.movementSpeedMultiplier = 1f; - vr.simulateFalling = false; + vr.simulateFalling = true; //jrbudda// vr.weaponCollision = true; + vr.animaltouching = true; vr.vrAllowCrawling = false; vr.vrAllowLocoModeSwotch = true; vr.vrFreeMove = false; @@ -181,7 +182,7 @@ else if (par1GuiButton.id == ID_GENERIC_DEFAULTS) vr.realisticRowEnabled = true; vr.vehicleRotation = false; vr.useFOVReduction = false; - vr.animaltouching = true; + vr.walkUpBlocks = true; //end jrbudda Minecraft.getMinecraft().gameSettings.viewBobbing = true; @@ -243,12 +244,6 @@ protected String[] getTooltipLines(String displayString, int buttonId) "Defaults to 0.33 (1.0 is standard Minecraft movement", "speed)." } ; - case ANIMAL_TOUCHING: - return new String[] { - "If enabled, touching a passive mob (animal) without a", - "weapon will right-click (interact) instead of attacking.", - "Turn off for Piggy Slapping, Josh.", - } ; case WALK_UP_BLOCKS: return new String[] { "Allows you to set the ability to walk up blocks without", @@ -281,11 +276,17 @@ protected String[] getTooltipLines(String displayString, int buttonId) "If enabled, you can swing your pickaxe at blocks to", "mine them, or your sword at enemies to hit them." } ; + case ANIMAL_TOUCHING: + return new String[] { + "If enabled, touching a passive mob (animal) without a", + "weapon will right-click (interact) instead of attacking.", + "Turn off for Piggy Slapping, Josh.", + } ; // VIVE END - new options //JRBUDDA case ALLOW_MODE_SWITCH: return new String[] { - "Allows the use of the Right Grip button to switch between", + "Allows the use of the Pick Block button to switch between", "Teleport and Free Move mode." } ; case ALLOW_CRAWLING: @@ -305,14 +306,15 @@ protected String[] getTooltipLines(String displayString, int buttonId) } ; case BCB_ON: return new String[] { - "Shows your body position as a blue dot on the gound.", - "This is your Blue Circle Buddy (tm).", - "Do not lose your Blue Circle Buddy." + "Shows your body position as a square shadow on the ground.", + "This is your Square Shadow Buddy (tm).", + "Do not lose your Square Shadow Buddy." }; case REALISTIC_JUMP: return new String[]{ "If turned on, once you jump in real life", - "Your player will also jump" + "Your player will also jump. Also enables", + "Jump Boots." }; case REALISTIC_SNEAK: return new String[]{ @@ -322,7 +324,7 @@ protected String[] getTooltipLines(String displayString, int buttonId) case REALISTIC_CLIMB: return new String[]{ "If turned on, allow climbing ladders and vines", - "by touching them." + "by touching them. Also enables Climb Claws." }; case REALISTIC_SWIM: return new String[]{ @@ -345,7 +347,9 @@ protected String[] getTooltipLines(String displayString, int buttonId) "Controller: Uses left controller direction, max speed", "HMD: Uses head direction, max speed", "Run In Place: Use average controllers direction. Speed based", - "on controller motion." + "on controller motion.", + "Joy/Pad: Uses the left touchpad or joystick for all motion.", + "Overrides all 4 movement direction keybinds." } ; case VEHICLE_ROTATION: diff --git a/src/com/mtbs3d/minecrift/gui/GuiVRControls.java b/src/com/mtbs3d/minecrift/gui/GuiVRControls.java index 14e9910a..3ae4c078 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiVRControls.java +++ b/src/com/mtbs3d/minecrift/gui/GuiVRControls.java @@ -4,6 +4,8 @@ */ package com.mtbs3d.minecrift.gui; +import java.io.IOException; + import com.mtbs3d.minecrift.control.VRControllerButtonMapping; import com.mtbs3d.minecrift.gui.framework.BaseGuiSettings; import com.mtbs3d.minecrift.gui.framework.GuiButtonEx; @@ -14,17 +16,24 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiSlot; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.KeyBinding; -import net.minecraft.util.EnumChatFormatting; public class GuiVRControls extends BaseGuiSettings { - private GuiVRControlsList guiList; public VRControllerButtonMapping buttonId; - + public boolean selectionMode = false; + public boolean waitingForKey; + + private GuiVRControlsList guiList; + private GuiKeyBindingSelection guiSelection; + private GuiButton btnDefaults; + private GuiButton btnDone; + private GuiButton btnCancel; + public GuiVRControls(GuiScreen par1GuiScreen, VRSettings par2vrSettings) { super(par1GuiScreen, par2vrSettings); - screenTitle = "Control Remapping"; + screenTitle = "VR Control Remapping"; } /** @@ -33,50 +42,105 @@ public GuiVRControls(GuiScreen par1GuiScreen, VRSettings par2vrSettings) { */ protected void keyTyped(char typedChar, int keyCode) { - if (this.buttonId != null) + if (waitingForKey) { buttonId.FunctionExt = typedChar; - this.buttonId = null; + waitingForKey = false; } else { - super.keyTyped(typedChar, keyCode); + super.keyTyped(typedChar, keyCode); } } + + /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { this.guiList = new GuiVRControlsList(this, mc); + this.guiSelection = new GuiKeyBindingSelection(this, mc); this.buttonList.clear(); - this.buttonList.add(new GuiButtonEx (202, this.width / 2 , this.height -20,100,18, "Reset To Defaults")); - this.buttonList.add(new GuiButtonEx(200, this.width / 2 - 100, this.height -20,100,18, "Done")); - + btnDefaults = (new GuiButtonEx(ID_GENERIC_DEFAULTS, this.width / 2 - 155 , this.height -25 ,150,20, "Reset To Defaults")); + btnDone = (new GuiButtonEx(ID_GENERIC_DONE, this.width / 2 - 155 + 160, this.height -25,150,20, "Done")); + btnCancel = (new GuiButtonEx(99, this.width / 2 - 155 + 80, this.height -25,150,20, "Cancel")); + btnCancel.visible = false; + this.buttonList.add(btnDefaults); + this.buttonList.add(btnDone); + this.buttonList.add(btnCancel); } /** * Draws the screen and all the components in it. */ public void drawScreen(int par1, int par2, float par3) { - if (reinit) { - initGui(); - reinit = false; - } - this.guiList.drawScreen(par1, par2, par3); - super.drawScreen(par1,par2,par3,false); - } + if (reinit) { + initGui(); + reinit = false; + } + if(waitingForKey){ + screenTitle = "Press Keyboard Key..."; + btnCancel.visible = true; + btnDone.visible = false; + btnDefaults.visible = false; + }else { + if(this.selectionMode && this.buttonId != null){ + btnCancel.visible = true; + btnDone.visible = false; + btnDefaults.visible = false; + screenTitle = "Choose action for " + this.buttonId.Button.toString() + " (Current: " + I18n.format(this.buttonId.FunctionDesc)+")"; + this.guiSelection.drawScreen(par1, par2, par3); + } + else{ + btnCancel.visible = false; + btnDone.visible = true; + btnDefaults.visible = true; + this.selectionMode = false; + screenTitle = "VR Control Remapping"; + this.guiList.drawScreen(par1, par2, par3); + } + } + super.drawScreen(par1,par2,par3,false); + + } + + public void bindKey(VRControllerButtonMapping key){ + if(key.FunctionDesc.equals("None")){ + key.key = null; + key.FunctionExt = 0; + return; + } + if(key.FunctionDesc.startsWith("keyboard")){ + key.key = null; + if(key.FunctionDesc.contains("-")) key.FunctionExt = 0; + return; + } + KeyBinding[] var3 = mc.gameSettings.keyBindings; + for (final KeyBinding keyBinding : var3) { + if (keyBinding.getKeyDescription().equals(key.FunctionDesc)){ + key.key = keyBinding; + key.FunctionExt = 0; + return; + } + } + System.out.println("Keybind not found for " + key.FunctionDesc); + } + /** * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { - if (par1GuiButton.id == 200) { + if (par1GuiButton.id == ID_GENERIC_DONE) { this.guivrSettings.saveOptions(); this.mc.displayGuiScreen(this.parentGuiScreen); - } else if (par1GuiButton.id == 202){ + } else if (par1GuiButton.id == ID_GENERIC_DEFAULTS){ mc.vrSettings.resetBindings(); this.initGui(); + } else if (par1GuiButton.id == 99){ //selection cancel + this.selectionMode = false; + this.waitingForKey = false; } } @@ -85,10 +149,19 @@ protected void actionPerformed(GuiButton par1GuiButton) { */ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { - this.buttonId = null; - if (mouseButton != 0 || !this.guiList.func_148179_a(mouseX, mouseY, mouseButton)) + + boolean flag = false; + + if(this.selectionMode){ + flag = this.guiSelection.func_148179_a(mouseX, mouseY, mouseButton); + this.guiList.setEnabled(true); + }else{ + flag = this.guiList.func_148179_a(mouseX, mouseY, mouseButton); + this.guiSelection.setEnabled(true); + } + if (!flag) { - super.mouseClicked(mouseX, mouseY, mouseButton); + super.mouseClicked(mouseX, mouseY, mouseButton); } } diff --git a/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java b/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java index d1faaea6..f6771f4d 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java +++ b/src/com/mtbs3d/minecrift/gui/GuiVRControlsList.java @@ -11,7 +11,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.EnumChatFormatting; + import org.apache.commons.lang3.ArrayUtils; import com.mtbs3d.minecrift.control.VRControllerButtonMapping; @@ -26,46 +26,6 @@ public class GuiVRControlsList extends GuiListExtended private final GuiListExtended.IGuiListEntry[] listEntries; private int maxListLabelWidth = 0; private static final String __OBFID = "CL_00000732"; - - public ArrayList getPossibleFunctions(){ - ArrayList out = new ArrayList(); - - out.add("none"); - - for (KeyBinding key : mc.gameSettings.keyBindings) { - out.add(key.getKeyDescription()); - } - - out.add("keyboard(press)"); - out.add("keyboard(hold)"); - out.add("keyboard-shift"); - out.add("keyboard-ctrl"); - out.add("keyboard-alt"); - - return out; - } - - public void bindKey(VRControllerButtonMapping key){ - if(key.FunctionDesc.equals("none")){ - key.key = null; - key.FunctionExt = 0; - return; - } - if(key.FunctionDesc.startsWith("keyboard")){ - key.key = null; - if(key.FunctionDesc.contains("-")) key.FunctionExt = 0; - return; - } - KeyBinding[] var3 = mc.gameSettings.keyBindings; - for (final KeyBinding keyBinding : var3) { - if (keyBinding.getKeyDescription().equals(key.FunctionDesc)){ - key.key = keyBinding; - key.FunctionExt = 0; - return; - } - } - System.out.println("Keybind not found for " + key.FunctionDesc); - } public GuiVRControlsList(GuiVRControls parent, Minecraft mc) { @@ -73,29 +33,21 @@ public GuiVRControlsList(GuiVRControls parent, Minecraft mc) this.parent = parent; this.mc = mc; - ArrayList bindings = new ArrayList(); for (VRControllerButtonMapping vb : mc.vrSettings.buttonMappings) { - if(MCOpenVR.isVive && vb.Button.name().startsWith("BUTTON")) bindings.add(vb); - if(!MCOpenVR.isVive && vb.Button.name().startsWith("OCULUS")) bindings.add(vb); - } - + if(MCOpenVR.isVive && vb.Button.name().startsWith("BUTTON")) bindings.add(vb); + if(!MCOpenVR.isVive && vb.Button.name().startsWith("OCULUS")) bindings.add(vb); + } + this.listEntries = new GuiListExtended.IGuiListEntry[bindings.size()]; - - // Arrays.sort(bindings); + String var5 = null; int var4 = 0; int var7 = bindings.size(); for (int i = 0; i < var7; i++) { VRControllerButtonMapping kb = bindings.get(i); - String cat = "VR"; // kb.getKeyCategory(); - - if (!cat.equals(var5)) - { - var5 = cat; - // this.listEntries[var4++] = new GuiVRControlsList.CategoryEntry(cat); - } + String cat = "VR"; int width = mc.fontRendererObj.getStringWidth(I18n.format(kb.FunctionDesc, new Object[0])); @@ -146,9 +98,10 @@ public CategoryEntry(String p_i45028_2_) this.labelWidth = GuiVRControlsList.this.mc.fontRendererObj.getStringWidth(this.labelText); } - public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + @Override + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_,Tessellator t, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) { - GuiVRControlsList.this.mc.fontRendererObj.drawString(this.labelText, GuiVRControlsList.this.mc.currentScreen.width / 2 - this.labelWidth / 2, p_148279_3_ + p_148279_5_ - GuiVRControlsList.this.mc.fontRendererObj.FONT_HEIGHT - 1, 16777215); + mc.fontRendererObj.drawString(this.labelText, GuiVRControlsList.this.mc.currentScreen.width / 2 - this.labelWidth / 2, p_148279_3_ + p_148279_5_ - GuiVRControlsList.this.mc.fontRendererObj.FONT_HEIGHT - 1, 16777215); } public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) @@ -156,74 +109,47 @@ public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, i return false; } - public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) + { + } + } public class MappingEntry implements GuiListExtended.IGuiListEntry { private final VRControllerButtonMapping myKey; private final GuiButton btnChangeKeyBinding; - private final GuiButton btnKey; - private final ArrayList possibilites; - private int myi; private static final String __OBFID = "CL_00000735"; private GuiEnterText guiEnterText; + private GuiVRControls parentScreen; - private MappingEntry(VRControllerButtonMapping key) + private MappingEntry(VRControllerButtonMapping key, GuiVRControls parent) { this.myKey = key; this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 150, 18, I18n.format(key.FunctionDesc, new Object[0])); - this.possibilites = GuiVRControlsList.this.getPossibleFunctions(); - myi = this.possibilites.indexOf(myKey.FunctionDesc); - btnKey =new GuiButton(0, 0, 0, 18, 18, ""); + this.parentScreen = parent; } - - public void drawEntry(int p_148279_1_, int x, int y, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + + @Override + public void drawEntry(int p_148279_1_, int x, int y, int p_148279_4_, int p_148279_5_,Tessellator t, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) { GuiVRControlsList.this.mc.fontRendererObj.drawString(myKey.Button.toString().replace("BUTTON_", "").replace("OCULUS_", ""), x + 40 - GuiVRControlsList.this.maxListLabelWidth, y + p_148279_5_ / 2 - GuiVRControlsList.this.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215); this.btnChangeKeyBinding.xPosition = x + 90; - this.btnChangeKeyBinding.yPosition = y; - this.btnChangeKeyBinding.displayString = I18n.format(this.myKey.FunctionDesc, new Object[0]); + this.btnChangeKeyBinding.yPosition= y; + this.btnChangeKeyBinding.displayString = I18n.format(this.myKey.FunctionDesc, new Object[0]) + " " + this.myKey.FunctionExt; - this.btnKey.xPosition = x+240; - this.btnKey.yPosition = y; - this.btnKey.visible = (myKey.FunctionDesc.startsWith("keyboard(")); - this.btnKey.displayString = String.valueOf((myKey.FunctionExt)); - boolean var10 = GuiVRControlsList.this.parent.buttonId == myKey; - - if (var10) - { - this.btnKey.displayString = EnumChatFormatting.WHITE + "> " + EnumChatFormatting.YELLOW + this.btnKey.displayString + EnumChatFormatting.WHITE + " <"; - } - else if (false) - { //alow multi binding. - this.btnKey.displayString = EnumChatFormatting.RED + this.btnKey.displayString; - } - this.btnChangeKeyBinding.drawButton(GuiVRControlsList.this.mc, p_148279_7_, p_148279_8_); - this.btnKey.drawButton(GuiVRControlsList.this.mc, p_148279_7_, p_148279_8_); } public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) { - if (this.btnChangeKeyBinding.mousePressed(GuiVRControlsList.this.mc, p_148278_2_, p_148278_3_)) - { - //cycle? select from list? - myi++; - if(myi >= possibilites.size()) myi = 0; - this.myKey.FunctionDesc = possibilites.get(myi); - bindKey(myKey); - - return true; - } - else if (this.btnKey.mousePressed(GuiVRControlsList.this.mc, p_148278_2_, p_148278_3_)) - { - GuiVRControlsList.this.parent.buttonId = myKey; - - return true; + { + parent.selectionMode = true; + parent.buttonId = myKey; + return true; } else { @@ -234,12 +160,8 @@ else if (this.btnKey.mousePressed(GuiVRControlsList.this.mc, p_148278_2_, p_1482 public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) { this.btnChangeKeyBinding.mouseReleased(p_148277_2_, p_148277_3_); - // this.btnReset.mouseReleased(p_148277_2_, p_148277_3_); } - MappingEntry(VRControllerButtonMapping p_i45030_2_, Object p_i45030_3_) - { - this(p_i45030_2_); - } + } } diff --git a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java index c61c3000..cc8f1c76 100644 --- a/src/com/mtbs3d/minecrift/provider/MCOpenVR.java +++ b/src/com/mtbs3d/minecrift/provider/MCOpenVR.java @@ -35,6 +35,7 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiWinGame; import net.minecraft.client.gui.inventory.*; +import net.minecraft.client.main.Main; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -1120,7 +1121,8 @@ private static void updateControllerButtonState() } } } - + + public static float joyPadX, joyPadZ; //OK the fundamental problem with this is Minecraft uses a LWJGL event buffer for keyboard and mouse inputs. It polls those devices faster //and presents the game with a nice queue of things that happened. With OpenVR we're polling the controllers directly on the -game- (edit render?) loop. @@ -1129,7 +1131,7 @@ private static void updateControllerButtonState() //TODO: make a new class that polls more quickly and provides Minecraft.java with a HTCController.next() event queue. (unless openVR has one?) private static void processControllerButtons(boolean sleeping, boolean gui) { - // right controller + // right controller //last boolean lastpressedRGrip = (lastControllerState[RIGHT_CONTROLLER].ulButtonPressed & k_buttonGrip) > 0; boolean lastpressedRtouchpadBottomLeft = (lastControllerState[RIGHT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && @@ -1146,7 +1148,7 @@ private static void processControllerButtons(boolean sleeping, boolean gui) (lastControllerState[RIGHT_CONTROLLER].rAxis[k_EAxis_TouchPad].x > 0 ) ; boolean lastpressedRAppMenu = (lastControllerState[RIGHT_CONTROLLER].ulButtonPressed & k_buttonAppMenu) > 0; boolean lastpressedRTrigger = lastControllerState[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x > triggerThreshold; - boolean lastpressedRTriggerClick =( lastControllerState[RIGHT_CONTROLLER].ulButtonPressed & k_buttonTrigger )>0; + boolean lastpressedRTriggerClick = lastControllerState[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x > 0.99F; //current boolean pressedRGrip = (controllerStateReference[RIGHT_CONTROLLER].ulButtonPressed & k_buttonGrip) > 0; boolean pressedRtouchpadBottomLeft = (controllerStateReference[RIGHT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && @@ -1163,7 +1165,7 @@ private static void processControllerButtons(boolean sleeping, boolean gui) (controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_TouchPad].x > 0 ) ; boolean pressedRAppMenu = (controllerStateReference[RIGHT_CONTROLLER].ulButtonPressed & k_buttonAppMenu) > 0; boolean pressedRTrigger = controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x > triggerThreshold; - boolean pressedRTriggerClick =( controllerStateReference[RIGHT_CONTROLLER].ulButtonPressed & k_buttonTrigger )>0; + boolean pressedRTriggerClick = controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_Trigger].x > 0.99F; if(!gui){ //R GRIP @@ -1196,7 +1198,7 @@ private static void processControllerButtons(boolean sleeping, boolean gui) mc.vrSettings.buttonMappings[ViveButtons.BUTTON_RIGHT_TRIGGER_FULLCLICK.ordinal()].press(); } } - + if(!pressedRGrip && lastpressedRGrip) { mc.vrSettings.buttonMappings[ViveButtons.BUTTON_RIGHT_GRIP.ordinal()].unpress(); } @@ -1224,8 +1226,6 @@ private static void processControllerButtons(boolean sleeping, boolean gui) mc.vrSettings.buttonMappings[ViveButtons.BUTTON_RIGHT_TRIGGER_FULLCLICK.ordinal()].unpress(); } - - // left controller //last boolean lastpressedLGrip = (lastControllerState[LEFT_CONTROLLER].ulButtonPressed & k_buttonGrip) > 0; @@ -1243,26 +1243,40 @@ private static void processControllerButtons(boolean sleeping, boolean gui) (lastControllerState[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x > 0 ) ; boolean lastpressedLAppMenu = (lastControllerState[LEFT_CONTROLLER].ulButtonPressed & k_buttonAppMenu) > 0; boolean lastpressedLTrigger = lastControllerState[LEFT_CONTROLLER].rAxis[k_EAxis_Trigger].x > triggerThreshold; - boolean lastpressedLTriggerClick =( lastControllerState[LEFT_CONTROLLER].ulButtonPressed & k_buttonTrigger )>0; + boolean lastpressedLTriggerClick = lastControllerState[LEFT_CONTROLLER].rAxis[k_EAxis_Trigger].x > 0.99F; //current + + float LTouchPadX = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x; + float LTouchPadY = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y; + boolean pressedLGrip = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonGrip) > 0; boolean pressedLtouchpadBottomLeft = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y < 0 ) && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x < 0 ) ; + (LTouchPadY< 0 ) && + (LTouchPadX < 0 ) ; boolean pressedLtouchpadBottomRight = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y < 0 ) && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x > 0 ) ; + (LTouchPadY < 0 ) && + (LTouchPadX > 0 ) ; boolean pressedLtouchpadTopLeft = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y > 0 ) && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x < 0 ) ; + (LTouchPadY> 0 ) && + (LTouchPadX < 0 ) ; boolean pressedLtouchpadTopRight = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonTouchpad) > 0 && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y > 0 ) && - (controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x > 0 ) ; + (LTouchPadY > 0 ) && + (LTouchPadX> 0 ) ; boolean pressedLAppMenu = (controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonAppMenu) > 0; boolean pressedLTrigger = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_Trigger].x > triggerThreshold; - boolean pressedLTriggerClick =( controllerStateReference[LEFT_CONTROLLER].ulButtonPressed & k_buttonTrigger )>0; - - + boolean pressedLTriggerClick = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_Trigger].x > 0.99F; + + + boolean TouchingLPad = (controllerStateReference[LEFT_CONTROLLER].ulButtonTouched & k_buttonTouchpad) > 0; + + if(TouchingLPad){ + joyPadX = -LTouchPadX; + joyPadZ = LTouchPadY; + } else { + joyPadX = 0; + joyPadZ = 0; + } + if(!gui){ //l GRIP - no gui cause shift. if (pressedLGrip && !lastpressedLGrip) { @@ -1270,7 +1284,7 @@ private static void processControllerButtons(boolean sleeping, boolean gui) } } - + if (pressedLtouchpadBottomLeft && !lastpressedLtouchpadBottomLeft){ mc.vrSettings.buttonMappings[ViveButtons.BUTTON_LEFT_TOUCHPAD_BL.ordinal()].press(); } @@ -1320,28 +1334,42 @@ private static void processControllerButtons(boolean sleeping, boolean gui) mc.vrSettings.buttonMappings[ViveButtons.BUTTON_LEFT_TRIGGER_FULLCLICK.ordinal()].unpress(); } - if(pressedLAppMenu && !lastpressedLAppMenu) { //handle menu directly - - if(pressedLGrip){ + if(pressedLAppMenu && !lastpressedLAppMenu) { //handle menu directly + if(pressedLGrip){ setKeyboardOverlayShowing(!keyboardShowing, null); } else{ if(gui || keyboardShowing){ - if(mc.currentScreen instanceof GuiWinGame){ //from 'esc' key on guiwingame since we cant push it. - mc.thePlayer.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); - mc.displayGuiScreen((GuiScreen)null); + mc.thePlayer.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); mc.displayGuiScreen((GuiScreen)null); }else { - mc.thePlayer.closeScreen(); + + if(Display.isActive()){ + KeyboardSimulator.robot.keyPress(KeyEvent.VK_ESCAPE); //window focus... yadda yadda + KeyboardSimulator.robot.keyRelease(KeyEvent.VK_ESCAPE); //window focus... yadda yadda + } + else + mc.thePlayer.closeScreen(); + setKeyboardOverlayShowing(false, null); } - }else - mc.displayInGameMenu(); + }else{ + if(!Main.kiosk){ + if(Display.isActive()){ + KeyboardSimulator.robot.keyPress(KeyEvent.VK_ESCAPE); //window focus... yadda yadda + KeyboardSimulator.robot.keyRelease(KeyEvent.VK_ESCAPE); //window focus... yadda yadda + } + else + mc.displayInGameMenu(); + } + setKeyboardOverlayShowing(false, null); + } } } - + if(pressedRAppMenu && !lastpressedRAppMenu) { if(mc.gameSettings.keyBindPickBlock.getIsKeyPressed() && mc.vrSettings.displayMirrorMode == mc.vrSettings.MIRROR_MIXED_REALITY){ - VRHotkeys.snapMRCam(mc,0); + if(!Main.kiosk)VRHotkeys.snapMRCam(mc,0); + mc.vrSettings.saveOptions(); } } } @@ -1387,7 +1415,7 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui boolean pressedRStickDown = controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_TouchPad].y < -0.5 ; boolean pressedRStickUp = controllerStateReference[RIGHT_CONTROLLER].rAxis[k_EAxis_TouchPad].y > 0.5 ; - + if(!gui){ //ignore the left, right, middle mouse buttons //R GRIP if (pressedRHandTrigger && !lastpressedRHandTrigger) { @@ -1402,12 +1430,12 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_A_PRESS.ordinal()].press(); } } - + //R B if (pressedB && !lastpressedB) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_B_PRESS.ordinal()].press(); } - + //R GRIP if (TouchedRHandTrigger && !lastTouchedRHandTrigger) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_HAND_TRIGGER_TOUCH.ordinal()].press(); @@ -1416,7 +1444,7 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui if (TouchedRTrigger && !lastTouchedRTrigger) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_INDEX_TRIGGER_TOUCH.ordinal()].press(); } - + //R B if (TouchedB && !lastTouchedB) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_B_TOUCH.ordinal()].press(); @@ -1451,8 +1479,8 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui if (pressedRStickDown && !lastpressedRStickDown) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_STICK_DOWN.ordinal()].press(); } - - + + //R GRIP if (!pressedRHandTrigger && lastpressedRHandTrigger) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_HAND_TRIGGER_PRESS.ordinal()].unpress(); @@ -1512,7 +1540,7 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui if (!pressedRStickDown && lastpressedRStickDown) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_RIGHT_STICK_DOWN.ordinal()].unpress(); } - + // LEFT controller //last boolean lastpressedLHandTrigger = (lastControllerState[LEFT_CONTROLLER].ulButtonPressed & k_buttonGrip) > 0; @@ -1551,7 +1579,8 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui boolean pressedStickDown = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y < -0.5 ; boolean pressedStickUp = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y > 0.5 ; - + joyPadX = -controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x; + joyPadZ = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y; rtbX = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].x; rtbY = controllerStateReference[LEFT_CONTROLLER].rAxis[k_EAxis_TouchPad].y; @@ -1601,24 +1630,27 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui if (TouchedLStick && !lastTouchedLStick) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_TOUCH.ordinal()].press(); } - //L Stick Left - if (pressedStickLeft && !lastpressedStickLeft) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_LEFT.ordinal()].press(); - } - //L Stick Right - if (pressedStickRight && !lastpressedStickRight) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_RIGHT.ordinal()].press(); - } - //L Stick Up - if (pressedStickUp && !lastpressedStickUp) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_UP.ordinal()].press(); - } - //L Stick Down - if (pressedStickDown && !lastpressedStickDown) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_DOWN.ordinal()].press(); + + if(mc.vrSettings.vrFreeMoveMode != mc.vrSettings.FREEMOVE_JOYPAD){ + //L Stick Left + if (pressedStickLeft && !lastpressedStickLeft) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_LEFT.ordinal()].press(); + } + //L Stick Right + if (pressedStickRight && !lastpressedStickRight) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_RIGHT.ordinal()].press(); + } + //L Stick Up + if (pressedStickUp && !lastpressedStickUp) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_UP.ordinal()].press(); + } + //L Stick Down + if (pressedStickDown && !lastpressedStickDown) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_DOWN.ordinal()].press(); + } } + //unpress - //L GRIP if (!pressedLHandTrigger && lastpressedLHandTrigger) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_HAND_TRIGGER_PRESS.ordinal()].unpress(); @@ -1659,49 +1691,61 @@ private static void processControllerButtonsOculus(boolean sleeping, boolean gui if (!TouchedLStick && lastTouchedLStick) { mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_TOUCH.ordinal()].unpress(); } - //L Stick Left - if (!pressedStickLeft && lastpressedStickLeft) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_LEFT.ordinal()].unpress(); - } - //L Stick Right - if (!pressedStickRight && lastpressedStickRight) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_RIGHT.ordinal()].unpress(); - } - //L Stick Up - if (!pressedStickUp && lastpressedStickUp) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_UP.ordinal()].unpress(); - } - //L Stick Down - if (!pressedStickDown && lastpressedStickDown) { - mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_DOWN.ordinal()].unpress(); + + if(mc.vrSettings.vrFreeMoveMode != mc.vrSettings.FREEMOVE_JOYPAD){ + //L Stick Left + if (!pressedStickLeft && lastpressedStickLeft) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_LEFT.ordinal()].unpress(); + } + //L Stick Right + if (!pressedStickRight && lastpressedStickRight) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_RIGHT.ordinal()].unpress(); + } + //L Stick Up + if (!pressedStickUp && lastpressedStickUp) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_UP.ordinal()].unpress(); + } + //L Stick Down + if (!pressedStickDown && lastpressedStickDown) { + mc.vrSettings.buttonMappings[ViveButtons.OCULUS_LEFT_STICK_DOWN.ordinal()].unpress(); + } } - - if(pressedY && !lastpressedY) { //handle menu directly - + if(pressedY && !lastpressedY) { //handle menu directly if(pressedLHandTrigger){ setKeyboardOverlayShowing(!keyboardShowing, null); } else{ if(gui || keyboardShowing){ - if(mc.currentScreen instanceof GuiWinGame){ //from 'esc' key on guiwingame since we cant push it. - mc.thePlayer.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); - mc.displayGuiScreen((GuiScreen)null); + mc.thePlayer.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); mc.displayGuiScreen((GuiScreen)null); }else { mc.thePlayer.closeScreen(); setKeyboardOverlayShowing(false, null); } }else - mc.displayInGameMenu(); + if(!Main.kiosk)mc.displayInGameMenu(); } } if(pressedA && !lastpressedA) { //handle menu directly if(mc.gameSettings.keyBindPickBlock.getIsKeyPressed() && mc.vrSettings.displayMirrorMode == mc.vrSettings.MIRROR_MIXED_REALITY){ - VRHotkeys.snapMRCam(mc,0); + if(!Main.kiosk)VRHotkeys.snapMRCam(mc,0); + mc.vrSettings.saveOptions(); } } + if (mc.currentScreen != null) { + if(pressedRStickUp && !lastpressedRStickUp){ + KeyboardSimulator.robot.mouseWheel(-120); + MCOpenVR.triggerHapticPulse(0, 100); + } + + if(pressedRStickDown && !lastpressedRStickDown){ + KeyboardSimulator.robot.mouseWheel(120); + MCOpenVR.triggerHapticPulse(0, 100); + } + } + } private static void processVRFunctions(boolean sleeping, boolean gui) { @@ -1928,6 +1972,7 @@ private static void clearTouchpadSampleBuffer(int controller) private static void processTouchpadSampleBuffer() { for(int c=0;c<2;c++){ + if(c==1 && mc.vrSettings.vrFreeMoveMode == mc.vrSettings.FREEMOVE_JOYPAD) continue; boolean touchpadPressed = (controllerStateReference[c].ulButtonPressed & k_buttonTouchpad) > 0; if (touchpadSampleCount[c] > 5 && !touchpadPressed){ int sample = touchpadSampleCount[c] - 5; diff --git a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java index b01a9656..5e5039c5 100644 --- a/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java +++ b/src/com/mtbs3d/minecrift/provider/OpenVRPlayer.java @@ -258,9 +258,8 @@ public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) } if (getFreeMoveMode()) { - if(player.movementInput.moveForward ==0) doPlayerMoveInRoom(player); - NetworkHelper.sendVRPlayerPositions(this); - + if(player.movementInput.moveForward ==0 && player.movementInput.moveStrafe == 0) doPlayerMoveInRoom(player); + return; //let mc handle look direction movement // controller vs gaze movement is handled in Entity.java > moveFlying } @@ -272,7 +271,7 @@ public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) boolean doTeleport = false; Vec3 dest = null; - if (player.movementInput.moveForward != 0 && !player.isRiding()) //holding down Ltrigger + if ((player.movementInput.moveForward != 0 || player.movementInput.moveStrafe != 0) && !player.isRiding()) //holding down Ltrigger { dest = movementTeleportDestination; @@ -481,7 +480,6 @@ public void onLivingUpdate(EntityPlayerSP player, Minecraft mc, Random rand) { doPlayerMoveInRoom(player); } - NetworkHelper.sendVRPlayerPositions(this); mc.mcProfiler.endSection(); } diff --git a/src/com/mtbs3d/minecrift/settings/VRSettings.java b/src/com/mtbs3d/minecrift/settings/VRSettings.java index 2480e956..6275bb1f 100644 --- a/src/com/mtbs3d/minecrift/settings/VRSettings.java +++ b/src/com/mtbs3d/minecrift/settings/VRSettings.java @@ -73,6 +73,7 @@ public class VRSettings public static final int FREEMOVE_CONTROLLER= 1; public static final int FREEMOVE_HMD= 2; public static final int FREEMOVE_RUNINPLACE= 3; + public static final int FREEMOVE_JOYPAD = 4; public static final int NO_SHADER = -1; @@ -914,6 +915,8 @@ else if (this.inertiaFactor == INERTIA_MASSIVE) return var4 + " HMD"; case FREEMOVE_RUNINPLACE: return var4 + " RunInPlace"; + case FREEMOVE_JOYPAD: + return var4 + " Joy/Pad"; } case FOV_REDUCTION: return this.useFOVReduction ? var4 + "ON" : var4 + "OFF"; @@ -1174,7 +1177,10 @@ public void setOptionValue(VRSettings.VrOptions par1EnumOptions, int par2) this.vrFreeMoveMode = FREEMOVE_RUNINPLACE; break; case FREEMOVE_RUNINPLACE: - this.vrFreeMoveMode = FREEMOVE_CONTROLLER; + this.vrFreeMoveMode = FREEMOVE_JOYPAD; + break; + case FREEMOVE_JOYPAD: + this.vrFreeMoveMode = FREEMOVE_CONTROLLER; break; } break;