|
@@ -1,56 +1,63 @@
|
|
|
-local logoSprite = nil
|
|
|
|
|
|
|
+Sample = {}
|
|
|
|
|
|
|
|
-local cache = GetCache()
|
|
|
|
|
-local engine = GetEngine()
|
|
|
|
|
-local ui = GetUI()
|
|
|
|
|
-
|
|
|
|
|
-function SampleStart()
|
|
|
|
|
- CreateLogo()
|
|
|
|
|
- CreateConsoleAndDebugHud()
|
|
|
|
|
|
|
+function Sample:Start()
|
|
|
|
|
+ self.logoSprite = nil
|
|
|
|
|
+ self:CreateLogo()
|
|
|
|
|
+ self:CreateConsoleAndDebugHud()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function SampleStop()
|
|
|
|
|
- logoSprite = nil
|
|
|
|
|
|
|
+function Sample:Stop()
|
|
|
|
|
+ self.logoSprite = nil
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function CreateLogo()
|
|
|
|
|
|
|
+function Sample:CreateLogo()
|
|
|
|
|
+ local cache = GetCache()
|
|
|
local logoTexture = cache:GetTexture2D("Textures/LogoLarge.png")
|
|
local logoTexture = cache:GetTexture2D("Textures/LogoLarge.png")
|
|
|
if logoTexture == nil then
|
|
if logoTexture == nil then
|
|
|
return
|
|
return
|
|
|
- end
|
|
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
|
|
+ local ui = GetUI()
|
|
|
|
|
+ self.logoSprite = ui.root:CreateSprite()
|
|
|
|
|
+ --self.logoSprite.texture = logoTexture
|
|
|
|
|
+ self.logoSprite:SetTexture(logoTexture)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- logoSprite = ui.root:CreateSprite()
|
|
|
|
|
- logoSprite.texture = logoTexture
|
|
|
|
|
local textureWidth = logoTexture.width
|
|
local textureWidth = logoTexture.width
|
|
|
local textureHeight = logoTexture.height
|
|
local textureHeight = logoTexture.height
|
|
|
|
|
|
|
|
- logoSprite:SetScale(256 / textureWidth)
|
|
|
|
|
- logoSprite.size = IntVector2(textureWidth, textureHeight)
|
|
|
|
|
- logoSprite.hotSpot = IntVector2(0, textureHeight)
|
|
|
|
|
-
|
|
|
|
|
- logoSprite:SetAlignment(HA_LEFT, VA_BOTTOM);
|
|
|
|
|
|
|
+ self.logoSprite:SetScale(256 / textureWidth)
|
|
|
|
|
+ --self.logoSprite.size = IntVector2(textureWidth, textureHeight)
|
|
|
|
|
+ self.logoSprite:SetSize(textureWidth, textureHeight)
|
|
|
|
|
+ self.logoSprite.hotSpot = IntVector2(0, textureHeight)
|
|
|
|
|
+
|
|
|
|
|
+ self.logoSprite:SetAlignment(HA_LEFT, VA_BOTTOM);
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function CreateConsoleAndDebugHud()
|
|
|
|
|
|
|
+function Sample:CreateConsoleAndDebugHud()
|
|
|
|
|
+ local cache = GetCache()
|
|
|
local uiStyle = cache:GetXMLFile("UI/DefaultStyle.xml")
|
|
local uiStyle = cache:GetXMLFile("UI/DefaultStyle.xml")
|
|
|
if uiStyle == nil then
|
|
if uiStyle == nil then
|
|
|
return
|
|
return
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ local engine = GetEngine()
|
|
|
local console = engine:CreateConsole()
|
|
local console = engine:CreateConsole()
|
|
|
console.defaultStyle = uiStyle
|
|
console.defaultStyle = uiStyle
|
|
|
|
|
|
|
|
local debugHud = engine:CreateDebugHud()
|
|
local debugHud = engine:CreateDebugHud()
|
|
|
debugHud.defaultStyle = uiStyle
|
|
debugHud.defaultStyle = uiStyle
|
|
|
|
|
|
|
|
- SubscribeToEvent("KeyDown", "HandleKeyDownEventForSample")
|
|
|
|
|
|
|
+ SubscribeToEvent("KeyDown", "Sample.HandleKeyDownEvent")
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-function HandleKeyDownEventForSample(eventType, eventData)
|
|
|
|
|
|
|
+function Sample.HandleKeyDownEvent(eventType, eventData)
|
|
|
local key = eventData:GetInt("Key")
|
|
local key = eventData:GetInt("Key")
|
|
|
|
|
|
|
|
if key == KEY_ESC then
|
|
if key == KEY_ESC then
|
|
|
|
|
+ local ui = GetUI()
|
|
|
if ui:GetFocusElement() == nil then
|
|
if ui:GetFocusElement() == nil then
|
|
|
|
|
+ local engine = GetEngine()
|
|
|
engine:Exit()
|
|
engine:Exit()
|
|
|
else
|
|
else
|
|
|
local console = GetConsole()
|
|
local console = GetConsole()
|