Re: MVC and thread-safety
Re: MVC and thread-safety
- Subject: Re: MVC and thread-safety
- From: Steve Klingsporn <email@hidden>
- Date: Sun, 3 Nov 2002 17:06:10 -0600
When I do that, I see a lot of drawing anomalies in my window. =(
On Sunday, November 3, 2002, at 05:05 PM, Scott Anguish wrote:
>
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.