From b423ccc70198d2a73f991fc5a55f089d9e195082 Mon Sep 17 00:00:00 2001 From: jrags <> Date: Mon, 6 Mar 2006 02:38:22 +0000 Subject: Updated Hangman to use view controls --- .../pages/Fundamentals/Samples/Hangman/Home.page | 20 +++++++++------- .../pages/Fundamentals/Samples/Hangman/Home.php | 27 +++++++++------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.page b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.page index 977b2a04..6f5508d3 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.page +++ b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.page @@ -3,7 +3,9 @@

Hangman Game

- + + +

This is the game of Hangman. You must guess a word, a letter at a time. If you make too many mistakes, you lose the game!

@@ -13,9 +15,9 @@ If you make too many mistakes, you lose the game!

-
+ - +

Please make a guess

<%= $this->Page->GuessWord %>

You have made <%=$this->Page->Misses %> bad guesses @@ -49,18 +51,20 @@ out of a maximum of <%= $this->Page->Level %>.

-
+ - +

You Win!

The word was: <%= $this->Page->Word %>.

-
+ - +

You Lose!

The word was: <%= $this->Page->Word %>.

-
+ + + \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php index cbbd1c56..1d78186d 100644 --- a/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php +++ b/demos/quickstart/protected/pages/Fundamentals/Samples/Hangman/Home.php @@ -1,7 +1,12 @@ IsPostBack) + $this->GameMultiView->ActiveView=$this->IntroView; + } + public function selectLevel($sender,$param) { if(($selection=$this->LevelSelection->SelectedValue)==='') @@ -10,11 +15,11 @@ class Home extends TPage return; } else - $this->Level=TPropertyValue::ensureInteger($selection); + $this->Level=TPropertyValue::ensureInteger($selection); $this->Word=$this->generateWord(); $this->GuessWord=str_repeat('_',strlen($this->Word)); $this->Misses=0; - $this->showPanel('GuessPanel'); + $this->GameMultiView->ActiveView=$this->GuessView; } public function guessWord($sender,$param) @@ -35,7 +40,7 @@ class Home extends TPage { $this->GuessWord=$guessWord; if($guessWord===$word) - $this->showPanel('WinPanel'); + $this->GameMultiView->ActiveView=$this->WinView; } else { @@ -47,12 +52,12 @@ class Home extends TPage public function giveUp($sender,$param) { - $this->showPanel('LosePanel'); + $this->GameMultiView->ActiveView=$this->LoseView; } public function startAgain($sender,$param) { - $this->showPanel('IntroPanel'); + $this->GameMultiView->ActiveView=$this->IntroView; $this->LevelError->Visible=false; for($letter=65;$letter<=90;++$letter) { @@ -73,15 +78,6 @@ class Home extends TPage return strtoupper($word); } - protected function showPanel($panelID) - { - $this->IntroPanel->Visible=false; - $this->GuessPanel->Visible=false; - $this->WinPanel->Visible=false; - $this->LosePanel->Visible=false; - $this->$panelID->Visible=true; - } - public function setLevel($value) { $this->setViewState('Level',$value,0); @@ -122,5 +118,4 @@ class Home extends TPage return $this->getViewState('Misses',0); } } - ?> \ No newline at end of file -- cgit v1.2.3