Skip to content

Commit e180aa5

Browse files
committed
Change cursor when the map is being scrolled.
1 parent 45ab013 commit e180aa5

File tree

2,256 files changed

+42883
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,256 files changed

+42883
-20
lines changed
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
[gd_scene load_steps=2 format=3 uid="uid://2hgdqurtbrxg"]
1+
[gd_scene load_steps=8 format=3 uid="uid://2hgdqurtbrxg"]
22

33
[ext_resource type="Script" path="res://scripts/controllers/player_controller.gd" id="1_86wpr"]
4+
[ext_resource type="Texture2D" uid="uid://p0bi3bytr53n" path="res://vendor/kenney_cursor-pack/PNG/Outline/Default/hand_closed.png" id="2_tvrf7"]
5+
[ext_resource type="Texture2D" uid="uid://h7bopucdukak" path="res://vendor/kenney_cursor-pack/PNG/Outline/Default/pointer_b.png" id="3_h3cn0"]
6+
[ext_resource type="Texture2D" uid="uid://bjck8jhfqnq0b" path="res://vendor/kenney_cursor-pack/PNG/Outline/Double/arrow_e.png" id="4_sg2mc"]
7+
[ext_resource type="Texture2D" uid="uid://duld2c16y04fr" path="res://vendor/kenney_cursor-pack/PNG/Outline/Double/arrow_n.png" id="5_x6eqs"]
8+
[ext_resource type="Texture2D" uid="uid://ovblhumn68fu" path="res://vendor/kenney_cursor-pack/PNG/Outline/Double/arrow_s.png" id="6_c3rid"]
9+
[ext_resource type="Texture2D" uid="uid://bxw018pmva53p" path="res://vendor/kenney_cursor-pack/PNG/Outline/Double/arrow_w.png" id="7_gew4c"]
410

511
[node name="PlayerController" type="Node2D"]
612
script = ExtResource("1_86wpr")
713
mouse_drag_scroll_speed = 0.7
14+
drag_icon = ExtResource("2_tvrf7")
15+
arrow_icon = ExtResource("3_h3cn0")
16+
scroll_east_icon = ExtResource("4_sg2mc")
17+
scroll_north_icon = ExtResource("5_x6eqs")
18+
scroll_south_icon = ExtResource("6_c3rid")
19+
scroll_west_icon = ExtResource("7_gew4c")

scenes/main/main.tscn

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
[gd_scene load_steps=2 format=3 uid="uid://d3nj6rt0cm53e"]
1+
[gd_scene load_steps=5 format=3 uid="uid://d3nj6rt0cm53e"]
22

33
[ext_resource type="PackedScene" uid="uid://xlfbl7fowoic" path="res://scenes/worldmap/world_map.tscn" id="1_cjno1"]
4+
[ext_resource type="PackedScene" uid="uid://bnqxch8qylr8l" path="res://ui/widgets/hud.tscn" id="2_jggq6"]
5+
[ext_resource type="PackedScene" uid="uid://2hgdqurtbrxg" path="res://scenes/common/player_controller.tscn" id="3_jr0xa"]
6+
[ext_resource type="PackedScene" uid="uid://dcnty7qxod06" path="res://scenes/components/camera_component.tscn" id="4_xha1d"]
47

58
[node name="World" type="Node2D"]
69

710
[node name="WorldMap" parent="." instance=ExtResource("1_cjno1")]
11+
position = Vector2(0, 1)
12+
13+
[node name="CanvasLayer" type="CanvasLayer" parent="."]
14+
15+
[node name="HUD" parent="CanvasLayer" instance=ExtResource("2_jggq6")]
16+
17+
[node name="Controllers" type="Node" parent="."]
18+
19+
[node name="PlayerController" parent="Controllers" node_paths=PackedStringArray("hud", "camera_component") instance=ExtResource("3_jr0xa")]
20+
hud = NodePath("../../CanvasLayer/HUD")
21+
camera_component = NodePath("../../Components/CameraComponent")
22+
23+
[node name="Components" type="Node" parent="."]
24+
25+
[node name="CameraComponent" parent="Components" instance=ExtResource("4_xha1d")]

scenes/worldmap/world_map.tscn

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
[gd_scene load_steps=4 format=3 uid="uid://xlfbl7fowoic"]
1+
[gd_scene load_steps=2 format=3 uid="uid://xlfbl7fowoic"]
22

33
[ext_resource type="Texture2D" uid="uid://dy5vfc6jr3l4i" path="res://vendor/Double C's Pixel World Map/3x Size/All_3x/PixelWorldMap_All_Countries_3x.png" id="1_kd50k"]
4-
[ext_resource type="PackedScene" uid="uid://2hgdqurtbrxg" path="res://scenes/common/player_controller.tscn" id="2_bjhnr"]
5-
[ext_resource type="PackedScene" uid="uid://dcnty7qxod06" path="res://scenes/components/camera_component.tscn" id="3_f33gq"]
64

