mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-18 07:53:48 +00:00
Mouse cursor resizing
This commit is contained in:
parent
543f5f0d6b
commit
1d3349f7e0
9 changed files with 80 additions and 3 deletions
BIN
ExternalMaterial/3DCursor/3DCursor.png
(Stored with Git LFS)
Normal file
BIN
ExternalMaterial/3DCursor/3DCursor.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
ExternalMaterial/3DCursor/3DCursor.png.import
Normal file
34
ExternalMaterial/3DCursor/3DCursor.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d3oxwik1uoe4j"
|
||||||
|
path="res://.godot/imported/3DCursor.png-3846395cd15d92b7aa2d0b098e1c7a4b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ExternalMaterial/3DCursor/3DCursor.png"
|
||||||
|
dest_files=["res://.godot/imported/3DCursor.png-3846395cd15d92b7aa2d0b098e1c7a4b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
BIN
ExternalMaterial/3DCursor/3DCursor.pxc
Normal file
BIN
ExternalMaterial/3DCursor/3DCursor.pxc
Normal file
Binary file not shown.
BIN
ExternalMaterial/3DCursor/3DCursor.pxc1
Normal file
BIN
ExternalMaterial/3DCursor/3DCursor.pxc1
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Cirno.Scripts.Resources;
|
using Cirno.Scripts.Resources;
|
||||||
using Cirno.Scripts.Utils;
|
using Cirno.Scripts.Utils;
|
||||||
|
|
@ -20,6 +21,12 @@ public partial class GlobalState : Node
|
||||||
|
|
||||||
private Control _loadingPlaque;
|
private Control _loadingPlaque;
|
||||||
|
|
||||||
|
private readonly StringName _menuMouseTexturePath = "uid://d3oxwik1uoe4j";
|
||||||
|
private readonly StringName _reticuleMouseTexturePath = "uid://8nns6w0skiy3";
|
||||||
|
|
||||||
|
private Texture2D _menuMouseTexture;
|
||||||
|
private Image _menuMouseImage;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
@ -32,9 +39,28 @@ public partial class GlobalState : Node
|
||||||
|
|
||||||
_fader = CreateFader();
|
_fader = CreateFader();
|
||||||
|
|
||||||
|
_menuMouseTexture =ResourceLoader.Load<Texture2D>(_menuMouseTexturePath);
|
||||||
|
_menuMouseImage = _menuMouseTexture.GetImage();
|
||||||
|
|
||||||
|
GetTree().GetRoot().SizeChanged += OnSizeChanged;
|
||||||
|
//_mouseTexture =
|
||||||
|
OnSizeChanged();
|
||||||
//LoadPlaque();
|
//LoadPlaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSizeChanged()
|
||||||
|
{
|
||||||
|
var root = GetTree().GetRoot();
|
||||||
|
var baseSize = root.ContentScaleSize;
|
||||||
|
var newSize = root.Size;
|
||||||
|
|
||||||
|
int scaleX = newSize.X / baseSize.X;
|
||||||
|
int scaleY = newSize.Y / baseSize.Y;
|
||||||
|
int scale = Math.Min(scaleX, scaleY); // Ensure pixel-perfect scaling
|
||||||
|
|
||||||
|
ResizeCursor(scale / 2);
|
||||||
|
}
|
||||||
|
|
||||||
public void GotoScene(string path)
|
public void GotoScene(string path)
|
||||||
{
|
{
|
||||||
// This function will usually be called from a signal callback,
|
// This function will usually be called from a signal callback,
|
||||||
|
|
@ -176,9 +202,21 @@ public partial class GlobalState : Node
|
||||||
|
|
||||||
saveFile.StoreLine(jsonString);
|
saveFile.StoreLine(jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadGame()
|
public void LoadGame()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResizeCursor(float scale)
|
||||||
|
{
|
||||||
|
var scaled = (Image)_menuMouseImage.Duplicate();
|
||||||
|
|
||||||
|
var size = (Vector2I)(scale * _menuMouseTexture.GetSize());
|
||||||
|
|
||||||
|
scaled.Resize(size.X, size.Y, Image.Interpolation.Nearest);
|
||||||
|
|
||||||
|
DisplayServer.CursorSetCustomImage(scaled);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -120,5 +120,9 @@ public partial class OptionsMenu : MenuBase
|
||||||
AudioServer.SetBusVolumeLinear(AudioServer.GetBusIndex("Effects"), config.GetValue("Audio", "Effects", AudioServer.GetBusVolumeLinear(AudioServer.GetBusIndex("Effects"))).AsSingle());
|
AudioServer.SetBusVolumeLinear(AudioServer.GetBusIndex("Effects"), config.GetValue("Audio", "Effects", AudioServer.GetBusVolumeLinear(AudioServer.GetBusIndex("Effects"))).AsSingle());
|
||||||
|
|
||||||
AudioServer.SetBusVolumeLinear(AudioServer.GetBusIndex("Music"), config.GetValue("Audio", "Music", AudioServer.GetBusVolumeLinear(AudioServer.GetBusIndex("Music"))).AsSingle());
|
AudioServer.SetBusVolumeLinear(AudioServer.GetBusIndex("Music"), config.GetValue("Audio", "Music", AudioServer.GetBusVolumeLinear(AudioServer.GetBusIndex("Music"))).AsSingle());
|
||||||
|
|
||||||
|
// Scale mouse
|
||||||
|
|
||||||
|
GlobalState.Instance.ResizeCursor(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,8 +127,6 @@ window/size/window_width_override=1920
|
||||||
window/size/window_height_override=1080
|
window/size/window_height_override=1080
|
||||||
window/stretch/mode="canvas_items"
|
window/stretch/mode="canvas_items"
|
||||||
window/stretch/scale_mode="integer"
|
window/stretch/scale_mode="integer"
|
||||||
mouse_cursor/custom_image="uid://8nns6w0skiy3"
|
|
||||||
mouse_cursor/custom_image_hotspot=Vector2(24, 24)
|
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue