use of util.settings.Settings in project Botnak by Gocnak.
the class GUIMain method initComponents.
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - Nick K
menuBar1 = new JMenuBar();
fileMenu = new JMenu();
openBotnakFolderOption = new JMenuItem();
openLogViewerOption = new JMenuItem();
openSoundsOption = new JMenuItem();
exitOption = new JMenuItem();
preferencesMenu = new JMenu();
botReplyMenu = new JMenu();
botReplyAll = new JRadioButtonMenuItem();
botReplyJustYou = new JRadioButtonMenuItem();
botReplyNobody = new JRadioButtonMenuItem();
autoReconnectToggle = new JCheckBoxMenuItem();
alwaysOnTopToggle = new JCheckBoxMenuItem();
settingsOption = new JMenuItem();
toolsMenu = new JMenu();
startRaffleOption = new JMenuItem();
startVoteOption = new JMenuItem();
soundsToggle = new JCheckBoxMenuItem();
soundDelayMenu = new JMenu();
soundDelayOffOption = new JRadioButtonMenuItem();
soundDelay5secOption = new JRadioButtonMenuItem();
soundDelay10secOption = new JRadioButtonMenuItem();
soundDelay20secOption = new JRadioButtonMenuItem();
soundDelayCustomOption = new JRadioButtonMenuItem();
soundDelayCustomOption.setToolTipText("Set a custom sound delay with \"!setsound (time)\" in chat");
soundPermissionMenu = new JMenu();
soundPermEveryoneOption = new JRadioButtonMenuItem();
soundPermSDMBOption = new JRadioButtonMenuItem();
soundPermDMBOption = new JRadioButtonMenuItem();
soundPermModAndBroadOption = new JRadioButtonMenuItem();
soundPermBroadOption = new JRadioButtonMenuItem();
manageTextCommandsOption = new JMenuItem();
runAdMenu = new JMenu();
timeOption30sec = new JMenuItem();
timeOption60sec = new JMenuItem();
timeOption90sec = new JMenuItem();
timeOption120sec = new JMenuItem();
timeOption150sec = new JMenuItem();
timeOption180sec = new JMenuItem();
updateStatusOption = new JMenuItem();
subOnlyToggle = new JCheckBoxMenuItem();
slowModeMenu = new JMenu();
slowModeOffOption = new JRadioButtonMenuItem();
slowMode5secOption = new JRadioButtonMenuItem();
slowMode10secOption = new JRadioButtonMenuItem();
slowMode15secOption = new JRadioButtonMenuItem();
slowMode30secOption = new JRadioButtonMenuItem();
slowModeCustomOption = new JRadioButtonMenuItem();
slowModeCustomOption.setToolTipText("Set a custom slow mode time with \"/slow (time in seconds)\" in chat");
helpMenu = new JMenu();
projectGithubOption = new JMenuItem();
projectWikiOption = new JMenuItem();
projectDetailsOption = new JMenuItem();
channelPane = new DraggableTabbedPane();
allChatsScroll = new JScrollPane();
allChats = new JTextPane();
dankLabel = new JLabel();
scrollPane1 = new JScrollPane();
userChat = new JTextArea();
//======== Botnak ========
{
setMinimumSize(new Dimension(640, 404));
setName("Botnak Control Panel");
setTitle("Botnak | Please go to Preferences->Settings!");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(new ImageIcon(getClass().getResource("/image/icon.png")).getImage());
Container BotnakContentPane = getContentPane();
//======== menuBar1 ========
{
//======== fileMenu ========
{
fileMenu.setText("File");
//---- openBotnakFolderOption ----
openBotnakFolderOption.setText("Open Botnak Folder");
openBotnakFolderOption.addActionListener(e -> openBotnakFolderOptionActionPerformed());
fileMenu.add(openBotnakFolderOption);
//---- openLogViewerOption ----
openLogViewerOption.setText("Open Log Viewer");
openLogViewerOption.addActionListener(e -> openLogViewerOptionActionPerformed());
//TODO
openLogViewerOption.setEnabled(false);
fileMenu.add(openLogViewerOption);
//---- openSoundsOption ----
openSoundsOption.setText("Open Sound Directory");
openSoundsOption.addActionListener(e -> openSoundsOptionActionPerformed());
fileMenu.add(openSoundsOption);
fileMenu.addSeparator();
//---- exitOption ----
exitOption.setText("Save and Exit");
exitOption.addActionListener(e -> exitButtonActionPerformed());
fileMenu.add(exitOption);
}
menuBar1.add(fileMenu);
//======== preferencesMenu ========
{
preferencesMenu.setText("Preferences");
//======== botReplyMenu ========
{
botReplyMenu.setText("Bot Reply");
//---- botReplyAll ----
botReplyAll.setText("Reply to all");
botReplyAll.addActionListener(e -> {
if (bot != null) {
Response r = bot.parseReplyType("2", Settings.accountManager.getUserAccount().getName());
logCurrent(r.getResponseText());
}
});
botReplyMenu.add(botReplyAll);
//---- botReplyJustYou ----
botReplyJustYou.setText("Reply to you");
botReplyJustYou.addActionListener(e -> {
if (bot != null) {
Response r = bot.parseReplyType("1", Settings.accountManager.getUserAccount().getName());
logCurrent(r.getResponseText());
}
});
botReplyMenu.add(botReplyJustYou);
//---- botReplyNobody ----
botReplyNobody.setText("Reply to none");
botReplyNobody.addActionListener(e -> {
if (bot != null) {
Response r = bot.parseReplyType("0", Settings.accountManager.getUserAccount().getName());
logCurrent(r.getResponseText());
}
});
botReplyNobody.setSelected(true);
botReplyMenu.add(botReplyNobody);
}
preferencesMenu.add(botReplyMenu);
//---- autoReconnectToggle ----
autoReconnectToggle.setText("Auto-Reconnect");
autoReconnectToggle.setSelected(true);
autoReconnectToggle.addItemListener(this::autoReconnectToggleItemStateChanged);
preferencesMenu.add(autoReconnectToggle);
//---- alwaysOnTopToggle ----
alwaysOnTopToggle.setText("Always On Top");
alwaysOnTopToggle.setSelected(false);
alwaysOnTopToggle.addItemListener(this::alwaysOnTopToggleItemStateChanged);
preferencesMenu.add(alwaysOnTopToggle);
preferencesMenu.addSeparator();
//---- settingsOption ----
settingsOption.setText("Settings...");
settingsOption.addActionListener(e -> settingsOptionActionPerformed());
preferencesMenu.add(settingsOption);
}
menuBar1.add(preferencesMenu);
//======== toolsMenu ========
{
toolsMenu.setText("Tools");
//---- startRaffleOption ----
startRaffleOption.setText("Create Raffle...");
//TODO
startRaffleOption.setEnabled(false);
startRaffleOption.addActionListener(e -> startRaffleOptionActionPerformed());
toolsMenu.add(startRaffleOption);
//---- startVoteOption ----
startVoteOption.setText("Create Vote...");
//TODO
startVoteOption.setEnabled(false);
startVoteOption.addActionListener(e -> startVoteOptionActionPerformed());
toolsMenu.add(startVoteOption);
//---- soundsToggle ----
soundsToggle.setText("Enable Sounds");
soundsToggle.setSelected(true);
soundsToggle.addActionListener(e -> soundsToggleItemStateChanged());
toolsMenu.add(soundsToggle);
//======== soundDelayMenu ========
{
soundDelayMenu.setText("Sound Delay");
//---- soundDelayOffOption ----
soundDelayOffOption.setText("None (Off)");
soundDelayOffOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundDelay("0");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundDelayMenu.add(soundDelayOffOption);
//---- soundDelay5secOption ----
soundDelay5secOption.setText("5 seconds");
soundDelay5secOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundDelay("5");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundDelayMenu.add(soundDelay5secOption);
//---- soundDelay10secOption ----
soundDelay10secOption.setText("10 seconds");
soundDelay10secOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundDelay("10");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundDelay10secOption.setSelected(true);
soundDelayMenu.add(soundDelay10secOption);
//---- soundDelay20secOption ----
soundDelay20secOption.setText("20 seconds");
soundDelay20secOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundDelay("20");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundDelayMenu.add(soundDelay20secOption);
//---- soundDelayCustomOption ----
soundDelayCustomOption.setText("Custom (Use chat)");
soundDelayCustomOption.setEnabled(false);
soundDelayMenu.add(soundDelayCustomOption);
}
toolsMenu.add(soundDelayMenu);
//======== soundPermissionMenu ========
{
soundPermissionMenu.setText("Sound Permission");
//---- soundPermEveryoneOption ----
soundPermEveryoneOption.setText("Everyone");
soundPermEveryoneOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundPermission("0");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundPermissionMenu.add(soundPermEveryoneOption);
//---- soundPermSDMBOption ----
soundPermSDMBOption.setText("Subs, Donors, Mods, Broadcaster");
soundPermSDMBOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundPermission("1");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundPermSDMBOption.setSelected(true);
soundPermissionMenu.add(soundPermSDMBOption);
//---- soundPermDMBOption ----
soundPermDMBOption.setText("Donors, Mods, Broadcaster");
soundPermDMBOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundPermission("2");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundPermissionMenu.add(soundPermDMBOption);
//---- soundPermModAndBroadOption ----
soundPermModAndBroadOption.setText("Mods and Broadcaster Only");
soundPermModAndBroadOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundPermission("3");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundPermissionMenu.add(soundPermModAndBroadOption);
//---- soundPermBroadOption ----
soundPermBroadOption.setText("Broadcaster Only");
soundPermBroadOption.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = SoundEngine.getEngine().setSoundPermission("4");
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
}
});
soundPermissionMenu.add(soundPermBroadOption);
}
toolsMenu.add(soundPermissionMenu);
//---- manageTextCommandsOption ----
manageTextCommandsOption.setText("Manage Text Commands...");
//TODO
manageTextCommandsOption.setEnabled(false);
manageTextCommandsOption.addActionListener(e -> manageTextCommandsOptionActionPerformed());
toolsMenu.add(manageTextCommandsOption);
toolsMenu.addSeparator();
//======== runAdMenu ========
{
runAdMenu.setText("Run Ad");
//---- timeOption30sec ----
timeOption30sec.setText("30 sec");
timeOption30sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "30", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(30000);
logCurrent("The 30-second advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption30sec);
//---- timeOption60sec ----
timeOption60sec.setText("1 min");
timeOption60sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "1m", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(60000);
logCurrent("The 1-minute advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption60sec);
//---- timeOption90sec ----
timeOption90sec.setText("1 min 30 sec");
timeOption90sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "1m30s", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(90000);
logCurrent("The 1-minute 30-second advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption90sec);
//---- timeOption120sec ----
timeOption120sec.setText("2 min");
timeOption120sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "2m", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(120000);
logCurrent("The 2 minute advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption120sec);
//---- timeOption150sec ----
timeOption150sec.setText("2 min 30 sec");
timeOption150sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "2m30s", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(150000);
logCurrent("The 2 minute 30 second advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption150sec);
//---- timeOption180sec ----
timeOption180sec.setText("3 min");
timeOption180sec.addActionListener(e -> {
if (bot != null && bot.getBot() != null) {
Response r = bot.playAdvert(Settings.accountManager.getUserAccount().getKey(), "3m", Settings.accountManager.getUserAccount().getName());
bot.getBot().sendMessage("#" + Settings.accountManager.getUserAccount().getName(), r.getResponseText());
ThreadEngine.submit(() -> {
try {
Thread.sleep(180000);
logCurrent("The 3 minute advertisement has ended.");
} catch (InterruptedException ignored) {
}
});
}
});
runAdMenu.add(timeOption180sec);
}
toolsMenu.add(runAdMenu);
//---- updateStatusOption ----
updateStatusOption.setText("Update Status...");
updateStatusOption.addActionListener(e -> updateStatusOptionActionPerformed());
toolsMenu.add(updateStatusOption);
//---- subOnlyToggle ----
subOnlyToggle.setText("Sub-only Chat");
subOnlyToggle.addActionListener(e -> subOnlyToggleItemStateChanged());
toolsMenu.add(subOnlyToggle);
//======== slowModeMenu ========
{
slowModeMenu.setText("Slow Mode");
//---- slowModeOffOption ----
slowModeOffOption.setText("Off");
slowModeOffOption.addActionListener(e -> {
if (viewer != null) {
viewer.getViewer().sendRawMessage("#" + Settings.accountManager.getUserAccount().getName(), "/slowoff");
}
});
slowModeOffOption.setSelected(true);
slowModeMenu.add(slowModeOffOption);
//---- slowMode5secOption ----
slowMode5secOption.setText("5 seconds");
slowMode5secOption.addActionListener(e -> {
if (viewer != null) {
viewer.getViewer().sendRawMessage("#" + Settings.accountManager.getUserAccount().getName(), "/slow 5");
}
});
slowModeMenu.add(slowMode5secOption);
//---- slowMode10secOption ----
slowMode10secOption.setText("10 seconds");
slowMode10secOption.addActionListener(e -> {
if (viewer != null) {
viewer.getViewer().sendRawMessage("#" + Settings.accountManager.getUserAccount().getName(), "/slow 10");
}
});
slowModeMenu.add(slowMode10secOption);
//---- slowMode15secOption ----
slowMode15secOption.setText("15 seconds");
slowMode15secOption.addActionListener(e -> {
if (viewer != null) {
viewer.getViewer().sendRawMessage("#" + Settings.accountManager.getUserAccount().getName(), "/slow 15");
}
});
slowModeMenu.add(slowMode15secOption);
//---- slowMode30secOption ----
slowMode30secOption.setText("30 seconds");
slowMode30secOption.addActionListener(e -> {
if (viewer != null) {
viewer.getViewer().sendRawMessage("#" + Settings.accountManager.getUserAccount().getName(), "/slow 30");
}
});
slowModeMenu.add(slowMode30secOption);
//---- slowModeCustomOption ----
slowModeCustomOption.setText("Custom (use chat)");
slowModeCustomOption.setEnabled(false);
slowModeMenu.add(slowModeCustomOption);
}
toolsMenu.add(slowModeMenu);
}
menuBar1.add(toolsMenu);
//======== helpMenu ========
{
helpMenu.setText("Help");
//---- projectGithubOption ----
projectGithubOption.setText("Botnak Github");
projectGithubOption.addActionListener(e -> projectGithubOptionActionPerformed());
helpMenu.add(projectGithubOption);
//---- projectWikiOption ----
projectWikiOption.setText("Botnak Wiki");
projectWikiOption.addActionListener(e -> projectWikiOptionActionPerformed());
helpMenu.add(projectWikiOption);
JMenuItem bugReport = new JMenuItem("Report an Issue");
bugReport.addActionListener(e -> Utils.openWebPage("https://github.com/Gocnak/Botnak/issues/new"));
helpMenu.add(bugReport);
helpMenu.addSeparator();
//---- projectDetailsOption ----
projectDetailsOption.setText("About...");
projectDetailsOption.addActionListener(e -> projectDetailsOptionActionPerformed());
helpMenu.add(projectDetailsOption);
}
menuBar1.add(helpMenu);
}
setJMenuBar(menuBar1);
//======== channelPane ========
{
channelPane.setFocusable(false);
channelPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
channelPane.setAutoscrolls(true);
channelPane.addChangeListener(Constants.tabListener);
channelPane.addMouseListener(Constants.tabListener);
//======== allChatsScroll ========
{
allChatsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- allChats ----
allChats.setEditable(false);
allChats.setForeground(Color.white);
allChats.setBackground(Color.black);
allChats.setFont(new Font("Calibri", Font.PLAIN, 16));
allChats.setMargin(new Insets(0, 0, 0, 0));
allChats.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
allChats.addMouseListener(Constants.listenerURL);
allChats.addMouseListener(Constants.listenerName);
allChats.setEditorKit(Constants.wrapEditorKit);
allChatsScroll.setViewportView(allChats);
}
channelPane.addTab("System Logs", allChatsScroll);
//---- dankLabel ----
dankLabel.setText("Dank memes");
channelPane.addTab("+", dankLabel);
channelPane.setEnabledAt(channelPane.getTabCount() - 1, false);
channelPane.addMouseListener(new NewTabListener());
}
//======== scrollPane1 ========
{
scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
//---- userChat ----
userChat.setFont(new Font("Consolas", Font.PLAIN, 12));
userChat.setLineWrap(true);
userChat.setWrapStyleWord(true);
userChat.addKeyListener(new ListenerUserChat(userChat));
scrollPane1.setViewportView(userChat);
}
GroupLayout BotnakContentPaneLayout = new GroupLayout(BotnakContentPane);
BotnakContentPane.setLayout(BotnakContentPaneLayout);
BotnakContentPaneLayout.setHorizontalGroup(BotnakContentPaneLayout.createParallelGroup().addComponent(channelPane, GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE).addComponent(scrollPane1));
BotnakContentPaneLayout.setVerticalGroup(BotnakContentPaneLayout.createParallelGroup().addGroup(BotnakContentPaneLayout.createSequentialGroup().addComponent(channelPane, GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)));
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
if (channelPane != null) {
channelPane.scrollDownPanes();
}
}
});
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
exitButtonActionPerformed();
}
});
pack();
setLocationRelativeTo(getOwner());
}
//---- botReplyGroup ----
ButtonGroup botReplyGroup = new ButtonGroup();
botReplyGroup.add(botReplyAll);
botReplyGroup.add(botReplyJustYou);
botReplyGroup.add(botReplyNobody);
//---- soundDelayGroup ----
ButtonGroup soundDelayGroup = new ButtonGroup();
soundDelayGroup.add(soundDelayOffOption);
soundDelayGroup.add(soundDelay5secOption);
soundDelayGroup.add(soundDelay10secOption);
soundDelayGroup.add(soundDelay20secOption);
soundDelayGroup.add(soundDelayCustomOption);
//---- soundPermissionGroup ----
ButtonGroup soundPermissionGroup = new ButtonGroup();
soundPermissionGroup.add(soundPermEveryoneOption);
soundPermissionGroup.add(soundPermSDMBOption);
soundPermissionGroup.add(soundPermDMBOption);
soundPermissionGroup.add(soundPermModAndBroadOption);
soundPermissionGroup.add(soundPermBroadOption);
//---- slowModeGroup ----
ButtonGroup slowModeGroup = new ButtonGroup();
slowModeGroup.add(slowModeOffOption);
slowModeGroup.add(slowMode5secOption);
slowModeGroup.add(slowMode10secOption);
slowModeGroup.add(slowMode15secOption);
slowModeGroup.add(slowMode30secOption);
slowModeGroup.add(slowModeCustomOption);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
Aggregations