Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
potzplitz committed Mar 21, 2023
1 parent f2188a8 commit b6d3335
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 35 deletions.
40 changes: 25 additions & 15 deletions src/api/MapInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
Expand Down Expand Up @@ -49,28 +48,17 @@ public class MapInfo {

private String id;

private static String arrin;


@SuppressWarnings("unused")
public void BeatmapInfo() throws IllegalStateException, IOException{

MapInfo info = new MapInfo();

// API-Key
String apikey = "3c29279d7f702fdd1094900daa128d898812b8d8";
JSONArray a = new JSONArray(arrin);



// API-Reader
id = info.getMapID();
String url = "https://osu.ppy.sh/api/get_beatmaps?s=" + id + "&k=" + apikey;
URL apireq = new URL(url);
URLConnection con = apireq.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine = in.readLine();
String arrin = inputLine + "";
JSONArray a = new JSONArray(arrin);


// JSON-Reader
int i = 0;

Expand Down Expand Up @@ -101,6 +89,28 @@ public void BeatmapInfo() throws IllegalStateException, IOException{



}


public void getApi() throws IOException {
MapInfo info = new MapInfo();

// API-Key
String apikey = "3c29279d7f702fdd1094900daa128d898812b8d8";


// API-Reader
id = info.getMapID();
String url = "https://osu.ppy.sh/api/get_beatmaps?s=" + id + "&k=" + apikey;
URL apireq = new URL(url);
URLConnection con = apireq.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine = in.readLine();
arrin = inputLine + "";

System.out.println("api request with link: " + url);


}

public String getAR() throws IllegalStateException, IOException {
Expand Down
107 changes: 100 additions & 7 deletions src/main/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

import java.awt.Button;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import javax.imageio.ImageIO;
Expand All @@ -21,6 +26,7 @@
import api.UserMaps;
import arrays.Genres;
import arrays.Languages;
import javafx.application.Application;
import randomizer.IDRandomizer;
import web.MapBanner;
import web.MapperPFP;
Expand Down Expand Up @@ -115,9 +121,15 @@ public static void main(String[] args) throws IOException {
JLabel ratinglabeling = new JLabel("1 10");
ratinglabeling.setBounds(10, 140, 200, 30);

Button browser = new Button("browser");
browser.setBounds(343, 197, 50, 15);

Button direct = new Button("direct");
direct.setBounds(343, 212, 50, 15);

MapInfo run = new MapInfo();

Desktop desktop = Desktop.getDesktop();

Button randomize = new Button("randomize");
randomize.setBounds(187, 240, 100, 30);
Expand All @@ -126,21 +138,32 @@ public static void main(String[] args) throws IOException {
@Override
public void actionPerformed(ActionEvent e) {

randomize.setLabel("loading...");

IDRandomizer randomize = new IDRandomizer();
IDRandomizer randomizer = new IDRandomizer();

randomizer.Random();

randomize.Random();

MapInfo run = new MapInfo();
UserInfo user = new UserInfo();
UserMaps maps = new UserMaps();





try {run.getApi();} catch (IOException e5) {e5.printStackTrace(); }
randomize.setLabel("loading...");
randomize.setLabel("error");
try {user.PlayerInfo();} catch (IOException e5) {e5.printStackTrace();}
try {run.BeatmapInfo();} catch (IllegalStateException | IOException e4) {e4.printStackTrace();}
// try {maps.getUserMaps();} catch (IllegalStateException | IOException e4) {e4.printStackTrace();} catch (InterruptedException e1) {e1.printStackTrace();}



randomize.setLabel("loading...");
randomize.setLabel("error");
try {run.BeatmapInfo();} catch (IllegalStateException | IOException e4) {e4.printStackTrace();}
randomize.setLabel("loading...");

String mapid = run.getMapID();

MapBanner banner = new MapBanner();
Expand All @@ -155,16 +178,23 @@ public void actionPerformed(ActionEvent e) {
MapperPFP pfp = new MapperPFP();
try {pfp.addPFP();} catch (IOException e2) {e2.printStackTrace();}



Genres genres = new Genres();
genres.addList();

Languages languages = new Languages();
languages.addLanguages();

mapperpfp.setIcon(pfp.getMapperPFP());






try { genrelabel.setText("Genre: " + genres.genres.get(Integer.parseInt(run.getGenre()))); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }

try { genrelabel.setText("Genre: " + genres.genres.get(Integer.parseInt(run.getGenre()))); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }
try { languagelabel.setText("Language: " + languages.languages.get(Integer.parseInt(run.getLanguage()))); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }
try { playlabel.setText("Plays: " + run.getPlays()); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }
try { likelabel.setText("Likes: " + run.getLikes()); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }
Expand All @@ -174,17 +204,76 @@ public void actionPerformed(ActionEvent e) {
try { ranklabel.setText("#" + user.getPlayerRank()); } catch (IllegalStateException | IOException e1) {e1.printStackTrace();}






randomize.setLabel("Randomize");

gui.repaint();
mapname.repaint();



gui.repaint();



}


});

browser.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {

try {
Desktop.getDesktop().browse(new URI("https://osu.ppy.sh/beatmapsets/" + run.getMapID()));
} catch (IOException | URISyntaxException e1) {

e1.printStackTrace();
}
}

});

direct.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {

try {
Desktop.getDesktop().browse(new URI("osu://b/4045797/" + run.getMapID()));
} catch (IOException | URISyntaxException e1) {

e1.printStackTrace();
}
}

});


mapperpfp.addMouseListener(new MouseListener() {

@Override
public void mouseClicked(MouseEvent e) {
try {desktop.browse(URI.create("https://osu.ppy.sh/users/" + run.getMapperID()));} catch (IOException e1) {e1.printStackTrace();}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});


mapcard.setBounds(40, 50, 400, 140);
Expand All @@ -203,10 +292,14 @@ public void actionPerformed(ActionEvent e) {
rating.setVisible(true);
ratinglabel.setVisible(true);
ratinglabeling.setVisible(true);
browser.setVisible(true);
direct.setVisible(true);

gui.add(output);
gui.add(mapcard);
gui.add(mapname);
gui.add(browser);
gui.add(direct);
info.add(title);
info.add(genrelabel);
info.add(languagelabel);
Expand Down
15 changes: 2 additions & 13 deletions src/randomizer/IDRandomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,18 @@ public class IDRandomizer {

private static String randNumber;
public void Random() {

@SuppressWarnings("unused")



Random rand = new Random();

int intnumb = rand.nextInt(999999) + 100000;

randNumber = 1 + "" + Integer.toString(intnumb);

System.out.println(randNumber);


}






public String getRandom() {

System.out.println(randNumber);

return randNumber;

}
Expand Down

0 comments on commit b6d3335

Please sign in to comment.