diff --git a/Example/Tween/Texture/Gobot_Model.tscn b/Example/Tween/Texture/Gobot_Model.tscn new file mode 100644 index 0000000..1208446 --- /dev/null +++ b/Example/Tween/Texture/Gobot_Model.tscn @@ -0,0 +1,133 @@ +[gd_scene load_steps=2 format=3 uid="uid://bonekg2q1lxx4"] + +[ext_resource type="Texture2D" uid="uid://cbq4j4svebp45" path="res://Example/Tween/Texture/gBot_pieces.png" id="1_vmu55"] + +[node name="Node2D" type="Node2D"] + +[node name="Gobot" type="Node2D" parent="."] +position = Vector2(157, 138) + +[node name="arm_left" type="Polygon2D" parent="Gobot"] +position = Vector2(77, 210) +texture = ExtResource("1_vmu55") +skeleton = NodePath("../../Skeleton2D") +polygon = PackedVector2Array(188, 36, 225, 22, 276, 47, 266, 129, 248, 188, 275, 275, 298, 302, 275, 348, 220, 360, 194, 313, 176, 246, 187, 199, 184, 102, 176, 48, 224, 96, 216, 192, 240, 304, 216, 208) +uv = PackedVector2Array(188, 36, 225, 22, 276, 47, 266, 129, 248, 188, 275, 275, 298, 302, 275, 348, 220, 360, 194, 313, 176, 246, 187, 199, 184, 102, 174, 44, 216, 96, 216, 192, 240, 304, 216, 200) +polygons = [PackedInt32Array(14, 1, 0, 13, 12), PackedInt32Array(1, 2, 3, 14), PackedInt32Array(14, 15, 4, 3), PackedInt32Array(14, 12, 11, 15), PackedInt32Array(5, 6, 7, 16), PackedInt32Array(16, 9, 8, 7), PackedInt32Array(11, 17, 15), PackedInt32Array(15, 17, 4), PackedInt32Array(17, 16, 9, 10, 11), PackedInt32Array(4, 17, 16, 5)] +bones = ["hip", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head/jaw", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right/hand_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left", PackedFloat32Array(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0), "hip/chest/arm_left/hand_left", PackedFloat32Array(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1), "hip/leg_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left/calf_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left/calf_left/foot_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2/leg_right3", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] +internal_vertex_count = 4 + +[node name="leg_left" type="Polygon2D" parent="Gobot"] +position = Vector2(-46, 56) +texture = ExtResource("1_vmu55") +skeleton = NodePath("../../Skeleton2D") +polygon = PackedVector2Array(285.231, 396.984, 311.252, 384.229, 343.905, 401.066, 341.354, 431.678, 333.701, 442.392, 327.578, 478.617, 337.782, 475.556, 340.843, 504.637, 326.047, 538.821, 327.578, 569.433, 349.517, 602.086, 382.17, 608.719, 391.354, 649.535, 403.088, 657.698, 406.66, 688.821, 397.476, 693.413, 250.027, 690.352, 247.476, 660.25, 252.068, 657.188, 247.986, 629.127, 254.619, 613.821, 254.619, 509.229, 281.66, 471.474, 290.992, 521.359, 297.01, 631.544, 294.695, 615.34, 297.473, 498.674) +uv = PackedVector2Array(285.231, 396.984, 311.252, 384.229, 343.905, 401.066, 341.354, 431.678, 333.701, 442.392, 327.578, 478.617, 337.782, 475.556, 340.843, 504.637, 326.047, 538.821, 327.578, 569.433, 349.517, 602.086, 382.17, 608.719, 391.354, 649.535, 403.088, 657.698, 406.66, 688.821, 397.476, 693.413, 250.027, 690.352, 247.476, 660.25, 252.068, 657.188, 247.986, 629.127, 254.619, 613.821, 254.619, 509.229, 281.66, 471.474, 290.992, 521.359, 297.01, 631.544, 294.695, 615.34, 297.473, 498.674) +polygons = [PackedInt32Array(23, 21, 20, 25, 9, 8), PackedInt32Array(25, 24, 10, 9), PackedInt32Array(20, 25, 24, 19), PackedInt32Array(26, 23, 8, 7), PackedInt32Array(22, 26, 23, 21), PackedInt32Array(7, 6, 5, 4, 3, 2, 1, 0, 22, 26), PackedInt32Array(19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 24)] +bones = ["hip", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/head/jaw", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_right/hand_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/chest/arm_left/hand_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_left", PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1), "hip/leg_left/calf_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1), "hip/leg_left/calf_left/foot_left", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "hip/leg_right/leg_right2/leg_right3", PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)] +internal_vertex_count = 4 + +[node name="Body" type="Polygon2D" parent="Gobot"] +position = Vector2(-213, 183) +texture = ExtResource("1_vmu55") +polygon = PackedVector2Array(454, 19, 483, 39, 487, 82, 521, 157, 524, 194, 509.272, 215.601, 494, 238, 475, 250, 476, 260, 493, 276, 488, 312, 462, 339, 422, 348, 367, 331, 346, 297, 349, 262, 375, 251, 372, 236, 350, 205, 340, 135, 357, 85, 384, 78, 393, 37, 427, 18) +uv = PackedVector2Array(454, 19, 483, 39, 487, 82, 521, 157, 524, 194, 494, 238, 475, 250, 476, 260, 493, 276, 488, 312, 462, 339, 422, 348, 367, 331, 346, 297, 349, 262, 375, 251, 372, 236, 350, 205, 340, 135, 357, 85, 384, 78, 393, 37, 427, 18) + +[node name="leg_right" type="Polygon2D" parent="Gobot"] +position = Vector2(59, 63) +texture = ExtResource("1_vmu55") +polygon = PackedVector2Array(89.832, 385.034, 117.043, 400.68, 119.084, 426.531, 108.88, 441.497, 108.88, 463.265, 103.437, 476.871, 115.002, 472.789, 119.084, 508.843, 104.798, 537.415, 105.478, 559.864, 125.886, 593.197, 155.818, 602.041, 166.022, 617.007, 168.063, 643.537, 182.349, 653.061, 183.029, 676.19, 174.186, 685.714, 29.2878, 683.673, 19.7639, 674.83, 25.8864, 653.061, 30.6483, 604.762, 32.6891, 510.884, 61.2605, 470.068, 63.3014, 399.32) +uv = PackedVector2Array(89.832, 385.034, 117.043, 400.68, 119.084, 426.531, 108.88, 441.497, 108.88, 463.265, 103.437, 476.871, 115.002, 472.789, 119.084, 508.843, 104.798, 537.415, 105.478, 559.864, 125.886, 593.197, 155.818, 602.041, 166.022, 617.007, 168.063, 643.537, 182.349, 653.061, 183.029, 676.19, 174.186, 685.714, 29.2878, 683.673, 19.7639, 674.83, 25.8864, 653.061, 30.6483, 604.762, 32.6891, 510.884, 61.2605, 470.068, 63.3014, 399.32) + +[node name="arm_right" type="Polygon2D" parent="Gobot"] +position = Vector2(53, 227) +texture = ExtResource("1_vmu55") +polygon = PackedVector2Array(80, 13, 141, 46, 98, 181, 139, 320, 122, 354, 62, 365, 26, 311, 14, 229, 32, 192, 21, 120, 34, 25) +uv = PackedVector2Array(80, 13, 141, 46, 98, 181, 139, 320, 122, 354, 62, 365, 26, 311, 14, 229, 32, 192, 21, 120, 34, 25) + +[node name="head" type="Polygon2D" parent="Gobot"] +position = Vector2(-427, -344) +texture = ExtResource("1_vmu55") +polygon = PackedVector2Array(481.482, 378.14, 484.033, 449.058, 495.767, 494.466, 537.094, 496.507, 544.747, 525.079, 667.196, 533.242, 677.91, 506.711, 713.624, 511.303, 721.278, 521.507, 765.155, 517.426, 772.808, 505.181, 800.869, 503.65, 807.502, 489.364, 809.033, 380.691, 801.89, 361.303, 813.624, 340.895, 784.033, 294.466, 761.073, 297.017, 763.114, 272.528, 711.073, 252.119, 663.624, 255.691, 659.543, 269.977, 643.216, 249.568, 620.767, 247.017, 554.441, 282.221, 565.155, 316.405, 546.788, 327.119, 510.053, 328.14) +uv = PackedVector2Array(481.482, 378.14, 484.033, 449.058, 495.767, 494.466, 537.094, 496.507, 544.747, 525.079, 667.196, 533.242, 677.91, 506.711, 713.624, 511.303, 721.278, 521.507, 765.155, 517.426, 772.808, 505.181, 800.869, 503.65, 807.502, 489.364, 809.033, 380.691, 801.89, 361.303, 813.624, 340.895, 784.033, 294.466, 761.073, 297.017, 763.114, 272.528, 711.073, 252.119, 663.624, 255.691, 659.543, 269.977, 643.216, 249.568, 620.767, 247.017, 554.441, 282.221, 565.155, 316.405, 546.788, 327.119, 510.053, 328.14) + +[node name="jaw" type="Polygon2D" parent="Gobot"] +position = Vector2(-423, -438) +texture = ExtResource("1_vmu55") +polygon = PackedVector2Array(488.089, 572.317, 541.793, 575.404, 544.879, 600.712, 548.583, 574.169, 616.484, 574.169, 620.805, 585.898, 635.003, 585.898, 644.879, 571.083, 716.484, 572.317, 723.891, 582.194, 738.706, 582.811, 744.262, 571.083, 819.57, 561.823, 815.867, 613.058, 788.089, 657.503, 754.756, 674.169, 654.138, 688.984, 547.965, 680.959, 498.583, 643.922, 481.916, 605.651) +uv = PackedVector2Array(488.089, 572.317, 541.793, 575.404, 544.879, 600.712, 548.583, 574.169, 616.484, 574.169, 620.805, 585.898, 635.003, 585.898, 644.879, 571.083, 716.484, 572.317, 723.891, 582.194, 738.706, 582.811, 744.262, 571.083, 819.57, 561.823, 815.867, 613.058, 788.089, 657.503, 754.756, 674.169, 654.138, 688.984, 547.965, 680.959, 498.583, 643.922, 481.916, 605.651) + +[node name="Skeleton2D" type="Skeleton2D" parent="."] +position = Vector2(157, 138) + +[node name="hip" type="Bone2D" parent="Skeleton2D"] +position = Vector2(218, 493) +rest = Transform2D(1, 0, 0, 1, 218, 493) + +[node name="chest" type="Bone2D" parent="Skeleton2D/hip"] +position = Vector2(1, -45) +rest = Transform2D(1, 0, 0, 1, 1, -45) + +[node name="head" type="Bone2D" parent="Skeleton2D/hip/chest"] +position = Vector2(5, -185) +rest = Transform2D(1, 0, 0, 1, 5, -185) + +[node name="jaw" type="Bone2D" parent="Skeleton2D/hip/chest/head"] +position = Vector2(-95, -64) +rest = Transform2D(1, 0, 0, 1, -95, -64) +auto_calculate_length_and_angle = false +length = 150.0 +bone_angle = 0.0 + +[node name="arm_right" type="Bone2D" parent="Skeleton2D/hip/chest"] +position = Vector2(-95, -132) +rest = Transform2D(1, 0, 0, 1, -95, -132) + +[node name="hand_right" type="Bone2D" parent="Skeleton2D/hip/chest/arm_right"] +position = Vector2(-5, 101) +rotation = 1.39626 +rest = Transform2D(0.173648, 0.984808, -0.984808, 0.173648, -5, 101) +auto_calculate_length_and_angle = false +length = 120.0 +bone_angle = 0.0 + +[node name="arm_left" type="Bone2D" parent="Skeleton2D/hip/chest"] +position = Vector2(78, -142) +rest = Transform2D(1, 0, 0, 1, 78, -142) + +[node name="hand_left" type="Bone2D" parent="Skeleton2D/hip/chest/arm_left"] +position = Vector2(1, 99) +rest = Transform2D(1, 0, 0, 1, 1, 99) +auto_calculate_length_and_angle = false +length = 120.0 +bone_angle = 70.0 + +[node name="leg_left" type="Bone2D" parent="Skeleton2D/hip"] +position = Vector2(55, -21) +rest = Transform2D(1, 0, 0, 1, 55, -21) + +[node name="calf_left" type="Bone2D" parent="Skeleton2D/hip/leg_left"] +position = Vector2(-29, 98) +rest = Transform2D(1, 0, 0, 1, -29, 98) + +[node name="foot_left" type="Bone2D" parent="Skeleton2D/hip/leg_left/calf_left"] +position = Vector2(20, 135) +rest = Transform2D(1, 0, 0, 1, 20, 135) +auto_calculate_length_and_angle = false +length = 60.0 +bone_angle = 0.0 + +[node name="leg_right" type="Bone2D" parent="Skeleton2D/hip"] +position = Vector2(-69, -16) +rest = Transform2D(1, 0, 0, 1, -69, -16) + +[node name="leg_right2" type="Bone2D" parent="Skeleton2D/hip/leg_right"] +position = Vector2(-20, 98) +rest = Transform2D(1, 0, 0, 1, -20, 98) + +[node name="leg_right3" type="Bone2D" parent="Skeleton2D/hip/leg_right/leg_right2"] +position = Vector2(13, 133) +rest = Transform2D(1, 0, 0, 1, 13, 133) +auto_calculate_length_and_angle = false +length = 60.0 +bone_angle = 0.0 diff --git a/Example/Tween/Texture/gBot_pieces.png b/Example/Tween/Texture/gBot_pieces.png new file mode 100644 index 0000000..183c898 Binary files /dev/null and b/Example/Tween/Texture/gBot_pieces.png differ diff --git a/Example/Tween/Texture/gBot_pieces.png.import b/Example/Tween/Texture/gBot_pieces.png.import new file mode 100644 index 0000000..8450cf6 --- /dev/null +++ b/Example/Tween/Texture/gBot_pieces.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cbq4j4svebp45" +path="res://.godot/imported/gBot_pieces.png-1c5266364ba54cfdb5b194e098160c14.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Example/Tween/Texture/gBot_pieces.png" +dest_files=["res://.godot/imported/gBot_pieces.png-1c5266364ba54cfdb5b194e098160c14.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Example/UsingTest/Scene/TestEGFramework.tscn b/Example/UsingTest/Scene/TestEGFramework.tscn index 3b076e8..4e31c68 100644 --- a/Example/UsingTest/Scene/TestEGFramework.tscn +++ b/Example/UsingTest/Scene/TestEGFramework.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://Example/UsingTest/Script/EGSaveTest.cs" id="1_eij2h"] -[node name="TestEgFramework" type="Control"] +[node name="Test" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -20,6 +20,7 @@ offset_right = 361.0 offset_bottom = 164.0 [node name="Button1" type="Button" parent="."] +visible = false layout_mode = 0 offset_right = 50.0 offset_bottom = 50.0 diff --git a/Example/UsingTest/Script/EGSaveTest.cs b/Example/UsingTest/Script/EGSaveTest.cs index 25f85e3..a54964b 100644 --- a/Example/UsingTest/Script/EGSaveTest.cs +++ b/Example/UsingTest/Script/EGSaveTest.cs @@ -1,7 +1,5 @@ using Godot; using LiteDB; -using System; -using System.IO; namespace EGFramework.Examples.Test{ public partial class EGSaveTest : Node,IEGFramework @@ -9,6 +7,21 @@ namespace EGFramework.Examples.Test{ public override void _Ready() { base._Ready(); + TestCode(); + } + + public void TestSqlite(){ + // string result = this.EGSqlite().CreateTable(); + this.EGSqlite().SaveData(new SqliteBackpackItem{ + ItemID = 10, + ItemCount = 1, + BackpackID = 1, + }); + GD.Print(this.EGSqlite().ExceptionMsg); + // var properties = typeof(SqliteBackpackItem).GetFields(); + // Godot.GD.Print(properties.Count() + " Readed "); + } + public void TestCode(){ // this.EGSave().OpenUserPath(); // GD.Print(ProjectSettings.GlobalizePath("res://SaveData/Default.json")); // GD.Print(ProjectSettings.GlobalizePath("user://SaveData/Default.json")); @@ -16,13 +29,23 @@ namespace EGFramework.Examples.Test{ // TestLiteDB(); // string CardPath1 = "SaveData/CardData1.json".GetGodotResPath(); // this.EGSave().LoadObjectFile(CardPath1); + // // this.EGSave().SetObject(CardPath1,"Customer1",new Customer() { Name = "Andy" }); // // this.EGSave().SetObject(CardPath1,"Customer3",new Customer() { Name = "Terry" }); + + string CardPath1 = "Card1"; + // FileAccess fileAccess = FileAccess.Open("res://SaveData/TestCsv.csv", FileAccess.ModeFlags.Read); + // GD.Print(fileAccess.GetAsText()); + // FileAccess testFile = FileAccess.Open("res://SaveData/CardData1.json", FileAccess.ModeFlags.Read); + // this.EGSave().ReadObject(CardPath1,testFile.GetAsText()); // Customer customer = this.EGSave().GetObject(CardPath1,"Customer3"); // GD.Print("ReadName is "+customer.Name); - EGCsvSave csvSave = new EGCsvSave(); - csvSave.InitSaveFile("SaveData/TestCsv.csv"); + // FileAccess testCSV = FileAccess.Open("res://SaveData/TestCSV.json", FileAccess.ModeFlags.Read); + + + // EGCsvSave csvSave = new EGCsvSave(); + // csvSave.InitSaveFile("SaveData/TestCsv.csv"); // Customer testData = csvSave.GetData("",1); // GD.Print("Name = "+testData.Name +" || ID = "+testData.Id); // Customer testData = new Customer(){ @@ -31,12 +54,13 @@ namespace EGFramework.Examples.Test{ // IsActive = true // }; // csvSave.SetData("",testData,2) - - // IEnumerable allResult = csvSave.GetAll(""); - // GD.Print("Get result " + allResult.Count()); - // foreach(Customer customer in allResult){ - // GD.Print(customer.Id +"|" + customer.Name); - // } + FileAccess testCsv = FileAccess.Open("res://SaveData/TestCsv.csv", FileAccess.ModeFlags.Read); + this.EGSave().ReadData(CardPath1,testCsv.GetAsText()); + IEnumerable allResult = this.EGSave().GetAllData(CardPath1,""); + GD.Print("Get result " + allResult.Count()); + foreach(Customer customer in allResult){ + GD.Print(customer.Id +"|" + customer.Name); + } // System.Linq.Expressions.Expression> expr = i => i.Name == "Creature"; // IEnumerable linqResult = csvSave.FindData("",expr); @@ -58,19 +82,6 @@ namespace EGFramework.Examples.Test{ // GD.Print(property.Name); // } } - - public void TestSqlite(){ - // string result = this.EGSqlite().CreateTable(); - this.EGSqlite().SaveData(new SqliteBackpackItem{ - ItemID = 10, - ItemCount = 1, - BackpackID = 1, - }); - GD.Print(this.EGSqlite().ExceptionMsg); - // var properties = typeof(SqliteBackpackItem).GetFields(); - // Godot.GD.Print(properties.Count() + " Readed "); - } - } public struct SqliteBackpackItem{ public int Id { get; set; } diff --git a/addons/EGFramework/Module/SaveTools/EGByteSave.cs b/addons/EGFramework/Module/SaveTools/EGByteSave.cs index 86ed428..9996941 100644 --- a/addons/EGFramework/Module/SaveTools/EGByteSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGByteSave.cs @@ -3,43 +3,91 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Runtime.Serialization.Formatters.Binary; -using Godot; +using System.IO; namespace EGFramework { public class EGByteSave : IEGSave,IEGSaveObject { - - public void SaveToFile(string content) - { - using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write); - Variant hp = 10; - file.StoreVar(hp); - Variant pos = new Vector2(100,100); - file.StoreVar(pos); - } + public Encoding StringEncoding { set; get; } = Encoding.ASCII; + private string DefaultPath { set; get; } + private byte[] Data { get; set; } - public Variant LoadFromFile() - { - using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read); - Variant content = file.GetVar(); - Variant pos = file.GetVar(); - return pos; + public void ReadDataBlock(string path){ + DefaultPath = path; + try + { + FileStream fileStream = new FileStream(path,FileMode.Open); + byte[] buffer = new byte[fileStream.Length]; + fileStream.Read(buffer, 0, (int)fileStream.Length); + fileStream.Close(); + fileStream.Dispose(); + Data = buffer; + } + catch (System.Exception e) + { + Godot.GD.Print("e:" + e); + throw; + } + } + public void WriteDataBlock(string path){ + try + { + FileStream fileStream = File.Create(path); + fileStream.Write(Data,0,Data.Length); + fileStream.Close(); + fileStream.Dispose(); + } + catch (System.Exception e) + { + Godot.GD.Print("e:" + e); + throw; + } } public void InitSaveFile(string path) { - //throw new NotImplementedException(); + ReadDataBlock(path); } public void SetObject(string objectKey , TObject obj) { - throw new NotImplementedException(); + // throw new NotImplementedException(); } public TObject GetObject(string objectKey) where TObject : new() { throw new NotImplementedException(); } + + public int GetDataLength(Type type){ + + switch(type){ + + default: return 0 ; + } + } + } + + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] + public class ByteParamAttribute: Attribute{ + public int _pointer { set; get; } + public int _length { set; get; } + public ByteParamAttribute(int pointer,int length = 0){ + this._pointer = pointer; + this._length = length; + } + } + + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] + public class ByteClassAttribute:Attribute{ + public int _length { set; get; } + public ByteClassAttribute(int length){ + this._length = length; + } + } + + public interface IEGByteInit{ + void Init(byte[] data); } } \ No newline at end of file diff --git a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs index 8607e92..d681579 100644 --- a/addons/EGFramework/Module/SaveTools/EGCsvSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGCsvSave.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace EGFramework { - public class EGCsvSave : IEGSaveData, IEGSave + public class EGCsvSave : IEGSaveData, IEGSave, IEGSaveReadOnly { public Encoding StringEncoding { set; get; } = Encoding.UTF8; private string DefaultPath { set; get; } @@ -24,6 +24,14 @@ namespace EGFramework ReadDataBlock(path); } + public void InitReadOnly(string data) + { + ReadText = data; + if(ReadText != null || ReadText != ""){ + CsvDataBlock = GetCSVDataBlockFromText(ReadText,out CsvDataHeader); + } + } + public void ReadDataBlock(string path){ DefaultPath = path; try diff --git a/addons/EGFramework/Module/SaveTools/EGJsonSave.cs b/addons/EGFramework/Module/SaveTools/EGJsonSave.cs index eb172ad..9c8f2c4 100644 --- a/addons/EGFramework/Module/SaveTools/EGJsonSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGJsonSave.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json.Linq; namespace EGFramework { - public class EGJsonSave : IEGSave,IEGSaveObject + public class EGJsonSave : IEGSave,IEGSaveReadOnly,IEGSaveObject { private string DefaultPath { set; get; } private JObject _SaveObject; @@ -42,6 +42,11 @@ namespace EGFramework } } + public void InitReadOnly(string data) + { + _SaveObject = JObject.Parse(data); + } + public void SetObject(string objectKey,TObject obj) { if(SaveObject.ContainsKey(objectKey)){ @@ -63,5 +68,6 @@ namespace EGFramework TObject data = SaveObject[objectKey].ToObject(); return data; } + } } \ No newline at end of file diff --git a/addons/EGFramework/Module/SaveTools/EGSave.cs b/addons/EGFramework/Module/SaveTools/EGSave.cs index 28f8d04..1f499f1 100644 --- a/addons/EGFramework/Module/SaveTools/EGSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGSave.cs @@ -27,6 +27,9 @@ namespace EGFramework private Dictionary DataBaseFiles = new Dictionary(); private Dictionary ObjectFiles = new Dictionary(); + + private Dictionary DataBaseReadOnly = new Dictionary(); + private Dictionary ObjectReadOnly = new Dictionary(); public EGSave() {} public override void Init() { @@ -39,26 +42,70 @@ namespace EGFramework DataBaseFiles.Add(path,saveData); } + public void ReadData(string key,string data)where TReadOnlyData:IEGSaveDataReadOnly,IEGSaveReadOnly,new(){ + TReadOnlyData readOnlyData = new TReadOnlyData(); + readOnlyData.InitReadOnly(data); + DataBaseReadOnly.Add(key,readOnlyData); + } + public void LoadObjectFile(string path) where TSaveObject:IEGSaveObject,IEGSave,new(){ TSaveObject saveObject = new TSaveObject(); saveObject.InitSaveFile(path); ObjectFiles.Add(path, saveObject); } + public void ReadObject(string key,string data)where TReadOnlyObject:IEGSaveObjectReadOnly,IEGSaveReadOnly,new(){ + TReadOnlyObject readOnlyObject = new TReadOnlyObject(); + readOnlyObject.InitReadOnly(data); + ObjectReadOnly.Add(key,readOnlyObject); + } + public void SetObject(string path,string objectKey,TObject obj){ - ObjectFiles[path].SetObject(objectKey,obj); + if(ObjectFiles.ContainsKey(path)){ + ObjectFiles[path].SetObject(objectKey,obj); + }else{ + throw new Exception("File not loaded, you should use LoadObjectFile(key) first."); + } } + public TObject GetObject(string path,string key) where TObject : new(){ - return ObjectFiles[path].GetObject(key); + if(ObjectFiles.ContainsKey(path)){ + return ObjectFiles[path].GetObject(key); + }else if(ObjectReadOnly.ContainsKey(path)){ + return ObjectReadOnly[path].GetObject(key); + }else{ + throw new Exception("File not loaded, you should use LoadObjectFile(key) or ReadObject(key) first."); + } } public void SetData(string path,string dataKey,TData data,int id){ - DataBaseFiles[path].SetData(dataKey,data,id); + if(DataBaseFiles.ContainsKey(path)){ + DataBaseFiles[path].SetData(dataKey,data,id); + }else{ + throw new Exception("File not loaded, you should use LoadDataFile(path) first."); + } + } + public TData GetData(string path,string key,int id) where TData : new(){ + if(DataBaseFiles.ContainsKey(path)){ + return DataBaseFiles[path].GetData(key,id); + }else if(DataBaseReadOnly.ContainsKey(path)){ + return DataBaseReadOnly[path].GetData(key,id); + }else{ + throw new Exception("File not loaded, you should use LoadDataFile(key) or ReadData(key,data) first."); + } } - public void GetData(string path,string key,int id) where TData : new(){ - DataBaseFiles[path].GetData(key,id); + + public IEnumerable GetAllData(string path,string key) where TData : new(){ + if(DataBaseFiles.ContainsKey(path)){ + return DataBaseFiles[path].GetAll(key); + }else if(DataBaseReadOnly.ContainsKey(path)){ + return DataBaseReadOnly[path].GetAll(key); + }else{ + throw new Exception("File not loaded, you should use LoadDataFile(key) or ReadData(key,data) first."); + } } + //------------------------------------------------------------------------------// #region Default Json Operation diff --git a/addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs b/addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs index cccc949..8a58ffa 100644 --- a/addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs +++ b/addons/EGFramework/Module/SaveTools/SaveToolsInterface.cs @@ -10,16 +10,25 @@ namespace EGFramework void InitSaveFile(string path); } - public interface IEGSaveObject{ - void SetObject(string objectKey,TObject obj); + public interface IEGSaveReadOnly{ + void InitReadOnly(string data); + } + + public interface IEGSaveObjectReadOnly{ TObject GetObject(string objectKey) where TObject : new(); } - - // - public interface IEGSaveData{ - void SetData(string dataKey,TData data,object id); + public interface IEGSaveDataReadOnly{ TData GetData(string dataKey,object id) where TData : new(); IEnumerable GetAll(string dataKey) where TData : new(); IEnumerable FindData(string dataKey,Expression> expression) where TData : new(); } + + public interface IEGSaveObject : IEGSaveObjectReadOnly{ + void SetObject(string objectKey,TObject obj); + } + + // + public interface IEGSaveData : IEGSaveDataReadOnly{ + void SetData(string dataKey,TData data,object id); + } } \ No newline at end of file diff --git a/addons/Tools/ItemImporter/ToolItemImporter.cs b/addons/Tools/ItemImporter/ToolItemImporter.cs deleted file mode 100644 index a9c3913..0000000 --- a/addons/Tools/ItemImporter/ToolItemImporter.cs +++ /dev/null @@ -1,54 +0,0 @@ -#if TOOLS -using Godot; -using System; - -namespace EGFramework.Example.SystemExamples.PlayerStorage -{ - [Tool] - public partial class ToolItemImporter : EditorPlugin - { - PackedScene MainPanel = ResourceLoader.Load("res://addons/Tools/ItemImporter/ToolItemImporter.tscn"); - Control MainPanelInstance; - public override void _EnterTree() - { - // Initialization of the plugin goes here. - MainPanelInstance = (Control)MainPanel.Instantiate(); - // Add the main panel to the editor's main viewport. - EditorInterface.Singleton.GetEditorMainScreen().AddChild(MainPanelInstance); - // Hide the main panel. Very much required. - _MakeVisible(false); - } - - public override void _ExitTree() - { - // Clean-up of the plugin goes here. - if (MainPanelInstance != null) - { - MainPanelInstance.QueueFree(); - } - } - public override bool _HasMainScreen() - { - return true; - } - - public override void _MakeVisible(bool visible) - { - if (MainPanelInstance != null) - { - MainPanelInstance.Visible = visible; - } - } - - public override string _GetPluginName() - { - return "Tool Item Importer"; - } - - public override Texture2D _GetPluginIcon() - { - return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons"); - } - } -} -#endif diff --git a/addons/Tools/ItemImporter/ToolItemImporter.tscn b/addons/Tools/ItemImporter/ToolItemImporter.tscn deleted file mode 100644 index 0cc55a3..0000000 --- a/addons/Tools/ItemImporter/ToolItemImporter.tscn +++ /dev/null @@ -1,37 +0,0 @@ -[gd_scene format=3 uid="uid://bglw1yht7w1kt"] - -[node name="ToolItemImporter" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="Button" type="Button" parent="."] -layout_mode = 1 -offset_right = 69.0 -offset_bottom = 31.0 -text = "导入CSV" - -[node name="Button2" type="Button" parent="."] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -72.0 -offset_bottom = 31.0 -grow_horizontal = 0 -text = "重新载入" - -[node name="Button3" type="Button" parent="."] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -71.0 -offset_top = 36.0 -offset_right = 1.0 -offset_bottom = 67.0 -grow_horizontal = 0 -text = "重新载入" diff --git a/addons/Tools/ItemImporter/plugin.cfg b/addons/Tools/ItemImporter/plugin.cfg deleted file mode 100644 index b1c3cf3..0000000 --- a/addons/Tools/ItemImporter/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="ItemImporter" -description="a csv ItemImporter" -author="jkpete" -version="" -script="ToolItemImporter.cs" \ No newline at end of file diff --git a/project.godot b/project.godot index cc00667..23c921a 100644 --- a/project.godot +++ b/project.godot @@ -16,6 +16,11 @@ run/main_scene="res://Example/UsingTest/Scene/TestEGFramework.tscn" config/features=PackedStringArray("4.2", "C#", "GL Compatibility") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 + [dotnet] project/assembly_name="EGFramework"