-
Notifications
You must be signed in to change notification settings - Fork 64
Victory status, towards victory conditions #983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ajhalme
wants to merge
19
commits into
C7-Game:Development
Choose a base branch
from
ajhalme:victory-status
base: Development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1d7d43e
Init grid
ajhalme 0245a99
Basic support for victory status views, towards game victory
ajhalme 43805e0
Merge branch 'Development' into victory-status
ajhalme b450966
Rewiring victory conditions
ajhalme b0893ed
Reorg; refactor to more of an OOP style so victory conditions can evo…
ajhalme 0bdd2e2
Add TimeLimitVictory
ajhalme f08d43c
Add ConquestVictory
ajhalme 32a8c0d
Add CulturalVictory
ajhalme cb9551a
Add Diplomatic win and Space Race
ajhalme d730f2a
Add Score "Victory"
ajhalme c314a13
Headers redrawn
ajhalme b6c5e87
Cleanup, title row
ajhalme 90dc506
Update Assets
ajhalme efd1b71
Culture Victory cleanup
ajhalme cd75f42
Add history
ajhalme 8860d25
Update history
ajhalme 6d925d7
Push victory condition registration into SaveGame
ajhalme bb538b2
Victory game data tests (thx Claude)
ajhalme 6e74854
TODOs, cleanup
ajhalme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| using Godot; | ||
| using System; | ||
|
|
||
| // The standard civ3 checkbox with text attached. | ||
| [GlobalClass] | ||
| [Tool] | ||
| public partial class Civ3Checkbox : CheckBox { | ||
| public enum TextPosition { | ||
| TextLeftOfIcon, | ||
| TextRightOfIcon, | ||
| TextAboveIcon, | ||
| TextBelowIcon | ||
| } | ||
|
|
||
| private Texture2D normalTexture = TextureLoader.Load("ui.checkbox.inactive"); | ||
| private Texture2D hoverTexture = TextureLoader.Load("ui.checkbox.hover"); | ||
| private Texture2D pressedTexture = TextureLoader.Load("ui.checkbox.pressed"); | ||
|
|
||
| private string _text; | ||
| [Export] | ||
| public string Text { | ||
| get => _text; | ||
| set { | ||
| _text = value; | ||
| if (label != null) { | ||
| label.Text = _text; | ||
| } | ||
| } | ||
| } | ||
| private int _fontSize; | ||
| [Export] | ||
| public int FontSize { | ||
| get => _fontSize; | ||
| set { | ||
| _fontSize = value; | ||
| if (label != null) { | ||
| label.AddThemeFontSizeOverride("font_size", _fontSize); | ||
| } | ||
| } | ||
| } | ||
| private TextPosition _textPosition; | ||
| [Export] | ||
| public TextPosition textPosition { | ||
| get => _textPosition; | ||
| set { | ||
| _textPosition = value; | ||
| if (label != null && textureRect != null) { | ||
| SetUpLayout(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private Color fontColor; | ||
| private Color hoverColor; | ||
| private Color pressedColor; | ||
|
|
||
| private Label label; | ||
| private TextureRect textureRect; | ||
| private BoxContainer boxContainer; | ||
|
|
||
| private bool hovered = false; | ||
|
|
||
| public Civ3Checkbox(TextPosition textPosition = TextPosition.TextRightOfIcon) { | ||
| this.textPosition = textPosition; | ||
|
|
||
| Flat = true; | ||
| FontSize = 12; | ||
| SizeFlagsHorizontal = SizeFlags.Expand; | ||
| SizeFlagsVertical = SizeFlags.ShrinkCenter; | ||
| } | ||
|
|
||
| public override void _Ready() { | ||
| fontColor = GetThemeColor("font_color", "Button"); | ||
| hoverColor = GetThemeColor("font_hover_color", "Button"); | ||
| pressedColor = GetThemeColor("font_pressed_color", "Button"); | ||
|
|
||
| // Set up the label and texture. | ||
| label = new() { | ||
| Text = Text, | ||
| MouseFilter = MouseFilterEnum.Pass, | ||
| VerticalAlignment = VerticalAlignment.Center, | ||
| HorizontalAlignment = HorizontalAlignment.Center, | ||
| SizeFlagsHorizontal = SizeFlags.ShrinkCenter, | ||
| SizeFlagsVertical = SizeFlags.ShrinkCenter, | ||
| }; | ||
| label.AddThemeFontSizeOverride("font_size", FontSize); | ||
|
|
||
| textureRect = new() { | ||
| Texture = normalTexture, | ||
| MouseFilter = MouseFilterEnum.Pass, | ||
| CustomMinimumSize = new Vector2(normalTexture.GetWidth(), normalTexture.GetHeight()), | ||
| ExpandMode = TextureRect.ExpandModeEnum.KeepSize, | ||
| SizeFlagsHorizontal = SizeFlags.ShrinkCenter, | ||
| SizeFlagsVertical = SizeFlags.ShrinkCenter, | ||
| }; | ||
|
|
||
| SetUpLayout(); | ||
|
|
||
| // Hook up our code to the button signals. | ||
| MouseEntered += () => { | ||
| hovered = true; | ||
| UpdateVisuals(); | ||
| }; | ||
| MouseExited += () => { | ||
| hovered = false; | ||
| UpdateVisuals(); | ||
| }; | ||
| Pressed += UpdateVisuals; | ||
| Toggled += (bool toggledOn) => { UpdateVisuals(); }; | ||
|
|
||
| UpdateVisuals(); | ||
| } | ||
|
|
||
| private void SetUpLayout() { | ||
| if (boxContainer != null) { | ||
| boxContainer.RemoveChild(label); | ||
| boxContainer.RemoveChild(textureRect); | ||
| RemoveChild(boxContainer); | ||
| boxContainer.QueueFree(); | ||
| } | ||
|
|
||
| // Depending on the text positioning, add the label and texture as children | ||
| // of the appropriate layout. | ||
| if (textPosition == TextPosition.TextAboveIcon || textPosition == TextPosition.TextBelowIcon) { | ||
| boxContainer = new VBoxContainer(); | ||
| } else { | ||
| boxContainer = new HBoxContainer() { | ||
| Alignment = (textPosition == TextPosition.TextLeftOfIcon) ? BoxContainer.AlignmentMode.End : BoxContainer.AlignmentMode.Begin, | ||
| }; | ||
| } | ||
| boxContainer.SetAnchorsPreset(LayoutPreset.FullRect); | ||
| boxContainer.MouseFilter = MouseFilterEnum.Pass; | ||
| AddChild(boxContainer); | ||
|
|
||
| if (textPosition == TextPosition.TextAboveIcon || textPosition == TextPosition.TextLeftOfIcon) { | ||
| boxContainer.AddChild(label); | ||
| boxContainer.AddChild(textureRect); | ||
| } else { | ||
| boxContainer.AddChild(textureRect); | ||
| boxContainer.AddChild(label); | ||
| } | ||
| } | ||
|
|
||
| // Expand the size of the button to contain the texture and the label. | ||
| public override Vector2 _GetMinimumSize() { | ||
| if (boxContainer == null) { | ||
| return base._GetMinimumSize(); | ||
| } | ||
| return boxContainer.GetCombinedMinimumSize(); | ||
| } | ||
|
|
||
| public void UpdateVisuals() { | ||
| Texture2D currentTexture = normalTexture; | ||
| Color currentTextColor = fontColor; | ||
|
|
||
| // ButtonPressed is true if ToggleMode is on and button is selected | ||
| bool isEffectivelyPressed = (ToggleMode && ButtonPressed); | ||
|
|
||
| if (isEffectivelyPressed) { | ||
| currentTexture = pressedTexture; | ||
| currentTextColor = pressedColor; | ||
| } else if (hovered) { | ||
| currentTexture = hoverTexture; | ||
| currentTextColor = hoverColor; | ||
| } | ||
|
|
||
| textureRect.Texture = currentTexture; | ||
| label.AddThemeColorOverride("font_color", currentTextColor); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://b4grm7mhaqgri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.