mirror of
https://git.tonybark.com/tonytins/CyberBits.git
synced 2026-02-10 09:34:48 -05:00
Refactored Program.cs
- Introduce ResourceFiles.cs with constants for JSON resource paths. - Updated Program.cs to use those constants. - Refactored scene handling to store current scene in a variables. - Added file existence checks and switch quit handling to sys.Environment.Exit. - Updated .editorconfig.
This commit is contained in:
parent
533e1bb076
commit
55044ae4b8
15 changed files with 172 additions and 64 deletions
|
|
@ -13,9 +13,6 @@ indent_style = space
|
|||
|
||||
# C# files
|
||||
[*.cs]
|
||||
# Nullable reference types
|
||||
csharp_nullable_reference_types = enable
|
||||
|
||||
# Naming conventions
|
||||
dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
|
||||
dotnet_naming_rule.async_methods_end_in_async.symbols = async_methods
|
||||
|
|
@ -27,6 +24,16 @@ dotnet_naming_symbols.async_methods.required_modifiers = async
|
|||
dotnet_naming_style.end_in_async.required_suffix = Async
|
||||
dotnet_naming_style.end_in_async.capitalization = pascal_case
|
||||
|
||||
# Constants are UPPERCASE
|
||||
dotnet_naming_rule.constants_should_be_upper_case.severity = suggestion
|
||||
dotnet_naming_rule.constants_should_be_upper_case.symbols = constants
|
||||
dotnet_naming_rule.constants_should_be_upper_case.style = constant_style
|
||||
|
||||
dotnet_naming_symbols.constants.applicable_kinds = field, local
|
||||
dotnet_naming_symbols.constants.required_modifiers = const
|
||||
|
||||
dotnet_naming_style.constant_style.capitalization = all_upper
|
||||
|
||||
# Formatting
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_indent_case_contents = true
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
<Solution>
|
||||
<Folder Name="/Solution Items/">
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="global.json" />
|
||||
<File Path="README.md" />
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="global.json" />
|
||||
<File Path=".editorconfig" />
|
||||
<File Path="README.md" />
|
||||
</Folder>
|
||||
<Project Path="Cyberbits/Cyberbits.csproj" />
|
||||
</Solution>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,31 @@
|
|||
namespace Cyberbits;
|
||||
|
||||
public class FileFetcher
|
||||
public static class FileFetcher
|
||||
{
|
||||
public static string LoadTextFile(string filename)
|
||||
public static string LoadTextFile(string filename, bool userDir = false)
|
||||
{
|
||||
using var file = FileAccess.Open($"res://{filename}", FileAccess.ModeFlags.Read);
|
||||
return file.GetAsText();
|
||||
var location = "res";
|
||||
|
||||
if (userDir)
|
||||
location = "user";
|
||||
|
||||
using var file = FileAccess.Open($"{location}://{filename}", FileAccess.ModeFlags.Read);
|
||||
var contents = file.GetAsText();
|
||||
|
||||
file.Close();
|
||||
return contents;
|
||||
}
|
||||
|
||||
public static ConfigFile LoadConfig(string filename, bool userDir = false)
|
||||
{
|
||||
var config = new ConfigFile();
|
||||
|
||||
// Load data from a file.
|
||||
var err = config.Load(LoadTextFile(filename, userDir));
|
||||
|
||||
if (err != Error.Ok)
|
||||
sys.Environment.Exit(sys.Environment.ExitCode);
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
// System
|
||||
global using System;
|
||||
global using sys = System;
|
||||
global using System.Text.Json;
|
||||
global using System.Text.Json.Serialization;
|
||||
|
||||
// Godot
|
||||
global using Godot;
|
||||
global using Godot.Collections;
|
||||
global using Engine = twodog.Engine;
|
||||
|
|
|
|||
|
|
@ -6,38 +6,40 @@ using var godot = engine.Start();
|
|||
// Load a scene
|
||||
var scene = GD.Load<PackedScene>("res://main.tscn");
|
||||
engine.Tree.Root.AddChild(scene.Instantiate());
|
||||
var load = engine.Tree.CurrentScene;
|
||||
|
||||
var bitsImage = engine.Tree.CurrentScene.GetNode<TextureRect>("BitsImage");
|
||||
var bitsSelection = engine.Tree.CurrentScene.GetNode<OptionButton>("BitsSelection");
|
||||
var unlockedFeat = engine.Tree.CurrentScene.GetNode<Label>("UnlockedFeat");
|
||||
var genitalStyles = engine.Tree.CurrentScene.GetNode<ItemList>("GenitalList");
|
||||
var bitsImage = load.GetNode<TextureRect>("BitsImage");
|
||||
// var bitsSelection = curScene.GetNode<OptionButton>("BitsSelection");
|
||||
var unlockedFeatLbl = load.GetNode<Label>("UnlockedFeatLbl");
|
||||
var cyberwareList = load.GetNode<ItemList>("CyberwareList");
|
||||
var genitalList = load.GetNode<ItemList>("GenitalList");
|
||||
|
||||
// TODO: Figure out how to get this work.
|
||||
var baseContents = FileFetcher.LoadTextFile("data/cock.json");
|
||||
var addonContents = FileFetcher.LoadTextFile("data/addon.json");
|
||||
var baseContents = FileFetcher.LoadTextFile(ResourceFiles.COCK_JSON);
|
||||
var addonContents = FileFetcher.LoadTextFile(ResourceFiles.ADDONS_JSON);
|
||||
|
||||
bitsSelection.ItemSelected += index =>
|
||||
{
|
||||
baseContents = index switch
|
||||
{
|
||||
1 => baseContents = FileFetcher.LoadTextFile("data/pussy.json"),
|
||||
_ => baseContents = FileFetcher.LoadTextFile("data/cock.json")
|
||||
};
|
||||
};
|
||||
var screenSize = DisplayServer.ScreenGetSize();
|
||||
var window = load.GetWindow();
|
||||
window.Size = new Vector2I(screenSize.X - 66, screenSize.Y - 1);
|
||||
|
||||
if (!FileAccess.FileExists(baseContents)
|
||||
|| !FileAccess.FileExists(addonContents))
|
||||
sys.Environment.Exit(sys.Environment.ExitCode);
|
||||
|
||||
var bits = JsonSerializer.Deserialize<Bits>(baseContents);
|
||||
var addon = JsonSerializer.Deserialize<Addon>(addonContents);
|
||||
|
||||
bitsImage.Texture.ResourcePath = bits.Image;
|
||||
unlockedFeat.Text = $"Feat: {bits?.Feat}";
|
||||
unlockedFeatLbl.Text = $"Feat: {bits?.Feat}";
|
||||
|
||||
foreach (var selection in bits.Base)
|
||||
genitalStyles.AddItem(selection);
|
||||
genitalList.AddItem(selection);
|
||||
|
||||
foreach (var cyberware in addon.Cyberware)
|
||||
cyberwareList.AddItem(cyberware);
|
||||
|
||||
// Run the main loop
|
||||
while (!godot.Iteration())
|
||||
{
|
||||
if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Q)
|
||||
break;
|
||||
|
||||
sys.Environment.Exit(sys.Environment.ExitCode);
|
||||
}
|
||||
|
|
|
|||
8
CyberBits/ResourceFiles.cs
Normal file
8
CyberBits/ResourceFiles.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace Cyberbits;
|
||||
|
||||
public struct ResourceFiles
|
||||
{
|
||||
public const string COCK_JSON = "resources/cock.json";
|
||||
public const string PUSSY_JSON = "resources/pussy.json";
|
||||
public const string ADDONS_JSON = "resources/addons.json";
|
||||
}
|
||||
1
CyberBits/project/config.cfg
Normal file
1
CyberBits/project/config.cfg
Normal file
|
|
@ -0,0 +1 @@
|
|||
hidpi = true
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"cyberware": ["Piercings", "Datajack"]
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"image": "res://sprites/cock.jpg",
|
||||
"feat": "Aim Piss",
|
||||
"base": ["Au Natural", "Les Americaines"],
|
||||
"style": ["Bioware", "Cyberware"],
|
||||
"cyberware": ["Piercings", "Datajack"]
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"image": "res://sprites/pussy.jpg",
|
||||
"feat": "Boom of the Mother Goddness",
|
||||
"base": ["Au Natural", "Les Americaines"],
|
||||
"style": ["Bioware", "Cyberware"]
|
||||
}
|
||||
|
|
@ -14,10 +14,10 @@ metadata/_edit_lock_ = true
|
|||
[node name="BitsImage" type="TextureRect" parent="." unique_id=420796857]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.01328125
|
||||
anchor_top = 0.023611112
|
||||
anchor_right = 0.2625
|
||||
anchor_bottom = 0.49722221
|
||||
anchor_left = 0.02578125
|
||||
anchor_top = 0.2125
|
||||
anchor_right = 0.2921875
|
||||
anchor_bottom = 0.6861111
|
||||
texture = ExtResource("1_ig7tw")
|
||||
expand_mode = 3
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
|
@ -25,35 +25,79 @@ metadata/_edit_use_anchors_ = true
|
|||
[node name="GenitalList" type="ItemList" parent="." unique_id=1657021535]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.30078125
|
||||
anchor_top = 0.083333336
|
||||
anchor_right = 0.60859376
|
||||
anchor_bottom = 0.44722223
|
||||
select_mode = 2
|
||||
anchor_left = 0.3140625
|
||||
anchor_top = 0.29722223
|
||||
anchor_right = 0.5804688
|
||||
anchor_bottom = 0.6611111
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="UnlockedFeat" type="Label" parent="." unique_id=1358090682]
|
||||
[node name="CyberwareList" type="ItemList" parent="." unique_id=1780192556]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.421875
|
||||
anchor_top = 0.027777778
|
||||
anchor_right = 0.6039063
|
||||
anchor_bottom = 0.059722222
|
||||
anchor_left = 0.5921875
|
||||
anchor_top = 0.2986111
|
||||
anchor_right = 0.78984374
|
||||
anchor_bottom = 0.6194445
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="UnlockedFeatLbl" type="Label" parent="." unique_id=1358090682]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.40546876
|
||||
anchor_top = 0.23888889
|
||||
anchor_right = 0.5726563
|
||||
anchor_bottom = 0.27083334
|
||||
text = "Feat:"
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="BitsSelection" type="OptionButton" parent="." unique_id=1632883177]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.30078125
|
||||
anchor_top = 0.019444445
|
||||
anchor_right = 0.3609375
|
||||
anchor_bottom = 0.07083334
|
||||
anchor_left = 0.315625
|
||||
anchor_top = 0.23055555
|
||||
anchor_right = 0.37578124
|
||||
anchor_bottom = 0.28194445
|
||||
selected = 0
|
||||
fit_to_longest_item = false
|
||||
allow_reselect = true
|
||||
item_count = 2
|
||||
popup/item_0/text = "Dick"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "Pussy"
|
||||
popup/item_1/id = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="CyberwareLbl" type="Label" parent="." unique_id=1646946419]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.5921875
|
||||
anchor_top = 0.25277779
|
||||
anchor_right = 0.7867187
|
||||
anchor_bottom = 0.29166666
|
||||
text = "Cyberware"
|
||||
horizontal_alignment = 1
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="BioEssenceLbl" type="Label" parent="." unique_id=1183351215]
|
||||
layout_mode = 0
|
||||
offset_left = 759.0
|
||||
offset_top = 458.0
|
||||
offset_right = 877.0
|
||||
offset_bottom = 481.0
|
||||
text = "Bio-Essence: 10"
|
||||
|
||||
[node name="MegaDebtLbl" type="Label" parent="." unique_id=1875640511]
|
||||
layout_mode = 0
|
||||
offset_left = 896.0
|
||||
offset_top = 458.0
|
||||
offset_right = 1014.0
|
||||
offset_bottom = 481.0
|
||||
text = "Mega Debt: 10"
|
||||
|
||||
[node name="ActionRatingLbl" type="Label" parent="." unique_id=865651652]
|
||||
layout_mode = 0
|
||||
offset_left = 762.0
|
||||
offset_top = 489.0
|
||||
offset_right = 880.0
|
||||
offset_bottom = 512.0
|
||||
text = "Action Rating: 0"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ config/features=PackedStringArray("4.6")
|
|||
|
||||
window/size/viewport_width=1280
|
||||
window/size/viewport_height=720
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[dotnet]
|
||||
|
||||
|
|
|
|||
6
CyberBits/project/resources/addons.json
Normal file
6
CyberBits/project/resources/addons.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"cyberware": [
|
||||
"Piercings",
|
||||
"Datajack"
|
||||
]
|
||||
}
|
||||
16
CyberBits/project/resources/cock.json
Normal file
16
CyberBits/project/resources/cock.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"image": "res://sprites/cock.jpg",
|
||||
"feat": "Aim Piss",
|
||||
"base": [
|
||||
"Au Natural",
|
||||
"Les Americaines"
|
||||
],
|
||||
"style": [
|
||||
"Bioware",
|
||||
"Cyberware"
|
||||
],
|
||||
"cyberware": [
|
||||
"Piercings",
|
||||
"Datajack"
|
||||
]
|
||||
}
|
||||
12
CyberBits/project/resources/pussy.json
Normal file
12
CyberBits/project/resources/pussy.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"image": "res://sprites/pussy.jpg",
|
||||
"feat": "Boom of the Mother Goddness",
|
||||
"base": [
|
||||
"Au Natural",
|
||||
"Les Americaines"
|
||||
],
|
||||
"style": [
|
||||
"Bioware",
|
||||
"Cyberware"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue