• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MVC and thread-safety
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MVC and thread-safety


  • Subject: Re: MVC and thread-safety
  • From: Scott Anguish <email@hidden>
  • Date: Sun, 3 Nov 2002 18:05:01 -0500

one option might be to temporarily suspend drawing in the window before
you start the updates and then flush it..

it used to be possible to do that.. I'm assuming it still is..


On Sunday, November 3, 2002, at 06:01 PM, Steve Klingsporn wrote:

>
> It was very rare when they got out of sync, but calling display() on
> them seems to eliminate this.
> Here's the code. I realize it can be condensed some.
>
> /**
> Updates the score text fields
> **/
> public void updateScores()
> {
> int currentPlayer = mGame.getCurrentPlayer();
>
> /* Player one */
> String label = formattedScoreLabel(AtaxxGame.PLAYER_ONE);
> mPlayerOneScoreShadowField.setStringValue(label);
> mPlayerOneScoreField.setStringValue(label);
>
> if ((mGame.isGameOver() &&
> mGame.getScore(AtaxxGame.PLAYER_ONE) > 0) &&
> (mGame.getWinningPlayer() == AtaxxGame.PLAYER_ONE ||
> mGame.getWinningPlayer() == 0))
> {
> mPlayerOneScoreField.setTextColor(BLUE_COLOR);
> mPlayerOneScoreShadowField.setTextColor(WHITE_COLOR);
> }
> else if (! mGame.isGameOver() &&
> currentPlayer == AtaxxGame.PLAYER_ONE)
> {
> mPlayerOneScoreField.setTextColor(BLACK_COLOR);
> mPlayerOneScoreShadowField.setTextColor(GRAY_COLOR);
> }
> else
> {
> mPlayerOneScoreField.setTextColor(ETCHED_GRAY_COLOR);
> mPlayerOneScoreShadowField.setTextColor(WHITE_COLOR);
> }
> mPlayerOneScoreShadowField.display();
> mPlayerOneScoreField.display();
>
> /* Player two */
> label = formattedScoreLabel(AtaxxGame.PLAYER_TWO);
> mPlayerTwoScoreShadowField.setStringValue(label);
> mPlayerTwoScoreField.setStringValue(label);
> if ((mGame.isGameOver() &&
> mGame.getScore(AtaxxGame.PLAYER_TWO) > 0) &&
> (mGame.getWinningPlayer() == AtaxxGame.PLAYER_TWO ||
> mGame.getWinningPlayer() == 0))
> {
> mPlayerTwoScoreField.setTextColor(BLUE_COLOR);
> mPlayerTwoScoreShadowField.setTextColor(WHITE_COLOR);
> }
> else if (! mGame.isGameOver() &&
> currentPlayer == AtaxxGame.PLAYER_TWO)
> {
> mPlayerTwoScoreField.setTextColor(BLACK_COLOR);
> mPlayerTwoScoreShadowField.setTextColor(GRAY_COLOR);
> }
> else
> {
> mPlayerTwoScoreField.setTextColor(ETCHED_GRAY_COLOR);
> mPlayerTwoScoreShadowField.setTextColor(WHITE_COLOR);
> }
> mPlayerTwoScoreShadowField.display();
> mPlayerTwoScoreField.display();
> }
>
>
> Steve
>
> On Sunday, November 3, 2002, at 04:56 PM, Scott Anguish wrote:
>
>> although, this isn't the best way to do this... you could make a
>> simple TextField subclass that draws the text properly..
>>
>> why they aren't synced, I don't know. and when you say out of sync..
>> how out of sync are they?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: MVC and thread-safety
      • From: Steve Klingsporn <email@hidden>
References: 
 >Re: MVC and thread-safety (From: Steve Klingsporn <email@hidden>)

  • Prev by Date: Re: MVC and thread-safety
  • Next by Date: Re: MVC and thread-safety
  • Previous by thread: Re: MVC and thread-safety
  • Next by thread: Re: MVC and thread-safety
  • Index(es):
    • Date
    • Thread