Skip to content

Commit

Permalink
0.16.0b
Browse files Browse the repository at this point in the history
Fix flashlight

Try default download dir for importing

Mnetwork normal multiword search

Attempt to fix UnmappableCharacterException
  • Loading branch information
fd committed Sep 18, 2017
1 parent 85a6397 commit 228d213
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 27 deletions.
45 changes: 45 additions & 0 deletions res/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
opsu!

opsu! is an unofficial open-source client for the rhythm game osu!, written in Java using Slick2D and LWJGL (wrappers around OpenGL and OpenAL).

opsu! runs on Windows, OS X, and Linux. A libGDX port also supports Android devices.

Getting Started

opsu! requires "beatmaps" to run, which contain the songs and gameplay data. These can be downloaded directly through opsu! in the downloads menu, or manually from the osu! website (requires registration) and mirror sites like Bloodcat. Place any manually downloaded beatmaps (in .osz format) in the Import/ directory for opsu! to unpack them automatically.

The beatmap directory can be changed by setting the "BeatmapDirectory" value in the generated configuration file.

First Run

opsu! will parse all beatmaps when launched, which can take a while for the first time. If no beatmaps are found, the game will prompt you to download some to get started.

Game settings can be changed in the options menu, accessed by clicking the "Other Options" button in the song menu. The "Music Offset" value will likely need to be adjusted initially, or whenever hit objects are out of sync with the music.

Directory Structure

The following files and folders will be created by opsu! as needed:

opsu.cfg: The configuration file. Most (but not all) of the settings can be changed through the options menu.
opsu.log: The error log. All critical errors displayed in-game are also logged to this file, and other warnings not shown are logged as well.
Songs/: The beatmap directory. The parser searches all of its subdirectories for .osu files to load.
Skins/: The skins directory. Each skin must be placed in a folder within this directory. Any game resource (in res/) can be skinned by placing a file with the same name in a skin folder. Skins can be selected in the options menu.
Replays/: The replay directory. Replays of each completed game are saved as .osr files, and can be viewed at a later time or shared with others.
Import/: The import directory. All beatmap packs (.osz) and skin packs (.osk) are unpacked to the proper location. All replays (.osr) are moved to the replay directory, and their scores saved to the scores database.


opsu! - an open-source osu! client
Copyright (C) 2014-2017 Jeffrey Han + fluddokt

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
5 changes: 5 additions & 0 deletions src/fluddokt/ex/DeviceInfo.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package fluddokt.ex;

import fluddokt.opsu.fake.File;

public class DeviceInfo {
public static DeviceInfo info = new DeviceInfo();
public String getInfo() {
return "";
}
public File getDownloadDir() {
return null;
}
}
5 changes: 3 additions & 2 deletions src/fluddokt/opsu/fake/DynamicFreeTypeFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.badlogic.gdx.utils.IntMap;

