Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ContextActionDisplay
- DialogElement
- FieldInfoDisplay
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputHelpDisplay
- ListElement
- ListItemElement
- MapHotspot
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- SettingsModel
- SideNotification
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- StableListElement
- StatusBar
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TextElement
- TextInputElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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. |
131 | function GuiProfile:getBool(name, default) |
132 | local value = self:getValue(name) |
133 | local ret = default |
134 | if value ~= nil and value ~= "nil" then |
135 | ret = (value:lower() == "true") |
136 | end |
137 | |
138 | return ret |
139 | 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. |
145 | function GuiProfile:getNumber(name, default) |
146 | local value = self:getValue(name) |
147 | local ret = default |
148 | if value ~= nil and value ~= "nil" then |
149 | ret = tonumber(value) |
150 | end |
151 | |
152 | return ret |
153 | 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. |
100 | function GuiProfile:getValue(name, default) |
101 | local ret = default |
102 | |
103 | -- Try a special case |
104 | if self.values[name .. g_baseUIPostfix] ~= nil and self.values[name .. g_baseUIPostfix] ~= "nil" then |
105 | ret = self.values[name .. g_baseUIPostfix] |
106 | |
107 | -- Try definition in the profile |
108 | elseif self.values[name] ~= nil and self.values[name] ~= "nil" then |
109 | ret = self.values[name] |
110 | |
111 | -- Try the profile itself |
112 | else |
113 | if self.parent ~= nil then |
114 | if self.profiles[self.parent] ~= nil then |
115 | if self.profiles[self.parent] ~= "nil" then |
116 | ret = self.profiles[self.parent]:getValue(name, default) |
117 | end |
118 | else |
119 | print("Warning: Parent-profile '" .. self.parent .. "' not found for profile '" .. self.name .. "'") |
120 | end |
121 | end |
122 | end |
123 | |
124 | return ret |
125 | 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) |
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 | |
48 | -- If this is not a trait, resolve traits |
49 | if not isTrait then |
50 | local traits = getXMLString(xmlFile, key .. "#with") |
51 | if traits ~= nil then |
52 | local traitNames = StringUtil.splitString(" ", traits) |
53 | |
54 | -- Copy all values, overwriting previous ones. |
55 | -- This is resolving of the traits. |
56 | for i = #traitNames, 1, -1 do |
57 | local traitName = traitNames[i] |
58 | local trait = self.traits[traitName] |
59 | |
60 | if trait ~= nil then |
61 | for name, value in pairs(trait.values) do |
62 | self.values[name] = value |
63 | end |
64 | else |
65 | print("Warning: Trait-profile '" .. traitName .. "' not found for trait '" .. self.name .. "'") |
66 | end |
67 | end |
68 | end |
69 | end |
70 | |
71 | local i = 0 |
72 | while true do |
73 | local k = key .. ".Value(" .. i .. ")" |
74 | local name = getXMLString(xmlFile, k .. "#name") |
75 | local value = getXMLString(xmlFile, k .. "#value") |
76 | if name == nil or value == nil then |
77 | break |
78 | end |
79 | |
80 | if StringUtil.startsWith(value, "$preset_") then |
81 | local preset = string.gsub(value, "$preset_", "") |
82 | if presets[preset] ~= nil then |
83 | value = presets[preset] |
84 | else |
85 | print("Warning: Preset '" .. preset .. "' is not defined in GuiProfile!") |
86 | end |
87 | end |
88 | |
89 | self.values[name] = value |
90 | i = i + 1 |
91 | end |
92 | |
93 | return true |
94 | 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 |