forum

Generating Storyboards in .net languages using osu!Elements

posted
Total Posts
3
Topic Starter
ExCellRaD
Description
You can create storyboards in a way very similar to SGL, using the many benefits of a complete programming language + all the .NET functions.
This means that you can make use of intellisense and debugging, which can be very usefull when trying to find errors.
This is done using my osu framework: osu!Elements
All storyboard related functions (at the time of writing this) is currently supported and working.

Before starting
I would first recommend getting familiar with c# (or vb.net) if you aren't allready. There are plenty of guides out there, just google for it.
You can use visual studio 2015 community for free.
Then take a look at the example code for osuElements (linked in the main post).
Don't forget to download the latest version of the dll (also linked at the main post).

Setup
Create a new project (console application preferred because of least overhead)
Include the osuElements.Net.dll in the project as a reference (or a clone of the project on github)
Put your code under the method "Main" in Program.cs

Usage
Reading or creating and writing storyboards
You can always open an exisiting storyboard and edit or add stuff to that, or make a completely new one.
//reading existing .osb file:
var storyboard = new Storyboard("mapsetfolder\\song - artist(creator).osb");
//making a new one:
var storyboard = new Storyboard();
storyboard.Directory = "mapsetfolder";
storybaord.FileName = "storyboard.osb";
Or do exactly the same with a beatmap (because those support storyboards too!)
//reading existing .osu file:
var storyboard = new Beatmap("mapsetfolder\\song - artist(creator)[Difficulty].osu");
//making a new one, not really recommended:
var storyboard = new Beatmap();
storyboard.Directory = "mapsetfolder";
storybaord.FileName = "song - artist(creator)[Difficulty].osu";
Write it when you are finished:
//optional: set a new filename for a copy:
storyboard.FileName="copy.osb";
storyboard.WriteFile();

//same for beatmaps:
beatmap.FileName="copy.osu"; //optional
beatmap.WriteFile();

Adding sprites, animations and samples
creation
//using default values for layer, origin and origin coordinates:
var sprite = new SpriteEvent("image.png");
//or custom values:
var sprite = new SpriteEvent("image.png", EventLayer.Foreground, Origin.BottomLeft, 0, 400);

//for animations you need to specify the amount of frames and the duration per frame
var animation = new AnimationEvent("anim.jpg", 10, 20); //10 frames and 20ms per frame
var animation = new AnimationEvent("anim.jpg", 10, 20,EventLayer.Fail,Origin.CentreRight,400,200,Looptypes.LoopOnce);
//everything you can do with sprites, you can also do with animations

//samples:
var sample = new SampleEvent("sample.wav",0); //starttime is 0ms
var sample = new SampleEvent("sample.wav",0,90,EventLayer.Pass);//90% volume
adding to storyboard
storyboard.AddSpriteEvent(sprite);
storyboard.AddSpriteEvent(animation);
storyboard.SampleEvents.Add(sample);
//again, this can be done to beatmaps also
beatmap.AddSpriteEvent(sprite);
beatmap.AddSpriteEvent(animation);
beatmap.SampleEvents.Add(sample);

Transformations
note: all these can be applied to SpriteEvents, AnimationEvents, LoopEvents and TriggerEvents

basic ones: M(Move), MX(MoveX), MY(MoveY), S(Scale), V(ScaleVector), F(Fade) ,C(Color)
//short method
sprite.Fade(0,values:0.5f) //starttime 0, opacity 50%
//longer method
sprite.MoveX(0, 200, Easing.In, 10, 100); //starttime 0, endtime 200, startx 10, endx 100
//or add multiple repeating by adding more parameters
sprite.Scale(0,100,Easing.None,1,0,1,0,1,0); //scales from 1 to 0 and back every 100ms starting at 0ms (becomes 5 transforms)

//Move and ScaleVector need a Position(X,Y) objects to be passed as parameter
var startposition = new Position(100,200);
sprite.Move(0,values:startposition);
var endposition = new Position(200,100);
sprite.ScaleVector(0,200,Easing.None,startposition, endposition);

//Color needs a Colour(R,G,B) object
var white = new Colour(255,255,255);
sprite.Color(0,values:white);

Paramaters: FlipV, FlipH, Additive
//flip the image vertically from 0 to 100ms
sprite.FlipV(0,100);
//flip the image horizontally from 0 to 100ms
sprite.FlipH(0,100);
//use additive color blending
sprite.Additive(0,100);

Loops
var loop = new LoopEvent(200, 5);
loop.Move(0,100,Easing.In,new Position(10,10)); //these start and endtimes are 0-based in the loop itself
sprite.AddLoop(loop); //don't forget!

Triggers
//short constructor, only for failing and passing
var trigger = new TriggerEvent(TriggerTypes.Failing, 0, 1000);
//long constructor for hitsoundtriggers:
var hitsound = new HitSoundTrigger(HitObjectSoundType.Clap);
hitsound.SampleSet = SampleSet.Drum;
var hitsoundTrigger = new TriggerEvent(hitsound, 0, 500);

trigger.Fade(0,values:0);//also 0-based

sprite.AddTrigger(trigger);//don't forget!
Variables
this is only supported on storyboards!
//remove all occurences of 255,255,255 with $whitecolor
//and add a key to the top of the file
storyboard.VariablesDictionary.Add("$whitecolor", "255,255,255");
//you can also do this for complete lines
storyboard.VariablesDictionary.Add("$sprite", "Sprite,Foreground,Center,\"image.png\",320,240");
//advanced: add a complete line by ToString()
storyboard.VariablesDictionary.Add("$sprite",sprite.ToString());
storyboard.VariablesDictionary.Add("$fade",sprite.Transformations[0].ToString());

Im looking for someone who can supply me a reasonably-sized SGL(or similar) file so I can translate it to c# and use it as an example in this post. DONE
iiyo
👌👀👌👀👌👀👌👀👌👀 good shit go౦ԁ sHit👌 thats ✔ some good👌👌shit right👌👌there👌👌👌 right✔there ✔✔if i do ƽaү so my self 💯 i say so 💯 thats what im talking about right there right there (chorus: ʳᶦᵍʰᵗ ᵗʰᵉʳᵉ) mMMMMᎷМ💯 👌👌 👌НO0ОଠOOOOOОଠଠOoooᵒᵒᵒᵒᵒᵒᵒᵒᵒ👌 👌👌 👌 💯 👌 👀 👀 👀 👌👌Good shit
Ephemeral
Charles445 has the SGL file for Underworld Monarchy available on request, hit him up.
Please sign in to reply.

New reply