mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix problems from last commit
This commit is contained in:
parent
36c425906f
commit
1e6bcd5306
@ -7,14 +7,11 @@ namespace ClassicalSharp.Gui {
|
||||
public delegate void ClickHandler(Game g, Widget w);
|
||||
|
||||
public abstract class GuiElement : IDisposable {
|
||||
|
||||
protected Game game;
|
||||
public GuiElement(Game game) { this.game = game; }
|
||||
protected Game game;
|
||||
|
||||
public abstract void Init();
|
||||
|
||||
public abstract void Render(double delta);
|
||||
|
||||
public abstract void Dispose();
|
||||
|
||||
/// <summary> Causes the gui element to recreate all of its sub-elements and/or textures. </summary>
|
||||
@ -22,17 +19,12 @@ namespace ClassicalSharp.Gui {
|
||||
public virtual void Recreate() { Dispose(); Init(); }
|
||||
|
||||
public virtual bool HandlesKeyDown(Key key) { return false; }
|
||||
|
||||
public virtual bool HandlesKeyPress(char key) { return false; }
|
||||
|
||||
public virtual bool HandlesKeyUp(Key key) { return false; }
|
||||
|
||||
public virtual bool HandlesMouseDown(int mouseX, int mouseY, MouseButton button) { return false; }
|
||||
|
||||
public virtual bool HandlesMouseMove(int mouseX, int mouseY) { return false; }
|
||||
|
||||
public virtual bool HandlesMouseScroll(float delta) { return false; }
|
||||
|
||||
public virtual bool HandlesMouseUp(int mouseX, int mouseY, MouseButton button) { return false; }
|
||||
|
||||
protected static int CalcPos(Anchor anchor, int offset, int size, int axisLen) {
|
||||
@ -49,21 +41,17 @@ namespace ClassicalSharp.Gui {
|
||||
/// <summary> Represents a container of widgets and other 2D elements. </summary>
|
||||
/// <remarks> May cover the entire game window. </remarks>
|
||||
public abstract class Screen : GuiElement {
|
||||
|
||||
public Screen(Game game) : base(game) { }
|
||||
|
||||
public bool HandlesAllInput, BlocksWorld, HidesHud, RenderHudOver;
|
||||
|
||||
public abstract void OnResize();
|
||||
|
||||
protected abstract void ContextLost();
|
||||
|
||||
protected abstract void ContextRecreated();
|
||||
}
|
||||
|
||||
/// <summary> Represents an individual 2D gui component. </summary>
|
||||
public abstract class Widget : GuiElement {
|
||||
|
||||
public Widget(Game game) : base(game) { }
|
||||
|
||||
public ClickHandler MenuClick;
|
||||
|
@ -74,8 +74,9 @@ namespace ClassicalSharp.Audio {
|
||||
for (int i = 0; i < monoOutputs.Length; i++) {
|
||||
IAudioOutput output = outputs[i];
|
||||
if (output == null) {
|
||||
outputs[i] = GetPlatformOut();
|
||||
output = outputs[i];
|
||||
output = GetPlatformOut();
|
||||
output.Create(1);
|
||||
outputs[i] = output;
|
||||
}
|
||||
|
||||
if (!output.IsFinished()) continue;
|
||||
@ -95,14 +96,6 @@ namespace ClassicalSharp.Audio {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IAudioOutput MakeSoundOutput(IAudioOutput[] outputs, int i) {
|
||||
IAudioOutput output = GetPlatformOut();
|
||||
output.Create(1);
|
||||
outputs[i] = output;
|
||||
return output;
|
||||
}
|
||||
|
||||
void PlaySound(IAudioOutput output, float volume) {
|
||||
try {
|
||||
output.SetVolume(volume);
|
||||
|
@ -85,10 +85,13 @@ namespace ClassicalSharp.Audio {
|
||||
musicOut.PlayStreaming(container);
|
||||
} catch (InvalidOperationException ex) {
|
||||
HandleMusicError(ex);
|
||||
try { musicOut.Dispose(); } catch { }
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
ErrorHandler.LogError("AudioPlayer.DoMusicThread()", ex);
|
||||
game.Chat.Add("&cError while trying to play music file " + file);
|
||||
try { musicOut.Dispose(); } catch { }
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (disposingMusic) break;
|
||||
@ -120,6 +123,7 @@ namespace ClassicalSharp.Audio {
|
||||
void DisposeMusic() {
|
||||
disposingMusic = true;
|
||||
musicHandle.Set();
|
||||
|
||||
DisposeOf(ref musicOut, ref musicThread);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user