mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-23 05:08:34 +01:00
made cameras snap right in small rooms and made panels not require a texture
This commit is contained in:
parent
2bd62ee09d
commit
548e603900
2 changed files with 18 additions and 9 deletions
|
@ -130,6 +130,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix) {
|
public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix) {
|
||||||
|
if (this.Texture.Value != null)
|
||||||
batch.Draw(this.Texture, this.DisplayArea, Color.White * alpha, this.Scale);
|
batch.Draw(this.Texture, this.DisplayArea, Color.White * alpha, this.Scale);
|
||||||
// if we handle overflow, draw using the render target in DrawUnbound
|
// if we handle overflow, draw using the render target in DrawUnbound
|
||||||
if (!this.scrollOverflow) {
|
if (!this.scrollOverflow) {
|
||||||
|
|
|
@ -71,16 +71,24 @@ namespace MLEM.Cameras {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConstrainWorldBounds(Vector2 min, Vector2 max) {
|
public void ConstrainWorldBounds(Vector2 min, Vector2 max) {
|
||||||
|
if (this.Position.X < min.X && this.Max.X > max.X) {
|
||||||
|
this.LookingPosition = new Vector2((max.X - min.X) / 2, this.LookingPosition.Y);
|
||||||
|
} else {
|
||||||
if (this.Position.X < min.X)
|
if (this.Position.X < min.X)
|
||||||
this.Position.X = min.X;
|
this.Position.X = min.X;
|
||||||
if (this.Position.Y < min.Y)
|
|
||||||
this.Position.Y = min.Y;
|
|
||||||
|
|
||||||
if (this.Max.X > max.X)
|
if (this.Max.X > max.X)
|
||||||
this.Max = new Vector2(max.X, this.Max.Y);
|
this.Max = new Vector2(max.X, this.Max.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Position.Y < min.Y && this.Max.Y > max.Y) {
|
||||||
|
this.LookingPosition = new Vector2(this.LookingPosition.X, (max.Y - min.Y) / 2);
|
||||||
|
} else {
|
||||||
|
if (this.Position.Y < min.Y)
|
||||||
|
this.Position.Y = min.Y;
|
||||||
if (this.Max.Y > max.Y)
|
if (this.Max.Y > max.Y)
|
||||||
this.Max = new Vector2(this.Max.X, max.Y);
|
this.Max = new Vector2(this.Max.X, max.Y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Zoom(float delta, Vector2? zoomCenter = null) {
|
public void Zoom(float delta, Vector2? zoomCenter = null) {
|
||||||
var center = (zoomCenter ?? this.Viewport.Size.ToVector2() / 2) / this.ActualScale;
|
var center = (zoomCenter ?? this.Viewport.Size.ToVector2() / 2) / this.ActualScale;
|
||||||
|
|
Loading…
Reference in a new issue