public class DynamicFreeTypeFont {
static int PAD = 1;
FileHandle handle;
Face face;
Face backupface;
Expand Down Expand Up @@ -236,7 +237,7 @@ public CharInfo addChar(char c) {
// cant fit width, go to next line
if (x + pixMapWidth > curPixmap.getWidth()) {
x = 0;
y += maxHeight;
y += maxHeight + PAD;
maxHeight = 0;
}
// find the max Height of the this line
Expand All @@ -260,7 +261,7 @@ public CharInfo addChar(char c) {
TextureRegion tr = new TextureRegion(curTexture, x, y,
pixMapWidth, pixmap.getHeight());
tr.flip(false, true);
x += pixMapWidth;
x += pixMapWidth + PAD;

GlyphMetrics metrics = slot.getMetrics();
CharInfo ci = new CharInfo();
Expand Down
6 changes: 5 additions & 1 deletion src/fluddokt/opsu/fake/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public File(String name) {

}

private File(FileHandle nfh) {
public File(FileHandle nfh) {
this.fh = nfh;
}

Expand Down Expand Up @@ -222,4 +222,8 @@ public boolean isExternal() {
);
}

public long length() {
return fh.length();
}

}
23 changes: 22 additions & 1 deletion src/fluddokt/opsu/fake/GameOpsu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;

Expand All @@ -23,7 +25,7 @@

public class GameOpsu extends com.badlogic.gdx.Game {

public final static String VERSION = "0.16.0a";
public final static String VERSION = "0.16.0b";
public StateBasedGame sbg;

Stage stage;
Expand Down Expand Up @@ -108,6 +110,25 @@ public void render() {
File nomediafile = new File(dataDir, ".nomedia");
if(!nomediafile.exists())
new FileOutputStream(nomediafile.getIOFile()).close();

File readmefile = new File(new File(Gdx.files.internal("res")), "readme.txt");
File readmefilecpyto = new File(dataDir, "readme.txt");
System.out.println("readmeexist: "+readmefile.exists()+" "+readmefilecpyto.exists()+" "+readmefile.length()+" "+readmefilecpyto.length());
if (readmefile.exists() && !readmefilecpyto.exists() || readmefile.length() != readmefilecpyto.length()) {
try(
InputStream in = new FileInputStream(readmefile);
OutputStream out = new fluddokt.opsu.fake.FileOutputStream(readmefilecpyto);
) {
byte[] buf = new byte[512];
while (true) {
int read = in.read(buf);
if (read < 0)
break;
out.write(buf, 0, read);
}
}
}

}
System.out.println("Local Dir:"+Gdx.files.getLocalStoragePath());
Gdx.input.setInputProcessor(new InputMultiplexer(stage, sbg));
Expand Down
11 changes: 10 additions & 1 deletion src/fluddokt/opsu/fake/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;

import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.utils.GdxRuntimeException;
Expand Down Expand Up @@ -404,7 +406,14 @@ public Image getScaledCopy(float f) {
}

public void setAlpha(float f) {
this.alpha = f;
this.alpha = clamp(f, 0, 1);
}
public float clamp(float val, float low, float high) {
if (val < low)
return low;
if (val > high)
return high;
return val;
}

public boolean isDestroyed() {
Expand Down
9 changes: 5 additions & 4 deletions src/fluddokt/opsu/fake/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TextField extends GInputAdapter {

UnicodeFont font;
int x, y, w, h;
StringBuilder str = new StringBuilder();
String str = new String();
Color bgColor = Color.green, textColor = Color.blue,
borderColor = Color.red;
GameContainer container;
Expand Down Expand Up @@ -61,6 +61,7 @@ public void render(GUIContext container2, Graphics g) {
g.fillRect(x, y, w, h);
g.setColor(borderColor);
g.drawRect(x, y, w, h);

g.setColor(textColor);
g.drawString(font, str.toString(), x, y);
}
Expand All @@ -74,7 +75,7 @@ public String getText() {
}

public void setText(String string) {
str = new StringBuilder(string);
str = string;
}

public int getWidth() {
Expand All @@ -89,9 +90,9 @@ public int getHeight() {
public void keyType(char character) {
if (hasFocus) {
if (character == KeyEvent.VK_BACK_SPACE)
str.setLength(Math.max(str.length() - 1, 0));
str = str.substring(0, Math.max(str.length() - 1, 0));
else if (!Character.isISOControl(character))
str.append(character);
str += character;
consumeEvent();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/itdelatrisu/opsu/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package itdelatrisu.opsu;

import fluddokt.opsu.fake.*;

import itdelatrisu.opsu.audio.HitSound;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
Expand Down
13 changes: 9 additions & 4 deletions src/itdelatrisu/opsu/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,16 @@ else if (doReplace)
* @param file the ZIP archive
* @param dest the destination directory
*/
public static void unzip(File file, File dest) {
public static boolean unzip(File file, File dest) {
try {
ZipFile zipFile = new ZipFile(file.getIOFile());
zipFile.extractAll(dest.getAbsolutePath());
return true;
} catch (ZipException e) {
ErrorHandler.error(String.format("Failed to unzip file %s to dest %s.",
file.getAbsolutePath(), dest.getAbsolutePath()), e, false);
//ErrorHandler.error(String.format("Failed to unzip file %s to dest %s.",
// file.getAbsolutePath(), dest.getAbsolutePath()), e, false);
}
return false;
}

/**
Expand Down Expand Up @@ -757,6 +759,10 @@ public static void moveFile(File src, File dst) throws IOException {
if(src.getIOFile().renameTo(dst.getIOFile())){
return;
}
copyFile(src, dst);
src.delete();
}
public static void copyFile(File src, File dst) throws IOException {
FileInputStream instream = new FileInputStream(src.getIOFile());
FileOutputStream outstream = new FileOutputStream(dst.getIOFile());
FileChannel inChannel = instream.getChannel();
Expand All @@ -780,7 +786,6 @@ public static void moveFile(File src, File dst) throws IOException {
if (outChannel != null)
outChannel.close();
}
src.delete();
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/itdelatrisu/opsu/beatmap/BeatmapSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public boolean matches(String query) {
beatmap.creator.toLowerCase().contains(query) ||
beatmap.source.toLowerCase().contains(query) ||
beatmap.version.toLowerCase().contains(query) ||
Integer.toString(beatmap.beatmapSetID).contains(query) ||
beatmap.tags.contains(query))
return true;

Expand Down
9 changes: 6 additions & 3 deletions src/itdelatrisu/opsu/beatmap/OszUnpacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ public boolean accept(java.io.File dir, String name) {
File songDir = new File(dest, dirName);
if (!songDir.isDirectory()) {
songDir.mkdir();
Utils.unzip(file, songDir);
file.delete(); // delete the OSZ when finished
dirs.add(songDir);
if (Utils.unzip(file, songDir)) {
file.delete(); // delete the OSZ when finished
dirs.add(songDir);
} else {
songDir.delete();
}
}
}
if (ws != null)
Expand Down
2 changes: 1 addition & 1 deletion src/itdelatrisu/opsu/downloads/servers/MnetworkServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public DownloadNode[] resultList(String query, int page, boolean rankedOnly) thr
try {
// read HTML
String queryString = (query.isEmpty()) ? "-" : query;
String search = String.format(SEARCH_URL, URLEncoder.encode(queryString, "UTF-8"));
String search = String.format(SEARCH_URL, URLEncoder.encode(queryString, "UTF-8").replace("+", "%20"));
String html = Utils.readDataFromUrl(new URL(search));
if (html == null) {
this.totalResults = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/itdelatrisu/opsu/options/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public void setValue(int value) {
},
EFFECT_VOLUME ("Effects", "VolumeEffect", "Menu and game sound effects volume.", 70, 0, 100),
HITSOUND_VOLUME ("Hit sounds", "VolumeHitSound", "Hit sounds volume.", 30, 0, 100),
MUSIC_OFFSET ("Universal offset", "Offset", "Adjust this value if hit objects are out of sync.", -75, -500, 500) {
MUSIC_OFFSET ("Universal offset", "Offset", "Adjust this value if hit objects are out of sync.", -200, -500, 500) {
@Override
public String getValueString() { return String.format("%dms", val); }
},
Expand Down
2 changes: 2 additions & 0 deletions src/itdelatrisu/opsu/options/OptionsOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,8 @@ public void keyType(char c){
* @param mouseY the mouse y coordinate
*/
private void adjustSlider(int mouseX, int mouseY) {
if (hoverOption == null)
return;
int oldSliderValue = hoverOption.getIntegerValue();

// set new value
Expand Down
8 changes: 7 additions & 1 deletion src/itdelatrisu/opsu/replay/Replay.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
//import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;


//import org.newdawn.slick.util.Log;
import org.tukaani.xz.LZMA2Options;
Expand Down Expand Up @@ -327,7 +331,9 @@ public void run() {
// LZMA-encoded replay data
if (frames != null && frames.length > 0) {
// build full frame string
NumberFormat nf = new DecimalFormat("###.#####");
NumberFormat nf = new DecimalFormat("###.#####"
,DecimalFormatSymbols.getInstance(Locale.forLanguageTag("en_US"))
);
sb = new StringBuilder();
for (int i = 0; i < frames.length; i++) {
ReplayFrame frame = frames[i];
Expand Down
5 changes: 5 additions & 0 deletions src/itdelatrisu/opsu/states/DownloadsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ public void run() {
private void importBeatmaps() {
// invoke unpacker and parser
File[] dirs = OszUnpacker.unpackAllFiles(Options.getImportDir(), Options.getBeatmapDir());
if (dirs == null || dirs.length <=0) {
File dlDir = fluddokt.ex.DeviceInfo.info.getDownloadDir();
if (dlDir != null)
dirs = OszUnpacker.unpackAllFiles(dlDir, Options.getBeatmapDir());
}
if (dirs != null && dirs.length > 0) {
this.importedNode = BeatmapParser.parseDirectories(dirs);
if (importedNode == null)
Expand Down
6 changes: 3 additions & 3 deletions src/itdelatrisu/opsu/states/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ public enum PlayState {
private LinkedList<LifeFrame> lifeFrames;

/** The offscreen image rendered to. */
private Image offscreen;
//private Image offscreen;

/** The offscreen graphics. */
private Graphics gOffscreen;
//private Graphics gOffscreen;

/** The current flashlight area radius. */
private int flashlightRadius;
Expand Down Expand Up @@ -576,7 +576,7 @@ else if (breakIndex > 1) {
}

if (GameMod.FLASHLIGHT.isActive()) {
drawHitObjects(gOffscreen, trackPos);
drawHitObjects(g, trackPos);
GameImage.ALPHA_MAP.getImage().draw(alphaX, alphaY, alphaRadius, alphaRadius);
g.clearClip();

Expand Down
Loading

0 comments on commit 228d213

Please sign in to comment.