Added better grid to the map and reworked camera positioning whilst map is open
This commit is contained in:
+18
-15
@@ -35,6 +35,9 @@ bg_color = Color(0.36567047, 0.46785766, 0.7000103, 0.5176471)
|
|||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2irst"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2irst"]
|
||||||
bg_color = Color(0.30085096, 0.39694247, 0.6216495, 0.5176471)
|
bg_color = Color(0.30085096, 0.39694247, 0.6216495, 0.5176471)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bf53h"]
|
||||||
|
bg_color = Color(0.3106171, 0.31061712, 0.310617, 1)
|
||||||
|
|
||||||
[node name="Main" type="Node3D" unique_id=234207355]
|
[node name="Main" type="Node3D" unique_id=234207355]
|
||||||
|
|
||||||
[node name="World" type="Node3D" parent="." unique_id=770208789]
|
[node name="World" type="Node3D" parent="." unique_id=770208789]
|
||||||
@@ -54,7 +57,7 @@ environment = SubResource("Environment_sb48q")
|
|||||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
|
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1558432386]
|
||||||
follow_viewport_enabled = true
|
follow_viewport_enabled = true
|
||||||
|
|
||||||
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "information", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu")]
|
[node name="UIHandler" type="Control" parent="CanvasLayer" unique_id=1713248285 node_paths=PackedStringArray("codingWindow", "robotList", "mainCam", "map", "FPS", "RAM", "options", "uiContent", "menu")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@@ -68,7 +71,6 @@ size_flags_vertical = 3
|
|||||||
script = ExtResource("4_fgofq")
|
script = ExtResource("4_fgofq")
|
||||||
codingWindow = NodePath("MainUI/Content/CodingWindow")
|
codingWindow = NodePath("MainUI/Content/CodingWindow")
|
||||||
robotList = NodePath("MainUI/Content/RobotList")
|
robotList = NodePath("MainUI/Content/RobotList")
|
||||||
information = NodePath("")
|
|
||||||
mainCam = NodePath("../../Camera3D")
|
mainCam = NodePath("../../Camera3D")
|
||||||
map = NodePath("MainUI/Content/Map")
|
map = NodePath("MainUI/Content/Map")
|
||||||
FPS = NodePath("MainUI/FooterContainer/HBoxContainer/FPS")
|
FPS = NodePath("MainUI/FooterContainer/HBoxContainer/FPS")
|
||||||
@@ -255,24 +257,25 @@ theme_override_constants/separation = 10
|
|||||||
[node name="Map" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=292881873 node_paths=PackedStringArray("grid")]
|
[node name="Map" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=292881873 node_paths=PackedStringArray("grid")]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 15
|
||||||
anchor_left = 0.5
|
anchor_right = 1.0
|
||||||
anchor_top = 0.5
|
anchor_bottom = 1.0
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
offset_left = -20.0
|
|
||||||
offset_top = -20.0
|
|
||||||
offset_right = 20.0
|
|
||||||
offset_bottom = 20.0
|
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_bf53h")
|
||||||
script = ExtResource("8_bf53h")
|
script = ExtResource("8_bf53h")
|
||||||
grid = NodePath("GridContainer")
|
grid = NodePath("CenterContainer/AspectRatioContainer/GridContainer")
|
||||||
|
|
||||||
[node name="GridContainer" type="GridContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Map" unique_id=218955579]
|
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Map" unique_id=1126051644]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 4
|
|
||||||
size_flags_vertical = 4
|
[node name="AspectRatioContainer" type="AspectRatioContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Map/CenterContainer" unique_id=871200780]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="GridContainer" type="GridContainer" parent="CanvasLayer/UIHandler/MainUI/Content/Map/CenterContainer/AspectRatioContainer" unique_id=981768520]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/h_separation = 10
|
||||||
|
theme_override_constants/v_separation = 10
|
||||||
|
|
||||||
[node name="Menu" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=370952082]
|
[node name="Menu" type="PanelContainer" parent="CanvasLayer/UIHandler/MainUI/Content" unique_id=370952082]
|
||||||
visible = false
|
visible = false
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ public partial class Camera3d : Camera3D
|
|||||||
[Export] public float ScrollStrength = 5.0f;
|
[Export] public float ScrollStrength = 5.0f;
|
||||||
|
|
||||||
private bool isShowingMap = false;
|
private bool isShowingMap = false;
|
||||||
private Vector3 previousPosition;
|
|
||||||
|
|
||||||
private Vector2 _mouseDelta;
|
private Vector2 _mouseDelta;
|
||||||
|
|
||||||
@@ -25,18 +24,6 @@ public partial class Camera3d : Camera3D
|
|||||||
{
|
{
|
||||||
isShowingMap = !isShowingMap;
|
isShowingMap = !isShowingMap;
|
||||||
canMove = !isShowingMap;
|
canMove = !isShowingMap;
|
||||||
if (isShowingMap)
|
|
||||||
{
|
|
||||||
previousPosition = Position;
|
|
||||||
Position = new Vector3(layerSize * tileWidth / 2 - tileWidth / 2, 90 - visibleLayer * 4, layerSize * tileWidth / 2 - tileWidth / 2);
|
|
||||||
RotationDegrees = new Vector3(-90, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Position = previousPosition;
|
|
||||||
RotationDegrees = new Vector3(-75, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,34 +7,55 @@ public partial class Map : PanelContainer
|
|||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
grid.Columns = GameData.layerSize + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
//TODO: This has to be temporary! Drawing each frame is way too expensive.
|
|
||||||
if (Visible)
|
|
||||||
{
|
|
||||||
ShowMap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowMap()
|
public void ShowMap()
|
||||||
{
|
{
|
||||||
grid.Columns = GameData.layerSize;
|
|
||||||
grid.AddThemeConstantOverride("h_separation", (int)(GameData.tileWidth * 2.5f));
|
|
||||||
grid.AddThemeConstantOverride("v_separation", (int)(GameData.tileWidth * 2.5f));
|
|
||||||
foreach (Node node in grid.GetChildren())
|
foreach (Node node in grid.GetChildren())
|
||||||
{
|
{
|
||||||
grid.RemoveChild(node);
|
grid.RemoveChild(node);
|
||||||
node.QueueFree();
|
node.QueueFree();
|
||||||
}
|
}
|
||||||
TextureRect texture;
|
TextureRect texture;
|
||||||
|
Label label;
|
||||||
Tile[,] tiles = GameData.map[GameData.currentLayer].tiles;
|
Tile[,] tiles = GameData.map[GameData.currentLayer].tiles;
|
||||||
for (int z = 0; z < GameData.layerSize; z++)
|
int size = GameData.layerSize;
|
||||||
|
for (int z = -1; z < size; z++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < GameData.layerSize; x++)
|
for (int x = -1; x < size; x++)
|
||||||
{
|
{
|
||||||
|
if (z == -1 || x == -1)
|
||||||
|
{
|
||||||
|
label = new Label
|
||||||
|
{
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
|
||||||
|
SizeFlagsHorizontal = SizeFlags.ExpandFill,
|
||||||
|
SizeFlagsVertical = SizeFlags.ExpandFill
|
||||||
|
};
|
||||||
|
if (z == -1 && x == -1)
|
||||||
|
{
|
||||||
|
label.Text = "\u2193 Z | \u2192 X";
|
||||||
|
}
|
||||||
|
else if(z == -1)
|
||||||
|
{
|
||||||
|
label.Text = x.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label.Text = z.ToString();
|
||||||
|
}
|
||||||
|
grid.AddChild(label);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
texture = new TextureRect();
|
texture = new TextureRect();
|
||||||
if (tiles[x, z].wasVisited)
|
if (tiles[x, z].wasVisited)
|
||||||
{
|
{
|
||||||
@@ -52,6 +73,10 @@ public partial class Map : PanelContainer
|
|||||||
texture.Texture = GenerateTexture(32, new Color(0, 0, 0, 1));
|
texture.Texture = GenerateTexture(32, new Color(0, 0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
texture.SizeFlagsHorizontal = SizeFlags.ExpandFill;
|
||||||
|
texture.SizeFlagsVertical = SizeFlags.ExpandFill;
|
||||||
|
texture.StretchMode = TextureRect.StretchModeEnum.Scale;
|
||||||
|
|
||||||
grid.AddChild(texture);
|
grid.AddChild(texture);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user