Skip to content

Commit

Permalink
Merge pull request Revolutionary-Games#419 from Revolutionary-Games/T…
Browse files Browse the repository at this point in the history
…utorial_Squashed

Simple tutorial and organelle tooltips
  • Loading branch information
TheCreator-- committed Mar 11, 2016
2 parents f539ca7 + d5a6c30 commit 1e479ff
Show file tree
Hide file tree
Showing 10 changed files with 1,857 additions and 1,413 deletions.
214 changes: 107 additions & 107 deletions scripts/main_menu/main_menu_hud.lua
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
-- Updates the hud with relevant information
class 'MainMenuHudSystem' (System)

function MainMenuHudSystem:__init()
System.__init(self)
end

function MainMenuHudSystem:init(gameState)
System.init(self, "MainMenuHudSystem", gameState)
root = gameState:rootGUIWindow()
local microbeButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("NewGameButton")
local microbeEditorButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("EditorMenuButton")
local quitButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("ExitGameButton")
local loadButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton")
microbeButton:registerEventHandler("Clicked", mainMenuMicrobeStageButtonClicked)
microbeEditorButton:registerEventHandler("Clicked", mainMenuMicrobeEditorButtonClicked)
loadButton:registerEventHandler("Clicked", mainMenuLoadButtonClicked)
quitButton:registerEventHandler("Clicked", quitButtonClicked)
updateLoadButton();
self.videoPlayer = CEGUIVideoPlayer("IntroPlayer")
root:addChild( self.videoPlayer)
self.hasShownIntroVid = false
self.vidFadeoutStarted = false
self.skippedVideo = false

end

__soundTimer = 0
function MainMenuHudSystem:update(renderTime, logicTime)
if keyCombo(kmp.screenshot) then
Engine:screenShot("screenshot.png")
elseif keyCombo(kmp.skipvideo) then
if self.videoPlayer then
self.videoPlayer:pause()
self.videoPlayer:hide()
Entity("gui_sounds"):getComponent(SoundSourceComponent.TYPE_ID):interruptPlaying()
Entity("main_menu_ambience"):getComponent(SoundSourceComponent.TYPE_ID).autoLoop = true
self.skippedVideo = true
end
elseif keyCombo(kmp.forward) then

end
if self.videoPlayer then
self.videoPlayer:update()
if self.videoPlayer:getCurrentTime() >= self.videoPlayer:getDuration() - 3.0 then
if not self.vidFadeoutStarted then
self.videoPlayer:playAnimation("fadeout")
self.vidFadeoutStarted = true
end
if not self.skippedVideo and self.videoPlayer:getCurrentTime() >= self.videoPlayer:getDuration() then
self.videoPlayer:hide()
Entity("main_menu_ambience"):getComponent(SoundSourceComponent.TYPE_ID).autoLoop = true
end
else
__soundTimer = __soundTimer + 1
if __soundTimer == 2 then
-- cAudio gives an error if we play this first frame or in active or init
-- The manual playing of sound here is a temporary fix until we get the video player to play audio
Entity("gui_sounds"):getComponent(SoundSourceComponent.TYPE_ID):playSound("intro")
end
end
end
end

function MainMenuHudSystem:shutdown()
-- Necessary to avoid failed assert in ogre on exit
CEGUIVideoPlayer.destroyVideoPlayer(self.videoPlayer)
end

function MainMenuHudSystem:activate()
updateLoadButton();
if self.videoPlayer and not self.hasShownIntroVid then
self.videoPlayer:setVideo("intro.wmv")
self.hasShownIntroVid = true
self.videoPlayer:play()
end
end
function updateLoadButton()
if Engine:fileExists("quick.sav") then
root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton"):enable();
else
root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton"):disable();
end
end


function mainMenuLoadButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE)
Engine:load("quick.sav")
print("Game loaded");
end

function mainMenuMicrobeStageButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE)
end

function mainMenuMicrobeEditorButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE_EDITOR)
end

-- quitButtonClicked is already defined in microbe_stage_hud.lua
-- Updates the hud with relevant information
class 'MainMenuHudSystem' (System)

function MainMenuHudSystem:__init()
System.__init(self)
end

