Github API software updating fully implemented. Overlay color/alpha
control options added. Added ability to disable automatic software update. Fixed emoticon alignment bug for chat log viewer.
This commit is contained in:
parent
b3044fd600
commit
222de35e80
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
@ -53,7 +53,7 @@ public class Module {
|
||||
}
|
||||
|
||||
private void enableWindowDrag(int mouseX, int mouseY) {
|
||||
if (!dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) {
|
||||
if (!sigIRC.overlayMode && !dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) {
|
||||
//Enable dragging.
|
||||
dragOffset = new Point((int)position.getX() - mouseX,(int)position.getY()-mouseY);
|
||||
dragging=DRAGGING=true;
|
||||
@ -87,6 +87,7 @@ public class Module {
|
||||
}
|
||||
|
||||
private void modifyCursor() {
|
||||
if (!sigIRC.overlayMode) {
|
||||
int cursortype = sigIRC.panel.getCursor().getType();
|
||||
if (inDragZone &&
|
||||
cursortype!=Cursor.MOVE_CURSOR) {
|
||||
@ -96,6 +97,7 @@ public class Module {
|
||||
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dragWindow() {
|
||||
if (dragging) {
|
||||
@ -135,6 +137,7 @@ public class Module {
|
||||
}
|
||||
|
||||
private void drawModuleHeader(Graphics g) {
|
||||
if (!sigIRC.overlayMode) {
|
||||
g.drawImage(Module.IMG_DRAGBAR,
|
||||
(int)position.getX()+2,
|
||||
(int)position.getY()-Module.IMG_DRAGBAR.getHeight(),
|
||||
@ -143,6 +146,7 @@ public class Module {
|
||||
sigIRC.panel);
|
||||
DrawUtils.drawTextFont(g, sigIRC.panel.smallFont, (int)position.getX(), (int)position.getY()-titleHeight/2+4, Color.BLACK, this.name);
|
||||
}
|
||||
}
|
||||
|
||||
private Rectangle2D getDrawBounds() {
|
||||
Rectangle2D drawBounds = new Rectangle((int)position.getX(),(int)position.getY()-titleHeight+3,(int)position.getWidth(),(int)position.getHeight()+titleHeight);
|
||||
|
@ -81,6 +81,9 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
||||
lastMouseY = -1;
|
||||
}*/
|
||||
//
|
||||
for (Module m : sigIRC.modules) {
|
||||
m.draw(g);
|
||||
}
|
||||
for (int i=0;i<sigIRC.textobj.size();i++) {
|
||||
if (sigIRC.textobj.get(i).isActive()) {
|
||||
if (sigIRC.overlayMode) {
|
||||
@ -96,9 +99,6 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Module m : sigIRC.modules) {
|
||||
m.draw(g);
|
||||
}
|
||||
for (int i=0;i<sigIRC.chatlogtwitchemoticons.size();i++) {
|
||||
if (sigIRC.chatlogtwitchemoticons.get(i).textRefIsVisible()) {
|
||||
sigIRC.chatlogtwitchemoticons.get(i).draw(g);
|
||||
@ -226,12 +226,14 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
||||
m.windowClosed(ev);
|
||||
}
|
||||
sigIRC.config.saveProperties();
|
||||
if (sigIRC.autoUpdateProgram) {
|
||||
try {
|
||||
FileUtils.copyFile(new File(sigIRC.PROGRAM_UPDATE_FILE), new File(sigIRC.BASEDIR+"sigIRCv2.jar"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent ev) {
|
||||
|
@ -43,17 +43,17 @@ public class ChatLogMessage {
|
||||
}
|
||||
this.position.setLocation(this.position.getX(), this.position.getY()-messageDisplaySize.getY()+ChatLogModule.chatlogmodule.scrolllog_yoffset);
|
||||
//System.out.println(displayMessage);
|
||||
DetectUsername(displayMessage);
|
||||
this.username = DetectUsername(displayMessage);
|
||||
if (this.username!=null) {
|
||||
displayMessage.set(0,GetMessage(displayMessage.get(0)));
|
||||
displayMessage.set(0,GetMessage(displayMessage.get(0)+" "));
|
||||
usernameWidth = (int)TextUtils.calculateStringBoundsFont(this.username, sigIRC.panel.userFont).getWidth();
|
||||
}
|
||||
for (int i=0;i<displayMessage.size();i++) {
|
||||
displayMessage.set(i, ReplaceMessageWithEmoticons(displayMessage.get(i)+" ",i*MESSAGE_SPACING));
|
||||
displayMessage.set(i, ReplaceMessageWithEmoticons(displayMessage.get(i)+" ",(i==0)?usernameWidth:0,i*MESSAGE_SPACING));
|
||||
}
|
||||
}
|
||||
|
||||
private String ReplaceMessageWithEmoticons(String basemsg, int ypos) {
|
||||
private String ReplaceMessageWithEmoticons(String basemsg, int xpos, int ypos) {
|
||||
int marker = basemsg.indexOf(" ");
|
||||
while (marker<basemsg.length()) {
|
||||
//Find a space.
|
||||
@ -64,7 +64,7 @@ public class ChatLogMessage {
|
||||
sigIRC.emoticons.addAll(sigIRC.emoticon_queue);
|
||||
sigIRC.emoticon_queue.clear();
|
||||
for (Emoticon e : sigIRC.emoticons) {
|
||||
//System.out.println("Checking for emoticon "+e.getEmoteName());
|
||||
//System.out.println("Checking for emoticon "+e.getEmoteName()+" vs \""+word+"\"");
|
||||
try {
|
||||
if (e.getEmoteName().equals(word)) {
|
||||
if (e instanceof SubEmoticon) {
|
||||
@ -76,7 +76,7 @@ public class ChatLogMessage {
|
||||
}
|
||||
//System.out.println(" Found one!");
|
||||
basemsg = TextUtils.replaceFirst(basemsg, e.getEmoteName(), e.getSmallSpaceFiller());
|
||||
GenerateEmoticon(marker+1, ypos, basemsg, e);
|
||||
GenerateEmoticon(marker+1, xpos, ypos, basemsg, e);
|
||||
space = basemsg.indexOf(" ", marker+1);
|
||||
break;
|
||||
}
|
||||
@ -94,11 +94,12 @@ public class ChatLogMessage {
|
||||
return basemsg;
|
||||
}
|
||||
|
||||
private void GenerateEmoticon(int textpos, int ypos, String basemsg, Emoticon e) {
|
||||
private void GenerateEmoticon(int textpos, int xpos, int ypos, String basemsg, Emoticon e) {
|
||||
String cutstring = basemsg.substring(0, textpos);
|
||||
double width = TextUtils.calculateStringBoundsFont(cutstring, sigIRC.panel.userFont).getWidth();
|
||||
//System.out.println("Width of '"+cutstring+"' is "+width);
|
||||
sigIRC.createEmoticon(e, this, (int)(width), ypos+16);
|
||||
//System.out.println("Offsetting emote by "+xpos+"+"+width);
|
||||
sigIRC.createEmoticon(e, this, (int)(xpos+width), ypos+16);
|
||||
//textMaxHeight = Math.max(textMaxHeight, e.getImage().getHeight());
|
||||
//textMaxWidth = (int)(width + e.getImage().getWidth()+1);
|
||||
}
|
||||
@ -107,16 +108,17 @@ public class ChatLogMessage {
|
||||
String basemsg = " "+msg.substring(msg.indexOf(":")+2, msg.length())+" ";
|
||||
//basemsg = ConvertMessageSymbols(basemsg);
|
||||
//basemsg = ReplaceMessageWithEmoticons(basemsg);
|
||||
return basemsg.replaceFirst(" ", "").substring(0,basemsg.length()-1);
|
||||
return basemsg.substring(0,basemsg.length()-1);
|
||||
}
|
||||
|
||||
private void DetectUsername(List<String> messages) {
|
||||
private String DetectUsername(List<String> messages) {
|
||||
if (messages.size()>0) {
|
||||
String username = GetUsername(messages.get(0));
|
||||
if (username!=null) {
|
||||
this.username = username;
|
||||
return username;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Color GetUserNameColor(String username) {
|
||||
@ -221,12 +223,14 @@ public class ChatLogMessage {
|
||||
|
||||
public static void importMessages(String...logContents) {
|
||||
for (String s : logContents) {
|
||||
if (s!=null) {
|
||||
if (ChatLogModule.chatlogmodule.messageHistory.size()>=ChatLogModule.messageHistoryCount) {
|
||||
ChatLogModule.chatlogmodule.messageHistory.remove(0).cleanup();
|
||||
}
|
||||
ChatLogModule.chatlogmodule.messageHistory.add(new ChatLogMessage(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
active=false;
|
||||
|
@ -18,6 +18,7 @@ import javax.swing.SwingUtilities;
|
||||
import sig.Module;
|
||||
import sig.sigIRC;
|
||||
import sig.modules.ChatLog.ChatLogMessage;
|
||||
import sig.utils.DrawUtils;
|
||||
import sig.utils.FileUtils;
|
||||
|
||||
public class ChatLogModule extends Module{
|
||||
@ -27,11 +28,13 @@ public class ChatLogModule extends Module{
|
||||
boolean initialized=false;
|
||||
public static ChatLogModule chatlogmodule;
|
||||
public int scrolllog_yoffset = 0;
|
||||
public Color backgroundColor;
|
||||
|
||||
public ChatLogModule(Rectangle2D bounds, String moduleName) {
|
||||
super(bounds, moduleName);
|
||||
//Initialize();
|
||||
chatlogmodule = this;
|
||||
backgroundColor = DrawUtils.convertStringToColor(sigIRC.chatlogmodule_backgroundColor);
|
||||
}
|
||||
|
||||
private void Initialize() {
|
||||
@ -72,7 +75,7 @@ public class ChatLogModule extends Module{
|
||||
|
||||
public void draw(Graphics g) {
|
||||
super.draw(g);
|
||||
g.setColor(new Color(195,195,195,255));
|
||||
g.setColor(backgroundColor);
|
||||
g.fill3DRect((int)position.getX(), (int)position.getY(), (int)position.getWidth(), (int)position.getHeight(), true);
|
||||
g.setColor(Color.BLACK);
|
||||
for (int i=0; i<messageHistory.size();i++) {
|
||||
|
@ -119,6 +119,7 @@ public class sigIRC{
|
||||
public static String twitchmodule_newfollowerImgBackgroundColor="90,90,90";
|
||||
public static String twitchmodule_newfollowerShadowTextColor="26,90,150";
|
||||
public static String twitchmodule_newfollowerTextColor="255,255,255";
|
||||
public static String chatlogmodule_backgroundColor="195,195,195,255";
|
||||
public static int twitchmodule_newfollowerImgLogoSize=32;
|
||||
public static boolean testMode=false;
|
||||
public final static String TWITCHEMOTEURL = "https://static-cdn.jtvnw.net/emoticons/v1/";
|
||||
@ -182,6 +183,7 @@ public class sigIRC{
|
||||
chatlogmodule_Y = config.getInteger("CHATLOG_module_Y",312);
|
||||
chatlogmodule_width = config.getInteger("CHATLOG_module_width",320);
|
||||
chatlogmodule_height = config.getInteger("CHATLOG_module_height",312);
|
||||
chatlogmodule_backgroundColor = config.getProperty("CHATLOG_module_BackgroundColor", "195,195,195,255");
|
||||
chatlogMessageHistory = config.getInteger("CHATLOG_module_MessageHistory",50);
|
||||
hardwareAcceleration = config.getBoolean("hardware_acceleration",true);
|
||||
autoUpdateProgram = config.getBoolean("Automatically_Update_Program", true);
|
||||
@ -229,7 +231,7 @@ public class sigIRC{
|
||||
public static void DownloadAllRequiredDependencies() {
|
||||
FileManager manager = new FileManager("sigIRC/oauthToken.txt"); manager.verifyAndFetchFileFromServer();
|
||||
manager = new FileManager("sigIRC/Emotes/",true); manager.verifyAndFetchFileFromServer();
|
||||
manager = new FileManager("sigIRC/Emotes/subscribers.txt"); manager.verifyAndFetchFileFromServer();
|
||||
manager = new FileManager("sigIRC/subscribers.txt"); manager.verifyAndFetchFileFromServer();
|
||||
manager = new FileManager("sigIRC/logs/",true); manager.verifyAndFetchFileFromServer();
|
||||
manager = new FileManager("sigIRC/sounds/",true); manager.verifyAndFetchFileFromServer();
|
||||
//manager = new FileManager("sigIRC/sounds/Glaceon_cry.wav"); manager.verifyAndFetchFileFromServer();
|
||||
@ -270,6 +272,7 @@ public class sigIRC{
|
||||
long fileSize = GithubUtils.getSizeOfFileFromLatestGithubCommit("sigIRCv2.jar");
|
||||
System.out.println("File size on Github is "+fileSize);
|
||||
if (fileSize!=programFile.length()) {
|
||||
System.out.println("File size on Github varies from currently running program... Downloading new program.");
|
||||
try {
|
||||
if (programFile.exists()) {
|
||||
programFile.delete();
|
||||
@ -404,7 +407,7 @@ public class sigIRC{
|
||||
System.out.println("Emote "+id+" with name "+name);
|
||||
}
|
||||
//System.out.println("Subscriber object: "+subemotes);
|
||||
String[] channel_names = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/Emotes/subscribers.txt");
|
||||
String[] channel_names = FileUtils.readFromFile(sigIRC.BASEDIR+"sigIRC/subscribers.txt");
|
||||
subchannelCount = channel_names.length;
|
||||
//System.out.println("Expecting "+subchannelCount+" Channel IDs.");
|
||||
for (String s : channel_names) {
|
||||
|
@ -70,4 +70,24 @@ public class DrawUtils {
|
||||
Rectangle2D textBounds = TextUtils.calculateStringBoundsFont(text, font);
|
||||
g.drawString(as.getIterator(),(int)(x-textBounds.getWidth()/2),(int)(y+textBounds.getHeight()));
|
||||
}
|
||||
|
||||
public static Color convertStringToColor(String s) {
|
||||
String[] split = s.split(",");
|
||||
if (split.length==3) {
|
||||
return new Color(
|
||||
Math.min(Math.abs(Integer.parseInt(split[0])),255),
|
||||
Math.min(Math.abs(Integer.parseInt(split[1])),255),
|
||||
Math.min(Math.abs(Integer.parseInt(split[2])),255));
|
||||
} else
|
||||
if (split.length==4) {
|
||||
return new Color(
|
||||
Math.min(Math.abs(Integer.parseInt(split[0])),255),
|
||||
Math.min(Math.abs(Integer.parseInt(split[1])),255),
|
||||
Math.min(Math.abs(Integer.parseInt(split[2])),255),
|
||||
Math.min(Math.abs(Integer.parseInt(split[3])),255));
|
||||
} else {
|
||||
System.out.println("WARNING! Invalid Color string specified ("+s+").");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user