package ui import ( "fyne.io/fyne/v2/container" "gitea.mmo.to/ProtocolPacketForger/ppf/protocol" "gitea.mmo.to/ProtocolPacketForger/ppf/protocolctl" ) type ProtocolFileHandler struct { ProtocolEditor *ProtocolEditor Filename string Changed bool Reference *protocol.ProtocolStructure } func NewProtocolFileHandler() *ProtocolFileHandler { pfh := ProtocolFileHandler{} pfh.Filename = "*new" pfh.Changed = true pfh.ProtocolEditor = GetProtocolEditor() return &pfh } func LoadProtocolFileHandler(path string) *ProtocolFileHandler { pfh := ProtocolFileHandler{} pfh.Filename = path pfh.Load() return &pfh } func (pfh *ProtocolFileHandler) Load() { prot, err := protocolctl.LoadNew(pfh.Filename) if err != nil { // process error err = nil } pfh.ProtocolEditor = NewProtocolEditor(prot) pfh.Reference = prot PPF.ProtocolMeta.SetProtocol(prot) } func (pfh *ProtocolFileHandler) Save() { pfh.Changed = false } func (pfh *ProtocolFileHandler) GetWorkarea() *container.Scroll { return container.NewVScroll(pfh.ProtocolEditor.Representation) }