function MainMenuHudSystem:init(gameState)
System.init(self, "MainMenuHudSystem", gameState)
root = gameState:rootGUIWindow()
local microbeButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("NewGameButton")
local microbeEditorButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("EditorMenuButton")
local quitButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("ExitGameButton")
local loadButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton")
microbeButton:registerEventHandler("Clicked", mainMenuMicrobeStageButtonClicked)
microbeEditorButton:registerEventHandler("Clicked", mainMenuMicrobeEditorButtonClicked)
loadButton:registerEventHandler("Clicked", mainMenuLoadButtonClicked)
quitButton:registerEventHandler("Clicked", quitButtonClicked)
updateLoadButton();
self.videoPlayer = CEGUIVideoPlayer("IntroPlayer")
root:addChild( self.videoPlayer)
self.hasShownIntroVid = false
self.vidFadeoutStarted = false
self.skippedVideo = false

end

__soundTimer = 0
function MainMenuHudSystem:update(renderTime, logicTime)
if keyCombo(kmp.screenshot) then
Engine:screenShot("screenshot.png")
elseif keyCombo(kmp.skipvideo) then
if self.videoPlayer then
self.videoPlayer:pause()
self.videoPlayer:hide()
Entity("gui_sounds"):getComponent(SoundSourceComponent.TYPE_ID):interruptPlaying()
Entity("main_menu_ambience"):getComponent(SoundSourceComponent.TYPE_ID).autoLoop = true
self.skippedVideo = true
end
elseif keyCombo(kmp.forward) then

end
if self.videoPlayer then
self.videoPlayer:update()
if self.videoPlayer:getCurrentTime() >= self.videoPlayer:getDuration() - 3.0 then
if not self.vidFadeoutStarted then
self.videoPlayer:playAnimation("fadeout")
self.vidFadeoutStarted = true
end
if not self.skippedVideo and self.videoPlayer:getCurrentTime() >= self.videoPlayer:getDuration() then
self.videoPlayer:hide()
Entity("main_menu_ambience"):getComponent(SoundSourceComponent.TYPE_ID).autoLoop = true
end
else
__soundTimer = __soundTimer + 1
if __soundTimer == 2 then
-- cAudio gives an error if we play this first frame or in active or init
-- The manual playing of sound here is a temporary fix until we get the video player to play audio
Entity("gui_sounds"):getComponent(SoundSourceComponent.TYPE_ID):playSound("intro")
end
end
end
end

function MainMenuHudSystem:shutdown()
-- Necessary to avoid failed assert in ogre on exit
CEGUIVideoPlayer.destroyVideoPlayer(self.videoPlayer)
end

function MainMenuHudSystem:activate()
updateLoadButton();
if self.videoPlayer and not self.hasShownIntroVid then
self.videoPlayer:setVideo("intro.wmv")
self.hasShownIntroVid = true
self.videoPlayer:play()
end
end
function updateLoadButton()
if Engine:fileExists("quick.sav") then
root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton"):enable();
else
root:getChild("Background"):getChild("MainMenuInteractive"):getChild("LoadGameButton"):disable();
end
end


function mainMenuLoadButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE)
Engine:load("quick.sav")
print("Game loaded");
end

function mainMenuMicrobeStageButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE_TUTORIAL)
end

function mainMenuMicrobeEditorButtonClicked()
local guiSoundEntity = Entity("gui_sounds")
guiSoundEntity:getComponent(SoundSourceComponent.TYPE_ID):playSound("button-hover-click")
Engine:setCurrentGameState(GameState.MICROBE_EDITOR)
end

-- quitButtonClicked is already defined in microbe_stage_hud.lua
31 changes: 16 additions & 15 deletions scripts/manifest.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
colours.lua
constants.lua
quick_save.lua
util.lua

keymap.lua

main_menu
microbe_stage
microbe_editor
//sandbox

console.lua
console_commands.lua

colours.lua
constants.lua
quick_save.lua
util.lua

keymap.lua

main_menu
microbe_stage
microbe_stage_tutorial
microbe_editor
//sandbox

console.lua
console_commands.lua

Loading

0 comments on commit 1e479ff

Please sign in to comment.