fix: Windows support
eww...
This commit is contained in:
@@ -9,6 +9,10 @@ Können Sie meinen Highscore schlagen?
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Im Falle einer IllegalArgumentException
|
||||||
|
Eclipse ist unfähig Java-Konventionen zu befolgen und fügt den resources-Ordner nicht automatisch zum classpath hinzu.
|
||||||
|
Um das zu beheben, gehen Sie in die Projekteinstellungen -> Java Build Path -> Source und fügen Sie den resources-Ordner manuell hinzu.
|
||||||
|
|
||||||
## Rechtliche Hinweise
|
## Rechtliche Hinweise
|
||||||
»Tetris« ist eine eingetragene Marke von The Tetris Company, Inc.
|
»Tetris« ist eine eingetragene Marke von The Tetris Company, Inc.
|
||||||
Die Verwendung des Namens »Tetris« und des Spielkonzepts erfolgen lediglich zu Bildungszwecken.
|
Die Verwendung des Namens »Tetris« und des Spielkonzepts erfolgen lediglich zu Bildungszwecken.
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
package eu.midnightdust.yaytris.ui;
|
package eu.midnightdust.yaytris.ui;
|
||||||
|
|
||||||
|
import eu.midnightdust.yaytris.util.CatppuccinColor;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
import static eu.midnightdust.yaytris.ui.TetrisUI.scale;
|
import static eu.midnightdust.yaytris.ui.TetrisUI.scale;
|
||||||
import static eu.midnightdust.yaytris.ui.TetrisUI.setFontScale;
|
|
||||||
|
|
||||||
public class AbstractMenu extends JPanel {
|
public class AbstractMenu extends JPanel {
|
||||||
@Override
|
@Override
|
||||||
public Component add(Component comp) {
|
public Component add(Component comp) {
|
||||||
comp.setBounds(scale(60), scale(20+getSpacing()*this.getComponentCount()), scale(100), scale(20));
|
comp.setBounds(scale(60), scale(20+getSpacing()*this.getComponentCount()), scale(100), scale(20));
|
||||||
if (comp instanceof JComponent) setFontScale((JComponent) comp);
|
if (comp instanceof JLabel) {
|
||||||
|
comp.setForeground(CatppuccinColor.TEXT.getColor());
|
||||||
|
}
|
||||||
|
if (comp instanceof JComponent) {
|
||||||
|
((JComponent) comp).setOpaque(false);
|
||||||
|
}
|
||||||
return super.add(comp);
|
return super.add(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ public class HighScoreMenu extends JPanel {
|
|||||||
highscores.sort((s1, s2) -> Integer.compare(Integer.parseInt(s2.split("–")[0].replace(" ", "")), Integer.parseInt(s1.split("–")[0].replace(" ", ""))));
|
highscores.sort((s1, s2) -> Integer.compare(Integer.parseInt(s2.split("–")[0].replace(" ", "")), Integer.parseInt(s1.split("–")[0].replace(" ", ""))));
|
||||||
JList<String> highscoreList = new JList<>(highscores.toArray(String[]::new));
|
JList<String> highscoreList = new JList<>(highscores.toArray(String[]::new));
|
||||||
highscoreList.setBackground(CatppuccinColor.BASE.getColor());
|
highscoreList.setBackground(CatppuccinColor.BASE.getColor());
|
||||||
|
highscoreList.setForeground(CatppuccinColor.TEXT.getColor());
|
||||||
highscoreList.setSelectionForeground(CatppuccinColor.CRUST.getColor());
|
highscoreList.setSelectionForeground(CatppuccinColor.CRUST.getColor());
|
||||||
JScrollPane highscoreScrollPane = new JScrollPane(highscoreList);
|
JScrollPane highscoreScrollPane = new JScrollPane(highscoreList);
|
||||||
highscoreScrollPane.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), 3, true));
|
highscoreScrollPane.setBorder(new LineBorder(CatppuccinColor.SURFACE0.getColor(), 3, true));
|
||||||
this.add(highscoreScrollPane);
|
this.add(highscoreScrollPane);
|
||||||
highscoreScrollPane.setBounds(scale(60), scale(43), scale(100), scale(80));
|
highscoreScrollPane.setBounds(scale(60), scale(43), scale(100), scale(80));
|
||||||
|
highscoreList.setBounds(scale(60), scale(43), scale(100), scale(80));
|
||||||
|
|
||||||
JButton backButton = new JButton(t("ui.back"));
|
JButton backButton = new JButton(t("ui.back"));
|
||||||
backButton.addActionListener(ui::openMainMenu);
|
backButton.addActionListener(ui::openMainMenu);
|
||||||
@@ -45,6 +47,10 @@ public class HighScoreMenu extends JPanel {
|
|||||||
public Component add(Component comp) {
|
public Component add(Component comp) {
|
||||||
if (comp instanceof JLabel) {
|
if (comp instanceof JLabel) {
|
||||||
comp.setBounds(scale(60), scale(30), scale(100), scale(7));
|
comp.setBounds(scale(60), scale(30), scale(100), scale(7));
|
||||||
|
comp.setForeground(CatppuccinColor.TEXT.getColor());
|
||||||
|
}
|
||||||
|
if (comp instanceof JComponent) {
|
||||||
|
((JComponent) comp).setOpaque(false);
|
||||||
}
|
}
|
||||||
return super.add(comp);
|
return super.add(comp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package eu.midnightdust.yaytris.ui;
|
|||||||
|
|
||||||
import eu.midnightdust.yaytris.Settings;
|
import eu.midnightdust.yaytris.Settings;
|
||||||
import eu.midnightdust.yaytris.Translation;
|
import eu.midnightdust.yaytris.Translation;
|
||||||
|
import eu.midnightdust.yaytris.util.CatppuccinColor;
|
||||||
import eu.midnightdust.yaytris.util.Difficulty;
|
import eu.midnightdust.yaytris.util.Difficulty;
|
||||||
import eu.midnightdust.yaytris.util.Language;
|
import eu.midnightdust.yaytris.util.Language;
|
||||||
|
|
||||||
@@ -10,7 +11,6 @@ import java.awt.*;
|
|||||||
|
|
||||||
import static eu.midnightdust.yaytris.Translation.t;
|
import static eu.midnightdust.yaytris.Translation.t;
|
||||||
import static eu.midnightdust.yaytris.ui.TetrisUI.scale;
|
import static eu.midnightdust.yaytris.ui.TetrisUI.scale;
|
||||||
import static eu.midnightdust.yaytris.ui.TetrisUI.setFontScale;
|
|
||||||
|
|
||||||
public class SettingsMenu extends JPanel {
|
public class SettingsMenu extends JPanel {
|
||||||
final TetrisUI ui;
|
final TetrisUI ui;
|
||||||
@@ -87,9 +87,10 @@ public class SettingsMenu extends JPanel {
|
|||||||
comp.setBounds(scale(60), scale(20+17*this.getComponentCount()-labelAmount*10), scale(100), scale(20));
|
comp.setBounds(scale(60), scale(20+17*this.getComponentCount()-labelAmount*10), scale(100), scale(20));
|
||||||
if (comp instanceof JLabel) {
|
if (comp instanceof JLabel) {
|
||||||
comp.setBounds(scale(60), scale(20+17*(this.getComponentCount())-labelAmount*10), scale(100), scale(7));
|
comp.setBounds(scale(60), scale(20+17*(this.getComponentCount())-labelAmount*10), scale(100), scale(7));
|
||||||
|
comp.setForeground(CatppuccinColor.TEXT.getColor());
|
||||||
labelAmount++;
|
labelAmount++;
|
||||||
}
|
}
|
||||||
if (comp instanceof JComponent) setFontScale((JComponent) comp);
|
if (comp instanceof JComponent) ((JComponent) comp).setOpaque(false);
|
||||||
return super.add(comp);
|
return super.add(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
public TetrisUI() {
|
public TetrisUI() {
|
||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
this.setTitle("Tetris");
|
this.setTitle("Tetris");
|
||||||
this.setSize((int) (400 * guiScale), (int) (300 * guiScale));
|
this.setSize((int) (400 * guiScale), (int) (320 * guiScale));
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.getContentPane().setBackground(CatppuccinColor.MANTLE.getColor());
|
this.getContentPane().setBackground(CatppuccinColor.MANTLE.getColor());
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
@@ -62,13 +62,10 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
* Resize all elements to match the current GUI scale.
|
* Resize all elements to match the current GUI scale.
|
||||||
*/
|
*/
|
||||||
private void rescale() {
|
private void rescale() {
|
||||||
this.setSize((int) (400 * guiScale), (int) (300 * guiScale));
|
this.setSize((int) (400 * guiScale), (int) (320 * guiScale));
|
||||||
titleLabel.setBounds(scale(225), scale(7), scale(110), scale(30));
|
titleLabel.setBounds(scale(225), scale(7), scale(110), scale(30));
|
||||||
titleLabel.setIcon(new ImageIcon(new ImageIcon(titleImage).getImage().getScaledInstance(scale(110), scale(30), Image.SCALE_DEFAULT)));
|
titleLabel.setIcon(new ImageIcon(new ImageIcon(titleImage).getImage().getScaledInstance(scale(110), scale(30), Image.SCALE_DEFAULT)));
|
||||||
gamePanel.setBounds(scale(10), scale(10), scale(150), scale(282));
|
gamePanel.setBounds(scale(10), scale(10), scale(150), scale(282));
|
||||||
for (Component comp : this.getComponents()){
|
|
||||||
if (comp instanceof JComponent) setFontScale((JComponent) comp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,9 +76,6 @@ public class TetrisUI extends JFrame implements KeyListener {
|
|||||||
public static int scale(int bound) {
|
public static int scale(int bound) {
|
||||||
return (int) (bound * guiScale);
|
return (int) (bound * guiScale);
|
||||||
}
|
}
|
||||||
public static void setFontScale(JComponent label) {
|
|
||||||
//if (label.getFont() != null) label.setFont(label.getFont().deriveFont((float) label.getFont().getSize() * guiScale));
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameCanvas getGamePanel() {
|
public GameCanvas getGamePanel() {
|
||||||
return gamePanel;
|
return gamePanel;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.awt.*;
|
|||||||
* Color scheme based on the <a href="https://github.com/catppuccin/catppuccin">Catppuccin Mocha</a> color palette
|
* Color scheme based on the <a href="https://github.com/catppuccin/catppuccin">Catppuccin Mocha</a> color palette
|
||||||
*/
|
*/
|
||||||
public enum CatppuccinColor {
|
public enum CatppuccinColor {
|
||||||
CRUST(0x11111b), MANTLE(0x181825), BASE(0x1e1e2e), SURFACE0(0x313244);
|
TEXT(0xcdd6f4), CRUST(0x11111b), MANTLE(0x181825), BASE(0x1e1e2e), SURFACE0(0x313244);
|
||||||
|
|
||||||
final Color color;
|
final Color color;
|
||||||
CatppuccinColor(int rgb) {
|
CatppuccinColor(int rgb) {
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public class MusicThread extends Thread {
|
|||||||
sourceDataLine.close();
|
sourceDataLine.close();
|
||||||
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
|
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
// Happens when no audio device is connected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ public class SoundUtil {
|
|||||||
setVolume(audioClip, Settings.soundVolume);
|
setVolume(audioClip, Settings.soundVolume);
|
||||||
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
|
} catch (LineUnavailableException | IOException | UnsupportedAudioFileException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
// Happens when no audio device is connected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
// Volume of theme music (0-100)
|
// Volume of theme music (0-100)
|
||||||
"musicVolume": 30,
|
"musicVolume": 100,
|
||||||
// Volume of sound effects (0-100)
|
// Volume of sound effects (0-100)
|
||||||
"soundVolume": 100,
|
"soundVolume": 100,
|
||||||
// Amount the user interface should be scaled
|
// Amount the user interface should be scaled
|
||||||
"guiScale": 5.7,
|
"guiScale": 2.00,
|
||||||
// Whether speed should scale with level (true/false)
|
// Whether speed should scale with level (true/false)
|
||||||
"shouldScaleSpeed": true,
|
"shouldScaleSpeed": true,
|
||||||
// One of [Noob, Easy, Normal, Hard, Extreme, WTF]
|
// One of [Noob, Easy, Normal, Hard, Extreme, WTF]
|
||||||
|
|||||||
Reference in New Issue
Block a user