Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Jan 23, 2021
0 parents commit bf74343
Show file tree
Hide file tree
Showing 12 changed files with 788 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java-scoreboard</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Shriansh Chari

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Java Scoreboard v1.3.1

This is a Java-based scoreboard for use in Open Broadcaster Software as a Score Board (in the vein of Score Board Edit by Zou).

It was initially built as a way for people unable to run SBE on their device (as it is based on the .NET framework), and as a way for me to practice programming Java. As such, the code is incomplete and can be improved.

It is primarily for use in streaming fighting game tournaments, and lets you change the score in the match, or change the players' names in between matches very easily.

## Changelog (from v1.3.02)
- Updated comments to show what each function actually does
- Renamed "Misc" and "Label" to "Tournament Name" and "Tournament Round"

## Prerequisites

Your computer should be running the latest version of the Java Development Kit to run this program. To check if you are running the latest JDK, enter the following command in your computer's command line:

```bash
javac -version
```

## Usage

### Windows

If you are running a Windows system, enter `Windows/Scoreboard` and execute `scoreboard.exe`.

Running the program will create the output folder as well as all of the necessary files in `Windows/Output`.

### Other Platforms

If you are running macOS, \*nix, or any other operating system, enter `Other Platforms/Scoreboard` and execute `scoreboard.jar`.

Running the program will create the output folder as well as all of the necessary files in `Other Platforms/Output`.

### Interaction with OBS

In OBS, in your scene, add a new text source. In its properties (which will probably pop up after you've created it), check the `Read from file` option. Then browse your files until you find the `Output` folder containing your files. Choose the TXT file you want OBS to read from and the text in OBS will automatically update as you update the TXT file.

### Interaction with Xsplit
Make sure that your Text plugin is updated by going into `Tools → My Plugins`.

Then, you add a Text source, check mark `Use Custom Script` and click the button labeled `Edit Script`. Make sure the template is set to `Load Text from Local File` and set the path to the TXT file of your choice and the text in XSplit will automatically update as you update the TXT file.

## What is there currently:

- Can support a name, score, and sponsor of two players, along with the tournament name/round

## To-do
- Add extra text boxes for "miscellaneous" and "label" files
- Being able to browse the user's computer to store the output files
13 changes: 13 additions & 0 deletions src/Driver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Driver
{
public static void main(String[] args) {
File_Creator fc = new File_Creator();
File_Writer fw = new File_Writer();

fc.createFiles();

fw.prepareXML("scores.xml");

ScoreboardMenu menu = new ScoreboardMenu();
}
}
53 changes: 53 additions & 0 deletions src/File_Creator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.io.*;
/*
* First function of the program that runs
* If the files don't already exist, then they are created
* Output folder, both players' tags, scores, and prefixes (as txt files)
*/
public class File_Creator
{
public void createFiles()
{
folderMaker("Output");

fileMaker("p1_tag.txt");
fileMaker("p2_tag.txt");
fileMaker("p1_score.txt");
fileMaker("p2_score.txt");
fileMaker("p1_prefix.txt");
fileMaker("p2_prefix.txt");
fileMaker("tourneyname.txt");
fileMaker("tourneyround.txt");

fileMaker("scores.xml");
}

/*
* Creates folders to store output in
*/
public void folderMaker(String foldername) {
File newfolder = new File("../" + foldername);
if (newfolder.mkdir()) {
System.out.println(foldername + " folder created");
} else {
System.out.println(foldername + " folder already exists");
}
}

/*
* Creates the files with the filetype included in filename
* Example: fileMaker("index.txt") generates index.txt file
*/
public void fileMaker(String filename) {
try {
File new_file = new File("../Output/" + filename);
if (new_file.createNewFile()) {
System.out.println(filename + " created");
} else {
System.out.println(filename + " already exists");
}
} catch (IOException e) {
System.out.println("An error occurred when making " + filename);
}
}
}
100 changes: 100 additions & 0 deletions src/File_Writer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import java.io.*;
/*
* Writes to the output files
* Not called FileWriter because that's
* already a Java class.
*/
public class File_Writer
{
private String xmlprep = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<score>\n" +
"\t<p1>\n" +
"\t\t<tag></tag>\n" +
"\t\t<prefix></prefix>\n" +
"\t\t<score>0</score>\n" +
"\t</p1>\n" +
"\t<p2>\n" +
"\t\t<tag></tag>\n" +
"\t\t<prefix></prefix>\n" +
"\t\t<score>0</score>\n" +
"\t</p2>\n" +
"\t<label></label>\n" +
"\t<misc></misc>\n" +
"</score>";

VarStorage vs = ScoreboardMenu.getVS();

public void writeToText(String filename, String input)
{
// put your code here
try {
FileWriter filetowrite = new FileWriter("../Output/" + filename);
filetowrite.write(input);
filetowrite.close();
System.out.println("Successfully wrote '" + input + "' to "
+ filename);
} catch (IOException e) {
System.out.println("An error occurred while trying to write to " + filename);
}
}

public void clearFile(String filename) {
try {
File toclear = new File("../Output/" + filename);
toclear.delete();
toclear.createNewFile();
System.out.println(filename + " successfully cleared");
} catch (IOException e) {
System.out.println("Uh-oh. Something went wrong when clearing "
+ filename);
}
}

public void updateFile(String filename, String input) {
clearFile(filename);
writeToText(filename, input);
}

public void prepareXML(String filename)
{
try {
FileWriter filetowrite = new FileWriter("../Output/" + filename);
filetowrite.write(xmlprep);
filetowrite.close();
System.out.println("Successfully prepared " + filename);
} catch (IOException e) {
System.out.println("An error occurred while trying to prepare " + filename);
}
}

public void updateXML() {
String p1tag = vs.getP1Tag();
String p1prefix = vs.getP1Prefix();
int p1score = vs.getP1Score();

String p2tag = vs.getP2Tag();
String p2prefix = vs.getP2Prefix();
int p2score = vs.getP2Score();

String tourneyname = vs.getTournament();
String tourneyround = vs.getRound();

xmlprep = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<score>\n" +
"\t<p1>\n" +
"\t\t<tag>" + p1tag + "</tag>\n" +
"\t\t<prefix>" + p1prefix + "</prefix>\n" +
"\t\t<score>" + p1score + "</score>\n" +
"\t</p1>\n" +
"\t<p2>\n" +
"\t\t<tag>" + p2tag + "</tag>\n" +
"\t\t<prefix>" + p2prefix + "</prefix>\n" +
"\t\t<score>" + p2score + "</score>\n" +
"\t</p2>\n" +
"\t<label>" + tourneyname + "</label>\n" +
"\t<misc>" + tourneyround + "</misc>\n" +
"</score>";

prepareXML("scores.xml");
}
}
Loading

0 comments on commit bf74343

Please sign in to comment.