forum

osu!Elements - open source .net framework

posted
Total Posts
13
Topic Starter
ExCellRaD
Description

Osu!Elements is a free open-sourced .net library written in c#. The main functions of the framework are:
  1. Reading and writing beatmaps and storyboards
  2. Retrieving data from the API
  3. Reading replay data

The main goal is to help others create cool 3rd party stuff, so there's a lot of functionality.
The code is hosted over at github, feel free to drop issues, fork and all that good stuff.

Why did you make this?
While it's nice seeing people create applications each their own way, doing the same thing over and over is pointless. This started out as an improvement of smoogipooo's Beatmap API, but has evolved a lot since then. Every time i wanted to make an application for osu stuff, I added it to this library and that's why it's this big now (but probably far from finished).

What can I do with it?

Read Files:
  1. Read and write beatmaps (.osu), includes loading everything into objects (such as timingpoints, hitobjects, spritevents...)
  2. Read and write storyboards (.osb)
  3. Read and write skins (skin.ini)
  4. Read replays (.osr)
  5. Read and write collections (collection.db)
  6. Read scores (scores.db)
  7. Read the beatmap database (osu!.db)

Acces the osu!api:
see all the functions here
osu!Elements uses an external reference to Newtonsoft's Json.Net , so you'll need this to use these functions.
Also included are the URL functions (on the bottom of the osu!api page).

Generate storyboards:
You can create storyboards in a way very similar to SGL, using the many benefits of a complete programming language + all the .NET functions.
Steps:
  1. Open an existing storyboard/ beatmap or make a new Stoyboard() object
  2. Add Sprites/Animations, Add transformations to those, and even add Samples
  3. optional: use the Variables functionality by adding keys and values to the VariablesDictionary
  4. Save to a new or existing storyboard/beatmap


Anything else :D
Make a custom replay viewer, or even a complete clone of osu, if you want that.
Make a collections editor, using beatmap search functionality (with osu.db) or by score achieved (scores.db) --might do this myself though :p
... use your imagination!


Download
osuElements.Net.dll v1.0.6
osuElements.Net.dll v1.0.0

Versions:
v1.0: initial release
v1.0.1: easier to use transformation methods for storyboarding
v1.0.2: bug fixes on perfect curve, some documentation of the beatmap properties
v1.0.3: beatmap reading small fixes
v1.0.4: slider updates
v1.0.5: API properties documentation + renaming to fit the name scheme. Difficulty Calculation for standard!
v1.0.6: pp calculation for osu!standard (and for other gamemodes if you already have the strain values)

Wanna help? or need help?
Discord server!
you can also always add an issue on github for things that don't work, or send me a message on osu!

Sample code
beatmap reading c#
using osuElements;
using osuElements.Beatmaps;

var beatmap = new Beatmap(@"1 Kenji Ninuma - DISCO PRINCE\Kenji Ninuma - DISCOüÜPRINCE (peppy) [Normal].osu");
beatmap.Version = "THIS MAP IS GREAT";
beatmap.Diff_Approach = 9.5f;
var hitcircle = new HitCircle(new Position(10, 20), 200);
beatmap.HitObjects.Add(hitcircle);
beatmap.FileName = "Kenji Ninuma - DISCOüÜPRINCE (peppy) [Improved version].osu";
beatmap.WriteFile();

api c#
using osuElements.Api.Repositories;

var bRep = new ApiBeatmapRepository();
var firstMap = await bRep.Get(1);
var someManiaMap = await bRep.Get("ds12dza68123sdq564", GameMode.Mania);
var mapsByMe = await bRep.GetCreator("ExCellRaD", limit: 5);
var scoresOnMap = bRep.GetScores(firstMap.Beatmap_Id);
var maps2016 = bRep.GetSince(new DateTime(2016, 1, 1));

var uRep = new ApiUserRepository();
var peppy = await uRep.Get("peppy");
var peppyscores = await uRep.GetBest(peppy.User_Id, GameMode.CatchTheBeat);
var recentscores = await uRep.GetRecent("Rafis");

