Documentation ¶
Index ¶
- type Command
- type ElectronicMessageStore
- type RemoveElectronicMessageCommand
- type SetActiveLevelCommand
- type SetAudioCommand
- type SetBitmapCommand
- type SetBooleanPropertyCommand
- type SetEditorModeCommand
- type SetIntPropertyCommand
- type SetLevelTexturesCommand
- type SetStringPropertyCommand
- type Stack
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 ¶
func (cmd RemoveElectronicMessageCommand) Do() error
Do removes the message.
func (RemoveElectronicMessageCommand) Undo ¶
func (cmd RemoveElectronicMessageCommand) Undo() error
Undo restores the message.
type SetActiveLevelCommand ¶
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.
type SetBitmapCommand ¶
type SetBitmapCommand struct { Setter func(bmp *model.RawBitmap) error OldValue *model.RawBitmap NewValue *model.RawBitmap }
SetBitmapCommand changes an audio clip.
type SetBooleanPropertyCommand ¶
SetBooleanPropertyCommand changes a boolean property.
func (SetBooleanPropertyCommand) Do ¶
func (cmd SetBooleanPropertyCommand) Do() error
Do sets the new value.
func (SetBooleanPropertyCommand) Undo ¶
func (cmd SetBooleanPropertyCommand) Undo() error
Undo sets the old value.
type SetEditorModeCommand ¶
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 ¶
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 ¶
func (cmd SetStringPropertyCommand) Do() error
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 ¶
CanRedo returns true if there is at least one more command that can be redone.
func (*Stack) CanUndo ¶
CanUndo returns true if there is at least one more command that can be undone.
func (*Stack) Perform ¶
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 ¶
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.