Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
GuiProfile
DescriptionGUI element display profile. Holds GuiElement property data for re-use similar to a HTML/CSS definition.Functions
getBool
DescriptionGet a boolean value from this profile (and its ancestors) by name.Definition
getBool(name Name, default Default)Arguments
name | Name | of attribute value to retrieve |
default | Default | value to use if the attribute is not defined. |
143 | function GuiProfile:getBool(name, default) |
144 | local value = self:getValue(name) |
145 | local ret = default |
146 | if value ~= nil and value ~= "nil" then |
147 | ret = (value:lower() == "true") |
148 | end |
149 | |
150 | return ret |
151 | end |
getNumber
DescriptionGet a number value from this profile (and its ancestors) by name.Definition
getNumber(name Name, default Default)Arguments
name | Name | of attribute value to retrieve |
default | Default | value to use if the attribute is not defined. |
157 | function GuiProfile:getNumber(name, default) |
158 | local value = self:getValue(name) |
159 | local ret = default |
160 | if value ~= nil and value ~= "nil" then |
161 | ret = tonumber(value) |
162 | end |
163 | |
164 | return ret |
165 | end |
getValue
DescriptionGet a string value from this profile (and its ancestors) by name.Definition
getValue(name Name, default Default)Arguments
name | Name | of attribute value to retrieve |
default | Default | value to use if the attribute is not defined. |
105 | function GuiProfile:getValue(name, default) |
106 | local ret = default |
107 | |
108 | -- Try a special case |
109 | if self.values[name .. g_baseUIPostfix] ~= nil and self.values[name .. g_baseUIPostfix] ~= "nil" then |
110 | ret = self.values[name .. g_baseUIPostfix] |
111 | |
112 | -- Try definition in the profile |
113 | elseif self.values[name] ~= nil and self.values[name] ~= "nil" then |
114 | ret = self.values[name] |
115 | |
116 | -- Try the profile itself |
117 | else |
118 | if self.parent ~= nil then |
119 | -- Try parent |
120 | local parentProfile |
121 | if self.isVariant then |
122 | parentProfile = self.profiles[self.parent] |
123 | else |
124 | -- Follow the path of special variants so top-level variants update all children |
125 | parentProfile = g_gui:getProfile(self.parent) |
126 | end |
127 | |
128 | if parentProfile ~= nil and parentProfile ~= "nil" then |
129 | ret = parentProfile:getValue(name, default) |
130 | else |
131 | print("Warning: Parent-profile '" .. self.parent .. "' not found for profile '" .. self.name .. "'") |
132 | end |
133 | end |
134 | end |
135 | |
136 | return ret |
137 | end |
loadFromXML
DescriptionLoad profile data from XML.Definition
loadFromXML(xmlFile XML, key Profile, presets Table, isTrait Whether)Arguments
xmlFile | XML | file handle |
key | Profile | XML element node path |
presets | Table | of presets for symbol resolution, {preset name=preset value} |
isTrait | Whether | this profile is a trait |
True | if | profile values could be loaded, false otherwise. |
38 | function GuiProfile:loadFromXML(xmlFile, key, presets, isTrait, isVariant) |
39 | local name = getXMLString(xmlFile, key .. "#name") |
40 | if name == nil then |
41 | return false |
42 | end |
43 | |
44 | self.name = name |
45 | self.isTrait = isTrait or false |
46 | self.parent = getXMLString(xmlFile, key .. "#extends") |
47 | self.isVariant = isVariant |
48 | |
49 | if self.parent == self.name then |
50 | error("Profile " .. name .. " extends itself") |
51 | end |
52 | |
53 | -- If this is not a trait, resolve traits |
54 | if not isTrait then |
55 | local traits = getXMLString(xmlFile, key .. "#with") |
56 | if traits ~= nil then |
57 | local traitNames = traits:split(" ") |
58 | |
59 | -- Copy all values, overwriting previous ones. |
60 | -- This is resolving of the traits. |
61 | for i = #traitNames, 1, -1 do |
62 | local traitName = traitNames[i] |
63 | local trait = self.traits[traitName] |
64 | |
65 | if trait ~= nil then |
66 | for traitValueName, value in pairs(trait.values) do |
67 | self.values[traitValueName] = value |
68 | end |
69 | else |
70 | print("Warning: Trait-profile '" .. traitName .. "' not found for trait '" .. self.name .. "'") |
71 | end |
72 | end |
73 | end |
74 | end |
75 | |
76 | local i = 0 |
77 | while true do |
78 | local k = key .. ".Value(" .. i .. ")" |
79 | local valueName = getXMLString(xmlFile, k .. "#name") |
80 | local value = getXMLString(xmlFile, k .. "#value") |
81 | if valueName == nil or value == nil then |
82 | break |
83 | end |
84 | |
85 | if value:startsWith("$preset_") then |
86 | local preset = string.gsub(value, "$preset_", "") |
87 | if presets[preset] ~= nil then |
88 | value = presets[preset] |
89 | else |
90 | print("Warning: Preset '" .. preset .. "' is not defined in GuiProfile!") |
91 | end |
92 | end |
93 | |
94 | self.values[valueName] = value |
95 | i = i + 1 |
96 | end |
97 | |
98 | return true |
99 | end |
new
DescriptionCreate a new GuiProfile.Definition
new(profiles Reference, traits Reference)Arguments
profiles | Reference | to loaded profiles table for inheritance checking. |
traits | Reference | to loaded traits table for inheritance checking. |
New | GuiProfile | instance |
19 | function GuiProfile.new(profiles, traits) |
20 | local self = setmetatable({}, GuiProfile_mt) |
21 | |
22 | self.values = {} |
23 | self.name = "" |
24 | self.profiles = profiles |
25 | self.traits = traits |
26 | self.parent = nil |
27 | |
28 | return self |
29 | end |