Skip to content

Commit

Permalink
Game zoom (#84)
Browse files Browse the repository at this point in the history
* Set zoom to min at start of board

* Build 0.7.2
  • Loading branch information
patches34 authored Dec 8, 2023
1 parent fcbca90 commit 14505f8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
51 changes: 30 additions & 21 deletions Assets/Scripts/Singletons/MenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ void Start()
{
Application.targetFrameRate = 30;



for(int i = 0; i < transform.childCount; ++i)
{
UIMenu childScreen = transform.GetChild(i).GetComponent<UIMenu>();
Expand All @@ -72,9 +70,9 @@ void Start()
}
}

#if !UNITY_EDITOR
#if !UNITY_EDITOR
ShowMenu(MenuTypes.Info);
#endif
#endif
}

public string BuildVersionStr;
Expand Down Expand Up @@ -147,29 +145,38 @@ void SetZoom(float delta, float zoomSpeed)

// X
rectScale.x -= delta * zoomSpeed;
if(rectScale.x > zoomMax)
{
rectScale.x = zoomMax;
}
else if(rectScale.x < zoomMin)
{
rectScale.x = zoomMin;
}

// Y
rectScale.y -= delta * zoomSpeed;
if(rectScale.y > zoomMax)
{
rectScale.y = zoomMax;
}
else if(rectScale.y < zoomMin)
{
rectScale.y = zoomMin;
}

boardPaddingRect.localScale = rectScale;
SetZoom(rectScale);
}

void SetZoom(Vector2 newZoom)
{
// X
if (newZoom.x > zoomMax)
{
newZoom.x = zoomMax;
}
else if (newZoom.x < zoomMin)
{
newZoom.x = zoomMin;
}

// Y
if (newZoom.y > zoomMax)
{
newZoom.y = zoomMax;
}
else if (newZoom.y < zoomMin)
{
newZoom.y = zoomMin;
}

boardPaddingRect.localScale = newZoom;
}

public void ShowMenu(int type)
{
ShowMenu((MenuTypes)type);
Expand Down Expand Up @@ -199,6 +206,8 @@ public void ResizeGameBoard(Vector2 boardSize)
boardPaddingRect.offsetMin = -boardSize - boardPadding;

zoomMin = Mathf.Min(CanvasRect.width / boardPaddingRect.rect.width, CanvasRect.height / boardPaddingRect.rect.height);

SetZoom(new Vector2(zoomMin, zoomMin));
}

public void SetZoomSpeed(float value)
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.7.1
bundleVersion: 0.7.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down
Binary file modified docs/Build/docs.data
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/Build/docs.framework.js

Large diffs are not rendered by default.

Binary file modified docs/Build/docs.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
streamingAssetsUrl: "StreamingAssets",
companyName: "Patches",
productName: "CreatureSweep",
productVersion: "0.7.1",
productVersion: "0.7.2",
showBanner: unityShowBanner,
};

Expand Down

0 comments on commit 14505f8

Please sign in to comment.