Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 2 additions & 128 deletions C7/C7Game.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://cldl5nk4n61m2"]
[gd_scene load_steps=18 format=3 uid="uid://cldl5nk4n61m2"]

[ext_resource type="Script" uid="uid://yxhiwx46tety" path="res://Game.cs" id="1"]
[ext_resource type="Script" uid="uid://cfenrvu7tnp40" path="res://DoubleClickHandler.cs" id="2_t735q"]
Expand All @@ -18,62 +18,13 @@
[ext_resource type="PackedScene" uid="uid://dkcu255o1qrt1" path="res://UIElements/PalaceScreen/palace_screen.tscn" id="14_ud8vi"]
[ext_resource type="PackedScene" uid="uid://da7hbbufyfllg" path="res://UIElements/Advisors/domestic_advisor.tscn" id="15"]

[sub_resource type="Animation" id="2"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1024, 80)]
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:offset_left")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(),
"points": PackedFloat32Array(),
"times": PackedFloat32Array()
}

[sub_resource type="Animation" id="1"]
resource_name = "SlideOutAnimation"
length = 0.5
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:offset_left")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(),
"points": PackedFloat32Array(),
"times": PackedFloat32Array()
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_bowxq"]
_data = {
&"RESET": SubResource("2"),
&"SlideOutAnimation": SubResource("1")
}

[node name="C7Game" type="Node2D" node_paths=PackedStringArray("Toolbar", "popupOverlay", "cityScreen", "advisor", "diplomacy", "slider", "animationPlayer", "doubleClickHandler", "palaceScreen")]
[node name="C7Game" type="Node" node_paths=PackedStringArray("Toolbar", "popupOverlay", "cityScreen", "advisor", "diplomacy", "doubleClickHandler", "palaceScreen")]
script = ExtResource("1")
Toolbar = NodePath("CanvasLayer/Control/ToolBar/MarginContainer/HBoxContainer")
popupOverlay = NodePath("CanvasLayer/PopupOverlay")
cityScreen = NodePath("CanvasLayer/CityScreen")
advisor = NodePath("CanvasLayer/Advisor")
diplomacy = NodePath("CanvasLayer/Diplomacy")
slider = NodePath("CanvasLayer/Control/SlideOutBar/VBoxContainer/Zoom")
animationPlayer = NodePath("CanvasLayer/Control/SlideOutBar/AnimationPlayer")
doubleClickHandler = NodePath("DoubleClickHandler")
palaceScreen = NodePath("CanvasLayer/PalaceScreen")

Expand Down Expand Up @@ -160,76 +111,6 @@ visible = false
layout_mode = 2
text = "End Turn"

[node name="SlideOutBar" type="Control" parent="CanvasLayer/Control"]
visible = false
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 80.0
offset_right = 9324.0
offset_bottom = 1086.0
grow_horizontal = 0
grow_vertical = 2
mouse_filter = 1

[node name="SlideToggle" type="Button" parent="CanvasLayer/Control/SlideOutBar"]
layout_mode = 0
offset_left = -124.27
offset_right = -91.27
offset_bottom = 20.0
toggle_mode = true
text = "<->"

