-
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.
ui by Asthowen
- Loading branch information
Showing
9 changed files
with
247 additions
and
26 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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 @@ | ||
package asthowen.chaika.ui; | ||
|
||
import asthowen.chaika.ui.panels.ConfigPanel; | ||
import asthowen.chaika.ui.panels.MainPanel; | ||
import isoss.chaika.rpc.ChaikaPresence; | ||
|
||
import javax.imageio.ImageIO; | ||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class Main extends JFrame { | ||
|
||
public static ChaikaPresence presence; | ||
|
||
public static Main main; | ||
public static MainPanel mainPanel; | ||
|
||
public ConfigPanel configPanel; | ||
|
||
public Main(){ | ||
System.out.println("ROAD TO ADD CHAIKA'S EMOJI ON GITHUB !"); | ||
|
||
presence = new ChaikaPresence(); | ||
presence.init(); | ||
|
||
setTitle("Chaika Discord RPC"); | ||
setSize(1280, 720); | ||
setResizable(false); | ||
setLocationRelativeTo(null); | ||
|
||
setContentPane(mainPanel = new MainPanel()); | ||
|
||
setDefaultCloseOperation(EXIT_ON_CLOSE); | ||
|
||
try { | ||
setIconImage(ImageIO.read(Main.class.getResourceAsStream("/chaika.png"))); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
Color backgroundColor = Color.decode("#24343C"); | ||
getContentPane().setBackground(backgroundColor); | ||
|
||
setVisible(true); | ||
|
||
try { | ||
TimeUnit.SECONDS.sleep(2); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
setContentPane(configPanel = new ConfigPanel()); | ||
getContentPane().setBackground(backgroundColor); | ||
|
||
repaint(); | ||
revalidate(); | ||
|
||
} | ||
|
||
public static void main(String[] args){ | ||
main = new 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package asthowen.chaika.ui.panels; | ||
|
||
import asthowen.chaika.ui.Main; | ||
import asthowen.chaika.ui.utils.Utils; | ||
import isoss.chaika.rpc.ConfigWrapper; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionListener; | ||
import java.nio.file.Paths; | ||
|
||
public class ConfigPanel extends JPanel { | ||
|
||
private static final JTextField applicationIDField = new JTextField(); | ||
private static final JLabel applicationIDLabel = new JLabel("Application ID :"); | ||
|
||
private static final JTextField applicationDetailsField = new JTextField(); | ||
private static final JLabel applicationDetailsLabel = new JLabel("Détails :"); | ||
|
||
private static final JTextField applicationLargeImageKeyField = new JTextField(); | ||
private static final JLabel applicationLargeImageKeyLabel = new JLabel("Large Image Key :"); | ||
|
||
private static final JTextField applicationLargeImageTextField = new JTextField(); | ||
private static final JLabel applicationLargeImageTextLabel = new JLabel("Large Image Text :"); | ||
|
||
private static final JTextField applicationSmallImageKeyField = new JTextField(); | ||
private static final JLabel applicationSmallImageKeyLabel = new JLabel("Small Image Key :"); | ||
|
||
private static final JTextField applicationSmallImageTextField = new JTextField(); | ||
private static final JLabel applicationSmallImageTextLabel = new JLabel("Small Image Text :"); | ||
|
||
private static final JButton enterButton = new JButton("Save"); | ||
|
||
public ConfigPanel(){ | ||
setLayout(null); | ||
|
||
String applicationId = ConfigWrapper.get("applicationId"); | ||
String details = ConfigWrapper.get("details"); | ||
String largeImageKey = ConfigWrapper.get("largeImageKey"); | ||
String largeImageText = ConfigWrapper.get("largeImageText"); | ||
String smallImageKey = ConfigWrapper.get("smallImageKey"); | ||
String smallImageText = ConfigWrapper.get("smallImageText"); | ||
|
||
Utils.createFieldAndLabel(applicationIDField, applicationId, 100, applicationIDLabel, 65); | ||
Utils.createFieldAndLabel(applicationDetailsField, details, 180, applicationDetailsLabel, 145); | ||
Utils.createFieldAndLabel(applicationLargeImageKeyField, largeImageKey, 260, applicationLargeImageKeyLabel, 225); | ||
Utils.createFieldAndLabel(applicationLargeImageTextField, largeImageText, 340, applicationLargeImageTextLabel, 305); | ||
Utils.createFieldAndLabel(applicationSmallImageKeyField, smallImageKey, 420, applicationSmallImageKeyLabel, 385); | ||
Utils.createFieldAndLabel(applicationSmallImageTextField, smallImageText, 500, applicationSmallImageTextLabel, 465); | ||
|
||
applicationIDField.setText(applicationId); | ||
applicationDetailsField.setText(details); | ||
applicationLargeImageKeyField.setText(largeImageKey); | ||
applicationLargeImageTextField.setText(largeImageText); | ||
applicationSmallImageKeyField.setText(smallImageKey); | ||
applicationSmallImageTextField.setText(smallImageText); | ||
|
||
enterButton.setBounds(1280 / 2 - 275 /2, 600, 275, 40); | ||
enterButton.setFont(new Font("Verdana", Font.PLAIN, 20)); | ||
enterButton.setForeground(Utils.colorForeground); | ||
enterButton.setBackground(Utils.colorBackground); | ||
|
||
ActionListener actionListener = event -> { | ||
ConfigWrapper.set("applicationId", applicationIDField.getText()); | ||
ConfigWrapper.set("details", applicationDetailsField.getText()); | ||
ConfigWrapper.set("largeImageKey", applicationLargeImageKeyField.getText()); | ||
ConfigWrapper.set("largeImageText", applicationLargeImageTextField.getText()); | ||
ConfigWrapper.set("smallImageKey", applicationSmallImageKeyField.getText()); | ||
ConfigWrapper.set("smallImageText", applicationSmallImageTextField.getText()); | ||
|
||
Main.presence.updatePresence(); | ||
|
||
ConfigWrapper.write(Paths.get("config.json")); | ||
|
||
System.out.println("Config saved !"); | ||
}; | ||
|
||
enterButton.addActionListener(actionListener); | ||
|
||
add(applicationIDField); | ||
add(applicationIDLabel); | ||
add(applicationDetailsField); | ||
add(applicationDetailsLabel); | ||
add(applicationLargeImageKeyField); | ||
add(applicationLargeImageKeyLabel); | ||
add(applicationLargeImageKeyField); | ||
add(applicationLargeImageTextField); | ||
add(applicationLargeImageTextLabel); | ||
add(applicationSmallImageKeyField); | ||
add(applicationSmallImageKeyField); | ||
add(applicationSmallImageKeyLabel); | ||
add(applicationSmallImageTextField); | ||
add(applicationSmallImageTextLabel); | ||
add(enterButton); | ||
|
||
} | ||
|
||
} |
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,23 @@ | ||
package asthowen.chaika.ui.panels; | ||
|
||
import asthowen.chaika.ui.utils.Utils; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class MainPanel extends JPanel { | ||
|
||
public MainPanel(){ | ||
setLayout(new GridBagLayout()); | ||
|
||
//Add Title | ||
JLabel textLabel = new JLabel("Bienvenue sur Chaika Discord RPC !"); | ||
textLabel.setFont(new Font("Verdana", 0, 50)); | ||
textLabel.setForeground(Utils.colorForeground); | ||
textLabel.setBackground(Utils.colorBackground); | ||
textLabel.setSize(550, 150); | ||
add(textLabel); | ||
|
||
} | ||
|
||
} |
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,26 @@ | ||
package asthowen.chaika.ui.utils; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class Utils { | ||
public static Color colorBackground = Color.decode("#24343C"); | ||
public static Color colorForeground = Color.decode("#99AAB5"); | ||
|
||
public static void createFieldAndLabel(JTextField textField, String text, int y, JLabel textLabel, int y2){ | ||
//Create TextField | ||
textField.setBounds(1280 / 2 - 550 /2, y, 550, 40); | ||
textField.setFont(new Font("Verdana", 0, 30)); | ||
textField.setForeground(colorForeground); | ||
textField.setBackground(colorBackground); | ||
textField.setText(text); | ||
|
||
//Create JLabel | ||
textLabel.setBounds(1280 / 2 - 550 /2, y2, 550, 40); | ||
textLabel.setFont(new Font("Verdana", 0, 20)); | ||
textLabel.setForeground(colorForeground); | ||
textLabel.setBackground(colorBackground); | ||
|
||
} | ||
|
||
} |
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