cmd

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	// Do performs the action.
	// An error is returned if the action could not be performed.
	Do() error

	// Undo reverses its action to restore the environment to the previous state.
	// An error is returned if the action could not be successfully undone. The
	// environment may not be in the state as before.
	Undo() error
}

Command describes an action that can be performed, undone, and redone.

type ElectronicMessageStore

type ElectronicMessageStore interface {
	RequestRemove()
	RequestMessageChange(model.ElectronicMessage)
	RequestAudioChange(model.ResourceLanguage, audio.SoundData)
}

ElectronicMessageStore is the simple interface for a message store.

type RemoveElectronicMessageCommand

type RemoveElectronicMessageCommand struct {
	RestoreState func()
	Store        ElectronicMessageStore

	Properties model.ElectronicMessage
	Audio      [model.LanguageCount]audio.SoundData
}

RemoveElectronicMessageCommand removes and restores an electronic message.

func (RemoveElectronicMessageCommand) Do

Do removes the message.

func (RemoveElectronicMessageCommand) Undo

Undo restores the message.

type SetActiveLevelCommand

type SetActiveLevelCommand struct {
	Setter   func(levelID int) error
	OldValue int
	NewValue int
}

SetActiveLevelCommand sets the currently active level.

func (SetActiveLevelCommand) Do

func (cmd SetActiveLevelCommand) Do() error

Do sets the new value.

func (SetActiveLevelCommand) Undo

func (cmd SetActiveLevelCommand) Undo() error

Undo sets the old value.

type SetAudioCommand

type SetAudioCommand struct {
	Setter   func(data audio.SoundData) error
	OldValue audio.SoundData
	NewValue audio.SoundData
}

SetAudioCommand changes an audio clip.

func (SetAudioCommand) Do

func (cmd SetAudioCommand) Do() error

Do sets the new value.

func (SetAudioCommand) Undo

func (cmd SetAudioCommand) Undo() error

Undo sets the old value.

type SetBitmapCommand

type SetBitmapCommand struct {
	Setter   func(bmp *model.RawBitmap) error
	OldValue *model.RawBitmap
	NewValue *model.RawBitmap
}

SetBitmapCommand changes an audio clip.

func (SetBitmapCommand) Do

func (cmd SetBitmapCommand) Do() error

Do sets the new value.

func (SetBitmapCommand) Undo

func (cmd SetBitmapCommand) Undo() error

Undo sets the old value.

type SetBooleanPropertyCommand

type SetBooleanPropertyCommand struct {
	Setter   func(value bool) error
	OldValue bool
	NewValue bool
}

SetBooleanPropertyCommand changes a boolean property.

func (SetBooleanPropertyCommand) Do

Do sets the new value.

func (SetBooleanPropertyCommand) Undo

func (cmd SetBooleanPropertyCommand) Undo() error

Undo sets the old value.

type SetEditorModeCommand

type SetEditorModeCommand struct {
	Activator func(name string)
	OldMode   string
	NewMode   string
}

SetEditorModeCommand changes the current editor mode.

func (SetEditorModeCommand) Do

func (cmd SetEditorModeCommand) Do() error

Do activates the new mode.

func (SetEditorModeCommand) Undo

func (cmd SetEditorModeCommand) Undo() error

Undo activates the old mode.

type SetIntPropertyCommand

type SetIntPropertyCommand struct {
	Setter   func(value int) error
	OldValue int
	NewValue int
}

SetIntPropertyCommand changes an integer property.

func (SetIntPropertyCommand) Do

func (cmd SetIntPropertyCommand) Do() error

Do sets the new value.

func (SetIntPropertyCommand) Undo

func (cmd SetIntPropertyCommand) Undo() error

Undo sets the old value.

type SetLevelTexturesCommand

type SetLevelTexturesCommand struct {
	Setter        func(textureIDs []int) error
	OldTextureIDs []int
	NewTextureIDs []int
}

SetLevelTexturesCommand sets the textures of a level.

func (SetLevelTexturesCommand) Do

func (cmd SetLevelTexturesCommand) Do() error

Do sets the new value.

func (SetLevelTexturesCommand) Undo

func (cmd SetLevelTexturesCommand) Undo() error

Undo sets the old value.

type SetStringPropertyCommand

type SetStringPropertyCommand struct {
	Setter   func(value string) error
	OldValue string
	NewValue string
}

SetStringPropertyCommand changes a textual property.

func (SetStringPropertyCommand) Do

Do sets the new value.

func (SetStringPropertyCommand) Undo

func (cmd SetStringPropertyCommand) Undo() error

Undo sets the old value.

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack describes a list of commands. The stack allows to sequentially undo and redo stacked commands. It essentially stores two lists: a list of commands to undo, and another of commands to redo. Modifying stack functions will panic if they are called while already in use.

func (*Stack) CanRedo

func (stack *Stack) CanRedo() bool

CanRedo returns true if there is at least one more command that can be redone.

func (*Stack) CanUndo

func (stack *Stack) CanUndo() bool

CanUndo returns true if there is at least one more command that can be undone.

func (*Stack) Perform

func (stack *Stack) Perform(cmd Command) error

Perform executes the given command and puts it on the stack if the command was successful. This function also clears the list of commands to be redone.

func (*Stack) Redo

func (stack *Stack) Redo() error

Redo attempts to perform the next command on the redo list. If there is no further command to redo, nothing happens. An error is returned if the command failed. In this case, the stack is unchanged and a further attempt to redo will try the same command again.

func (*Stack) Undo

func (stack *Stack) Undo() error

Undo attempts to undo the previous command on the list. If there is no further command to undo, nothing happens. An error is returned if the command failed. In this case, the stack is unchanged and a further attempt to undo will try the same command again.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL