Going forward...
build
Details
build
Details
This commit is contained in:
parent
c5f7d0f9a5
commit
0e932342e0
|
@ -21,7 +21,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: https://github.com/actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.19
|
||||
go-version: 1.20
|
||||
- name: Install GoReleaser
|
||||
uses: https://github.com/goreleaser/goreleaser-action@v2.7.0
|
||||
with:
|
||||
|
|
|
@ -10,10 +10,12 @@ import (
|
|||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
// A Representationer provides a representation as fyne.Container
|
||||
type Representationer interface {
|
||||
Representation() *fyne.Container
|
||||
}
|
||||
|
||||
// A FileHandler handles files in the application
|
||||
type FileHandler interface {
|
||||
Name() string
|
||||
Path() string
|
||||
|
@ -28,11 +30,13 @@ type FileHandler interface {
|
|||
GetReference() interface{}
|
||||
}
|
||||
|
||||
// A TabProvider gives back a container.TabItem and allows to set it for internal storage
|
||||
type TabProvider interface {
|
||||
SetTab(tab *container.TabItem)
|
||||
Tab() *container.TabItem
|
||||
}
|
||||
|
||||
// ppfApp is the internal struct holding all the required main objects/elements for the application
|
||||
type ppfApp struct {
|
||||
App fyne.App
|
||||
Window fyne.Window
|
||||
|
@ -65,8 +69,10 @@ type ppfApp struct {
|
|||
OpenProtocolFiles []*ProtocolFileHandler//*/
|
||||
}
|
||||
|
||||
// PPF is the global variable holding the application struct
|
||||
var PPF ppfApp
|
||||
|
||||
// NewPPF is the entrypoint to create the application
|
||||
func NewPPF(fyneApp fyne.App, w fyne.Window) ppfApp {
|
||||
PPF.App = fyneApp
|
||||
PPF.Window = w
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"gitea.mmo.to/ProtocolPacketForger/ppf/packet"
|
||||
"gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
||||
"gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl"
|
||||
)
|
||||
|
@ -114,6 +115,10 @@ func (md *ProtocolMetadata) Unset() {
|
|||
md.SetChanged(func(s string) {})
|
||||
}
|
||||
|
||||
func (md *PacketMetadata) SetData(pack *packet.Structure) {
|
||||
|
||||
}
|
||||
|
||||
func NewMetadataPacket() *PacketMetadata {
|
||||
md := PacketMetadata{}
|
||||
vbox := container.NewVBox()
|
||||
|
|
|
@ -17,10 +17,10 @@ type PacketEditor struct {
|
|||
|
||||
ShowShortHints bool
|
||||
|
||||
Reference *packet.PacketStructure
|
||||
Reference *packet.Structure
|
||||
}
|
||||
|
||||
func NewPacketEditor(ref *packet.PacketStructure) *PacketEditor {
|
||||
func NewPacketEditor(ref *packet.Structure) *PacketEditor {
|
||||
metadata := NewMetadataPacket()
|
||||
fields := container.NewGridWrap(fyne.NewSize(300, 200))
|
||||
container := container.NewBorder(nil, nil, metadata.Representation, nil, container.NewVScroll(fields))
|
||||
|
|
|
@ -15,6 +15,7 @@ type PacketFieldEditor struct {
|
|||
Reference *packet.FieldValue
|
||||
|
||||
GlobalIndex int
|
||||
LayerIndex int
|
||||
Index int
|
||||
}
|
||||
|
||||
|
@ -28,6 +29,7 @@ func CreatePacketFieldEditor(
|
|||
pfe := &PacketFieldEditor{}
|
||||
pfe.Reference = ref
|
||||
pfe.Index = index
|
||||
pfe.LayerIndex = lyridx
|
||||
pfe.GlobalIndex = gblidx
|
||||
|
||||
setfunc := func(s string) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"gitea.mmo.to/ProtocolPacketForger/ppf/packetctl"
|
||||
)
|
||||
|
||||
// implements TabProvider, FileHandler
|
||||
// PacketFileHandler implements TabProvider, FileHandler
|
||||
type PacketFileHandler struct {
|
||||
PacketEditor *PacketEditor
|
||||
name string
|
||||
|
@ -14,7 +14,7 @@ type PacketFileHandler struct {
|
|||
changed bool
|
||||
tab *container.TabItem
|
||||
|
||||
Reference *packet.PacketStructure
|
||||
Reference *packet.Structure
|
||||
}
|
||||
|
||||
func NewPacketFileHandler() *PacketFileHandler {
|
||||
|
@ -33,3 +33,37 @@ func (pfh *PacketFileHandler) SetTab(tab *container.TabItem) {
|
|||
func (pfh *PacketFileHandler) Tab() *container.TabItem {
|
||||
return pfh.tab
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) Name() string {
|
||||
return pfh.name
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) Path() string {
|
||||
return pfh.path
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) Open(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) Save() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) SaveAs(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pfh *PacketFileHandler) SetChanged() {
|
||||
|
||||
}
|
||||
func (pfh *PacketFileHandler) HasChanged() bool {
|
||||
return true
|
||||
}
|
||||
func (pfh *PacketFileHandler) GetReference() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package ui
|
||||
|
||||
// packet protocol chooser
|
||||
/*
|
||||
Choose layer to start from
|
||||
[start layer]
|
||||
|
||||
Layers:
|
||||
[1st layer]
|
||||
[2nd layer] [del]
|
||||
|
||||
Add layer
|
||||
[combobox] [add]
|
||||
|
||||
*! removing a layer discards it's content !
|
||||
|
||||
*/
|
|
@ -2,7 +2,7 @@ package packet
|
|||
|
||||
import "gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
||||
|
||||
// implements protocol.ProtocolFieldReferencer
|
||||
// FieldValue implements protocol.ProtocolFieldReferencer
|
||||
type FieldValue struct {
|
||||
fieldReference *protocol.Field
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package packet
|
|||
|
||||
import "gitea.mmo.to/ProtocolPacketForger/ppf/protocol"
|
||||
|
||||
// implements protocol.ProtocolReferencer
|
||||
type PacketLayer struct {
|
||||
// Layer implements protocol.ProtocolReferencer
|
||||
type Layer struct {
|
||||
// needs a reference to a protocol
|
||||
protocolReference *protocol.ProtocolStructure
|
||||
|
||||
|
@ -11,15 +11,16 @@ type PacketLayer struct {
|
|||
Values []FieldValue
|
||||
}
|
||||
|
||||
type PacketStructure struct {
|
||||
MetaData PacketMetadata
|
||||
Layers []PacketLayer
|
||||
// Structure contains all layers of a packet
|
||||
type Structure struct {
|
||||
MetaData Metadata
|
||||
Layers []Layer
|
||||
}
|
||||
|
||||
func (pl *PacketLayer) GetProtocol() *protocol.ProtocolStructure {
|
||||
func (pl *Layer) GetProtocol() *protocol.ProtocolStructure {
|
||||
return pl.protocolReference
|
||||
}
|
||||
|
||||
func (pl *PacketLayer) Setprotocol(ps *protocol.ProtocolStructure) {
|
||||
func (pl *Layer) Setprotocol(ps *protocol.ProtocolStructure) {
|
||||
pl.protocolReference = ps
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package packet
|
||||
|
||||
type PacketMetadata struct {
|
||||
type Metadata struct {
|
||||
Name string
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@ import (
|
|||
"gitea.mmo.to/ProtocolPacketForger/ppf/packet"
|
||||
)
|
||||
|
||||
func NewPacketStructure() *packet.PacketStructure {
|
||||
p := packet.PacketStructure{}
|
||||
func NewPacketStructure() *packet.Structure {
|
||||
p := packet.Structure{}
|
||||
return &p
|
||||
}
|
||||
|
||||
func UpdateMetaData(
|
||||
pack *packet.PacketStructure,
|
||||
pack *packet.Structure,
|
||||
) {
|
||||
// still empty
|
||||
}
|
||||
|
||||
func NewPacketLayer() *packet.PacketLayer {
|
||||
p := packet.PacketLayer{}
|
||||
func NewPacketLayer() *packet.Layer {
|
||||
p := packet.Layer{}
|
||||
return &p
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@ func NewFieldValue(
|
|||
return &f
|
||||
}
|
||||
|
||||
func AppendField(pack *packet.PacketLayer, field *packet.FieldValue) int {
|
||||
func AppendField(pack *packet.Layer, field *packet.FieldValue) int {
|
||||
i := len(pack.Values)
|
||||
pack.Values = append(pack.Values, *field)
|
||||
return i + 1
|
||||
}
|
||||
|
||||
func AddField(pack *packet.PacketLayer, index int, field *packet.FieldValue) {
|
||||
func AddField(pack *packet.Layer, index int, field *packet.FieldValue) {
|
||||
if len(pack.Values) == index {
|
||||
AppendField(pack, field)
|
||||
return
|
||||
|
@ -56,31 +56,31 @@ func AddField(pack *packet.PacketLayer, index int, field *packet.FieldValue) {
|
|||
pack.Values = ret
|
||||
}
|
||||
|
||||
func AppendLayer(pack *packet.PacketStructure, layer *packet.PacketLayer) {
|
||||
func AppendLayer(pack *packet.Structure, layer *packet.Layer) {
|
||||
pack.Layers = append(pack.Layers, *layer)
|
||||
}
|
||||
|
||||
func Addlayer(pack *packet.PacketStructure, index int, layer *packet.PacketLayer) {
|
||||
func Addlayer(pack *packet.Structure, index int, layer *packet.Layer) {
|
||||
if len(pack.Layers) == index {
|
||||
AppendLayer(pack, layer)
|
||||
return
|
||||
}
|
||||
ret := make([]packet.PacketLayer, 0)
|
||||
ret := make([]packet.Layer, 0)
|
||||
ret = append(ret, pack.Layers[:index]...)
|
||||
ret = append(ret, *layer)
|
||||
ret = append(ret, pack.Layers[index:]...)
|
||||
pack.Layers = ret
|
||||
}
|
||||
|
||||
func UpdateField(pack *packet.PacketLayer, e int, field *packet.FieldValue) {
|
||||
func UpdateField(pack *packet.Layer, e int, field *packet.FieldValue) {
|
||||
pack.Values[e] = *field
|
||||
}
|
||||
|
||||
func UpdateLayer(pack *packet.PacketStructure, e int, layer *packet.PacketLayer) {
|
||||
func UpdateLayer(pack *packet.Structure, e int, layer *packet.Layer) {
|
||||
pack.Layers[e] = *layer
|
||||
}
|
||||
|
||||
func RemoveField(pack *packet.PacketLayer, e int) {
|
||||
func RemoveField(pack *packet.Layer, e int) {
|
||||
l := len(pack.Values) - 1
|
||||
ret := make([]packet.FieldValue, l)
|
||||
ret = append(ret, pack.Values[:e]...)
|
||||
|
@ -88,15 +88,15 @@ func RemoveField(pack *packet.PacketLayer, e int) {
|
|||
pack.Values = ret
|
||||
}
|
||||
|
||||
func RemoveLayer(pack *packet.PacketStructure, e int) {
|
||||
func RemoveLayer(pack *packet.Structure, e int) {
|
||||
l := len(pack.Layers) - 1
|
||||
ret := make([]packet.PacketLayer, l)
|
||||
ret := make([]packet.Layer, l)
|
||||
ret = append(ret, pack.Layers[:e]...)
|
||||
ret = append(ret, pack.Layers[e+1:]...)
|
||||
pack.Layers = ret
|
||||
}
|
||||
|
||||
func Load(pack *packet.PacketStructure, path string) error {
|
||||
func Load(pack *packet.Structure, path string) error {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -105,7 +105,7 @@ func Load(pack *packet.PacketStructure, path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func ToJson(pack *packet.PacketStructure) string {
|
||||
func ToJson(pack *packet.Structure) string {
|
||||
data, err := json.MarshalIndent(*pack, "", " ")
|
||||
if err != nil {
|
||||
return ""
|
||||
|
@ -113,7 +113,7 @@ func ToJson(pack *packet.PacketStructure) string {
|
|||
return string(data)
|
||||
}
|
||||
|
||||
func Save(pack *packet.PacketStructure, path string) error {
|
||||
func Save(pack *packet.Structure, path string) error {
|
||||
data, err := json.MarshalIndent(*pack, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue