Old notes

This file contains some old notes I made in the past. It is largely unstructured.


TODO: could explain stuff using test runner

problems with framework

  • what is Add vs AddInternal?
  • How do Clocks work?
  • How to make buttons that size to fit content? Optionally size to fit container in X?
  • Scroll container, how to stop contents from disappearing when scrolling up?

Notes:

  • Button needs to be given an Action

ideas for roslyn analyzer:

  • error when BDL is not private
  • error if using bad AutoSize- or RelativeSizeAxes
  • Error when adding object twice to children?

Framework info

Drawables

TODO (drawable, compositedrawable, etc)

Containers

Namespace: osu.Framework.Graphics.Containers

List of containers (excluding Markdown):

  • CompositeDrawable
    • Container
      • BufferedContainer
      • CircularContainer
      • ClickableContainer
      • DrawSizePreservingFillContainer
      • FlowContainer
        • FillFlowContainer
          • SearchContainer
          • TextFlowContainer
            • CustomizableTextContainer
      • SafeAreaContainer
      • SafeAreaDefiningContainer
      • ScrollContainer
        • BasicScrollContainer
      • TabbableContainer
      • VisibilityContainer
        • OverlayContainer
          • FocusedOverlayContainer
    • DelayedLoadWrapper
      • DelayedLoadUnloadWrapper
    • DrawableAudioWrapper
      • AudioContainer
      • DrawableSample
      • DrawableTrack
    • GridContainer
    • LifetimeManagementContainer
    • ModelBackedDrawable
    • RearrangeableListContainer
    • RearrangeableListItem (abstract)
    • TableContainer

Up to date as of 25/6/2021.

Markdown

TODO

Screens

A Screen is a CompositeDrawable that implements IScreen and can be used with a ScreenStack.

A Screen can be thought of as a menu in a game: you start with your first screen (eg. the main menu) and when clicking a button you push a new menu on the stack (eg. the options or gameplay screen). A screen can be exited again by popping it off the stack, which will return you to the previous screen. The osu-framework wiki describes this as sheets of papers.

IScreen has some extention methods such as Push(newScreen) and Exit() to easily allow pushing and popping screens.

A base class that inherits from Screen can be made to automatically provide animations when transitioning or to place a permanent back button on the screen.

Input

TODO

Implementing new input methods in your game

Basic required classes:

  • A custom InputHandler that generates inputs.
  • An input class (implements IInput, can also simply extend from ButtonInput<T>). Denotes a single input, can be applied to an InputState. This could be a simple collection of all current input states, according to the device.
  • An input state class, to be put in InputState. Contains information about the entire state of the input device (ie. all individual buttons).
  • Input state change events, represents the change of an InputState (extends InputStateChangeEvent)
  • UI-level events (extend UIEvent), gets created in an InputManager. Separate events for different actions like KeyUp, KeyDown, MouseClick, MouseDoubleClick, etc.

Adding from within a game:

  1. Override InputState to add your own state.
  2. Override UserInputManager See UserInputManagerfor the original implementations.
    • Override CreateInitialState creates your custom state.
    • Override HandleInputStateChange checks if an event is your custom one (and calls PropagateBlockableEvent) or passes down to the base method.
    • Override InputHandlers to add your own input handler.
  3. In your Game class, override CreateUserInputManager to return your custom UserInputManager.

Resource stores

TODO

Audio

Namespace: osu.Framework.Audio

TODO

AudioManager, AudioManager.Tracks and AudioManager.Samples are added to DI. Tracks and Samples can be retrieved through that ITrackStore and ISampleStore respectively. Tracks and Samples can be stored in the Resources/Tracks and Resources/Samples folders to be automatically accessible.

Every audio component inherits from AudioComponent which provides HasCompleted, IsAlive, IsLoaded.

AdjustableAudioComponent extends AudioComponent and implements IAggregateAudioAdjustment and IAdjustableAudioComponent. Volume, Balance and Frequency can be changed.

TODO: AudioCollectionManager "allows managing multiple AdjustableAudioComponents". Used to keep BASS device in sync?

AudioManager extends AudioCollectionManager. Has ITrackStore Tracks, ISampleStore Samples, BindableDouble VolumeSample, BindableDouble VolumeTrack

IAdjustableResourceStore<T> : IResourceStore<T>, IAdjustableAudioComponent

Sample

Namespace: osu.Framework.Audio.Samples

TODO

Sample extends AudioComponent and is abstract. Its constructor allows passing playback concurrency (polyphony). TODO how to create?

ISampleChannel has Play(bool restart = true), Stop(), bool Playing, bool Played

SampleChannel extends AdjustableAudioComponent and implements ISampleChannel. Is abstract; actual implementation is SampleChannelBass. They expose Play(bool restart = true), Stop(), bool Playing, bool Played, bool IsAlive.

SampleStore extends AudioCollectionManager and ISampleStore. It has a SampleChannel Get(string name) method and an async equivalent.

Track

Namespace: osu.Framework.Audio.Tracks

TODO

ITrack has properties Looping, RestartPoint (for loop or Restart), CurrentTime, Length, IsRunning and methods Reset(), Restart(), ResetSpeedAdjustments(), bool Seek(double seed), Start(), Stop().

Track, implementation is TrackBass

ISampleStore, for some reason in .Audio.Tracks.

ITrackStore

Clocks

Namespace: osu.Framework.Timing.

Clocks are usually used to control the timing of Transitions on Drawables or of audio.

Interfaces

  • IClock: Read-only clock info. Provides CurrentTime, Rate and IsRunning getters. Other interfaces implement this too.
  • IAdjustableClock: Read/write clock. Can start, stop, reset, seek and its rate can be changed
  • IFrameBasedClock: Has a method ProcessFrame which will update the clock. ElapsedFrameTime, FramesPerSecond and TimeInfo have stats.
  • ISourceChangeableClock: Allows changing the underlying IClock source. Useful for building on other IClocks

Classes

  • ManualClock: The most basic implementation of IClock with all properties writable. Note that this only implements IClock, not IAdjustableClock. You probably want StopwatchClock instead.

  • StopwatchClock: A basic clock. Built on the System.Diagnostics.Stopwatch class, implements IAdjustableClock.

  • OffsetClock: A clock that extends another clock, but adds an offset to its CurrentTime. Implements IClock.

  • FramedClock: An implementation of IFrameBasedClock which extends another clock. It implements IFrameBasedClock and ISourceChangeableClock.

    • FramedOffsetClock: An extension of FramedClock which adds an offset.
    • ThrottledFrameClock: An extension of FramedClock which has a property MaximumUpdateHz to throttle the rate at which ProcessFrame is called. It does this by blocking the thread until the next ProcessFrame is allowed to be called. This should probably be used by running ProcessFrame in a loop on another thread. Limiting can be disabled by setting MaximumUpdateHz to be less than or equal to 0.
  • InterpolatingFrameClock: A clock that extends another clock, but "smooths it out". This is can be used on an IFrameBasedClock with low update rate to make it appear to have a higher update rate. Can also be used on other clocks if they don't update in real-time.

    • DecoupleableInterpolatingFramedClock: An extension of InterpolatingFrameClock which "can keep running even if the underlying source has been stopped or cannot handle the current time range". TODO: what does this mean in practice?

Config

TODO

Dependency injection

TODO

Standard DI items

  • TextureStore
  • AudioManager
  • ITrackStore
  • ISampleStore
  • ShaderManager
  • FontStore
  • LocalisationManager
  • ISafeArea
  • GameHost
  • Storage
  • FrameworkDebugConfigManager
  • FrameworkConfigManager
  • InputManager
  • YourGame