[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/Control/SlideOutBar"]
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -45.0
grow_horizontal = 0
grow_vertical = 2

[node name="DownButton" type="Button" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Down"

[node name="RightButton" type="Button" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Right"

[node name="LeftButton" type="Button" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Left"

[node name="UpButton" type="Button" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Up"

[node name="Label" type="Label" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Zoom"

[node name="Zoom" type="VSlider" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 1
size_flags_vertical = 3
min_value = 0.1
max_value = 4.0
step = 0.1
value = 1.0

[node name="QuitButton" type="Button" parent="CanvasLayer/Control/SlideOutBar/VBoxContainer"]
layout_mode = 2
text = "Quit"

[node name="AnimationPlayer" type="AnimationPlayer" parent="CanvasLayer/Control/SlideOutBar"]
libraries = {
&"": SubResource("AnimationLibrary_bowxq")
}

[node name="GameStatus" type="Control" parent="CanvasLayer/Control"]
layout_mode = 1
anchors_preset = 3
Expand Down Expand Up @@ -354,13 +235,6 @@ visible = false
[connection signal="ActionRequested" from="CanvasLayer/Control/UnitButtons" to="." method="ProcessAction"]
[connection signal="pressed" from="CanvasLayer/Control/ToolBar/MarginContainer/HBoxContainer/AdvisorButton" to="CanvasLayer/Advisor" method="ShowLatestAdvisor"]
[connection signal="pressed" from="CanvasLayer/Control/ToolBar/MarginContainer/HBoxContainer/UiBarEndTurnButton" to="." method="_onEndTurnButtonPressed"]
[connection signal="toggled" from="CanvasLayer/Control/SlideOutBar/SlideToggle" to="." method="_on_SlideToggle_toggled"]
[connection signal="pressed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/DownButton" to="." method="_on_DownButton_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/RightButton" to="." method="_on_RightButton_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/LeftButton" to="." method="_on_LeftButton_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/UpButton" to="." method="_on_UpButton_pressed"]
[connection signal="value_changed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/Zoom" to="." method="_on_Zoom_value_changed"]
[connection signal="pressed" from="CanvasLayer/Control/SlideOutBar/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]
[connection signal="BlinkyEndTurnButtonPressed" from="CanvasLayer/Control/GameStatus/LowerRightInfoBox" to="." method="OnPlayerEndTurn"]
[connection signal="BuildCity" from="CanvasLayer/PopupOverlay" to="." method="OnBuildCity"]
[connection signal="DiplomacySelection" from="CanvasLayer/PopupOverlay" to="." method="OnDiplomacySelected"]
Expand Down
2 changes: 1 addition & 1 deletion C7/Credits.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://pfefjvwiljdp"]

[ext_resource type="Script" path="res://Credits.cs" id="1"]
[ext_resource type="Script" uid="uid://0qchn4tg1h03" path="res://Credits.cs" id="1"]

[node name="Node2D" type="Node2D"]
script = ExtResource("1")
68 changes: 10 additions & 58 deletions C7/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Linq;
using C7Engine.AI;

public partial class Game : Node2D {
public partial class Game : Node {
[Signal] public delegate void TurnEndedEventHandler();
[Signal] public delegate void ShowSpecificAdvisorEventHandler();
[Signal] public delegate void NewAutoselectedUnitEventHandler();
Expand Down Expand Up @@ -80,10 +80,6 @@ public class GotoInfo {
[Export]
private Diplomacy diplomacy;
[Export]
private VSlider slider;
[Export]
private AnimationPlayer animationPlayer;
[Export]
private DoubleClickHandler doubleClickHandler;
[Export]
private PalaceScreen palaceScreen;
Expand Down Expand Up @@ -137,12 +133,6 @@ public override void _Ready() {

InitializeMapView();

//TODO: What was this supposed to do? It throws errors and occasinally causes crashes now, because _OnViewportSizeChanged doesn't exist
// GetTree().Root.Connect("size_changed",new Callable(this,"_OnViewportSizeChanged"));

// Hide slideout bar on startup
_on_SlideToggle_toggled(false);

log.Information("Now in game!");

loadTimer.Stop();
Expand Down Expand Up @@ -532,32 +522,6 @@ public void _on_Zoom_value_changed(float value) {
mapView.setCameraZoomFromMiddle(value);
}

public void AdjustZoomSlider(int numSteps, Vector2 zoomCenter) {
double newScale = slider.Value + slider.Step * (double)numSteps;
if (newScale < slider.MinValue)
newScale = slider.MinValue;
else if (newScale > slider.MaxValue)
newScale = slider.MaxValue;

// Note we must set the camera zoom before setting the new slider value since setting the value will trigger the callback which will
// adjust the zoom around a center we don't want.
mapView.setCameraZoom((float)newScale, zoomCenter);
slider.Value = newScale;
}

public void _on_RightButton_pressed() {
mapView.cameraLocation += new Vector2(128, 0);
}
public void _on_LeftButton_pressed() {
mapView.cameraLocation += new Vector2(-128, 0);
}
public void _on_UpButton_pressed() {
mapView.cameraLocation += new Vector2(0, -64);
}
public void _on_DownButton_pressed() {
mapView.cameraLocation += new Vector2(0, 64);
}

public override void _Input(InputEvent @event) {
if (@event is InputEventKey e && e.Pressed && !e.IsAction(C7Action.UnitGoto)) {
this.setGotoMode(false);
Expand Down Expand Up @@ -589,14 +553,18 @@ private void HandleMouseButtonInput(InputEventMouseButton eventMouseButton) {
} else if (eventMouseButton.ButtonIndex == MouseButton.Right && !eventMouseButton.IsPressed()) {
HandleRightMouseButton(eventMouseButton);
} else if (eventMouseButton.ButtonIndex == MouseButton.WheelUp) {
GetViewport().SetInputAsHandled();
AdjustZoomSlider(1, GetViewport().GetMousePosition());
AdjustZoom(0.1f);
} else if (eventMouseButton.ButtonIndex == MouseButton.WheelDown) {
GetViewport().SetInputAsHandled();
AdjustZoomSlider(-1, GetViewport().GetMousePosition());
AdjustZoom(-0.1f);
}
}

private void AdjustZoom(float delta) {
float newScale = mapView.cameraZoom + delta;
mapView.setCameraZoom(newScale, GetViewport().GetMousePosition());
GetViewport().SetInputAsHandled();
}

private void HandleLeftMouseButton(InputEventMouseButton eventMouseButton) {
GetViewport().SetInputAsHandled();
if (eventMouseButton.IsPressed()) {
Expand Down Expand Up @@ -810,15 +778,9 @@ private void ToggleC7Graphics() {
}

private void HandleMagnifyGesture(InputEventMagnifyGesture magnifyGesture) {
// UI slider has the min/max zoom settings for now
double newScale = mapView.cameraZoom * magnifyGesture.Factor;
if (newScale < slider.MinValue)
newScale = slider.MinValue;
else if (newScale > slider.MaxValue)
newScale = slider.MaxValue;

mapView.setCameraZoom((float)newScale, magnifyGesture.Position);
// Update the UI slider
slider.Value = newScale;
}

private void ProcessActions() {
Expand Down Expand Up @@ -887,10 +849,8 @@ private void ProcessAction(string currentAction) {
if (currentAction == C7Action.ToggleZoom) {
if (mapView.cameraZoom != 1) {
mapView.setCameraZoomFromMiddle(1.0f);
slider.Value = 1.0f;
} else {
mapView.setCameraZoomFromMiddle(0.5f);
slider.Value = 0.5f;
}
}

Expand Down Expand Up @@ -1067,14 +1027,6 @@ private GotoInfo GetGotoInfo(Vector2 mousePos) {
return result;
}

private void _on_SlideToggle_toggled(bool buttonPressed) {
if (buttonPressed) {
animationPlayer.PlayBackwards("SlideOutAnimation");
} else {
animationPlayer.Play("SlideOutAnimation");
}
}

/**
* User quit. We *may* want to do some things here like make a back-up save, or call the server and let it know we're bailing (esp. in MP).
**/
Expand Down
5 changes: 5 additions & 0 deletions C7/MapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ public int getRowStartX(int y) {
public CityLayer cityLayer { get; private set; }
public TileAssignmentLayer tileAssignmentLayer { get; private set; }

const float MIN_SCALE = 0.1f;
const float MAX_SCALE = 4.0f;

public MapView(Game game, int mapWidth, int mapHeight, bool wrapHorizontally, bool wrapVertically) {
this.game = game;
this.mapWidth = mapWidth;
Expand Down Expand Up @@ -655,6 +658,8 @@ public VisibleRegion getVisibleRegion() {
// "center" is the screen location around which the zoom is centered, e.g., if center is (0, 0) the tile in the top left corner will be the
// same after the zoom level is changed, and if center is screenSize/2, the tile in the center of the window won't change.
public void setCameraZoom(float newScale, Vector2 center) {
newScale = Math.Clamp(newScale, MIN_SCALE, MAX_SCALE);

Vector2 v2NewZoom = new Vector2(newScale, newScale);
Vector2 v2OldZoom = new Vector2(cameraZoom, cameraZoom);
if (v2NewZoom != v2OldZoom) {
Expand Down
6 changes: 3 additions & 3 deletions C7/UIElements/Advisors/domestic_advisor.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://da7hbbufyfllg"]

[ext_resource type="Script" path="res://UIElements/Advisors/DomesticAdvisor.cs" id="1"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureRect.cs" id="2"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureButton.cs" id="3"]
[ext_resource type="Script" uid="uid://ch2d6f1o1sxh2" path="res://UIElements/Advisors/DomesticAdvisor.cs" id="1"]
[ext_resource type="Script" uid="uid://doqipc4rnaotx" path="res://UIElements/Civ3TextureRect.cs" id="2"]
[ext_resource type="Script" uid="uid://dcrdcjop64t6t" path="res://UIElements/Civ3TextureButton.cs" id="3"]

[sub_resource type="LabelSettings" id="LabelSettings_0b8py"]
font_size = 13
Expand Down
8 changes: 4 additions & 4 deletions C7/UIElements/CityScreen/city_screen.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[gd_scene load_steps=12 format=3 uid="uid://bo4yg85jcbgdx"]

[ext_resource type="Script" path="res://UIElements/CityScreen/CityScreen.cs" id="1_e5kig"]
[ext_resource type="Script" uid="uid://cc43pgbg3jt26" path="res://UIElements/CityScreen/CityScreen.cs" id="1_e5kig"]
[ext_resource type="PackedScene" uid="uid://bnvwn0hhrsn82" path="res://UIElements/black_sidebars.tscn" id="1_hl43g"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureRect.cs" id="2_0mao8"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureButton.cs" id="3_3cdyr"]
[ext_resource type="Script" path="res://UIElements/CityScreen/ProductionMenu.cs" id="4_xfbtv"]
[ext_resource type="Script" uid="uid://doqipc4rnaotx" path="res://UIElements/Civ3TextureRect.cs" id="2_0mao8"]
[ext_resource type="Script" uid="uid://dcrdcjop64t6t" path="res://UIElements/Civ3TextureButton.cs" id="3_3cdyr"]
[ext_resource type="Script" uid="uid://xd5truvfnnws" path="res://UIElements/CityScreen/ProductionMenu.cs" id="4_xfbtv"]
[ext_resource type="FontFile" uid="uid://c1qd602n7xu3h" path="res://Fonts/NotoSans-Regular.ttf" id="5_hld1k"]

[sub_resource type="InputEventKey" id="InputEventKey_ce4da"]
Expand Down
4 changes: 2 additions & 2 deletions C7/UIElements/MainMenu/main_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gmerc"]

[node name="MainMenu" type="Node" node_paths=PackedStringArray("LoadDialog", "SetCiv3Home", "SetCiv3HomeDialog", "LoadScenarioDialog", "ButtonContainer", "UseStandaloneMode", "player")]
[node name="MainMenu" type="Node" node_paths=PackedStringArray("LoadDialog", "SetCiv3Home", "SetCiv3HomeDialog", "LoadScenarioDialog", "ButtonContainer", "player", "UseStandaloneMode")]
script = ExtResource("1_akneh")
LoadDialog = NodePath("LoadDialog")
SetCiv3Home = NodePath("SetCiv3Home")
SetCiv3HomeDialog = NodePath("SetCiv3HomeDialog")
LoadScenarioDialog = NodePath("LoadScenarioDialog")
UseStandaloneMode = NodePath("UseStandaloneMode")
ButtonContainer = NodePath("Control/MainMenuContainer")
player = NodePath("SoundEffectPlayer")
UseStandaloneMode = NodePath("UseStandaloneMode")

[node name="Control" type="Control" parent="."]
layout_mode = 3
Expand Down
1 change: 1 addition & 0 deletions C7/UIElements/NewGame/ScenarioSetup.cs.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://dpe8ukuhvtdvx
6 changes: 3 additions & 3 deletions C7/UIElements/PalaceScreen/palace_screen.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://dkcu255o1qrt1"]

[ext_resource type="PackedScene" uid="uid://bnvwn0hhrsn82" path="res://UIElements/black_sidebars.tscn" id="1_a64pg"]
[ext_resource type="Script" path="res://UIElements/PalaceScreen/PalaceScreen.cs" id="2_er1um"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureRect.cs" id="2_p0gtj"]
[ext_resource type="Script" path="res://UIElements/Civ3TextureButton.cs" id="4_yi45k"]
[ext_resource type="Script" uid="uid://by7gjap06whbu" path="res://UIElements/PalaceScreen/PalaceScreen.cs" id="2_er1um"]
[ext_resource type="Script" uid="uid://doqipc4rnaotx" path="res://UIElements/Civ3TextureRect.cs" id="2_p0gtj"]
[ext_resource type="Script" uid="uid://dcrdcjop64t6t" path="res://UIElements/Civ3TextureButton.cs" id="4_yi45k"]

[node name="PalaceScreen" node_paths=PackedStringArray("background", "close") instance=ExtResource("1_a64pg")]
script = ExtResource("2_er1um")
Expand Down
2 changes: 1 addition & 1 deletion C7/UIElements/civ3_file_dialog.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bvncm1bgcii5e"]

[ext_resource type="Script" path="res://UIElements/Civ3FileDialog.cs" id="1_mb1lm"]
[ext_resource type="Script" uid="uid://bw35dy5mh6hx" path="res://UIElements/Civ3FileDialog.cs" id="1_mb1lm"]

[node name="LoadDialog" type="FileDialog"]
initial_position = 1
Expand Down