75
[node name="WorldMap" type="Node2D"]
86

97
[node name="WorldMapImage" type="TextureRect" parent="."]
108
offset_right = 40.0
119
offset_bottom = 40.0
1210
texture = ExtResource("1_kd50k")
13-
14-
[node name="Controllers" type="Node" parent="."]
15-
16-
[node name="PlayerController" parent="Controllers" node_paths=PackedStringArray("camera_component") instance=ExtResource("2_bjhnr")]
17-
camera_component = NodePath("../../Components/CameraComponent")
18-
19-
[node name="Components" type="Node" parent="."]
20-
21-
[node name="CameraComponent" parent="Components" instance=ExtResource("3_f33gq")]

scripts/controllers/player_controller.gd

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,33 @@ extends Node2D
44
@export var mouse_drag_scroll_speed: float = 1.5
55
@export var mouse_edge_scroll_speed: float = 6
66
@export var mouse_scroll_threshold: float = 50 # how many pixels from the sides of the screen triggers a mouse scroll
7+
@export var drag_icon: Texture2D
8+
@export var arrow_icon: Texture2D
9+
@export var scroll_east_icon: Texture2D
10+
@export var scroll_north_icon: Texture2D
11+
@export var scroll_south_icon: Texture2D
12+
@export var scroll_west_icon: Texture2D
13+
@export var hud: Control
714
@export var camera_component: CameraComponent
815
var is_dragging: bool = false
916

1017
func _ready():
1118
Input.mouse_mode = Input.MOUSE_MODE_CONFINED
19+
Input.set_custom_mouse_cursor(arrow_icon, Input.CURSOR_ARROW)
1220

1321
func _input(event):
1422
if event.is_action_pressed("start_drag"):
23+
Input.set_custom_mouse_cursor(drag_icon, Input.CURSOR_DRAG)
1524
is_dragging = true
25+
hud.mouse_default_cursor_shape = Control.CURSOR_DRAG
1626
elif event.is_action_released("start_drag"):
1727
is_dragging = false
28+
hud.mouse_default_cursor_shape = Control.CURSOR_ARROW
1829

1930
if event is InputEventMouseMotion and is_dragging:
2031
camera_component.apply_camera_movement(event.relative * mouse_drag_scroll_speed)
21-
2232

23-
func _process(delta: float) -> void:
33+
func _process(_delta: float) -> void:
2434
var camera_movement := Vector2.ZERO
2535

2636
if Input.is_action_pressed("move_map_left"):
@@ -37,12 +47,28 @@ func _process(delta: float) -> void:
3747
var max_y = get_viewport_rect().size.y
3848
var mouse_global_position = get_viewport().get_mouse_position()
3949
if mouse_global_position.x <= mouse_scroll_threshold:
40-
camera_component.apply_camera_movement(Vector2.LEFT * mouse_edge_scroll_speed)
50+
scroll_and_set_cursor(Vector2.LEFT)
4151
elif mouse_global_position.y <= mouse_scroll_threshold:
42-
camera_component.apply_camera_movement(Vector2.UP * mouse_edge_scroll_speed)
52+
scroll_and_set_cursor(Vector2.UP)
4353
elif mouse_global_position.y >= max_y - mouse_scroll_threshold:
44-
camera_component.apply_camera_movement(Vector2.DOWN * mouse_edge_scroll_speed)
54+
scroll_and_set_cursor(Vector2.DOWN)
4555
elif mouse_global_position.x >= max_x - mouse_scroll_threshold:
46-
camera_component.apply_camera_movement(Vector2.RIGHT * mouse_edge_scroll_speed)
56+
scroll_and_set_cursor(Vector2.RIGHT)
57+
elif !is_dragging:
58+
hud.mouse_default_cursor_shape = Control.CURSOR_ARROW
4759

