├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── CMakeSettings.json
├── ISSUE_TEMPLATE.md
├── LICENCE
├── README.md
├── imgui
├── .gitignore
└── CMakeLists.txt
├── minhook
├── .gitignore
└── CMakeLists.txt
├── osumer-daemon
├── .gitignore
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── github
│ │ └── mob41
│ │ └── osumer
│ │ └── daemon
│ │ ├── Daemon.java
│ │ ├── Main.java
│ │ └── OverlayThread.java
│ └── resources
│ └── trayIcon.png
├── osumer-debugdump
├── .gitignore
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── mob41
│ └── osumer
│ └── debug
│ ├── DebugDump.java
│ ├── DumpManager.java
│ ├── NotReportedFilter.java
│ ├── ResettableGauge.java
│ └── WithDumpException.java
├── osumer-installer
├── .gitignore
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── mob41
│ └── osumer
│ └── installer
│ └── Installer.java
├── osumer-jni
├── .gitignore
├── CMakeLists.txt
├── com_github_mob41_osumer_OsumerNative.cpp
├── com_github_mob41_osumer_OsumerNative.h
├── dllmain.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── osumer-launcher
├── .gitignore
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── mob41
│ └── osumer
│ └── launcher
│ ├── ArgParser.java
│ └── Main.java
├── osumer-lib
├── .gitignore
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── mob41
│ └── osumer
│ ├── Configuration.java
│ ├── Osumer.java
│ ├── OsumerNative.java
│ ├── exceptions
│ ├── ErrorDumpDialog.java
│ ├── InvalidSourceIntegerException.java
│ ├── NoBuildsForVersionException.java
│ ├── NoSuchBuildNumberException.java
│ ├── NoSuchSourceException.java
│ ├── NoSuchVersionException.java
│ └── OsuException.java
│ ├── io
│ ├── Downloader.java
│ ├── OsuDownloader.java
│ └── URLDownloader.java
│ ├── method
│ ├── ErrorCode.java
│ └── MethodResult.java
│ ├── queue
│ ├── Queue.java
│ ├── QueueAction.java
│ ├── QueueManager.java
│ ├── QueueStatus.java
│ └── actions
│ │ ├── AfterSoundAction.java
│ │ ├── BeatmapImportAction.java
│ │ ├── BeforeSoundAction.java
│ │ ├── CustomImportAction.java
│ │ └── UpdaterRunAction.java
│ ├── rmi
│ ├── IDaemon.java
│ ├── IUI.java
│ └── OverlayRmi.java
│ └── updater
│ ├── Announcement.java
│ ├── AnnouncementChecker.java
│ ├── UpdateInfo.java
│ ├── Updater.java
│ └── VersionInfo.java
├── osumer-overlay
├── .gitignore
├── CMakeLists.txt
├── dllmain.cpp
├── osumeroverlay.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── osumer-setup
├── .gitignore
├── osumer-setup.sln
├── osumer-setup.vdproj
├── vc10redist_x86.exe
└── vc15redist_x86.exe
├── osumer-ui
├── .gitignore
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── github
│ │ └── mob41
│ │ └── osumer
│ │ └── ui
│ │ ├── AppMain.java
│ │ ├── BeatmapPreviewDialogController.java
│ │ ├── LoginDialogController.java
│ │ ├── MainController.java
│ │ ├── PreferencesController.java
│ │ ├── ProgressDialogController.java
│ │ ├── QueueController.java
│ │ └── UI.java
│ └── resources
│ ├── css
│ └── application.css
│ ├── image
│ ├── osumerIcon_128px.png
│ ├── osumerIcon_16px.png
│ ├── osumerIcon_256px.png
│ ├── osumerIcon_32px.png
│ └── osumerIcon_64px.png
│ └── view
│ ├── BeatmapPreviewDialogLayout.fxml
│ ├── LoginDialogLayout.fxml
│ ├── PreferencesLayout.fxml
│ ├── ProgressDialogLayout.fxml
│ ├── QueueLayout.fxml
│ └── RootLayout.fxml
├── osumer.sln
├── osums-api
├── .gitignore
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── mob41
│ └── osums
│ ├── Osums.java
│ ├── OsumsNewParser.java
│ ├── OsumsOldParser.java
│ ├── beatmap
│ ├── OsuBeatmap.java
│ └── OsuSong.java
│ └── search
│ ├── RankFilter.java
│ ├── SearchFilter.java
│ ├── SearchResult.java
│ ├── SongResult.java
│ └── StringRankFilter.java
├── osums-server
├── .gitignore
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── github
│ │ └── mob41
│ │ └── osums
│ │ └── server
│ │ ├── Main.java
│ │ ├── OsumsServer.java
│ │ ├── QueryOutput.java
│ │ └── QueryServlet.java
│ └── resources
│ ├── log4j.properties
│ └── osums.sql
├── pom.xml
└── src
└── main
└── resources
└── osumerIcon_128px.ico
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | .vs/*
3 | .idea
4 | .project
5 | .classpath
6 | .settings
7 | .settings/*
8 | **/target/
9 | /target/
10 | *.iml
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "gl3w"]
2 | path = gl3w
3 | url = https://github.com/skaslev/gl3w.git
4 | [submodule "minhook/minhook"]
5 | path = minhook/minhook
6 | url = https://github.com/TsudaKageyu/minhook.git
7 | [submodule "imgui/imgui"]
8 | path = imgui/imgui
9 | url = https://github.com/ocornut/imgui.git
10 | [submodule "osumer-jre"]
11 | path = osumer-jre
12 | url = https://github.com/mob41/osumer-jre.git
13 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required (VERSION 3.0)
2 |
3 | project("osumer-native")
4 |
5 | set(JAVA_HOME "C:\\Program Files (x86)\\Java\\jdk1.8.0_311")
6 | set(DIRECTX_SDK "C:\\Program Files (x86)\\Microsoft DirectX SDK (June 2010)")
7 | #find_package(JNI REQUIRED)
8 |
9 | #include_directories(${JNI_INCLUDE_DIRS})
10 | include_directories("${JAVA_HOME}/include")
11 | include_directories("${JAVA_HOME}/include/win32")
12 | file(GLOB JNI_LIBRARIES "${JAVA_HOME}/lib/*.lib")
13 |
14 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/minhook/minhook/include")
15 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui")
16 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui/examples")
17 |
18 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWINVER=0x0601 /D_WIN32_WINNT=0x0601")
19 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/target")
20 |
21 | add_subdirectory(gl3w)
22 | add_subdirectory(minhook)
23 | add_subdirectory(imgui)
24 | add_subdirectory(osumer-jni)
25 | add_subdirectory(osumer-overlay)
--------------------------------------------------------------------------------
/CMakeSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "x86-Debug",
5 | "generator": "Ninja",
6 | "configurationType": "Debug",
7 | "inheritEnvironments": [
8 | "msvc_x86"
9 | ],
10 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
11 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
12 | "cmakeCommandArgs": "",
13 | "buildCommandArgs": "-v",
14 | "ctestCommandArgs": ""
15 | },
16 | {
17 | "name": "x86-Release",
18 | "generator": "Ninja",
19 | "configurationType": "Release",
20 | "inheritEnvironments": [
21 | "msvc_x86"
22 | ],
23 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
24 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
25 | "cmakeCommandArgs": "",
26 | "buildCommandArgs": "-v",
27 | "ctestCommandArgs": ""
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | ### My environment
21 |
22 |
23 | - My operating system: *OS Here*
24 |
25 |
26 | - My Java Version: *Java version here*
27 |
28 | ### About my issue
29 |
30 |
31 | ### Dump files
32 |
39 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 mob41
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/imgui/.gitignore:
--------------------------------------------------------------------------------
1 | cmake_install.cmake
2 | CMakeFiles
3 | CMakeFiles/*
--------------------------------------------------------------------------------
/imgui/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | file(GLOB ROOT_SOURCES imgui/*.cpp)
2 |
3 | add_library(imgui STATIC ${ROOT_SOURCES} imgui/examples/imgui_impl_opengl3.cpp imgui/examples/imgui_impl_win32.cpp)
4 |
5 | target_link_libraries(imgui gl3w)
6 | target_link_libraries(imgui "${DIRECTX_SDK}/Lib/x86/XInput.lib")
7 |
8 | add_dependencies(imgui gl3w)
--------------------------------------------------------------------------------
/minhook/.gitignore:
--------------------------------------------------------------------------------
1 | cmake_install.cmake
2 | CMakeFiles
3 | CMakeFiles/*
--------------------------------------------------------------------------------
/minhook/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | file(GLOB ROOT_SOURCES minhook/src/*.c)
2 | file(GLOB HDE_SOURCES minhook/src/hde/*.c)
3 |
4 | add_library(minhook STATIC ${ROOT_SOURCES} ${HDE_SOURCES})
--------------------------------------------------------------------------------
/osumer-daemon/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-daemon/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osumer-daemon
9 |
10 |
11 | com.github.mob41
12 | osumer-lib
13 | ${global.version}
14 |
15 |
16 | com.github.mob41
17 | osums-api
18 | ${global.version}
19 |
20 |
21 | com.github.mob41
22 | osumer-debugdump
23 | ${global.version}
24 |
25 |
26 |
27 |
28 |
29 | org.apache.maven.plugins
30 | maven-dependency-plugin
31 |
32 |
33 | copy-dependencies
34 | prepare-package
35 |
36 | copy-dependencies
37 |
38 |
39 | ${project.parent.build.directory}/lib
40 | false
41 | false
42 | true
43 |
44 |
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-jar-plugin
50 |
51 | ${project.parent.build.directory}
52 |
53 |
54 | true
55 | lib/
56 | com.github.mob41.osumer.daemon.Main
57 |
58 |
59 |
60 |
61 |
62 | com.akathist.maven.plugins.launch4j
63 | launch4j-maven-plugin
64 |
65 |
66 | l4j-gui
67 | package
68 | launch4j
69 |
70 | gui
71 | ${project.parent.build.directory}/${project.artifactId}.exe
72 | ${project.parent.build.directory}/${project.artifactId}-${global.version}.jar
73 | osumer2
74 | https://github.com/mob41/osumer/issues/new
75 |
76 | com.github.mob41.osumer.daemon.Main
77 | false
78 | anything
79 |
80 |
81 | jre
82 | 1.8.0
83 | 32
84 | 64
85 | 128
86 |
87 |
88 | ${global.generation}.${global.build}
89 | ${global.version}
90 | osumer2 Daemon
91 | Copyright (c) 2019 mob41
92 | ${global.generation}.${global.build}
93 | ${global.version}
94 | osumer2 Daemon
95 | osumer-daemon
96 | osumer-daemon.exe
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/osumer-daemon/src/main/java/com/github/mob41/osumer/daemon/Main.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.daemon;
2 |
3 | import java.awt.GraphicsEnvironment;
4 | import java.io.IOException;
5 | import java.rmi.Naming;
6 | import java.rmi.registry.LocateRegistry;
7 |
8 | import javax.swing.JOptionPane;
9 |
10 | import com.codahale.metrics.MetricRegistry;
11 | import com.github.mob41.osumer.Configuration;
12 | import com.github.mob41.osumer.Osumer;
13 | import com.github.mob41.osumer.debug.DumpManager;
14 |
15 | import javafx.embed.swing.JFXPanel;
16 |
17 | public class Main {
18 |
19 | public static final int DEFAULT_PORT = 46726; //Old version uses 46725, increased by 1 to avoid problems
20 |
21 | public static void main(String[] args) {
22 | try {
23 | DumpManager.init(Osumer.getVersionString(), Osumer.getVersionString());
24 | } catch (IOException e2) {
25 | e2.printStackTrace();
26 | System.err.println("DumpManager: Error initializing dump manager");
27 | }
28 |
29 | String configPath = Osumer.isWindows() ? System.getenv("localappdata") + "\\osumerExpress" : "";
30 |
31 | Configuration config = new Configuration(configPath, Configuration.DEFAULT_DATA_FILE_NAME);
32 |
33 | try {
34 | config.load();
35 | } catch (IOException e1) {
36 | System.err.println("Unable to load configuration");
37 | e1.printStackTrace();
38 |
39 | if (!GraphicsEnvironment.isHeadless()) {
40 | JOptionPane.showMessageDialog(null, "Could not load configuration: " + e1, "Configuration Error",
41 | JOptionPane.ERROR_MESSAGE);
42 | }
43 |
44 | System.exit(-1);
45 | return;
46 | }
47 |
48 | //Initialize JXToolkit
49 | new JFXPanel();
50 |
51 | int port = DEFAULT_PORT; //TODO: Port to config
52 |
53 | try {
54 | LocateRegistry.createRegistry(port);
55 |
56 | Daemon daemon = new Daemon(config);
57 | Naming.bind("rmi://localhost:" + port + "/daemon", daemon);
58 |
59 | DumpManager.reportEvent("active", "daemon");
60 | } catch (Exception e) {
61 | e.printStackTrace();
62 | System.exit(-1);
63 | return;
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/osumer-daemon/src/main/java/com/github/mob41/osumer/daemon/OverlayThread.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.daemon;
2 |
3 | import com.github.mob41.osumer.Configuration;
4 | import com.github.mob41.osumer.OsumerNative;
5 | import com.github.mob41.osumer.debug.DebugDump;
6 | import com.github.mob41.osumer.debug.DumpManager;
7 |
8 | public class OverlayThread extends Thread{
9 |
10 | private final Configuration config;
11 |
12 | public OverlayThread(Configuration config) {
13 | super();
14 | this.config = config;
15 | }
16 |
17 | @Override
18 | public void run() {
19 | while (!this.isInterrupted()) {
20 | if (config.isOverlayEnabled()) {
21 | try {
22 | OsumerNative.injectOverlay();
23 | } catch (Throwable e) {
24 | DumpManager.addDump(new DebugDump(null, "Check is overlay enabled in configuration", "Ask native DLL to look for osu! for injection", "Sleep for 2500 ms", "Error calling DLL", false, e));
25 | break;
26 | }
27 | }
28 |
29 | try {
30 | Thread.sleep(2500);
31 | } catch (InterruptedException ignore) {
32 | break;
33 | }
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/osumer-daemon/src/main/resources/trayIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-daemon/src/main/resources/trayIcon.png
--------------------------------------------------------------------------------
/osumer-debugdump/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-debugdump/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osumer-debugdump
9 |
10 |
11 | commons-codec
12 | commons-codec
13 | 1.10
14 |
15 |
16 | io.dropwizard.metrics
17 | metrics-core
18 | ${metrics.version}
19 |
20 |
21 | io.dropwizard.metrics
22 | metrics-graphite
23 | ${metrics.version}
24 |
25 |
26 | io.dropwizard.metrics
27 | metrics-jvm
28 | ${metrics.version}
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-dependency-plugin
36 |
37 |
38 | copy-dependencies
39 | prepare-package
40 |
41 | copy-dependencies
42 |
43 |
44 | ${project.parent.build.directory}/lib
45 | false
46 | false
47 | true
48 |
49 |
50 |
51 |
52 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/osumer-debugdump/src/main/java/com/github/mob41/osumer/debug/DebugDump.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 Anthony Law
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *******************************************************************************/
24 | package com.github.mob41.osumer.debug;
25 |
26 | import java.io.IOException;
27 | import java.io.PrintWriter;
28 | import java.io.StringWriter;
29 | import java.security.SecureRandom;
30 | import java.util.Calendar;
31 |
32 | import org.apache.commons.codec.binary.Hex;
33 |
34 | public class DebugDump {
35 |
36 | private final String os;
37 |
38 | private final String osumerVersion;
39 |
40 | private final String debuggerVersion;
41 |
42 | private final String message;
43 |
44 | private final String uid;
45 |
46 | private final long generated;
47 |
48 | private final boolean containsPrivateData;
49 |
50 | private final String generated_human;
51 |
52 | private final String stacktrace;
53 |
54 | private final String specified_data;
55 |
56 | private final String exceptionClass;
57 |
58 | private final String lastoperation;
59 |
60 | private final String thisoperation;
61 |
62 | private final String nextoperation;
63 |
64 | public DebugDump(String specified_data, String last_op, String this_op, String next_op, boolean containsPrivateData, String message){
65 | this(specified_data, last_op, this_op, next_op, message, containsPrivateData, null);
66 | }
67 |
68 | public DebugDump(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData, Throwable e) {
69 | os = System.getProperty("os.name");
70 | osumerVersion = DumpManager.getOsumerVersion();
71 | debuggerVersion = DumpManager.getDebuggerVersion();
72 |
73 | Calendar cal = Calendar.getInstance();
74 |
75 | byte[] randuid = new byte[128/8];
76 | new SecureRandom().nextBytes(randuid);
77 | uid = Hex.encodeHexString(randuid);
78 |
79 | generated = cal.getTimeInMillis();
80 | generated_human = cal.getTime().toString();
81 |
82 | if (e != null){
83 | StringWriter sw = new StringWriter();
84 | PrintWriter pw = new PrintWriter(sw);
85 | e.printStackTrace(pw);
86 | pw.close();
87 |
88 | stacktrace = sw.toString();
89 | exceptionClass = e.getClass().getCanonicalName();
90 | } else {
91 | stacktrace = null;
92 | exceptionClass = null;
93 | }
94 |
95 | this.message = message;
96 |
97 | this.containsPrivateData = containsPrivateData;
98 | this.specified_data = specified_data;
99 | this.lastoperation = last_op;
100 | this.thisoperation = this_op;
101 | this.nextoperation = next_op;
102 |
103 | try {
104 | DumpManager.writeDump(this);
105 | } catch (IOException e1) {
106 | e1.printStackTrace();
107 | System.err.println("DumpManager: Error writing dump");
108 | }
109 | }
110 |
111 | public String getOs(){
112 | return os;
113 | }
114 |
115 | public long getGenerated(){
116 | return generated;
117 | }
118 |
119 | @Override
120 | public String toString(){
121 | return "===!===!===!===!-osumer-debugger-dump-!===!===!===!===\n" +
122 | "Debug information generated on " + generated_human + " (" + generated + " ms)\n" +
123 | "osumerDebugger v." + debuggerVersion + "\n" +
124 | "osumer v." + osumerVersion + "\n" +
125 | "\n" +
126 | "O/S Name: " + os + "\n" +
127 | "\n" +
128 | "Current operation: " + thisoperation + "\n" +
129 | "Returned message: " + message + "\n" +
130 | "\n" +
131 | "Last operation: " + lastoperation + "\n" +
132 | "Next operation: " + nextoperation + "\n" +
133 | "\n" +
134 | "Data specified: " + (containsPrivateData ? "(Contains private data)" : specified_data) + "\n" +
135 | "\n" +
136 | "Exception stacktrace: " + (stacktrace == null ? "(Does not contain exception)" : "\n" + stacktrace) + "\n" +
137 | "===!===!===!===!-dump-end-!===!===!===!===\n";
138 | }
139 |
140 | public String getOsumerVersion() {
141 | return osumerVersion;
142 | }
143 |
144 | public String getDebuggerVersion() {
145 | return debuggerVersion;
146 | }
147 |
148 | public String getMessage() {
149 | return message;
150 | }
151 |
152 | public String getUid() {
153 | return uid;
154 | }
155 |
156 | public boolean isContainsPrivateData() {
157 | return containsPrivateData;
158 | }
159 |
160 | public String getGeneratedHuman() {
161 | return generated_human;
162 | }
163 |
164 | public String getStacktrace() {
165 | return stacktrace;
166 | }
167 |
168 | public String getSpecifiedData() {
169 | return specified_data;
170 | }
171 |
172 | public String getLastOperation() {
173 | return lastoperation;
174 | }
175 |
176 | public String getThisOperation() {
177 | return thisoperation;
178 | }
179 |
180 | public String getNextOperation() {
181 | return nextoperation;
182 | }
183 |
184 | public String getExceptionClass() {
185 | return exceptionClass;
186 | }
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/osumer-debugdump/src/main/java/com/github/mob41/osumer/debug/NotReportedFilter.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.debug;
2 |
3 | import com.codahale.metrics.Metric;
4 | import com.codahale.metrics.MetricFilter;
5 |
6 | public class NotReportedFilter implements MetricFilter {
7 |
8 | @Override
9 | public boolean matches(String name, Metric metric) {
10 | return !name.contains("not_reported");
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/osumer-debugdump/src/main/java/com/github/mob41/osumer/debug/ResettableGauge.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.debug;
2 |
3 | import com.codahale.metrics.Counter;
4 | import com.codahale.metrics.Gauge;
5 |
6 | public class ResettableGauge implements Gauge {
7 |
8 | private final Counter c;
9 |
10 | public ResettableGauge(Counter c) {
11 | this.c = c;
12 | }
13 |
14 | @Override
15 | public Long getValue() {
16 | long count = c.getCount();
17 | c.dec(count);
18 | return count;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/osumer-debugdump/src/main/java/com/github/mob41/osumer/debug/WithDumpException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 Anthony Law
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *******************************************************************************/
24 | package com.github.mob41.osumer.debug;
25 |
26 | import java.awt.GraphicsEnvironment;
27 |
28 | public class WithDumpException extends Exception {
29 |
30 | /**
31 | *
32 | */
33 | private static final long serialVersionUID = -4350229047576754645L;
34 | private final DebugDump dump;
35 |
36 | public WithDumpException(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData) {
37 | dump = new DebugDump(specified_data, last_op, this_op, next_op, message, containsPrivateData, this);
38 | }
39 |
40 | public WithDumpException(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData, String arg0) {
41 | super(arg0);
42 | dump = new DebugDump(specified_data, last_op, this_op, next_op, message, containsPrivateData, this);
43 | }
44 |
45 | public WithDumpException(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData, Throwable arg0) {
46 | super(arg0);
47 | dump = new DebugDump(specified_data, last_op, this_op, next_op, message, containsPrivateData, this);
48 | }
49 |
50 | public WithDumpException(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData, String arg0, Throwable arg1) {
51 | super(arg0, arg1);
52 | dump = new DebugDump(specified_data, last_op, this_op, next_op, message, containsPrivateData, this);
53 | }
54 |
55 | public WithDumpException(String specified_data, String last_op, String this_op, String next_op, String message, boolean containsPrivateData, String arg0, Throwable arg1, boolean arg2, boolean arg3) {
56 | super(arg0, arg1, arg2, arg3);
57 | dump = new DebugDump(specified_data, last_op, this_op, next_op, message, containsPrivateData, this);
58 | }
59 |
60 | public DebugDump getDump(){
61 | return dump;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/osumer-installer/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-installer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osumer-installer
9 |
10 |
11 | com.github.mob41
12 | osumer-lib
13 | ${global.version}
14 |
15 |
16 | net.java.dev.jna
17 | jna-platform
18 | 4.2.2
19 |
20 |
21 | net.java.dev.jna
22 | jna
23 | 4.2.2
24 |
25 |
26 | com.github.mob41
27 | osumer-debugdump
28 | ${global.version}
29 |
30 |
31 | com.github.vatbub
32 | mslinks
33 | 1.0.4
34 |
35 |
36 | commons-codec
37 | commons-codec
38 | 1.10
39 |
40 |
41 |
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-dependency-plugin
46 |
47 |
48 | copy-dependencies
49 | prepare-package
50 |
51 | copy-dependencies
52 |
53 |
54 | ${project.parent.build.directory}/lib
55 | false
56 | false
57 | true
58 |
59 |
60 |
61 |
62 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/osumer-jni/.gitignore:
--------------------------------------------------------------------------------
1 | cmake_install.cmake
2 | CMakeFiles
3 | CMakeFiles/*
--------------------------------------------------------------------------------
/osumer-jni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project("osumer-jni")
2 |
3 | add_library(osumer-jni SHARED dllmain.cpp com_github_mob41_osumer_OsumerNative.cpp)
--------------------------------------------------------------------------------
/osumer-jni/com_github_mob41_osumer_OsumerNative.cpp:
--------------------------------------------------------------------------------
1 | #include "jni.h"
2 | #include "com_github_mob41_osumer_OsumerNative.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | void inject(HANDLE hProcess) {
11 | HANDLE hThread;
12 | char *lib_path;
13 | void *page;
14 | DWORD cbNeeded;
15 | HMODULE hMods[1024];
16 | unsigned int i;
17 |
18 | TCHAR pf[MAX_PATH];
19 | SHGetSpecialFolderPath(0, pf, CSIDL_PROGRAM_FILES, FALSE);
20 |
21 | char jvmDllStr[MAX_PATH];
22 | snprintf(jvmDllStr, MAX_PATH, "%s\\%s", pf, "osumer2\\jre\\bin\\client\\jvm.dll");
23 |
24 | char osumerDllStr[MAX_PATH];
25 | snprintf(osumerDllStr, MAX_PATH, "%s\\%s", pf, "osumer2\\osumer-overlay.dll");
26 |
27 | if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
28 | {
29 | for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
30 | {
31 | TCHAR szModName[MAX_PATH];
32 |
33 | if (GetModuleFileNameEx(hProcess, hMods[i], szModName,
34 | sizeof(szModName) / sizeof(TCHAR)))
35 | {
36 | if (strcmp(szModName, osumerDllStr) == 0) {
37 | return;
38 | }
39 | }
40 | }
41 | }
42 |
43 | // Allocate a page in memory for the arguments of LoadLibrary.
44 | page = VirtualAllocEx(hProcess, NULL, MAX_PATH, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
45 | if (page == NULL) {
46 | fprintf(stderr, "VirtualAllocEx failed; error code = 0x%08X\n", GetLastError());
47 | return;
48 | }
49 |
50 | char *libs[2] = {
51 | jvmDllStr,
52 | osumerDllStr
53 | };
54 |
55 | for (int i = 0; i < 2; i++) {
56 | lib_path = libs[i];
57 |
58 | if (GetFileAttributes(lib_path) == INVALID_FILE_ATTRIBUTES) {
59 | fprintf(stderr, "unable to locate library (%s).\n", lib_path);
60 | return;
61 | }
62 | //MessageBox(0, "Located", "osumer", MB_OK);
63 |
64 | // Write library path to the page used for LoadLibrary arguments.
65 | if (WriteProcessMemory(hProcess, page, lib_path, strlen(lib_path) + 1, NULL) == 0) {
66 | fprintf(stderr, "WriteProcessMemory failed; error code = 0x%08X\n", GetLastError());
67 | return;
68 | }
69 | //MessageBox(0, "Written", "osumer", MB_OK);
70 |
71 | // Inject the shared library into the address space of the process,
72 | // through a call to LoadLibrary.
73 | hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, page, 0, NULL);
74 | if (hThread == NULL) {
75 | fprintf(stderr, "CreateRemoteThread failed; error code = 0x%08X\n", GetLastError());
76 | return;
77 | }
78 | //MessageBox(0, "Thread", "osumer", MB_OK);
79 |
80 | // Wait for DllMain to return.
81 | if (WaitForSingleObject(hThread, INFINITE) == WAIT_FAILED) {
82 | fprintf(stderr, "WaitForSingleObject failed; error code = 0x%08X\n", GetLastError());
83 | return;
84 | }
85 | }
86 | //MessageBox(0, "Returned", "osumer", MB_OK);
87 |
88 | // Cleanup.
89 | CloseHandle(hThread);
90 | VirtualFreeEx(hProcess, page, MAX_PATH, MEM_RELEASE);
91 | }
92 |
93 | JNIEXPORT jstring JNICALL Java_com_github_mob41_osumer_OsumerNative_getProgramFiles(JNIEnv *env, jclass thisClass) {
94 | TCHAR pf[MAX_PATH];
95 | SHGetSpecialFolderPath(0, pf, CSIDL_PROGRAM_FILES, FALSE);
96 | return env->NewStringUTF(pf);
97 | }
98 |
99 | JNIEXPORT void JNICALL Java_com_github_mob41_osumer_OsumerNative_startWithOverlay(JNIEnv *env, jclass thisClass) {
100 | char exe_path[MAX_PATH];
101 | STARTUPINFO si = { 0 };
102 | PROCESS_INFORMATION pi = { 0 };
103 |
104 | TCHAR ad[MAX_PATH];
105 | SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, ad);
106 | fprintf(stderr, "ap:%s\n", ad);
107 |
108 | // Execute the process in suspended mode.
109 | snprintf(exe_path, MAX_PATH, "%s\\%s", ad, "osu!\\osu!.exe");
110 | fprintf(stderr, "ep:%s\n", exe_path);
111 |
112 | si.cb = sizeof(STARTUPINFO);
113 | if (!CreateProcess(NULL, exe_path, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) {
114 | fprintf(stderr, "CreateProcess(\"%s\") failed; error code = 0x%08X\n", exe_path, GetLastError());
115 | return;
116 | }
117 |
118 | inject(pi.hProcess);
119 |
120 | // Resume the execution of the process, once all libraries have been injected
121 | // into its address space.
122 | if (ResumeThread(pi.hThread) == -1) {
123 | fprintf(stderr, "ResumeThread failed; error code = 0x%08X\n", GetLastError());
124 | return;
125 | }
126 |
127 | //MessageBox(0, "Resume", "osumer", MB_OK);
128 | // Cleanup.
129 | CloseHandle(pi.hProcess);
130 | return;
131 | };
132 |
133 | JNIEXPORT void JNICALL Java_com_github_mob41_osumer_OsumerNative_injectOverlay(JNIEnv *env, jclass thisClass) {
134 | PROCESSENTRY32 entry;
135 | entry.dwSize = sizeof(PROCESSENTRY32);
136 |
137 | HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
138 |
139 | if (Process32First(snapshot, &entry) == TRUE)
140 | {
141 | while (Process32Next(snapshot, &entry) == TRUE)
142 | {
143 | if (stricmp(entry.szExeFile, "osu!.exe") == 0)
144 | {
145 | HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
146 |
147 | inject(hProcess);
148 |
149 | CloseHandle(hProcess);
150 | }
151 | }
152 | }
153 |
154 | CloseHandle(snapshot);
155 | }
--------------------------------------------------------------------------------
/osumer-jni/com_github_mob41_osumer_OsumerNative.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_github_mob41_osumer_OsumerNative */
4 |
5 | #ifndef _Included_com_github_mob41_osumer_OsumerNative
6 | #define _Included_com_github_mob41_osumer_OsumerNative
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_github_mob41_osumer_OsumerNative
12 | * Method: getProgramFiles
13 | * Signature: ()Ljava.lang.String;
14 | */
15 | JNIEXPORT jstring JNICALL Java_com_github_mob41_osumer_OsumerNative_getProgramFiles(JNIEnv *, jclass);
16 |
17 | /*
18 | * Class: com_github_mob41_osumer_OsumerNative
19 | * Method: startWithOverlay
20 | * Signature: ()V
21 | */
22 | JNIEXPORT void JNICALL Java_com_github_mob41_osumer_OsumerNative_startWithOverlay(JNIEnv *, jclass);
23 |
24 | /*
25 | * Class: com_github_mob41_osumer_OsumerNative
26 | * Method: injectOverlay
27 | * Signature: ()V
28 | */
29 | JNIEXPORT void JNICALL Java_com_github_mob41_osumer_OsumerNative_injectOverlay(JNIEnv *, jclass);
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 | #endif
35 |
--------------------------------------------------------------------------------
/osumer-jni/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "stdafx.h"
3 |
4 | BOOL APIENTRY DllMain( HMODULE hModule,
5 | DWORD ul_reason_for_call,
6 | LPVOID lpReserved
7 | )
8 | {
9 | switch (ul_reason_for_call)
10 | {
11 | case DLL_PROCESS_ATTACH:
12 | case DLL_THREAD_ATTACH:
13 | case DLL_THREAD_DETACH:
14 | case DLL_PROCESS_DETACH:
15 | break;
16 | }
17 | return TRUE;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/osumer-jni/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // $safeprojectname$.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/osumer-jni/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11 | // Windows Header Files:
12 | #include
13 |
14 |
15 |
16 | // TODO: reference additional headers your program requires here
17 |
--------------------------------------------------------------------------------
/osumer-jni/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/osumer-launcher/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-launcher/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osumer-launcher
9 |
10 |
11 | com.github.mob41
12 | osumer-lib
13 | ${global.version}
14 |
15 |
16 | com.github.mob41
17 | osumer-installer
18 | ${global.version}
19 |
20 |
21 | com.github.mob41
22 | osums-api
23 | ${global.version}
24 |
25 |
26 | com.github.mob41
27 | osumer-debugdump
28 | ${global.version}
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-dependency-plugin
36 |
37 |
38 | copy-dependencies
39 | prepare-package
40 |
41 | copy-dependencies
42 |
43 |
44 | ${project.parent.build.directory}/lib
45 | false
46 | false
47 | true
48 |
49 |
50 |
51 |
52 |
53 | org.apache.maven.plugins
54 | maven-jar-plugin
55 |
56 | ${project.parent.build.directory}
57 |
58 |
59 | true
60 | lib/
61 | com.github.mob41.osumer.launcher.Main
62 |
63 |
64 |
65 |
66 |
67 | com.akathist.maven.plugins.launch4j
68 | launch4j-maven-plugin
69 |
70 |
71 | l4j-gui
72 | package
73 | launch4j
74 |
75 | gui
76 | ${project.parent.build.directory}/${project.parent.artifactId}.exe
77 | ${project.parent.build.directory}/${project.artifactId}-${global.version}.jar
78 | osumer2
79 | https://github.com/mob41/osumer/issues/new
80 | ${project.parent.basedir}/src/main/resources/osumerIcon_128px.ico
81 |
82 | com.github.mob41.osumer.launcher.Main
83 | false
84 | anything
85 |
86 |
87 | jre
88 | 1.8.0
89 | 32
90 | 64
91 | 128
92 |
93 |
94 | ${global.generation}.${global.build}
95 | ${global.version}
96 | osumer2
97 | Copyright (c) 2019 mob41
98 | ${global.generation}.${global.build}
99 | ${global.version}
100 | osumer2
101 | osumer
102 | osumer.exe
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/osumer-launcher/src/main/java/com/github/mob41/osumer/launcher/ArgParser.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.launcher;
30 |
31 | public class ArgParser {
32 |
33 | private final String[] args;
34 |
35 | private boolean showIconsFlag = false;
36 |
37 | private boolean hideIconsFlag = false;
38 |
39 | private boolean reinstallFlag = false;
40 |
41 | private boolean installFlag = false;
42 |
43 | private boolean uninstallFlag = false;
44 |
45 | private boolean forceFlag = false;
46 |
47 | private boolean quietFlag = false;
48 |
49 | private boolean uiFlag = false;
50 |
51 | private boolean noUiFlag = false;
52 |
53 | private boolean versionFlag = false;
54 |
55 | private boolean daemonFlag = false;
56 |
57 | public ArgParser(String[] args) {
58 | this.args = args;
59 |
60 | if (args == null) {
61 | return;
62 | }
63 |
64 | for (int i = 0; i < args.length; i++) {
65 | if (args[i].equals("-hideicons")) {
66 | setHideIconsFlag(true);
67 | } else if (args[i].equals("-showicons")) {
68 | setShowIconsFlag(true);
69 | } else if (args[i].equals("-reinstall")) {
70 | setReinstallFlag(true);
71 | } else if (args[i].equals("-install")) {
72 | setInstallFlag(true);
73 | } else if (args[i].equals("-uninstall")) {
74 | setUninstallFlag(true);
75 | } else if (args[i].equals("-force")) {
76 | setForceFlag(true);
77 | } else if (args[i].equals("-quiet")) {
78 | setQuietFlag(true);
79 | } else if (args[i].equals("-ui")) {
80 | setUiFlag(true);
81 | } else if (args[i].equals("-noui")) {
82 | setNoUiFlag(true);
83 | } else if (args[i].equals("-version")) {
84 | setVersionFlag(true);
85 | } else if (args[i].equals("-daemon")) {
86 | setDaemonFlag(true);
87 | }
88 | }
89 | }
90 |
91 | public boolean isShowIconsFlag() {
92 | return showIconsFlag;
93 | }
94 |
95 | public void setShowIconsFlag(boolean showIconsFlag) {
96 | this.showIconsFlag = showIconsFlag;
97 | }
98 |
99 | public boolean isHideIconsFlag() {
100 | return hideIconsFlag;
101 | }
102 |
103 | public void setHideIconsFlag(boolean hideIconsFlag) {
104 | this.hideIconsFlag = hideIconsFlag;
105 | }
106 |
107 | public boolean isReinstallFlag() {
108 | return reinstallFlag;
109 | }
110 |
111 | public void setReinstallFlag(boolean reinstallFlag) {
112 | this.reinstallFlag = reinstallFlag;
113 | }
114 |
115 | public boolean isInstallFlag() {
116 | return installFlag;
117 | }
118 |
119 | public void setInstallFlag(boolean installFlag) {
120 | this.installFlag = installFlag;
121 | }
122 |
123 | public boolean isUninstallFlag() {
124 | return uninstallFlag;
125 | }
126 |
127 | public void setUninstallFlag(boolean uninstallFlag) {
128 | this.uninstallFlag = uninstallFlag;
129 | }
130 |
131 | public boolean isForceFlag() {
132 | return forceFlag;
133 | }
134 |
135 | public void setForceFlag(boolean forceFlag) {
136 | this.forceFlag = forceFlag;
137 | }
138 |
139 | public boolean isQuietFlag() {
140 | return quietFlag;
141 | }
142 |
143 | public void setQuietFlag(boolean quietFlag) {
144 | this.quietFlag = quietFlag;
145 | }
146 |
147 | public boolean isUiFlag() {
148 | return uiFlag;
149 | }
150 |
151 | public void setUiFlag(boolean uiFlag) {
152 | this.uiFlag = uiFlag;
153 | }
154 |
155 | public String[] getArgs() {
156 | return args;
157 | }
158 |
159 | public boolean isVersionFlag() {
160 | return versionFlag;
161 | }
162 |
163 | public void setVersionFlag(boolean versionFlag) {
164 | this.versionFlag = versionFlag;
165 | }
166 |
167 | public boolean isNoUiFlag() {
168 | return noUiFlag;
169 | }
170 |
171 | public void setNoUiFlag(boolean noUiFlag) {
172 | this.noUiFlag = noUiFlag;
173 | }
174 |
175 | public boolean isDaemonFlag() {
176 | return daemonFlag;
177 | }
178 |
179 | public void setDaemonFlag(boolean daemonFlag) {
180 | this.daemonFlag = daemonFlag;
181 | }
182 |
183 | }
184 |
--------------------------------------------------------------------------------
/osumer-lib/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-lib/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osumer-lib
9 |
10 |
11 | org.json
12 | json
13 | 20160212
14 |
15 |
16 | com.github.mob41
17 | osumer-debugdump
18 | ${global.version}
19 |
20 |
21 | com.github.mob41
22 | osums-api
23 | ${global.version}
24 |
25 |
26 | com.google.code.gson
27 | gson
28 | 2.8.5
29 |
30 |
31 | org.openjfx
32 | javafx-swing
33 | 17.0.1
34 |
35 |
36 | org.openjfx
37 | javafx-media
38 | 17.0.1
39 |
40 |
41 | org.openjfx
42 | javafx-controls
43 | 17.0.1
44 |
45 |
46 | org.openjfx
47 | javafx-fxml
48 | 17.0.1
49 |
50 |
51 |
52 |
53 |
54 | org.apache.maven.plugins
55 | maven-dependency-plugin
56 |
57 |
58 | copy-dependencies
59 | prepare-package
60 |
61 | copy-dependencies
62 |
63 |
64 | ${project.parent.build.directory}/lib
65 | false
66 | false
67 | true
68 |
69 |
70 |
71 |
72 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/Osumer.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer;
30 |
31 | import java.io.File;
32 | import java.io.IOException;
33 |
34 | import com.github.mob41.osumer.updater.Updater;
35 |
36 | public class Osumer {
37 |
38 | // TODO: Hard-code version?
39 |
40 | public static final String OSUMER_VERSION = "2.0.0";
41 |
42 | public static final String OSUMER_BRANCH = "snapshot";
43 |
44 | public static final int OSUMER_BUILD_NUM = 11;
45 |
46 | public static String getVersionString() {
47 | return OSUMER_VERSION + "-" + OSUMER_BRANCH + "-b" + OSUMER_BUILD_NUM;
48 | }
49 |
50 | private Osumer() {
51 |
52 | }
53 |
54 | public static boolean isWindows() {
55 | return System.getProperty("os.name").contains("Windows");
56 | }
57 |
58 | public static boolean isWindowsElevated() {
59 | if (!isWindows()) {
60 | return false;
61 | }
62 |
63 | final String programfiles = System.getenv("PROGRAMFILES");
64 |
65 | if (programfiles == null || programfiles.length() < 1) {
66 | throw new IllegalStateException("OS mismatch. Program Files directory not detected");
67 | }
68 |
69 | File testPriv = new File(programfiles);
70 | if (!testPriv.canWrite()) {
71 | return false;
72 | }
73 | File fileTest = null;
74 |
75 | try {
76 | fileTest = File.createTempFile("testsu", ".dll", testPriv);
77 | } catch (IOException e) {
78 | return false;
79 | } finally {
80 | if (fileTest != null) {
81 | fileTest.delete();
82 | }
83 | }
84 | return true;
85 | }
86 |
87 | public static int updateSourceStrToInt(String branchStr) {
88 | if (branchStr.equals("snapshot")) {
89 | return 2;
90 | } else if (branchStr.equals("beta")) {
91 | return 1;
92 | } else if (branchStr.equals("stable")) {
93 | return 0;
94 | }
95 | return -1;
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/OsumerNative.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer;
2 |
3 | import java.io.File;
4 |
5 | import javax.swing.JOptionPane;
6 |
7 | public class OsumerNative {
8 |
9 | static {
10 | final String dllName = "osumer-jni.dll";
11 | final String path32 = "C:\\Program Files\\osumer2\\" + dllName;
12 | final String path64 = "C:\\Program Files (x86)\\osumer2\\" + dllName;
13 |
14 | boolean success = false;
15 | String reason = null;
16 |
17 | File file32 = new File(path32);
18 | File file64 = new File(path64);
19 |
20 | if (file64.exists()) {
21 | try {
22 | System.load(path64);
23 | success = true;
24 | } catch (UnsatisfiedLinkError e) {
25 | e.printStackTrace();
26 | reason = e.getMessage();
27 | }
28 | } else if (file32.exists()) {
29 | try {
30 | System.load(path32);
31 | success = true;
32 | } catch (UnsatisfiedLinkError e) {
33 | e.printStackTrace();
34 | reason = e.getMessage();
35 | }
36 | } else {
37 | JOptionPane.showMessageDialog(null, "Could not find any osumer2 DLL in both 32, 64 bit folders!\nYou might not be able to use overlay features.\nPlease check if you have installed osumer2 properly.", "osumer2 Native Error", JOptionPane.ERROR_MESSAGE);
38 | System.exit(-1);
39 | }
40 |
41 | if (!success) {
42 | JOptionPane.showMessageDialog(null, "Could not load osumer2 DLL!\nPlease check if you have installed osumer2 properly.\nReason:\n" + reason, "osumer2 Native Error", JOptionPane.ERROR_MESSAGE);
43 | System.exit(-1);
44 | }
45 | }
46 |
47 | public static native void startWithOverlay();
48 |
49 | public static native void injectOverlay();
50 |
51 | public static native String getProgramFiles();
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/InvalidSourceIntegerException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | import com.github.mob41.osumer.debug.WithDumpException;
32 |
33 | public class InvalidSourceIntegerException extends WithDumpException {
34 |
35 | /**
36 | *
37 | */
38 | private static final long serialVersionUID = 4508589028039107867L;
39 | private static final String MSG = "Invalid source integer provided in the configuration";
40 |
41 | public InvalidSourceIntegerException(String json, String last_op, String this_op, String next_op, int source) {
42 | super(json, last_op, this_op, next_op, MSG + ": " + source, false);
43 | }
44 |
45 | public InvalidSourceIntegerException(String json, String last_op, String this_op, String next_op, String arg0,
46 | int source) {
47 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0);
48 | }
49 |
50 | public InvalidSourceIntegerException(String json, String last_op, String this_op, String next_op, Throwable arg0,
51 | int source) {
52 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0);
53 | }
54 |
55 | public InvalidSourceIntegerException(String json, String last_op, String this_op, String next_op, String arg0,
56 | Throwable arg1, int source) {
57 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0, arg1);
58 | }
59 |
60 | public InvalidSourceIntegerException(String json, String last_op, String this_op, String next_op, String arg0,
61 | Throwable arg1, boolean arg2, boolean arg3, int source) {
62 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0, arg1, arg2, arg3);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/NoBuildsForVersionException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | import com.github.mob41.osumer.debug.WithDumpException;
32 |
33 | public class NoBuildsForVersionException extends WithDumpException {
34 |
35 | /**
36 | *
37 | */
38 | private static final long serialVersionUID = 4508589028039107867L;
39 | private static final String MSG = "No builds are defined in the version JSON.";
40 |
41 | public NoBuildsForVersionException(String json, String last_op, String this_op, String next_op) {
42 | super(json, last_op, this_op, next_op, MSG, false);
43 | }
44 |
45 | public NoBuildsForVersionException(String json, String last_op, String this_op, String next_op, String arg0) {
46 | super(json, last_op, this_op, next_op, MSG, false, arg0);
47 | }
48 |
49 | public NoBuildsForVersionException(String json, String last_op, String this_op, String next_op, Throwable arg0) {
50 | super(json, last_op, this_op, next_op, MSG, false, arg0);
51 | }
52 |
53 | public NoBuildsForVersionException(String json, String last_op, String this_op, String next_op, String arg0,
54 | Throwable arg1) {
55 | super(json, last_op, this_op, next_op, MSG, false, arg0, arg1);
56 | }
57 |
58 | public NoBuildsForVersionException(String json, String last_op, String this_op, String next_op, String arg0,
59 | Throwable arg1, boolean arg2, boolean arg3) {
60 | super(json, last_op, this_op, next_op, MSG, false, arg0, arg1, arg2, arg3);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/NoSuchBuildNumberException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | import com.github.mob41.osumer.debug.WithDumpException;
32 |
33 | public class NoSuchBuildNumberException extends WithDumpException {
34 |
35 | /**
36 | *
37 | */
38 | private static final long serialVersionUID = 4508589028039107867L;
39 | private static final String MSG = "No such build number/index defined in the versions' JSON";
40 |
41 | public NoSuchBuildNumberException(String json, String last_op, String this_op, String next_op, int buildnum) {
42 | super(json, last_op, this_op, next_op, MSG + ": " + buildnum, false);
43 | }
44 |
45 | public NoSuchBuildNumberException(String json, String last_op, String this_op, String next_op, String arg0,
46 | int buildnum) {
47 | super(json, last_op, this_op, next_op, MSG + ": " + buildnum, false, arg0);
48 | }
49 |
50 | public NoSuchBuildNumberException(String json, String last_op, String this_op, String next_op, Throwable arg0,
51 | int buildnum) {
52 | super(json, last_op, this_op, next_op, MSG + ": " + buildnum, false, arg0);
53 | }
54 |
55 | public NoSuchBuildNumberException(String json, String last_op, String this_op, String next_op, String arg0,
56 | Throwable arg1, int buildnum) {
57 | super(json, last_op, this_op, next_op, MSG + ": " + buildnum, false, arg0, arg1);
58 | }
59 |
60 | public NoSuchBuildNumberException(String json, String last_op, String this_op, String next_op, String arg0,
61 | Throwable arg1, boolean arg2, boolean arg3, int buildnum) {
62 | super(json, last_op, this_op, next_op, MSG + ": " + buildnum, false, arg0, arg1, arg2, arg3);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/NoSuchSourceException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | import com.github.mob41.osumer.debug.WithDumpException;
32 |
33 | public class NoSuchSourceException extends WithDumpException{
34 |
35 | /**
36 | *
37 | */
38 | private static final long serialVersionUID = 4508589028039107867L;
39 | private static final String MSG = "No such source are defined in the update JSON";
40 |
41 | public NoSuchSourceException(String json, String last_op, String this_op, String next_op, String source) {
42 | super(json, last_op, this_op, next_op, MSG + ": " + source, false);
43 | }
44 |
45 | public NoSuchSourceException(String json, String last_op, String this_op, String next_op, String arg0,
46 | String source) {
47 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0);
48 | }
49 |
50 | public NoSuchSourceException(String json, String last_op, String this_op, String next_op, Throwable arg0,
51 | String source) {
52 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0);
53 | }
54 |
55 | public NoSuchSourceException(String json, String last_op, String this_op, String next_op, String arg0,
56 | Throwable arg1, String source) {
57 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0, arg1);
58 | }
59 |
60 | public NoSuchSourceException(String json, String last_op, String this_op, String next_op, String arg0,
61 | Throwable arg1, boolean arg2, boolean arg3, String source) {
62 | super(json, last_op, this_op, next_op, MSG + ": " + source, false, arg0, arg1, arg2, arg3);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/NoSuchVersionException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | import com.github.mob41.osumer.debug.WithDumpException;
32 |
33 | public class NoSuchVersionException extends WithDumpException {
34 |
35 | /**
36 | *
37 | */
38 | private static final long serialVersionUID = 4508589028039107867L;
39 | private static final String MSG = "No such version are defined in the source JSON";
40 |
41 | public NoSuchVersionException(String json, String last_op, String this_op, String next_op, String source,
42 | String version) {
43 | super(json, last_op, this_op, next_op, MSG + ": " + source + "/" + version, false);
44 | }
45 |
46 | public NoSuchVersionException(String json, String last_op, String this_op, String next_op, String arg0,
47 | String source, String version) {
48 | super(json, last_op, this_op, next_op, MSG + ": " + source + "/" + version, false, arg0);
49 | }
50 |
51 | public NoSuchVersionException(String json, String last_op, String this_op, String next_op, Throwable arg0,
52 | String source, String version) {
53 | super(json, last_op, this_op, next_op, MSG + ": " + source + "/" + version, false, arg0);
54 | }
55 |
56 | public NoSuchVersionException(String json, String last_op, String this_op, String next_op, String arg0,
57 | Throwable arg1, String source, String version) {
58 | super(json, last_op, this_op, next_op, MSG + ": " + source + "/" + version, false, arg0, arg1);
59 | }
60 |
61 | public NoSuchVersionException(String json, String last_op, String this_op, String next_op, String arg0,
62 | Throwable arg1, boolean arg2, boolean arg3, String source, String version) {
63 | super(json, last_op, this_op, next_op, MSG + ": " + source + "/" + version, false, arg0, arg1, arg2, arg3);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/exceptions/OsuException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.exceptions;
30 |
31 | public class OsuException extends Exception {
32 |
33 | /**
34 | *
35 | */
36 | private static final long serialVersionUID = -7589497596398382068L;
37 |
38 | public OsuException() {
39 |
40 | }
41 |
42 | public OsuException(String arg0) {
43 | super(arg0);
44 | }
45 |
46 | public OsuException(Throwable arg0) {
47 | super(arg0);
48 | }
49 |
50 | public OsuException(String arg0, Throwable arg1) {
51 | super(arg0, arg1);
52 | }
53 |
54 | public OsuException(String arg0, Throwable arg1, boolean arg2, boolean arg3) {
55 | super(arg0, arg1, arg2, arg3);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/io/Downloader.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.io;
30 |
31 | import java.util.Observable;
32 |
33 | import com.github.mob41.osumer.debug.DebugDump;
34 |
35 | public abstract class Downloader extends Observable implements Runnable {
36 |
37 | public static final int DOWNLOADING = 0;
38 |
39 | public static final int PAUSED = 1;
40 |
41 | public static final int COMPLETED = 2;
42 |
43 | public static final int CANCELLED = 3;
44 |
45 | public static final int ERROR = 4;
46 |
47 | public abstract DebugDump getErrorDump();
48 |
49 | public abstract String getDownloadFolder();
50 |
51 | public abstract String getFileName();
52 |
53 | public abstract String getUrl();
54 |
55 | public abstract int getDownloaded();
56 |
57 | public abstract int getSize();
58 |
59 | public abstract float getProgress();
60 |
61 | public abstract int getStatus();
62 |
63 | public abstract void pause();
64 |
65 | public abstract void resume();
66 |
67 | public abstract void cancel();
68 |
69 | public abstract void download();
70 |
71 | public abstract void run();
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/io/OsuDownloader.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.io;
30 |
31 | import java.io.File;
32 | import java.io.IOException;
33 | import java.io.InputStream;
34 | import java.io.RandomAccessFile;
35 | import java.net.HttpCookie;
36 | import java.net.HttpURLConnection;
37 | import java.net.URL;
38 | import java.util.List;
39 |
40 | import com.github.mob41.osumer.debug.DebugDump;
41 | import com.github.mob41.osumer.debug.DumpManager;
42 | import com.github.mob41.osums.Osums;
43 |
44 | public class OsuDownloader extends Downloader {
45 |
46 | private static final int MAX_BUFFER_SIZE = 1024;
47 |
48 | private final URL url;
49 |
50 | private final Osums osu;
51 |
52 | private final String folder;
53 |
54 | private final String fileName;
55 |
56 | private int size = -1;
57 |
58 | private int downloaded = 0;
59 |
60 | private int status = -1;
61 |
62 | private DebugDump dump;
63 |
64 | public OsuDownloader(String downloadFolder, String fileName, Osums osu, URL downloadUrl) {
65 | this.url = downloadUrl;
66 | this.osu = osu;
67 | this.folder = downloadFolder;
68 | this.fileName = fileName;
69 | }
70 |
71 | public String getDownloadFolder() {
72 | return folder;
73 | }
74 |
75 | public String getFileName() {
76 | return fileName;
77 | }
78 |
79 | public String getUrl() {
80 | return url.toString();
81 | }
82 |
83 | public int getDownloaded() {
84 | return downloaded;
85 | }
86 |
87 | public int getSize() {
88 | return size;
89 | }
90 |
91 | public float getProgress() {
92 | return ((float) downloaded / size) * 100;
93 | }
94 |
95 | public int getStatus() {
96 | return status;
97 | }
98 |
99 | public void pause() {
100 | status = PAUSED;
101 | reportState();
102 | }
103 |
104 | public void resume() {
105 | status = DOWNLOADING;
106 | reportState();
107 | download();
108 | }
109 |
110 | public void cancel() {
111 | status = CANCELLED;
112 | reportState();
113 |
114 | File file = new File(folder + "\\" + fileName + ".osz");
115 | file.delete();
116 |
117 | downloaded = 0;
118 | }
119 |
120 | private void error() {
121 | System.out.println("Errored!!");
122 | status = ERROR;
123 | reportState();
124 | }
125 |
126 | public void download() {
127 | if (status != DOWNLOADING && status != COMPLETED) {
128 | status = DOWNLOADING;
129 | Thread thread = new Thread(this);
130 | thread.start();
131 | reportState();
132 | }
133 | }
134 |
135 | @Override
136 | public void run() {
137 | RandomAccessFile file = null;
138 | InputStream in = null;
139 |
140 | try {
141 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
142 |
143 | conn.setRequestProperty("Range", "bytes=" + downloaded + "-");
144 |
145 | osu.setCookies(conn);
146 |
147 | conn.connect();
148 |
149 | int code = conn.getResponseCode() / 100;
150 | if (code < 2 && code > 3) {
151 | error();
152 | }
153 |
154 | int len = conn.getContentLength();
155 |
156 | if (len < 1) {
157 | error();
158 | }
159 |
160 | if (size == -1) {
161 | size = len;
162 | reportState();
163 | }
164 |
165 | file = new RandomAccessFile(folder + "\\" + fileName + ".osz", "rw");
166 | file.seek(downloaded);
167 |
168 | in = conn.getInputStream();
169 |
170 | while (status == DOWNLOADING) {
171 | byte[] buffer = size - downloaded > MAX_BUFFER_SIZE ? new byte[MAX_BUFFER_SIZE]
172 | : new byte[size - downloaded];
173 | int read = in.read(buffer);
174 | if (read == -1) {
175 | break;
176 | }
177 |
178 | file.write(buffer, 0, read);
179 | downloaded += read;
180 | reportState();
181 | }
182 |
183 | if (status == DOWNLOADING) {
184 | status = COMPLETED;
185 | reportState();
186 | }
187 | } catch (IOException e) {
188 | e.printStackTrace();
189 | DumpManager.addDump(dump = new DebugDump(null, "(Try&catch try)", "Error reporting and debug dump",
190 | "(Try&catch finally)", "Error when downloading", false, e));
191 | error();
192 | } finally {
193 | if (file != null) {
194 | try {
195 | file.close();
196 | } catch (IOException e) {
197 | e.printStackTrace();
198 | }
199 | }
200 |
201 | if (in != null) {
202 | try {
203 | in.close();
204 | } catch (IOException e) {
205 | e.printStackTrace();
206 | }
207 | }
208 | }
209 | }
210 |
211 | private void reportState() {
212 | setChanged();
213 | notifyObservers();
214 | }
215 |
216 | private static String join(String separator, List objs) {
217 | String out = "";
218 |
219 | String str;
220 | for (int i = 0; i < objs.size(); i++) {
221 | str = objs.get(i).toString();
222 |
223 | out += str + separator;
224 |
225 | if (i != objs.size() - 1) {
226 | out += " ";
227 | }
228 | }
229 |
230 | return out;
231 | }
232 |
233 | @Override
234 | public DebugDump getErrorDump() {
235 | return dump;
236 | }
237 |
238 | }
239 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/io/URLDownloader.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.io;
30 |
31 | import java.io.File;
32 | import java.io.IOException;
33 | import java.io.InputStream;
34 | import java.io.RandomAccessFile;
35 | import java.net.HttpURLConnection;
36 | import java.net.URL;
37 |
38 | import com.github.mob41.osumer.debug.DebugDump;
39 | import com.github.mob41.osumer.debug.DumpManager;
40 |
41 | public class URLDownloader extends Downloader {
42 |
43 | private static final int MAX_BUFFER_SIZE = 1024;
44 |
45 | private final URL url;
46 |
47 | private final String folder;
48 |
49 | private final String fileName;
50 |
51 | private int size = -1;
52 |
53 | private int downloaded = 0;
54 |
55 | private int status = -1;
56 |
57 | private DebugDump dump;
58 |
59 | public URLDownloader(String downloadFolder, String fileName, URL downloadUrl) {
60 | this.url = downloadUrl;
61 | this.folder = downloadFolder;
62 | this.fileName = fileName;
63 | }
64 |
65 | public String getDownloadFolder() {
66 | return folder;
67 | }
68 |
69 | public String getFileName() {
70 | return fileName;
71 | }
72 |
73 | public String getUrl() {
74 | return url.toString();
75 | }
76 |
77 | public int getDownloaded() {
78 | return downloaded;
79 | }
80 |
81 | public int getSize() {
82 | return size;
83 | }
84 |
85 | public float getProgress() {
86 | return ((float) downloaded / size) * 100;
87 | }
88 |
89 | public int getStatus() {
90 | return status;
91 | }
92 |
93 | public void pause() {
94 | status = PAUSED;
95 | reportState();
96 | }
97 |
98 | public void resume() {
99 | status = DOWNLOADING;
100 | reportState();
101 | download();
102 | }
103 |
104 | public void cancel() {
105 | status = CANCELLED;
106 | reportState();
107 |
108 | File file = new File(folder + "\\" + fileName + ".osz");
109 | file.delete();
110 |
111 | downloaded = 0;
112 | }
113 |
114 | private void error() {
115 | status = ERROR;
116 | reportState();
117 | }
118 |
119 | public void download() {
120 | if (status != DOWNLOADING && status != COMPLETED) {
121 | status = DOWNLOADING;
122 | Thread thread = new Thread(this);
123 | thread.start();
124 | }
125 | }
126 |
127 | @Override
128 | public void run() {
129 | RandomAccessFile file = null;
130 | InputStream in = null;
131 |
132 | try {
133 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
134 |
135 | conn.setRequestProperty("Range", "bytes=" + downloaded + "-");
136 |
137 | conn.connect();
138 |
139 | if (conn.getResponseCode() / 100 != 2) {
140 | error();
141 | }
142 |
143 | int len = conn.getContentLength();
144 |
145 | if (len < 1) {
146 | error();
147 | }
148 |
149 | if (size == -1) {
150 | size = len;
151 | reportState();
152 | }
153 |
154 | file = new RandomAccessFile(folder + "\\" + fileName, "rw");
155 | file.seek(downloaded);
156 |
157 | in = conn.getInputStream();
158 |
159 | while (status == DOWNLOADING) {
160 | if (size == downloaded) {
161 | break;
162 | }
163 |
164 | byte[] buffer = size - downloaded > MAX_BUFFER_SIZE ? new byte[MAX_BUFFER_SIZE]
165 | : new byte[size - downloaded];
166 | int read = in.read(buffer);
167 | if (read == -1) {
168 | break;
169 | }
170 |
171 | file.write(buffer, 0, read);
172 | downloaded += read;
173 | reportState();
174 | }
175 |
176 | if (status == DOWNLOADING) {
177 | if (file != null) {
178 | try {
179 | file.close();
180 | } catch (IOException e) {
181 | e.printStackTrace();
182 | }
183 | }
184 |
185 | if (in != null) {
186 | try {
187 | in.close();
188 | } catch (IOException e) {
189 | e.printStackTrace();
190 | }
191 | }
192 |
193 | status = COMPLETED;
194 |
195 | reportState();
196 | }
197 | } catch (IOException e) {
198 | DumpManager.addDump(dump = new DebugDump(null, "(Try&catch try)", "Error reporting and debug dump",
199 | "(Try&catch finally)", "Error when downloading", false, e));
200 | error();
201 | } finally {
202 | if (file != null) {
203 | try {
204 | file.close();
205 | } catch (IOException e) {
206 | e.printStackTrace();
207 | }
208 | }
209 |
210 | if (in != null) {
211 | try {
212 | in.close();
213 | } catch (IOException e) {
214 | e.printStackTrace();
215 | }
216 | }
217 | }
218 | }
219 |
220 | private void reportState() {
221 | setChanged();
222 | notifyObservers();
223 | }
224 |
225 | @Override
226 | public DebugDump getErrorDump() {
227 | return dump;
228 | }
229 |
230 | }
231 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/method/ErrorCode.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.method;
2 |
3 | public class ErrorCode {
4 |
5 | public static final int RESULT_OK = 0;
6 |
7 | public static final int RESULT_NO_CREDENTIALS = 1;
8 |
9 | public static final int RESULT_LOGIN_FAILED = 2;
10 |
11 | public static final int RESULT_GET_BEATMAP_INFO_FAILED = 3;
12 |
13 | public static final int RESULT_VALIDATE_DOWNLOAD_URL_FAILED = 4;
14 |
15 | public static final Integer RESULT_DOWNLOAD_URL_TOO_SHORT = 5;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/method/MethodResult.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.method;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.github.mob41.osumer.debug.DebugDump;
6 |
7 | public class MethodResult implements Serializable {
8 |
9 | /**
10 | *
11 | */
12 | private static final long serialVersionUID = -5828470383744187539L;
13 |
14 | private T result;
15 |
16 | private DebugDump dump;
17 |
18 | public MethodResult(T result) {
19 | this(result, null);
20 | }
21 |
22 | public MethodResult(T result, DebugDump dump) {
23 | this.result = result;
24 | this.dump = dump;
25 | }
26 |
27 | public T getResult() {
28 | return result;
29 | }
30 |
31 | public DebugDump getDump() {
32 | return dump;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/Queue.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.queue;
30 |
31 | import java.awt.image.BufferedImage;
32 | import java.util.Observable;
33 | import java.util.Observer;
34 |
35 | import com.github.mob41.osumer.io.Downloader;
36 |
37 | public class Queue {
38 |
39 | private final Downloader downloader;
40 |
41 | private final String name;
42 |
43 | private final String thumbUrl;
44 |
45 | private long startTime = 0;
46 |
47 | private final QueueAction[] beforeActions;
48 |
49 | private final QueueAction[] afterActions;
50 |
51 | public Queue(String name, Downloader downloader, String thumbUrl, QueueAction[] beforeActions,
52 | QueueAction[] afterActions) {
53 | this.downloader = downloader;
54 | this.name = name;
55 | this.thumbUrl = thumbUrl;
56 | this.beforeActions = beforeActions;
57 | this.afterActions = afterActions;
58 | }
59 |
60 | public void runBeforeActions() {
61 | if (beforeActions != null) {
62 | for (QueueAction action : beforeActions) {
63 | action.run(this);
64 | }
65 | }
66 | }
67 |
68 | public void runAfterActions() {
69 | if (afterActions != null) {
70 | for (QueueAction action : afterActions) {
71 | action.run(this);
72 | }
73 | }
74 | }
75 |
76 | public Downloader getDownloader() {
77 | return downloader;
78 | }
79 |
80 | public String getName() {
81 | return name;
82 | }
83 |
84 | public float getProgress() {
85 | return downloader.getProgress();
86 | }
87 |
88 | public void start() {
89 | runBeforeActions();
90 |
91 | setStartTime(System.nanoTime());
92 | downloader.download();
93 |
94 | //downloader.deleteObservers();
95 | downloader.addObserver(new Observer() {
96 |
97 | @Override
98 | public void update(Observable arg0, Object arg1) {
99 | if (downloader.getStatus() == Downloader.COMPLETED) {
100 | runAfterActions();
101 | }
102 | }
103 |
104 | });
105 | }
106 |
107 | public void pause() {
108 | downloader.pause();
109 | }
110 |
111 | public void resume() {
112 | setStartTime(System.nanoTime());
113 | downloader.resume();
114 | }
115 |
116 | public void cancel() {
117 | downloader.cancel();
118 | downloader.deleteObservers();
119 | }
120 |
121 | public String getThumbUrl() {
122 | return thumbUrl;
123 | }
124 |
125 | public long getStartTime() {
126 | return startTime;
127 | }
128 |
129 | public void setStartTime(long startTime) {
130 | this.startTime = startTime;
131 | }
132 |
133 | public QueueAction[] getBeforeActions() {
134 | return beforeActions;
135 | }
136 |
137 | public QueueAction[] getAfterActions() {
138 | return afterActions;
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/QueueAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.queue;
30 |
31 | public interface QueueAction {
32 |
33 | public void run(Queue queue);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/QueueManager.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.queue;
30 |
31 | import java.util.Collections;
32 | import java.util.List;
33 | import java.util.concurrent.CopyOnWriteArrayList;
34 |
35 | import com.github.mob41.osumer.Configuration;
36 | import com.github.mob41.osumer.io.Downloader;
37 |
38 | public class QueueManager {
39 |
40 | public static final int DEFAULT_MAX_THREADS = 4;
41 |
42 | public final List queues;
43 |
44 | private Thread thread;
45 |
46 | private boolean keepRunning = false;
47 |
48 | private final Configuration config;
49 |
50 | // private int maxThread = 4;
51 |
52 | public QueueManager(Configuration config) {
53 | queues = new CopyOnWriteArrayList();
54 | this.config = config;
55 | startQueuing();
56 | }
57 |
58 | public void startQueuing() {
59 | if (!keepRunning) {
60 | keepRunning = true;
61 | thread = new Thread() {
62 | public void run() {
63 | while (keepRunning) {
64 | final int maxThread = config.getMaxThreads();
65 | final int delay = config.getNextCheckDelay();
66 |
67 | int running = 0;
68 | List list = getList();
69 | for (Queue queue : list) {
70 | if (queue.getDownloader().getStatus() == Downloader.DOWNLOADING) {
71 | running++;
72 | }
73 | }
74 |
75 | if (running < maxThread) {
76 | for (Queue queue : list) {
77 | if (running >= maxThread) {
78 | break;
79 | }
80 |
81 | if (queue.getDownloader().getStatus() == -1) {
82 | queue.start();
83 | running++;
84 | }
85 | }
86 | }
87 | try {
88 | sleep(delay);
89 | } catch (InterruptedException e) {
90 | break;
91 | }
92 | }
93 | }
94 | };
95 | thread.start();
96 | }
97 | }
98 |
99 | public void stopQueuing() {
100 | if (keepRunning) {
101 | keepRunning = false;
102 | thread.interrupt();
103 | }
104 | }
105 |
106 | public List getList() {
107 | return Collections.unmodifiableList(queues);
108 | }
109 |
110 | public boolean addQueue(Queue queue) {
111 | if (getQueue(queue.getName()) != null) {
112 | return false;
113 | } else {
114 | queues.add(queue);
115 | return true;
116 | }
117 | }
118 |
119 | public boolean removeQueue(Queue queue) {
120 | if (queues.contains(queue)) {
121 | queues.remove(queue);
122 | return true;
123 | } else {
124 | return false;
125 | }
126 | }
127 |
128 | public Queue getQueue(String name) {
129 | List copyList = Collections.unmodifiableList(queues);
130 |
131 | for (Queue queue : copyList) {
132 | if (queue.getName().equals(name)) {
133 | return queue;
134 | }
135 | }
136 |
137 | return null;
138 | }
139 |
140 | public void startAll() {
141 | List copyList = Collections.unmodifiableList(queues);
142 |
143 | for (Queue queue : copyList) {
144 | queue.start();
145 | }
146 | }
147 |
148 | public void cancelAll() {
149 | List copyList = Collections.unmodifiableList(queues);
150 |
151 | for (Queue queue : copyList) {
152 | queue.cancel();
153 | removeQueue(queue);
154 | }
155 | }
156 |
157 | public void pauseAll() {
158 | List copyList = Collections.unmodifiableList(queues);
159 |
160 | for (Queue queue : copyList) {
161 | queue.pause();
162 | }
163 | }
164 |
165 | public void resumeAll() {
166 | List copyList = Collections.unmodifiableList(queues);
167 |
168 | for (Queue queue : copyList) {
169 | queue.resume();
170 | }
171 | }
172 |
173 | }
174 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/QueueStatus.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.queue;
2 |
3 | import java.io.Serializable;
4 | import java.rmi.RemoteException;
5 |
6 | public class QueueStatus implements Serializable{
7 |
8 | private String title;
9 |
10 | private String fileName;
11 |
12 | private String thumbUrl;
13 |
14 | private int progress;
15 |
16 | private long eta;
17 |
18 | private long elapsed;
19 |
20 | private int status;
21 |
22 | public QueueStatus(String title, String fileName, String thumbUrl, int progress, long eta, long elapsed, int status) {
23 | super();
24 | this.title = title;
25 | this.fileName = fileName;
26 | this.thumbUrl = thumbUrl;
27 | this.progress = progress;
28 | this.eta = eta;
29 | this.elapsed = elapsed;
30 | this.status = status;
31 | }
32 |
33 | public String getFileName() {
34 | return fileName;
35 | }
36 |
37 | public void setFileName(String fileName) {
38 | this.fileName = fileName;
39 | }
40 |
41 | public String getThumbUrl() {
42 | return thumbUrl;
43 | }
44 |
45 | public void setThumbUrl(String thumbUrl) {
46 | this.thumbUrl = thumbUrl;
47 | }
48 |
49 | public int getProgress() {
50 | return progress;
51 | }
52 |
53 | public void setProgress(int progress) {
54 | this.progress = progress;
55 | }
56 |
57 | public long getEta() {
58 | return eta;
59 | }
60 |
61 | public void setEta(int eta) {
62 | this.eta = eta;
63 | }
64 |
65 | public long getElapsed() {
66 | return elapsed;
67 | }
68 |
69 | public void setElapsed(int elapsed) {
70 | this.elapsed = elapsed;
71 | }
72 |
73 | public int getStatus() {
74 | return status;
75 | }
76 |
77 | public void setStatus(int status) {
78 | this.status = status;
79 | }
80 |
81 | public String getTitle() {
82 | return title;
83 | }
84 |
85 | public void setTitle(String title) {
86 | this.title = title;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/actions/AfterSoundAction.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.queue.actions;
2 |
3 | import java.io.File;
4 |
5 | import com.github.mob41.osumer.Configuration;
6 | import com.github.mob41.osumer.debug.DebugDump;
7 | import com.github.mob41.osumer.debug.DumpManager;
8 | import com.github.mob41.osumer.queue.Queue;
9 | import com.github.mob41.osumer.queue.QueueAction;
10 |
11 | import javafx.embed.swing.JFXPanel;
12 | import javafx.scene.media.Media;
13 | import javafx.scene.media.MediaPlayer;
14 |
15 | public class AfterSoundAction implements QueueAction {
16 |
17 | private final Configuration config;
18 |
19 | public AfterSoundAction(Configuration config) {
20 | this.config = config;
21 | }
22 |
23 | @Override
24 | public void run(Queue queue) {
25 | Thread thread = new Thread(new Runnable() {
26 | public void run() {
27 | try {
28 | Media m = new Media(new File(config.getToneAfterDownloadPath()).toURI().toString());
29 | MediaPlayer mp = new MediaPlayer(m);
30 | mp.play();
31 | } catch (Exception e) {
32 | e.printStackTrace();
33 | DumpManager.addDump(new DebugDump(null, "---", "Play after download sound", "---", "Error occurred when trying to play sound", false, e));
34 | }
35 | }
36 | });
37 | thread.setDaemon(true);
38 | thread.start();
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/actions/BeatmapImportAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.queue.actions;
30 |
31 | import java.awt.Desktop;
32 | import java.io.File;
33 | import java.io.FileOutputStream;
34 | import java.io.IOException;
35 | import java.nio.file.Files;
36 |
37 | import javax.swing.JOptionPane;
38 |
39 | import com.github.mob41.osumer.Configuration;
40 | import com.github.mob41.osumer.io.Downloader;
41 | import com.github.mob41.osumer.queue.Queue;
42 | import com.github.mob41.osumer.queue.QueueAction;
43 |
44 | public class BeatmapImportAction implements QueueAction {
45 |
46 | private final Configuration config;
47 |
48 | public BeatmapImportAction(Configuration config) {
49 | this.config = config;
50 | }
51 |
52 | @Override
53 | public void run(Queue queue) {
54 | Downloader dwn = queue.getDownloader();
55 | String path = dwn.getDownloadFolder() + dwn.getFileName();
56 |
57 | File file = new File(path + ".osz");
58 |
59 | if (!file.exists()) {
60 | System.out.println("File not exists: " + path + ".osz");
61 | return;
62 | }
63 |
64 | int action = config.getDefaultOpenBeatmapAction();
65 |
66 |
67 | if (action == 1 || action == 2) {
68 | String loc = null;
69 | if (action == 1) {
70 | loc = System.getenv("LOCALAPPDATA") + "\\osu!\\Songs";
71 | } else {
72 | loc = config.getDefaultBeatmapSaveLocation();
73 | }
74 |
75 | File songsFolder = new File(loc);
76 |
77 | if (!songsFolder.exists()) {
78 | songsFolder.mkdirs();
79 | }
80 |
81 | File toFile = new File(loc + "\\" + dwn.getFileName() + ".osz");
82 |
83 | if (toFile.exists()) {
84 | toFile.delete();
85 | }
86 |
87 | FileOutputStream toFileOut;
88 | try {
89 | toFileOut = new FileOutputStream(toFile);
90 | Files.copy(file.toPath(), toFileOut);
91 | toFileOut.close();
92 | } catch (IOException e) {
93 | JOptionPane.showMessageDialog(null, "osumer Song Copy failed:\n\nFrom: " + path + "\nTo: " + loc + "\n\nMake sure you have access to that folder.\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
94 | e.printStackTrace();
95 | }
96 | } else {
97 | try {
98 | Desktop.getDesktop().open(file);
99 | } catch (IOException e) {
100 | e.printStackTrace();
101 | }
102 | }
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/actions/BeforeSoundAction.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.queue.actions;
2 |
3 | import java.io.File;
4 |
5 | import com.github.mob41.osumer.Configuration;
6 | import com.github.mob41.osumer.debug.DebugDump;
7 | import com.github.mob41.osumer.debug.DumpManager;
8 | import com.github.mob41.osumer.queue.Queue;
9 | import com.github.mob41.osumer.queue.QueueAction;
10 |
11 | import javafx.scene.media.Media;
12 | import javafx.scene.media.MediaPlayer;
13 |
14 | public class BeforeSoundAction implements QueueAction {
15 |
16 | private final Configuration config;
17 |
18 | public BeforeSoundAction(Configuration config) {
19 | this.config = config;
20 | }
21 |
22 | @Override
23 | public void run(Queue queue) {
24 | Thread thread = new Thread(new Runnable() {
25 | public void run() {
26 | try {
27 | Media m = new Media(new File(config.getToneBeforeDownloadPath()).toURI().toString());
28 | MediaPlayer mp = new MediaPlayer(m);
29 | mp.play();
30 | } catch (Exception e) {
31 | e.printStackTrace();
32 | DumpManager.addDump(new DebugDump(null, "---", "Play before download sound", "---", "Error occurred when trying to play sound", false, e));
33 | }
34 | }
35 | });
36 | thread.setDaemon(true);
37 | thread.start();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/actions/CustomImportAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.queue.actions;
30 |
31 | import java.awt.Desktop;
32 | import java.io.File;
33 | import java.io.FileOutputStream;
34 | import java.io.IOException;
35 | import java.nio.file.Files;
36 |
37 | import javax.swing.JOptionPane;
38 |
39 | import com.github.mob41.osumer.io.Downloader;
40 | import com.github.mob41.osumer.queue.Queue;
41 | import com.github.mob41.osumer.queue.QueueAction;
42 |
43 | public class CustomImportAction implements QueueAction {
44 |
45 | private final int action;
46 |
47 | private final String targetFileOrFolder;
48 |
49 | public CustomImportAction(int action, String targetFileOrFolder) {
50 | this.action = action;
51 | this.targetFileOrFolder = targetFileOrFolder;
52 | }
53 |
54 | @Override
55 | public void run(Queue queue) {
56 | Downloader dwn = queue.getDownloader();
57 | String path = dwn.getDownloadFolder() + dwn.getFileName();
58 |
59 | File file = new File(path + ".osz");
60 |
61 | if (!file.exists()) {
62 | System.out.println("File not exists: " + path + ".osz");
63 | return;
64 | }
65 |
66 | if (action == 1 || action == 2 || action == 3) {
67 | String loc = null;
68 | if (action == 1) {
69 | loc = System.getenv("LOCALAPPDATA") + "\\osu!\\Songs";
70 | } else {
71 | loc = targetFileOrFolder;
72 | }
73 |
74 | if (action == 3) {
75 | File songsFolder = new File(loc);
76 |
77 | if (!songsFolder.exists()) {
78 | songsFolder.mkdirs();
79 | }
80 | }
81 |
82 | String filePath;
83 | if (action == 2) {
84 | if (!loc.endsWith(".osz")) {
85 | loc = loc + ".osz";
86 | }
87 | filePath = loc;
88 | } else {
89 | filePath = loc + "\\" + dwn.getFileName() + ".osz";
90 | }
91 |
92 | File toFile = new File(filePath);
93 |
94 | if (toFile.exists()) {
95 | toFile.delete();
96 | }
97 |
98 | FileOutputStream toFileOut;
99 | try {
100 | toFileOut = new FileOutputStream(toFile);
101 | Files.copy(file.toPath(), toFileOut);
102 | toFileOut.close();
103 | } catch (IOException e) {
104 | JOptionPane.showMessageDialog(null, "osumer Song Copy failed:\n\nFrom: " + path + "\nTo: " + loc + "\n\nMake sure you have access to that folder.\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
105 | e.printStackTrace();
106 | }
107 | } else {
108 | try {
109 | Desktop.getDesktop().open(file);
110 | } catch (IOException e) {
111 | e.printStackTrace();
112 | }
113 | }
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/queue/actions/UpdaterRunAction.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.queue.actions;
2 |
3 | import java.io.IOException;
4 |
5 | import com.github.mob41.osumer.debug.DebugDump;
6 | import com.github.mob41.osumer.debug.DumpManager;
7 | import com.github.mob41.osumer.queue.Queue;
8 | import com.github.mob41.osumer.queue.QueueAction;
9 |
10 | public class UpdaterRunAction implements QueueAction{
11 |
12 | private final String filePath;
13 |
14 | public UpdaterRunAction(String filePath) {
15 | this.filePath = filePath;
16 | }
17 |
18 | @Override
19 | public void run(Queue queue) {
20 | try {
21 | System.out.println("Starting: \"" + filePath + "\"");
22 | Runtime.getRuntime().exec("cmd.exe /c \"" + filePath + "\" -install");
23 |
24 | try {
25 | Thread.sleep(5000);
26 | } catch (InterruptedException e) {
27 | e.printStackTrace();
28 | }
29 | System.exit(0);
30 | return;
31 | } catch (IOException e1) {
32 | e1.printStackTrace();
33 | DebugDump dump = new DebugDump(
34 | null,
35 | "(If[openFile] scope) (UI) Set status to lblStatus",
36 | "(Try scope) Open file loc using Desktop.getDesktop.open()",
37 | "(Try scope) Sleep 2000 ms (2 sec)",
38 | "Unable to open file",
39 | false,
40 | e1);
41 | DumpManager.addDump(dump);
42 | //TODO
43 | /*
44 | ErrorDumpDialog dialog = new ErrorDumpDialog(dump);
45 | dialog.setModal(true);
46 | dialog.setVisible(true);
47 | */
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/rmi/IDaemon.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.rmi;
2 |
3 | import java.awt.TrayIcon.MessageType;
4 | import java.io.IOException;
5 | import java.rmi.Remote;
6 | import java.rmi.RemoteException;
7 |
8 | import com.github.mob41.osumer.method.MethodResult;
9 | import com.github.mob41.osumer.queue.Queue;
10 | import com.github.mob41.osumer.queue.QueueManager;
11 | import com.github.mob41.osumer.queue.QueueStatus;
12 |
13 | public interface IDaemon extends Remote{
14 |
15 | public void test() throws RemoteException;
16 |
17 | public MethodResult addQueue(String url) throws RemoteException;
18 |
19 | public MethodResult addQueue(String url, int downloadAction, String targetFileOrFolder) throws RemoteException;
20 |
21 | public boolean removeQueue(String name) throws RemoteException;
22 |
23 | public QueueStatus[] getQueues() throws RemoteException;
24 |
25 | public void registerUi(IUI ui) throws RemoteException;
26 |
27 | public void unregisterUi(IUI ui) throws RemoteException;
28 |
29 | public void setOverlayAgreement(boolean agreed) throws RemoteException;
30 |
31 | public boolean isOverlayAgreement() throws RemoteException;
32 |
33 | public void startOsuWithOverlay() throws RemoteException;
34 |
35 | public void trayIconDisplayMessage(String caption, String text, MessageType msgType) throws RemoteException;
36 |
37 | public void reloadConfiguration() throws RemoteException, IOException;
38 |
39 | public void shutdown() throws RemoteException;
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/rmi/IUI.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.rmi;
2 |
3 | import java.io.IOException;
4 | import java.rmi.Remote;
5 | import java.rmi.RemoteException;
6 |
7 | import com.github.mob41.osumer.queue.Queue;
8 | import com.github.mob41.osumer.queue.QueueManager;
9 |
10 | public interface IUI extends Remote{
11 |
12 | public void onQueueStatusUpdate() throws RemoteException;
13 |
14 | public void wake() throws RemoteException;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/rmi/OverlayRmi.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.rmi;
2 |
3 | import java.awt.TrayIcon.MessageType;
4 | import java.rmi.Naming;
5 | import java.rmi.RemoteException;
6 |
7 | import javax.swing.JOptionPane;
8 |
9 | import com.github.mob41.osumer.queue.QueueStatus;
10 |
11 | public class OverlayRmi {
12 |
13 | private static final int RMI_DAEMON_PORT = 46726;
14 |
15 | private static final String RMI_DAEMON_PATH = "daemon";
16 |
17 | private IDaemon d = null;
18 |
19 | public OverlayRmi() {
20 | String daemonSuffix = RMI_DAEMON_PORT + "/" + RMI_DAEMON_PATH;
21 | try {
22 | d = (IDaemon) Naming.lookup("rmi://localhost:" + daemonSuffix); //Contact the daemon via RMI
23 | } catch (Exception e) {
24 | e.printStackTrace();
25 |
26 | String msg =
27 | "Could not connect to daemon! Please ensure osumer-daemon is running properly.\n" +
28 | "osumer2 Overlay requires daemon to be running. osu! will terminate right now.";
29 | System.err.println(msg);
30 |
31 | JOptionPane.showMessageDialog(null, msg,
32 | "osumer-overlay RMI Connection Error",
33 | JOptionPane.ERROR_MESSAGE);
34 |
35 | System.exit(-1);
36 | return;
37 | }
38 | }
39 |
40 | public void setLicenseAgreed(boolean agreed) throws RemoteException {
41 | d.setOverlayAgreement(agreed);
42 | }
43 |
44 | public boolean isLicenseAgreed() throws RemoteException {
45 | return d.isOverlayAgreement();
46 | }
47 |
48 | public QueueStatus[] getQueues() throws RemoteException{
49 | return d.getQueues();
50 | }
51 |
52 | public void test() throws RemoteException{
53 | d.trayIconDisplayMessage("Overlay has been successfully connected.", "osumer2", MessageType.INFO);
54 | d.test();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/updater/Announcement.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.updater;
2 |
3 | import java.util.Calendar;
4 |
5 | public class Announcement {
6 |
7 | private final Calendar time;
8 |
9 | private final String text;
10 |
11 | public Announcement(Calendar time, String text) {
12 | this.time = time;
13 | this.text = text;
14 | }
15 |
16 | public Calendar getTime() {
17 | return time;
18 | }
19 |
20 | public String getText() {
21 | return text;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/updater/AnnouncementChecker.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.updater;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.net.HttpURLConnection;
8 | import java.net.MalformedURLException;
9 | import java.net.URL;
10 | import java.util.Calendar;
11 |
12 | import org.json.JSONArray;
13 | import org.json.JSONException;
14 | import org.json.JSONObject;
15 |
16 | import com.github.mob41.osumer.debug.WithDumpException;
17 |
18 | public class AnnouncementChecker {
19 |
20 | private static final String ANNOUNCEMENT_LIST = "https://mob41.github.io/osumer-updater/announcements.json";
21 |
22 | public Announcement[] getAnnouncements() throws WithDumpException{
23 | URL url = null;
24 |
25 | try {
26 | url = new URL(ANNOUNCEMENT_LIST + "?update=" + Calendar.getInstance().getTimeInMillis());
27 | } catch (MalformedURLException e){
28 | throw new WithDumpException(
29 | ANNOUNCEMENT_LIST,
30 | "URL url = null;",
31 | "new URL(VERSION_LIST);",
32 | "URLConnection conn = url.openConnection();",
33 | "",
34 | false, e);
35 | }
36 |
37 | String data = "";
38 | try {
39 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
40 |
41 | conn.setRequestMethod("GET");
42 | conn.setRequestProperty("Connection", "close");
43 | conn.setUseCaches(false);
44 | conn.setConnectTimeout(10000);
45 | conn.setReadTimeout(10000);
46 |
47 | InputStream in = conn.getInputStream();
48 | BufferedReader reader = new BufferedReader(new InputStreamReader(in));
49 |
50 | String line;
51 | while ((line = reader.readLine()) != null){
52 | data += line;
53 | }
54 | } catch (IOException e) {
55 | throw new WithDumpException(
56 | ANNOUNCEMENT_LIST,
57 | "URL url = new URL(VERSION_LIST);",
58 | "(lots of code) -- Connecting and fetch data",
59 | "Data validating (isEmpty / null)",
60 | "",
61 | false, e);
62 | }
63 |
64 | if (data == null || data.isEmpty()){
65 | throw new WithDumpException(
66 | ANNOUNCEMENT_LIST,
67 | "(lots of code) -- Connecting and fetch data",
68 | "Data validating (isEmpty / null)",
69 | "Create JSONObject",
70 | "No data fetched. \"data\" is null/isEmpty",
71 | false);
72 | }
73 |
74 | JSONObject json = null;
75 | try {
76 | json = new JSONObject(data);
77 | } catch (JSONException e){
78 | throw new WithDumpException(
79 | ANNOUNCEMENT_LIST,
80 | "Data validating (isEmpty / null)",
81 | "Create JSONObject",
82 | "JSONObject validating \"announcements\" parameter",
83 | "Structure invalid",
84 | false, e);
85 | }
86 |
87 | if (json.isNull("announcements")){
88 | throw new WithDumpException(
89 | ANNOUNCEMENT_LIST,
90 | "Create JSONObject",
91 | "JSONObject validating \"sources\" parameter",
92 | "Parsing announcement json to objects",
93 | "Structure invalid, missing \"announcements\" parameter",
94 | false);
95 | }
96 |
97 | JSONArray arr = json.getJSONArray("announcements");
98 |
99 | Calendar cal;
100 | JSONObject obj;
101 | Announcement[] out = new Announcement[arr.length()];
102 | for (int i = 0; i < out.length; i++) {
103 | obj = arr.getJSONObject(i);
104 | if (obj.isNull("time") || obj.isNull("text")) {
105 | throw new WithDumpException(
106 | data,
107 | "JSONObject validating \"sources\" parameter",
108 | "Parsing announcement json to objects",
109 | "Output array",
110 | "Structure invalid, announcement json missing some parameters",
111 | false);
112 | }
113 | cal = Calendar.getInstance();
114 | cal.setTimeInMillis(obj.getLong("time"));
115 | out[i] = new Announcement(cal, obj.getString("text"));
116 | }
117 |
118 | return out;
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/updater/UpdateInfo.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.updater;
30 |
31 | public class UpdateInfo {
32 |
33 | private final String version;
34 |
35 | private final String webLink;
36 |
37 | private final String exeLink;
38 |
39 | private final String jarLink;
40 |
41 | private final String description;
42 |
43 | private final int branch;
44 |
45 | private final int buildNum;
46 |
47 | private final boolean isThisVersion;
48 |
49 | private final boolean upgradedVersion;
50 |
51 | public UpdateInfo(String description, String version, int branch, int buildNum, String webLink, String exeLink,
52 | String jarLink, boolean isThisVersion, boolean upgradedVersion) {
53 | this.description = description;
54 | this.version = version;
55 | this.webLink = webLink;
56 | this.exeLink = exeLink;
57 | this.jarLink = jarLink;
58 | this.branch = branch;
59 | this.buildNum = buildNum;
60 | this.isThisVersion = isThisVersion;
61 | this.upgradedVersion = upgradedVersion;
62 | }
63 |
64 | public String getVersion() {
65 | return version;
66 | }
67 |
68 | public int getBranch() {
69 | return branch;
70 | }
71 |
72 | public int getBuildNum() {
73 | return buildNum;
74 | }
75 |
76 | public String getDescription() {
77 | return description;
78 | }
79 |
80 | public boolean isThisVersion() {
81 | return isThisVersion;
82 | }
83 |
84 | public boolean isUpgradedVersion() {
85 | return upgradedVersion;
86 | }
87 |
88 | public String getExeLink() {
89 | return exeLink;
90 | }
91 |
92 | public String getJarLink() {
93 | return jarLink;
94 | }
95 |
96 | public String getWebLink() {
97 | return webLink;
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/osumer-lib/src/main/java/com/github/mob41/osumer/updater/VersionInfo.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Any modification, copies of sections of this file must be attached with this
3 | * license and shown clearly in the developer's project. The code can be used
4 | * as long as you state clearly you do not own it. Any violation might result in
5 | * a take-down.
6 | *
7 | * MIT License
8 | *
9 | * Copyright (c) 2016, 2017 Anthony Law
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | * copies of the Software, and to permit persons to whom the Software is
16 | * furnished to do so, subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all
19 | * copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | * SOFTWARE.
28 | *******************************************************************************/
29 | package com.github.mob41.osumer.updater;
30 |
31 | import com.github.mob41.osumer.Osumer;
32 | import com.github.mob41.osumer.updater.Updater;
33 |
34 | public class VersionInfo {
35 |
36 | private final String version;
37 |
38 | private final String branch;
39 |
40 | private final int buildNum;
41 |
42 | public VersionInfo(String version, String branch, int buildNum) {
43 | this.version = version;
44 | this.branch = branch;
45 | this.buildNum = buildNum;
46 | }
47 |
48 | public String getVersion() {
49 | return version;
50 | }
51 |
52 | public String getBranch() {
53 | return branch;
54 | }
55 |
56 | public int getBuildNum() {
57 | return buildNum;
58 | }
59 |
60 | /*
61 | public boolean isEqualToRunning() {
62 | return Updater.compareVersion(Osumer.OSUMER_VERSION, version) == 0 && Osumer.OSUMER_BRANCH.equals(branch)
63 | && Osumer.OSUMER_BUILD_NUM == buildNum;
64 | }
65 |
66 | public boolean isNewerThanRunning() {
67 | int result = Updater.compareVersion(Osumer.OSUMER_VERSION, version);
68 | return result == -1 || (result == 0 && Osumer.OSUMER_BUILD_NUM < buildNum);
69 | }
70 | */
71 | }
72 |
--------------------------------------------------------------------------------
/osumer-overlay/.gitignore:
--------------------------------------------------------------------------------
1 | cmake_install.cmake
2 | CMakeFiles
3 | CMakeFiles/*
--------------------------------------------------------------------------------
/osumer-overlay/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(osumer-overlay SHARED dllmain.cpp)
2 |
3 | add_dependencies(osumer-overlay gl3w)
4 | add_dependencies(osumer-overlay minhook)
5 | add_dependencies(osumer-overlay imgui)
6 |
7 | target_link_libraries(osumer-overlay gl3w)
8 | target_link_libraries(osumer-overlay imgui)
9 | target_link_libraries(osumer-overlay minhook)
10 | target_link_libraries(osumer-overlay ${JNI_LIBRARIES})
--------------------------------------------------------------------------------
/osumer-overlay/osumeroverlay.cpp:
--------------------------------------------------------------------------------
1 | // osumeroverlay.cpp : Defines the exported functions for the DLL application.
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 |
--------------------------------------------------------------------------------
/osumer-overlay/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // $safeprojectname$.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/osumer-overlay/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11 | // Windows Header Files:
12 | #include
13 |
14 |
15 |
16 | // TODO: reference additional headers your program requires here
17 |
--------------------------------------------------------------------------------
/osumer-overlay/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/osumer-setup/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | .vs/*
3 | Debug
4 | Debug/*
5 | Release
6 | Release/*
--------------------------------------------------------------------------------
/osumer-setup/osumer-setup.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.572
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "osumer-setup", "osumer-setup.vdproj", "{39F3CAAC-A041-493F-A613-90872A6A3A7C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Default = Debug|Default
11 | Release|Default = Release|Default
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {39F3CAAC-A041-493F-A613-90872A6A3A7C}.Debug|Default.ActiveCfg = Debug
15 | {39F3CAAC-A041-493F-A613-90872A6A3A7C}.Debug|Default.Build.0 = Debug
16 | {39F3CAAC-A041-493F-A613-90872A6A3A7C}.Release|Default.ActiveCfg = Release
17 | {39F3CAAC-A041-493F-A613-90872A6A3A7C}.Release|Default.Build.0 = Release
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {15919A1B-C5DD-4DE6-80B0-5CD37799C0E2}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/osumer-setup/vc10redist_x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-setup/vc10redist_x86.exe
--------------------------------------------------------------------------------
/osumer-setup/vc15redist_x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-setup/vc15redist_x86.exe
--------------------------------------------------------------------------------
/osumer-ui/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osumer-ui/pom.xml:
--------------------------------------------------------------------------------
1 |
29 |
30 | 4.0.0
31 |
32 | com.github.mob41
33 | osumer
34 | ${global.version}
35 |
36 | osumer-ui
37 | osumer-ui
38 | An UI to connect to osumer daemon.
39 |
40 |
41 |
42 | false
43 |
44 | bintray-dukke-maven
45 | bintray
46 | https://dl.bintray.com/dukke/maven
47 |
48 |
49 |
50 |
51 |
52 | false
53 |
54 | bintray-dukke-maven
55 | bintray-plugins
56 | https://dl.bintray.com/dukke/maven
57 |
58 |
59 |
60 |
61 | com.github.mob41
62 | osumer-debugdump
63 | ${global.version}
64 |
65 |
66 | com.github.mob41
67 | osums-api
68 | ${global.version}
69 |
70 |
71 | com.github.mob41
72 | osumer-lib
73 | ${global.version}
74 |
75 |
76 | com.github.mob41
77 | osumer-installer
78 | ${global.version}
79 |
80 |
81 | org.jfxtras
82 | jmetro
83 | 5.2
84 |
85 |
86 |
87 |
88 |
89 | org.apache.maven.plugins
90 | maven-dependency-plugin
91 |
92 |
93 | copy-dependencies
94 | prepare-package
95 |
96 | copy-dependencies
97 |
98 |
99 | ${project.parent.build.directory}/lib
100 | false
101 | false
102 | true
103 |
104 |
105 |
106 |
107 |
108 | org.apache.maven.plugins
109 | maven-jar-plugin
110 |
111 | ${project.parent.build.directory}
112 |
113 |
114 | true
115 | lib/
116 | com.github.mob41.osumer.ui.AppMain
117 |
118 |
119 |
120 |
121 |
122 | com.akathist.maven.plugins.launch4j
123 | launch4j-maven-plugin
124 |
125 |
126 | l4j-gui
127 | package
128 | launch4j
129 |
130 | gui
131 | ${project.parent.build.directory}/${project.artifactId}.exe
132 | ${project.parent.build.directory}/${project.artifactId}-${global.version}.jar
133 | osumer2
134 | https://github.com/mob41/osumer/issues/new
135 |
136 | com.github.mob41.osumer.ui.AppMain
137 | false
138 | anything
139 |
140 |
141 | jre
142 | 1.8.0
143 | 32
144 | 64
145 | 128
146 |
147 |
148 | ${global.generation}.${global.build}
149 | ${global.version}
150 | osumer2 UI
151 | Copyright (c) 2019 mob41
152 | ${global.generation}.${global.build}
153 | ${global.version}
154 | osumer2 UI
155 | osumer-ui
156 | osumer-ui.exe
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/java/com/github/mob41/osumer/ui/BeatmapPreviewDialogController.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.ui;
2 |
3 | import java.net.URL;
4 | import java.text.DecimalFormat;
5 | import java.util.List;
6 | import java.util.ResourceBundle;
7 |
8 | import com.github.mob41.osums.beatmap.OsuBeatmap;
9 | import com.github.mob41.osums.beatmap.OsuSong;
10 |
11 | import javafx.fxml.FXML;
12 | import javafx.fxml.Initializable;
13 | import javafx.scene.Node;
14 | import javafx.scene.control.Label;
15 | import javafx.scene.control.Tab;
16 | import javafx.scene.control.TabPane;
17 | import javafx.scene.image.Image;
18 | import javafx.scene.image.ImageView;
19 | import javafx.scene.layout.VBox;
20 |
21 | public class BeatmapPreviewDialogController implements Initializable {
22 |
23 | @FXML
24 | private ImageView image;
25 |
26 | @FXML
27 | private TabPane tab;
28 |
29 | @FXML
30 | private Tab beatmapTab;
31 |
32 | @FXML
33 | private VBox songBox;
34 |
35 | @FXML
36 | private VBox beatmapBox;
37 |
38 | private OsuSong map;
39 |
40 | @Override
41 | public void initialize(URL location, ResourceBundle resources) {
42 |
43 | }
44 |
45 | protected void preview(OsuSong map) {
46 | this.map = map;
47 |
48 | DecimalFormat df = new DecimalFormat("#.##");
49 | List songNodes = songBox.getChildren();
50 |
51 | songNodes.add(new Label("Name: " + map.getName()));
52 | songNodes.add(new Label("Artist: " + map.getArtist()));
53 | songNodes.add(new Label("Title: " + map.getTitle()));
54 | songNodes.add(new Label("BPM: " + map.getBpm()));
55 | songNodes.add(new Label("Creator: " + map.getCreator()));
56 | songNodes.add(new Label("Source: " + map.getSource()));
57 | songNodes.add(new Label("Genre: " + map.getGenre()));
58 | songNodes.add(new Label("Rating: " + df.format(map.getRating()) + "%"));
59 | songNodes.add(new Label("Good/Bad Votes: " + map.getGoodRating() + "/" + map.getBadRating()));
60 |
61 | if (map instanceof OsuBeatmap) { //TODO Future use
62 | OsuBeatmap bmap = (OsuBeatmap) map;
63 |
64 | List beatmapNodes = beatmapBox.getChildren();
65 |
66 | beatmapNodes.add(new Label("Circle Size: " + df.format(bmap.getCircleSize())));
67 | beatmapNodes.add(new Label("Approach Rate: " + df.format(bmap.getApproachRate())));
68 | beatmapNodes.add(new Label("Accuracy: " + df.format(bmap.getAccuracy())));
69 | beatmapNodes.add(new Label("HP Drain: " + df.format(bmap.getHpDrain())));
70 | beatmapNodes.add(new Label("Star Difficulty: " + df.format(bmap.getStarDifficulty())));
71 | beatmapNodes.add(new Label("Success Rate: " + df.format(bmap.getSuccessRate()) + "%"));
72 | } else {
73 | beatmapTab.setDisable(true);
74 | }
75 |
76 | image.setImage(new Image("http:" + map.getThumbUrl()));
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/java/com/github/mob41/osumer/ui/LoginDialogController.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.ui;
2 |
3 | import java.net.URL;
4 | import java.util.ResourceBundle;
5 |
6 | import javafx.fxml.FXML;
7 | import javafx.fxml.Initializable;
8 | import javafx.scene.control.PasswordField;
9 | import javafx.scene.control.TextField;
10 |
11 | public class LoginDialogController implements Initializable {
12 |
13 | @FXML
14 | private TextField usr;
15 |
16 | @FXML
17 | private PasswordField pwd;
18 |
19 | @Override
20 | public void initialize(URL location, ResourceBundle resources) {
21 |
22 | }
23 |
24 | public String getUser() {
25 | return usr.getText();
26 | }
27 |
28 | public String getPwd() {
29 | return pwd.getText();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/java/com/github/mob41/osumer/ui/ProgressDialogController.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.ui;
2 |
3 | import java.net.URL;
4 | import java.util.ResourceBundle;
5 |
6 | import javafx.fxml.FXML;
7 | import javafx.fxml.Initializable;
8 | import javafx.scene.control.Label;
9 | import javafx.scene.control.ProgressBar;
10 |
11 | public class ProgressDialogController implements Initializable {
12 |
13 | @FXML
14 | private Label headerText;
15 |
16 | @FXML
17 | private Label statusText;
18 |
19 | @FXML
20 | private ProgressBar progressBar;
21 |
22 | @Override
23 | public void initialize(URL location, ResourceBundle resources) {
24 |
25 | }
26 |
27 | public Label getHeaderText() {
28 | return headerText;
29 | }
30 |
31 | public Label getStatusText() {
32 | return statusText;
33 | }
34 |
35 | public ProgressBar getProgressBar() {
36 | return progressBar;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/java/com/github/mob41/osumer/ui/QueueController.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.ui;
2 |
3 | import java.net.URL;
4 | import java.rmi.RemoteException;
5 | import java.util.ResourceBundle;
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import com.github.mob41.osumer.io.Downloader;
9 | import com.github.mob41.osumer.queue.QueueStatus;
10 | import com.github.mob41.osumer.rmi.IDaemon;
11 |
12 | import javafx.event.ActionEvent;
13 | import javafx.event.EventHandler;
14 | import javafx.fxml.FXML;
15 | import javafx.fxml.Initializable;
16 | import javafx.scene.control.Alert;
17 | import javafx.scene.control.Alert.AlertType;
18 | import javafx.scene.control.ButtonType;
19 | import javafx.scene.control.Hyperlink;
20 | import javafx.scene.control.Label;
21 | import javafx.scene.control.ProgressBar;
22 | import javafx.scene.image.Image;
23 | import javafx.scene.image.ImageView;
24 |
25 | public class QueueController implements Initializable {
26 |
27 | @FXML
28 | private Label title;
29 |
30 | @FXML
31 | private Label status;
32 |
33 | @FXML
34 | private Label remain;
35 |
36 | @FXML
37 | private Label elapsed;
38 |
39 | @FXML
40 | private ProgressBar progressBar;
41 |
42 | @FXML
43 | private Hyperlink startLink;
44 |
45 | @FXML
46 | private Hyperlink pauseLink;
47 |
48 | @FXML
49 | private Hyperlink stopLink;
50 |
51 | @FXML
52 | private Hyperlink cancelLink;
53 |
54 | @FXML
55 | private ImageView image;
56 |
57 | private IDaemon d;
58 |
59 | private String lastThumbUrl = null;
60 |
61 | @Override
62 | public void initialize(URL location, ResourceBundle resources) {
63 | cancelLink.setOnAction(new EventHandler() {
64 |
65 | @Override
66 | public void handle(ActionEvent event) {
67 | cancelLink.setDisable(true);
68 | try {
69 | d.removeQueue(title.getText());
70 | } catch (RemoteException e) {
71 | cancelLink.setDisable(false);
72 | e.printStackTrace();
73 | Alert alert = new Alert(AlertType.ERROR, "Error requesting daemon to remove queue:\n" + e.getMessage(), ButtonType.OK);
74 | alert.showAndWait();
75 | }
76 |
77 | }
78 | });
79 | }
80 |
81 | private String nanoSecToString(long ns) {
82 | if (ns < 0) {
83 | return "...";
84 | }
85 |
86 | long sec = TimeUnit.NANOSECONDS.toSeconds(ns);
87 | long min = 0;
88 | if (sec >= 60) {
89 | min = (long) (sec / 60.0);
90 | sec -= min * 60;
91 | }
92 |
93 | long hr = 0;
94 | if (min >= 60) {
95 | hr = (long) (min / 60.0);
96 | min -= hr * 60;
97 | }
98 |
99 | return (hr != 0 ? (hr + " hr(s) ") : "") + (min != 0 ? (min + " min(s) ") : "") + sec + " sec(s)";
100 | }
101 |
102 | public void update(QueueStatus qs) {
103 | String thumbUrl = qs.getThumbUrl();
104 | //TODO To do with null thumb url
105 | if (thumbUrl != null && (lastThumbUrl == null || !lastThumbUrl.equals(thumbUrl))) {
106 | this.lastThumbUrl = thumbUrl;
107 | image.setImage(new Image(thumbUrl));
108 | }
109 | title.setText(qs.getTitle());
110 |
111 | int p = qs.getProgress();
112 | switch (qs.getStatus()) {
113 | case Downloader.DOWNLOADING:
114 | elapsed.setText("Elapsed Time: " + nanoSecToString(qs.getElapsed()));
115 | remain.setText("Remaining Time: " + nanoSecToString(qs.getEta()));
116 | status.setText("Status: Downloading... (" + p + "%)");
117 | progressBar.setProgress(p / 100.0);
118 | startLink.setDisable(true);
119 | pauseLink.setDisable(false);
120 | stopLink.setDisable(false);
121 | cancelLink.setDisable(false);
122 | break;
123 | case Downloader.COMPLETED:
124 | elapsed.setText("");
125 | remain.setText("");
126 | status.setText("Status: Completed.");
127 | startLink.setDisable(true);
128 | pauseLink.setDisable(true);
129 | stopLink.setDisable(true);
130 | cancelLink.setDisable(false);
131 | progressBar.setProgress(1);
132 | break;
133 | case Downloader.ERROR:
134 | elapsed.setText("");
135 | remain.setText("");
136 | status.setText("Status: Error occurred while downloading.");
137 | startLink.setDisable(true);
138 | pauseLink.setDisable(true);
139 | stopLink.setDisable(true);
140 | cancelLink.setDisable(false);
141 | progressBar.setProgress(0);
142 | break;
143 | case Downloader.PAUSED:
144 | elapsed.setText("");
145 | remain.setText("");
146 | status.setText("Status: Paused.");
147 | startLink.setDisable(true);
148 | pauseLink.setDisable(true);
149 | stopLink.setDisable(false);
150 | cancelLink.setDisable(false);
151 | break;
152 | case Downloader.CANCELLED:
153 | elapsed.setText("");
154 | remain.setText("");
155 | status.setText("Status: Cancelled.");
156 | startLink.setDisable(true);
157 | pauseLink.setDisable(true);
158 | stopLink.setDisable(true);
159 | cancelLink.setDisable(false);
160 | progressBar.setProgress(0);
161 | break;
162 | case -1:
163 | elapsed.setText("");
164 | remain.setText("");
165 | status.setText("Status: Waiting for queuing...");
166 | startLink.setDisable(true);
167 | pauseLink.setDisable(true);
168 | stopLink.setDisable(true);
169 | cancelLink.setDisable(false);
170 | break;
171 | default:
172 | elapsed.setText("");
173 | remain.setText("");
174 | status.setText("Status: Unknown status.");
175 | startLink.setDisable(true);
176 | pauseLink.setDisable(true);
177 | stopLink.setDisable(true);
178 | cancelLink.setDisable(false);
179 | }
180 | }
181 |
182 | public void setD(IDaemon d) {
183 | this.d = d;
184 | }
185 |
186 | public String getId() {
187 | return title.getText();
188 | }
189 |
190 | public Label getTitle() {
191 | return title;
192 | }
193 |
194 | public Label getStatus() {
195 | return status;
196 | }
197 |
198 | public Label getRemain() {
199 | return remain;
200 | }
201 |
202 | public Label getElapsed() {
203 | return elapsed;
204 | }
205 |
206 | public ProgressBar getProgressBar() {
207 | return progressBar;
208 | }
209 |
210 | public Hyperlink getStartLink() {
211 | return startLink;
212 | }
213 |
214 | public Hyperlink getPauseLink() {
215 | return pauseLink;
216 | }
217 |
218 | public Hyperlink getStopLink() {
219 | return stopLink;
220 | }
221 |
222 | public Hyperlink getCancelLink() {
223 | return cancelLink;
224 | }
225 |
226 | public ImageView getImage() {
227 | return image;
228 | }
229 |
230 | }
231 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/java/com/github/mob41/osumer/ui/UI.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osumer.ui;
2 |
3 | import java.rmi.RemoteException;
4 | import java.rmi.server.UnicastRemoteObject;
5 |
6 | import com.github.mob41.osumer.rmi.IUI;
7 |
8 | public class UI extends UnicastRemoteObject implements IUI {
9 |
10 | private final AppMain appMain;
11 |
12 | public UI(AppMain appMain) throws RemoteException {
13 | this.appMain = appMain;
14 | }
15 |
16 | @Override
17 | public void wake() throws RemoteException {
18 | appMain.wake();
19 | }
20 |
21 | @Override
22 | public void onQueueStatusUpdate() throws RemoteException {
23 | appMain.onQueueStatusUpdate();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/css/application.css:
--------------------------------------------------------------------------------
1 | .text-field {
2 | -fx-skin: null; /* To fix the annoying TextFieldSkin NullPointerException temporary */
3 | }
4 |
5 | .combo-box {
6 | -fx-skin: null;
7 | }
8 |
9 | .hyperlink:visited {
10 | -fx-text-fill: -fx-accent;
11 | }
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/image/osumerIcon_128px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-ui/src/main/resources/image/osumerIcon_128px.png
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/image/osumerIcon_16px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-ui/src/main/resources/image/osumerIcon_16px.png
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/image/osumerIcon_256px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-ui/src/main/resources/image/osumerIcon_256px.png
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/image/osumerIcon_32px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-ui/src/main/resources/image/osumerIcon_32px.png
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/image/osumerIcon_64px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/osumer-ui/src/main/resources/image/osumerIcon_64px.png
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/view/BeatmapPreviewDialogLayout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/view/LoginDialogLayout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/view/ProgressDialogLayout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/osumer-ui/src/main/resources/view/QueueLayout.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/osumer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.572
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "osumer-setup", "osumer-setup\osumer-setup.vdproj", "{61E5885C-6583-4473-8027-8A54A2C58BF3}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Default = Debug|Default
11 | Release|Default = Release|Default
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {61E5885C-6583-4473-8027-8A54A2C58BF3}.Debug|Default.ActiveCfg = Debug
15 | {61E5885C-6583-4473-8027-8A54A2C58BF3}.Debug|Default.Build.0 = Debug
16 | {61E5885C-6583-4473-8027-8A54A2C58BF3}.Release|Default.ActiveCfg = Release
17 | {61E5885C-6583-4473-8027-8A54A2C58BF3}.Release|Default.Build.0 = Release
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {74FCBC03-70FA-4B35-994A-7282D8EF9C4F}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/osums-api/.gitignore:
--------------------------------------------------------------------------------
1 | .project
2 | .classpath
3 | .settings
4 | .settings/*
5 | /target/
--------------------------------------------------------------------------------
/osums-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osums-api
9 |
10 |
11 | org.jsoup
12 | jsoup
13 | 1.10.1
14 |
15 |
16 | com.github.mob41
17 | osumer-debugdump
18 | ${global.version}
19 |
20 |
21 | commons-io
22 | commons-io
23 | 2.5
24 |
25 |
26 |
27 |
28 |
29 | org.apache.maven.plugins
30 | maven-dependency-plugin
31 |
32 |
33 | copy-dependencies
34 | prepare-package
35 |
36 | copy-dependencies
37 |
38 |
39 | ${project.parent.build.directory}/lib
40 | false
41 | false
42 | true
43 |
44 |
45 |
46 |
47 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/OsumsNewParser.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums;
2 |
3 | import org.jsoup.nodes.Document;
4 |
5 | import com.github.mob41.osumer.debug.WithDumpException;
6 | import com.github.mob41.osums.beatmap.OsuBeatmap;
7 | import com.github.mob41.osums.beatmap.OsuSong;
8 | import com.github.mob41.osums.search.SongResult;
9 | import com.github.mob41.osums.search.SearchFilter;
10 | import com.github.mob41.osums.search.SearchResult;
11 |
12 | public class OsumsNewParser extends Osums {
13 |
14 | @Override
15 | public SearchResult searchOnlineMaps(String keywords, SearchFilter[] filters) throws WithDumpException {
16 | // TODO Auto-generated method stub
17 | return null;
18 | }
19 |
20 | @Override
21 | public int login(String username, String password) throws WithDumpException {
22 | // TODO Auto-generated method stub
23 | return 0;
24 | }
25 |
26 | @Override
27 | public boolean logout() throws WithDumpException {
28 | // TODO Auto-generated method stub
29 | return false;
30 | }
31 |
32 | @Override
33 | public boolean isLoggedIn() {
34 | // TODO Auto-generated method stub
35 | return false;
36 | }
37 |
38 | @Override
39 | public boolean checkLoggedIn() {
40 | // TODO Auto-generated method stub
41 | return false;
42 | }
43 |
44 | @Override
45 | public OsuSong getSongInfo(String link) throws WithDumpException {
46 | // TODO Auto-generated method stub
47 | return null;
48 | }
49 |
50 | @Override
51 | public OsuBeatmap getBeatmapInfo(String link) throws WithDumpException {
52 | // TODO Auto-generated method stub
53 | return null;
54 | }
55 |
56 | @Override
57 | public OsuSong parseSong(String originalUrl, Document doc) {
58 | // TODO Auto-generated method stub
59 | return null;
60 | }
61 |
62 | @Override
63 | public SearchResult searchOnlineMaps(String keywords, SearchFilter[] filters, int page) throws WithDumpException {
64 | // TODO Auto-generated method stub
65 | return null;
66 | }
67 |
68 | @Override
69 | public SongResult[] parseSearch(String category, Document doc) throws WithDumpException {
70 | // TODO Auto-generated method stub
71 | return null;
72 | }
73 |
74 | @Override
75 | public boolean isVaildBeatmapUrl(String url) {
76 | return checkVaildBeatmapUrl(url);
77 | }
78 |
79 | public static boolean checkVaildBeatmapUrl(String url) {
80 | return false;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/beatmap/OsuBeatmap.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 Anthony Law
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *******************************************************************************/
24 | package com.github.mob41.osums.beatmap;
25 |
26 | public class OsuBeatmap extends OsuSong{
27 |
28 | private final float circleSize;
29 |
30 | private final float approachRate;
31 |
32 | private final float hpDrain;
33 |
34 | private final float accuracy;
35 |
36 | private final float starDifficulty;
37 |
38 | private final float success_rate;
39 |
40 | public OsuBeatmap(String originalUrl, String name, String title,
41 | String artist, String creator, String source, String genre, String dwnUrl,
42 | String thumbUrl, int badRating, int goodRating,
43 | float bpm, float circleSize, float approachRate, float hpDrain,
44 | float acurracy, float starDifficulty, float successRate, boolean pageBeatmap) {
45 | super(originalUrl, name, title, artist, creator, source, genre, dwnUrl, thumbUrl, badRating, goodRating, bpm, pageBeatmap);
46 | this.circleSize = circleSize;
47 | this.approachRate = approachRate;
48 | this.hpDrain = hpDrain;
49 | this.accuracy = acurracy;
50 | this.starDifficulty = starDifficulty;
51 | this.success_rate = successRate;
52 | }
53 |
54 | public float getStarDifficulty() {
55 | return starDifficulty;
56 | }
57 |
58 | public float getSuccessRate() {
59 | return success_rate;
60 | }
61 |
62 | public float getCircleSize() {
63 | return circleSize;
64 | }
65 |
66 | public float getApproachRate() {
67 | return approachRate;
68 | }
69 |
70 | public float getHpDrain() {
71 | return hpDrain;
72 | }
73 |
74 | public float getAccuracy() {
75 | return accuracy;
76 | }
77 |
78 | public static boolean equalsArr(String[] arg0, String[] arg1){
79 | if (arg0 == null && arg1 == null){
80 | return true;
81 | } else if (arg0 == null || arg1 == null) {
82 | return false;
83 | }
84 |
85 | if (arg0.length != arg1.length){
86 | return false;
87 | }
88 |
89 | for (int i = 0; i < arg0.length; i++){
90 | if (!arg0[i].equals(arg1[i])){
91 | return false;
92 | }
93 | }
94 | return true;
95 | }
96 |
97 | public boolean equals(OsuBeatmap map){
98 | return getArtist().equals(map.getArtist()) &&
99 | getBadRating() == map.getBadRating() &&
100 | getBpm() == map.getBpm() &&
101 | getCreator().equals(map.getCreator()) &&
102 | //equalsArr(getDifficulties(), map.getDifficulties()) &&
103 | getDwnUrl().equals(map.getDwnUrl()) &&
104 | getGenre().equals(map.getGenre()) &&
105 | getGoodRating() == map.getGoodRating() &&
106 | getName().equals(map.getName()) &&
107 | getRating() == map.getRating() &&
108 | getSource().equals(map.getSource()) &&
109 | getCircleSize() == map.getCircleSize() &&
110 | getApproachRate() == map.getApproachRate() &&
111 | getHpDrain() == map.getHpDrain() &&
112 | getAccuracy() == map.getAccuracy() &&
113 | getStarDifficulty() == map.getStarDifficulty() &&
114 | getSuccessRate() == map.getSuccessRate() &&
115 | getThumbUrl().equals(map.getThumbUrl()) &&
116 | getTitle().equals(map.getTitle());
117 | }
118 |
119 | /*
120 | public JSONObject toJson(){
121 | return mapToJson(this);
122 | }
123 |
124 | public static JSONObject mapToJson(OsuBeatmap map){
125 | JSONObject json = new JSONObject();
126 | json.put("orgUrl", map.getOriginalUrl());
127 | json.put("artist", map.getArtist());
128 | json.put("badRating", map.getBadRating());
129 | json.put("bpm", map.getBpm());
130 | json.put("creator", map.getCreator());
131 | //json.put("diff", map.getDifficulties());
132 | json.put("dwnUrl", map.getDwnUrl());
133 | json.put("genre", map.getGenre());
134 | json.put("goodRating", map.getGoodRating());
135 | json.put("name", map.getName());
136 | json.put("rating", map.getRating());
137 | json.put("source", map.getSource());
138 | json.put("circleSize", map.getCircleSize());
139 | json.put("approachRate", map.getApproachRate());
140 | json.put("hpDrain", map.getHpDrain());
141 | json.put("accuracy", map.getAccuracy());
142 | json.put("starDiff", map.getStarDifficulty());
143 | json.put("successRate", map.getSuccessRate());
144 | json.put("thumbUrl", map.getThumbUrl());
145 | json.put("title", map.getTitle());
146 | return json;
147 | }
148 |
149 | public static OsuBeatmap fromJson(JSONObject json){
150 | return new OsuBeatmap(
151 | json.getString("orgUrl"), json.getString("name"), json.getString("title"),
152 | json.getString("artist"), json.getString("creator"), json.getString("source"),
153 | json.getString("genre"), json.getString("dwnUrl"), json.getString("thumbUrl"),
154 | (float) json.getDouble("circleSize"), (float) json.getDouble("approachRate"), (float) json.getDouble("hpDrain"),
155 | (float) json.getDouble("accuracy"), (float) json.getDouble("starDiff"), json.getInt("badRating"),
156 | json.getInt("goodRating"), (float) json.getDouble("bpm"), (float) json.getDouble("successRate"),
157 | true);
158 | }
159 | */
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/beatmap/OsuSong.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 Anthony Law
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *******************************************************************************/
24 | package com.github.mob41.osums.beatmap;
25 |
26 | public class OsuSong {
27 |
28 | private final String originalUrl;
29 |
30 | private final String name;
31 |
32 | //private final String[] difficulties;
33 |
34 | private final String title;
35 |
36 | private final String artist;
37 |
38 | private final String creator;
39 |
40 | private final String source;
41 |
42 | private final String genre;
43 |
44 | private final String dwnUrl;
45 |
46 | private final String thumbUrl;
47 |
48 | private final int bad_rating;
49 |
50 | private final int good_rating;
51 |
52 | private final float bpm;
53 |
54 | private final boolean pageBeatmap;
55 |
56 | public OsuSong(String originalUrl, String name, String title, //... String name, String[] difficulties ...
57 | String artist, String creator, String source, String genre, String dwnUrl,
58 | String thumbUrl, int badRating, int goodRating,
59 | float bpm, boolean pageBeatmap) {
60 | this.originalUrl = originalUrl;
61 | this.name = name;
62 | //this.difficulties = difficulties;
63 | this.title = title;
64 | this.artist = artist;
65 | this.creator = creator;
66 | this.source = source;
67 | this.genre = genre;
68 | this.dwnUrl = dwnUrl;
69 | this.thumbUrl = thumbUrl;
70 | this.bad_rating = badRating;
71 | this.good_rating = goodRating;
72 | this.bpm = bpm;
73 | this.pageBeatmap = pageBeatmap;
74 | }
75 |
76 | public String getName(){
77 | return name;
78 | }
79 |
80 | //TODO Unnecessary for a beatmap URL instead of song URL
81 | /*
82 | public String[] getDifficulties(){
83 | return difficulties;
84 | }
85 | */
86 |
87 | public String getTitle(){
88 | return title;
89 | }
90 |
91 | public String getArtist() {
92 | return artist;
93 | }
94 |
95 | public String getCreator() {
96 | return creator;
97 | }
98 |
99 | public String getSource() {
100 | return source;
101 | }
102 |
103 | public String getGenre() {
104 | return genre;
105 | }
106 |
107 | public String getDwnUrl() {
108 | return dwnUrl;
109 | }
110 |
111 | public String getThumbUrl() {
112 | return thumbUrl;
113 | }
114 |
115 | public int getBadRating() {
116 | return bad_rating;
117 | }
118 |
119 | public int getGoodRating() {
120 | return good_rating;
121 | }
122 |
123 | public float getRating(){
124 | return (float) good_rating / (bad_rating + good_rating) * 100;
125 | }
126 |
127 | public float getBpm() {
128 | return bpm;
129 | }
130 |
131 | public String getOriginalUrl() {
132 | return originalUrl;
133 | }
134 |
135 | public static boolean equalsArr(String[] arg0, String[] arg1){
136 | if (arg0 == null && arg1 == null){
137 | return true;
138 | } else if (arg0 == null || arg1 == null) {
139 | return false;
140 | }
141 |
142 | if (arg0.length != arg1.length){
143 | return false;
144 | }
145 |
146 | for (int i = 0; i < arg0.length; i++){
147 | if (!arg0[i].equals(arg1[i])){
148 | return false;
149 | }
150 | }
151 | return true;
152 | }
153 |
154 | public boolean equals(OsuSong map){
155 | return getArtist().equals(map.getArtist()) &&
156 | getBadRating() == map.getBadRating() &&
157 | getBpm() == map.getBpm() &&
158 | getCreator().equals(map.getCreator()) &&
159 | //equalsArr(getDifficulties(), map.getDifficulties()) &&
160 | getDwnUrl().equals(map.getDwnUrl()) &&
161 | getGenre().equals(map.getGenre()) &&
162 | getGoodRating() == map.getGoodRating() &&
163 | getName().equals(map.getName()) &&
164 | getRating() == map.getRating() &&
165 | getSource().equals(map.getSource()) &&
166 | getThumbUrl().equals(map.getThumbUrl()) &&
167 | getTitle().equals(map.getTitle());
168 | }
169 |
170 | public boolean isPageBeatmap() {
171 | return pageBeatmap;
172 | }
173 |
174 | /*
175 | public JSONObject toJson(){
176 | return mapToJson(this);
177 | }
178 |
179 | public static JSONObject mapToJson(OsuBeatmap map){
180 | JSONObject json = new JSONObject();
181 | json.put("orgUrl", map.getOriginalUrl());
182 | json.put("artist", map.getArtist());
183 | json.put("badRating", map.getBadRating());
184 | json.put("bpm", map.getBpm());
185 | json.put("creator", map.getCreator());
186 | //json.put("diff", map.getDifficulties());
187 | json.put("dwnUrl", map.getDwnUrl());
188 | json.put("genre", map.getGenre());
189 | json.put("goodRating", map.getGoodRating());
190 | json.put("name", map.getName());
191 | json.put("rating", map.getRating());
192 | json.put("source", map.getSource());
193 | json.put("circleSize", map.getCircleSize());
194 | json.put("approachRate", map.getApproachRate());
195 | json.put("hpDrain", map.getHpDrain());
196 | json.put("accuracy", map.getAccuracy());
197 | json.put("starDiff", map.getStarDifficulty());
198 | json.put("successRate", map.getSuccessRate());
199 | json.put("thumbUrl", map.getThumbUrl());
200 | json.put("title", map.getTitle());
201 | return json;
202 | }
203 |
204 | public static OsuBeatmap fromJson(JSONObject json){
205 | return new OsuBeatmap(
206 | json.getString("orgUrl"), json.getString("name"), json.getString("title"),
207 | json.getString("artist"), json.getString("creator"), json.getString("source"),
208 | json.getString("genre"), json.getString("dwnUrl"), json.getString("thumbUrl"),
209 | (float) json.getDouble("circleSize"), (float) json.getDouble("approachRate"), (float) json.getDouble("hpDrain"),
210 | (float) json.getDouble("accuracy"), (float) json.getDouble("starDiff"), json.getInt("badRating"),
211 | json.getInt("goodRating"), (float) json.getDouble("bpm"), (float) json.getDouble("successRate"),
212 | true);
213 | }
214 | */
215 |
216 | }
217 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/search/RankFilter.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.search;
2 |
3 | public interface RankFilter extends SearchFilter {
4 |
5 | public String getRank();
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/search/SearchFilter.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.search;
2 |
3 | public interface SearchFilter {
4 |
5 | public String handleUrl(String url);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/search/SearchResult.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.search;
2 |
3 | public class SearchResult {
4 |
5 | private final SongResult[] result;
6 |
7 | private final int currentPage;
8 |
9 | private final int totalPages;
10 |
11 | public SearchResult(SongResult[] result, int currentPage, int totalPages) {
12 | super();
13 | this.result = result;
14 | this.currentPage = currentPage;
15 | this.totalPages = totalPages;
16 | }
17 |
18 | public int getTotalPages() {
19 | return totalPages;
20 | }
21 |
22 | public int getCurrentPage() {
23 | return currentPage;
24 | }
25 |
26 | public SongResult[] getResult() {
27 | return result;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/search/SongResult.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.search;
2 |
3 | import com.github.mob41.osumer.debug.WithDumpException;
4 | import com.github.mob41.osums.Osums;
5 | import com.github.mob41.osums.beatmap.OsuSong;
6 |
7 | public class SongResult {
8 |
9 | private static final String SONG_URL = "https://osu.ppy.sh/s/";
10 |
11 | private int id;
12 |
13 | private String rank;
14 |
15 | private String artist;
16 |
17 | private String title;
18 |
19 | private String creator;
20 |
21 | private String[] tags;
22 |
23 | private int favourites;
24 |
25 | private int plays;
26 |
27 | protected SongResult(){
28 |
29 | }
30 |
31 | public SongResult(int id, String rank, String artist, String title, String creator, String[] tags, int favourites, int plays) {
32 | this.id = id;
33 | this.rank = rank;
34 | this.artist = artist;
35 | this.title = title;
36 | this.creator = creator;
37 | this.tags = tags;
38 | this.favourites = favourites;
39 | this.plays = plays;
40 | }
41 |
42 | public String getArtist() {
43 | return artist;
44 | }
45 |
46 | public String getTitle() {
47 | return title;
48 | }
49 |
50 | public String getCreator() {
51 | return creator;
52 | }
53 |
54 | public String[] getTags() {
55 | return tags;
56 | }
57 |
58 | public int getFavourites() {
59 | return favourites;
60 | }
61 |
62 | public int getPlays() {
63 | return plays;
64 | }
65 |
66 | public OsuSong getOsuSong(Osums osums) throws WithDumpException{
67 | return osums.getSongInfo(SONG_URL + id);
68 | }
69 |
70 | public int getId() {
71 | return id;
72 | }
73 |
74 | public String getRank() {
75 | return rank;
76 | }
77 |
78 | /*
79 | public JSONObject toJson(){
80 | JSONArray arr = new JSONArray();
81 |
82 | for (int i = 0; i < tags.length; i++){
83 | arr.put(tags[i]);
84 | }
85 |
86 | JSONObject json = new JSONObject();
87 | json.put("id", id);
88 | json.put("artist", artist);
89 | json.put("title", title);
90 | json.put("creator", creator);
91 | json.put("tags", arr);
92 | json.put("favourites", favourites);
93 | json.put("plays", plays);
94 | json.put("beatmapUrl", beatmapUrl);
95 | json.put("thumbUrl", thumbUrl);
96 | json.put("thumbData", thumbData);
97 | return json;
98 | }
99 |
100 | public static ResultBeatmap fromJson(JSONObject json){
101 | JSONArray tagsArr = json.getJSONArray("tags");
102 | String[] tags = new String[tagsArr.length()];
103 | for (int i = 0; i < tags.length; i++){
104 | tags[i] = tagsArr.getString(i);
105 | }
106 |
107 | return new ResultBeatmap(
108 | json.getInt("id"), json.getString("artist"), json.getString("title"),
109 | json.getString("creator"), tags, json.getInt("favourites"), json.getInt("plays"),
110 | json.getString("beatmapUrl"), json.getString("thumbUrl"), json.getString("thumbData")
111 | );
112 | }
113 | */
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/osums-api/src/main/java/com/github/mob41/osums/search/StringRankFilter.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.search;
2 |
3 | public class StringRankFilter implements RankFilter {
4 |
5 | private final String rank;
6 |
7 | public StringRankFilter(String rank) {
8 | this.rank = rank;
9 | }
10 |
11 | public String getRank() {
12 | return rank;
13 | }
14 |
15 | @Override
16 | public String handleUrl(String url) {
17 | return url;
18 | };
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/osums-server/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/osums-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.github.mob41
5 | osumer
6 | ${global.version}
7 |
8 | osums-server
9 |
10 |
11 | com.github.mob41
12 | osums-api
13 | ${global.version}
14 |
15 |
16 | org.eclipse.jetty
17 | jetty-server
18 | 9.4.20.v20190813
19 |
20 |
21 | org.eclipse.jetty
22 | jetty-servlet
23 | 9.4.20.v20190813
24 |
25 |
26 | org.eclipse.jetty
27 | jetty-servlets
28 | 9.4.20.v20190813
29 |
30 |
31 | com.google.code.gson
32 | gson
33 | 2.8.5
34 |
35 |
36 | org.xerial
37 | sqlite-jdbc
38 | 3.28.0
39 |
40 |
41 | org.slf4j
42 | slf4j-api
43 | 1.7.28
44 |
45 |
46 | org.slf4j
47 | slf4j-log4j12
48 | 1.7.28
49 |
50 |
51 |
--------------------------------------------------------------------------------
/osums-server/src/main/java/com/github/mob41/osums/server/Main.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.server;
2 |
3 | import org.eclipse.jetty.server.Server;
4 | import org.eclipse.jetty.servlet.FilterHolder;
5 | import org.eclipse.jetty.servlet.ServletContextHandler;
6 | import org.eclipse.jetty.servlet.ServletHolder;
7 | import org.eclipse.jetty.servlets.CrossOriginFilter;
8 |
9 | import com.github.mob41.osums.Osums;
10 | import com.github.mob41.osums.OsumsOldParser;
11 |
12 | public class Main {
13 |
14 | public static void main(String[] args) throws Exception {
15 | Osums osums = new OsumsOldParser();
16 | OsumsServer osumsServer = new OsumsServer(osums, OsumsServer.DEFAULT_PROP_FILE_NAME);
17 |
18 | Server server = new Server(6099);
19 |
20 | FilterHolder filterHolder = new FilterHolder(CrossOriginFilter.class);
21 | filterHolder.setInitParameter("allowedOrigins", "https://www.osumer.ml");
22 | filterHolder.setInitParameter("allowedHeaders", "X-Requested-With");
23 | filterHolder.setInitParameter("allowedMethods", "GET");
24 |
25 | ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
26 | servletHandler.setContextPath("/");
27 | servletHandler.addServlet(new ServletHolder(new QueryServlet(osums, osumsServer)), "/query");
28 | servletHandler.addFilter(filterHolder, "/query", null);
29 |
30 | server.setHandler(servletHandler);
31 |
32 | server.start();
33 | server.join();
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/osums-server/src/main/java/com/github/mob41/osums/server/QueryOutput.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.server;
2 |
3 | import com.github.mob41.osums.search.SongResult;
4 |
5 | public class QueryOutput {
6 |
7 | public int result;
8 |
9 | public String msg;
10 |
11 | public int currentPage;
12 |
13 | public int totalPages;
14 |
15 | public SongResult[] output;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/osums-server/src/main/java/com/github/mob41/osums/server/QueryServlet.java:
--------------------------------------------------------------------------------
1 | package com.github.mob41.osums.server;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.http.HttpServlet;
7 | import javax.servlet.http.HttpServletRequest;
8 | import javax.servlet.http.HttpServletResponse;
9 |
10 | import com.github.mob41.osums.Osums;
11 | import com.github.mob41.osums.search.SearchResult;
12 | import com.github.mob41.osums.search.SongResult;
13 | import com.google.gson.Gson;
14 |
15 | public class QueryServlet extends HttpServlet {
16 |
17 | /**
18 | *
19 | */
20 | private static final long serialVersionUID = 9033797298845660820L;
21 |
22 | private Osums osums;
23 |
24 | private OsumsServer srv;
25 |
26 | public QueryServlet(Osums osums, OsumsServer srv) {
27 | this.osums = osums;
28 | this.srv = srv;
29 | }
30 |
31 | @Override
32 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
33 | String itemsStr = req.getParameter("i");
34 | String pageStr = req.getParameter("p");
35 | String key = req.getParameter("k");
36 |
37 | resp.setContentType("application/json");
38 |
39 | QueryOutput output = new QueryOutput();
40 |
41 | if (itemsStr == null || pageStr == null) {
42 | output.result = -1;
43 | output.msg = "Invalid request";
44 | resp.setStatus(400);
45 | end(resp, output);
46 | return;
47 | }
48 |
49 | if (key == null) {
50 | key = "";
51 | }
52 |
53 | int items = -1;
54 | int page = -1;
55 | try {
56 | items = Integer.parseInt(itemsStr);
57 | page = Integer.parseInt(pageStr);
58 | } catch (NumberFormatException e) {
59 | output.result = -1;
60 | output.msg = "Invalid request";
61 | resp.setStatus(400);
62 | end(resp, output);
63 | return;
64 | }
65 | /*
66 | int max = (int) Math.ceil(results.length / items);
67 |
68 | if (page > max) {
69 | output.result = -1;
70 | output.msg = "Invalid request";
71 | resp.setStatus(400);
72 | end(resp, output);
73 | return;
74 | }
75 | */
76 |
77 | SearchResult result = null;
78 | try {
79 | result = srv.searchSong(key, null, items, page);
80 | } catch (Exception e) {
81 | e.printStackTrace();
82 | output.result = -2;
83 | output.msg = "Server Error";
84 | resp.setStatus(503);
85 | end(resp, output);
86 | return;
87 | }
88 |
89 | SongResult[] results = result.getResult();
90 |
91 | if (results == null) {
92 | output.result = -3;
93 | output.msg = "No result";
94 | end(resp, output);
95 | return;
96 | }
97 |
98 | output.currentPage = page;
99 | output.totalPages = result.getTotalPages();
100 | output.result = 0;
101 | output.output = results;
102 | end(resp, output);
103 | return;
104 | }
105 |
106 | private void end(HttpServletResponse resp, QueryOutput output) throws IOException {
107 | Gson gson = new Gson();
108 | resp.getWriter().println(gson.toJson(output));
109 | resp.getWriter().flush();
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/osums-server/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG and its only appender to A1.
2 | log4j.rootLogger=INFO, A1
3 |
4 | # A1 is set to be a ConsoleAppender.
5 | log4j.appender.A1=org.apache.log4j.ConsoleAppender
6 |
7 | # A1 uses PatternLayout.
8 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout
9 | log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
--------------------------------------------------------------------------------
/osums-server/src/main/resources/osums.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS songs (
2 | id INTEGER PRIMARY KEY NOT NULL,
3 | rank TEXT NOT NULL,
4 | artist TEXT NOT NULL,
5 | title TEXT NOT NULL,
6 | creator TEXT NOT NULL,
7 | tags TEXT NOT NULL,
8 | favourites INTEGER NOT NULL,
9 | plays INTEGER NOT NULL,
10 | lastUpdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
11 | );
12 |
13 | CREATE TABLE IF NOT EXISTS beatmaps (
14 | id INTEGER PRIMARY KEY NOT NULL,
15 | songId INTEGER NOT NULL,
16 | circleSize REAL NOT NULL,
17 | approachRate REAL NOT NULL,
18 | hpDrain REAL NOT NULL,
19 | accuracy REAL NOT NULL,
20 | starDifficulty REAL NOT NULL,
21 | success_rate REAL NOT NULL,
22 | lastUpdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
23 | FOREIGN KEY (songId) REFERENCES songs (id)
24 | );
25 |
26 | CREATE TABLE IF NOT EXISTS requests (
27 | id INTEGER PRIMARY KEY AUTOINCREMENT,
28 | songId INTEGER NOT NULL,
29 | rank TEXT,
30 | artist TEXT,
31 | title TEXT,
32 | creator TEXT,
33 | tags TEXT,
34 | favourites INTEGER,
35 | plays INTEGER,
36 | beatmapId INTEGER,
37 | circleSize REAL,
38 | approachRate REAL,
39 | hpDrain REAL,
40 | accuracy REAL,
41 | starDifficulty REAL,
42 | success_rate REAL,
43 | reqTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
44 | );
45 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | com.github.mob41
4 | osumer
5 | ${global.version}
6 | pom
7 |
8 | osumer-ui
9 | osumer-daemon
10 | osumer-lib
11 | osumer-installer
12 | osumer-launcher
13 | osumer-debugdump
14 | osums-api
15 | osums-server
16 |
17 |
18 | 2.0.0
19 | SNAPSHOT
20 | 11
21 | ${global.generation}-${global.branch}
22 | 3.1.0
23 | 1.8
24 | 1.8
25 |
26 |
60 |
--------------------------------------------------------------------------------
/src/main/resources/osumerIcon_128px.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a1aw/osumer/248f480f885e42be2d54faaf248deb9920549f6a/src/main/resources/osumerIcon_128px.ico
--------------------------------------------------------------------------------