Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
|
1c13162f80 | 7 years ago |
|
904a9925e2 | 7 years ago |
|
413fab117b | 7 years ago |
|
79bb1e576b | 7 years ago |
|
824b8249d9 | 7 years ago |
|
e210299f7f | 7 years ago |
|
629f118e7c | 7 years ago |
|
9e6aa20a21 | 7 years ago |
|
63dfe0c60e | 7 years ago |
|
f07a89fe22 | 7 years ago |
|
2cee57d9e9 | 7 years ago |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 331 B |
After Width: | Height: | Size: 7.0 KiB |
@ -0,0 +1 @@ |
||||
<img src="../sigIRCicon.png" style="float:left;padding-right:5px;vertical-align:text-bottom;"><font size="5"><b>sigIRC</b> allows you to present dynamic content to viewers on stream and provides various features that may be helpful to you as a streamer. Click <i>Next</i> to begin the setup process.</font> |
@ -0,0 +1,12 @@ |
||||
<font size="5">Now it's time to configure basic features of <b>sigIRC</b>. sigIRC provides the following modules: |
||||
<br> |
||||
<ul> |
||||
<li><b>Scrolling Chat</b> - Displays scrolling chat messages across the screen as users of your channel talk.</li> |
||||
<li><b>Chat Log</b> - Displays a box that contains the latest chat messages from your channel for that day.</li> |
||||
<li><b>Controller</b> - Displays a controller on screen and allows you to configure the buttons and display so viewers can see your button inputs.</li> |
||||
<li><b>Twitch</b> - Displays a bar that shows your channel's stream uptime, number of followers, channel view, and current viewers. Also announces new followers of your stream.</li> |
||||
<li><b>Rabi-Race</b> - For the game <b>Rabi-Ribi</b>. A tracker that allows players of the game to connect to each other in game rooms and see each others' progress as they race. Supports randomizer Egg Hunts and Item Hunts.</li> |
||||
<li><b>Touhou Mother</b> - For the game <b>Touhou Mother</b>. A tracker that displays boss health whenever you get into a boss encounter, the amount of time the boss fight takes, and how much damage your party members deal.</li> |
||||
</ul> |
||||
<br><br> |
||||
Each module will open up in a separate window that you can place and resize on your screen as you see fit.</font> |
@ -0,0 +1 @@ |
||||
<font size="5"><b>sigIRC</b> uses your Twitch account in order to retrieve and send data. Please input your Twitch username below and hit <i>Next</i> to continue. You will be asked for authentication details on the next screen.</font> |
@ -0,0 +1 @@ |
||||
<font size="5">Below you will see a button to <i><a href="https://twitchapps.com/tmi/">https://twitchapps.com/tmi/</a></i> which will allow you to retrieve an <b>oauth Token</b>. Connect to Twitch and generate an <b>oauth token</b>, then copy and paste the token into the box below to grant this program the ability to use Twitch services.</font> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,53 @@ |
||||
package sig; |
||||
|
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.KeyListener; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.awt.event.MouseWheelEvent; |
||||
import java.awt.event.MouseWheelListener; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
public class ListenerPanel extends JPanel implements MouseListener, MouseWheelListener{ |
||||
|
||||
Module mod; |
||||
|
||||
public ListenerPanel(Module mod) { |
||||
this.addMouseListener(this); |
||||
this.addMouseWheelListener(this); |
||||
this.mod=mod; |
||||
} |
||||
|
||||
@Override |
||||
public void mouseWheelMoved(MouseWheelEvent e) { |
||||
this.mod.mouseWheelMoved(e); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
this.mod.mouseClicked(e); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
this.mod.mouseEntered(e); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
this.mod.mouseExited(e); |
||||
} |
||||
|
||||
@Override |
||||
public void mousePressed(MouseEvent e) { |
||||
this.mod.mousePressed(e); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseReleased(MouseEvent e) { |
||||
this.mod.mouseReleased(e); |
||||
} |
||||
|
||||
|
||||
} |
@ -1,178 +1,263 @@ |
||||
package sig; |
||||
import java.awt.Color; |
||||
import java.awt.Cursor; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.Point; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ComponentEvent; |
||||
import java.awt.event.ComponentListener; |
||||
import java.awt.event.KeyEvent; |
||||
import java.awt.event.KeyListener; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseWheelEvent; |
||||
import java.awt.event.WindowEvent; |
||||
import java.awt.event.WindowListener; |
||||
import java.awt.geom.Rectangle2D; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.IOException; |
||||
import java.util.Vector; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.SwingUtilities; |
||||
|
||||
import sig.utils.DrawUtils; |
||||
import sig.utils.TextUtils; |
||||
import sig.windows.ProgramWindow; |
||||
|
||||
public class Module { |
||||
public Rectangle2D position; |
||||
public class Module extends JFrame implements ComponentListener, WindowListener, KeyListener{ |
||||
public ListenerPanel panel; |
||||
public Rectangle position; |
||||
protected boolean enabled; |
||||
protected String name; |
||||
public static BufferedImage IMG_DRAGBAR; |
||||
public static BufferedImage MSG_SEPARATOR; |
||||
public static boolean inDragZone=false; |
||||
final public static int WINDOW_EXTRA_BORDER = 32; //Number of pixels that the border takes up (Reduces the size of the window)
|
||||
|
||||
final protected int titleHeight; |
||||
|
||||
Point dragOffset; |
||||
boolean dragging=false; |
||||
public static boolean DRAGGING=false; |
||||
public Graphics myGraphics; |
||||
long lasttime = System.currentTimeMillis(); |
||||
float avgfps = sigIRC.framerate; |
||||
int counter = 0; |
||||
int avgcount = 10; |
||||
int[] sum = new int[10]; |
||||
int windowUpdateCounter = 30; |
||||
|
||||
public Module(Rectangle bounds, String moduleName) { |
||||
|
||||
try { |
||||
Thread.sleep(1000); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
this.addComponentListener(this); |
||||
this.addWindowListener(this); |
||||
this.addKeyListener(this); |
||||
|
||||
public Module(Rectangle2D bounds, String moduleName) { |
||||
this.position = bounds; |
||||
System.out.println(position); |
||||
this.name = moduleName; |
||||
this.enabled=true; |
||||
|
||||
this.titleHeight = (int)TextUtils.calculateStringBoundsFont(this.name, sigIRC.panel.userFont).getHeight(); |
||||
this.setTitle(moduleName); |
||||
panel = new ListenerPanel(this){ |
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
draw(g); |
||||
} |
||||
}; |
||||
this.setLocation((int)position.getX(), (int)position.getY()); |
||||
|
||||
this.titleHeight = (int)TextUtils.calculateStringBoundsFont(this.name, sigIRC.userFont).getHeight(); |
||||
|
||||
this.setSize(new Dimension((int)position.getWidth(), (int)position.getHeight())); |
||||
|
||||
panel.setSize(this.getSize()); |
||||
//System.out.println("Module "+moduleName+": "+position);
|
||||
|
||||
this.add(panel); |
||||
//this.pack();
|
||||
repaint(); |
||||
this.setVisible(true); |
||||
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
||||
scheduler.scheduleWithFixedDelay(()->{ |
||||
run(); |
||||
panel.repaint(); |
||||
},(long)((1d/(sigIRC.framerate+1))*1000),(long)((1d/(sigIRC.framerate+1))*1000),TimeUnit.MILLISECONDS); |
||||
} |
||||
|
||||
public Module(Rectangle2D bounds, String moduleName, boolean enabled) { |
||||
public Module(Rectangle bounds, String moduleName, boolean enabled) { |
||||
this(bounds, moduleName); |
||||
this.enabled=enabled; |
||||
} |
||||
|
||||
protected void mouseModuleMousePress(MouseEvent ev) { |
||||
int mouseX = ev.getX(); |
||||
int mouseY = ev.getY(); |
||||
//System.out.println(mouseX + "," + mouseY);
|
||||
enableWindowDrag(mouseX,mouseY); |
||||
mousePressed(ev); |
||||
|
||||
|
||||
public void updateFPSCounter() { |
||||
float val = 1000f/(System.currentTimeMillis()-lasttime); |
||||
sum[counter++ % sum.length] = (int)val; |
||||
avgfps = (float)sum(sum)/sum.length; |
||||
this.setTitle(name+" - "+(int)Math.round(avgfps)+" FPS"); |
||||
lasttime=System.currentTimeMillis(); |
||||
} |
||||
|
||||
private void enableWindowDrag(int mouseX, int mouseY) { |
||||
if (!sigIRC.overlayMode && !dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) { |
||||
//Enable dragging.
|
||||
dragOffset = new Point((int)position.getX() - mouseX,(int)position.getY()-mouseY); |
||||
dragging=DRAGGING=true; |
||||
private int sum(int[] array) { |
||||
int val = 0; |
||||
for (int i=0;i<array.length;i++) { |
||||
val+=array[i]; |
||||
} |
||||
return val; |
||||
} |
||||
|
||||
public boolean inDragBounds(int x, int y) { |
||||
return x>=position.getX() && x<=position.getX()+position.getWidth() && |
||||
y>=(int)position.getY()-Module.IMG_DRAGBAR.getHeight() && |
||||
y<=(int)position.getY(); |
||||
public void ApplyConfigWindowProperties() { |
||||
} |
||||
|
||||
public void mousePressed(MouseEvent ev) { |
||||
public void SaveConfig() { |
||||
|
||||
} |
||||
|
||||
public void ApplyConfigWindowProperties() { |
||||
protected void moduleRun() { |
||||
run(); |
||||
} |
||||
|
||||
public void SaveConfig() { |
||||
public Rectangle2D getPosition() { |
||||
return position; |
||||
} |
||||
|
||||
public void run() { |
||||
} |
||||
|
||||
public void mouseReleased(MouseEvent ev) { |
||||
if (dragging) { |
||||
dragging=DRAGGING=false; |
||||
ApplyConfigWindowProperties(); |
||||
sigIRC.config.saveProperties(); |
||||
} |
||||
public void draw(Graphics g) { |
||||
//g.fillRect(0, 0, (int)position.getWidth(), (int)position.getHeight());
|
||||
//DrawUtils.drawText(g, 0, 16, Color.WHITE, "Test");
|
||||
updateFPSCounter(); |
||||
} |
||||
|
||||
protected void moduleRun() { |
||||
dragWindow(); |
||||
modifyCursor(); |
||||
run(); |
||||
public void windowClosed(WindowEvent ev) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void windowActivated(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void windowClosing(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void windowDeactivated(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void windowDeiconified(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
private void modifyCursor() { |
||||
if (!sigIRC.overlayMode) { |
||||
int cursortype = sigIRC.panel.getCursor().getType(); |
||||
if (inDragZone && |
||||
cursortype!=Cursor.MOVE_CURSOR) { |
||||
sigIRC.panel.setCursor(new Cursor(Cursor.MOVE_CURSOR)); |
||||
} else |
||||
if (!inDragZone && cursortype!=Cursor.DEFAULT_CURSOR) { |
||||
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||||
} |
||||
@Override |
||||
public void windowIconified(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void windowOpened(WindowEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void componentHidden(ComponentEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void componentMoved(ComponentEvent e) { |
||||
if (this.isVisible()) { |
||||
UpdatePosition(e); |
||||
} |
||||
} |
||||
|
||||
private void dragWindow() { |
||||
if (dragging) { |
||||
//sigIRC.panel.repaint(getDrawBounds().getBounds());
|
||||
int mouseX = sigIRC.panel.lastMouseX+(int)dragOffset.getX(); |
||||
int mouseY = sigIRC.panel.lastMouseY+(int)dragOffset.getY(); |
||||
int oldX = (int)position.getX(); |
||||
int oldY = (int)position.getY(); |
||||
position = new Rectangle((int)Math.min(Math.max(0,mouseX),sigIRC.window.getWidth()-position.getWidth()), (int)Math.min(Math.max(titleHeight,mouseY),sigIRC.window.getHeight()-position.getHeight()-titleHeight*2),(int)position.getWidth(),(int)position.getHeight()); |
||||
//System.out.println(sigIRC.panel.lastMouseX+","+sigIRC.panel.lastMouseY);
|
||||
ModuleDragEvent(oldX,oldY,mouseX,mouseY); |
||||
private void UpdatePosition(ComponentEvent e) { |
||||
position = new Rectangle((int)e.getComponent().getLocationOnScreen().getX(),(int)e.getComponent().getLocationOnScreen().getY(),e.getComponent().getWidth(),e.getComponent().getHeight()); |
||||
//System.out.println(position);
|
||||
ApplyConfigWindowProperties(); |
||||
sigIRC.configNeedsUpdating = System.currentTimeMillis(); |
||||
} |
||||
|
||||
@Override |
||||
public void componentResized(ComponentEvent e) { |
||||
if (this.isVisible()) { |
||||
UpdatePosition(e); |
||||
} |
||||
if (inDragBounds(sigIRC.panel.lastMouseX,sigIRC.panel.lastMouseY)) { |
||||
inDragZone=true; |
||||
//System.out.println("In Drag Zone for Module "+name);
|
||||
//sigIRC.panel.setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
||||
} /*else |
||||
if (sigIRC.panel.getCursor().getType()==Cursor.MOVE_CURSOR) { |
||||
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
||||
}*/ |
||||
} |
||||
|
||||
public Rectangle2D getPosition() { |
||||
return position; |
||||
@Override |
||||
public void componentShown(ComponentEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void run() { |
||||
public void keyPressed(KeyEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
drawModuleHeader(g); |
||||
/*SwingUtilities.invokeLater(new Runnable() { |
||||
public void run() { |
||||
sigIRC.panel.repaint(getDrawBounds().getBounds()); |
||||
} |
||||
});*/ |
||||
} |
||||
|
||||
private void drawModuleHeader(Graphics g) { |
||||
if (!sigIRC.overlayMode) { |
||||
g.drawImage(Module.IMG_DRAGBAR, |
||||
(int)position.getX()+2, |
||||
(int)position.getY()-Module.IMG_DRAGBAR.getHeight(), |
||||
(int)position.getWidth()-4, |
||||
Module.IMG_DRAGBAR.getHeight(), |
||||
sigIRC.panel); |
||||
DrawUtils.drawTextFont(g, sigIRC.panel.smallFont, (int)position.getX(), (int)position.getY()-titleHeight/2+4, Color.BLACK, this.name); |
||||
//g.fillRect((int)position.getX(), (int)position.getY(), (int)position.getWidth(), (int)position.getHeight());
|
||||
} |
||||
public void keyReleased(KeyEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
private Rectangle2D getDrawBounds() { |
||||
Rectangle2D drawBounds = new Rectangle((int)position.getX()-2,(int)position.getY()-titleHeight+3-1,(int)position.getWidth()+2,(int)position.getHeight()+titleHeight+1); |
||||
return drawBounds; |
||||
public void keyTyped(KeyEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void ModuleDragEvent(int oldX, int oldY, int newX, int newY) { |
||||
public void mouseWheelMoved(MouseWheelEvent arg0) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void mouseWheel(MouseWheelEvent ev) { |
||||
public void mouseClicked(MouseEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void keypressed(KeyEvent ev) { |
||||
public void mouseEntered(MouseEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void keyreleased(KeyEvent ev) { |
||||
public void mouseExited(MouseEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void windowClosed(WindowEvent ev) { |
||||
public void mousePressed(MouseEvent e) { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
public void mouseReleased(MouseEvent e) { |
||||
} |
||||
} |
@ -0,0 +1,203 @@ |
||||
package sig.modules; |
||||
|
||||
import java.awt.Graphics; |
||||
import java.awt.Rectangle; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.Calendar; |
||||
|
||||
import org.json.JSONException; |
||||
import org.json.JSONObject; |
||||
|
||||
import sig.CustomSound; |
||||
import sig.Module; |
||||
import sig.TextRow; |
||||
import sig.sigIRC; |
||||
import sig.utils.FileUtils; |
||||
import sig.windows.ProgramWindow; |
||||
|
||||
public class ScrollingChatModule extends Module{ |
||||
|
||||
final static int MSGTIMER = 300; |
||||
final static int AUTOSAVETIMER = 600; |
||||
int last_authentication_msg = MSGTIMER; |
||||
int last_autosave = AUTOSAVETIMER; |
||||
public static ScrollingChatModule module; |
||||
|
||||
public ScrollingChatModule(Rectangle bounds, String moduleName) { |
||||
super(bounds, moduleName); |
||||
|
||||
ScrollingChatModule.module = this; |
||||
String[] filedata = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/oauthToken.txt"); |
||||
|
||||
for (int i=0;i<sigIRC.chatRows;i++) { |
||||
sigIRC.rowobj.add(new TextRow(32+sigIRC.ROWSEPARATION*i)); |
||||
} |
||||
//UpdateSubEmoticons();
|
||||
} |
||||
|
||||
public void run() { |
||||
super.run(); |
||||
UpdateScrollingText(); |
||||
UpdateAuthenticationCountdownMessage(); |
||||
//System.out.println("Called.");
|
||||
} |
||||
|
||||
|
||||
private void UpdateSubEmoticons() { |
||||
if (!sigIRC.downloadedSubEmotes && |
||||
sigIRC.disableChatMessages && |
||||
sigIRC.subchannelCount==sigIRC.subchannelIds.size()) { |
||||
Thread downloadThread = new Thread(){ |
||||
public void run() { |
||||
JSONObject data = GetSubEmoteJson(); |
||||
sigIRC.downloadSubEmotes(data); |
||||
sigIRC.subEmotesCompleted=true; |
||||
} |
||||
}; |
||||
downloadThread.start(); |
||||
sigIRC.downloadedSubEmotes=true; |
||||
} |
||||
} |
||||
|
||||
public void ApplyConfigWindowProperties() { |
||||
sigIRC.scrollingchatmodule_X=(int)position.getX(); |
||||
sigIRC.scrollingchatmodule_Y=(int)position.getY(); |
||||
sigIRC.scrollingchatmodule_width=(int)position.getWidth(); |
||||
sigIRC.scrollingchatmodule_height=(int)position.getHeight(); |
||||
sigIRC.config.setInteger("SCROLLINGCHAT_module_X", sigIRC.scrollingchatmodule_X); |
||||
sigIRC.config.setInteger("SCROLLINGCHAT_module_Y", sigIRC.scrollingchatmodule_Y); |
||||
sigIRC.config.setInteger("SCROLLINGCHAT_module_width", sigIRC.scrollingchatmodule_width); |
||||
sigIRC.config.setInteger("SCROLLINGCHAT_module_height", sigIRC.scrollingchatmodule_height); |
||||
sigIRC.config.saveProperties(); |
||||
} |
||||
|
||||
public void draw(Graphics g) { |
||||
super.draw(g); |
||||
for (int i=0;i<sigIRC.textobj.size();i++) { |
||||
if (sigIRC.textobj.get(i).isActive()) { |
||||
if (sigIRC.overlayMode) { |
||||
if (!sigIRC.textobj.get(i).intersects((int)(ProgramWindow.frame.lastMouseX-position.getX()),(int)(ProgramWindow.frame.lastMouseY-position.getY()))) { |
||||
sigIRC.textobj.get(i).setVisible(true); |
||||
sigIRC.textobj.get(i).draw(g); |
||||
} else { |
||||
//System.out.println("Setting to False.");
|
||||
sigIRC.textobj.get(i).setVisible(false); |
||||
} |
||||
} else { |
||||
sigIRC.textobj.get(i).draw(g); |
||||
} |
||||
} |
||||
} |
||||
for (int i=0;i<sigIRC.twitchemoticons.size();i++) { |
||||
if (sigIRC.twitchemoticons.get(i).isActive() && |
||||
sigIRC.twitchemoticons.get(i).textRefIsVisible()) { |
||||
sigIRC.twitchemoticons.get(i).draw(g); |
||||
} else { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private JSONObject GetSubEmoteJson() { |
||||
JSONObject subemotes = null; |
||||
try { |
||||
File filer = new File(sigIRC.SUBEMOTELISTFILE); |
||||
if (!filer.exists()) { |
||||
System.out.println("Local copy of Sub emotes not found. Downloading in background..."); |
||||
subemotes = FileUtils.readJsonFromUrlWithFilter("https://twitchemotes.com/api_cache/v3/subscriber.json",sigIRC.subchannelIds,sigIRC.SUBEMOTELISTFILE,true); |
||||
} else { |
||||
if (sigIRC.lastSubEmoteUpdate == Calendar.getInstance().get(Calendar.DAY_OF_YEAR)) { |
||||
System.out.println("Using local copy of Sub emote JSON."); |
||||
subemotes = FileUtils.readJsonFromFileWithFilter(sigIRC.SUBEMOTELISTFILE,sigIRC.subchannelIds); |
||||
} else { |
||||
System.out.println("Local copy of Sub emote JSON out-of-date! Re-downloading in background..."); |
||||
subemotes = FileUtils.readJsonFromFileWithFilter(sigIRC.SUBEMOTELISTFILE,sigIRC.subchannelIds); |
||||
new Thread(){ |
||||
public void run() { |
||||
try { |
||||
FileUtils.readJsonFromUrlWithFilter("https://twitchemotes.com/api_cache/v3/subscriber.json",sigIRC.subchannelIds,sigIRC.SUBEMOTELISTFILE,true); |
||||
} catch (JSONException e) { |
||||
e.printStackTrace(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
}.start(); |
||||
} |
||||
} |
||||
} catch (JSONException | IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
sigIRC.lastSubEmoteUpdate = Calendar.getInstance().get(Calendar.DAY_OF_YEAR); |
||||
sigIRC.config.setInteger("lastSubEmote_APIUpdate", sigIRC.lastSubEmoteUpdate); |
||||
return subemotes; |
||||
} |
||||
|
||||
private void UpdateAuthenticationCountdownMessage() { |
||||
if (sigIRC.downloadsComplete) { |
||||
if ((!sigIRC.authenticated || sigIRC.testMode) && last_authentication_msg<MSGTIMER) { |
||||
last_authentication_msg++; |
||||
} else |
||||
if ((!sigIRC.authenticated || sigIRC.testMode) && last_authentication_msg>=MSGTIMER) { |
||||
last_authentication_msg=0; |
||||
if (!sigIRC.authenticated && !sigIRC.testMode) { |
||||
sigIRC.panel.addMessage("SYSTEM: Your oauthToken was not successful. Please go to the sigIRC folder and make sure your oauthToken.txt file is correct!!! SwiftRage",!sigIRC.playedoAuthSoundOnce); |
||||
if (!sigIRC.playedoAuthSoundOnce) { |
||||
sigIRC.playedoAuthSoundOnce=true; |
||||
} |
||||
} else { |
||||
sigIRC.panel.addMessage("SYSTEM: This is a test message for your testing convenience. mikansBox",!sigIRC.playedoAuthSoundOnce); |
||||
} |
||||
} |
||||
if (last_autosave<AUTOSAVETIMER) { |
||||
last_authentication_msg++; |
||||
} else |
||||
if (last_autosave>=AUTOSAVETIMER) { |
||||
last_autosave=0; |
||||
sigIRC.windowX = (int)sigIRC.window.getLocationOnScreen().getX(); |
||||
sigIRC.windowY = (int)sigIRC.window.getLocationOnScreen().getY(); |
||||
sigIRC.windowWidth = sigIRC.window.getWidth(); |
||||
sigIRC.windowHeight = sigIRC.window.getHeight(); |
||||
sigIRC.config.setInteger("windowX", sigIRC.windowX); |
||||
sigIRC.config.setInteger("windowY", sigIRC.windowY); |
||||
sigIRC.config.setInteger("windowWidth", sigIRC.windowWidth); |
||||
sigIRC.config.setInteger("windowHeight", sigIRC.windowHeight); |
||||
sigIRC.config.saveProperties(); |
||||
} |
||||
if (sigIRC.lastPlayedDing>0) { |
||||
sigIRC.lastPlayedDing--; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void UpdateScrollingText() { |
||||
for (int i=0;i<sigIRC.twitchemoticons.size();i++) { |
||||
boolean keep = sigIRC.twitchemoticons.get(i).run(); |
||||
if (!keep) { |
||||
sigIRC.twitchemoticons.remove(i--); |
||||
} |
||||
} |
||||
for (int i=0;i<sigIRC.textobj.size();i++) { |
||||
//System.out.println(sigIRC.textobj.get(i).getX()+","+sigIRC.textobj.get(i).getY());
|
||||
boolean keep = sigIRC.textobj.get(i).run(); |
||||
if (!keep) { |
||||
sigIRC.textobj.remove(i--); |
||||
} |
||||
} |
||||
ProcessTextRows(); |
||||
for (CustomSound cs : sigIRC.customsounds) { |
||||
if (!cs.isSoundAvailable()) { |
||||
cs.decreaseCooldown(1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void ProcessTextRows() { |
||||
for (TextRow tr : sigIRC.rowobj) { |
||||
tr.update(); |
||||
} |
||||
sigIRC.dingEnabled = (sigIRC.textobj.size()<=sigIRC.dingThreshold); |
||||
//System.out.println(sigIRC.textobj.size()+"/"+sigIRC.dingThreshold+sigIRC.dingEnabled);
|
||||
} |
||||
} |
@ -0,0 +1,416 @@ |
||||
package sig.windows; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Desktop; |
||||
import java.awt.Dimension; |
||||
import java.awt.Font; |
||||
import java.awt.FontFormatException; |
||||
import java.awt.GraphicsEnvironment; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.io.BufferedReader; |
||||
import java.io.BufferedWriter; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.io.InputStreamReader; |
||||
import java.io.OutputStreamWriter; |
||||
import java.net.Socket; |
||||
import java.net.URI; |
||||
import java.net.URISyntaxException; |
||||
import java.net.UnknownHostException; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.Box; |
||||
import javax.swing.Icon; |
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JComboBox; |
||||
import javax.swing.JEditorPane; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextField; |
||||
import javax.swing.JToggleButton; |
||||
import javax.swing.border.TitledBorder; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import javax.swing.text.BadLocationException; |
||||
import javax.swing.text.html.HTMLDocument; |
||||
|
||||
import sig.sigIRC; |
||||
import sig.modules.RabiRaceModule; |
||||
import sig.utils.FileUtils; |
||||
|
||||
public class IntroDialog extends JFrame{ |
||||
Font systemFont; |
||||
final static Color panelBackgroundColor = new Color(192,192,192); |
||||
JPanel displayPanel; |
||||
JPanel borderPanel; |
||||
JPanel buttonPanel; |
||||
JButton nextbutton; |
||||
JButton exitbutton; |
||||
JButton backbutton; |
||||
JEditorPane introText; |
||||
TitledBorder border; |
||||
JTextField nameBox,oauthTokenBox; |
||||
JPanel namePanel; |
||||
JLabel nameLabel; |
||||
JLabel oauthLabel; |
||||
JScrollPane scrollDisplayPanel; |
||||
JButton openWebpage; |
||||
ModuleButton[] moduleButtons; |
||||
JComboBox<String> updateType; |
||||
|
||||
static Icon deselected_icon,selected_icon; |
||||
|
||||
public IntroDialog() { |
||||
this.setLocationByPlatform(true); |
||||
this.setVisible(true); |
||||
this.setTitle("sigIRCv2 v"+sigIRC.VERSION); |
||||
|
||||
InputStream stream = sigIRC.class.getResourceAsStream("/resource/CP_Font.ttf"); |
||||
//File font = new File(sigIRC.BASEDIR+"sigIRC/CP_Font.ttf");
|
||||
|
||||
try { |
||||
systemFont = Font.createFont(Font.TRUETYPE_FONT,stream); |
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(systemFont); |
||||
systemFont = new Font("CP Font",0,16); |
||||
} catch (FontFormatException | IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
borderPanel = new JPanel(); |
||||
displayPanel = new JPanel(); |
||||
buttonPanel = new JPanel(); |
||||
namePanel = new JPanel(); |
||||
namePanel.setBackground(panelBackgroundColor); |
||||
namePanel.setPreferredSize(new Dimension(560,320)); |
||||
nameBox = new JTextField(30); |
||||
oauthTokenBox = new JTextField(30); |
||||
//dialogPanel.setSize(this.getSize());
|
||||
border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK, 2, true),"Welcome to sigIRC!",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,systemFont); |
||||
borderPanel.setBorder(border); |
||||
|
||||
this.add(borderPanel); |
||||
|
||||
try { |
||||
this.setIconImage(ImageIO.read(sigIRC.class.getResource("/resource/sigIRCicon.png"))); |
||||
deselected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/deselected_button.png"))); |
||||
selected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/selected_button.png"))); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
|
||||
moduleButtons = new ModuleButton[]{ |
||||
new ModuleButton("Scrolling Chat"), |
||||
new ModuleButton("Chat Log"), |
||||
new ModuleButton("Controller"), |
||||
new ModuleButton("Twitch"), |
||||
new ModuleButton("Rabi-Race"), |
||||
new ModuleButton("Touhou Mother"), |
||||
}; |
||||
|
||||
moduleButtons[0].setSelected(true); |
||||
moduleButtons[1].setSelected(true); |
||||
moduleButtons[3].setSelected(true); |
||||
|
||||
introText = new JEditorPane(); |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/introText.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
introText.setPreferredSize(new Dimension(560, 320)); |
||||
introText.setEditable(false); |
||||
introText.setBackground(panelBackgroundColor); |
||||
|
||||
|
||||
backbutton = new JButton("< Back"); |
||||
backbutton.setPreferredSize(new Dimension(128,24)); |
||||
backbutton.setActionCommand("2"); |
||||
backbutton.setEnabled(false); |
||||
backbutton.addActionListener(new ActionListener(){ |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent ev) { |
||||
setupBackPage(ev.getActionCommand()); |
||||
} |
||||
|
||||
}); |
||||
|
||||
nextbutton = new JButton("Next >"); |
||||
nextbutton.setPreferredSize(new Dimension(128,24)); |
||||
nextbutton.setActionCommand("2"); |
||||
nextbutton.addActionListener(new ActionListener(){ |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent ev) { |
||||
setupPage(ev.getActionCommand()); |
||||
} |
||||
|
||||
}); |
||||
exitbutton = new JButton("Exit"); |
||||
exitbutton.setPreferredSize(new Dimension(128,24)); |
||||
|
||||
displayPanel.setPreferredSize(new Dimension(680,360)); |
||||
|
||||
scrollDisplayPanel = new JScrollPane(); |
||||
scrollDisplayPanel.setViewportView(introText); |
||||
scrollDisplayPanel.setPreferredSize(introText.getPreferredSize()); |
||||
scrollDisplayPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
||||
scrollDisplayPanel.setBorder(null); |
||||
displayPanel.add(scrollDisplayPanel); |
||||
displayPanel.add(namePanel); |
||||
displayPanel.setBackground(panelBackgroundColor); |
||||
|
||||
buttonPanel.setPreferredSize(new Dimension(680,48)); |
||||
|
||||
buttonPanel.add(Box.createHorizontalStrut(128)); |
||||
buttonPanel.add(backbutton); |
||||
buttonPanel.add(Box.createHorizontalStrut(12)); |
||||
buttonPanel.add(nextbutton); |
||||
buttonPanel.add(Box.createHorizontalStrut(80)); |
||||
buttonPanel.add(exitbutton); |
||||
buttonPanel.setBackground(panelBackgroundColor); |
||||
|
||||
borderPanel.add(displayPanel); |
||||
borderPanel.add(buttonPanel); |
||||
|
||||
borderPanel.setBackground(panelBackgroundColor); |
||||
|
||||
this.setSize(720, 480); |
||||
this.setBackground(panelBackgroundColor); |
||||
this.setResizable(false); |
||||
} |
||||
|
||||
protected void setupBackPage(String page) { |
||||
switch (page) { |
||||
case "2":{ |
||||
setupPage("1"); |
||||
}break; |
||||
case "3":{ |
||||
setupPage("2"); |
||||
}break; |
||||
case "4":{ |
||||
setupPage("3"); |
||||
}break; |
||||
} |
||||
} |
||||
|
||||
protected void setupPage(String page) { |
||||
switch (page) { |
||||
case "1":{ |
||||
scrollDisplayPanel.setPreferredSize(new Dimension(560, 320)); |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/introText.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
displayPanel.validate(); |
||||
backbutton.setEnabled(false); |
||||
nextbutton.setActionCommand("2"); |
||||
namePanel.removeAll(); |
||||
namePanel.validate(); |
||||
border.setTitle("Welcome to sigIRC!"); |
||||
borderPanel.repaint(); |
||||
}break; |
||||
case "2":{ |
||||
border.setTitle("Setup Twitch Account"); |
||||
borderPanel.repaint(); |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/setupTwitchName.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
scrollDisplayPanel.setPreferredSize(new Dimension(560,180)); |
||||
nameLabel = new JLabel("Twitch Username: "); |
||||
namePanel.removeAll(); |
||||
namePanel.add(nameLabel); |
||||
namePanel.add(nameBox); |
||||
namePanel.setPreferredSize(new Dimension(560,320)); |
||||
namePanel.setBackground(panelBackgroundColor); |
||||
nextbutton.setActionCommand("3"); |
||||
backbutton.setActionCommand("2"); |
||||
namePanel.validate(); |
||||
displayPanel.validate(); |
||||
displayPanel.repaint(); |
||||
backbutton.setEnabled(true); |
||||
}break; |
||||
case "3":{ |
||||
border.setTitle("Setup Twitch Account"); |
||||
borderPanel.repaint(); |
||||
if (nameBox.getText().length()==0) { |
||||
JOptionPane.showMessageDialog(this, "You must enter a Twitch Username!", "Error!", JOptionPane.WARNING_MESSAGE); |
||||
break; |
||||
} |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/setupoauthToken.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
openWebpage = new JButton("Get oauthToken"); |
||||
openWebpage.addActionListener(new ActionListener(){ |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
try { |
||||
Desktop.getDesktop().browse(new URI("https://twitchapps.com/tmi/")); |
||||
} catch (IOException | URISyntaxException e1) { |
||||
e1.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
scrollDisplayPanel.setPreferredSize(new Dimension(560,180)); |
||||
nextbutton.setActionCommand("4"); |
||||
backbutton.setActionCommand("3"); |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/setupoauthToken.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
oauthLabel = new JLabel("Twitch oauth Token:"); |
||||
namePanel.removeAll(); |
||||
namePanel.add(openWebpage); |
||||
namePanel.add(Box.createRigidArea(new Dimension(640,32))); |
||||
namePanel.add(oauthLabel); |
||||
namePanel.add(oauthTokenBox); |
||||
namePanel.validate(); |
||||
}break; |
||||
case "4":{ |
||||
oauthTokenBox.setText(oauthTokenBox.getText().trim()); |
||||
if (oauthTokenBox.getText().length()!=36) { |
||||
JOptionPane.showMessageDialog(this, "An oauth Token is 36 characters long. Please verify you have copied and pasted it correctly! (Include the oauth: part)", "Error!", JOptionPane.WARNING_MESSAGE); |
||||
break; |
||||
} |
||||
border.setTitle("Connecting to Twitch..."); |
||||
borderPanel.repaint(); |
||||
this.repaint(); |
||||
if (!AttemptConnection()) { |
||||
JOptionPane.showMessageDialog(this, "Failed to authenticate with Twitch! Please verify your username, oauth Token, and Internet Connection and then try again.", "Error!", JOptionPane.WARNING_MESSAGE); |
||||
border.setTitle("Setup Twitch Account"); |
||||
borderPanel.repaint(); |
||||
break; |
||||
} |
||||
border.setTitle("Successfully Authenticated!"); |
||||
borderPanel.repaint(); |
||||
try { |
||||
introText.setPage(sigIRC.class.getResource("/resource/text/setupProgramSettings.html")); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
scrollDisplayPanel.setPreferredSize(new Dimension(560,200)); |
||||
namePanel.removeAll(); |
||||
JLabel label = new JLabel("Program Updating Behavior: "); |
||||
JLabel modulelabel = new JLabel("Select all Modules you want enabled:"); |
||||
updateType = new JComboBox<String>(); |
||||
updateType.addItem("Automatically Update"); |
||||
updateType.addItem("Notify when Update Available"); |
||||
updateType.addItem("Never Update"); |
||||
namePanel.add(label); |
||||
namePanel.add(updateType); |
||||
namePanel.add(Box.createRigidArea(new Dimension(520,4))); |
||||
namePanel.add(modulelabel); |
||||
namePanel.add(Box.createRigidArea(new Dimension(520,4))); |
||||
for (ModuleButton button : moduleButtons) { |
||||
namePanel.add(button); |
||||
} |
||||
nextbutton.setActionCommand("5"); |
||||
backbutton.setActionCommand("4"); |
||||
//namePanel.setMinimumSize(new Dimension(560,64));
|
||||
namePanel.validate(); |
||||
displayPanel.validate(); |
||||
displayPanel.repaint(); |
||||
sigIRC.config.setProperty("nickname", nameBox.getText()); |
||||
sigIRC.config.setProperty("channel", "#"+nameBox.getText()); |
||||
sigIRC.config.saveProperties(); |
||||
FileUtils.writetoFile(new String[]{oauthTokenBox.getText()}, sigIRC.BASEDIR+"sigIRC/oauthToken.txt"); |
||||
}break; |
||||
case "5":{ |
||||
sigIRC.disableChatMessages = !moduleButtons[0].isSelected(); |
||||
sigIRC.chatlogmodule_enabled = moduleButtons[1].isSelected(); |
||||
sigIRC.controllermodule_enabled = moduleButtons[2].isSelected(); |
||||
sigIRC.twitchmodule_enabled = moduleButtons[3].isSelected(); |
||||
sigIRC.rabiracemodule_enabled = moduleButtons[4].isSelected(); |
||||
sigIRC.touhoumothermodule_enabled = moduleButtons[5].isSelected(); |
||||
sigIRC.config.setBoolean("Disable_Chat_Messages", sigIRC.disableChatMessages); |
||||
sigIRC.config.setBoolean("Module_chatlog_Enabled", sigIRC.chatlogmodule_enabled); |
||||
sigIRC.config.setBoolean("Module_controller_Enabled", sigIRC.controllermodule_enabled); |
||||
sigIRC.config.setBoolean("Module_twitch_Enabled", sigIRC.twitchmodule_enabled); |
||||
sigIRC.config.setBoolean("Module_rabirace_Enabled", sigIRC.rabiracemodule_enabled); |
||||
sigIRC.config.setBoolean("Module_touhoumother_Enabled", sigIRC.touhoumothermodule_enabled); |
||||
switch ((String)updateType.getSelectedItem()) { |
||||
case "Automatically Update":{ |
||||
sigIRC.autoUpdateProgram = 0; |
||||
}break; |
||||
case "Notify when Update Available":{ |
||||
sigIRC.autoUpdateProgram = 1; |
||||
}break; |
||||
case "Never Update":{ |
||||
sigIRC.autoUpdateProgram = 2; |
||||
}break; |
||||
} |
||||
sigIRC.config.setInteger("Auto_Update_Program", sigIRC.autoUpdateProgram); |
||||
sigIRC.config.saveProperties(); |
||||
this.invalidate(); |
||||
}break; |
||||
} |
||||
} |
||||
|
||||
protected boolean AttemptConnection() { |
||||
Socket socket; |
||||
try { |
||||
socket = new Socket(sigIRC.server, 6667); |
||||
BufferedWriter writer = new BufferedWriter( |
||||
new OutputStreamWriter(socket.getOutputStream( ))); |
||||
BufferedReader reader = new BufferedReader( |
||||
new InputStreamReader(socket.getInputStream( ))); |
||||
|
||||
// Log on to the server.
|
||||
writer.write("PASS " + oauthTokenBox.getText() + "\r\n"); |
||||
writer.write("NICK " + nameBox.getText() + "\r\n"); |
||||
writer.flush( ); |
||||
return sigIRC.VerifyLogin(reader); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
class ModuleButton extends JToggleButton{ |
||||
String label = ""; |
||||
ModuleButton button; |
||||
public ModuleButton(String label) { |
||||
this.label = label; |
||||
this.button = this; |
||||
this.setBackground(Color.DARK_GRAY); |
||||
button.setForeground(Color.GRAY); |
||||
button.setIconTextGap(4); |
||||
button.setIcon(IntroDialog.deselected_icon); |
||||
button.setSelectedIcon(IntroDialog.selected_icon); |
||||
this.setText(label); |
||||
this.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
if (button.isSelected()) { |
||||
button.setForeground(Color.BLUE); |
||||
} |
||||
else { |
||||
button.setBackground(Color.DARK_GRAY); |
||||
button.setForeground(Color.GRAY); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,226 @@ |
||||
package sig.windows; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.net.MalformedURLException; |
||||
import java.net.UnknownHostException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JProgressBar; |
||||
|
||||
import org.json.JSONException; |
||||
import org.json.JSONObject; |
||||
|
||||
import sig.Emoticon; |
||||
import sig.FileManager; |
||||
import sig.sigIRC; |
||||
import sig.modules.RabiRace.Avatar; |
||||
import sig.modules.RabiRace.MemoryData; |
||||
import sig.utils.FileUtils; |
||||
|
||||
public class LoadingDialog extends JFrame{ |
||||
JProgressBar bar = new JProgressBar(); |
||||
List<FileManager> managers = new ArrayList<FileManager>(); |
||||
FakeFileManager programUpdate = new FakeFileManager("_FAKE_"); |
||||
FakeFileManager twitchEmoteUpdate = new FakeFileManager("_FAKE_"); |
||||
public JPanel panel; |
||||
public static List<TwitchEmoteDownload> emotes = new ArrayList<TwitchEmoteDownload>(); |
||||
|
||||
public LoadingDialog() { |
||||
sigIRC.loadingdialog = this; |
||||
panel = new JPanel(); |
||||
|
||||
managers.add(new FileManager("sigIRC/oauthToken.txt")); |
||||
managers.add(new FileManager("sigIRC/Emotes/",true)); |
||||
managers.add(new FileManager("sigIRC/subscribers.txt")); |
||||
managers.add(new FileManager("sigIRC/logs/",true)); |
||||
managers.add(new FileManager("sigIRC/sounds/",true)); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/",true)); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/unknown.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/characters",true)); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items",true)); |
||||
//managers.add(new FileManager("sigIRC/sounds/Glaceon_cry.wav")
|
||||
File follower_sounds_folder = new File(sigIRC.BASEDIR+"sigIRC/follower_sounds"); |
||||
if (!follower_sounds_folder.exists()) { |
||||
managers.add(new FileManager("sigIRC/follower_sounds/Glaceon_cry.wav")); |
||||
managers.add(new FileManager("sigIRC/follower_sounds/README.txt")); |
||||
} |
||||
managers.add(new FileManager("sigIRC/record")); |
||||
managers.add(new FileManager("sigIRC/glaceon_follower.png")); |
||||
managers.add(new FileManager("sigIRC/sigIRCicon.png")); |
||||
managers.add(new FileManager("sigIRC/icon_down_arrow.png")); |
||||
managers.add(new FileManager("sigIRC/icon_follower_count.png")); |
||||
managers.add(new FileManager("sigIRC/icon_up_arrow.png")); |
||||
managers.add(new FileManager("sigIRC/icon_uptime.png")); |
||||
managers.add(new FileManager("sigIRC/icon_viewers_count.png")); |
||||
managers.add(new FileManager("sigIRC/icon_views_count.png")); |
||||
managers.add(new FileManager("sigIRC/message_separator.png")); |
||||
managers.add(new FileManager("sigIRC/controller/2-way_axis.png")); |
||||
managers.add(new FileManager("sigIRC/controller/4-way_axis.png")); |
||||
managers.add(new FileManager("sigIRC/controller/controller_overlay.png")); |
||||
managers.add(new FileManager("sigIRC/controller/controller_template.png")); |
||||
managers.add(new FileManager("sigIRC/CP_Font.ttf")); |
||||
managers.add(new FileManager("kill.png")); |
||||
managers.add(new FileManager("memory")); |
||||
managers.add(new FileManager("swap.png")); |
||||
managers.add(new FileManager("update.png")); |
||||
managers.add(new FileManager("backcolor.png")); |
||||
managers.add(new FileManager("drag_bar.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/1.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/2.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/3.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/4.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/5.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/6.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/7.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/8.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/9.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/10.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/11.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/12.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/13.png")); |
||||
managers.add(new FileManager("sigIRC/Emotes/20.png")); |
||||
managers.add(programUpdate); |
||||
|
||||
if (sigIRC.rabiracemodule_enabled) { |
||||
for (MemoryData data : MemoryData.values()) { |
||||
//Attempt to fetch from server.
|
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/"+data.img_path)); |
||||
} |
||||
for (Avatar avatar : Avatar.values()) { |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/characters/"+avatar.fileName)); |
||||
} |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/easter_egg.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/health_up.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/mana_up.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/regen_up.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/pack_up.png")); |
||||
managers.add(new FileManager("sigIRC/rabi-ribi/items/attack_up.png")); |
||||
} |
||||
|
||||
if (!sigIRC.offlineMode) { |
||||
JSONObject twitchemotes; |
||||
try { |
||||
twitchemotes = FileUtils.readJsonFromUrl("https://twitchemotes.com/api_cache/v3/global.json"); |
||||
System.out.println("Twitch emote Json read."); |
||||
if (twitchemotes!=null) { |
||||
for (String emotes : twitchemotes.keySet()) { |
||||
JSONObject emote = twitchemotes.getJSONObject(emotes); |
||||
int id = emote.getInt("id"); |
||||
String name = emote.getString("code"); |
||||
LoadingDialog.emotes.add(new TwitchEmoteDownload(name,id)); |
||||
managers.add(new FakeFileManager("_FAKE_")); |
||||
//emoticons.add(new Emoticon(name, new URL(TWITCHEMOTEURL+id+"/1.0")));
|
||||
System.out.println("Emote "+id+" with name "+name); |
||||
} |
||||
} |
||||
} catch (NullPointerException | JSONException | IOException e) { |
||||
sigIRC.offlineMode=true; |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
bar.setValue(0); |
||||
bar.setMaximum(managers.size()); |
||||
bar.setPreferredSize(new Dimension(240,24)); |
||||
bar.setString("Downloading resources... (0/"+managers.size()+")"); |
||||
bar.setStringPainted(true); |
||||
|
||||
panel.setSize(new Dimension(260,30)); |
||||
|
||||
panel.add(bar); |
||||
|
||||
this.add(panel); |
||||
|
||||
this.setSize(new Dimension(260,36)); |
||||
this.setLocationByPlatform(true); |
||||
this.setMinimumSize(new Dimension(260, 36)); |
||||
this.setMaximumSize(new Dimension(260, 36)); |
||||
this.setUndecorated(true); |
||||
this.setVisible(true); |
||||
this.setAlwaysOnTop(true); |
||||
this.setFocusable(false); |
||||
|
||||
for (FileManager manager : managers) { |
||||
if (manager.verifyAndFetchFileFromServer()) { |
||||
bar.setValue(bar.getValue()+1); |
||||
UpdateBar(); |
||||
} |
||||
} |
||||
|
||||
for (TwitchEmoteDownload d : emotes) { |
||||
try { |
||||
if (!sigIRC.offlineMode) { |
||||
d.download(); |
||||
} |
||||
bar.setValue(bar.getValue()+1); |
||||
UpdateBar(); |
||||
} catch (MalformedURLException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
if (!sigIRC.offlineMode) { |
||||
sigIRC.prepareTwitchEmoteUpdate(); |
||||
} |
||||
twitchEmoteUpdate.setDone(); |
||||
bar.setValue(bar.getValue()+1); |
||||
UpdateBar(); |
||||
if (!sigIRC.offlineMode) { |
||||
sigIRC.DownloadProgramUpdate(); |
||||
} |
||||
programUpdate.setDone(); |
||||
bar.setValue(bar.getValue()+1); |
||||
UpdateBar(); |
||||
|
||||
sigIRC.emoticons.add(new Emoticon(":)","1")); |
||||
sigIRC.emoticons.add(new Emoticon(":(","2")); |
||||
sigIRC.emoticons.add(new Emoticon(":o","3")); |
||||
sigIRC.emoticons.add(new Emoticon(":O","3")); |
||||
sigIRC.emoticons.add(new Emoticon(":z","4")); |
||||
sigIRC.emoticons.add(new Emoticon(":Z","4")); |
||||
sigIRC.emoticons.add(new Emoticon("B)","5")); |
||||
sigIRC.emoticons.add(new Emoticon(":\\","6")); |
||||
sigIRC.emoticons.add(new Emoticon(":/","6")); |
||||
sigIRC.emoticons.add(new Emoticon(";)","7")); |
||||
sigIRC.emoticons.add(new Emoticon(";p","8")); |
||||
sigIRC.emoticons.add(new Emoticon(";P","8")); |
||||
sigIRC.emoticons.add(new Emoticon(":p","9")); |
||||
sigIRC.emoticons.add(new Emoticon(":P","9")); |
||||
sigIRC.emoticons.add(new Emoticon("R)","10")); |
||||
sigIRC.emoticons.add(new Emoticon("o_O","20")); |
||||
sigIRC.emoticons.add(new Emoticon("O_o","20")); |
||||
sigIRC.emoticons.add(new Emoticon(":D","11")); |
||||
sigIRC.emoticons.add(new Emoticon(">(","12")); |
||||
sigIRC.emoticons.add(new Emoticon("<3","13")); |
||||
|
||||
|
||||
try { |
||||
Thread.sleep(1000); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//Load is done. Start up the panel.
|
||||
sigIRC.window = new ProgramWindow(); |
||||
this.setVisible(false); |
||||
sigIRC.downloadsComplete=true; |
||||
} |
||||
|
||||
private void UpdateBar() { |
||||
bar.setString("Downloading resources... ("+bar.getValue()+"/"+managers.size()+")"); |
||||
} |
||||
} |
||||
|
||||
class FakeFileManager extends FileManager{ |
||||
boolean done=false; |
||||
public FakeFileManager(String location) { |
||||
super(location); |
||||
} |
||||
public void setDone() { |
||||
done=true; |
||||
} |
||||
} |
@ -0,0 +1,46 @@ |
||||
package sig.windows; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
|
||||
import javax.swing.JToggleButton; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
|
||||
import sig.Module; |
||||
|
||||
@SuppressWarnings("serial") |
||||
class ModuleSelectButton extends JToggleButton{ |
||||
String label = ""; |
||||
ModuleSelectButton button; |
||||
Module myModule; |
||||
public ModuleSelectButton(String label, Module module) { |
||||
this.label=label; |
||||
this.button=this; |
||||
this.myModule=module; |
||||
this.setBackground(Color.DARK_GRAY); |
||||
this.setText(label); |
||||
this.setToolTipText("Click to enable and disable the \n"+label+" module."); |
||||
this.setPreferredSize(new Dimension(160,56)); |
||||
this.setForeground(Color.GRAY); |
||||
this.setIconTextGap(4); |
||||
this.setSelectedIcon(ProgramWindow.selected_icon); |
||||
this.setIcon(ProgramWindow.deselected_icon); |
||||
this.setSelected(true); |
||||
button.setForeground(Color.BLUE); |
||||
this.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
if (button.isSelected()) { |
||||
button.setForeground(Color.BLUE); |
||||
} |
||||
else { |
||||
button.setBackground(Color.DARK_GRAY); |
||||
button.setForeground(Color.GRAY); |
||||
} |
||||
myModule.setVisible(button.isSelected()); |
||||
} |
||||
|
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
package sig.windows; |
||||
|
||||
public class ProgramText { |
||||
public static String intro_text = "Welcome to sigIRCv2!" |
||||
+ ""; |
||||
} |
@ -0,0 +1,169 @@ |
||||
package sig.windows; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.GridLayout; |
||||
import java.awt.Image; |
||||
import java.awt.MouseInfo; |
||||
import java.awt.Rectangle; |
||||
import java.awt.geom.Rectangle2D; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.swing.BoxLayout; |
||||
import javax.swing.Icon; |
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JFrame; |
||||
import javax.swing.JLabel; |
||||
|
||||
import javazoom.jlgui.basicplayer.BasicController; |
||||
import javazoom.jlgui.basicplayer.BasicPlayer; |
||||
import javazoom.jlgui.basicplayer.BasicPlayerEvent; |
||||
import javazoom.jlgui.basicplayer.BasicPlayerException; |
||||
import javazoom.jlgui.basicplayer.BasicPlayerListener; |
||||
import sig.BackgroundColorButton; |
||||
import sig.ColorPanel; |
||||
import sig.Module; |
||||
import sig.MyPanel; |
||||
import sig.sigIRC; |
||||
import sig.modules.ChatLogModule; |
||||
import sig.modules.RabiRaceModule; |
||||
import sig.modules.ScrollingChatModule; |
||||
|
||||
@SuppressWarnings("serial") |
||||
public class ProgramWindow extends JFrame{ |
||||
|
||||
public static Icon deselected_icon,selected_icon; |
||||
|
||||
List<ModuleSelectButton> buttons = new ArrayList<ModuleSelectButton>(); |
||||
|
||||
public int lastMouseX = 0; |
||||
|
||||
public int lastMouseY = 0; |
||||
|
||||
public static ProgramWindow frame; |
||||
|
||||
public ProgramWindow() { |
||||
ProgramWindow.frame=this; |
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
||||
scheduler.scheduleWithFixedDelay(()->{ |
||||
if (sigIRC.configNeedsUpdating>0 && |
||||
System.currentTimeMillis()-sigIRC.configNeedsUpdating>1000) { |
||||
sigIRC.config.saveProperties(); |
||||
sigIRC.configNeedsUpdating=0; |
||||
} |
||||
},1000,1000,TimeUnit.MILLISECONDS); |
||||
scheduler.scheduleWithFixedDelay(()->{ |
||||
lastMouseX = (int)(MouseInfo.getPointerInfo().getLocation().getX()); |
||||
lastMouseY = (int)(MouseInfo.getPointerInfo().getLocation().getY()); |
||||
},(long)((1d/(sigIRC.framerate+1))*1000),(long)((1d/(sigIRC.framerate+1))*1000),TimeUnit.MILLISECONDS); |
||||
|
||||
try { |
||||
sigIRC.programIcon = ImageIO.read(sigIRC.class.getResource("/resource/sigIRCicon.png")); |
||||
} catch (IOException e1) { |
||||
e1.printStackTrace(); |
||||
} |
||||
|
||||
try { |
||||
deselected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/deselected_button.png"))); |
||||
selected_icon = new ImageIcon(ImageIO.read(sigIRC.class.getResource("/resource/selected_button.png"))); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
if (sigIRC.overlayMode && sigIRC.showWindowControls) { |
||||
JFrame.setDefaultLookAndFeelDecorated(true); |
||||
} |
||||
System.setProperty("sun.java2d.opengl", Boolean.toString(sigIRC.hardwareAcceleration)); |
||||
System.setProperty("sun.java2d.d3d",Boolean.toString(true)); |
||||
JFrame f = new JFrame("sigIRCv2"); |
||||
this.setAutoRequestFocus(true); |
||||
this.toFront(); |
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
if (sigIRC.overlayMode && !sigIRC.showWindowControls) { |
||||
this.setUndecorated(true); |
||||
} |
||||
|
||||
|
||||
sigIRC.panel = new MyPanel(); |
||||
|
||||
JLabel myLabel = new JLabel("Module Control:"); |
||||
if (sigIRC.overlayMode) { |
||||
sigIRC.panel.setOpaque(false); |
||||
} |
||||
sigIRC.panel.setBackground(Color.BLACK); |
||||
myLabel.setBackground(sigIRC.panel.getBackground()); |
||||
myLabel.setForeground(Color.WHITE); |
||||
myLabel.setIcon(new ImageIcon(sigIRC.programIcon.getScaledInstance(48, 48, Image.SCALE_AREA_AVERAGING))); |
||||
|
||||
sigIRC.panel.add(myLabel); |
||||
|
||||
if (!sigIRC.disableChatMessages) { |
||||
ScrollingChatModule mod = new ScrollingChatModule(new Rectangle((int)sigIRC.scrollingchatmodule_X,(int)sigIRC.scrollingchatmodule_Y,(int)sigIRC.scrollingchatmodule_width,(int)sigIRC.scrollingchatmodule_height),"Scrolling Chat"); |
||||
ModuleSelectButton button = new ModuleSelectButton("Scrolling Chat",mod); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
if (sigIRC.chatlogmodule_enabled) { |
||||
ChatLogModule mod = new ChatLogModule(new Rectangle(sigIRC.chatlogmodule_X,sigIRC.chatlogmodule_Y,sigIRC.chatlogmodule_width,sigIRC.chatlogmodule_height),"Chat Log"); |
||||
ModuleSelectButton button = new ModuleSelectButton("Chat Log",mod); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
if (sigIRC.controllermodule_enabled) { |
||||
ModuleSelectButton button = new ModuleSelectButton("Controller",new Module(new Rectangle(0,0,0,0),"Test")); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
if (sigIRC.twitchmodule_enabled) { |
||||
ModuleSelectButton button = new ModuleSelectButton("Twitch",new Module(new Rectangle(0,0,0,0),"Test")); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
if (sigIRC.rabiracemodule_enabled) { |
||||
RabiRaceModule mod = new RabiRaceModule(new Rectangle((int)sigIRC.rabiracemodule_X,(int)sigIRC.rabiracemodule_Y,(int)sigIRC.rabiracemodule_width,(int)sigIRC.rabiracemodule_height),"Rabi Race"); |
||||
ModuleSelectButton button = new ModuleSelectButton("Rabi-Race",mod); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
if (sigIRC.touhoumothermodule_enabled) { |
||||
ModuleSelectButton button = new ModuleSelectButton("Touhou Mother",new Module(new Rectangle(0,0,0,0),"Test")); |
||||
sigIRC.panel.add(button); |
||||
} |
||||
GridLayout myLayout = new GridLayout(0,1); |
||||
sigIRC.panel.setLayout(myLayout); |
||||
|
||||
///Play MUSIC
|
||||
/*BasicPlayer player = new BasicPlayer(); |
||||
try { |
||||
player.open(new File("D:\\Videos\\4K Video Downloader\\3R2 - The Truth Never Spoken (Energetic Trance Mix).mp3")); |
||||
player.play(); |
||||
} catch (BasicPlayerException e) { |
||||
e.printStackTrace(); |
||||
}*/ |
||||
|
||||
//colorpanel = new ColorPanel();
|
||||
//this.add(colorpanel);
|
||||
this.setLocationByPlatform(true); |
||||
this.add(sigIRC.panel); |
||||
//this.pack();
|
||||
this.setSize(240, 640); |
||||
this.setVisible(true); |
||||
//this.setLocation(sigIRC.windowX, sigIRC.windowY);
|
||||
//this.setSize(sigIRC.windowWidth, sigIRC.windowHeight);
|
||||
|
||||
this.setIconImage(sigIRC.programIcon); |
||||
|
||||
// button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
|
||||
if (sigIRC.overlayMode) { |
||||
this.setBackground(new Color(0,0,0,0)); |
||||
this.setAlwaysOnTop(true); |
||||
} |
||||
//this.setOpacity(0.5f);
|
||||
//this.addWindowListener(sigIRC.panel);
|
||||
|
||||
//Module testMod = new Module(new Rectangle(0,0,640,480),"Test");
|
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
package sig.windows; |
||||
|
||||
import java.net.MalformedURLException; |
||||
import java.net.URL; |
||||
|
||||
import sig.Emoticon; |
||||
import sig.sigIRC; |
||||
|
||||
public class TwitchEmoteDownload { |
||||
String name; |
||||
int id; |
||||
|
||||
public TwitchEmoteDownload(String name,int id) { |
||||
this.name=name; |
||||
this.id=id; |
||||
} |
||||
|
||||
public void download() throws MalformedURLException { |
||||
sigIRC.emoticons.add(new Emoticon(name,new URL(sigIRC.TWITCHEMOTEURL+id+"/1.0"))); |
||||
} |
||||
} |
Loading…
Reference in new issue