4860
camera_component.apply_camera_movement(camera_movement)
61+
62+
func scroll_and_set_cursor(direction: Vector2):
63+
match direction:
64+
Vector2.LEFT:
65+
Input.set_custom_mouse_cursor(scroll_west_icon, Input.CURSOR_MOVE)
66+
Vector2.RIGHT:
67+
Input.set_custom_mouse_cursor(scroll_east_icon, Input.CURSOR_MOVE)
68+
Vector2.DOWN:
69+
Input.set_custom_mouse_cursor(scroll_south_icon, Input.CURSOR_MOVE)
70+
Vector2.UP:
71+
Input.set_custom_mouse_cursor(scroll_north_icon, Input.CURSOR_MOVE)
72+
73+
hud.mouse_default_cursor_shape = Control.CURSOR_MOVE
74+
camera_component.apply_camera_movement(direction * mouse_edge_scroll_speed)
214 KB
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[remap]
2+
3+
importer="font_data_dynamic"
4+
type="FontFile"
5+
uid="uid://bpwuvjqnnu722"
6+
path="res://.godot/imported/Lora-Italic-VariableFont_wght.ttf-5eea12e4558fc9ab5487d8bc45524162.fontdata"
7+
8+
[deps]
9+
10+
source_file="res://ui/fonts/lora/Lora-Italic-VariableFont_wght.ttf"
11+
dest_files=["res://.godot/imported/Lora-Italic-VariableFont_wght.ttf-5eea12e4558fc9ab5487d8bc45524162.fontdata"]
12+
13+
[params]
14+
15+
Rendering=null
16+
antialiasing=1
17+
generate_mipmaps=false
18+
multichannel_signed_distance_field=false
19+
msdf_pixel_range=8
20+
msdf_size=48
21+
allow_system_fallback=true
22+
force_autohinter=false
23+
hinting=1
24+
subpixel_positioning=1
25+
oversampling=0.0
26+
Fallbacks=null
27+
fallbacks=[]
28+
Compress=null
29+
compress=true
30+
preload=[]
31+
language_support={}
32+
script_support={}
33+
opentype_features={}
206 KB
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[remap]
2+
3+
importer="font_data_dynamic"
4+
type="FontFile"
5+
uid="uid://8v41ay8s1ap5"
6+
path="res://.godot/imported/Lora-VariableFont_wght.ttf-796cb679087b03af2f2f172e699536d2.fontdata"
7+
8+
[deps]
9+
10+
source_file="res://ui/fonts/lora/Lora-VariableFont_wght.ttf"
11+
dest_files=["res://.godot/imported/Lora-VariableFont_wght.ttf-796cb679087b03af2f2f172e699536d2.fontdata"]
12+
13+
[params]
14+
15+
Rendering=null
16+
antialiasing=1
17+
generate_mipmaps=false
18+
multichannel_signed_distance_field=false
19+
msdf_pixel_range=8
20+
msdf_size=48
21+
allow_system_fallback=true
22+
force_autohinter=false
23+
hinting=1
24+
subpixel_positioning=1
25+
oversampling=0.0
26+
Fallbacks=null
27+
fallbacks=[]
28+
Compress=null
29+
compress=true
30+
preload=[]
31+
language_support={}
32+
script_support={}
33+
opentype_features={}

ui/fonts/lora/OFL.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2011 The Lora Project Authors (https://github.com/cyrealtype/Lora-Cyrillic), with Reserved Font Name "Lora".
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
https://openfontlicense.org
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.

ui/fonts/lora/README.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Lora Variable Font
2+
==================
3+
4+
This download contains Lora as both variable fonts and static fonts.
5+
6+
Lora is a variable font with this axis:
7+
wght
8+
9+
This means all the styles are contained in these files:
10+
Lora/Lora-VariableFont_wght.ttf
11+
Lora/Lora-Italic-VariableFont_wght.ttf
12+
13+
If your app fully supports variable fonts, you can now pick intermediate styles
14+
that aren’t available as static fonts. Not all apps support variable fonts, and
15+
in those cases you can use the static font files for Lora:
16+
Lora/static/Lora-Regular.ttf
17+
Lora/static/Lora-Medium.ttf
18+
Lora/static/Lora-SemiBold.ttf
19+
Lora/static/Lora-Bold.ttf
20+
Lora/static/Lora-Italic.ttf
21+
Lora/static/Lora-MediumItalic.ttf
22+
Lora/static/Lora-SemiBoldItalic.ttf
23+
Lora/static/Lora-BoldItalic.ttf
24+
25+
Get started
26+
-----------
27+
28+
1. Install the font files you want to use
29+
30+
2. Use your app's font picker to view the font family and all the
31+
available styles
32+
33+
Learn more about variable fonts
34+
-------------------------------
35+
36+
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
37+
https://variablefonts.typenetwork.com
38+
https://medium.com/variable-fonts
39+
40+
In desktop apps
41+
42+
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
43+
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
44+
45+
Online
46+
47+
https://developers.google.com/fonts/docs/getting_started
48+
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
49+
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
50+
51+
Installing fonts
52+
53+
MacOS: https://support.apple.com/en-us/HT201749
54+
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
55+
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
56+
57+
Android Apps
58+
59+
https://developers.google.com/fonts/docs/android
60+
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
61+
62+
License
63+
-------
64+
Please read the full license text (OFL.txt) to understand the permissions,
65+
restrictions and requirements for usage, redistribution, and modification.
66+
67+
You can use them in your products & projects – print or digital,
68+
commercial or otherwise.
69+
70+
This isn't legal advice, please consider consulting a lawyer and see the full
71+
license for all details.

0 commit comments

Comments
 (0)