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