jkpete
3 months ago
14 changed files with 266 additions and 9 deletions
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bhsavl0d80s6j"] |
||||
|
||||
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs" id="1_j773b"] |
||||
|
||||
[resource] |
||||
script = ExtResource("1_j773b") |
||||
Id = 0 |
||||
Name = "" |
||||
Info = "" |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://tee7nc525si7"] |
||||
|
||||
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs" id="1_goow2"] |
||||
|
||||
[node name="PlayerStorage" type="Control"] |
||||
layout_mode = 3 |
||||
anchors_preset = 15 |
||||
anchor_right = 1.0 |
||||
anchor_bottom = 1.0 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
script = ExtResource("1_goow2") |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.Example.SystemExamples.PlayerStorage |
||||
{ |
||||
public partial class DataStorageItem : Resource, IItem |
||||
{ |
||||
[Export] public int Id { set; get; } |
||||
[Export] public string Name { set; get; } |
||||
[Export(PropertyHint.MultilineText)] public string Info { set; get; } |
||||
[Export] public Texture Icon { set; get; } |
||||
|
||||
public Texture GetIcon() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetInfo() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetItemId() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetName() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.Example.SystemExamples.PlayerStorage |
||||
{ |
||||
public interface IItem |
||||
{ |
||||
public int GetItemId(); |
||||
public string GetName(); |
||||
public Texture GetIcon(); |
||||
public string GetInfo(); |
||||
} |
||||
public interface IBackPackItem : IItem{ |
||||
public int GetCount(); |
||||
} |
||||
|
||||
public interface ICostItem: IItem { |
||||
public void OnCost(); |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
using Godot; |
||||
using System; |
||||
using EGFramework; |
||||
|
||||
public partial class ViewStorage : Node,IEGFramework |
||||
{ |
||||
// Called when the node enters the scene tree for the first time. |
||||
public override void _Ready() |
||||
{ |
||||
// this.GetModule<EGByteSave>().SaveToFile("nihao"); |
||||
Variant result = this.GetModule<EGByteSave>().LoadFromFile(); |
||||
GD.Print(result); |
||||
} |
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame. |
||||
public override void _Process(double delta) |
||||
{ |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using System.Runtime.Serialization.Formatters.Binary; |
||||
using Godot; |
||||
|
||||
namespace EGFramework |
||||
{ |
||||
public class EGByteSave : EGModule//, IEGSave |
||||
{ |
||||
|
||||
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 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 override void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
// public TData GetDataByFile<TData>() where TData : class, new() |
||||
// { |
||||
// throw new NotImplementedException(); |
||||
// } |
||||
// public void InitSaveData(string fileName) |
||||
// { |
||||
// throw new NotImplementedException(); |
||||
// } |
||||
public void SetDataToFile<TData>(TData data) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
#if TOOLS |
||||
using Godot; |
||||
using System; |
||||
|
||||
namespace EGFramework.Example.SystemExamples.PlayerStorage |
||||
{ |
||||
[Tool] |
||||
public partial class ToolItemImporter : EditorPlugin |
||||
{ |
||||
PackedScene MainPanel = ResourceLoader.Load<PackedScene>("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 |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
[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 = "重新载入" |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
[plugin] |
||||
|
||||
name="ItemImporter" |
||||
description="a csv ItemImporter" |
||||
author="jkpete" |
||||
version="" |
||||
script="ToolItemImporter.cs" |
Loading…
Reference in new issue