LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

GuiMixin

Description
GuiElement mixin base class. Implements base functionality for GUI element mixins. All other GUI mixins should be descendants of this class.
Functions

addTo

Description
Add a mixin to a GuiElement. Adds mixin methods to the element which can then be used. A mixin's state is located in "element[mixinType]".
Definition
addTo()
Code
41function GuiMixin:addTo(guiElement)
42 if not guiElement[self.mixinType] then
43 guiElement[self.mixinType] = self
44 guiElement.hasIncluded = self.hasIncluded
45
46 return true
47 else
48 return false
49 end
50end

clone

Description
Clone this mixin's state from a source to a destination GuiElement instance.
Definition
clone()
Code
68function GuiMixin:clone(srcGuiElement, dstGuiElement)
69 -- implement in subclasses to copy mixin state between decorated GuiElement instances
70end

cloneMixin

Description
Clone mixin states for a mixin type from a source to a destination GuiElement instance.
Definition
cloneMixin()
Code
62function GuiMixin.cloneMixin(mixinType, srcGuiElement, dstGuiElement)
63 mixinType:clone(srcGuiElement, dstGuiElement)
64end

hasIncluded

Description
Determine if a GuiElement has a mixin type included.
Definition
hasIncluded(guiElement GuiElement, mixinType GuiMixin)
Arguments
guiElementGuiElementinstance
mixinTypeGuiMixinclass reference
Code
56function GuiMixin.hasIncluded(guiElement, mixinType)
57 return guiElement[mixinType] ~= nil
58end

new

Description
Create a new GuiMixin instance. Subclasses need to provide their class type table for identification.
Definition
new(class Class, mixinType Class)
Arguments
classClassmetatable
mixinTypeClasstype table
Return Values
Newinstance
Code
23function GuiMixin.new(class, mixinType)
24 if class == nil then
25 class = GuiMixin_mt
26 end
27
28 if mixinType == nil then
29 mixinType = GuiMixin
30 end
31
32 local self = setmetatable({}, class)
33 self.mixinType = mixinType
34
35 return self
36end