var mRep = new ApiMultiplayerRepository();
var match = await mRep.Get(123456);
var games = match.Games;

Sample code on Github

More sample code and projects coming soon, I will also post a full guide to generating storyboards on the storyboarding forum section.

Any help and feedback is greatly appreciated.
want more stuff to be added? Just give me a shout!

Have a nice day developing :D
Benpoi
That's really cool! :!:
Pannari
You're a lifesaver I've been waiting for this for so long omfg
Agka
Hah, nice.
I had been working on a python version of something similar to this, but you beat me to it :)
maboesanman
this is awesome! I was already making an osu replay viewer, and this should really help me out!
Sh0keR
By reading beapmaps do you mean i can get the full information of a beatmap. Including title creator hit circles etc.
Edit
I meant do i need an api key or i can directly read and write beatmaps
Topic Starter
ExCellRaD

Sh0keR wrote:

By reading beapmaps do you mean i can get the full information of a beatmap. Including title creator hit circles etc.
Edit
I meant do i need an api key or i can directly read and write beatmaps
You don't need anything to completely read a beatmap, just call the constructor with a string as parameter (or use the .ReadFile() function). Api keys are only needed for getting stuff from the osu!api.
Sh0keR
After messing with it for a few hours, it's pretty cool and work well!
I have an issue though with retrieving some of the information from a beatmap, but I think it's because I need an API key, is that true?

the properties I am having issues with (they are always the same or empty)

Approved, Total_Length, Hit_Length, File_MD5(empty), Approved Date, Last Update, BPM, Source, GeneralID, Language_ID, Favorutie_Count, PlayCount,
PassCount, Max_Combo (Empty), DifficultyRating, BeatmapDifficulty (Always easy)
Topic Starter
ExCellRaD

Sh0keR wrote:

After messing with it for a few hours, it's pretty cool and work well!
I have an issue though with retrieving some of the information from a beatmap, but I think it's because I need an API key, is that true?

the properties I am having issues with (they are always the same or empty)

Approved, Total_Length, Hit_Length, File_MD5(empty), Approved Date, Last Update, BPM, Source, GeneralID, Language_ID, Favorutie_Count, PlayCount,
PassCount, Max_Combo (Empty), DifficultyRating, BeatmapDifficulty (Always easy)
Yeah those do come from the API, and the reason why they're there are because Beatmap inherits from ApiBeatmap. You can get the File_MD5 from using the GetHash() method and calculate max_como, hit_length and total_length with HitObjects.
Would it be less confusing if Beatmap didn't inherit from ApiBeatmap? Be sure to tell me if this seems wrong to you, I can always find a better solution.
Sh0keR

ExCellRaD wrote:

Sh0keR wrote:

After messing with it for a few hours, it's pretty cool and work well!
I have an issue though with retrieving some of the information from a beatmap, but I think it's because I need an API key, is that true?

the properties I am having issues with (they are always the same or empty)

Approved, Total_Length, Hit_Length, File_MD5(empty), Approved Date, Last Update, BPM, Source, GeneralID, Language_ID, Favorutie_Count, PlayCount,
PassCount, Max_Combo (Empty), DifficultyRating, BeatmapDifficulty (Always easy)
Yeah those do come from the API, and the reason why they're there are because Beatmap inherits from ApiBeatmap. You can get the File_MD5 from using the GetHash() method and calculate max_como, hit_length and total_length with HitObjects.
Would it be less confusing if Beatmap didn't inherit from ApiBeatmap? Be sure to tell me if this seems wrong to you, I can always find a better solution.
"Title" also inherits from ApiBeatmaps but it works just fine?
I have a feeling I am just confused about some stuff.
Topic Starter
ExCellRaD

Sh0keR wrote:

"Title" also inherits from ApiBeatmaps but it works just fine?
I have a feeling I am just confused about some stuff.
Yes because you can read that from .osu files, but stuff like favourite_count not because that is stored in servers :)
Pickkle
Cool, thanks
TrippinBeats
Sorry for necro-posting. This is really useful! But I can't seem to find how to calculate pp on beatmaps though, can anyone give me an example?
Please sign in to reply.

New reply