Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
added show gamemode
  • Loading branch information
potzplitz committed Mar 21, 2023
1 parent b6d3335 commit 0c897ff
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 40 deletions.
68 changes: 34 additions & 34 deletions src/api/MapInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class MapInfo {
private String name;
private String artist;
private String mapperid;
private String mode;


private String id;

Expand Down Expand Up @@ -80,13 +82,19 @@ public void BeatmapInfo() throws IllegalStateException, IOException{
name = a.getJSONObject(i).getString("title");
artist = a.getJSONObject(i).getString("artist");
mapperid = a.getJSONObject(i).getString("creator_id");
mode = a.getJSONObject(i).getString("mode");



int genreint = Integer.parseInt(genre) - 1;
genre = genreint + "";

int langint = Integer.parseInt(language) - 1;
language = langint + "";

int modeint = Integer.parseInt(mode) - 1;
mode = langint + "";



}
Expand All @@ -101,7 +109,7 @@ public void getApi() throws IOException {

// API-Reader
id = info.getMapID();
String url = "https://osu.ppy.sh/api/get_beatmaps?s=" + id + "&k=" + apikey;
String url = "https://osu.ppy.sh/api/get_beatmaps?s=" + id + "&m=" + "0" + "&k=" + apikey;
URL apireq = new URL(url);
URLConnection con = apireq.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
Expand All @@ -114,141 +122,133 @@ public void getApi() throws IOException {
}

public String getAR() throws IllegalStateException, IOException {

BeatmapInfo();


return ar;

}

public String getCS() throws IllegalStateException, IOException {

BeatmapInfo();

return cs;

}

public String getSR() throws IllegalStateException, IOException {

BeatmapInfo();


return sr;

}

public String getMapper() throws IllegalStateException, IOException {

BeatmapInfo();


return mapper;

}

public String getDuration() throws IllegalStateException, IOException {

BeatmapInfo();


return length;

}

public String getBPM() throws IllegalStateException, IOException {

BeatmapInfo();


return bpm;

}

public String getOD() throws IllegalStateException, IOException {

BeatmapInfo();

return od;

}

public String getDiffCount() throws IllegalStateException, IOException {

BeatmapInfo();


return diffs;

}

public String getPlays() throws IllegalStateException, IOException {

BeatmapInfo();


return plays;

}

public String getLikes() throws IllegalStateException, IOException {

BeatmapInfo();


return likes;

}

public String getGenre() throws IllegalStateException, IOException {

BeatmapInfo();


return genre;

}

public String getLanguage() throws IllegalStateException, IOException {

BeatmapInfo();


return language;

}

public String getRating() throws IllegalStateException, IOException {

BeatmapInfo();


return rating;

}

public String getUploadDate() throws IllegalStateException, IOException {

BeatmapInfo();


return uploaddate;

}

public String getName() throws IllegalStateException, IOException {

BeatmapInfo();


return name;

}

public String getArtist() throws IllegalStateException, IOException {

BeatmapInfo();


return artist;

}

public String getMapperID() throws IllegalStateException, IOException {

BeatmapInfo();
public String getMapperID() throws IllegalStateException, IOException {


return mapperid;

}

public String getGameMode() throws IllegalStateException, IOException {


return mode;

}





public String getMapID() {
Expand Down
25 changes: 25 additions & 0 deletions src/arrays/Gamemode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package arrays;

import java.util.ArrayList;

public class Gamemode {

public ArrayList<String> mode = new ArrayList<String>();

public void addList() {

mode.add("Standard");
mode.add("Taiko");
mode.add("Catch");
mode.add("Mania");

}

@SuppressWarnings("rawtypes")
public ArrayList getGameMode() {

return mode;

}

}
31 changes: 25 additions & 6 deletions src/main/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand All @@ -24,6 +25,7 @@
import api.MapInfo;
import api.UserInfo;
import api.UserMaps;
import arrays.Gamemode;
import arrays.Genres;
import arrays.Languages;
import javafx.application.Application;
Expand Down Expand Up @@ -59,6 +61,9 @@ public class Gui {

public String id;



@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) throws IOException {


Expand Down Expand Up @@ -88,14 +93,14 @@ public static void main(String[] args) throws IOException {
info.setBackground(Color.LIGHT_GRAY);

JLabel mapperinfolabel = new JLabel("Mapper Information");
mapperinfolabel.setBounds(230, 1, 200, 30);
mapperinfolabel.setBounds(230, 290, 200, 30);

JLabel title = new JLabel();
title.setBounds(10, 1, 100, 30);
title.setBounds(10, 290, 100, 30);
title.setText("Map Information");

JLabel genrelabel = new JLabel("Genre: ");
genrelabel.setBounds(10, 30, 250, 30);
genrelabel.setBounds(10, 31, 250, 30);

JLabel languagelabel = new JLabel("Language: ");
languagelabel.setBounds(10, 50, 250, 30);
Expand All @@ -121,12 +126,17 @@ public static void main(String[] args) throws IOException {
JLabel ratinglabeling = new JLabel("1 10");
ratinglabeling.setBounds(10, 140, 200, 30);

JLabel gm = new JLabel("Gamemode: ");
gm.setBounds(10, 11, 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();
Expand All @@ -138,6 +148,7 @@ public static void main(String[] args) throws IOException {
@Override
public void actionPerformed(ActionEvent e) {


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

IDRandomizer randomizer = new IDRandomizer();
Expand Down Expand Up @@ -186,6 +197,9 @@ public void actionPerformed(ActionEvent e) {
Languages languages = new Languages();
languages.addLanguages();

Gamemode mode = new Gamemode();
mode.addList();

mapperpfp.setIcon(pfp.getMapperPFP());


Expand All @@ -199,6 +213,8 @@ public void actionPerformed(ActionEvent e) {
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(); }
try { rating.setValue(Math.round(Float.parseFloat(run.getRating()))); } catch (NumberFormatException | IllegalStateException | IOException e1) { e1.printStackTrace(); }
try { gm.setText("Gamemode: " + mode.getGameMode().get(Integer.parseInt(run.getGameMode()))); } catch (NumberFormatException | IllegalStateException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace();}


try { mapperlabel.setText(run.getMapper()); } catch (IllegalStateException | IOException e1) {e1.printStackTrace();}
try { ranklabel.setText("#" + user.getPlayerRank()); } catch (IllegalStateException | IOException e1) {e1.printStackTrace();}
Expand Down Expand Up @@ -293,25 +309,27 @@ public void mouseExited(MouseEvent e) {
ratinglabel.setVisible(true);
ratinglabeling.setVisible(true);
browser.setVisible(true);
direct.setVisible(true);
direct.setVisible(true);
gm.setVisible(true);

gui.add(output);
gui.add(mapcard);
gui.add(mapname);
gui.add(browser);
gui.add(direct);
info.add(title);
gui.add(title);
gui.add(mapperinfolabel);
info.add(genrelabel);
info.add(languagelabel);
info.add(playlabel);
info.add(likelabel);
info.add(mapperpfp);
info.add(mapperinfolabel);
info.add(mapperlabel);
info.add(ranklabel);
info.add(rating);
info.add(ratinglabel);
info.add(ratinglabeling);
info.add(gm);

gui.add(info);

Expand All @@ -320,6 +338,7 @@ public void mouseExited(MouseEvent e) {
randomize.setVisible(true);
gui.add(randomize);
info.repaint();

gui.repaint();

}
Expand Down

0 comments on commit 0c897ff

Please sign in to comment.