This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a start menu and a modpack launcher
- Loading branch information
1 parent
96cd5c9
commit 53baa50
Showing
15 changed files
with
143 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: Main | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.ArrayList; | ||
import java.util.Scanner; | ||
|
||
public class LaunchFrame extends JFrame implements ActionListener { | ||
ArrayList<JButton> buttons = new ArrayList<>(); | ||
int startingX = 0; | ||
int startingY = 0; | ||
File path; | ||
public LaunchFrame() { | ||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); | ||
int width = 800, height = 500; | ||
double screenHeight = dimension.getHeight(); | ||
double screenWidth = dimension.getWidth(); | ||
this.setLocation((int)(screenWidth / 2) - (width / 2), (int)(screenHeight / 2) - (height / 2)); | ||
// read from a txt file and save to a string then for every line in the string, create a button with the line as the text and add it to the arraylist of buttons and add the actionlistener to the button and add it to the frame | ||
try { | ||
path = new File(System.getProperty("user.home") + "/.linuxcurse/"); | ||
File myObj = new File(path.getAbsolutePath() + "/modpacks.txt"); | ||
Scanner myReader = new Scanner(myObj); | ||
while (myReader.hasNextLine()) { | ||
String data = myReader.nextLine(); | ||
JButton button = new JButton(data); | ||
button.setBounds(0, 0, width / 3, 40); | ||
button.setLocation(startingX, startingY); | ||
button.addActionListener(this); | ||
buttons.add(button); | ||
|
||
add(button); | ||
startingX += button.getWidth(); | ||
if(startingX + button.getWidth() > width) { | ||
startingX = 0; | ||
startingY += button.getHeight(); | ||
} | ||
} | ||
myReader.close(); | ||
} catch (FileNotFoundException e) { | ||
System.out.println("An error occurred."); | ||
e.printStackTrace(); | ||
} | ||
this.setSize(width,height); | ||
this.setLayout(null); | ||
this.setTitle("Select the modpack from the list"); | ||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
this.setVisible(true); | ||
this.getContentPane().setBackground(Color.GRAY); | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
for(JButton button : buttons) { | ||
if(e.getSource() == button) { | ||
String modpackName = button.getText(); | ||
String folderName = modpackName.replaceAll("[^A-Za-z0-9\",]|,(?!(([^\"]*\"){2})*[^\"]*$)", "").replace("\"", "").replace(",", "").replace(" ", ""); | ||
new ExecuteCommand("minecraft-launcher --workDir " + path.getAbsolutePath() + "/" + folderName + "/" + ".minecraft/"); | ||
System.exit(0); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: Main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import java.net.URISyntaxException; | ||
|
||
public class Main { | ||
public static SearchFrame search; | ||
static StartingFrame starting; | ||
public static void main(String[] args) throws URISyntaxException { | ||
search = new SearchFrame(); | ||
//search = new SearchFrame(); | ||
starting = new StartingFrame(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import javax.swing.*; | ||
import javax.swing.border.Border; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
public class StartingFrame extends JFrame implements ActionListener { | ||
public static SearchFrame search; | ||
JButton newModpack = new JButton("Install new modpack"); | ||
public static SearchFrame searchFrame; | ||
JButton launchModpack = new JButton("Launch a modpack"); | ||
public StartingFrame() { | ||
Border border = BorderFactory.createLineBorder(Color.RED, 3); | ||
int width = 800, height = 500; | ||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); | ||
|
||
double screenHeight = dimension.getHeight(); | ||
double screenWidth = dimension.getWidth(); | ||
this.setLocation((int)(screenWidth / 2) - (width / 2), (int)(screenHeight / 2) - (height / 2)); | ||
newModpack.setBounds(0,0, 180, 40); | ||
newModpack.setLocation((width / 2) - (newModpack.getWidth() / 2),(height/2) - (newModpack.getHeight()/2) - 40); | ||
newModpack.setFocusable(false); | ||
newModpack.addActionListener(this); | ||
launchModpack.setBounds(0,0, 180, 40); | ||
launchModpack.setLocation((width / 2) - (launchModpack.getWidth() / 2),(height/2) - (launchModpack.getHeight()/2) + 40); | ||
launchModpack.setFocusable(false); | ||
launchModpack.addActionListener(this); | ||
this.setSize(width,height); | ||
this.setLayout(null); | ||
this.setTitle("LinuxCurse"); | ||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
this.add(newModpack); | ||
this.add(launchModpack); | ||
|
||
this.setVisible(true); | ||
this.getContentPane().setBackground(Color.GRAY); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
if(e.getSource() == newModpack) { | ||
this.dispose(); | ||
new SearchFrame(); | ||
} | ||
if(e.getSource() == launchModpack) { | ||
this.dispose(); | ||
new LaunchFrame(); | ||
} | ||
} | ||
} |